tests: External MAC address change for connection

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2020-01-02 12:09:33 +02:00
parent ad2f096609
commit b5a3b80718

View file

@ -165,6 +165,55 @@ def test_sta_dynamic_ext_mac_addr_change(dev, apdev):
'address', prev_addr])
subprocess.call(['ifconfig', wpas.ifname, 'up'])
def test_sta_dynamic_ext_mac_addr_change_for_connection(dev, apdev):
"""Dynamically added wpa_supplicant interface with external MAC address change for connection"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
hapd = hostapd.add_ap(apdev[0], params)
bssid = apdev[0]['ifname']
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5")
wpas.scan_for_bss(bssid, freq=2412)
subprocess.call(['ifconfig', wpas.ifname, 'down'])
if wpas.get_status_field("wpa_state") != "INTERFACE_DISABLED":
raise Exception("Unexpected wpa_state")
prev_addr = wpas.own_addr()
new_addr = '02:11:22:33:44:55'
try:
subprocess.call(['ip', 'link', 'set', 'dev', wpas.ifname,
'address', new_addr])
subprocess.call(['ifconfig', wpas.ifname, 'up'])
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412",
wait_connect=False)
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED",
"CTRL-EVENT-SCAN-RESULTS"], timeout=10)
if "CTRL-EVENT-SCAN-RESULTS" in ev:
raise Exception("Unexpected scan after MAC address change")
hapd.wait_sta()
hwsim_utils.test_connectivity(wpas, hapd)
sta = hapd.get_sta(new_addr)
if sta['addr'] != new_addr:
raise Exception("STA association with new address not found")
wpas.request("DISCONNECT")
wpas.wait_disconnected()
wpas.dump_monitor()
subprocess.call(['ifconfig', wpas.ifname, 'down'])
time.sleep(0.1)
res = wpas.get_bss(bssid)
if res is None:
raise Exception("BSS entry not maintained after interface disabling")
ev = wpas.wait_event(["CTRL-EVENT-BSS-REMOVED"], timeout=5.5)
if ev is None:
raise Exception("BSS entry not removed after interface has been disabled for a while")
res2 = wpas.get_bss(bssid)
if res2 is not None:
raise Exception("Unexpected BSS entry found on a disabled interface")
finally:
subprocess.call(['ifconfig', wpas.ifname, 'down'])
subprocess.call(['ip', 'link', 'set', 'dev', wpas.ifname,
'address', prev_addr])
subprocess.call(['ifconfig', wpas.ifname, 'up'])
def test_sta_dynamic_random_mac_addr(dev, apdev):
"""Dynamically added wpa_supplicant interface and random MAC address"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")