athn(4) bpf tap short-preamble fix

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

athn(4) bpf tap short-preamble fix

Stefan Sperling-5
This fixes a cosmetic issue:

tcpdump -n -i athn0 -y IEEE802_11_RADIO shows a SHORTPRE flag on most frames
sent from athn0. Even for OFDM frames. Which is bogus because short preamble
only applies to non-OFDM frames with Tx rates 2, 5.5, and 11 MBit/s.

This is handled correctly when Tx configuration is provided to hardware
where we check Tx rate _and_ PHY type. But the PHY type check is missing
from the bpf tap code path, so add it there as well.

Index: ar5008.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
retrieving revision 1.46
diff -u -p -r1.46 ar5008.c
--- ar5008.c 28 Nov 2017 04:35:39 -0000 1.46
+++ ar5008.c 1 Feb 2019 13:52:55 -0000
@@ -1393,7 +1393,8 @@ ar5008_tx(struct athn_softc *sc, struct
  tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
  tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
  tap->wt_hwqueue = qid;
- if (ridx[0] != ATHN_RIDX_CCK1 &&
+ if (athn_rates[ridx[0]].phy == IEEE80211_T_DS &&
+    ridx[0] != ATHN_RIDX_CCK1 &&
     (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
  tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
  mb.m_data = (caddr_t)tap;
Index: ar9003.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/ar9003.c,v
retrieving revision 1.46
diff -u -p -r1.46 ar9003.c
--- ar9003.c 19 May 2017 11:42:48 -0000 1.46
+++ ar9003.c 1 Feb 2019 13:54:04 -0000
@@ -1482,7 +1482,8 @@ ar9003_tx(struct athn_softc *sc, struct
  tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
  tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
  tap->wt_hwqueue = qid;
- if (ridx[0] != ATHN_RIDX_CCK1 &&
+ if (athn_rates[ridx[0]].phy == IEEE80211_T_DS &&
+    ridx[0] != ATHN_RIDX_CCK1 &&
     (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
  tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
  mb.m_data = (caddr_t)tap;

Reply | Threaded
Open this post in threaded view
|

Re: athn(4) bpf tap short-preamble fix

Stefan Sperling-5
On Fri, Feb 01, 2019 at 03:22:41PM +0100, Stefan Sperling wrote:
> This fixes a cosmetic issue:
>
> tcpdump -n -i athn0 -y IEEE802_11_RADIO shows a SHORTPRE flag on most frames
> sent from athn0. Even for OFDM frames. Which is bogus because short preamble
> only applies to non-OFDM frames with Tx rates 2, 5.5, and 11 MBit/s.
>
> This is handled correctly when Tx configuration is provided to hardware
> where we check Tx rate _and_ PHY type. But the PHY type check is missing
> from the bpf tap code path, so add it there as well.

I've just committed this fix.

> Index: ar5008.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 ar5008.c
> --- ar5008.c 28 Nov 2017 04:35:39 -0000 1.46
> +++ ar5008.c 1 Feb 2019 13:52:55 -0000
> @@ -1393,7 +1393,8 @@ ar5008_tx(struct athn_softc *sc, struct
>   tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
>   tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
>   tap->wt_hwqueue = qid;
> - if (ridx[0] != ATHN_RIDX_CCK1 &&
> + if (athn_rates[ridx[0]].phy == IEEE80211_T_DS &&
> +    ridx[0] != ATHN_RIDX_CCK1 &&
>      (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
>   tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
>   mb.m_data = (caddr_t)tap;
> Index: ar9003.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ar9003.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 ar9003.c
> --- ar9003.c 19 May 2017 11:42:48 -0000 1.46
> +++ ar9003.c 1 Feb 2019 13:54:04 -0000
> @@ -1482,7 +1482,8 @@ ar9003_tx(struct athn_softc *sc, struct
>   tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
>   tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
>   tap->wt_hwqueue = qid;
> - if (ridx[0] != ATHN_RIDX_CCK1 &&
> + if (athn_rates[ridx[0]].phy == IEEE80211_T_DS &&
> +    ridx[0] != ATHN_RIDX_CCK1 &&
>      (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
>   tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
>   mb.m_data = (caddr_t)tap;
>