diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index d4877495070c..d849be11c798 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -103,12 +103,7 @@ #include #endif -#include "bpfilter.h" - -#if NBPFILTER > 0 #include -#include -#endif /* This struct describes one address family */ struct iffam { @@ -135,7 +130,7 @@ const static struct iffam gFamilies[] = { NG_IFACE_HOOK_INET, AF_INET, NETISR_NONE, - ip_input + { ip_input } }, #endif #ifdef NETATALK @@ -143,7 +138,7 @@ const static struct iffam gFamilies[] = { NG_IFACE_HOOK_ATALK, AF_APPLETALK, NETISR_ATALK, - &atintrq2 + { &atintrq2 } }, #endif #ifdef IPX @@ -151,7 +146,7 @@ const static struct iffam gFamilies[] = { NG_IFACE_HOOK_IPX, AF_IPX, NETISR_IPX, - &ipxintrq + { &ipxintrq } }, #endif #ifdef NS @@ -159,7 +154,7 @@ const static struct iffam gFamilies[] = { NG_IFACE_HOOK_NS, AF_NS, NETISR_NS, - &nsintrq + { &nsintrq } }, #endif }; @@ -179,9 +174,7 @@ static void ng_iface_start(struct ifnet *ifp); static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int ng_iface_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct rtentry *rt0); -#if NBPFILTER > 0 static void ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, u_int af); -#endif #ifdef DEBUG static void ng_iface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data); #endif @@ -373,9 +366,7 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m, } /* Berkeley packet filter */ -#if NBPFILTER > 0 ng_iface_bpftap(ifp, m, dst->sa_family); -#endif /* Check address family to determine hook (if known) */ if (iffam == NULL) { @@ -409,7 +400,6 @@ ng_iface_start(struct ifnet *ifp) printf("%s%d: %s called?", ifp->if_name, ifp->if_unit, __FUNCTION__); } -#if NBPFILTER > 0 /* * Flash a packet by the BPF (requires prepending 4 byte AF header) * Note the phoney mbuf; this is OK because BPF treats it read-only. @@ -419,20 +409,21 @@ ng_iface_bpftap(struct ifnet *ifp, struct mbuf *m, u_int af) { struct mbuf m2; - if (af == AF_UNSPEC) { - af = *(mtod(m, int *)); - m->m_len -= sizeof(int); - m->m_pkthdr.len -= sizeof(int); - m->m_data += sizeof(int); + if (ifp->if_bpf) { + if (af == AF_UNSPEC) { + af = *(mtod(m, int *)); + m->m_len -= sizeof(int); + m->m_pkthdr.len -= sizeof(int); + m->m_data += sizeof(int); + } + if (!ifp->if_bpf) + return; + m2.m_next = m; + m2.m_len = 4; + m2.m_data = (char *) ⁡ + bpf_mtap(ifp, &m2); } - if (!ifp->if_bpf) - return; - m2.m_next = m; - m2.m_len = 4; - m2.m_data = (char *) ⁡ - bpf_mtap(ifp, &m2); } -#endif /* NBPFILTER > 0 */ #ifdef DEBUG /* @@ -536,9 +527,7 @@ ng_iface_constructor(node_p *nodep) /* Attach the interface */ if_attach(ifp); -#if NBPFILTER > 0 bpfattach(ifp, DLT_NULL, sizeof(u_int)); -#endif /* Done */ return (0); @@ -713,10 +702,8 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) /* Note receiving interface */ m->m_pkthdr.rcvif = ifp; -#if NBPFILTER > 0 /* Berkeley packet filter */ ng_iface_bpftap(ifp, m, iffam->af); -#endif /* Ignore any meta-data */ NG_FREE_META(meta);