Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Mar 2019 14:18:03 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345754 - head/sys/dev/usb/wlan
Message-ID:  <201903311418.x2VEI3ma087610@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Sun Mar 31 14:18:02 2019
New Revision: 345754
URL: https://svnweb.freebsd.org/changeset/base/345754

Log:
  run(4): properly set F_DATAPAD radiotap flag if frame has padding between
  frame header and data.
  
  This will fix 'Mysterious OLPC stuff' for received frames and wrong
  CCMP / TKIP / data decoding for transmitted frames in net/wireshark
  dissector.
  
  While here, drop unneeded comment - net80211 handles padding requirements
  for Tx & Rx without driver adjustment.
  
  Tested with D-Link DWA-140 rev B3, STA mode.
  
  MFC after:	1 week

Modified:
  head/sys/dev/usb/wlan/if_run.c

Modified: head/sys/dev/usb/wlan/if_run.c
==============================================================================
--- head/sys/dev/usb/wlan/if_run.c	Sun Mar 31 13:41:20 2019	(r345753)
+++ head/sys/dev/usb/wlan/if_run.c	Sun Mar 31 14:18:02 2019	(r345754)
@@ -2851,10 +2851,6 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin
 	}
 
 	if (flags & RT2860_RX_L2PAD) {
-		/*
-		 * XXX OpenBSD removes padding between header
-		 * and payload here...
-		 */
 		RUN_DPRINTF(sc, RUN_DEBUG_RECV,
 		    "received RT2860_RX_L2PAD frame\n");
 		len += 2;
@@ -2896,6 +2892,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin
 		uint16_t phy;
 
 		tap->wr_flags = 0;
+		if (flags & RT2860_RX_L2PAD)
+			tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD;
 		tap->wr_antsignal = rssi;
 		tap->wr_antenna = ant;
 		tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant);
@@ -3162,14 +3160,23 @@ tr_setup:
 
 		vap = data->ni->ni_vap;
 		if (ieee80211_radiotap_active_vap(vap)) {
+			const struct ieee80211_frame *wh;
 			struct run_tx_radiotap_header *tap = &sc->sc_txtap;
 			struct rt2860_txwi *txwi = 
 			    (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd));
+			int has_l2pad;
+
+			wh = mtod(m, struct ieee80211_frame *);
+			has_l2pad = IEEE80211_HAS_ADDR4(wh) !=
+			    IEEE80211_QOS_HAS_SEQ(wh);
+
 			tap->wt_flags = 0;
 			tap->wt_rate = rt2860_rates[data->ridx].rate;
 			tap->wt_hwqueue = index;
 			if (le16toh(txwi->phy) & RT2860_PHY_SHPRE)
 				tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
+			if (has_l2pad)
+				tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD;
 
 			ieee80211_radiotap_tx(vap, m);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903311418.x2VEI3ma087610>