summaryrefslogtreecommitdiffstats
path: root/sys/dev
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/dev
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/dev')
-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
9 files changed, 22 insertions, 28 deletions
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);
}
OpenPOWER on IntegriCloud