summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-12-29 13:59:50 +0000
committerjhb <jhb@FreeBSD.org>2006-12-29 13:59:50 +0000
commit67155fb0b2a1b3d5ee6f59198ae389f826754c66 (patch)
tree5677cbe8565b075c609dc8ea0a6087d8251a7bca /sys
parent89e0ae76db000800f893d800de9dcbf15519ff50 (diff)
downloadFreeBSD-src-67155fb0b2a1b3d5ee6f59198ae389f826754c66.zip
FreeBSD-src-67155fb0b2a1b3d5ee6f59198ae389f826754c66.tar.gz
Various bpf(4) related fixes to catch places up to the new bpf(4)
semantics. - Stop testing bpf pointers for NULL. In some cases use bpf_peers_present() and then call the function directly inside the conditional block instead of the macro. - For places where the entire conditional block is the macro, remove the test and make the macro unconditional. - Use BPF_MTAP() in if_pfsync on FreeBSD instead of an expanded version of the old semantics. Reviewed by: csjp (older version)
Diffstat (limited to 'sys')
-rw-r--r--sys/contrib/pf/net/if_pfsync.c4
-rw-r--r--sys/dev/arl/if_arl.c2
-rw-r--r--sys/dev/ce/if_ce.c8
-rw-r--r--sys/dev/cp/if_cp.c6
-rw-r--r--sys/dev/ctau/if_ct.c6
-rw-r--r--sys/dev/cx/if_cx.c6
-rw-r--r--sys/dev/en/midway.c4
-rw-r--r--sys/dev/firewire/if_fwip.c4
-rw-r--r--sys/dev/my/if_my.c4
-rw-r--r--sys/dev/ppbus/if_plip.c10
-rw-r--r--sys/i4b/driver/i4b_ipr.c8
-rw-r--r--sys/net/if_enc.c2
-rw-r--r--sys/netgraph/ng_sppp.c6
13 files changed, 33 insertions, 37 deletions
diff --git a/sys/contrib/pf/net/if_pfsync.c b/sys/contrib/pf/net/if_pfsync.c
index bec33e4..24687de 100644
--- a/sys/contrib/pf/net/if_pfsync.c
+++ b/sys/contrib/pf/net/if_pfsync.c
@@ -1793,9 +1793,13 @@ pfsync_sendout(sc)
KASSERT(m != NULL, ("pfsync_sendout: null mbuf"));
#endif
#if NBPFILTER > 0
+#ifdef __FreeBSD__
+ BPF_MTAP(ifp, m);
+#else
if (ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m);
#endif
+#endif
if (sc->sc_mbuf_net) {
m_freem(m);
diff --git a/sys/dev/arl/if_arl.c b/sys/dev/arl/if_arl.c
index 62d9afa..8be9bda 100644
--- a/sys/dev/arl/if_arl.c
+++ b/sys/dev/arl/if_arl.c
@@ -980,7 +980,7 @@ arl_read(sc, buf, len)
* Check if there's a bpf filter listening on this interface.
* If so, hand off the raw packet to bpf.
*/
- if (ifp->if_bpf) {
+ if (bpf_peers_present(ifp->if_bpf)) {
/*
* Note that the interface cannot be in promiscuous mode if
* there are no bpf listeners. And if el are in promiscuous
diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c
index b81d226..cf4204e 100644
--- a/sys/dev/ce/if_ce.c
+++ b/sys/dev/ce/if_ce.c
@@ -1070,10 +1070,10 @@ static void ce_send (drv_t *d)
if (! m)
return;
#ifndef NETGRAPH
- if (d->ifp->if_bpf)
#if __FreeBSD_version >= 500000
- BPF_MTAP (d->ifp, m);
+ BPF_MTAP (d->ifp, m);
#else
+ if (d->ifp->if_bpf)
bpf_mtap (d->ifp, m);
#endif
#endif
@@ -1192,10 +1192,10 @@ static void ce_receive (ce_chan_t *c, unsigned char *data, int len)
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->ifp->if_bpf)
#if __FreeBSD_version >= 500000
- BPF_TAP (d->ifp, data, len);
+ BPF_TAP (d->ifp, data, len);
#else
+ if (d->ifp->if_bpf)
bpf_tap (d->ifp, data, len);
#endif
IF_ENQUEUE(&d->rqueue, m);
diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c
index fefe9e6..fbd0b0e 100644
--- a/sys/dev/cp/if_cp.c
+++ b/sys/dev/cp/if_cp.c
@@ -833,8 +833,7 @@ static void cp_send (drv_t *d)
if (! m)
return;
#ifndef NETGRAPH
- if (d->ifp->if_bpf)
- BPF_MTAP (d->ifp, m);
+ BPF_MTAP (d->ifp, m);
#endif
len = m_length (m, NULL);
if (len >= BUFSZ)
@@ -943,8 +942,7 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->ifp->if_bpf)
- BPF_TAP (d->ifp, data, len);
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c
index d46ef89..7846334 100644
--- a/sys/dev/ctau/if_ct.c
+++ b/sys/dev/ctau/if_ct.c
@@ -1040,8 +1040,7 @@ static void ct_send (drv_t *d)
if (! m)
return;
#ifndef NETGRAPH
- if (d->ifp->if_bpf)
- BPF_MTAP (d->ifp, m);
+ BPF_MTAP (d->ifp, m);
#endif
len = m_length (m, NULL);
if (! m->m_next)
@@ -1161,8 +1160,7 @@ static void ct_receive (ct_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->ifp->if_bpf)
- BPF_TAP (d->ifp, data, len);
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c
index be136b3..4aa9829 100644
--- a/sys/dev/cx/if_cx.c
+++ b/sys/dev/cx/if_cx.c
@@ -1195,8 +1195,7 @@ static void cx_send (drv_t *d)
if (! m)
return;
#ifndef NETGRAPH
- if (d->ifp->if_bpf)
- BPF_MTAP (d->ifp, m);
+ BPF_MTAP (d->ifp, m);
#endif
len = m_length (m, NULL);
if (! m->m_next)
@@ -1352,8 +1351,7 @@ static void cx_receive (cx_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
- if (d->ifp->if_bpf)
- BPF_TAP (d->ifp, data, len);
+ BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c
index cfd8fd6..6732190 100644
--- a/sys/dev/en/midway.c
+++ b/sys/dev/en/midway.c
@@ -776,7 +776,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
sc->vccs[tx.vci]->obytes += tx.datalen;
#ifdef ENABLE_BPF
- if (sc->ifp->if_bpf != NULL) {
+ if (bpf_peers_present(sc->ifp->if_bpf)) {
/*
* adjust the top of the mbuf to skip the TBD if present
* before passing the packet to bpf.
@@ -794,7 +794,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
tx.m->m_pkthdr.len = tx.datalen;
}
- BPF_MTAP(sc->ifp, tx.m);
+ bpf_mtap(sc->ifp, tx.m);
}
#endif
diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index 0d7e5fe..c9587f0 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -838,7 +838,7 @@ fwip_stream_input(struct fw_xferq *xferq)
* Record the sender ID for possible BPF usage.
*/
src = ntohl(p[1]) >> 16;
- if (ifp->if_bpf) {
+ if (bpf_peers_present(ifp->if_bpf)) {
mtag = m_tag_alloc(MTAG_FIREWIRE,
MTAG_FIREWIRE_SENDER_EUID,
2*sizeof(uint32_t), M_NOWAIT);
@@ -939,7 +939,7 @@ fwip_unicast_input(struct fw_xfer *xfer)
return;
}
- if (ifp->if_bpf) {
+ if (bpf_peers_present(ifp->if_bpf)) {
/*
* Record the sender ID for possible BPF usage.
*/
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index b8f00d2..0e9d106 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -1161,8 +1161,8 @@ my_rxeof(struct my_softc * sc)
* broadcast packet, multicast packet, matches our ethernet
* address or the interface is in promiscuous mode.
*/
- if (ifp->if_bpf) {
- BPF_MTAP(ifp, m);
+ if (bpf_peers_present(ifp->if_bpf)) {
+ bpf_mtap(ifp, m);
if (ifp->if_flags & IFF_PROMISC &&
(bcmp(eh->ether_dhost, IF_LLADDR(sc->my_ifp),
ETHER_ADDR_LEN) &&
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 2af0fd1..df59f1b 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -455,7 +455,7 @@ static void
lptap(struct ifnet *ifp, struct mbuf *m)
{
u_int32_t af = AF_INET;
- BPF_MTAP2(ifp, &af, sizeof(af), m);
+ bpf_mtap2(ifp, &af, sizeof(af), m);
}
static void
@@ -514,7 +514,7 @@ lp_intr (void *arg)
sc->sc_ifp->if_ibytes += len;
top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp, 0);
if (top) {
- if (sc->sc_ifp->if_bpf)
+ if (bpf_peers_present(sc->sc_ifp->if_bpf))
lptap(sc->sc_ifp, top);
netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */
}
@@ -559,7 +559,7 @@ lp_intr (void *arg)
sc->sc_ifp->if_ibytes += len;
top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp, 0);
if (top) {
- if (sc->sc_ifp->if_bpf)
+ if (bpf_peers_present(sc->sc_ifp->if_bpf))
lptap(sc->sc_ifp, top);
netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */
}
@@ -694,7 +694,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
} else {
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
- if (ifp->if_bpf)
+ if (bpf_peers_present(ifp->if_bpf))
lptap(ifp, m);
}
@@ -739,7 +739,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
} else {
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
- if (ifp->if_bpf)
+ if (bpf_peers_present(ifp->if_bpf))
lptap(ifp, m);
}
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 537ef3d..c90e484 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -883,7 +883,7 @@ error:
}
#endif
- if(sc->sc_ifp->if_bpf)
+ if(bpf_peers_present(sc->sc_ifp->if_bpf))
{
/* prepend the address family as a four byte field */
struct mbuf mm;
@@ -891,7 +891,7 @@ error:
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- BPF_MTAP(sc->sc_ifp, &mm);
+ bpf_mtap(sc->sc_ifp, &mm);
}
if(netisr_queue(NETISR_IP, m)) /* (0) on success. */
@@ -936,7 +936,7 @@ ipr_tx_queue_empty(int unit)
microtime(&sc->sc_ifp->if_lastchange);
- if(sc->sc_ifp->if_bpf)
+ if(bpf_peers_present(sc->sc_ifp->if_bpf))
{
/* prepend the address family as a four byte field */
@@ -945,7 +945,7 @@ ipr_tx_queue_empty(int unit)
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- BPF_MTAP(sc->sc_ifp, &mm);
+ bpf_mtap(sc->sc_ifp, &mm);
}
#if I4BIPRACCT
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index 3875689..e8d279c 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -280,7 +280,7 @@ ipsec_bpf(struct mbuf *m, struct secasvar *sav, int af)
if ((encif->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
- if (encif->if_bpf) {
+ if (bpf_peers_present(encif->if_bpf)) {
flags = 0;
if (sav->alg_enc != SADB_EALG_NONE)
flags |= M_CONF;
diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c
index efe5c91..988de2e 100644
--- a/sys/netgraph/ng_sppp.c
+++ b/sys/netgraph/ng_sppp.c
@@ -219,8 +219,7 @@ ng_sppp_start (struct ifnet *ifp)
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
while ((m = sppp_dequeue (ifp)) != NULL) {
- if (ifp->if_bpf)
- BPF_MTAP (ifp, m);
+ BPF_MTAP (ifp, m);
len = m->m_pkthdr.len;
NG_SEND_DATA_ONLY (error, priv->hook, m);
@@ -382,8 +381,7 @@ ng_sppp_rcvdata (hook_p hook, item_p item)
m->m_pkthdr.rcvif = SP2IFP(pp);
/* Berkeley packet filter */
- if (SP2IFP(pp)->if_bpf)
- BPF_MTAP (SP2IFP(pp), m);
+ BPF_MTAP (SP2IFP(pp), m);
/* Send packet */
sppp_input (SP2IFP(pp), m);
OpenPOWER on IntegriCloud