]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Work around cfg80211 reg.c intersection (country 98) issues
authorJouni Malinen <j@w1.fi>
Sat, 22 Dec 2018 13:55:19 +0000 (15:55 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 23 Dec 2018 15:25:11 +0000 (17:25 +0200)
The Linux kernel commit 113f3aaa81bd ("cfg80211: Prevent regulatory
restore during STA disconnect in concurrent interfaces") broke the
regulatory clearing attempt in many test cases 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 <j@w1.fi>
tests/hwsim/test_ap_acs.py
tests/hwsim/test_ap_open.py
tests/hwsim/test_ap_params.py
tests/hwsim/test_ap_vht.py
tests/hwsim/test_dfs.py
tests/hwsim/test_ocv.py
tests/hwsim/test_rrm.py
tests/hwsim/test_wnm.py
tests/hwsim/test_wpas_ap.py

index 0e4ef477c802f2bf59cd952f87d11e1ac5544ebe..b08025f33c0fbd7f68ed20edfc86a8ef008f5a4d 100644 (file)
@@ -154,12 +154,15 @@ def test_ap_acs_5ghz(dev, apdev):
             raise Exception("Unexpected frequency")
 
         dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
-
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_acs_5ghz_40mhz(dev, apdev):
@@ -183,12 +186,15 @@ def test_ap_acs_5ghz_40mhz(dev, apdev):
             raise Exception("Secondary channel not set")
 
         dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
-
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_acs_vht(dev, apdev):
@@ -214,12 +220,15 @@ def test_ap_acs_vht(dev, apdev):
             raise Exception("Secondary channel not set")
 
         dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
-
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_acs_vht40(dev, apdev):
@@ -247,12 +256,15 @@ def test_ap_acs_vht40(dev, apdev):
             raise Exception("Secondary channel not set")
 
         dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
-
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_acs_vht160(dev, apdev):
@@ -283,11 +295,16 @@ def test_ap_acs_vht160(dev, apdev):
             if int(freq) < 5000:
                 raise Exception("Unexpected frequency")
             dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
+            dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
+        dev[0].flush_scan_cache()
 
 def test_ap_acs_vht160_scan_disable(dev, apdev):
     """Automatic channel selection for VHT160 and DISABLE during scan"""
index 20e00a2efdc65bda4ce0da2d86368dfa95c2ec6a..45fb7920fedd1e7094cc44e168c83560d264edaf 100644 (file)
@@ -767,10 +767,16 @@ def test_ap_open_country_outdoor(dev, apdev):
 
 def _test_ap_open_country(dev, apdev, country_code, country3):
     try:
-        run_ap_open_country(dev, apdev, country_code, country3)
+        hapd = None
+        hapd = run_ap_open_country(dev, apdev, country_code, country3)
     finally:
+        if hapd:
+            hapd.request("DISABLE")
         dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         set_world_reg(apdev[0], apdev[1], dev[0])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def run_ap_open_country(dev, apdev, country_code, country3):
@@ -780,8 +786,8 @@ def run_ap_open_country(dev, apdev, country_code, country3):
                                       "ieee80211d": "1" })
     dev[0].scan_for_bss(hapd.own_addr(), freq=2412)
     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
-    dev[0].request("DISCONNECT")
-    dev[0].wait_disconnected()
+    dev[0].wait_regdom(country_ie=True)
+    return hapd
 
 def test_ap_open_disable_select(dev, apdev):
     """DISABLE_NETWORK for connected AP followed by SELECT_NETWORK"""
index cd6846956da52d31a987cbc3422cc5575238cdb9..a39bfcee2e2e70bd4b5414489f74f5f9de62b98f 100644 (file)
@@ -116,10 +116,13 @@ def test_ap_country(dev, apdev):
         dev[0].connect(ssid, psk=passphrase, scan_freq="5180")
         hwsim_utils.test_connectivity(dev[0], hapd)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_acl_accept(dev, apdev):
@@ -415,11 +418,15 @@ def test_ap_spectrum_management_required(dev, apdev):
         hapd = None
         hapd = hostapd.add_ap(apdev[0], params)
         dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180")
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 @remote_compatible
index e6c39b65944ffd351c8d8c169bf1141579ed8cdb..64c0921b0cd8df6a47909021048d98d2879e2b2c 100644 (file)
@@ -357,6 +357,7 @@ def test_ap_vht160(dev, apdev):
             raise Exception("Unexpected interface state")
 
         dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
         sig = dev[0].request("SIGNAL_POLL").splitlines()
         if "FREQUENCY=5180" not in sig:
@@ -369,10 +370,13 @@ def test_ap_vht160(dev, apdev):
                 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_vht160b(dev, apdev):
