[PATCH 4/9] WNM: Avoid staying on a BSS if it is being terminated

Benjamin Berg benjamin at sipsolutions.net
Fri Jul 18 04:01:00 PDT 2025


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

If a BSS termination is included in a BTM request, then it makes sense
to assume that the BSS is going to terminate even if disassociation
imminent is not (yet) set.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 tests/hwsim/test_wnm.py  |  2 +-
 wpa_supplicant/wnm_sta.c | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py
index cfe813e40b..103cada473 100644
--- a/tests/hwsim/test_wnm.py
+++ b/tests/hwsim/test_wnm.py
@@ -650,7 +650,7 @@ def test_wnm_bss_tm_req(dev, apdev):
                      req_mode=0x0a, dialog_token=3)
     req['payload'] += struct.pack("<BBQH", 4, 10, 0, 10)
     hapd.mgmt_tx(req)
-    resp = rx_bss_tm_resp(hapd, expect_dialog=3, expect_status=1)
+    resp = rx_bss_tm_resp(hapd, expect_dialog=3, expect_status=7)
     dev[0].dump_monitor()
 
     # truncated Session Information URL
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index 881c0af6fc..1aa2695bb3 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1493,7 +1493,8 @@ 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) {
+	} else if (!disassoc_imminent &&
+		   !(wpa_s->wnm_mode & WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED)) {
 		enum bss_trans_mgmt_status_code status;
 
 		/* No candidate list and disassociation is not imminent */
@@ -1949,10 +1950,12 @@ bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
 	int i;
 
 	/*
-	 * In case disassociation imminent is set, do no try to use a BSS to
-	 * which we are connected.
+	 * Do not try to use a BSS to which we are connected, if it is expected
+	 * to disappear. Assume that will happen if DISASSOC_IMMINENT is set or
+	 * BSS termination information was included.
 	 */
-	if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT) {
+	if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT ||
+	    wpa_s->wnm_mode & WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED) {
 		if (!wpa_s->wnm_disassoc_mld) {
 			if (ether_addr_equal(bss->bssid,
 					     wpa_s->wnm_disassoc_addr))
-- 
2.50.0




More information about the Hostap mailing list