[PATCH 16/16] WNM: Scan for BSSID if there are forbidden neighbors

benjamin at sipsolutions.net benjamin at sipsolutions.net
Mon Apr 29 04:51:57 PDT 2024


From: Benjamin Berg <benjamin.berg at intel.com>

The test to scan for a single BSSID assumed that there is only a single
neighbor in the candidate list. Also do this optimization if there are
multiple neighbors but only one of them is valid.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
 wpa_supplicant/wnm_sta.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index b365fc4d3..f6443682b 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1262,8 +1262,11 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s)
 }
 
 static int wnm_parse_candidate_list(struct wpa_supplicant *wpa_s,
-				    const u8 *pos, const u8 *end)
+				    const u8 *pos, const u8 *end,
+				    int *num_valid_candidates)
 {
+	*num_valid_candidates = 0;
+
 	while (end - pos >= 2 &&
 	       wpa_s->wnm_num_neighbor_report < WNM_MAX_NEIGHBOR_REPORT)
 	{
@@ -1295,6 +1298,9 @@ static int wnm_parse_candidate_list(struct wpa_supplicant *wpa_s,
 			    ether_addr_equal(rep->bssid, wpa_s->bssid))
 				rep->disassoc_imminent = 1;
 
+			if (rep->preference_present && rep->preference)
+				*num_valid_candidates += 1;
+
 			wpa_s->wnm_num_neighbor_report++;
 #ifdef CONFIG_MBO
 			if (wpa_s->wnm_mbo_trans_reason_present &&
@@ -1323,6 +1329,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 	const u8 *vendor;
 #endif /* CONFIG_MBO */
 	bool disassoc_imminent;
+	int num_valid_candidates;
 
 	if (wpa_s->disable_mbo_oce || wpa_s->conf->disable_btm)
 		return;
@@ -1455,7 +1462,8 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 		wpas_mbo_ie_trans_req(wpa_s, vendor + 2, vendor[1]);
 #endif /* CONFIG_MBO */
 
-	if (wnm_parse_candidate_list(wpa_s, pos, end) < 0)
+	if (wnm_parse_candidate_list(wpa_s, pos, end,
+				     &num_valid_candidates) < 0)
 		goto reset;
 
 	if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED &&
@@ -1536,7 +1544,8 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 	}
 
 	wnm_set_scan_freqs(wpa_s);
-	if (wpa_s->wnm_num_neighbor_report == 1) {
+	if (num_valid_candidates == 1) {
+		/* Any invalid candidate was sorted to the end */
 		os_memcpy(wpa_s->next_scan_bssid,
 			  wpa_s->wnm_neighbor_report_elements[0].bssid,
 			  ETH_ALEN);
-- 
2.44.0




More information about the Hostap mailing list