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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Benjamin Berg <benjamin.berg@xxxxxxxxx>

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@xxxxxxxxx>
---
 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


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux