Skip to contentSkip to conversation

mac80211: ensure association req uses configured ratemask.

PATCH In review [email protected] 1 participant 2 messages Sep 18, 2015 – Sep 23, 2015 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: ensure association req uses configured ratemask.

From: Ben Greear <[email protected]>

When sending the association request, pay attention to the legacy rates configured by the user, and do not advertise support for any that are not configured.

This makes the assoc request packet look more correct when making modern hardware act like a /b mode station, for instance.

---
 net/mac80211/ieee80211_i.h |  2 +-
 net/mac80211/mlme.c        | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 3 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
index 2c3842e..b6042f2 100644
@@ -388,7 +388,7 @@ struct ieee80211_mgd_auth_data {
 
 struct ieee80211_mgd_assoc_data {
 	struct cfg80211_bss *bss;
-	const u8 *supp_rates;
+	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
 
 	unsigned long timeout;
 	int tries;
net/mac80211/mlme.c +34 -2
index 83c445b4..bce467c 100644
@@ -635,6 +635,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 						     assoc_data->supp_rates_len,
 						     &rates);
 	} else {
+		u32 msk = sdata->cfg_bitrate_mask.control[chan->band].legacy;
+
 		/*
 		 * In case AP not provide any supported rates information
 		 * before association, we send information element(s) with
@@ -645,6 +647,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 			if ((rate_flags & sband->bitrates[i].flags)
 			    != rate_flags)
 				continue;
+			if (sdata->cfg_bitrate_mask_set &&
+			    (!(msk & (1 << i))))
+				continue;
 			rates |= BIT(i);
 			rates_len++;
 		}
@@ -4735,8 +4740,35 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
 		sdata->smps_mode = ifmgd->req_smps;
 
 	assoc_data->capability = req->bss->capability;
-	assoc_data->supp_rates = bss->supp_rates;
-	assoc_data->supp_rates_len = bss->supp_rates_len;
+	if (sdata->cfg_bitrate_mask_set) {
+		int band = req->bss->channel->band;
+		u32 msk = sdata->cfg_bitrate_mask.control[band].legacy;
+		u8 all_rates[12] = {0x82, 0x84, 0x8b, 0x96,
+				    12, 18, 24, 36, 48, 72, 96, 108};
+		int i;
+		int q = 0;
+
+		for (i = 0; i < 12; i++) {
+			int j;
+
+			if (!(msk & (1 << i)))
+				break;
+
+			for (j = 0; j < bss->supp_rates_len; j++) {
+				if (bss->supp_rates[j] == all_rates[i]) {
+					assoc_data->supp_rates[q] =
+						all_rates[i];
+					q++;
+					break;
+				}
+			}
+		}
+		assoc_data->supp_rates_len = q;
+	} else {
+		memcpy(assoc_data->supp_rates, bss->supp_rates,
+		       bss->supp_rates_len);
+		assoc_data->supp_rates_len = bss->supp_rates_len;
+	}
 
 	rcu_read_lock();
 	ht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_OPERATION);
Signature · 1 line
2.4.3
author
#1 lore raw
Quoted 28 lines · On 09/18/2015 04:43 PM, [email protected] wrote:

From: Ben Greear <[email protected]>

When sending the association request, pay attention to the legacy rates configured by the user, and do not advertise support for any that are not configured.

This makes the assoc request packet look more correct when making modern hardware act like a /b mode station, for instance.

  	assoc_data->capability = req->bss->capability;
net/mac80211/mlme.c +14 -2
-	assoc_data->supp_rates = bss->supp_rates;
-	assoc_data->supp_rates_len = bss->supp_rates_len;
+	if (sdata->cfg_bitrate_mask_set) {
+		int band = req->bss->channel->band;
+		u32 msk = sdata->cfg_bitrate_mask.control[band].legacy;
+		u8 all_rates[12] = {0x82, 0x84, 0x8b, 0x96,
+				    12, 18, 24, 36, 48, 72, 96, 108};
+		int i;
+		int q = 0;
+
+		for (i = 0; i < 12; i++) {
+			int j;
+
+			if (!(msk & (1 << i)))
+				break;
+

net/mac80211/mlme.c int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, · line 4766

Quoted 10 lines
net/mac80211/mlme.c +10 -0
+			for (j = 0; j < bss->supp_rates_len; j++) {
+				if (bss->supp_rates[j] == all_rates[i]) {
+					assoc_data->supp_rates[q] =
+						all_rates[i];
+					q++;
+					break;
+				}
+			}
+		}
+		assoc_data->supp_rates_len = q;

This logic is buggy in at least two ways...I'll re-post after I get this working better.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com