[PATCH 19/21] tests: Extend HE MBSSID test with BIGTK only on non-TX BSS

Benjamin Berg benjamin at sipsolutions.net
Tue Oct 27 06:17:05 PDT 2026


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

This hits different paths in the code, so it makes sense to add a
separate test for this scenario. Also check keys against the AP as we
cannot check them against each other in that case.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 tests/hwsim/test_he_mbssid.py | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/tests/hwsim/test_he_mbssid.py b/tests/hwsim/test_he_mbssid.py
index cc3c9b59f0..befe7d1caa 100644
--- a/tests/hwsim/test_he_mbssid.py
+++ b/tests/hwsim/test_he_mbssid.py
@@ -425,6 +425,13 @@ def test_mbssid_beacon_prot_non_tx_then_tx(dev, apdev, params):
     """HE AP MBSSID beacon protection with Association on non-Tx BSS followed by Tx BSS"""
     run_mbssid_beacon_prot(dev, apdev, params, True)
 
+def test_he_ap_mbssid_nontx_beacon_prot_tx_then_non_tx(dev, apdev, params):
+    """HE AP MBSSID beacon protection (only non-TX) with Association on Tx BSS followed by non-Tx BSS"""
+    run_mbssid_beacon_prot(dev, apdev, params, False, False)
+
+def test_mbssid_nontx_beacon_prot_non_tx_then_tx(dev, apdev, params):
+    """HE AP MBSSID beacon protection (only non-TX) with Association on non-Tx BSS followed by Tx BSS"""
+    run_mbssid_beacon_prot(dev, apdev, params, True, False)
 
 def get_mac80211_bigtks(dev):
     phy = dev.get_driver_status_field("phyname")
@@ -456,14 +463,15 @@ def get_mac80211_bigtks(dev):
 
     return res
 
-def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first):
+def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True):
     check_sae_capab(dev[0])
     check_sae_capab(dev[1])
     f, fname, ifname = mbssid_create_cfg_file(apdev, params)
 
     sae_params = {"wpa": "2", "sae_password": "12345678",
                   "wpa_pairwise": "CCMP", "wpa_key_mgmt": "SAE",
-                  "ieee80211w": "2", "beacon_prot": "1"}
+                  "ieee80211w": "2",
+                  "beacon_prot": "1" if tx_beacon_prot else "0"}
     mbssid_write_bss_params(f, ifname, 0, sae_params)
     sae_params = {"wpa": "2", "sae_password": "another password",
                   "wpa_pairwise": "CCMP", "wpa_key_mgmt": "SAE",
@@ -482,19 +490,32 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first):
             dev[1].connect("bss-1", psk="another password", key_mgmt="SAE",
                            ieee80211w="2", beacon_prot="1", scan_freq="2412")
             dev[0].connect("bss-0", psk="12345678", key_mgmt="SAE",
-                           ieee80211w="2", beacon_prot="1", scan_freq="2412")
+                           ieee80211w="2", beacon_prot="1" if tx_beacon_prot else "0",
+                           scan_freq="2412")
         else:
             dev[0].connect("bss-0", psk="12345678", key_mgmt="SAE",
-                           ieee80211w="2", beacon_prot="1", scan_freq="2412")
+                           ieee80211w="2", beacon_prot="1" if tx_beacon_prot else "0",
+                           scan_freq="2412")
             dev[1].connect("bss-1", psk="another password", key_mgmt="SAE",
                            ieee80211w="2", beacon_prot="1", scan_freq="2412")
 
         bigtk_mismatch = False
+        unexpected_bigtk = False
         try:
+            ap_bigtks = get_mac80211_bigtks(hapd)
             dev0_bigtks = get_mac80211_bigtks(dev[0])
             dev1_bigtks = get_mac80211_bigtks(dev[1])
+            logger.info(f'BIGTKs AP: {ap_bigtks}')
+            logger.info(f'BIGTKs dev0: {dev0_bigtks}')
+            logger.info(f'BIGTKs dev1: {dev1_bigtks}')
+
+            if tx_beacon_prot:
+                if dev0_bigtks[0] not in ap_bigtks:
+                    bigtk_mismatch = True
+            elif dev0_bigtks:
+                unexpected_bigtk = True
 
-            if dev0_bigtks[0]['key'] != dev1_bigtks[0]['key']:
+            if dev1_bigtks[0] not in ap_bigtks:
                 bigtk_mismatch = True
         except HwsimSkip:
             # We can still check that no beacon loss happened
@@ -516,7 +537,9 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first):
         if beacon_loss1:
             raise Exception("Beacon loss detected on non-TX BSS")
         if bigtk_mismatch:
-            raise Exception("Installed BIGTKs did not match between STAs")
+            raise Exception("Installed BIGTKs did not match between AP and STA(s)")
+        if unexpected_bigtk:
+            raise Exception("STA on TX-BSSID should not have a BIGTK installed")
     finally:
         subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'],
                          'address', apdev[0]['bssid']])
-- 
2.56.0




More information about the Hostap mailing list