From patchwork Mon Apr 29 11:51:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1928953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=rCa92eJw; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=rczNFvEN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VShXj3sQKz1ymX for ; Mon, 29 Apr 2024 21:52:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WvAgLxaXLO8tiSN0d1CCexKeYMZm2sY1obK9ipCKDQ8=; b=rCa92eJwqlddIN BXd25JNizKwCxGtpKiJPJeCb8+xyvjF8RIvmRIdTfxCFh0ojI2DkNY0kJx48Utq87WlkTkiVTt81h SWBQIxv0pCabwCyIl4VPSRgyukai7KhBXq2sNrtSCosLr48Azz9OWj5Yx2gF4Ohmy0RPRbiiqajcq 78Uhn40Y3x5YsEWnCTs7nQLZZS3bECmp86/qX8Mn7BWjjfGpoymyl//Dfvw4JaI7amXo0nKu/rnfV S3reKH7lRKew6LP1snNU33XF/P9Xa55y15GJUsKGdQEXmx+2UcYXlyV7QE6VsKtuR4ygq8QImN8Sp KZEPjeedZgcDJa6T+LKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PYh-00000002XLS-3sPG; Mon, 29 Apr 2024 11:52:35 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PYP-00000002XBz-246j for hostap@lists.infradead.org; Mon, 29 Apr 2024 11:52:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=DApanPiljC1/Kg9JjOvITeN2YTjMAqAdw+mkr7ieRM8=; t=1714391537; x=1715601137; b=rczNFvENVlEBE2x9+b6yYj4UElYlpO2+GynJHsxxDUy5mkj nouom84k+eoiB9zglF6uYfcYRz9lDJgCHC7nDLfYvP85SYrbhJmHK6VYvOcdzCikD0KZhXItl1Xgr NRs5BMEa2y3XtLSSxvybd4EvfLeYldRNv1Tk91CGGAllVFueLIcIL6giYAmywdy4p/l+hdh5eI1up Hps+zPrIvooqPDMbS02swvkqKqjGgCzbhHJc22mPRR+s8Ehajh3vfK0IJMC7RWorpJ0LV2ETMWhdw 6Kn+9p8SjRKP065Y9e1yvsiabCULKd7OjRW3DZ0Sz24vzqB7Um2+f9Ww5pW9IksQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1s1PYL-0000000CNIg-3pbd; Mon, 29 Apr 2024 13:52:15 +0200 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH 10/16] WNM: Use standard BSS selection and enable abridged bit handling Date: Mon, 29 Apr 2024 13:51:51 +0200 Message-ID: <20240429115157.211073-11-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429115157.211073-1-benjamin@sipsolutions.net> References: <20240429115157.211073-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_045217_777970_81592B70 X-CRM114-Status: GOOD ( 21.81 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg Most of the logic to reject BSSs during transition has been moved into wnm_is_bss_excluded. In addition to this, since commit 67bf89f55442 ("WNM: Choose the best available BSS, not just the first one" [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg Most of the logic to reject BSSs during transition has been moved into wnm_is_bss_excluded. In addition to this, since commit 67bf89f55442 ("WNM: Choose the best available BSS, not just the first one") we will simply choose the BSS with the best throughput. Overall, this matches the behaviour that the supplicant will use anyway in wpa_supplicant_select_bss. The only bigger difference is that using this will check all known BSSs instead of only the ones in the candidate list. This means that with this change the abridged bit is handled according to spec. Another slight change is that this drops the logic to reject candidates with a very low signal level. This does not seem to very relevant anymore as we prefere stronger BSSs to begin with. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 2 +- wpa_supplicant/wnm_sta.c | 129 +++--------------------------- wpa_supplicant/wpa_supplicant_i.h | 5 ++ 3 files changed, 18 insertions(+), 118 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 4505d9e15..31c807879 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1709,7 +1709,7 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, } -static struct wpa_bss * +struct wpa_bss * wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, struct wpa_ssid *group, struct wpa_ssid **selected_ssid, diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 64124348f..8c51b3ddb 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -693,117 +693,6 @@ fetch_drv_mbo_transition_candidate_info(struct wpa_supplicant *wpa_s) #endif /* CONFIG_MBO */ -static struct wpa_bss * find_better_target(struct wpa_bss *a, - struct wpa_bss *b) -{ - if (!a) - return b; - if (!b) - return a; - - if (a->est_throughput > b->est_throughput) { - wpa_printf(MSG_DEBUG, "WNM: A is better: " MACSTR - " est-tput: %d B: " MACSTR " est-tput: %d", - MAC2STR(a->bssid), a->est_throughput, - MAC2STR(b->bssid), b->est_throughput); - return a; - } - - wpa_printf(MSG_DEBUG, "WNM: B is better, A: " MACSTR - " est-tput: %d B: " MACSTR " est-tput: %d", - MAC2STR(a->bssid), a->est_throughput, - MAC2STR(b->bssid), b->est_throughput); - return b; -} - -static struct wpa_bss * -compare_scan_neighbor_results(struct wpa_supplicant *wpa_s, - enum mbo_transition_reject_reason *reason) -{ - u8 i; - struct wpa_bss *bss = wpa_s->current_bss; - struct wpa_bss *target; - struct wpa_bss *best_target = NULL; - struct wpa_bss *bss_in_list = NULL; - - if (!bss) - return NULL; - - wpa_printf(MSG_DEBUG, "WNM: Current BSS " MACSTR " RSSI %d", - MAC2STR(wpa_s->bssid), bss->level); - - for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { - struct neighbor_report *nei; - - nei = &wpa_s->wnm_neighbor_report_elements[i]; - - target = wpa_bss_get_bssid(wpa_s, nei->bssid); - if (!target) { - wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR - " (pref %d) not found in scan results", - MAC2STR(nei->bssid), - nei->preference_present ? nei->preference : - -1); - continue; - } - - /* - * TODO: Could consider allowing transition to another ESS if - * PMF was enabled for the association. - */ - if (!wpa_scan_res_match(wpa_s, 0, target, wpa_s->current_ssid, - 1, 0)) { - wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR - " (pref %d) does not match the current network profile", - MAC2STR(nei->bssid), - nei->preference_present ? nei->preference : - -1); - continue; - } - - if (target->level < bss->level && target->level < -80) { - wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR - " (pref %d) does not have sufficient signal level (%d)", - MAC2STR(nei->bssid), - nei->preference_present ? nei->preference : - -1, - target->level); - continue; - } - - best_target = find_better_target(target, best_target); - if (target == bss) - bss_in_list = bss; - } - - target = best_target; - - if (!target) - return NULL; - - wpa_printf(MSG_DEBUG, - "WNM: Found an acceptable preferred transition candidate BSS " - MACSTR " (RSSI %d, tput: %d bss-tput: %d)", - MAC2STR(target->bssid), target->level, - target->est_throughput, bss->est_throughput); - - if (!bss_in_list) - return target; - - if ((!target->est_throughput && !bss_in_list->est_throughput) || - (target->est_throughput > bss_in_list->est_throughput && - target->est_throughput - bss_in_list->est_throughput > - bss_in_list->est_throughput >> 4)) { - /* It is more than 100/16 percent better, so switch. */ - return target; - } - - wpa_printf(MSG_DEBUG, - "WNM: Stay with our current BSS, not enough change in estimated throughput to switch"); - return bss_in_list; -} - - static int wpa_bss_ies_eq(struct wpa_bss *a, struct wpa_bss *b, u8 eid) { const u8 *ie_a, *ie_b; @@ -1121,11 +1010,12 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) { - struct wpa_bss *bss; + struct wpa_bss *bss, *current_bss = wpa_s->current_bss; struct wpa_ssid *ssid = wpa_s->current_ssid; enum bss_trans_mgmt_status_code status = WNM_BSS_TM_REJECT_UNSPECIFIED; enum mbo_transition_reject_reason reason = MBO_TRANSITION_REJECT_REASON_UNSPECIFIED; + struct wpa_ssid *selected_ssid = NULL; if (!wpa_s->wnm_dialog_token) return 0; @@ -1149,7 +1039,7 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) fetch_drv_mbo_candidate_info(wpa_s, &reason); /* Compare the Neighbor Report and scan results */ - bss = compare_scan_neighbor_results(wpa_s, &reason); + bss = wpa_supplicant_select_bss(wpa_s, ssid, &selected_ssid, 1); #ifdef CONFIG_MBO if (!bss && wpa_s->wnm_mbo_trans_reason_present && wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT) { @@ -1175,7 +1065,7 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) nei->drv_mbo_reject = 0; } - bss = compare_scan_neighbor_results(wpa_s, &reason); + bss = wpa_supplicant_select_bss(wpa_s, ssid, &selected_ssid, 1); } #endif /* CONFIG_MBO */ @@ -1200,9 +1090,8 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) return 0; #ifndef CONFIG_NO_ROAMING - if (wpa_s->current_bss && bss != wpa_s->current_bss && - wpa_supplicant_need_to_roam_within_ess(wpa_s, - wpa_s->current_bss, + if (current_bss && bss != current_bss && + wpa_supplicant_need_to_roam_within_ess(wpa_s, current_bss, bss)) return 0; #endif /* CONFIG_NO_ROAMING */ @@ -1214,6 +1103,12 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) goto send_bss_resp_fail; } + wpa_printf(MSG_DEBUG, + "WNM: Found an acceptable preferred transition candidate BSS " + MACSTR " (RSSI %d, tput: %d bss-tput: %d)", + MAC2STR(bss->bssid), bss->level, bss->est_throughput, + current_bss ? current_bss->est_throughput : -1); + /* Associate to the network */ wnm_bss_tm_connect(wpa_s, bss, ssid, 1); return 1; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d4a1284c3..64177546f 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1950,6 +1950,11 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, struct wpa_ssid *group, int only_first_ssid, int debug_print); +struct wpa_bss * wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, + struct wpa_ssid *group, + struct wpa_ssid **selected_ssid, + int only_first_ssid); + int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s, enum wpa_driver_if_type if_type, unsigned int *num,