test_ap_vlan.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. #!/usr/bin/python
  2. #
  3. # Test cases for AP VLAN
  4. # Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
  5. #
  6. # This software may be distributed under the terms of the BSD license.
  7. # See README for more details.
  8. import time
  9. import subprocess
  10. import logging
  11. logger = logging.getLogger(__name__)
  12. try:
  13. import netifaces
  14. netifaces_imported = True
  15. except ImportError:
  16. netifaces_imported = False
  17. import hwsim_utils
  18. import hostapd
  19. from utils import iface_is_in_bridge, HwsimSkip
  20. import os
  21. from tshark import run_tshark
  22. def test_ap_vlan_open(dev, apdev):
  23. """AP VLAN with open network"""
  24. params = { "ssid": "test-vlan-open",
  25. "dynamic_vlan": "1",
  26. "accept_mac_file": "hostapd.accept" }
  27. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  28. dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  29. dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  30. dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  31. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  32. hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
  33. hwsim_utils.test_connectivity(dev[2], hapd)
  34. def test_ap_vlan_file_open(dev, apdev):
  35. """AP VLAN with open network and vlan_file mapping"""
  36. params = { "ssid": "test-vlan-open",
  37. "dynamic_vlan": "1",
  38. "vlan_file": "hostapd.vlan",
  39. "accept_mac_file": "hostapd.accept" }
  40. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  41. dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  42. dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  43. dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  44. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  45. hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
  46. hwsim_utils.test_connectivity(dev[2], hapd)
  47. def test_ap_vlan_wpa2(dev, apdev):
  48. """AP VLAN with WPA2-PSK"""
  49. params = hostapd.wpa2_params(ssid="test-vlan",
  50. passphrase="12345678")
  51. params['dynamic_vlan'] = "1";
  52. params['accept_mac_file'] = "hostapd.accept";
  53. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  54. dev[0].connect("test-vlan", psk="12345678", scan_freq="2412")
  55. dev[1].connect("test-vlan", psk="12345678", scan_freq="2412")
  56. dev[2].connect("test-vlan", psk="12345678", scan_freq="2412")
  57. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  58. hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
  59. hwsim_utils.test_connectivity(dev[2], hapd)
  60. def test_ap_vlan_wpa2_radius(dev, apdev):
  61. """AP VLAN with WPA2-Enterprise and RADIUS attributes"""
  62. params = hostapd.wpa2_eap_params(ssid="test-vlan")
  63. params['dynamic_vlan'] = "1";
  64. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  65. dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  66. identity="vlan1",
  67. password_hex="0123456789abcdef0123456789abcdef",
  68. scan_freq="2412")
  69. dev[1].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  70. identity="vlan2",
  71. password_hex="0123456789abcdef0123456789abcdef",
  72. scan_freq="2412")
  73. dev[2].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  74. identity="pax.user@example.com",
  75. password_hex="0123456789abcdef0123456789abcdef",
  76. scan_freq="2412")
  77. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  78. hwsim_utils.test_connectivity_iface(dev[1], hapd, "brvlan2")
  79. hwsim_utils.test_connectivity(dev[2], hapd)
  80. def test_ap_vlan_wpa2_radius_id_change(dev, apdev):
  81. """AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID"""
  82. as_params = { "ssid": "as",
  83. "beacon_int": "2000",
  84. "radius_server_clients": "auth_serv/radius_clients.conf",
  85. "radius_server_auth_port": '18128',
  86. "eap_server": "1",
  87. "eap_user_file": "auth_serv/eap_user.conf",
  88. "ca_cert": "auth_serv/ca.pem",
  89. "server_cert": "auth_serv/server.pem",
  90. "private_key": "auth_serv/server.key" }
  91. authserv = hostapd.add_ap(apdev[1]['ifname'], as_params)
  92. params = hostapd.wpa2_eap_params(ssid="test-vlan")
  93. params['dynamic_vlan'] = "1";
  94. params['auth_server_port'] = "18128"
  95. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  96. dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  97. identity="vlan1",
  98. password_hex="0123456789abcdef0123456789abcdef",
  99. scan_freq="2412")
  100. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  101. logger.info("VLAN-ID -> 2")
  102. authserv.disable()
  103. authserv.set('eap_user_file', "auth_serv/eap_user_vlan.conf")
  104. authserv.enable()
  105. dev[0].dump_monitor()
  106. dev[0].request("REAUTHENTICATE")
  107. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
  108. if ev is None:
  109. raise Exception("EAP reauthentication timed out")
  110. ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
  111. if ev is None:
  112. raise Exception("4-way handshake after reauthentication timed out")
  113. state = dev[0].get_status_field('wpa_state')
  114. if state != "COMPLETED":
  115. raise Exception("Unexpected state after reauth: " + state)
  116. sta = hapd.get_sta(dev[0].own_addr())
  117. if 'vlan_id' not in sta:
  118. raise Exception("No VLAN ID in STA info")
  119. if sta['vlan_id'] != '2':
  120. raise Exception("Unexpected VLAN ID: " + sta['vlan_id'])
  121. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2")
  122. logger.info("VLAN-ID -> 1")
  123. time.sleep(1)
  124. authserv.disable()
  125. authserv.set('eap_user_file', "auth_serv/eap_user.conf")
  126. authserv.enable()
  127. dev[0].dump_monitor()
  128. dev[0].request("REAUTHENTICATE")
  129. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
  130. if ev is None:
  131. raise Exception("EAP reauthentication timed out")
  132. ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
  133. if ev is None:
  134. raise Exception("4-way handshake after reauthentication timed out")
  135. state = dev[0].get_status_field('wpa_state')
  136. if state != "COMPLETED":
  137. raise Exception("Unexpected state after reauth: " + state)
  138. sta = hapd.get_sta(dev[0].own_addr())
  139. if 'vlan_id' not in sta:
  140. raise Exception("No VLAN ID in STA info")
  141. if sta['vlan_id'] != '1':
  142. raise Exception("Unexpected VLAN ID: " + sta['vlan_id'])
  143. time.sleep(0.2)
  144. try:
  145. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  146. except Exception, e:
  147. # It is possible for new bridge setup to not be ready immediately, so
  148. # try again to avoid reporting issues related to that.
  149. logger.info("First VLAN-ID 1 data test failed - try again")
  150. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  151. def test_ap_vlan_wpa2_radius_required(dev, apdev):
  152. """AP VLAN with WPA2-Enterprise and RADIUS attributes required"""
  153. params = hostapd.wpa2_eap_params(ssid="test-vlan")
  154. params['dynamic_vlan'] = "2";
  155. hostapd.add_ap(apdev[0]['ifname'], params)
  156. dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  157. identity="vlan1",
  158. password_hex="0123456789abcdef0123456789abcdef",
  159. scan_freq="2412")
  160. dev[2].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  161. identity="pax.user@example.com",
  162. password_hex="0123456789abcdef0123456789abcdef",
  163. scan_freq="2412", wait_connect=False)
  164. ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED",
  165. "CTRL-EVENT-DISCONNECTED"], timeout=20)
  166. if ev is None:
  167. raise Exception("Timeout on connection attempt")
  168. if "CTRL-EVENT-CONNECTED" in ev:
  169. raise Exception("Unexpected success without tunnel parameters")
  170. def test_ap_vlan_tagged(dev, apdev):
  171. """AP VLAN with tagged interface"""
  172. params = { "ssid": "test-vlan-open",
  173. "dynamic_vlan": "1",
  174. "vlan_tagged_interface": "lo",
  175. "accept_mac_file": "hostapd.accept" }
  176. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  177. dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  178. dev[1].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  179. dev[2].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  180. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brlo.1")
  181. hwsim_utils.test_connectivity_iface(dev[1], hapd, "brlo.2")
  182. hwsim_utils.test_connectivity(dev[2], hapd)
  183. def ap_vlan_iface_cleanup_multibss_cleanup():
  184. subprocess.call(['ifconfig', 'dummy0', 'down'],
  185. stderr=open('/dev/null', 'w'))
  186. ifnames = [ 'wlan3.1', 'wlan3.2', 'wlan3-2.1', 'wlan3-2.2', 'dummy0.2',
  187. 'dummy0.1', 'dummy0', 'brvlan1', 'brvlan2' ]
  188. for ifname in ifnames:
  189. subprocess.call(['ip', 'link', 'del', ifname],
  190. stderr=open('/dev/null', 'w'))
  191. def ap_vlan_iface_test_and_prepare_environ():
  192. ifaces = netifaces.interfaces()
  193. if "dummy0" in ifaces:
  194. raise Exception("dummy0 already exists before")
  195. ifaces = netifaces.interfaces()
  196. if "dummy0.1" in ifaces:
  197. raise Exception("dummy0.1 already exists before")
  198. subprocess.call(['ip', 'link', 'add', 'dummy0', 'type', 'dummy'])
  199. subprocess.call(['ifconfig', 'dummy0', 'up'])
  200. ifaces = netifaces.interfaces()
  201. if not("dummy0" in ifaces):
  202. raise HwsimSkip("failed to add dummy0 - missing kernel config DUMMY ?")
  203. subprocess.call(['ip', 'link', 'add', 'link', 'dummy0', 'name', 'dummy0.1',
  204. 'type', 'vlan', 'id', '1'])
  205. ifaces = netifaces.interfaces()
  206. if not("dummy0.1" in ifaces):
  207. raise HwsimSkip("failed to add dummy0.1 - missing kernel config VLAN_8021Q ?")
  208. subprocess.call(['ip', 'link', 'del', 'dummy0.1'])
  209. ifaces = netifaces.interfaces()
  210. if "dummy0.1" in ifaces:
  211. raise Exception("dummy0.1 was not removed before testing")
  212. def test_ap_vlan_iface_cleanup_multibss(dev, apdev):
  213. """AP VLAN operation in multi-BSS multi-VLAN case"""
  214. ap_vlan_iface_cleanup_multibss(dev, apdev, 'multi-bss-iface.conf')
  215. def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile):
  216. # AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID
  217. # check that multiple bss do not interfere with each other with respect
  218. # to deletion of bridge and tagged interface.
  219. if not netifaces_imported:
  220. raise HwsimSkip("python module netifaces not available")
  221. try:
  222. ap_vlan_iface_cleanup_multibss_cleanup()
  223. ap_vlan_iface_test_and_prepare_environ()
  224. as_params = { "ssid": "as",
  225. "beacon_int": "2000",
  226. "radius_server_clients": "auth_serv/radius_clients.conf",
  227. "radius_server_auth_port": '18128',
  228. "eap_server": "1",
  229. "eap_user_file": "auth_serv/eap_user.conf",
  230. "ca_cert": "auth_serv/ca.pem",
  231. "server_cert": "auth_serv/server.pem",
  232. "private_key": "auth_serv/server.key",
  233. "vlan_naming": "1" }
  234. authserv = hostapd.add_ap(apdev[1]['ifname'], as_params)
  235. ifname = apdev[0]['ifname']
  236. # start the actual test
  237. hostapd.add_iface(ifname, cfgfile)
  238. hapd = hostapd.Hostapd(ifname)
  239. hapd1 = hostapd.Hostapd("wlan3-2", 1)
  240. hapd1.enable()
  241. ifaces = netifaces.interfaces()
  242. if "brvlan1" in ifaces:
  243. raise Exception("bridge brvlan1 already exists before")
  244. if "brvlan2" in ifaces:
  245. raise Exception("bridge brvlan2 already exists before")
  246. dev[0].connect("bss-1", key_mgmt="WPA-EAP", eap="PAX",
  247. identity="vlan1",
  248. password_hex="0123456789abcdef0123456789abcdef",
  249. scan_freq="2412")
  250. ifaces = netifaces.interfaces()
  251. if not("brvlan1" in ifaces):
  252. raise Exception("bridge brvlan1 was not created")
  253. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1")
  254. if not iface_is_in_bridge("brvlan1", "dummy0.1"):
  255. raise Exception("dummy0.1 not in brvlan1")
  256. dev[1].connect("bss-2", key_mgmt="WPA-EAP", eap="PAX",
  257. identity="vlan1",
  258. password_hex="0123456789abcdef0123456789abcdef",
  259. scan_freq="2412")
  260. hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1")
  261. if not iface_is_in_bridge("brvlan1", "dummy0.1"):
  262. raise Exception("dummy0.1 not in brvlan1")
  263. authserv.disable()
  264. authserv.set('eap_user_file', "auth_serv/eap_user_vlan.conf")
  265. authserv.enable()
  266. logger.info("wlan0 -> VLAN 2")
  267. dev[0].dump_monitor()
  268. dev[0].request("REAUTHENTICATE")
  269. ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
  270. if ev is None:
  271. raise Exception("EAP reauthentication timed out")
  272. ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5)
  273. if ev is None:
  274. raise Exception("4-way handshake after reauthentication timed out")
  275. state = dev[0].get_status_field('wpa_state')
  276. if state != "COMPLETED":
  277. raise Exception("Unexpected state after reauth: " + state)
  278. ifaces = netifaces.interfaces()
  279. if not ("brvlan1" in ifaces):
  280. raise Exception("bridge brvlan1 has been removed too early")
  281. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2",
  282. max_tries=5)
  283. if not iface_is_in_bridge("brvlan2", "dummy0.2"):
  284. raise Exception("dummy0.2 not in brvlan2")
  285. logger.info("test wlan1 == VLAN 1")
  286. hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1")
  287. if not iface_is_in_bridge("brvlan1", "dummy0.1"):
  288. raise Exception("dummy0.1 not in brvlan1")
  289. logger.info("wlan1 -> VLAN 2")
  290. dev[1].dump_monitor()
  291. dev[1].request("REAUTHENTICATE")
  292. ev = dev[1].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
  293. if ev is None:
  294. raise Exception("EAP reauthentication timed out")
  295. ev = dev[1].wait_event(["WPA: Key negotiation completed"], timeout=5)
  296. if ev is None:
  297. raise Exception("4-way handshake after reauthentication timed out")
  298. state = dev[1].get_status_field('wpa_state')
  299. if state != "COMPLETED":
  300. raise Exception("Unexpected state after reauth: " + state)
  301. # it can take some time for data connectivity to be updated
  302. hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan2",
  303. max_tries=5)
  304. logger.info("test wlan0 == VLAN 2")
  305. hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2")
  306. if not iface_is_in_bridge("brvlan2", "dummy0.2"):
  307. raise Exception("dummy0.2 not in brvlan2")
  308. ifaces = netifaces.interfaces()
  309. if "brvlan1" in ifaces:
  310. raise Exception("bridge brvlan1 has not been cleaned up")
  311. # disconnect dev0 first to test a corner case
  312. dev[0].request("DISCONNECT")
  313. dev[0].wait_disconnected()
  314. dev[1].request("DISCONNECT")
  315. dev[1].wait_disconnected()
  316. # station removal needs some time
  317. for i in range(5):
  318. time.sleep(1)
  319. ifaces = netifaces.interfaces()
  320. if "brvlan2" not in ifaces:
  321. break
  322. ifaces = netifaces.interfaces()
  323. if "brvlan2" in ifaces:
  324. raise Exception("bridge brvlan2 has not been cleaned up")
  325. hapd.request("DISABLE")
  326. finally:
  327. ap_vlan_iface_cleanup_multibss_cleanup()
  328. def test_ap_vlan_iface_cleanup_multibss_per_sta_vif(dev, apdev):
  329. """AP VLAN operation in multi-BSS multi-VLAN case with per-sta-vif set"""
  330. # AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID
  331. # check that multiple bss do not interfere with each other with respect
  332. # to deletion of bridge and tagged interface. per_sta_vif is enabled.
  333. ap_vlan_iface_cleanup_multibss(dev, apdev,
  334. 'multi-bss-iface-per_sta_vif.conf')
  335. def test_ap_vlan_without_station(dev, apdev, p):
  336. """AP VLAN with WPA2-PSK and no station"""
  337. try:
  338. subprocess.call(['brctl', 'addbr', 'brvlan1'])
  339. subprocess.call(['brctl', 'setfd', 'brvlan1', '0'])
  340. subprocess.call(['ifconfig', 'brvlan1', 'up'])
  341. # use a passphrase wlantest does not know, so it cannot
  342. # inject decrypted frames into pcap
  343. params = hostapd.wpa2_params(ssid="test-vlan",
  344. passphrase="12345678x")
  345. params['dynamic_vlan'] = "1";
  346. params['vlan_file'] = 'hostapd.wlan3.vlan'
  347. params['accept_mac_file'] = "hostapd.accept";
  348. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  349. # inject some traffic
  350. sa = hapd.own_addr()
  351. da = "ff:ff:ff:ff:ff:00"
  352. hapd.request('DATA_TEST_CONFIG 1 ifname=brvlan1')
  353. hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
  354. hapd.request('DATA_TEST_CONFIG 0')
  355. time.sleep(.1)
  356. dev[0].connect("test-vlan", psk="12345678x", scan_freq="2412")
  357. # inject some traffic
  358. sa = hapd.own_addr()
  359. da = "ff:ff:ff:ff:ff:01"
  360. hapd.request('DATA_TEST_CONFIG 1 ifname=brvlan1')
  361. hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
  362. hapd.request('DATA_TEST_CONFIG 0')
  363. # let the AP send couple of Beacon frames
  364. time.sleep(1)
  365. out = run_tshark(os.path.join(p['logdir'], "hwsim0.pcapng"),
  366. "wlan.da == ff:ff:ff:ff:ff:00",
  367. ["wlan.fc.protected"])
  368. if out is not None:
  369. lines = out.splitlines()
  370. if len(lines) < 1:
  371. raise Exception("first frame not observed")
  372. state = 1
  373. for l in lines:
  374. is_protected = int(l, 16)
  375. if is_protected != 1:
  376. state = 0
  377. if state != 1:
  378. raise Exception("Broadcast packets were not encrypted when no station was connected")
  379. else:
  380. raise Exception("first frame not observed")
  381. out = run_tshark(os.path.join(p['logdir'], "hwsim0.pcapng"),
  382. "wlan.da == ff:ff:ff:ff:ff:01",
  383. ["wlan.fc.protected"])
  384. if out is not None:
  385. lines = out.splitlines()
  386. if len(lines) < 1:
  387. raise Exception("second frame not observed")
  388. state = 1
  389. for l in lines:
  390. is_protected = int(l, 16)
  391. if is_protected != 1:
  392. state = 0
  393. if state != 1:
  394. raise Exception("Broadcast packets were not encrypted when station was connected")
  395. else:
  396. raise Exception("second frame not observed")
  397. dev[0].request("DISCONNECT")
  398. dev[0].wait_disconnected()
  399. finally:
  400. subprocess.call(['ip', 'link', 'set', 'dev', 'brvlan1', 'down'])
  401. subprocess.call(['ip', 'link', 'set', 'dev', 'wlan3.1', 'down'],
  402. stderr=open('/dev/null', 'w'))
  403. subprocess.call(['brctl', 'delif', 'brvlan1', 'wlan3.1'],
  404. stderr=open('/dev/null', 'w'))
  405. subprocess.call(['brctl', 'delbr', 'brvlan1'])
  406. def test_ap_open_per_sta_vif(dev, apdev):
  407. """AP VLAN with open network"""
  408. params = { "ssid": "test-vlan-open",
  409. "per_sta_vif": "1" }
  410. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  411. dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  412. hwsim_utils.test_connectivity_iface(dev[0], hapd,
  413. apdev[0]['ifname'] + ".4096")
  414. def test_ap_vlan_open_per_sta_vif(dev, apdev):
  415. """AP VLAN (dynamic) with open network"""
  416. params = { "ssid": "test-vlan-open",
  417. "per_sta_vif": "1",
  418. "dynamic_vlan": "1" }
  419. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  420. dev[0].connect("test-vlan-open", key_mgmt="NONE", scan_freq="2412")
  421. hwsim_utils.test_connectivity_iface(dev[0], hapd,
  422. apdev[0]['ifname'] + ".4096")
  423. def test_ap_vlan_wpa2_radius_tagged(dev, apdev):
  424. """AP VLAN with WPA2-Enterprise and RADIUS EGRESS_VLANID attributes"""
  425. ifname = 'wlan0.1'
  426. try:
  427. params = hostapd.wpa2_eap_params(ssid="test-vlan")
  428. params['dynamic_vlan'] = "1"
  429. params["vlan_naming"] = "1"
  430. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  431. dev[0].connect("test-vlan", key_mgmt="WPA-EAP", eap="PAX",
  432. identity="vlan1tagged",
  433. password_hex="0123456789abcdef0123456789abcdef",
  434. scan_freq="2412")
  435. # Create tagged interface for wpa_supplicant
  436. subprocess.call(['ip', 'link', 'add', 'link', dev[0].ifname,
  437. 'name', ifname, 'type', 'vlan', 'id', '1'])
  438. subprocess.call(['ifconfig', ifname, 'up'])
  439. hwsim_utils.run_connectivity_test(dev[0], hapd, 0, ifname1=ifname,
  440. ifname2="brvlan1")
  441. finally:
  442. subprocess.call(['ifconfig', ifname, 'down'])
  443. subprocess.call(['ip', 'link', 'del', ifname])