diff options
author | sam <sam@FreeBSD.org> | 2003-12-28 03:56:00 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-12-28 03:56:00 +0000 |
commit | c165a87f8dfc070bceb68d9c3ff183ec2135e060 (patch) | |
tree | f663da0db11fcecb5ff2d3e93732492fb4d7bd29 /sys/dev/wi | |
parent | 853a4ae85d691a2f3500efc16c2eab14e3c117b0 (diff) | |
download | FreeBSD-src-c165a87f8dfc070bceb68d9c3ff183ec2135e060.zip FreeBSD-src-c165a87f8dfc070bceb68d9c3ff183ec2135e060.tar.gz |
o eliminate widespread on-stack mbuf use for bpf by introducing
a new bpf_mtap2 routine that does the right thing for an mbuf
and a variable-length chunk of data that should be prepended.
o while we're sweeping the drivers, use u_int32_t uniformly when
when prepending the address family (several places were assuming
sizeof(int) was 4)
o return M_ASSERTVALID to BPF_MTAP* now that all stack-allocated
mbufs have been eliminated; this may better be moved to the bpf
routines
Reviewed by: arch@ and several others
Diffstat (limited to 'sys/dev/wi')
-rw-r--r-- | sys/dev/wi/if_wi.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index 53086c3..a99f96f 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -947,17 +947,8 @@ wi_start(struct ifnet *ifp) frmhdr.wi_dat_len = htole16(m0->m_pkthdr.len); #if NBPFILTER > 0 if (sc->sc_drvbpf) { - struct mbuf *mb; - - MGETHDR(mb, M_DONTWAIT, m0->m_type); - if (mb != NULL) { - mb->m_next = m0; - mb->m_data = (caddr_t)&sc->sc_tx_th; - mb->m_len = sizeof(sc->sc_tx_th); - mb->m_pkthdr.len += mb->m_len; - bpf_mtap(sc->sc_drvbpf, mb); - m_free(mb); - } + bpf_mtap2(sc->sc_drvbpf, + &sc->sc_tx_th, sizeof(sc->sc_tx_th), m0); } #endif if (IFF_DUMPPKTS(ifp)) @@ -1496,29 +1487,16 @@ wi_rx_intr(struct wi_softc *sc) #if NBPFILTER > 0 if (sc->sc_drvbpf) { - struct mbuf *mb; - - /* XXX pre-allocate space when setting up recv's */ - MGETHDR(mb, M_DONTWAIT, m->m_type); - if (mb != NULL) { - /* XXX replace divide by table */ - sc->sc_rx_th.wr_rate = frmhdr.wi_rx_rate / 5; - sc->sc_rx_th.wr_antsignal = - WI_RSSI_TO_DBM(sc, frmhdr.wi_rx_signal); - sc->sc_rx_th.wr_antnoise = - WI_RSSI_TO_DBM(sc, frmhdr.wi_rx_silence); - sc->sc_rx_th.wr_time = - htole32((frmhdr.wi_rx_tstamp1 << 16) | - frmhdr.wi_rx_tstamp0); - - (void) m_dup_pkthdr(mb, m, M_DONTWAIT); - mb->m_next = m; - mb->m_data = (caddr_t)&sc->sc_rx_th; - mb->m_len = sizeof(sc->sc_rx_th); - mb->m_pkthdr.len += mb->m_len; - bpf_mtap(sc->sc_drvbpf, mb); - m_free(mb); - } + sc->sc_rx_th.wr_rate = frmhdr.wi_rx_rate / 5; + sc->sc_rx_th.wr_antsignal = + WI_RSSI_TO_DBM(sc, frmhdr.wi_rx_signal); + sc->sc_rx_th.wr_antnoise = + WI_RSSI_TO_DBM(sc, frmhdr.wi_rx_silence); + sc->sc_rx_th.wr_time = + htole32((frmhdr.wi_rx_tstamp1 << 16) | + frmhdr.wi_rx_tstamp0); + bpf_mtap2(sc->sc_drvbpf, + &sc->sc_rx_th, sizeof(sc->sc_rx_th), m); } #endif wh = mtod(m, struct ieee80211_frame *); |