diff --git a/sys/net/bpf.c b/sys/net/bpf.c index a04fdef..065e1e3 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -69,7 +69,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define BPF_INTERNAL #include #include #ifdef BPF_JITTER @@ -90,6 +89,20 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); +struct bpf_if { +#define bif_next bif_ext.bif_next +#define bif_dlist bif_ext.bif_dlist + struct bpf_if_ext bif_ext; /* public members */ + u_int bif_dlt; /* link layer type */ + u_int bif_hdrlen; /* length of link header */ + struct ifnet *bif_ifp; /* corresponding interface */ + struct rwlock bif_lock; /* interface lock */ + LIST_HEAD(, bpf_d) bif_wlist; /* writer-only list */ + int bif_flags; /* Interface flags */ +}; + +CTASSERT(offsetof(struct bpf_if, bif_ext) == 0); + #if defined(DEV_BPF) || defined(NETGRAPH_BPF) #define PRINET 26 /* interruptible */ @@ -1890,7 +1903,7 @@ bpf_setif(struct bpf_d *d, struct ifreq *ifr) /* Check if interface is not being detached from BPF */ BPFIF_RLOCK(bp); - if (bp->flags & BPFIF_FLAG_DYING) { + if (bp->bif_flags & BPFIF_FLAG_DYING) { BPFIF_RUNLOCK(bp); return (ENXIO); } @@ -2559,7 +2572,7 @@ bpfdetach(struct ifnet *ifp) * Mark bp as detached to restrict new consumers. */ BPFIF_WLOCK(bp); - bp->flags |= BPFIF_FLAG_DYING; + bp->bif_flags |= BPFIF_FLAG_DYING; BPFIF_WUNLOCK(bp); CTR4(KTR_NET, "%s: sheduling free for encap %d (%p) for if %p", diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 47cbb87..df326e6 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1451,21 +1451,14 @@ SYSCTL_DECL(_net_bpf); /* * Descriptor associated with each attached hardware interface. - * FIXME: this structure is exposed to external callers to speed up - * bpf_peers_present() call. However we cover all fields not needed by - * this function via BPF_INTERNAL define + * Part of this structure is exposed to external callers to speed up + * bpf_peers_present() calls. */ -struct bpf_if { +struct bpf_if; + +struct bpf_if_ext { LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */ LIST_HEAD(, bpf_d) bif_dlist; /* descriptor list */ -#ifdef BPF_INTERNAL - u_int bif_dlt; /* link layer type */ - u_int bif_hdrlen; /* length of link header */ - struct ifnet *bif_ifp; /* corresponding interface */ - struct rwlock bif_lock; /* interface lock */ - LIST_HEAD(, bpf_d) bif_wlist; /* writer-only list */ - int flags; /* Interface flags */ -#endif }; void bpf_bufheld(struct bpf_d *d); @@ -1483,8 +1476,10 @@ u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); static __inline int bpf_peers_present(struct bpf_if *bpf) { + struct bpf_if_ext *ext; - if (!LIST_EMPTY(&bpf->bif_dlist)) + ext = (struct bpf_if_ext *)bpf; + if (!LIST_EMPTY(&ext->bif_dlist)) return (1); return (0); }