From 9c97126576b7dfa84731aec3d2a54f9195da1cfe Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 8 Nov 2023 14:19:03 +0200 Subject: [PATCH] OWE: Optimize transition mode scan to use known channels If the currently available scan results include OWE transition mode BSS with an unknown SSID, optimize the following scan for OWE to use only the channels on which a known transition mode BSS has been seen. This is needed to be able to remove the design that updates BSS entries with the learned OWE SSID in manner that does not result in regression to scanning latencies. Signed-off-by: Jouni Malinen --- wpa_supplicant/events.c | 27 +++++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant.c | 5 +++++ wpa_supplicant/wpa_supplicant_i.h | 6 ++++++ 3 files changed, 38 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index ff9b5b50b..d41676747 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1600,6 +1600,22 @@ skip_assoc_disallow: #endif /* CONFIG_SAE_PK */ if (bss->ssid_len == 0) { +#ifdef CONFIG_OWE + const u8 *owe_ssid = NULL; + size_t owe_ssid_len = 0; + + owe_trans_ssid(wpa_s, bss, &owe_ssid, &owe_ssid_len); + if (owe_ssid && owe_ssid_len && + owe_ssid_len == ssid->ssid_len && + os_memcmp(owe_ssid, ssid->ssid, owe_ssid_len) == 0) { + if (debug_print) + wpa_dbg(wpa_s, MSG_DEBUG, + " skip - no SSID in BSS entry for a possible OWE transition mode BSS"); + int_array_add_unique(&wpa_s->owe_trans_scan_freq, + bss->freq); + return false; + } +#endif /* CONFIG_OWE */ if (debug_print) wpa_dbg(wpa_s, MSG_DEBUG, " skip - no SSID known for the BSS"); @@ -2556,6 +2572,10 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s, return 0; /* no normal connection on p2p_mgmt interface */ wpa_s->owe_transition_search = 0; +#ifdef CONFIG_OWE + os_free(wpa_s->owe_trans_scan_freq); + wpa_s->owe_trans_scan_freq = NULL; +#endif /* CONFIG_OWE */ selected = wpa_supplicant_pick_network(wpa_s, &ssid); #ifdef CONFIG_MESH @@ -2675,6 +2695,13 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s, "OWE: Use shorter wait during transition mode search"); timeout_sec = 0; timeout_usec = 500000; + if (wpa_s->owe_trans_scan_freq) { + os_free(wpa_s->next_scan_freqs); + wpa_s->next_scan_freqs = + wpa_s->owe_trans_scan_freq; + wpa_s->owe_trans_scan_freq = NULL; + timeout_usec = 100000; + } wpa_supplicant_req_new_scan(wpa_s, timeout_sec, timeout_usec); return 0; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 48f9bc506..972f54fcb 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -749,6 +749,11 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) #endif /* CONFIG_PASN */ wpas_scs_deinit(wpa_s); wpas_dscp_deinit(wpa_s); + +#ifdef CONFIG_OWE + os_free(wpa_s->owe_trans_scan_freq); + wpa_s->owe_trans_scan_freq = NULL; +#endif /* CONFIG_OWE */ } diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d3bd5e196..c3c766bbf 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1576,6 +1576,12 @@ struct wpa_supplicant { struct wpa_ssid *ml_connect_probe_ssid; struct wpa_bss *ml_connect_probe_bss; + +#ifdef CONFIG_OWE + /* An array of frequencies to scan for OWE transition mode BSSs when + * owe_transition_search == 1 */ + int *owe_trans_scan_freq; +#endif /* CONFIG_OWE */ };