From 99bc57d0d1b14218d9d4767aa0ea33b2d0120f78 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 22 Dec 2018 00:55:26 +0200 Subject: [PATCH] tests: Fix mbo_supp_oper_classes after cfg80211 change The Linux kernel commit 113f3aaa81bd ("cfg80211: Prevent regulatory restore during STA disconnect in concurrent interfaces") broke the regulatory clearing attempt in this test case since cfg80211_is_all_idle() is now returning false due to the AP interface being up and that results in the Country IE -based regulatory information not getting cleared back to defaults. Work around this by stopping the AP interface first so that when the station interface receives the disconnection, there are no other active interfaces in the system. In addition, wait for REGDOM event for the Country IE hint after association to avoid disconnection before the regulatory events have been fully processed. Signed-off-by: Jouni Malinen --- tests/hwsim/test_mbo.py | 11 +++++++++-- tests/hwsim/wpasupplicant.py | 11 +++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/test_mbo.py b/tests/hwsim/test_mbo.py index 2677eba3e..cd6311d9b 100644 --- a/tests/hwsim/test_mbo.py +++ b/tests/hwsim/test_mbo.py @@ -35,6 +35,7 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country): dev[0].dump_monitor() logger.info("Country: " + country) + dev[0].note("Setting country code " + country) set_reg(country, apdev[0], apdev[1], dev[0]) for j in range(5): ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5) @@ -52,8 +53,10 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country): dev[0].connect("test-wnm-mbo", key_mgmt="NONE", scan_freq="5180") sta = hapd.get_sta(addr) res5 = sta['supp_op_classes'][2:] - dev[0].request("REMOVE_NETWORK all") + dev[0].wait_regdom(country_ie=True) hapd.disable() + dev[0].request("REMOVE_NETWORK all") + dev[0].request("ABORT_SCAN") dev[0].wait_disconnected() dev[0].dump_monitor() @@ -63,8 +66,10 @@ def run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, country): dev[0].connect("test-wnm-mbo-2", key_mgmt="NONE", scan_freq="2412") sta = hapd2.get_sta(addr) res2 = sta['supp_op_classes'][2:] - dev[0].request("REMOVE_NETWORK all") + dev[0].wait_regdom(country_ie=True) hapd2.disable() + dev[0].request("REMOVE_NETWORK all") + dev[0].request("ABORT_SCAN") dev[0].wait_disconnected() dev[0].dump_monitor() @@ -91,6 +96,7 @@ def test_mbo_supp_oper_classes(dev, apdev): hapd2 = hostapd.add_ap(apdev[1], params, no_enable=True) try: + dev[0].request("STA_AUTOCONNECT 0") za2, za5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "ZA") fi2, fi5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "FI") us2, us5 = run_mbo_supp_oper_classes(dev, apdev, hapd, hapd2, "US") @@ -101,6 +107,7 @@ def test_mbo_supp_oper_classes(dev, apdev): dev[0].dump_monitor() set_reg("00", apdev[0], apdev[1], dev[0]) ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1) + dev[0].request("STA_AUTOCONNECT 1") za = "515354737475767778797a7b808182" fi = "515354737475767778797a7b808182" diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 1064d2c16..bfa0b2ba9 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1319,3 +1319,14 @@ class WpaSupplicant: def note(self, txt): self.request("NOTE " + txt) + + def wait_regdom(self, country_ie=False): + for i in range(5): + ev = self.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1) + if ev is None: + break + if country_ie: + if "init=COUNTRY_IE" in ev: + break + else: + break