[PATCH 2/2] tests: MBSSID AIDs released into the shared pool

Andrei-Alexandru Bleortu me at andrei-z.com
Thu Nov 26 08:02:00 PST 2026


A STA that returns to a nontransmitted BSSID gets the same AID each time,
and a STA that leaves the transmitted BSSID releases its own AID only: a
new STA reuses it instead of the AID of a STA still associated.

Assisted-by: LLM
Signed-off-by: Andrei-Alexandru Bleortu <me at andrei-z.com>
---
 tests/hwsim/test_he_mbssid.py | 60 +++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/tests/hwsim/test_he_mbssid.py b/tests/hwsim/test_he_mbssid.py
index 8f2916071..c7395d9d9 100644
--- a/tests/hwsim/test_he_mbssid.py
+++ b/tests/hwsim/test_he_mbssid.py
@@ -466,3 +466,63 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first):
     finally:
         subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'],
                          'address', apdev[0]['bssid']])
+
+def mbssid_sta_aid(hapd, dev):
+    sta = hapd.get_sta(dev.own_addr())
+    if 'aid' not in sta:
+        raise Exception("No AID for " + dev.own_addr())
+    return int(sta['aid'])
+
+def mbssid_leave(hapd, dev):
+    dev.request("DISCONNECT")
+    dev.wait_disconnected()
+    hapd.wait_sta_disconnect(dev.own_addr())
+
+def test_he_ap_mbssid_aid_pool(dev, apdev, params):
+    """HE AP MBSSID AIDs freed into the pool they came from"""
+    f, fname, ifname = mbssid_create_cfg_file(apdev, params)
+    for idx in range(0, 2):
+        mbssid_write_bss_params(f, ifname, idx)
+    f.close()
+    mbssid_dump_config(fname)
+
+    hapd = None
+    try:
+        hapd, pid = mbssid_start_ap(dev, apdev, params, fname, ifname, None,
+                                    only_start_ap=True)
+        hapd1 = hostapd.Hostapd(ifname + '-1')
+        open_params = {"key_mgmt": "NONE", "scan_freq": "2412"}
+
+        # A STA that keeps returning to the nontransmitted BSS keeps the
+        # same AID: its AID goes back to the shared pool each time.
+        aids = []
+        for i in range(3):
+            dev[0].connect("bss-1", **open_params)
+            aids.append(mbssid_sta_aid(hapd1, dev[0]))
+            mbssid_leave(hapd1, dev[0])
+        logger.info("AIDs on the nontransmitted BSS: " + str(aids))
+        if aids != [2, 2, 2]:
+            raise Exception("AID not reused on the nontransmitted BSS: " +
+                            str(aids))
+
+        # Releasing one STA's AID frees that AID only: a new STA does not
+        # get the AID of a STA still associated.
+        dev[0].connect("bss-0", **open_params)
+        dev[1].connect("bss-0", **open_params)
+        a0 = mbssid_sta_aid(hapd, dev[0])
+        a1 = mbssid_sta_aid(hapd, dev[1])
+        mbssid_leave(hapd, dev[0])
+        dev[2].connect("bss-0", **open_params)
+        a2 = mbssid_sta_aid(hapd, dev[2])
+        logger.info("AIDs: STA0 %d, STA1 %d, STA2 %d" % (a0, a1, a2))
+        if a2 == a1:
+            raise Exception("STA2 got AID %d of the associated STA1" % a2)
+        if a2 != a0:
+            raise Exception("STA2 got AID %d, not the released %d" % (a2, a0))
+    finally:
+        for i in range(3):
+            dev[i].request("DISCONNECT")
+        if hapd:
+            mbssid_stop_ap(hapd, pid)
+        subprocess.call(['ip', 'link', 'set', 'dev', apdev[0]['ifname'],
+                         'address', apdev[0]['bssid']])
-- 
2.47.3





More information about the Hostap mailing list