summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-09-18 23:52:33 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-09-18 23:52:33 +0000
commit22d164e7696df2961cc7a4096fe32de4bf896f00 (patch)
tree0449e50d889f9cf9bc858aab5c5e288e23d46e6e
parentd73f1b98679b18a9a94da26db01bb9602a548fb8 (diff)
don't hand roll bpf_mtap_hdr functionality, just use bpf_mtap_hdr.
the radiotap code prepends a big struct to the packets, and wires them up with the packet by putting an mbuf on the stack and using that as the head of an mbuf chain. bpf_mtap_hdr does the chain head thing for us, so shrink this code by calling the bpf function. there's some other drivers that do this too, so if anyone wants a free commit they should go looking in the other wireless drivers and do the same change. ok claudio@
-rw-r--r--sys/dev/pci/if_ipw.c22
-rw-r--r--sys/dev/pci/if_iwi.c22
-rw-r--r--sys/dev/pci/if_iwm.c22
-rw-r--r--sys/dev/pci/if_iwn.c22
-rw-r--r--sys/dev/pci/if_wpi.c22
5 files changed, 25 insertions, 85 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c
index 579db1f9780..b0e8a3e778e 100644
--- a/sys/dev/pci/if_ipw.c
+++ b/sys/dev/pci/if_ipw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ipw.c,v 1.124 2019/09/12 12:55:07 stsp Exp $ */
+/* $OpenBSD: if_ipw.c,v 1.125 2019/09/18 23:52:32 dlg Exp $ */
/*-
* Copyright (c) 2004-2008
@@ -879,7 +879,6 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct ipw_rx_radiotap_header *tap = &sc->sc_rxtap;
tap->wr_flags = 0;
@@ -887,13 +886,8 @@ ipw_data_intr(struct ipw_softc *sc, struct ipw_status *status,
tap->wr_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
tap->wr_chan_flags = htole16(ic->ic_ibss_chan->ic_flags);
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len,
+ m, BPF_DIRECTION_IN, NULL);
}
#endif
@@ -1156,20 +1150,14 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct ipw_tx_radiotap_header *tap = &sc->sc_txtap;
tap->wt_flags = 0;
tap->wt_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
tap->wt_chan_flags = htole16(ic->ic_ibss_chan->ic_flags);
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_txtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_txtap_len,
+ m, BPF_DIRECTION_OUT, NULL);
}
#endif
diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c
index be8d57baecd..8b5f9119a60 100644
--- a/sys/dev/pci/if_iwi.c
+++ b/sys/dev/pci/if_iwi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwi.c,v 1.141 2019/09/12 12:55:07 stsp Exp $ */
+/* $OpenBSD: if_iwi.c,v 1.142 2019/09/18 23:52:32 dlg Exp $ */
/*-
* Copyright (c) 2004-2008
@@ -923,7 +923,6 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data,
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwi_rx_radiotap_header *tap = &sc->sc_rxtap;
tap->wr_flags = 0;
@@ -937,13 +936,8 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data,
if (frame->antenna & 0x40)
tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len,
+ m, BPF_DIRECTION_IN, NULL);
}
#endif
@@ -1267,20 +1261,14 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni)
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwi_tx_radiotap_header *tap = &sc->sc_txtap;
tap->wt_flags = 0;
tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_txtap_len;
- mb.m_next = m0;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_txtap_len,
+ m0, BPF_DIRECTION_OUT, NULL);
}
#endif
diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c
index 20ce2cbe3d2..1c024bb0bcc 100644
--- a/sys/dev/pci/if_iwm.c
+++ b/sys/dev/pci/if_iwm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwm.c,v 1.250 2019/09/12 12:55:07 stsp Exp $ */
+/* $OpenBSD: if_iwm.c,v 1.251 2019/09/18 23:52:32 dlg Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -3510,7 +3510,6 @@ iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap;
uint16_t chan_flags;
@@ -3555,13 +3554,8 @@ iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
}
}
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len,
+ m, BPF_DIRECTION_IN, NULL);
}
#endif
ieee80211_inputm(IC2IFP(ic), m, ni, &rxi, ml);
@@ -4246,7 +4240,6 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac)
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwm_tx_radiotap_header *tap = &sc->sc_txtap;
uint16_t chan_flags;
@@ -4268,13 +4261,8 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac)
(wh->i_fc[1] & IEEE80211_FC1_PROTECTED))
tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_txtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_txtap_len,
+ m, BPF_DIRECTION_OUT, NULL);
}
#endif
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 553451c0e37..e4ca02e0398 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.216 2019/09/12 12:55:07 stsp Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.217 2019/09/18 23:52:32 dlg Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -2189,7 +2189,6 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
uint16_t chan_flags;
@@ -2227,13 +2226,8 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
}
}
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len,
+ m, BPF_DIRECTION_IN, NULL);
}
#endif
@@ -3262,7 +3256,6 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
rinfo = &iwn_rates[ridx];
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct iwn_tx_radiotap_header *tap = &sc->sc_txtap;
uint16_t chan_flags;
@@ -3283,13 +3276,8 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
(wh->i_fc[1] & IEEE80211_FC1_PROTECTED))
tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_txtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_txtap_len,
+ m, BPF_DIRECTION_OUT, NULL);
}
#endif
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index d5f72492c2c..cbf2b816a62 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.147 2019/09/12 12:55:07 stsp Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.148 2019/09/18 23:52:32 dlg Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -1298,7 +1298,6 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc,
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap;
tap->wr_flags = 0;
@@ -1331,13 +1330,8 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc,
default: tap->wr_rate = 0;
}
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_rxtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_rxtap_len,
+ m, BPF_DIRECTION_IN, NULL);
}
#endif
@@ -1705,7 +1699,6 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {
- struct mbuf mb;
struct wpi_tx_radiotap_header *tap = &sc->sc_txtap;
tap->wt_flags = 0;
@@ -1717,13 +1710,8 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
(wh->i_fc[1] & IEEE80211_FC1_PROTECTED))
tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
- mb.m_data = (caddr_t)tap;
- mb.m_len = sc->sc_txtap_len;
- mb.m_next = m;
- mb.m_nextpkt = NULL;
- mb.m_type = 0;
- mb.m_flags = 0;
- bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ bpf_mtap_hdr(sc->sc_drvbpf, tap, sc->sc_txtap_len,
+ m, BPF_DIRECTION_OUT, NULL);
}
#endif