MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bpf_setdlt

Function bpf_setdlt

freebsd/net/bpf.c:2820–2856  ·  view source on GitHub ↗

* Set the data link type of a BPF instance. */

Source from the content-addressed store, hash-verified

2818 * Set the data link type of a BPF instance.
2819 */
2820static int
2821bpf_setdlt(struct bpf_d *d, u_int dlt)
2822{
2823 int error, opromisc;
2824 struct ifnet *ifp;
2825 struct bpf_if *bp;
2826
2827 BPF_LOCK_ASSERT();
2828 MPASS(d->bd_bif != NULL);
2829
2830 /*
2831 * It is safe to check bd_bif without BPFD_LOCK, it can not be
2832 * changed while we hold global lock.
2833 */
2834 if (d->bd_bif->bif_dlt == dlt)
2835 return (0);
2836
2837 ifp = d->bd_bif->bif_ifp;
2838 CK_LIST_FOREACH(bp, &bpf_iflist, bif_next) {
2839 if (bp->bif_ifp == ifp && bp->bif_dlt == dlt)
2840 break;
2841 }
2842 if (bp == NULL)
2843 return (EINVAL);
2844
2845 opromisc = d->bd_promisc;
2846 bpf_attachd(d, bp);
2847 if (opromisc) {
2848 error = ifpromisc(bp->bif_ifp, 1);
2849 if (error)
2850 if_printf(bp->bif_ifp, "%s: ifpromisc failed (%d)\n",
2851 __func__, error);
2852 else
2853 d->bd_promisc = 1;
2854 }
2855 return (0);
2856}
2857
2858static void
2859bpf_drvinit(void *unused)

Callers 1

bpfioctlFunction · 0.85

Calls 3

bpf_attachdFunction · 0.85
ifpromiscFunction · 0.85
if_printfFunction · 0.85

Tested by

no test coverage detected