[PATCH 14/16] WNM: Always parse candidate list

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

 



From: Benjamin Berg <benjamin.berg@xxxxxxxxx>

The candidate list included bit just makes parsing the list mandatory.
The AP may still include a candidate list which we should use to be able
to optimize scanning. As such, always parse out the list but still
verify that if the list is not empty if the bit is set.

Signed-off-by: Benjamin Berg <benjamin.berg@xxxxxxxxx>
---
 wpa_supplicant/wnm_sta.c | 48 ++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index f4986a3bc..b365fc4d3 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1264,12 +1264,6 @@ 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)
 {
-	wpa_s->wnm_neighbor_report_elements = os_calloc(
-		WNM_MAX_NEIGHBOR_REPORT,
-		sizeof(struct neighbor_report));
-	if (wpa_s->wnm_neighbor_report_elements == NULL)
-		return -1;
-
 	while (end - pos >= 2 &&
 	       wpa_s->wnm_num_neighbor_report < WNM_MAX_NEIGHBOR_REPORT)
 	{
@@ -1284,6 +1278,15 @@ static int wnm_parse_candidate_list(struct wpa_supplicant *wpa_s,
 		}
 		if (tag == WLAN_EID_NEIGHBOR_REPORT) {
 			struct neighbor_report *rep;
+
+			if (!wpa_s->wnm_num_neighbor_report) {
+				wpa_s->wnm_neighbor_report_elements = os_calloc(
+					WNM_MAX_NEIGHBOR_REPORT,
+					sizeof(struct neighbor_report));
+				if (wpa_s->wnm_neighbor_report_elements == NULL)
+					return -1;
+			}
+
 			rep = &wpa_s->wnm_neighbor_report_elements[
 				wpa_s->wnm_num_neighbor_report];
 			wnm_parse_neighbor_report(wpa_s, pos, len, rep);
@@ -1452,23 +1455,22 @@ 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 (wpa_s->wnm_mode & WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED) {
-		unsigned int valid_ms;
-
-		wpa_msg(wpa_s, MSG_INFO, "WNM: Preferred List Available");
+	if (wnm_parse_candidate_list(wpa_s, pos, end) < 0)
+		goto reset;
 
-		if (wnm_parse_candidate_list(wpa_s, pos, end) < 0)
-			goto reset;
+	if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED &&
+	    !wpa_s->wnm_num_neighbor_report) {
+		wpa_printf(MSG_DEBUG,
+			   "WNM: Candidate list included bit is set, but no candidates found");
+		wnm_send_bss_transition_mgmt_resp(
+			wpa_s, WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES,
+			MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0,
+			NULL);
+		goto reset;
+	}
 
-		if (!wpa_s->wnm_num_neighbor_report) {
-			wpa_printf(MSG_DEBUG,
-				   "WNM: Candidate list included bit is set, but no candidates found");
-			wnm_send_bss_transition_mgmt_resp(
-				wpa_s, WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES,
-				MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0,
-				NULL);
-			goto reset;
-		}
+	if (wpa_s->wnm_num_neighbor_report) {
+		unsigned int valid_ms;
 
 		wnm_sort_cand_list(wpa_s);
 		wnm_dump_cand_list(wpa_s);
@@ -1477,7 +1479,9 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 			   valid_ms);
 		os_get_reltime(&wpa_s->wnm_cand_valid_until);
 		os_reltime_add_ms(&wpa_s->wnm_cand_valid_until, valid_ms);
-	} else if (!disassoc_imminent) {
+	}
+
+	if (!wpa_s->wnm_num_neighbor_report && !disassoc_imminent) {
 		enum bss_trans_mgmt_status_code status;
 
 		/* No candidate list and disassociation is not imminent */
-- 
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