Skip to contentSkip to conversation

mac80211: fix A-MSDU outer SA/DA

RFC In review Michael Braun 2 participants 2 messages Oct 7, 2016 – Oct 10, 2016 mac80211

lore
Share & tools
lore
#0 lore raw

RFC 1/1 mac80211: fix A-MSDU outer SA/DA

According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer SA/DA of A-MSDU frames need to be changed depending on FromDS/ToDS values.

---
 net/mac80211/tx.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
net/mac80211/tx.c +23 -1
index 5023966..87670b7 100644
@@ -3050,7 +3050,7 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
 	int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header);
 	int subframe_len = skb->len - hdr_len;
 	void *data;
-	u8 *qc;
+	u8 *qc, *bssid;
 
 	if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
 		return false;
@@ -3062,10 +3062,32 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
 					 &subframe_len))
 		return false;
 
+	switch (sdata->vif.type) {
+	case NL80211_IFTYPE_STATION:
+		bssid = sdata->u.mgd.bssid;
+		break;
+	case NL80211_IFTYPE_AP:
+	case NL80211_IFTYPE_AP_VLAN:
+		bssid = sdata->vif.addr;
+		break;
+	default:
+		bssid = NULL;
+	}
+
 	amsdu_hdr.h_proto = cpu_to_be16(subframe_len);
 	memcpy(amsdu_hdr.h_source, skb->data + fast_tx->sa_offs, ETH_ALEN);
 	memcpy(amsdu_hdr.h_dest, skb->data + fast_tx->da_offs, ETH_ALEN);
 
+	/* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA
+	 * fields needs to be changed to BSSID for A-MSDU frames depending
+	 * on FromDS/ToDS values.
+	 */
+	hdr = data;
+	if (bssid && (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FROMDS)))
+		memcpy(amsdu_hdr.h_source, bssid, ETH_ALEN);
+	if (bssid && (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_TODS)))
+		memcpy(amsdu_hdr.h_dest, bssid, ETH_ALEN);
+
 	data = skb_push(skb, sizeof(amsdu_hdr));
 	memmove(data, data + sizeof(amsdu_hdr), hdr_len);
 	memcpy(data + hdr_len, &amsdu_hdr, sizeof(amsdu_hdr));
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 15 lines

(quoted diff) +1 -0
+	/* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer

SA/DA

(quoted diff) +1 -0
+	 * fields needs to be changed to BSSID for A-MSDU frames

depending

net/mac80211/tx.c +4 -0
+	 * on FromDS/ToDS values.
+	 */
+	hdr = data;
+	if (bssid && (hdr->frame_control &

cpu_to_le16(IEEE80211_FCTL_FROMDS)))

(quoted diff) +2 -0
+		memcpy(amsdu_hdr.h_source, bssid, ETH_ALEN);
+	if (bssid && (hdr->frame_control &

cpu_to_le16(IEEE80211_FCTL_TODS)))

net/mac80211/tx.c static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata, · line 3089

Quoted 1 line
net/mac80211/tx.c +1 -0
+		memcpy(amsdu_hdr.h_dest, bssid, ETH_ALEN);

You should probably use ieee80211_has_tods() and ieee80211_has_fromds()

johannes