tests: MLO: Use link ID to access control sockets

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@quicinc.com>
This commit is contained in:
Aditya Kumar Singh 2024-08-13 14:08:51 +05:30 committed by Jouni Malinen
parent 61dfd7ae35
commit 757d8d9aac
3 changed files with 69 additions and 69 deletions

View file

@ -165,12 +165,14 @@ class HostapdGlobal:
class Hostapd:
def __init__(self, ifname, bssidx=0, hostname=None, ctrl=hapd_ctrl,
port=8877, remote_cli=False):
port=8877, remote_cli=False, link=None):
self.hostname = hostname
self.host = remotehost.Host(hostname, ifname)
self.ifname = ifname
self.remote_cli = remote_cli
if hostname is None:
if link is not None:
ifname = ifname + "_link" + str(link)
self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
self.dbg = ifname
@ -767,7 +769,7 @@ def add_iface(apdev, confname):
raise Exception("Could not ping hostapd")
return hapd
def add_mld_link(apdev, params):
def add_mld_link(apdev, link_id, params):
if isinstance(apdev, dict):
ifname = apdev['ifname']
try:
@ -793,7 +795,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
@ -1067,9 +1070,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")

View file

@ -239,8 +239,8 @@ def test_eht_sae_mlo_tm(dev, apdev):
dev[0].set("sae_pwe", "0")
dev[1].set("sae_groups", "")
def eht_mld_enable_ap(iface, params):
hapd = hostapd.add_mld_link(iface, params)
def eht_mld_enable_ap(iface, link_id, params):
hapd = hostapd.add_mld_link(iface, link_id, params)
hapd.enable()
ev = hapd.wait_event(["AP-ENABLED", "AP-DISABLED"], timeout=1)
@ -310,8 +310,8 @@ def test_eht_mld_discovery(dev, apdev):
"hw_mode": "g",
"channel": "2"}
hapd0 = eht_mld_enable_ap(hapd_iface, link0_params)
hapd1 = eht_mld_enable_ap(hapd_iface, link1_params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, link0_params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, link1_params)
# Only scan link 0
res = wpas.request("SCAN freq=2412")
@ -391,13 +391,13 @@ 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")
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
if second_link_disabled:
params['mld_indicate_disabled'] = '1'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
# Check legacy client connection
dev[0].connect(ssid, scan_freq="2437", key_mgmt="OWE", ieee80211w="2")
@ -449,7 +449,7 @@ def test_eht_mld_sae_single_link(dev, apdev):
params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE",
mfp="2", pwe='2')
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
wpas.set("sae_pwe", "1")
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412",
@ -475,11 +475,11 @@ def run_eht_mld_sae_two_links(dev, apdev, beacon_prot="1",
beacon_prot=beacon_prot,
bridge=bridge)
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
if bridge:
hapd0.cmd_execute(['brctl', 'setfd', 'ap-br0', '0'])
@ -573,7 +573,7 @@ def test_eht_mld_sae_ext_one_link(dev, apdev):
ssid = "mld_ap_sae_ext_single_link"
params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE-EXT-KEY")
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412",
key_mgmt="SAE-EXT-KEY", ieee80211w="2")
@ -596,11 +596,11 @@ def test_eht_mld_sae_ext_two_links(dev, apdev):
params = eht_mld_ap_wpa2_params(ssid, passphrase,
key_mgmt="SAE-EXT-KEY")
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412 2437",
key_mgmt="SAE-EXT-KEY", ieee80211w="2")
@ -619,11 +619,11 @@ def test_eht_mld_sae_legacy_client(dev, apdev):
params = eht_mld_ap_wpa2_params(ssid, passphrase,
key_mgmt="SAE", mfp="2", pwe='1')
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
try:
dev[0].set("sae_groups", "")
@ -659,11 +659,11 @@ def test_eht_mld_sae_transition(dev, apdev):
key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
mfp="1")
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412 2437",
key_mgmt="SAE-EXT-KEY", ieee80211w="2")
@ -695,11 +695,11 @@ def test_eht_mld_ptk_rekey(dev, apdev):
mfp="1")
params['wpa_ptk_rekey'] = '5'
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412 2437",
key_mgmt="SAE-EXT-KEY", ieee80211w="2")
@ -735,11 +735,11 @@ def test_eht_mld_gtk_rekey(dev, apdev):
mfp="1")
params['wpa_group_rekey'] = '5'
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412 2437",
key_mgmt="SAE-EXT-KEY", ieee80211w="2")
@ -774,11 +774,11 @@ def test_eht_ml_probe_req(dev, apdev):
params = eht_mld_ap_wpa2_params(ssid, passphrase,
key_mgmt="SAE-EXT-KEY")
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
bssid = hapd0.own_addr()
wpas.scan_for_bss(bssid, freq=2412)
@ -815,11 +815,11 @@ 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'
hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, link_params)
link_params['channel'] = '6'
link_params['bssid'] = '00:11:22:33:44:02'
hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, link_params)
wpas.set("sae_pwe", "1")
wpas.connect(ssid, sae_password= passphrase, ieee80211w="2",
@ -860,11 +860,11 @@ 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'
hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, link_params)
link_params['channel'] = '6'
link_params['bssid'] = '00:11:22:33:44:02'
hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, link_params)
wpas.set("sae_pwe", "1")
with fail_test(hapd0, 1, "hostapd_get_aid"):
@ -890,11 +890,11 @@ 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'
hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, link_params)
link_params['channel'] = '6'
link_params['bssid'] = '00:11:22:33:44:02'
hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, link_params)
wpas.set("mld_connect_bssid_pref", "00:11:22:33:44:01")
wpas.set("sae_pwe", "1")
@ -933,11 +933,11 @@ 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'
hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, link_params)
link_params['channel'] = '6'
link_params['bssid'] = '00:11:22:33:44:02'
hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, link_params)
# We scan for both APs, then try to connect to link 0, but only the
# second attempt will work if mac80211 rejects the second link.
@ -968,10 +968,10 @@ 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")
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
ieee80211w="2")
@ -1021,11 +1021,11 @@ def test_eht_mld_bss_trans_mgmt_link_removal_imminent(dev, apdev):
params["bss_transition"] = "1"
params["mbo"] = "1"
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
ieee80211w="2")
@ -1073,11 +1073,11 @@ 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")
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
ap_mld_addr = hapd0.get_status_field("mld_addr[0]").replace(':', '')
bssid0 = hapd0.own_addr().replace(':', '')
@ -1461,11 +1461,11 @@ def test_eht_mld_gas(dev, apdev):
params['venue_group'] = "7"
params['venue_type'] = "1"
params['venue_name'] = "eng:Example venue"
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
bssid0 = hapd0.own_addr()
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
bssid1 = hapd1.own_addr()
wpas.scan_for_bss(bssid0, freq="2412")
@ -1497,10 +1497,10 @@ 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")
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
ieee80211w="2")
@ -1525,10 +1525,10 @@ 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")
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd0_iface, params)
hapd1 = eht_mld_enable_ap(hapd0_iface, 1, params)
wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
ieee80211w="2")
@ -1583,7 +1583,7 @@ def test_eht_mld_non_pref_chan(dev, apdev):
params["bss_transition"] = "1"
params["mbo"] = "1"
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
if "OK" not in wpas.request("SET non_pref_chan 81:7:200:1 81:9:100:2"):
raise Exception("Failed to set non-preferred channel list")
@ -1671,7 +1671,7 @@ def test_eht_mld_rrm_beacon_req(dev, apdev):
params["mbo"] = "1"
params["rrm_beacon_report"] = "1"
hapd0 = eht_mld_enable_ap(hapd0_iface, params)
hapd0 = eht_mld_enable_ap(hapd0_iface, 0, params)
wpas.connect(ssid, scan_freq="2412", key_mgmt="OWE", ieee80211w="2",
owe_only="1")
@ -1685,7 +1685,7 @@ 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'
hapd1 = eht_mld_enable_ap(hapd1_iface, params)
hapd1 = eht_mld_enable_ap(hapd1_iface, 0, params)
# Issue a beacon request for the second AP
addr = wpas.own_addr()
@ -1724,7 +1724,7 @@ def test_eht_mld_legacy_stas(dev, apdev):
mfp="2", pwe='2')
params['rsn_pairwise'] = "CCMP GCMP-256"
params['sae_groups'] = "19 20"
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
for i in range(3):
dev[i].set("sae_groups", "")
@ -1763,7 +1763,7 @@ def test_eht_mld_and_mlds(dev, apdev):
mfp="2", pwe='2')
params['rsn_pairwise'] = "CCMP GCMP-256"
params['sae_groups'] = "19 20"
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
wpas.set("sae_pwe", "1")
wpas.connect(ssid, sae_password=password, scan_freq="2412",
@ -1828,10 +1828,10 @@ def test_eht_mlo_csa(dev, apdev):
params = eht_mld_ap_wpa2_params(ssid, passphrase,
key_mgmt="SAE", mfp="2", pwe='1')
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
wpas.set("sae_pwe", "1")
wpas.connect(ssid, sae_password=passphrase, scan_freq="2412 2437",
@ -1928,7 +1928,7 @@ def get_config(iface, count, ssid, passphrase, channel, bssid_regex,
params['sae_pwe'] = "2"
params['group_mgmt_cipher'] = "AES-128-CMAC"
params['beacon_prot'] = "1"
params["ctrl_interface"] = "/var/run/hostapd/chan_" + str(channel)
params["ctrl_interface"] = "/var/run/hostapd/"
params["bssid"] = bssid_regex % (i + 1)
if rnr:
@ -1936,7 +1936,7 @@ def get_config(iface, count, ssid, passphrase, channel, bssid_regex,
append_bss_conf_to_file(f, ifname, params, first=(i == 0))
hapds.append([ifname, params["ctrl_interface"], i])
hapds.append([ifname, i])
f.close()
@ -1981,15 +1981,15 @@ def get_mld_devs(hapd_iface, count, prefix, rnr=False):
start_ap(prefix, fname1 + " " + fname2)
hapd_mld1_link0 = hostapd.Hostapd(ifname=hapds1[0][0], ctrl=hapds1[0][1],
bssidx=hapds1[0][2])
hapd_mld1_link1 = hostapd.Hostapd(ifname=hapds2[0][0], ctrl=hapds2[0][1],
bssidx=hapds2[0][2])
hapd_mld1_link0 = hostapd.Hostapd(ifname=hapds1[0][0], bssidx=hapds1[0][1],
link=0)
hapd_mld1_link1 = hostapd.Hostapd(ifname=hapds2[0][0], bssidx=hapds2[0][1],
link=1)
hapd_mld2_link0 = hostapd.Hostapd(ifname=hapds1[1][0], ctrl=hapds1[1][1],
bssidx=hapds1[1][2])
hapd_mld2_link1 = hostapd.Hostapd(ifname=hapds2[1][0], ctrl=hapds2[1][1],
bssidx=hapds2[1][2])
hapd_mld2_link0 = hostapd.Hostapd(ifname=hapds1[1][0], bssidx=hapds1[1][1],
link=0)
hapd_mld2_link1 = hostapd.Hostapd(ifname=hapds2[1][0], bssidx=hapds2[1][1],
link=1)
if not hapd_mld1_link0.ping():
raise Exception("Could not ping hostapd")
@ -2169,12 +2169,12 @@ def test_eht_mlo_color_change(dev, apdev):
key_mgmt="SAE", mfp="2", pwe='1')
params['he_bss_color'] = '42'
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params['channel'] = '6'
params['he_bss_color'] = '24'
hapd1 = eht_mld_enable_ap(hapd_iface, params)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params)
logger.info("Perform CCA on 1st link")
if "OK" not in hapd0.request("COLOR_CHANGE 10"):

View file

@ -176,12 +176,12 @@ def run_rsn_override_mld(dev, apdev, mixed, only_sta=False,
params1['rsn_override_pairwise_2'] = 'CCMP GCMP-256'
params1['rsn_override_mfp_2'] = '2'
hapd0 = eht_mld_enable_ap(hapd_iface, params)
hapd0 = eht_mld_enable_ap(hapd_iface, 0, params)
params1['channel'] = '6'
if too_long_elems:
params1['rsnoe_override'] = 'ddff506f9a29' + 251*'cc'
hapd1 = eht_mld_enable_ap(hapd_iface, params1)
hapd1 = eht_mld_enable_ap(hapd_iface, 1, params1)
wpas.set("sae_pwe", "1")
wpas.set("rsn_overriding", "1")