[PATCH v3 2/3] WNM: Fix pre-scan rejection heuristic for BTM handling

Benjamin Berg benjamin at sipsolutions.net
Thu Sep 19 03:19:16 PDT 2024


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

The idea was to only accept the cached scan results if the new target is
reasonably good. To avoid having to write a custom quality logic, a call
to wpa_supplicant_need_to_roam_within_ess was used. However, the
intention was to swap the parameters and check whether we would want to
roam from the new BSS back to the current one.

Fix the heuristic to match the comment. To do that, we need to add a
parameter to not poll the current signal level as that would result in
comparing the current BSS with itself within the function.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
 wpa_supplicant/events.c           | 7 ++++---
 wpa_supplicant/wnm_sta.c          | 4 ++--
 wpa_supplicant/wpa_supplicant_i.h | 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 90e1c7b9fb..668068167f 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2163,7 +2163,8 @@ static int wpas_evaluate_band_score(int frequency)
 
 int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
 					   struct wpa_bss *current_bss,
-					   struct wpa_bss *selected)
+					   struct wpa_bss *selected,
+					   bool poll_current)
 {
 	int min_diff, diff;
 	int cur_band_score, sel_band_score;
@@ -2218,7 +2219,7 @@ int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
 	 * scan results may be a bit old, since we can very quickly get fresh
 	 * information about our currently associated AP.
 	 */
-	if (wpa_drv_signal_poll(wpa_s, &si) == 0 &&
+	if (poll_current && wpa_drv_signal_poll(wpa_s, &si) == 0 &&
 	    (si.data.avg_beacon_signal || si.data.avg_signal)) {
 		/*
 		 * Normalize avg_signal to the RSSI over 20 MHz, as the
@@ -2391,7 +2392,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 
 #ifndef CONFIG_NO_ROAMING
 	return wpa_supplicant_need_to_roam_within_ess(wpa_s, current_bss,
-						      selected);
+						      selected, true);
 #else /* CONFIG_NO_ROAMING */
 	return 0;
 #endif /* CONFIG_NO_ROAMING */
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index 3638cd5433..dcef8053ee 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1195,9 +1195,9 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check)
 
 #ifndef CONFIG_NO_ROAMING
 		if (wpa_s->current_bss && bss != wpa_s->current_bss &&
-		    wpa_supplicant_need_to_roam_within_ess(wpa_s,
+		    wpa_supplicant_need_to_roam_within_ess(wpa_s, bss,
 							   wpa_s->current_bss,
-							   bss))
+							   false))
 			return 0;
 #endif /* CONFIG_NO_ROAMING */
 	}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 3f704ecfd9..7c51cdb20e 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1868,7 +1868,8 @@ void wpa_supplicant_update_channel_list(struct wpa_supplicant *wpa_s,
 					struct channel_list_changed *info);
 int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
 					   struct wpa_bss *current_bss,
-					   struct wpa_bss *seleceted);
+					   struct wpa_bss *selected,
+					   bool poll_current);
 void wpas_reset_mlo_info(struct wpa_supplicant *wpa_s);
 
 /* eap_register.c */
-- 
2.46.0




More information about the Hostap mailing list