@@ -427,6 +431,7 @@ def test_ap_vht160b(dev, apdev):
             raise Exception("Unexpected frequency(2)")
 
         dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520")
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
         sig = dev[0].request("SIGNAL_POLL").splitlines()
         if "FREQUENCY=5520" not in sig:
@@ -439,10 +444,13 @@ def test_ap_vht160b(dev, apdev):
                 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_vht160_no_dfs_100_plus(dev, apdev):
@@ -503,6 +511,7 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab):
 
         freq = str(int(channel) * 5 + 5000)
         dev[0].connect("vht", key_mgmt="NONE", scan_freq=freq)
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
         sig = dev[0].request("SIGNAL_POLL").splitlines()
         if "FREQUENCY=" + freq not in sig:
@@ -515,10 +524,13 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab):
                 raise HwsimSkip("80/160 MHz channel not supported in regulatory information")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_vht160_no_ht40(dev, apdev):
@@ -947,16 +959,20 @@ def test_ap_vht80_pwr_constraint(dev, apdev):
         hapd = hostapd.add_ap(apdev[0], params)
 
         dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
+        dev[0].wait_regdom(country_ie=True)
     except Exception, e:
         if isinstance(e, Exception) and str(e) == "AP startup failed":
             if not vht_supported():
                 raise HwsimSkip("80 MHz channel not supported in regulatory information")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_ap_vht_use_sta_nsts(dev, apdev):
@@ -1059,12 +1075,16 @@ def test_ap_vht_40_fallback_to_20(devs, apdevs):
                  }
         hapd = hostapd.add_ap(ap, params)
         dev.connect("test-vht40", scan_freq="5805", key_mgmt="NONE")
+        dev.wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev, hapd)
     finally:
-        dev.request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev.request("DISCONNECT")
+        dev.request("ABORT_SCAN")
+        dev.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev.flush_scan_cache()
 
 def test_ap_vht80_to_24g_ht(dev, apdev):
index bf9af8f8b682ae487b336527c4c9eff58cc9cabe..ae07b90d72736ba60458e0e9fc669fea4ce9c610 100644 (file)
@@ -106,6 +106,7 @@ def test_dfs(dev, apdev):
             raise Exception("Unexpected frequency")
 
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
 
         hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
@@ -128,10 +129,13 @@ def test_dfs(dev, apdev):
         time.sleep(1)
         hwsim_utils.test_connectivity(dev[0], hapd)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_etsi(dev, apdev, params):
@@ -161,6 +165,7 @@ def test_dfs_etsi(dev, apdev, params):
             raise Exception("Unexpected frequency")
 
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
 
         hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq)
@@ -197,10 +202,13 @@ def test_dfs_etsi(dev, apdev, params):
             time.sleep(1)
         hwsim_utils.test_connectivity(dev[0], hapd)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar1(dev, apdev):
@@ -255,11 +263,15 @@ def test_dfs_radar1(dev, apdev):
                 raise Exception("Unexpected frequency: " + freq)
 
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar2(dev, apdev):
@@ -324,11 +336,15 @@ def test_dfs_radar_chanlist(dev, apdev):
         if "AP-ENABLED" not in ev:
             raise Exception("Unexpected DFS event: " + ev)
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar_chanlist_vht80(dev, apdev):
@@ -359,14 +375,18 @@ def test_dfs_radar_chanlist_vht80(dev, apdev):
         if "AP-ENABLED" not in ev:
             raise Exception("Unexpected DFS event: " + ev)
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
 
         if hapd.get_status_field('vht_oper_centr_freq_seg0_idx') != "42":
             raise Exception("Unexpected seg0 idx")
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar_chanlist_vht20(dev, apdev):
@@ -397,11 +417,15 @@ def test_dfs_radar_chanlist_vht20(dev, apdev):
         if "AP-ENABLED" not in ev:
             raise Exception("Unexpected DFS event: " + ev)
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar_no_ht(dev, apdev):
@@ -432,11 +456,15 @@ def test_dfs_radar_no_ht(dev, apdev):
         if "AP-ENABLED" not in ev:
             raise Exception("Unexpected DFS event: " + ev)
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_dfs_radar_ht40minus(dev, apdev):
@@ -467,12 +495,18 @@ def test_dfs_radar_ht40minus(dev, apdev):
         if "AP-ENABLED" not in ev:
             raise Exception("Unexpected DFS event: " + ev)
         dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].wait_regdom(country_ie=True)
+        dev[0].request("STA_AUTOCONNECT 0")
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
+        dev[0].request("STA_AUTOCONNECT 1")
 
 def test_dfs_ht40_minus(dev, apdev, params):
     """DFS CAC functionality on channel 104 HT40- [long]"""
