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

Function bpfattach2

freebsd/net/bpf.c:2682–2712  ·  view source on GitHub ↗

* Attach an interface to bpf. ifp is a pointer to the structure * defining the interface to be attached, dlt is the link layer type, * and hdrlen is the fixed size of the link header (variable length * headers are not yet supporrted). */

Source from the content-addressed store, hash-verified

2680 * headers are not yet supporrted).
2681 */
2682void
2683bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen,
2684 struct bpf_if **driverp)
2685{
2686 struct bpf_if *bp;
2687
2688 KASSERT(*driverp == NULL,
2689 ("bpfattach2: driverp already initialized"));
2690
2691 bp = malloc(sizeof(*bp), M_BPF, M_WAITOK | M_ZERO);
2692
2693 CK_LIST_INIT(&bp->bif_dlist);
2694 CK_LIST_INIT(&bp->bif_wlist);
2695 bp->bif_ifp = ifp;
2696 bp->bif_dlt = dlt;
2697 bp->bif_hdrlen = hdrlen;
2698 bp->bif_bpf = driverp;
2699 bp->bif_refcnt = 1;
2700 *driverp = bp;
2701 /*
2702 * Reference ifnet pointer, so it won't freed until
2703 * we release it.
2704 */
2705 if_ref(ifp);
2706 BPF_LOCK();
2707 CK_LIST_INSERT_HEAD(&bpf_iflist, bp, bif_next);
2708 BPF_UNLOCK();
2709
2710 if (bootverbose && IS_DEFAULT_VNET(curvnet))
2711 if_printf(ifp, "bpf attached\n");
2712}
2713
2714#ifdef VIMAGE
2715/*

Callers 2

bpfattachFunction · 0.85

Calls 3

mallocFunction · 0.85
if_refFunction · 0.85
if_printfFunction · 0.85

Tested by

no test coverage detected