[PATCH 5/6] tests: MLO: use link ID to access control sockets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With MLO, each BSS will create sockets under the given ctrl_iface
directory with the socket name being '<ifname>_link<link_ID>'.

Make necessary changes in MLO related test cases so that it can access
the new socket and proceed further as expected.

Signed-off-by: Aditya Kumar Singh <quic_adisi@xxxxxxxxxxx>
---
 tests/hwsim/hostapd.py  | 27 +++++++++++-----
 tests/hwsim/test_eht.py | 70 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index ebb2e328af50..4fa19294a99e 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -147,14 +147,20 @@ class HostapdGlobal:
 
 class Hostapd:
     def __init__(self, ifname, bssidx=0, hostname=None, ctrl=hapd_ctrl,
-                 port=8877):
+                 port=8877, link=None):
         self.hostname = hostname
         self.host = remotehost.Host(hostname, ifname)
         self.ifname = ifname
         if hostname is None:
-            self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
-            self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
-            self.dbg = ifname
+            if link is None:
+                self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.dbg = ifname
+            else:
+                ifname = ifname + "_link" + link
+                self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.dbg = ifname
         else:
             self.ctrl = wpaspy.Ctrl(hostname, port)
             self.mon = wpaspy.Ctrl(hostname, port)
@@ -740,6 +746,13 @@ def add_mld_link(apdev, params):
         hostname = None
         port = 8878
 
+    if "link_id" not in params:
+        raise Exception("Link ID not passed in param")
+
+    link_id = params["link_id"]
+    # Delete the 'link_id' key from params or else it will be added in config
+    del params["link_id"]
+
     hapd_global = HostapdGlobal(apdev)
     confname, ctrl_iface = cfg_mld_link_file(ifname, params)
     hapd_global.send_file(confname, confname)
@@ -749,7 +762,8 @@ def add_mld_link(apdev, params):
         if str(e) == "Could not add hostapd link":
             raise utils.HwsimSkip("No MLO support in hostapd")
     port = hapd_global.get_ctrl_iface_port(ifname)
-    hapd = Hostapd(ifname, hostname=hostname, ctrl=ctrl_iface, port=port)
+    hapd = Hostapd(ifname, hostname=hostname, ctrl=ctrl_iface, port=port,
+                   link=link_id)
     if not hapd.ping():
         raise Exception("Could not ping hostapd")
     return hapd
@@ -1023,9 +1037,6 @@ def cfg_mld_link_file(ifname, params):
     fd, fname = tempfile.mkstemp(dir='/tmp', prefix=conf + '-')
     f = os.fdopen(fd, 'w')
 
-    if idx != 0:
-        ctrl_iface="/var/run/hostapd_%d" % idx
-
     f.write("ctrl_interface=%s\n" % ctrl_iface)
     f.write("driver=nl80211\n")
     f.write("ieee80211n=1\n")
diff --git a/tests/hwsim/test_eht.py b/tests/hwsim/test_eht.py
index 296445e27198..8acb6a57bc7b 100644
--- a/tests/hwsim/test_eht.py
+++ b/tests/hwsim/test_eht.py
@@ -300,10 +300,12 @@ def test_eht_mld_discovery(dev, apdev):
         ssid = "mld_ap"
         link0_params = {"ssid": ssid,
                         "hw_mode": "g",
-                        "channel": "1"}
+                        "channel": "1",
+                        "link_id": "0"}
         link1_params = {"ssid": ssid,
                         "hw_mode": "g",
-                        "channel": "2"}
+                        "channel": "2",
+                        "link_id": "1"}
 
         hapd0 = eht_mld_enable_ap(hapd_iface, link0_params)
         hapd1 = eht_mld_enable_ap(hapd_iface, link1_params)
