]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Test driver association ML link rejection flow
authorBenjamin Berg <benjamin.berg@intel.com>
Mon, 20 Nov 2023 23:51:54 +0000 (01:51 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 6 Dec 2023 20:41:40 +0000 (22:41 +0200)
The underlying driver can reject only specific links in an association
request. In that case we will only ignore the corresponding BSS. Add a
test for this flow by simulating an association failure on the second
link specifically.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
src/drivers/driver_nl80211.c
tests/hwsim/test_eht.py

index 56c00736dfa419a877dd878c252e2a42aea2a41c..c5af62a3fee4f30084c9a1cb86c733a34140c4f3 100644 (file)
@@ -7326,9 +7326,25 @@ static int wpa_driver_nl80211_associate(
                        goto fail;
        }
 
-       ret = send_and_recv_msgs_connect_handle(drv, msg, drv->first_bss, 1,
-                                               &err_info);
-       msg = NULL;
+       if (!TEST_FAIL_TAG("assoc")) {
+               ret = send_and_recv_msgs_connect_handle(drv, msg,
+                                                       drv->first_bss, 1,
+                                                       &err_info);
+               msg = NULL;
+       } else {
+               int i;
+
+               /* Error and force TEST_FAIL checking for each link */
+               ret = -EINVAL;
+               for (i = 0; i < MAX_NUM_MLD_LINKS; i++) {
+                       if (!(params->mld_params.valid_links & BIT(i)))
+                               continue;
+
+                       if (TEST_FAIL_TAG("link"))
+                               err_info.link_id = i;
+               }
+       }
+
        if (ret) {
                wpa_dbg(drv->ctx, MSG_DEBUG,
                        "nl80211: MLME command failed (assoc): ret=%d (%s)",
index cca63db3774cf95c7e04e208623f647f1f5c3525..dbffe172f58f7aceabe11471d86eb1cfe7a3682b 100644 (file)
@@ -793,6 +793,46 @@ def test_eht_all_links_rejected(dev, apdev, params):
             # connects.
             wpas.wait_connected(timeout=15)
 
+def test_eht_connect_invalid_link(dev, apdev, params):
+    """EHT MLD AP where one link is incorrectly configured and rejected by mac80211"""
+    with HWSimRadio(use_mlo=True) as (hapd_radio, hapd_iface), \
+        HWSimRadio(use_mlo=True) as (wpas_radio, wpas_iface):
+
+        wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+        wpas.interface_add(wpas_iface)
+
+        ssid = "mld_ap"
+        passphrase = 'qwertyuiop'
+        ssid = "mld_ap"
+        passphrase = 'qwertyuiop'
+        link_params = eht_mld_ap_wpa2_params(ssid, passphrase, mfp="2",
+                                             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)
+
+        link_params['channel'] = '6'
+        link_params['bssid'] = '00:11:22:33:44:02'
+        hapd1 = eht_mld_enable_ap(hapd_iface, 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.
+        wpas.set("mld_connect_bssid_pref", "00:11:22:33:44:01")
+        wpas.set("sae_pwe", "1")
+        with fail_test(wpas, 1, "assoc;wpa_driver_nl80211_associate",
+                             2, "link;wpa_driver_nl80211_associate"):
+            wpas.connect(ssid, sae_password=passphrase, ieee80211w="2",
+                         key_mgmt="SAE", scan_freq="2412")
+
+        eht_verify_status(wpas, hapd0, 2412, 20, is_ht=True, mld=True,
+                          valid_links=1, active_links=1)
+
+        out = run_tshark(os.path.join(params['logdir'], 'hwsim0.pcapng'),
+                         'wlan.fc.type_subtype == 0x0000 && wlan.ext_tag.data == 00:01:09:%s:00:00' % wpas.own_addr(),
+                         display=['frame.number'])
+        if not out.splitlines():
+            raise Exception('Association request send by mac80211 had unexpected ML element content (probably it contained a second link)')
+
 def test_eht_mld_link_removal(dev, apdev):
     """EHT MLD with two links. Links removed during association"""