From 1cde2549ec097628de07feed41895c52bd9261bd Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 21 Feb 2023 00:12:22 +0200 Subject: [PATCH] tests: WPA2-PSK and STA using 4addr mode Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_psk.py | 31 +++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index 4d7fcce44..b035c6ee2 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -3663,3 +3663,34 @@ def run_ap_wpa2_psk_ext_key_id_ptk_rekey_sta(dev, apdev, ext_key_id): hwsim_utils.test_connectivity(dev[0], hapd) finally: dev[0].set("extended_key_id", "0") + +def test_ap_wpa2_psk_4addr(dev, apdev): + """WPA2-PSK and STA using 4addr mode""" + br_ifname = 'sta-br0' + ssid = "test-wpa2-psk" + passphrase = 'qwertyuiop' + params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) + hapd = hostapd.add_ap(apdev[0], params) + dev[0].connect(ssid, psk=passphrase, scan_freq="2412", + enable_4addr_mode="1") + + # Verify that the station interface can be added into a bridge. + ifname = dev[0].ifname + try: + subprocess.check_call(['brctl', 'addbr', br_ifname]) + subprocess.check_call(['ip', 'link', 'set', 'dev', br_ifname, 'up']) + subprocess.check_call(['brctl', 'addif', br_ifname, ifname]) + cmd = subprocess.Popen(['brctl', 'show'], stdout=subprocess.PIPE) + res = cmd.stdout.read().decode() + finally: + subprocess.call(['brctl', 'delif', br_ifname, ifname]) + subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'down']) + subprocess.call(['brctl', 'delbr', br_ifname]) + + found = False + for s in res.splitlines(): + vals = s.split() + if br_ifname in vals and ifname in vals: + found = True + if not found: + raise Exception("Station interface was not seen in the bridge") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index d6b4c4891..bd53a1ec0 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1116,7 +1116,8 @@ class WpaSupplicant: "multi_ap_backhaul_sta", "rx_stbc", "tx_stbc", "ft_eap_pmksa_caching", "beacon_prot", "mac_value", - "wpa_deny_ptk0_rekey"] + "wpa_deny_ptk0_rekey", + "enable_4addr_mode"] for field in not_quoted: if field in kwargs and kwargs[field]: self.set_network(id, field, kwargs[field])