@@ -502,10 +536,14 @@ def test_dfs_ht40_minus(dev, apdev, params):
             raise Exception("Unexpected frequency")
 
         dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520")
+        dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
index 6244d2a8a29205d33685d257ea1eb464fc319a1b..b76b6cfd5540d3313d596d1406c00e956ddff579 100644 (file)
@@ -98,6 +98,7 @@ def run_wpa2_ocv_5ghz(dev, apdev):
     for ocv in range(2):
         dev[0].connect(ssid, psk=passphrase, scan_freq="5200", ocv=str(ocv),
                        ieee80211w="1")
+        dev[0].wait_regdom(country_ie=True)
         dev[0].request("REMOVE_NETWORK all")
         dev[0].wait_disconnected()
 
@@ -149,6 +150,7 @@ def run_wpa2_ocv_ht40(dev, apdev):
                            ieee80211w="1", disable_ht="1")
             dev[1].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
                            ieee80211w="1")
+            dev[0].wait_regdom(country_ie=True)
             dev[0].request("REMOVE_NETWORK all")
             dev[1].request("REMOVE_NETWORK all")
             dev[0].wait_disconnected()
@@ -190,6 +192,7 @@ def run_wpa2_ocv_vht40(dev, apdev):
                            ieee80211w="1", disable_vht="1")
             dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
                            ieee80211w="1")
+            dev[0].wait_regdom(country_ie=True)
             dev[0].request("REMOVE_NETWORK all")
             dev[1].request("REMOVE_NETWORK all")
             dev[2].request("REMOVE_NETWORK all")
@@ -230,6 +233,7 @@ def run_wpa2_ocv_vht80(dev, apdev):
                            ieee80211w="1", disable_vht="1")
             dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
                            ieee80211w="1")
+            dev[0].wait_regdom(country_ie=True)
             dev[0].request("REMOVE_NETWORK all")
             dev[1].request("REMOVE_NETWORK all")
             dev[2].request("REMOVE_NETWORK all")
@@ -270,6 +274,7 @@ def run_wpa2_ocv_vht160(dev, apdev):
                            ieee80211w="1", disable_vht="1")
             dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
                            ieee80211w="1")
+            dev[0].wait_regdom(country_ie=True)
             dev[0].request("REMOVE_NETWORK all")
             dev[1].request("REMOVE_NETWORK all")
             dev[2].request("REMOVE_NETWORK all")
@@ -285,6 +290,7 @@ def test_wpa2_ocv_vht80plus80(dev, apdev):
         run_wpa2_ocv_vht80plus80(dev, apdev)
     finally:
         set_world_reg(apdev[0], apdev[1], dev[0])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
         dev[1].flush_scan_cache()
         dev[2].flush_scan_cache()
@@ -313,13 +319,24 @@ def run_wpa2_ocv_vht80plus80(dev, apdev):
                            ieee80211w="1", disable_vht="1")
             dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
                            ieee80211w="1")
+            dev[0].wait_regdom(country_ie=True)
             dev[0].request("REMOVE_NETWORK all")
             dev[1].request("REMOVE_NETWORK all")
             dev[2].request("REMOVE_NETWORK all")
             dev[0].wait_disconnected()
             dev[1].wait_disconnected()
             dev[2].wait_disconnected()
+        for i in range(3):
+            dev[i].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
+                           ieee80211w="1")
+            if i == 0:
+                dev[i].wait_regdom(country_ie=True)
         hapd.disable()
+        for i in range(3):
+            dev[i].request("DISCONNECT")
+            dev[i].request("ABORT_SCAN")
+        for i in range(3):
+            dev[i].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
 
 class APConnection:
     def init_params(self):
@@ -372,6 +389,8 @@ class APConnection:
 
         dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq, ocv=sta_ocv,
                     ieee80211w="1", wait_connect=False)
+        if "country_code" in params:
+            dev.wait_regdom(country_ie=True)
         self.addr = dev.p2p_interface_addr()
 
         # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated
@@ -473,6 +492,7 @@ def test_wpa2_ocv_ap_vht160_mismatch(dev, apdev):
         run_wpa2_ocv_ap_vht160_mismatch(dev, apdev)
     finally:
         set_world_reg(apdev[0], apdev[1], dev[0])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev):
@@ -498,8 +518,11 @@ def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev):
     conn.confirm_valid_oci(129, 100, 0)
 
     dev[0].dump_monitor()
+    if conn.hapd:
+        conn.hapd.request("DISABLE")
     dev[0].request("DISCONNECT")
-    dev[0].wait_disconnected()
+    dev[0].request("ABORT_SCAN")
+    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
 
 @remote_compatible
 def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
@@ -508,6 +531,7 @@ def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
         run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev)
     finally:
         set_world_reg(apdev[0], apdev[1], dev[0])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
