1 # wpa_supplicant mesh mode tests
2 # Copyright (c) 2014, cozybit Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
15 from wpasupplicant import WpaSupplicant
16 from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
17 from tshark import run_tshark
19 def check_mesh_support(dev, secure=False):
20 if "MESH" not in dev.get_capability("modes"):
21 raise HwsimSkip("Driver does not support mesh")
22 if secure and "SAE" not in dev.get_capability("auth_alg"):
23 raise HwsimSkip("SAE not supported")
25 def check_mesh_scan(dev, params, other_started=False, beacon_int=0):
28 id = dev.request("SCAN " + params)
30 raise Exception("Failed to start scan")
34 ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
36 raise Exception("Other scan did not start")
37 if "id=" + str(id) in ev:
38 raise Exception("Own scan id unexpectedly included in start event")
40 ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
42 raise Exception("Other scan did not complete")
43 if "id=" + str(id) in ev:
45 "Own scan id unexpectedly included in completed event")
47 ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
49 raise Exception("Scan did not start")
50 if "id=" + str(id) not in ev:
51 raise Exception("Scan id not included in start event")
53 ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
55 raise Exception("Scan did not complete")
56 if "id=" + str(id) not in ev:
57 raise Exception("Scan id not included in completed event")
59 res = dev.request("SCAN_RESULTS")
61 if res.find("[MESH]") < 0:
62 raise Exception("Scan did not contain a MESH network")
64 bssid = res.splitlines()[1].split(' ')[0]
65 bss = dev.get_bss(bssid)
67 raise Exception("Could not get BSS entry for mesh")
68 if 'mesh_capability' not in bss:
69 raise Exception("mesh_capability missing from BSS entry")
71 if 'beacon_int' not in bss:
72 raise Exception("beacon_int missing from BSS entry")
73 if str(beacon_int) != bss['beacon_int']:
74 raise Exception("Unexpected beacon_int in BSS entry: " + bss['beacon_int'])
76 def check_mesh_group_added(dev):
77 ev = dev.wait_event(["MESH-GROUP-STARTED"])
79 raise Exception("Test exception: Couldn't join mesh")
82 def check_mesh_group_removed(dev):
83 ev = dev.wait_event(["MESH-GROUP-REMOVED"])
85 raise Exception("Test exception: Couldn't leave mesh")
88 def check_mesh_peer_connected(dev, timeout=10):
89 ev = dev.wait_event(["MESH-PEER-CONNECTED"], timeout=timeout)
91 raise Exception("Test exception: Remote peer did not connect.")
94 def check_mesh_peer_disconnected(dev):
95 ev = dev.wait_event(["MESH-PEER-DISCONNECTED"])
97 raise Exception("Test exception: Peer disconnect event not detected.")
100 def test_wpas_add_set_remove_support(dev):
101 """wpa_supplicant MESH add/set/remove network support"""
102 check_mesh_support(dev[0])
103 id = dev[0].add_network()
104 dev[0].set_network(id, "mode", "5")
105 dev[0].remove_network(id)
107 def add_open_mesh_network(dev, freq="2412", start=True, beacon_int=0,
108 basic_rates=None, chwidth=0):
109 id = dev.add_network()
110 dev.set_network(id, "mode", "5")
111 dev.set_network_quoted(id, "ssid", "wpas-mesh-open")
112 dev.set_network(id, "key_mgmt", "NONE")
114 dev.set_network(id, "frequency", freq)
116 dev.set_network(id, "max_oper_chwidth", str(chwidth))
118 dev.set_network(id, "beacon_int", str(beacon_int))
120 dev.set_network(id, "mesh_basic_rates", basic_rates)
122 dev.mesh_group_add(id)
125 def test_wpas_mesh_group_added(dev):
126 """wpa_supplicant MESH group add"""
127 check_mesh_support(dev[0])
128 add_open_mesh_network(dev[0])
130 # Check for MESH-GROUP-STARTED event
131 check_mesh_group_added(dev[0])
134 def test_wpas_mesh_group_remove(dev):
135 """wpa_supplicant MESH group remove"""
136 check_mesh_support(dev[0])
137 add_open_mesh_network(dev[0])
138 # Check for MESH-GROUP-STARTED event
139 check_mesh_group_added(dev[0])
140 dev[0].mesh_group_remove()
141 # Check for MESH-GROUP-REMOVED event
142 check_mesh_group_removed(dev[0])
143 dev[0].mesh_group_remove()
145 def test_wpas_mesh_peer_connected(dev):
146 """wpa_supplicant MESH peer connected"""
147 check_mesh_support(dev[0])
148 add_open_mesh_network(dev[0], beacon_int=160)
149 add_open_mesh_network(dev[1], beacon_int=160)
151 # Check for mesh joined
152 check_mesh_group_added(dev[0])
153 check_mesh_group_added(dev[1])
155 # Check for peer connected
156 check_mesh_peer_connected(dev[0])
157 check_mesh_peer_connected(dev[1])
160 def test_wpas_mesh_peer_disconnected(dev):
161 """wpa_supplicant MESH peer disconnected"""
162 check_mesh_support(dev[0])
163 add_open_mesh_network(dev[0])
164 add_open_mesh_network(dev[1])
166 # Check for mesh joined
167 check_mesh_group_added(dev[0])
168 check_mesh_group_added(dev[1])
170 # Check for peer connected
171 check_mesh_peer_connected(dev[0])
172 check_mesh_peer_connected(dev[1])
174 # Remove group on dev 1
175 dev[1].mesh_group_remove()
176 # Device 0 should get a disconnection event
177 check_mesh_peer_disconnected(dev[0])
180 def test_wpas_mesh_mode_scan(dev):
181 """wpa_supplicant MESH scan support"""
182 check_mesh_support(dev[0])
183 add_open_mesh_network(dev[0])
184 add_open_mesh_network(dev[1], beacon_int=175)
186 # Check for mesh joined
187 check_mesh_group_added(dev[0])
188 check_mesh_group_added(dev[1])
190 # Check for Mesh scan
191 check_mesh_scan(dev[0], "use_id=1", beacon_int=175)
193 def test_wpas_mesh_open(dev, apdev):
194 """wpa_supplicant open MESH network connectivity"""
195 check_mesh_support(dev[0])
196 add_open_mesh_network(dev[0], freq="2462", basic_rates="60 120 240")
197 add_open_mesh_network(dev[1], freq="2462", basic_rates="60 120 240")
199 # Check for mesh joined
200 check_mesh_group_added(dev[0])
201 check_mesh_group_added(dev[1])
203 # Check for peer connected
204 check_mesh_peer_connected(dev[0])
205 check_mesh_peer_connected(dev[1])
207 # Test connectivity 0->1 and 1->0
208 hwsim_utils.test_connectivity(dev[0], dev[1])
210 def test_wpas_mesh_open_no_auto(dev, apdev):
211 """wpa_supplicant open MESH network connectivity"""
212 check_mesh_support(dev[0])
213 id = add_open_mesh_network(dev[0], start=False)
214 dev[0].set_network(id, "dot11MeshMaxRetries", "16")
215 dev[0].set_network(id, "dot11MeshRetryTimeout", "255")
216 dev[0].mesh_group_add(id)
218 id = add_open_mesh_network(dev[1], start=False)
219 dev[1].set_network(id, "no_auto_peer", "1")
220 dev[1].mesh_group_add(id)
222 # Check for mesh joined
223 check_mesh_group_added(dev[0])
224 check_mesh_group_added(dev[1])
226 # Check for peer connected
227 check_mesh_peer_connected(dev[0], timeout=30)
228 check_mesh_peer_connected(dev[1])
230 # Test connectivity 0->1 and 1->0
231 hwsim_utils.test_connectivity(dev[0], dev[1])
233 def add_mesh_secure_net(dev, psk=True):
234 id = dev.add_network()
235 dev.set_network(id, "mode", "5")
236 dev.set_network_quoted(id, "ssid", "wpas-mesh-sec")
237 dev.set_network(id, "key_mgmt", "SAE")
238 dev.set_network(id, "frequency", "2412")
240 dev.set_network_quoted(id, "psk", "thisismypassphrase!")
243 def test_wpas_mesh_secure(dev, apdev):
244 """wpa_supplicant secure MESH network connectivity"""
245 check_mesh_support(dev[0], secure=True)
246 dev[0].request("SET sae_groups ")
247 id = add_mesh_secure_net(dev[0])
248 dev[0].mesh_group_add(id)
250 dev[1].request("SET sae_groups ")
251 id = add_mesh_secure_net(dev[1])
252 dev[1].mesh_group_add(id)
254 # Check for mesh joined
255 check_mesh_group_added(dev[0])
256 check_mesh_group_added(dev[1])
258 # Check for peer connected
259 check_mesh_peer_connected(dev[0])
260 check_mesh_peer_connected(dev[1])
262 # Test connectivity 0->1 and 1->0
263 hwsim_utils.test_connectivity(dev[0], dev[1])
265 def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
266 """wpa_supplicant secure MESH and SAE group mismatch"""
267 check_mesh_support(dev[0], secure=True)
268 addr0 = dev[0].p2p_interface_addr()
269 addr1 = dev[1].p2p_interface_addr()
270 addr2 = dev[2].p2p_interface_addr()
272 dev[0].request("SET sae_groups 19 25")
273 id = add_mesh_secure_net(dev[0])
274 dev[0].mesh_group_add(id)
276 dev[1].request("SET sae_groups 19")
277 id = add_mesh_secure_net(dev[1])
278 dev[1].mesh_group_add(id)
280 dev[2].request("SET sae_groups 26")
281 id = add_mesh_secure_net(dev[2])
282 dev[2].mesh_group_add(id)
284 check_mesh_group_added(dev[0])
285 check_mesh_group_added(dev[1])
286 check_mesh_group_added(dev[2])
288 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"])
290 raise Exception("Remote peer did not connect")
292 raise Exception("Unexpected peer connected: " + ev)
294 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"])
296 raise Exception("Remote peer did not connect")
298 raise Exception("Unexpected peer connected: " + ev)
300 ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
302 raise Exception("Unexpected peer connection at dev[2]: " + ev)
304 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
306 raise Exception("Unexpected peer connection: " + ev)
308 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
310 raise Exception("Unexpected peer connection: " + ev)
312 dev[0].request("SET sae_groups ")
313 dev[1].request("SET sae_groups ")
314 dev[2].request("SET sae_groups ")
316 def test_wpas_mesh_secure_sae_group_negotiation(dev, apdev):
317 """wpa_supplicant secure MESH and SAE group negotiation"""
318 check_mesh_support(dev[0], secure=True)
319 addr0 = dev[0].own_addr()
320 addr1 = dev[1].own_addr()
322 #dev[0].request("SET sae_groups 21 20 25 26")
323 dev[0].request("SET sae_groups 25")
324 id = add_mesh_secure_net(dev[0])
325 dev[0].mesh_group_add(id)
327 dev[1].request("SET sae_groups 19 25")
328 id = add_mesh_secure_net(dev[1])
329 dev[1].mesh_group_add(id)
331 check_mesh_group_added(dev[0])
332 check_mesh_group_added(dev[1])
334 check_mesh_peer_connected(dev[0])
335 check_mesh_peer_connected(dev[1])
337 dev[0].request("SET sae_groups ")
338 dev[1].request("SET sae_groups ")
340 def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
341 """wpa_supplicant secure MESH and missing SAE password"""
342 check_mesh_support(dev[0], secure=True)
343 id = add_mesh_secure_net(dev[0], psk=False)
344 dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
345 dev[0].mesh_group_add(id)
346 ev = dev[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
349 raise Exception("Timeout on mesh start event")
350 if "MESH-GROUP-STARTED" in ev:
351 raise Exception("Unexpected mesh group start")
352 ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.1)
354 raise Exception("Unexpected mesh group start")
356 def test_wpas_mesh_secure_no_auto(dev, apdev):
357 """wpa_supplicant secure MESH network connectivity"""
358 check_mesh_support(dev[0], secure=True)
359 dev[0].request("SET sae_groups 19")
360 id = add_mesh_secure_net(dev[0])
361 dev[0].mesh_group_add(id)
363 dev[1].request("SET sae_groups 19")
364 id = add_mesh_secure_net(dev[1])
365 dev[1].set_network(id, "no_auto_peer", "1")
366 dev[1].mesh_group_add(id)
368 # Check for mesh joined
369 check_mesh_group_added(dev[0])
370 check_mesh_group_added(dev[1])
372 # Check for peer connected
373 check_mesh_peer_connected(dev[0], timeout=30)
374 check_mesh_peer_connected(dev[1])
376 # Test connectivity 0->1 and 1->0
377 hwsim_utils.test_connectivity(dev[0], dev[1])
379 dev[0].request("SET sae_groups ")
380 dev[1].request("SET sae_groups ")
382 def test_wpas_mesh_secure_dropped_frame(dev, apdev):
383 """Secure mesh network connectivity when the first plink Open is dropped"""
384 check_mesh_support(dev[0], secure=True)
386 dev[0].request("SET ext_mgmt_frame_handling 1")
387 dev[0].request("SET sae_groups ")
388 id = add_mesh_secure_net(dev[0])
389 dev[0].mesh_group_add(id)
391 dev[1].request("SET sae_groups ")
392 id = add_mesh_secure_net(dev[1])
393 dev[1].mesh_group_add(id)
395 # Check for mesh joined
396 check_mesh_group_added(dev[0])
397 check_mesh_group_added(dev[1])
399 # Drop the first Action frame (plink Open) to test unexpected order of
400 # Confirm/Open messages.
405 raise Exception("Did not see Action frames")
406 rx_msg = dev[0].mgmt_rx()
408 raise Exception("MGMT-RX timeout")
409 if rx_msg['subtype'] == 13:
410 logger.info("Drop the first Action frame")
412 if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
413 raise Exception("MGMT_RX_PROCESS failed")
415 dev[0].request("SET ext_mgmt_frame_handling 0")
417 # Check for peer connected
418 check_mesh_peer_connected(dev[0])
419 check_mesh_peer_connected(dev[1])
421 # Test connectivity 0->1 and 1->0
422 hwsim_utils.test_connectivity(dev[0], dev[1])
424 def test_wpas_mesh_ctrl(dev):
425 """wpa_supplicant ctrl_iface mesh command error cases"""
426 check_mesh_support(dev[0])
427 if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"):
428 raise Exception("Unexpected MESH_GROUP_ADD success")
429 id = dev[0].add_network()
430 if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
431 raise Exception("Unexpected MESH_GROUP_ADD success")
432 dev[0].set_network(id, "mode", "5")
433 dev[0].set_network(id, "key_mgmt", "WPA-PSK")
434 if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
435 raise Exception("Unexpected MESH_GROUP_ADD success")
437 if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE foo"):
438 raise Exception("Unexpected MESH_GROUP_REMOVE success")
440 def test_wpas_mesh_dynamic_interface(dev):
441 """wpa_supplicant mesh with dynamic interface"""
442 check_mesh_support(dev[0])
446 mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
448 raise Exception("MESH_INTERFACE_ADD failed")
449 mesh1 = dev[1].request("MESH_INTERFACE_ADD")
451 raise Exception("MESH_INTERFACE_ADD failed")
453 wpas0 = WpaSupplicant(ifname=mesh0)
454 wpas1 = WpaSupplicant(ifname=mesh1)
455 logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
456 logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
458 add_open_mesh_network(wpas0)
459 add_open_mesh_network(wpas1)
460 check_mesh_group_added(wpas0)
461 check_mesh_group_added(wpas1)
462 check_mesh_peer_connected(wpas0)
463 check_mesh_peer_connected(wpas1)
464 hwsim_utils.test_connectivity(wpas0, wpas1)
466 # Must not allow MESH_GROUP_REMOVE on dynamic interface
467 if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh0):
468 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
469 if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh1):
470 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
472 # Must not allow MESH_GROUP_REMOVE on another radio interface
473 if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh1):
474 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
475 if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh0):
476 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
478 wpas0.remove_ifname()
479 wpas1.remove_ifname()
481 if "OK" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
482 raise Exception("MESH_GROUP_REMOVE failed")
483 if "OK" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
484 raise Exception("MESH_GROUP_REMOVE failed")
486 if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
487 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
488 if "FAIL" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
489 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
491 logger.info("Make sure another dynamic group can be added")
492 mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
494 raise Exception("MESH_INTERFACE_ADD failed")
495 mesh1 = dev[1].request("MESH_INTERFACE_ADD")
497 raise Exception("MESH_INTERFACE_ADD failed")
499 wpas0 = WpaSupplicant(ifname=mesh0)
500 wpas1 = WpaSupplicant(ifname=mesh1)
501 logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
502 logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
504 add_open_mesh_network(wpas0)
505 add_open_mesh_network(wpas1)
506 check_mesh_group_added(wpas0)
507 check_mesh_group_added(wpas1)
508 check_mesh_peer_connected(wpas0)
509 check_mesh_peer_connected(wpas1)
510 hwsim_utils.test_connectivity(wpas0, wpas1)
513 dev[0].request("MESH_GROUP_REMOVE " + mesh0)
515 dev[1].request("MESH_GROUP_REMOVE " + mesh1)
517 def test_wpas_mesh_max_peering(dev, apdev):
518 """Mesh max peering limit"""
519 check_mesh_support(dev[0])
521 dev[0].request("SET max_peer_links 1")
523 # first, connect dev[0] and dev[1]
524 add_open_mesh_network(dev[0])
525 add_open_mesh_network(dev[1])
527 ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
529 raise Exception("dev%d did not connect with any peer" % i)
531 # add dev[2] which will try to connect with both dev[0] and dev[1],
532 # but can complete connection only with dev[1]
533 add_open_mesh_network(dev[2])
534 for i in range(1, 3):
535 ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
537 raise Exception("dev%d did not connect the second peer" % i)
539 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
541 raise Exception("dev0 connection beyond max peering limit")
543 ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
545 raise Exception("dev2 reported unexpected peering: " + ev)
548 dev[i].mesh_group_remove()
549 check_mesh_group_removed(dev[i])
551 dev[0].request("SET max_peer_links 99")
553 def test_wpas_mesh_open_5ghz(dev, apdev):
554 """wpa_supplicant open MESH network on 5 GHz band"""
556 _test_wpas_mesh_open_5ghz(dev, apdev)
558 subprocess.call(['iw', 'reg', 'set', '00'])
559 dev[0].flush_scan_cache()
560 dev[1].flush_scan_cache()
562 def _test_wpas_mesh_open_5ghz(dev, apdev):
563 check_mesh_support(dev[0])
564 subprocess.call(['iw', 'reg', 'set', 'US'])
567 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
569 raise Exception("No regdom change event")
570 if "alpha2=US" in ev:
572 add_open_mesh_network(dev[i], freq="5180")
574 # Check for mesh joined
575 check_mesh_group_added(dev[0])
576 check_mesh_group_added(dev[1])
578 # Check for peer connected
579 check_mesh_peer_connected(dev[0])
580 check_mesh_peer_connected(dev[1])
582 # Test connectivity 0->1 and 1->0
583 hwsim_utils.test_connectivity(dev[0], dev[1])
585 def test_wpas_mesh_open_vht_80p80(dev, apdev):
586 """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
588 _test_wpas_mesh_open_vht_80p80(dev, apdev)
590 subprocess.call(['iw', 'reg', 'set', '00'])
591 dev[0].flush_scan_cache()
592 dev[1].flush_scan_cache()
594 def _test_wpas_mesh_open_vht_80p80(dev, apdev):
595 check_mesh_support(dev[0])
596 subprocess.call(['iw', 'reg', 'set', 'US'])
599 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
601 raise Exception("No regdom change event")
602 if "alpha2=US" in ev:
604 add_open_mesh_network(dev[i], freq="5180", chwidth=3)
606 # Check for mesh joined
607 check_mesh_group_added(dev[0])
608 check_mesh_group_added(dev[1])
610 # Check for peer connected
611 check_mesh_peer_connected(dev[0])
612 check_mesh_peer_connected(dev[1])
614 # Test connectivity 0->1 and 1->0
615 hwsim_utils.test_connectivity(dev[0], dev[1])
617 sig = dev[0].request("SIGNAL_POLL").splitlines()
618 if "WIDTH=80+80 MHz" not in sig:
619 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
620 if "CENTER_FRQ1=5210" not in sig:
621 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
622 if "CENTER_FRQ2=5775" not in sig:
623 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
625 sig = dev[1].request("SIGNAL_POLL").splitlines()
626 if "WIDTH=80+80 MHz" not in sig:
627 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
628 if "CENTER_FRQ1=5210" not in sig:
629 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
630 if "CENTER_FRQ2=5775" not in sig:
631 raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig))
633 def test_mesh_open_vht_160(dev, apdev):
634 """Open mesh network on VHT 160 MHz channel"""
636 _test_mesh_open_vht_160(dev, apdev)
638 subprocess.call(['iw', 'reg', 'set', '00'])
639 dev[0].flush_scan_cache()
640 dev[1].flush_scan_cache()
642 def _test_mesh_open_vht_160(dev, apdev):
643 check_mesh_support(dev[0])
644 subprocess.call(['iw', 'reg', 'set', 'ZA'])
647 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
649 raise Exception("No regdom change event")
650 if "alpha2=ZA" in ev:
653 cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
654 reg = cmd.stdout.read()
655 if "@ 160)" not in reg:
656 raise HwsimSkip("160 MHz channel not supported in regulatory information")
658 add_open_mesh_network(dev[i], freq="5520", chwidth=2)
660 # Check for mesh joined
661 check_mesh_group_added(dev[0])
662 check_mesh_group_added(dev[1])
664 # Check for peer connected
665 check_mesh_peer_connected(dev[0])
666 check_mesh_peer_connected(dev[1])
668 # Test connectivity 0->1 and 1->0
669 hwsim_utils.test_connectivity(dev[0], dev[1])
671 sig = dev[0].request("SIGNAL_POLL").splitlines()
672 if "WIDTH=160 MHz" not in sig:
673 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
674 if "FREQUENCY=5520" not in sig:
675 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
677 sig = dev[1].request("SIGNAL_POLL").splitlines()
678 if "WIDTH=160 MHz" not in sig:
679 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
680 if "FREQUENCY=5520" not in sig:
681 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
683 def test_wpas_mesh_password_mismatch(dev, apdev):
684 """Mesh network and one device with mismatching password"""
685 check_mesh_support(dev[0], secure=True)
686 dev[0].request("SET sae_groups ")
687 id = add_mesh_secure_net(dev[0])
688 dev[0].mesh_group_add(id)
690 dev[1].request("SET sae_groups ")
691 id = add_mesh_secure_net(dev[1])
692 dev[1].mesh_group_add(id)
694 dev[2].request("SET sae_groups ")
695 id = add_mesh_secure_net(dev[2])
696 dev[2].set_network_quoted(id, "psk", "wrong password")
697 dev[2].mesh_group_add(id)
699 # The two peers with matching password need to be able to connect
700 check_mesh_group_added(dev[0])
701 check_mesh_group_added(dev[1])
702 check_mesh_peer_connected(dev[0])
703 check_mesh_peer_connected(dev[1])
705 ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
707 raise Exception("dev2 did not report auth failure (1)")
708 ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
710 raise Exception("dev2 did not report auth failure (2)")
713 ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
715 logger.info("dev0 did not report auth failure")
717 if "addr=" + dev[2].own_addr() not in ev:
718 raise Exception("Unexpected peer address in dev0 event: " + ev)
721 ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
723 logger.info("dev1 did not report auth failure")
725 if "addr=" + dev[2].own_addr() not in ev:
726 raise Exception("Unexpected peer address in dev1 event: " + ev)
729 hwsim_utils.test_connectivity(dev[0], dev[1])
733 hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1)
734 raise Exception("Data connectivity test passed unexpectedly")
736 if "data delivery failed" not in str(e):
740 raise Exception("Neither dev0 nor dev1 reported auth failure")
742 def test_wpas_mesh_password_mismatch_retry(dev, apdev, params):
743 """Mesh password mismatch and retry [long]"""
744 if not params['long']:
745 raise HwsimSkip("Skip test case with long duration due to --long not specified")
746 check_mesh_support(dev[0], secure=True)
747 dev[0].request("SET sae_groups ")
748 id = add_mesh_secure_net(dev[0])
749 dev[0].mesh_group_add(id)
751 dev[1].request("SET sae_groups ")
752 id = add_mesh_secure_net(dev[1])
753 dev[1].set_network_quoted(id, "psk", "wrong password")
754 dev[1].mesh_group_add(id)
756 # Check for mesh joined
757 check_mesh_group_added(dev[0])
758 check_mesh_group_added(dev[1])
761 ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
763 raise Exception("dev0 did not report auth failure (%d)" % i)
764 ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
766 raise Exception("dev1 did not report auth failure (%d)" % i)
768 ev = dev[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
770 raise Exception("dev0 did not report auth blocked")
771 ev = dev[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
773 raise Exception("dev1 did not report auth blocked")
775 def test_mesh_wpa_auth_init_oom(dev, apdev):
776 """Secure mesh network setup failing due to wpa_init() OOM"""
777 check_mesh_support(dev[0], secure=True)
778 dev[0].request("SET sae_groups ")
779 with alloc_fail(dev[0], 1, "wpa_init"):
780 id = add_mesh_secure_net(dev[0])
781 dev[0].mesh_group_add(id)
782 ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.2)
784 raise Exception("Unexpected mesh group start during OOM")
786 def test_mesh_wpa_init_fail(dev, apdev):
787 """Secure mesh network setup local failure"""
788 check_mesh_support(dev[0], secure=True)
789 dev[0].request("SET sae_groups ")
791 with fail_test(dev[0], 1, "os_get_random;=__mesh_rsn_auth_init"):
792 id = add_mesh_secure_net(dev[0])
793 dev[0].mesh_group_add(id)
794 wait_fail_trigger(dev[0], "GET_FAIL")
796 with alloc_fail(dev[0], 1, "mesh_rsn_auth_init"):
797 id = add_mesh_secure_net(dev[0])
798 dev[0].mesh_group_add(id)
799 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
801 def test_wpas_mesh_reconnect(dev, apdev):
802 """Secure mesh network plink counting during reconnection"""
803 check_mesh_support(dev[0])
805 _test_wpas_mesh_reconnect(dev)
807 dev[0].request("SET max_peer_links 99")
809 def _test_wpas_mesh_reconnect(dev):
810 dev[0].request("SET max_peer_links 2")
811 dev[0].request("SET sae_groups ")
812 id = add_mesh_secure_net(dev[0])
813 dev[0].set_network(id, "beacon_int", "100")
814 dev[0].mesh_group_add(id)
815 dev[1].request("SET sae_groups ")
816 id = add_mesh_secure_net(dev[1])
817 dev[1].mesh_group_add(id)
818 check_mesh_group_added(dev[0])
819 check_mesh_group_added(dev[1])
820 check_mesh_peer_connected(dev[0])
821 check_mesh_peer_connected(dev[1])
824 # Drop incoming management frames to avoid handling link close
825 dev[0].request("SET ext_mgmt_frame_handling 1")
826 dev[1].mesh_group_remove()
827 check_mesh_group_removed(dev[1])
828 dev[1].request("FLUSH")
829 dev[0].request("SET ext_mgmt_frame_handling 0")
830 id = add_mesh_secure_net(dev[1])
831 dev[1].mesh_group_add(id)
832 check_mesh_group_added(dev[1])
833 check_mesh_peer_connected(dev[1])
834 dev[0].dump_monitor()
835 dev[1].dump_monitor()
837 def test_wpas_mesh_gate_forwarding(dev, apdev, p):
838 """Mesh forwards traffic to unknown sta to mesh gates"""
839 addr0 = dev[0].own_addr()
840 addr1 = dev[1].own_addr()
841 addr2 = dev[2].own_addr()
842 external_sta = '02:11:22:33:44:55'
844 # start 3 node connected mesh
845 check_mesh_support(dev[0])
847 add_open_mesh_network(dev[i])
848 check_mesh_group_added(dev[i])
850 check_mesh_peer_connected(dev[i])
852 hwsim_utils.test_connectivity(dev[0], dev[1])
853 hwsim_utils.test_connectivity(dev[1], dev[2])
854 hwsim_utils.test_connectivity(dev[0], dev[2])
856 # dev0 and dev1 are mesh gates
857 subprocess.call(['iw', 'dev', dev[0].ifname, 'set', 'mesh_param',
858 'mesh_gate_announcements=1'])
859 subprocess.call(['iw', 'dev', dev[1].ifname, 'set', 'mesh_param',
860 'mesh_gate_announcements=1'])
862 # wait for gate announcement frames
865 # data frame from dev2 -> external sta should be sent to both gates
866 dev[2].request("DATA_TEST_CONFIG 1")
867 dev[2].request("DATA_TEST_TX {} {} 0".format(external_sta, addr2))
868 dev[2].request("DATA_TEST_CONFIG 0")
870 capfile = os.path.join(p['logdir'], "hwsim0.pcapng")
871 filt = "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2,
874 da = run_tshark(capfile, filt, [ "wlan.da" ])
875 if addr0 in da and addr1 in da:
876 logger.debug("Frames seen in tshark iteration %d" % i)
881 raise Exception("Frame to gate %s not observed" % addr0)
883 raise Exception("Frame to gate %s not observed" % addr1)
885 def test_wpas_mesh_pmksa_caching(dev, apdev):
886 """Secure mesh network and PMKSA caching"""
887 check_mesh_support(dev[0], secure=True)
888 dev[0].request("SET sae_groups ")
889 id = add_mesh_secure_net(dev[0])
890 dev[0].mesh_group_add(id)
892 dev[1].request("SET sae_groups ")
893 id = add_mesh_secure_net(dev[1])
894 dev[1].mesh_group_add(id)
896 # Check for mesh joined
897 check_mesh_group_added(dev[0])
898 check_mesh_group_added(dev[1])
900 # Check for peer connected
901 check_mesh_peer_connected(dev[0])
902 check_mesh_peer_connected(dev[1])
904 addr0 = dev[0].own_addr()
905 addr1 = dev[1].own_addr()
906 pmksa0 = dev[0].get_pmksa(addr1)
907 pmksa1 = dev[1].get_pmksa(addr0)
908 if pmksa0 is None or pmksa1 is None:
909 raise Exception("No PMKSA cache entry created")
910 if pmksa0['pmkid'] != pmksa1['pmkid']:
911 raise Exception("PMKID mismatch in PMKSA cache entries")
913 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
914 raise Exception("Failed to remove peer")
915 pmksa0b = dev[0].get_pmksa(addr1)
917 raise Exception("PMKSA cache entry not maintained")
920 if "FAIL" not in dev[0].request("MESH_PEER_ADD " + addr1):
921 raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
923 def test_wpas_mesh_pmksa_caching2(dev, apdev):
924 """Secure mesh network and PMKSA caching with no_auto_peer=1"""
925 check_mesh_support(dev[0], secure=True)
926 addr0 = dev[0].own_addr()
927 addr1 = dev[1].own_addr()
928 dev[0].request("SET sae_groups ")
929 id = add_mesh_secure_net(dev[0])
930 dev[0].set_network(id, "no_auto_peer", "1")
931 dev[0].mesh_group_add(id)
933 dev[1].request("SET sae_groups ")
934 id = add_mesh_secure_net(dev[1])
935 dev[1].set_network(id, "no_auto_peer", "1")
936 dev[1].mesh_group_add(id)
938 # Check for mesh joined
939 check_mesh_group_added(dev[0])
940 check_mesh_group_added(dev[1])
942 # Check for peer connected
943 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
945 raise Exception("Missing no-initiate message")
946 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
947 raise Exception("MESH_PEER_ADD failed")
948 check_mesh_peer_connected(dev[0])
949 check_mesh_peer_connected(dev[1])
951 pmksa0 = dev[0].get_pmksa(addr1)
952 pmksa1 = dev[1].get_pmksa(addr0)
953 if pmksa0 is None or pmksa1 is None:
954 raise Exception("No PMKSA cache entry created")
955 if pmksa0['pmkid'] != pmksa1['pmkid']:
956 raise Exception("PMKID mismatch in PMKSA cache entries")
958 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
959 raise Exception("Failed to remove peer")
960 pmksa0b = dev[0].get_pmksa(addr1)
962 raise Exception("PMKSA cache entry not maintained")
964 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
966 raise Exception("Missing no-initiate message (2)")
967 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
968 raise Exception("MESH_PEER_ADD failed (2)")
969 check_mesh_peer_connected(dev[0])
970 check_mesh_peer_connected(dev[1])
972 pmksa0c = dev[0].get_pmksa(addr1)
973 pmksa1c = dev[1].get_pmksa(addr0)
974 if pmksa0c is None or pmksa1c is None:
975 raise Exception("No PMKSA cache entry created (2)")
976 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
977 raise Exception("PMKID mismatch in PMKSA cache entries")
978 if pmksa0['pmkid'] != pmksa0c['pmkid']:
979 raise Exception("PMKID changed")
981 hwsim_utils.test_connectivity(dev[0], dev[1])
983 def test_wpas_mesh_pmksa_caching_no_match(dev, apdev):
984 """Secure mesh network and PMKSA caching with no PMKID match"""
985 check_mesh_support(dev[0], secure=True)
986 addr0 = dev[0].own_addr()
987 addr1 = dev[1].own_addr()
988 dev[0].request("SET sae_groups ")
989 id = add_mesh_secure_net(dev[0])
990 dev[0].set_network(id, "no_auto_peer", "1")
991 dev[0].mesh_group_add(id)
993 dev[1].request("SET sae_groups ")
994 id = add_mesh_secure_net(dev[1])
995 dev[1].set_network(id, "no_auto_peer", "1")
996 dev[1].mesh_group_add(id)
998 # Check for mesh joined
999 check_mesh_group_added(dev[0])
1000 check_mesh_group_added(dev[1])
1002 # Check for peer connected
1003 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1005 raise Exception("Missing no-initiate message")
1006 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1007 raise Exception("MESH_PEER_ADD failed")
1008 check_mesh_peer_connected(dev[0])
1009 check_mesh_peer_connected(dev[1])
1011 pmksa0 = dev[0].get_pmksa(addr1)
1012 pmksa1 = dev[1].get_pmksa(addr0)
1013 if pmksa0 is None or pmksa1 is None:
1014 raise Exception("No PMKSA cache entry created")
1015 if pmksa0['pmkid'] != pmksa1['pmkid']:
1016 raise Exception("PMKID mismatch in PMKSA cache entries")
1018 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
1019 raise Exception("Failed to remove peer")
1021 if "OK" not in dev[1].request("PMKSA_FLUSH"):
1022 raise Exception("Failed to flush PMKSA cache")
1024 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1026 raise Exception("Missing no-initiate message (2)")
1027 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1028 raise Exception("MESH_PEER_ADD failed (2)")
1029 check_mesh_peer_connected(dev[0])
1030 check_mesh_peer_connected(dev[1])
1032 pmksa0c = dev[0].get_pmksa(addr1)
1033 pmksa1c = dev[1].get_pmksa(addr0)
1034 if pmksa0c is None or pmksa1c is None:
1035 raise Exception("No PMKSA cache entry created (2)")
1036 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
1037 raise Exception("PMKID mismatch in PMKSA cache entries")
1038 if pmksa0['pmkid'] == pmksa0c['pmkid']:
1039 raise Exception("PMKID did not change")
1041 hwsim_utils.test_connectivity(dev[0], dev[1])
1043 def test_mesh_pmksa_caching_oom(dev, apdev):
1044 """Secure mesh network and PMKSA caching failing due to OOM"""
1045 check_mesh_support(dev[0], secure=True)
1046 addr0 = dev[0].own_addr()
1047 addr1 = dev[1].own_addr()
1048 dev[0].request("SET sae_groups ")
1049 id = add_mesh_secure_net(dev[0])
1050 dev[0].set_network(id, "no_auto_peer", "1")
1051 dev[0].mesh_group_add(id)
1053 dev[1].request("SET sae_groups ")
1054 id = add_mesh_secure_net(dev[1])
1055 dev[1].set_network(id, "no_auto_peer", "1")
1056 dev[1].mesh_group_add(id)
1058 # Check for mesh joined
1059 check_mesh_group_added(dev[0])
1060 check_mesh_group_added(dev[1])
1062 # Check for peer connected
1063 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1065 raise Exception("Missing no-initiate message")
1066 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1067 raise Exception("MESH_PEER_ADD failed")
1068 check_mesh_peer_connected(dev[0])
1069 check_mesh_peer_connected(dev[1])
1071 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
1072 raise Exception("Failed to remove peer")
1073 pmksa0b = dev[0].get_pmksa(addr1)
1075 raise Exception("PMKSA cache entry not maintained")
1077 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1079 raise Exception("Missing no-initiate message (2)")
1081 with alloc_fail(dev[0], 1, "wpa_auth_sta_init;mesh_rsn_auth_sae_sta"):
1082 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1083 raise Exception("MESH_PEER_ADD failed (2)")
1084 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
1086 def test_mesh_oom(dev, apdev):
1087 """Mesh network setup failing due to OOM"""
1088 check_mesh_support(dev[0], secure=True)
1089 dev[0].request("SET sae_groups ")
1091 with alloc_fail(dev[0], 1, "mesh_config_create"):
1092 add_open_mesh_network(dev[0])
1093 ev = dev[0].wait_event(["Failed to init mesh"])
1095 raise Exception("Init failure not reported")
1097 with alloc_fail(dev[0], 4, "=wpa_supplicant_mesh_init"):
1098 add_open_mesh_network(dev[0], basic_rates="60 120 240")
1099 ev = dev[0].wait_event(["Failed to init mesh"])
1101 raise Exception("Init failure not reported")
1103 for i in range(1, 66):
1104 dev[0].dump_monitor()
1105 logger.info("Test instance %d" % i)
1107 with alloc_fail(dev[0], i, "wpa_supplicant_mesh_init"):
1108 add_open_mesh_network(dev[0])
1109 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
1110 ev = dev[0].wait_event(["Failed to init mesh",
1111 "MESH-GROUP-STARTED"])
1113 raise Exception("Init failure not reported")
1114 except Exception, e:
1117 logger.info("Ignore no-oom for i=%d" % i)
1119 with alloc_fail(dev[0], 5, "=wpa_supplicant_mesh_init"):
1120 id = add_mesh_secure_net(dev[0])
1121 dev[0].mesh_group_add(id)
1122 ev = dev[0].wait_event(["Failed to init mesh"])
1124 raise Exception("Init failure not reported")
1126 def test_mesh_add_interface_oom(dev):
1127 """wpa_supplicant mesh with dynamic interface addition failing"""
1128 check_mesh_support(dev[0])
1129 for i in range(1, 3):
1132 with alloc_fail(dev[0], i, "wpas_mesh_add_interface"):
1133 mesh = dev[0].request("MESH_INTERFACE_ADD").strip()
1135 if mesh and mesh != "FAIL":
1136 dev[0].request("MESH_GROUP_REMOVE " + mesh)
1138 def test_mesh_scan_oom(dev):
1139 """wpa_supplicant mesh scan results and OOM"""
1140 check_mesh_support(dev[0])
1141 add_open_mesh_network(dev[0])
1142 check_mesh_group_added(dev[0])
1144 dev[1].scan(freq="2412")
1145 res = dev[1].request("SCAN_RESULTS")
1148 for r in res.splitlines():
1151 bssid = r.split('\t')[0]
1153 bss = dev[1].get_bss(bssid)
1155 raise Exception("Could not get BSS entry for mesh")
1157 for i in range(1, 3):
1158 with alloc_fail(dev[1], i, "mesh_attr_text"):
1159 bss = dev[1].get_bss(bssid)
1161 raise Exception("Unexpected BSS result during OOM")
1163 def test_mesh_drv_fail(dev, apdev):
1164 """Mesh network setup failing due to driver command failure"""
1165 check_mesh_support(dev[0], secure=True)
1166 dev[0].request("SET sae_groups ")
1168 with fail_test(dev[0], 1, "nl80211_join_mesh"):
1169 add_open_mesh_network(dev[0])
1170 ev = dev[0].wait_event(["mesh join error"])
1172 raise Exception("Join failure not reported")
1174 dev[0].dump_monitor()
1175 with fail_test(dev[0], 1, "wpa_driver_nl80211_if_add"):
1176 if "FAIL" not in dev[0].request("MESH_INTERFACE_ADD").strip():
1177 raise Exception("Interface added unexpectedly")
1179 dev[0].dump_monitor()
1180 with fail_test(dev[0], 1, "wpa_driver_nl80211_init_mesh"):
1181 add_open_mesh_network(dev[0])
1182 ev = dev[0].wait_event(["Could not join mesh"])
1184 raise Exception("Join failure not reported")
1186 def test_mesh_sae_groups_invalid(dev, apdev):
1187 """Mesh with invalid SAE group configuration"""
1188 check_mesh_support(dev[0], secure=True)
1190 dev[0].request("SET sae_groups 25")
1191 id = add_mesh_secure_net(dev[0])
1192 dev[0].mesh_group_add(id)
1194 dev[1].request("SET sae_groups 123 122 121")
1195 id = add_mesh_secure_net(dev[1])
1196 dev[1].mesh_group_add(id)
1198 check_mesh_group_added(dev[0])
1199 check_mesh_group_added(dev[1])
1201 ev = dev[0].wait_event(["new peer notification"], timeout=10)
1203 raise Exception("dev[0] did not see peer")
1204 ev = dev[1].wait_event(["new peer notification"], timeout=10)
1206 raise Exception("dev[1] did not see peer")
1208 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
1210 raise Exception("Unexpected connection(0)")
1212 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
1214 raise Exception("Unexpected connection(1)")
1216 dev[0].request("SET sae_groups ")
1217 dev[1].request("SET sae_groups ")
1219 def test_mesh_sae_failure(dev, apdev):
1220 """Mesh and local SAE failures"""
1221 check_mesh_support(dev[0], secure=True)
1223 dev[0].request("SET sae_groups ")
1224 dev[1].request("SET sae_groups ")
1226 funcs = [ (1, "=mesh_rsn_auth_sae_sta", True),
1227 (1, "mesh_rsn_build_sae_commit;mesh_rsn_auth_sae_sta", False),
1228 (1, "auth_sae_init_committed;mesh_rsn_auth_sae_sta", True),
1229 (1, "=mesh_rsn_protect_frame", True),
1230 (2, "=mesh_rsn_protect_frame", True),
1231 (1, "aes_siv_encrypt;mesh_rsn_protect_frame", True),
1232 (1, "=mesh_rsn_process_ampe", True),
1233 (1, "aes_siv_decrypt;mesh_rsn_process_ampe", True) ]
1234 for count, func, success in funcs:
1235 id = add_mesh_secure_net(dev[0])
1236 dev[0].mesh_group_add(id)
1238 with alloc_fail(dev[1], count, func):
1239 id = add_mesh_secure_net(dev[1])
1240 dev[1].mesh_group_add(id)
1241 check_mesh_group_added(dev[0])
1242 check_mesh_group_added(dev[1])
1244 # retry is expected to work
1245 check_mesh_peer_connected(dev[0])
1246 check_mesh_peer_connected(dev[1])
1248 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1249 dev[0].mesh_group_remove()
1250 dev[1].mesh_group_remove()
1251 check_mesh_group_removed(dev[0])
1252 check_mesh_group_removed(dev[1])
1254 def test_mesh_failure(dev, apdev):
1255 """Mesh and local failures"""
1256 check_mesh_support(dev[0])
1258 funcs = [ (1, "ap_sta_add;mesh_mpm_add_peer", True),
1259 (1, "wpabuf_alloc;mesh_mpm_send_plink_action", True) ]
1260 for count, func, success in funcs:
1261 add_open_mesh_network(dev[0])
1263 with alloc_fail(dev[1], count, func):
1264 add_open_mesh_network(dev[1])
1265 check_mesh_group_added(dev[0])
1266 check_mesh_group_added(dev[1])
1268 # retry is expected to work
1269 check_mesh_peer_connected(dev[0])
1270 check_mesh_peer_connected(dev[1])
1272 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1273 dev[0].mesh_group_remove()
1274 dev[1].mesh_group_remove()
1275 check_mesh_group_removed(dev[0])
1276 check_mesh_group_removed(dev[1])
1278 funcs = [ (1, "mesh_mpm_init_link", True) ]
1279 for count, func, success in funcs:
1280 add_open_mesh_network(dev[0])
1282 with fail_test(dev[1], count, func):
1283 add_open_mesh_network(dev[1])
1284 check_mesh_group_added(dev[0])
1285 check_mesh_group_added(dev[1])
1287 # retry is expected to work
1288 check_mesh_peer_connected(dev[0])
1289 check_mesh_peer_connected(dev[1])
1291 wait_fail_trigger(dev[1], "GET_FAIL")
1292 dev[0].mesh_group_remove()
1293 dev[1].mesh_group_remove()
1294 check_mesh_group_removed(dev[0])
1295 check_mesh_group_removed(dev[1])
1297 def test_mesh_invalid_frequency(dev, apdev):
1298 """Mesh and invalid frequency configuration"""
1299 check_mesh_support(dev[0])
1300 add_open_mesh_network(dev[0], freq=None)
1301 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1302 "Could not join mesh"])
1303 if ev is None or "Could not join mesh" not in ev:
1304 raise Exception("Mesh join failure not reported")
1305 dev[0].request("REMOVE_NETWORK all")
1307 add_open_mesh_network(dev[0], freq="2413")
1308 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1309 "Could not join mesh"])
1310 if ev is None or "Could not join mesh" not in ev:
1311 raise Exception("Mesh join failure not reported")
1313 def test_mesh_default_beacon_int(dev, apdev):
1314 """Mesh and default beacon interval"""
1315 check_mesh_support(dev[0])
1317 dev[0].request("SET beacon_int 200")
1318 add_open_mesh_network(dev[0])
1319 check_mesh_group_added(dev[0])
1321 dev[0].request("SET beacon_int 0")
1323 def test_mesh_scan_parse_error(dev, apdev):
1324 """Mesh scan element parse error"""
1325 check_mesh_support(dev[0])
1326 params = { "ssid": "open",
1327 "beacon_int": "2000" }
1328 hapd = hostapd.add_ap(apdev[0], params)
1329 bssid = apdev[0]['bssid']
1330 hapd.set('vendor_elements', 'dd0201')
1332 dev[0].scan(freq=2412)
1333 if bssid in dev[0].request("SCAN_RESULTS"):
1335 # This will fail in IE parsing due to the truncated IE in the Probe
1337 bss = dev[0].request("BSS " + bssid)