@@ -385,12 +387,14 @@ def _eht_mld_owe_two_links(dev, apdev, second_link_disabled=False,
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
         if second_link_disabled:
             params['mld_indicate_disabled'] = '1'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
         # Check legacy client connection
@@ -443,6 +447,7 @@ def test_eht_mld_sae_single_link(dev, apdev):
         ssid = "mld_ap_sae_single_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE",
                                         mfp="2", pwe='2')
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -468,10 +473,12 @@ def run_eht_mld_sae_two_links(dev, apdev, beacon_prot="1",
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE", mfp="2", pwe='1',
                                         beacon_prot=beacon_prot)
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -554,6 +561,7 @@ def test_eht_mld_sae_ext_one_link(dev, apdev):
         passphrase = 'qwertyuiop'
         ssid = "mld_ap_sae_ext_single_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -577,10 +585,12 @@ def test_eht_mld_sae_ext_two_links(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -600,10 +610,12 @@ def test_eht_mld_sae_legacy_client(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE", mfp="2", pwe='1')
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -640,10 +652,12 @@ def test_eht_mld_sae_transition(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -676,10 +690,12 @@ def test_eht_mld_ptk_rekey(dev, apdev):
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
         params['wpa_ptk_rekey'] = '5'
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -716,10 +732,12 @@ def test_eht_mld_gtk_rekey(dev, apdev):
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
         params['wpa_group_rekey'] = '5'
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -756,10 +774,12 @@ def test_eht_ml_probe_req(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -798,10 +818,14 @@ def test_eht_mld_connect_probes(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         wpas.set("sae_pwe", "1")
@@ -843,10 +867,14 @@ def test_eht_tx_link_rejected_connect_other(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         wpas.set("sae_pwe", "1")
@@ -873,10 +901,14 @@ def test_eht_all_links_rejected(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
         wpas.set("mld_connect_bssid_pref", "00:11:22:33:44:01")
         wpas.set("sae_pwe", "1")
@@ -916,10 +948,13 @@ def test_eht_connect_invalid_link(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         # We scan for both APs, then try to connect to link 0, but only the
@@ -951,9 +986,12 @@ def test_eht_mld_link_removal(dev, apdev):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1003,10 +1041,12 @@ def test_eht_mld_bss_trans_mgmt_link_removal_imminent(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
         params["bss_transition"] = "1"
         params["mbo"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1055,10 +1095,12 @@ def test_eht_ap_mld_proto(dev, apdev):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1443,10 +1485,14 @@ def test_eht_mld_gas(dev, apdev):
         params['venue_group'] = "7"
         params['venue_type'] = "1"
         params['venue_name'] = "eng:Example venue"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
         bssid0 = hapd0.own_addr()
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
         bssid1 = hapd1.own_addr()
 
@@ -1479,9 +1525,13 @@ def test_eht_mld_dpp_responder_while_assoc(dev, apdev):
 
         ssid = "owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1507,9 +1557,13 @@ def _eht_mld_disconnect(dev, apdev, disassoc=True):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1564,6 +1618,7 @@ def test_eht_mld_non_pref_chan(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
         params["bss_transition"] = "1"
         params["mbo"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1652,6 +1707,7 @@ def test_eht_mld_rrm_beacon_req(dev, apdev):
         params["bss_transition"] = "1"
         params["mbo"] = "1"
         params["rrm_beacon_report"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1667,6 +1723,8 @@ def test_eht_mld_rrm_beacon_req(dev, apdev):
         other_ssid = "other"
         params = eht_mld_ap_wpa2_params(other_ssid, key_mgmt="OWE", mfp="2")
         params["channel"] = '6'
+        params['link_id'] = '0'
+
         hapd1 = eht_mld_enable_ap(hapd1_iface, params)
 
         # Issue a beacon request for the second AP
@@ -1706,6 +1764,8 @@ def test_eht_mld_legacy_stas(dev, apdev):
                                         mfp="2", pwe='2')
         params['rsn_pairwise'] = "CCMP GCMP-256"
         params['sae_groups'] = "19 20"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         for i in range(3):
@@ -1745,6 +1805,8 @@ def test_eht_mld_and_mlds(dev, apdev):
                                         mfp="2", pwe='2')
         params['rsn_pairwise'] = "CCMP GCMP-256"
         params['sae_groups'] = "19 20"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         wpas.set("sae_pwe", "1")
@@ -1810,9 +1872,13 @@ def test_eht_mlo_csa(dev, apdev):
 
             params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                             key_mgmt="SAE", mfp="2", pwe='1')
+            params['link_id'] = '0'
+
             hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
             params['channel'] = '6'
+            params['link_id'] = '1'
+
             hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
             wpas.set("sae_pwe", "1")
-- 
2.34.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux