tests: Work around cfg80211 reg.c intersection (country 98) issues

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>
This commit is contained in:
Jouni Malinen 2018-12-22 15:55:19 +02:00
parent 99bc57d0d1
commit b586054f95
9 changed files with 176 additions and 38 deletions

View file

@ -154,12 +154,15 @@ def test_ap_acs_5ghz(dev, apdev):
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq) dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
def test_ap_acs_5ghz_40mhz(dev, apdev): 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") raise Exception("Secondary channel not set")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq) dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
def test_ap_acs_vht(dev, apdev): def test_ap_acs_vht(dev, apdev):
@ -214,12 +220,15 @@ def test_ap_acs_vht(dev, apdev):
raise Exception("Secondary channel not set") raise Exception("Secondary channel not set")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq) dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
def test_ap_acs_vht40(dev, apdev): def test_ap_acs_vht40(dev, apdev):
@ -247,12 +256,15 @@ def test_ap_acs_vht40(dev, apdev):
raise Exception("Secondary channel not set") raise Exception("Secondary channel not set")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq) dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
def test_ap_acs_vht160(dev, apdev): def test_ap_acs_vht160(dev, apdev):
@ -283,11 +295,16 @@ def test_ap_acs_vht160(dev, apdev):
if int(freq) < 5000: if int(freq) < 5000:
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("test-acs", psk="12345678", scan_freq=freq) dev[0].connect("test-acs", psk="12345678", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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): def test_ap_acs_vht160_scan_disable(dev, apdev):
"""Automatic channel selection for VHT160 and DISABLE during scan""" """Automatic channel selection for VHT160 and DISABLE during scan"""

View file

@ -767,10 +767,16 @@ def test_ap_open_country_outdoor(dev, apdev):
def _test_ap_open_country(dev, apdev, country_code, country3): def _test_ap_open_country(dev, apdev, country_code, country3):
try: try:
run_ap_open_country(dev, apdev, country_code, country3) hapd = None
hapd = run_ap_open_country(dev, apdev, country_code, country3)
finally: finally:
if hapd:
hapd.request("DISABLE")
dev[0].request("DISCONNECT") 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]) 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[0].flush_scan_cache()
def run_ap_open_country(dev, apdev, country_code, country3): 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" }) "ieee80211d": "1" })
dev[0].scan_for_bss(hapd.own_addr(), freq=2412) dev[0].scan_for_bss(hapd.own_addr(), freq=2412)
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
dev[0].request("DISCONNECT") dev[0].wait_regdom(country_ie=True)
dev[0].wait_disconnected() return hapd
def test_ap_open_disable_select(dev, apdev): def test_ap_open_disable_select(dev, apdev):
"""DISABLE_NETWORK for connected AP followed by SELECT_NETWORK""" """DISABLE_NETWORK for connected AP followed by SELECT_NETWORK"""

View file

@ -116,10 +116,13 @@ def test_ap_country(dev, apdev):
dev[0].connect(ssid, psk=passphrase, scan_freq="5180") dev[0].connect(ssid, psk=passphrase, scan_freq="5180")
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
def test_ap_acl_accept(dev, apdev): def test_ap_acl_accept(dev, apdev):
@ -415,11 +418,15 @@ def test_ap_spectrum_management_required(dev, apdev):
hapd = None hapd = None
hapd = hostapd.add_ap(apdev[0], params) hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180")
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) 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() dev[0].flush_scan_cache()
@remote_compatible @remote_compatible

View file

@ -357,6 +357,7 @@ def test_ap_vht160(dev, apdev):
raise Exception("Unexpected interface state") raise Exception("Unexpected interface state")
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
sig = dev[0].request("SIGNAL_POLL").splitlines() sig = dev[0].request("SIGNAL_POLL").splitlines()
if "FREQUENCY=5180" not in sig: 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 HwsimSkip("80/160 MHz channel not supported in regulatory information")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_vht160b(dev, apdev): def test_ap_vht160b(dev, apdev):
@ -427,6 +431,7 @@ def test_ap_vht160b(dev, apdev):
raise Exception("Unexpected frequency(2)") raise Exception("Unexpected frequency(2)")
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520")
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
sig = dev[0].request("SIGNAL_POLL").splitlines() sig = dev[0].request("SIGNAL_POLL").splitlines()
if "FREQUENCY=5520" not in sig: 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 HwsimSkip("80/160 MHz channel not supported in regulatory information")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_vht160_no_dfs_100_plus(dev, apdev): 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) freq = str(int(channel) * 5 + 5000)
dev[0].connect("vht", key_mgmt="NONE", scan_freq=freq) dev[0].connect("vht", key_mgmt="NONE", scan_freq=freq)
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
sig = dev[0].request("SIGNAL_POLL").splitlines() sig = dev[0].request("SIGNAL_POLL").splitlines()
if "FREQUENCY=" + freq not in sig: 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 HwsimSkip("80/160 MHz channel not supported in regulatory information")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_vht160_no_ht40(dev, apdev): 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) hapd = hostapd.add_ap(apdev[0], params)
dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
dev[0].wait_regdom(country_ie=True)
except Exception, e: except Exception, e:
if isinstance(e, Exception) and str(e) == "AP startup failed": if isinstance(e, Exception) and str(e) == "AP startup failed":
if not vht_supported(): if not vht_supported():
raise HwsimSkip("80 MHz channel not supported in regulatory information") raise HwsimSkip("80 MHz channel not supported in regulatory information")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_ap_vht_use_sta_nsts(dev, apdev): 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) hapd = hostapd.add_ap(ap, params)
dev.connect("test-vht40", scan_freq="5805", key_mgmt="NONE") dev.connect("test-vht40", scan_freq="5805", key_mgmt="NONE")
dev.wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev, hapd) hwsim_utils.test_connectivity(dev, hapd)
finally: finally:
dev.request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev.flush_scan_cache() dev.flush_scan_cache()
def test_ap_vht80_to_24g_ht(dev, apdev): def test_ap_vht80_to_24g_ht(dev, apdev):

View file

@ -106,6 +106,7 @@ def test_dfs(dev, apdev):
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1") hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1")
@ -128,10 +129,13 @@ def test_dfs(dev, apdev):
time.sleep(1) time.sleep(1)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_etsi(dev, apdev, params): def test_dfs_etsi(dev, apdev, params):
@ -161,6 +165,7 @@ def test_dfs_etsi(dev, apdev, params):
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq) 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) time.sleep(1)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar1(dev, apdev): def test_dfs_radar1(dev, apdev):
@ -255,11 +263,15 @@ def test_dfs_radar1(dev, apdev):
raise Exception("Unexpected frequency: " + freq) raise Exception("Unexpected frequency: " + freq)
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar2(dev, apdev): def test_dfs_radar2(dev, apdev):
@ -324,11 +336,15 @@ def test_dfs_radar_chanlist(dev, apdev):
if "AP-ENABLED" not in ev: if "AP-ENABLED" not in ev:
raise Exception("Unexpected DFS event: " + ev) raise Exception("Unexpected DFS event: " + ev)
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar_chanlist_vht80(dev, apdev): 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: if "AP-ENABLED" not in ev:
raise Exception("Unexpected DFS event: " + ev) raise Exception("Unexpected DFS event: " + ev)
dev[0].connect("dfs", key_mgmt="NONE") 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": if hapd.get_status_field('vht_oper_centr_freq_seg0_idx') != "42":
raise Exception("Unexpected seg0 idx") raise Exception("Unexpected seg0 idx")
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar_chanlist_vht20(dev, apdev): 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: if "AP-ENABLED" not in ev:
raise Exception("Unexpected DFS event: " + ev) raise Exception("Unexpected DFS event: " + ev)
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar_no_ht(dev, apdev): 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: if "AP-ENABLED" not in ev:
raise Exception("Unexpected DFS event: " + ev) raise Exception("Unexpected DFS event: " + ev)
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_dfs_radar_ht40minus(dev, apdev): def test_dfs_radar_ht40minus(dev, apdev):
@ -467,12 +495,18 @@ def test_dfs_radar_ht40minus(dev, apdev):
if "AP-ENABLED" not in ev: if "AP-ENABLED" not in ev:
raise Exception("Unexpected DFS event: " + ev) raise Exception("Unexpected DFS event: " + ev)
dev[0].connect("dfs", key_mgmt="NONE") dev[0].connect("dfs", key_mgmt="NONE")
dev[0].wait_regdom(country_ie=True)
dev[0].request("STA_AUTOCONNECT 0")
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
dev[0].request("STA_AUTOCONNECT 1")
def test_dfs_ht40_minus(dev, apdev, params): def test_dfs_ht40_minus(dev, apdev, params):
"""DFS CAC functionality on channel 104 HT40- [long]""" """DFS CAC functionality on channel 104 HT40- [long]"""
@ -502,10 +536,14 @@ def test_dfs_ht40_minus(dev, apdev, params):
raise Exception("Unexpected frequency") raise Exception("Unexpected frequency")
dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520") dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520")
dev[0].wait_regdom(country_ie=True)
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()