@@ -530,8 +554,11 @@ def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev):
     conn.confirm_valid_oci(130, 36, 155)
 
     dev[0].dump_monitor()
+    if conn.hapd:
+        conn.hapd.request("DISABLE")
     dev[0].request("DISCONNECT")
-    dev[0].wait_disconnected()
+    dev[0].request("ABORT_SCAN")
+    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
 
 @remote_compatible
 def test_wpa2_ocv_ap_unexpected1(dev, apdev):
@@ -720,6 +747,8 @@ class STAConnection:
 
         self.dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq,
                          wait_connect=False, **sta_params)
+        if "country_code" in params:
+            self.dev.wait_regdom(country_ie=True)
         self.addr = dev.p2p_interface_addr()
 
         # Forward msg 1/4 from AP to STA
@@ -798,6 +827,7 @@ def test_wpa2_ocv_vht160_mismatch_client(dev, apdev):
         run_wpa2_ocv_vht160_mismatch_client(dev, apdev)
     finally:
         set_world_reg(apdev[0], apdev[1], dev[0])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def run_wpa2_ocv_vht160_mismatch_client(dev, apdev):
@@ -824,6 +854,13 @@ def run_wpa2_ocv_vht160_mismatch_client(dev, apdev):
                       129, 104, 0, "primary channel mismatch")
     conn.confirm_valid_oci(122, 100, 0)
 
+    dev[0].dump_monitor()
+    if conn.hapd:
+        conn.hapd.request("DISABLE")
+    dev[0].request("DISCONNECT")
+    dev[0].request("ABORT_SCAN")
+    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+
 def test_wpa2_ocv_sta_group_hs(dev, apdev):
     """OCV group handshake (STA)"""
     params = { "channel": "1",
index 155ab32b7712bccfb7046d10ea2e8b981ac88183..2b205bcad1a799631781df80c09088ce0be90177 100644 (file)
@@ -1555,10 +1555,13 @@ def test_rrm_beacon_req_passive_scan_vht(dev, apdev):
                 raise HwsimSkip("80 MHz channel not supported in regulatory information")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_rrm_beacon_req_passive_scan_vht160(dev, apdev):
@@ -1601,10 +1604,13 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev):
             raise HwsimSkip("ZA regulatory rule likely did not have DFS requirement removed")
         raise
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_rrm_beacon_req_ap_errors(dev, apdev):
index 1d13194c398c54b286189f0b93e1b781d8ab48ac..f2b5dd3efded644b5f4066dd029f0abef99a02b2 100644 (file)
@@ -23,13 +23,13 @@ def clear_regdom_state(dev, hapd, hapd2):
             ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
             if ev is None or "init=COUNTRY_IE" in ev:
                 break
-        dev[0].request("DISCONNECT")
-        dev[0].request("ABORT_SCAN")
-        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         if hapd:
             hapd.request("DISABLE")
         if hapd2:
             hapd2.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         dev[0].dump_monitor()
         subprocess.call(['iw', 'reg', 'set', '00'])
         dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
@@ -1128,13 +1128,13 @@ def start_wnm_tm(ap, country, dev, country3=None):
     return hapd, id
 
 def stop_wnm_tm(hapd, dev):
+    if hapd:
+        hapd.request("DISABLE")
     dev.request("DISCONNECT")
     try:
         dev.wait_disconnected()
     except:
         pass
-    if hapd:
-        hapd.request("DISABLE")
     subprocess.call(['iw', 'reg', 'set', '00'])
     dev.flush_scan_cache()
 
@@ -1864,11 +1864,15 @@ def test_wnm_bss_tm_reject(dev, apdev):
         if "status_code=123" not in ev:
             raise Exception("Unexpected BSS Transition Management Response status: " + ev)
         dev[0].wait_disconnected()
+        dev[0].wait_connected()
     finally:
-        dev[0].request("DISCONNECT")
         if hapd:
             hapd.request("DISABLE")
+        dev[0].request("DISCONNECT")
+        dev[0].request("ABORT_SCAN")
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
+        dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()
 
 def test_wnm_bss_tm_ap_proto(dev, apdev):
index ba0445f5756a85d160c04a2e81f618189443a280..1aff48ae5cb402639d429e092368a529744d9d2b 100644 (file)
@@ -382,7 +382,10 @@ def _test_wpas_ap_dfs(dev):
         raise Exception("AP failed to start")
 
     dev[1].connect("wpas-ap-dfs", key_mgmt="NONE")
+    dev[1].wait_regdom(country_ie=True)
+    dev[0].request("DISCONNECT")
     dev[1].request("DISCONNECT")
+    dev[1].request("ABORT_SCAN")
     dev[1].wait_disconnected()
 
 @remote_compatible