3 # Test cases for AP VLAN
4 # Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
6 # This software may be distributed under the terms of the BSD license.
7 # See README for more details.
9 from remotehost import remote_compatible
13 logger = logging.getLogger(__name__)
17 netifaces_imported = True
19 netifaces_imported = False
23 from utils import iface_is_in_bridge, HwsimSkip
25 from tshark import run_tshark
27 def test_ap_vlan_open(dev, apdev):
28 """AP VLAN with open network"""
29 params = { "ssid": "test-vlan-open",
31 "accept_mac_file": "hostapd.accept" }
32 hapd = hostapd.add_ap(apdev[0], params)
34 dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
35 dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
36 dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
37 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
38 hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
39 hwsim_utils.test_connectivity(dev[2], hapd)
41 def test_ap_vlan_file_open(dev, apdev):
42 """AP VLAN with open network and vlan_file mapping"""
43 params = { "ssid": "test-vlan-open",
45 "vlan_file": "hostapd.vlan",
46 "accept_mac_file": "hostapd.accept" }
47 hapd = hostapd.add_ap(apdev[0], params)
49 dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
50 dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
51 dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
52 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
53 hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
54 hwsim_utils.test_connectivity(dev[2], hapd)
56 def test_ap_vlan_wpa2(dev, apdev):
57 """AP VLAN with WPA2-PSK"""
58 params = hostapd.wpa2_params(ssid="test-vlan",
59 passphrase="12345678")
60 params['dynamic_vlan'] = "1"
61 params['accept_mac_file'] = "hostapd.accept"
62 hapd = hostapd.add_ap(apdev[0], params)
64 dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
65 dev[1].connect("test-vlan", psk="12345678", scan_freq="2412")
66 dev[2].connect("test-vlan", psk="12345678", scan_freq="2412")
67 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
68 hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
69 hwsim_utils.test_connectivity(dev[2], hapd)
71 def test_ap_vlan_wpa2_radius(dev, apdev):
72 """AP VLAN with WPA2-Enterprise and RADIUS attributes"""
73 params = hostapd.wpa2_eap_params(ssid="test-vlan")
74 params['dynamic_vlan'] = "1"
75 hapd = hostapd.add_ap(apdev[0], params)
77 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
79 password_hex="0123456789abcdef0123456789abcdef",
81 dev[1].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
83 password_hex="0123456789abcdef0123456789abcdef",
85 dev[2].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
86 identity="pax.user@example.com",
87 password_hex="0123456789abcdef0123456789abcdef",
89 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
90 hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
91 hwsim_utils.test_connectivity(dev[2], hapd)
93 def test_ap_vlan_wpa2_radius_2(dev, apdev):
94 """AP VLAN with WPA2-Enterprise and RADIUS EGRESS_VLANID attributes"""
95 params = hostapd.wpa2_eap_params(ssid="test-vlan")
96 params['dynamic_vlan'] = "1"
97 hapd = hostapd.add_ap(apdev[0], params)
99 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
101 password_hex="0123456789abcdef0123456789abcdef",
104 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
106 def test_ap_vlan_wpa2_radius_id_change(dev, apdev):
107 """AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID"""
108 generic_ap_vlan_wpa2_radius_id_change(dev, apdev, False)
110 def test_ap_vlan_tagged_wpa2_radius_id_change(dev, apdev):
111 """AP tagged VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID"""
115 # Create tagged interface for wpa_supplicant
116 subprocess.call(['ip', 'link', 'add', 'link', dev[0].ifname,
117 'name', ifname1, 'type', 'vlan', 'id', '1'])
118 subprocess.call(['ifconfig', ifname1, 'up'])
120 subprocess.call(['ip', 'link', 'add', 'link', dev[0].ifname,
121 'name', ifname2, 'type', 'vlan', 'id', '2'])
122 subprocess.call(['ifconfig', ifname2, 'up'])
124 generic_ap_vlan_wpa2_radius_id_change(dev, apdev, True)
126 subprocess.call(['ifconfig', ifname1, 'down'])
127 subprocess.call(['ifconfig', ifname2, 'down'])
128 subprocess.call(['ip', 'link', 'del', ifname1])
129 subprocess.call(['ip', 'link', 'del', ifname2])
131 def generic_ap_vlan_wpa2_radius_id_change(dev, apdev, tagged):
132 as_params = { "ssid": "as",
133 "beacon_int": "2000",
134 "radius_server_clients": "auth_serv/radius_clients.conf",
135 "radius_server_auth_port": '18128',
137 "eap_user_file": "auth_serv/eap_user.conf",
138 "ca_cert": "auth_serv/ca.pem",
139 "server_cert": "auth_serv/server.pem",
140 "private_key": "auth_serv/server.key" }
141 authserv = hostapd.add_ap(apdev[1], as_params)
143 params = hostapd.wpa2_eap_params(ssid="test-vlan")
144 params['dynamic_vlan'] = "1"
145 params['auth_server_port'] = "18128"
146 hapd = hostapd.add_ap(apdev[0], params)
148 identity = "vlan1tagged" if tagged else "vlan1"
150 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
152 password_hex="0123456789abcdef0123456789abcdef",
155 hwsim_utils.run_connectivity_test(dev[0], hapd, 0, ifname1="wlan0.1",
158 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
160 logger.info("VLAN-ID -> 2")
163 authserv.set('eap_user_file', "auth_serv/eap_user_vlan.conf")
166 dev[0].dump_monitor()
167 dev[0].request("REAUTHENTICATE")
168 ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
170 raise Exception("EAP reauthentication timed out")
171 ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
173 raise Exception("4-way handshake after reauthentication timed out")
174 state = dev[0].get_status_field('wpa_state')
175 if state != "COMPLETED":
176 raise Exception("Unexpected state after reauth: " + state)
177 sta = hapd.get_sta(dev[0].own_addr())
178 if 'vlan_id' not in sta:
179 raise Exception("No VLAN ID in STA info")
180 if (not tagged) and (sta['vlan_id'] != '2'):
181 raise Exception("Unexpected VLAN ID: " + sta['vlan_id'])
183 hwsim_utils.run_connectivity_test(dev[0], hapd, 0, ifname1="wlan0.2",
186 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2")
188 logger.info("VLAN-ID -> 1")
192 authserv.set('eap_user_file', "auth_serv/eap_user.conf")
195 dev[0].dump_monitor()
196 dev[0].request("REAUTHENTICATE")
197 ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
199 raise Exception("EAP reauthentication timed out")
200 ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
202 raise Exception("4-way handshake after reauthentication timed out")
203 state = dev[0].get_status_field('wpa_state')
204 if state != "COMPLETED":
205 raise Exception("Unexpected state after reauth: " + state)
206 sta = hapd.get_sta(dev[0].own_addr())
207 if 'vlan_id' not in sta:
208 raise Exception("No VLAN ID in STA info")
209 if (not tagged) and (sta['vlan_id'] != '1'):
210 raise Exception("Unexpected VLAN ID: " + sta['vlan_id'])
214 hwsim_utils.run_connectivity_test(dev[0], hapd, 0,
218 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
220 # It is possible for new bridge setup to not be ready immediately, so
221 # try again to avoid reporting issues related to that.
222 logger.info("First VLAN-ID 1 data test failed - try again")
224 hwsim_utils.run_connectivity_test(dev[0], hapd, 0,
228 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
230 def test_ap_vlan_wpa2_radius_required(dev, apdev):
231 """AP VLAN with WPA2-Enterprise and RADIUS attributes required"""
232 params = hostapd.wpa2_eap_params(ssid="test-vlan")
233 params['dynamic_vlan'] = "2"
234 hostapd.add_ap(apdev[0], params)
236 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
238 password_hex="0123456789abcdef0123456789abcdef",
240 dev[2].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
241 identity="pax.user@example.com",
242 password_hex="0123456789abcdef0123456789abcdef",
243 scan_freq="2412", wait_connect=False)
244 ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED",
245 "CTRL-EVENT-DISCONNECTED"], timeout=20)
247 raise Exception("Timeout on connection attempt")
248 if "CTRL-EVENT-CONNECTED" in ev:
249 raise Exception("Unexpected success without tunnel parameters")
251 def test_ap_vlan_tagged(dev, apdev):
252 """AP VLAN with tagged interface"""
253 params = { "ssid": "test-vlan-open",
255 "vlan_tagged_interface": "lo",
256 "accept_mac_file": "hostapd.accept" }
257 hapd = hostapd.add_ap(apdev[0], params)
259 dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
260 dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
261 dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
262 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brlo.1")
263 hwsim_utils.test_connectivity_iface(dev[1], hapd, "brlo.2")
264 hwsim_utils.test_connectivity(dev[2], hapd)
266 def ap_vlan_iface_cleanup_multibss_cleanup():
267 subprocess.call(['ifconfig', 'dummy0', 'down'],
268 stderr=open('/dev/null', 'w'))
269 ifnames = [ 'wlan3.1', 'wlan3.2', 'wlan3-2.1', 'wlan3-2.2', 'dummy0.2',
270 'dummy0.1', 'dummy0', 'brvlan1', 'brvlan2' ]
271 for ifname in ifnames:
272 subprocess.call(['ip', 'link', 'del', ifname],
273 stderr=open('/dev/null', 'w'))
275 def ap_vlan_iface_test_and_prepare_environ():
276 ifaces = netifaces.interfaces()
277 if "dummy0" in ifaces:
278 raise Exception("dummy0 already exists before")
279 ifaces = netifaces.interfaces()
280 if "dummy0.1" in ifaces:
281 raise Exception("dummy0.1 already exists before")
283 subprocess.call(['ip', 'link', 'add', 'dummy0', 'type', 'dummy'])
284 subprocess.call(['ifconfig', 'dummy0', 'up'])
286 ifaces = netifaces.interfaces()
287 if not("dummy0" in ifaces):
288 raise HwsimSkip("failed to add dummy0 - missing kernel config DUMMY ?")
290 subprocess.call(['ip', 'link', 'add', 'link', 'dummy0', 'name', 'dummy0.1',
291 'type', 'vlan', 'id', '1'])
293 ifaces = netifaces.interfaces()
294 if not("dummy0.1" in ifaces):
295 raise HwsimSkip("failed to add dummy0.1 - missing kernel config VLAN_8021Q ?")
297 subprocess.call(['ip', 'link', 'del', 'dummy0.1'])
299 ifaces = netifaces.interfaces()
300 if "dummy0.1" in ifaces:
301 raise Exception("dummy0.1 was not removed before testing")
303 def test_ap_vlan_iface_cleanup_multibss(dev, apdev):
304 """AP VLAN operation in multi-BSS multi-VLAN case"""
305 ap_vlan_iface_cleanup_multibss(dev, apdev, 'multi-bss-iface.conf')
307 def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile):
308 # AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID
309 # check that multiple bss do not interfere with each other with respect
310 # to deletion of bridge and tagged interface.
312 if not netifaces_imported:
313 raise HwsimSkip("python module netifaces not available")
316 ap_vlan_iface_cleanup_multibss_cleanup()
317 ap_vlan_iface_test_and_prepare_environ()
319 as_params = { "ssid": "as",
320 "beacon_int": "2000",
321 "radius_server_clients": "auth_serv/radius_clients.conf",
322 "radius_server_auth_port": '18128',
324 "eap_user_file": "auth_serv/eap_user.conf",
325 "ca_cert": "auth_serv/ca.pem",
326 "server_cert": "auth_serv/server.pem",
327 "private_key": "auth_serv/server.key",
329 authserv = hostapd.add_ap(apdev[1], as_params)
331 # start the actual test
332 hapd = hostapd.add_iface(apdev[0], cfgfile)
333 hapd1 = hostapd.Hostapd("wlan3-2", 1)
336 ifaces = netifaces.interfaces()
337 if "brvlan1" in ifaces:
338 raise Exception("bridge brvlan1 already exists before")
339 if "brvlan2" in ifaces:
340 raise Exception("bridge brvlan2 already exists before")
342 dev[0].connect("bss-1", key_mgmt="WPA-EAP", eap="PAX",
344 password_hex="0123456789abcdef0123456789abcdef",
347 ifaces = netifaces.interfaces()
348 if not("brvlan1" in ifaces):
349 raise Exception("bridge brvlan1 was not created")
351 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
352 if not iface_is_in_bridge("brvlan1", "dummy0.1"):
353 raise Exception("dummy0.1 not in brvlan1")
355 dev[1].connect("bss-2", key_mgmt="WPA-EAP", eap="PAX",
357 password_hex="0123456789abcdef0123456789abcdef",
360 hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1")
361 if not iface_is_in_bridge("brvlan1", "dummy0.1"):
362 raise Exception("dummy0.1 not in brvlan1")
365 authserv.set('eap_user_file', "auth_serv/eap_user_vlan.conf")
368 logger.info("wlan0 -> VLAN 2")
370 dev[0].dump_monitor()
371 dev[0].request("REAUTHENTICATE")
372 ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
374 raise Exception("EAP reauthentication timed out")
375 ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
377 raise Exception("4-way handshake after reauthentication timed out")
378 state = dev[0].get_status_field('wpa_state')
379 if state != "COMPLETED":
380 raise Exception("Unexpected state after reauth: " + state)
382 ifaces = netifaces.interfaces()
383 if not ("brvlan1" in ifaces):
384 raise Exception("bridge brvlan1 has been removed too early")
386 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2",
389 if not iface_is_in_bridge("brvlan2", "dummy0.2"):
390 raise Exception("dummy0.2 not in brvlan2")
392 logger.info("test wlan1 == VLAN 1")
393 hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1")
394 if not iface_is_in_bridge("brvlan1", "dummy0.1"):
395 raise Exception("dummy0.1 not in brvlan1")
397 logger.info("wlan1 -> VLAN 2")
399 dev[1].dump_monitor()
400 dev[1].request("REAUTHENTICATE")
401 ev = dev[1].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
403 raise Exception("EAP reauthentication timed out")
404 ev = dev[1].wait_event(["WPA: Key negotiation completed"], timeout=5)
406 raise Exception("4-way handshake after reauthentication timed out")
407 state = dev[1].get_status_field('wpa_state')
408 if state != "COMPLETED":
409 raise Exception("Unexpected state after reauth: " + state)
411 # it can take some time for data connectivity to be updated
412 hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan2",
414 logger.info("test wlan0 == VLAN 2")
415 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2")
417 if not iface_is_in_bridge("brvlan2", "dummy0.2"):
418 raise Exception("dummy0.2 not in brvlan2")
420 ifaces = netifaces.interfaces()
421 if "brvlan1" in ifaces:
422 raise Exception("bridge brvlan1 has not been cleaned up")
424 # disconnect dev0 first to test a corner case
425 dev[0].request("DISCONNECT")
426 dev[0].wait_disconnected()
427 dev[1].request("DISCONNECT")
428 dev[1].wait_disconnected()
430 # station removal needs some time
433 ifaces = netifaces.interfaces()
434 if "brvlan2" not in ifaces:
437 ifaces = netifaces.interfaces()
438 if "brvlan2" in ifaces:
439 raise Exception("bridge brvlan2 has not been cleaned up")
441 hapd.request("DISABLE")
443 ap_vlan_iface_cleanup_multibss_cleanup()
445 def test_ap_vlan_iface_cleanup_multibss_per_sta_vif(dev, apdev):
446 """AP VLAN operation in multi-BSS multi-VLAN case with per-sta-vif set"""
448 # AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID
449 # check that multiple bss do not interfere with each other with respect
450 # to deletion of bridge and tagged interface. per_sta_vif is enabled.
451 ap_vlan_iface_cleanup_multibss(dev, apdev,
452 'multi-bss-iface-per_sta_vif.conf')
454 def test_ap_vlan_without_station(dev, apdev, p):
455 """AP VLAN with WPA2-PSK and no station"""
457 subprocess.call(['brctl', 'addbr', 'brvlan1'])
458 subprocess.call(['brctl', 'setfd', 'brvlan1', '0'])
459 subprocess.call(['ifconfig', 'brvlan1', 'up'])
460 # use a passphrase wlantest does not know, so it cannot
461 # inject decrypted frames into pcap
462 params = hostapd.wpa2_params(ssid="test-vlan",
463 passphrase="12345678x")
464 params['dynamic_vlan'] = "1"
465 params['vlan_file'] = 'hostapd.wlan3.vlan'
466 params['accept_mac_file'] = "hostapd.accept"
467 hapd = hostapd.add_ap(apdev[0], params)
469 # inject some traffic
471 da = "ff:ff:ff:ff:ff:00"
472 hapd.request('DATA_TEST_CONFIG 1 ifname=brvlan1')
473 hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
474 hapd.request('DATA_TEST_CONFIG 0')
477 dev[0].connect("test-vlan", psk="12345678x", scan_freq="2412")
479 # inject some traffic
481 da = "ff:ff:ff:ff:ff:01"
482 hapd.request('DATA_TEST_CONFIG 1 ifname=brvlan1')
483 hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
484 hapd.request('DATA_TEST_CONFIG 0')
486 # let the AP send couple of Beacon frames
488 out = run_tshark(os.path.join(p['logdir'], "hwsim0.pcapng"),
489 "wlan.da == ff:ff:ff:ff:ff:00",
490 ["wlan.fc.protected"])
493 lines = out.splitlines()
495 raise Exception("first frame not observed")
498 is_protected = int(l, 16)
499 if is_protected != 1:
502 raise Exception("Broadcast packets were not encrypted when no station was connected")
504 raise Exception("first frame not observed")
506 out = run_tshark(os.path.join(p['logdir'], "hwsim0.pcapng"),
507 "wlan.da == ff:ff:ff:ff:ff:01",
508 ["wlan.fc.protected"])
511 lines = out.splitlines()
513 raise Exception("second frame not observed")
516 is_protected = int(l, 16)
517 if is_protected != 1:
520 raise Exception("Broadcast packets were not encrypted when station was connected")
522 raise Exception("second frame not observed")
524 dev[0].request("DISCONNECT")
525 dev[0].wait_disconnected()
528 subprocess.call(['ip', 'link', 'set', 'dev', 'brvlan1', 'down'])
529 subprocess.call(['ip', 'link', 'set', 'dev', 'wlan3.1', 'down'],
530 stderr=open('/dev/null', 'w'))
531 subprocess.call(['brctl', 'delif', 'brvlan1', 'wlan3.1'],
532 stderr=open('/dev/null', 'w'))
533 subprocess.call(['brctl', 'delbr', 'brvlan1'])
536 def test_ap_open_per_sta_vif(dev, apdev):
537 """AP VLAN with open network"""
538 params = { "ssid": "test-vlan-open",
540 hapd = hostapd.add_ap(apdev[0], params)
542 dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
543 hwsim_utils.test_connectivity_iface(dev[0], hapd,
544 apdev[0]['ifname'] + ".4096")
547 def test_ap_vlan_open_per_sta_vif(dev, apdev):
548 """AP VLAN (dynamic) with open network"""
549 params = { "ssid": "test-vlan-open",
551 "dynamic_vlan": "1" }
552 hapd = hostapd.add_ap(apdev[0], params)
554 dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
555 hwsim_utils.test_connectivity_iface(dev[0], hapd,
556 apdev[0]['ifname'] + ".4096")
558 def test_ap_vlan_wpa2_radius_tagged(dev, apdev):
559 """AP VLAN with WPA2-Enterprise and RADIUS EGRESS_VLANID attributes"""
562 params = hostapd.wpa2_eap_params(ssid="test-vlan")
563 params['dynamic_vlan'] = "1"
564 params["vlan_naming"] = "1"
565 hapd = hostapd.add_ap(apdev[0], params)
567 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
568 identity="vlan1tagged",
569 password_hex="0123456789abcdef0123456789abcdef",
572 # Create tagged interface for wpa_supplicant
573 subprocess.call(['ip', 'link', 'add', 'link', dev[0].ifname,
574 'name', ifname, 'type', 'vlan', 'id', '1'])
575 subprocess.call(['ifconfig', ifname, 'up'])
577 hwsim_utils.run_connectivity_test(dev[0], hapd, 0, ifname1=ifname,
580 subprocess.call(['ifconfig', ifname, 'down'])
581 subprocess.call(['ip', 'link', 'del', ifname])
583 def test_ap_vlan_wpa2_radius_mixed(dev, apdev):
584 """AP VLAN with WPA2-Enterprise and tagged+untagged VLANs"""
587 params = hostapd.wpa2_eap_params(ssid="test-vlan")
588 params['dynamic_vlan'] = "1"
589 params["vlan_naming"] = "1"
590 hapd = hostapd.add_ap(apdev[0], params)
592 dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
593 identity="vlan12mixed",
594 password_hex="0123456789abcdef0123456789abcdef",
597 # Add tagged VLAN interface to wpa_supplicant interface for testing
598 subprocess.call(['ip', 'link', 'add', 'link', dev[0].ifname,
599 'name', ifname, 'type', 'vlan', 'id', '1'])
600 subprocess.call(['ifconfig', ifname, 'up'])
602 logger.info("Test connectivity in untagged VLAN 2")
603 hwsim_utils.run_connectivity_test(dev[0], hapd, 0,
604 ifname1=dev[0].ifname,
606 logger.info("Test connectivity in tagged VLAN 1")
607 hwsim_utils.run_connectivity_test(dev[0], hapd, 0, ifname1=ifname,
610 subprocess.call(['ifconfig', ifname, 'down'])
611 subprocess.call(['ip', 'link', 'del', ifname])
613 def test_ap_vlan_reconnect(dev, apdev):
614 """AP VLAN with WPA2-PSK connect, disconnect, connect"""
615 params = hostapd.wpa2_params(ssid="test-vlan",
616 passphrase="12345678")
617 params['dynamic_vlan'] = "1"
618 params['accept_mac_file'] = "hostapd.accept"
619 hapd = hostapd.add_ap(apdev[0], params)
621 logger.info("connect sta")
622 dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
623 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
624 logger.info("disconnect sta")
625 dev[0].request("REMOVE_NETWORK all")
626 dev[0].wait_disconnected(timeout=10)
628 logger.info("reconnect sta")
629 dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
630 hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")