linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Ilan Peer <ilan.peer@intel.com>
Subject: [PATCH 10/28] wifi: mac80211: Process association status for affiliated links
Date: Wed,  5 Oct 2022 15:00:30 +0200	[thread overview]
Message-ID: <20221005145226.ca9ee81680b3.I6c6b73b6c0433a3433a324945ef56a1244a11c65@changeid> (raw)
In-Reply-To: <20221005130048.217341-1-johannes@sipsolutions.net>

From: Ilan Peer <ilan.peer@intel.com>

In case the AP returned a non success status for one of the links,
do not activate the link.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/ieee80211_i.h |  2 ++
 net/mac80211/mlme.c        | 40 +++++++++++++++++++++++++++++++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 5dcbc8de53fd..517a50abdb09 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -412,6 +412,8 @@ struct ieee80211_mgd_assoc_data {
 		u8 *elems; /* pointing to inside ie[] below */
 
 		ieee80211_conn_flags_t conn_flags;
+
+		u16 status;
 	} link[IEEE80211_MLD_MAX_NUM_LINKS];
 
 	u8 ap_addr[ETH_ALEN] __aligned(2);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index a7e06c8ddaf3..2e4bb75c68c0 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2754,7 +2754,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
 		struct cfg80211_bss *cbss = assoc_data->link[link_id].bss;
 		struct ieee80211_link_data *link;
 
-		if (!cbss)
+		if (!cbss ||
+		    assoc_data->link[link_id].status != WLAN_STATUS_SUCCESS)
 			continue;
 
 		link = sdata_dereference(sdata->link[link_id], sdata);
@@ -2782,7 +2783,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
 			struct ieee80211_link_data *link;
 			struct cfg80211_bss *cbss = assoc_data->link[link_id].bss;
 
-			if (!cbss)
+			if (!cbss ||
+			    assoc_data->link[link_id].status != WLAN_STATUS_SUCCESS)
 				continue;
 
 			link = sdata_dereference(sdata->link[link_id], sdata);
@@ -3945,6 +3947,12 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
 
 	if (link_id == assoc_data->assoc_link_id) {
 		capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
+
+		/*
+		 * we should not get to this flow unless the association was
+		 * successful, so set the status directly to success
+		 */
+		assoc_data->link[link_id].status = WLAN_STATUS_SUCCESS;
 	} else if (!elems->prof) {
 		ret = false;
 		goto out;
@@ -3952,8 +3960,19 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
 		const u8 *ptr = elems->prof->variable +
 				elems->prof->sta_info_len - 1;
 
-		/* FIXME: need to also handle the status code */
+		/*
+		 * During parsing, we validated that these fields exist,
+		 * otherwise elems->prof would have been set to NULL.
+		 */
 		capab_info = get_unaligned_le16(ptr);
+		assoc_data->link[link_id].status = get_unaligned_le16(ptr + 2);
+
+		if (assoc_data->link[link_id].status != WLAN_STATUS_SUCCESS) {
+			link_info(link, "association response status code=%u\n",
+				  assoc_data->link[link_id].status);
+			ret = true;
+			goto out;
+		}
 	}
 
 	if (!is_s1g && !elems->supp_rates) {
@@ -4874,6 +4893,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
 	unsigned int link_id;
 	struct sta_info *sta;
 	u64 changed[IEEE80211_MLD_MAX_NUM_LINKS] = {};
+	u16 valid_links = 0;
 	int err;
 
 	mutex_lock(&sdata->local->sta_mtx);
@@ -4886,8 +4906,6 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
 		goto out_err;
 
 	if (sdata->vif.valid_links) {
-		u16 valid_links = 0;
-
 		for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
 			if (!assoc_data->link[link_id].bss)
 				continue;
@@ -4957,6 +4975,12 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
 						 &changed[link_id]))
 			goto out_err;
 
+		if (assoc_data->link[link_id].status != WLAN_STATUS_SUCCESS) {
+			valid_links &= ~BIT(link_id);
+			ieee80211_sta_remove_link(sta, link_id);
+			continue;
+		}
+
 		if (link_id != assoc_data->assoc_link_id) {
 			err = ieee80211_sta_activate_link(sta, link_id);
 			if (err)
@@ -4964,6 +4988,9 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
 		}
 	}
 