View file

@ -98,6 +98,7 @@ def run_wpa2_ocv_5ghz(dev, apdev):
for ocv in range(2): for ocv in range(2):
dev[0].connect(ssid, psk=passphrase, scan_freq="5200", ocv=str(ocv), dev[0].connect(ssid, psk=passphrase, scan_freq="5200", ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[0].wait_disconnected() dev[0].wait_disconnected()
@ -149,6 +150,7 @@ def run_wpa2_ocv_ht40(dev, apdev):
ieee80211w="1", disable_ht="1") ieee80211w="1", disable_ht="1")
dev[1].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), dev[1].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[0].wait_disconnected() dev[0].wait_disconnected()
@ -190,6 +192,7 @@ def run_wpa2_ocv_vht40(dev, apdev):
ieee80211w="1", disable_vht="1") ieee80211w="1", disable_vht="1")
dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[2].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") ieee80211w="1", disable_vht="1")
dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[2].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") ieee80211w="1", disable_vht="1")
dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[2].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) run_wpa2_ocv_vht80plus80(dev, apdev)
finally: finally:
set_world_reg(apdev[0], apdev[1], dev[0]) 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[0].flush_scan_cache()
dev[1].flush_scan_cache() dev[1].flush_scan_cache()
dev[2].flush_scan_cache() dev[2].flush_scan_cache()
@ -313,13 +319,24 @@ def run_wpa2_ocv_vht80plus80(dev, apdev):
ieee80211w="1", disable_vht="1") ieee80211w="1", disable_vht="1")
dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv),
ieee80211w="1") ieee80211w="1")
dev[0].wait_regdom(country_ie=True)
dev[0].request("REMOVE_NETWORK all") dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all")
dev[2].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all")
dev[0].wait_disconnected() dev[0].wait_disconnected()
dev[1].wait_disconnected() dev[1].wait_disconnected()
dev[2].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() 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: class APConnection:
def init_params(self): def init_params(self):
@ -372,6 +389,8 @@ class APConnection:
dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq, ocv=sta_ocv, dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq, ocv=sta_ocv,
ieee80211w="1", wait_connect=False) ieee80211w="1", wait_connect=False)
if "country_code" in params:
dev.wait_regdom(country_ie=True)
self.addr = dev.p2p_interface_addr() self.addr = dev.p2p_interface_addr()
# Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated # 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) run_wpa2_ocv_ap_vht160_mismatch(dev, apdev)
finally: finally:
set_world_reg(apdev[0], apdev[1], dev[0]) 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[0].flush_scan_cache()
def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev): 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) conn.confirm_valid_oci(129, 100, 0)
dev[0].dump_monitor() dev[0].dump_monitor()
if conn.hapd:
conn.hapd.request("DISABLE")
dev[0].request("DISCONNECT") 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 @remote_compatible
def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): 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) run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev)
finally: finally:
set_world_reg(apdev[0], apdev[1], dev[0]) 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[0].flush_scan_cache()
def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): 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) conn.confirm_valid_oci(130, 36, 155)
dev[0].dump_monitor() dev[0].dump_monitor()
if conn.hapd:
conn.hapd.request("DISABLE")
dev[0].request("DISCONNECT") 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 @remote_compatible
def test_wpa2_ocv_ap_unexpected1(dev, apdev): 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, self.dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq,
wait_connect=False, **sta_params) wait_connect=False, **sta_params)
if "country_code" in params:
self.dev.wait_regdom(country_ie=True)
self.addr = dev.p2p_interface_addr() self.addr = dev.p2p_interface_addr()
# Forward msg 1/4 from AP to STA # 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) run_wpa2_ocv_vht160_mismatch_client(dev, apdev)
finally: finally:
set_world_reg(apdev[0], apdev[1], dev[0]) 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[0].flush_scan_cache()
def run_wpa2_ocv_vht160_mismatch_client(dev, apdev): 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") 129, 104, 0, "primary channel mismatch")
conn.confirm_valid_oci(122, 100, 0) 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): def test_wpa2_ocv_sta_group_hs(dev, apdev):
"""OCV group handshake (STA)""" """OCV group handshake (STA)"""
params = { "channel": "1", params = { "channel": "1",

View 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 HwsimSkip("80 MHz channel not supported in regulatory information")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_rrm_beacon_req_passive_scan_vht160(dev, apdev): 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 HwsimSkip("ZA regulatory rule likely did not have DFS requirement removed")
raise raise
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_rrm_beacon_req_ap_errors(dev, apdev): def test_rrm_beacon_req_ap_errors(dev, apdev):

View file

@ -23,13 +23,13 @@ def clear_regdom_state(dev, hapd, hapd2):
ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
if ev is None or "init=COUNTRY_IE" in ev: if ev is None or "init=COUNTRY_IE" in ev:
break break
dev[0].request("DISCONNECT")
dev[0].request("ABORT_SCAN")
dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
if hapd: if hapd:
hapd.request("DISABLE") hapd.request("DISABLE")
if hapd2: if hapd2:
hapd2.request("DISABLE") 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() dev[0].dump_monitor()
subprocess.call(['iw', 'reg', 'set', '00']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) 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 return hapd, id
def stop_wnm_tm(hapd, dev): def stop_wnm_tm(hapd, dev):
if hapd:
hapd.request("DISABLE")
dev.request("DISCONNECT") dev.request("DISCONNECT")
try: try:
dev.wait_disconnected() dev.wait_disconnected()
except: except:
pass pass
if hapd:
hapd.request("DISABLE")
subprocess.call(['iw', 'reg', 'set', '00']) subprocess.call(['iw', 'reg', 'set', '00'])
dev.flush_scan_cache() dev.flush_scan_cache()
@ -1864,11 +1864,15 @@ def test_wnm_bss_tm_reject(dev, apdev):
if "status_code=123" not in ev: if "status_code=123" not in ev:
raise Exception("Unexpected BSS Transition Management Response status: " + ev) raise Exception("Unexpected BSS Transition Management Response status: " + ev)
dev[0].wait_disconnected() dev[0].wait_disconnected()
dev[0].wait_connected()
finally: finally:
dev[0].request("DISCONNECT")
if hapd: if hapd:
hapd.request("DISABLE") 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']) subprocess.call(['iw', 'reg', 'set', '00'])
dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
dev[0].flush_scan_cache() dev[0].flush_scan_cache()
def test_wnm_bss_tm_ap_proto(dev, apdev): def test_wnm_bss_tm_ap_proto(dev, apdev):

View file

@ -382,7 +382,10 @@ def _test_wpas_ap_dfs(dev):
raise Exception("AP failed to start") raise Exception("AP failed to start")
dev[1].connect("wpas-ap-dfs", key_mgmt="NONE") 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("DISCONNECT")
dev[1].request("ABORT_SCAN")
dev[1].wait_disconnected() dev[1].wait_disconnected()
@remote_compatible @remote_compatible