+	/* links might have changed due to rejected ones, set them again */
+	ieee80211_vif_set_links(sdata, valid_links);
+
 	rate_control_rate_init(sta);
 
 	if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) {
@@ -5197,10 +5224,13 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
 		link = sdata_dereference(sdata->link[link_id], sdata);
 		if (!link)
 			continue;
+
 		if (!assoc_data->link[link_id].bss)
 			continue;
+
 		resp.links[link_id].bss = assoc_data->link[link_id].bss;
 		resp.links[link_id].addr = link->conf->addr;
+		resp.links[link_id].status = assoc_data->link[link_id].status;
 
 		/* get uapsd queues configuration - same for all links */
 		resp.uapsd_queues = 0;
-- 
2.37.3


  parent reply	other threads:[~2022-10-05 13:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 13:00 [PATCH 00/28] wifi: further MLO work Johannes Berg
2022-10-05 13:00 ` [PATCH 01/28] wifi: mac80211: add pointer from link STA to STA Johannes Berg
2022-10-05 13:00 ` [PATCH 02/28] wifi: mac80211: add API to show the link STAs in debugfs Johannes Berg
2022-10-05 13:00 ` [PATCH 03/28] wifi: mac80211: include link address " Johannes Berg
2022-10-05 13:00 ` [PATCH 04/28] wifi: mac80211: recalc station aggregate data during link switch Johannes Berg
2022-10-05 13:00 ` [PATCH 05/28] wifi: cfg80211: support reporting failed links Johannes Berg
2022-10-06 10:49   ` Veerendranath Jakkam
2022-10-06 10:51     ` Johannes Berg
2022-10-06 11:09       ` Veerendranath Jakkam
2022-10-06 11:11         ` Johannes Berg
2022-10-06 14:40           ` Veerendranath Jakkam
2022-10-05 13:00 ` [PATCH 06/28] wifi: ieee80211: Support validating ML station profile length Johannes Berg
2022-10-05 13:00 ` [PATCH 07/28] wifi: cfg80211/mac80211: Fix ML element common size calculation Johannes Berg
2022-10-05 13:00 ` [PATCH 08/28] wifi: cfg80211/mac80211: Fix ML element common size validation Johannes Berg
2022-10-05 13:00 ` [PATCH 09/28] wifi: mac80211: Parse station profile from association response Johannes Berg
2022-10-05 13:00 ` Johannes Berg [this message]
2022-10-05 13:00 ` [PATCH 11/28] wifi: mac80211: wme: use ap_addr instead of deflink BSSID Johannes Berg
2022-10-05 13:00 ` [PATCH 12/28] wifi: mac80211: transmit AddBA with MLD address Johannes Berg
2022-10-05 13:00 ` [PATCH 13/28] wifi: nl80211: use link ID in NL80211_CMD_SET_BSS Johannes Berg
2022-10-05 13:00 ` [PATCH 14/28] wifi: mac80211: use link_id in ieee80211_change_bss() Johannes Berg
2022-10-05 13:00 ` [PATCH 15/28] wifi: mac80211: advertise TWT requester only with HW support Johannes Berg
2022-10-05 13:00 ` [PATCH 16/28] wifi: mac80211: set internal scan request BSSID Johannes Berg
2022-10-05 13:00 ` [PATCH 17/28] wifi: mac80211: fix AddBA response addressing Johannes Berg
2022-10-05 13:00 ` [PATCH 18/28] wifi: mac80211: add RCU _check() link access variants Johannes Berg
2022-10-05 13:00 ` [PATCH 19/28] wifi: fix multi-link element subelement iteration Johannes Berg
2022-10-05 13:00 ` [PATCH 20/28] wifi: mac80211: mlme: fix null-ptr deref on failed assoc Johannes Berg
2022-10-05 13:00 ` [PATCH 21/28] wifi: mac80211: check link ID in auth/assoc continuation Johannes Berg
2022-10-05 13:00 ` [PATCH 22/28] wifi: mac80211: mlme: mark assoc link in output Johannes Berg
2022-10-05 13:00 ` [PATCH 23/28] wifi: mac80211: change AddBA deny error message Johannes Berg
2022-10-05 13:00 ` [PATCH 24/28] wifi: mac80211: don't clear DTIM period after setting it Johannes Berg
2022-10-05 13:00 ` [PATCH 25/28] wifi: mac80211: prohibit IEEE80211_HT_CAP_DELAY_BA with MLO Johannes Berg
2022-10-05 13:00 ` [PATCH 26/28] wifi: mac80211: agg-rx: avoid band check Johannes Berg
2022-10-05 13:00 ` [PATCH 27/28] wifi: mac80211: remove support for AddBA with fragmentation Johannes Berg
2022-10-05 13:00 ` [PATCH 28/28] wifi: mac80211: fix ifdef symbol name Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221005145226.ca9ee81680b3.I6c6b73b6c0433a3433a324945ef56a1244a11c65@changeid \
    --to=johannes@sipsolutions.net \
    --cc=ilan.peer@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).