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()
14 from wpasupplicant import WpaSupplicant
15 from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
16 from tshark import run_tshark
18 def check_mesh_support(dev, secure=False):
19 if "MESH" not in dev.get_capability("modes"):
20 raise HwsimSkip("Driver does not support mesh")
21 if secure and "SAE" not in dev.get_capability("auth_alg"):
22 raise HwsimSkip("SAE not supported")
24 def check_mesh_scan(dev, params, other_started=False, beacon_int=0):
27 id = dev.request("SCAN " + params)
29 raise Exception("Failed to start scan")
33 ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
35 raise Exception("Other scan did not start")
36 if "id=" + str(id) in ev:
37 raise Exception("Own scan id unexpectedly included in start event")
39 ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
41 raise Exception("Other scan did not complete")
42 if "id=" + str(id) in ev:
44 "Own scan id unexpectedly included in completed event")
46 ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
48 raise Exception("Scan did not start")
49 if "id=" + str(id) not in ev:
50 raise Exception("Scan id not included in start event")
52 ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
54 raise Exception("Scan did not complete")
55 if "id=" + str(id) not in ev:
56 raise Exception("Scan id not included in completed event")
58 res = dev.request("SCAN_RESULTS")
60 if res.find("[MESH]") < 0:
61 raise Exception("Scan did not contain a MESH network")
63 bssid = res.splitlines()[1].split(' ')[0]
64 bss = dev.get_bss(bssid)
66 raise Exception("Could not get BSS entry for mesh")
67 if 'mesh_capability' not in bss:
68 raise Exception("mesh_capability missing from BSS entry")
70 if 'beacon_int' not in bss:
71 raise Exception("beacon_int missing from BSS entry")
72 if str(beacon_int) != bss['beacon_int']:
73 raise Exception("Unexpected beacon_int in BSS entry: " + bss['beacon_int'])
75 def check_mesh_group_added(dev):
76 ev = dev.wait_event(["MESH-GROUP-STARTED"])
78 raise Exception("Test exception: Couldn't join mesh")
81 def check_mesh_group_removed(dev):
82 ev = dev.wait_event(["MESH-GROUP-REMOVED"])
84 raise Exception("Test exception: Couldn't leave mesh")
87 def check_mesh_peer_connected(dev, timeout=10):
88 ev = dev.wait_event(["MESH-PEER-CONNECTED"], timeout=timeout)
90 raise Exception("Test exception: Remote peer did not connect.")
93 def check_mesh_peer_disconnected(dev):
94 ev = dev.wait_event(["MESH-PEER-DISCONNECTED"])
96 raise Exception("Test exception: Peer disconnect event not detected.")
99 def test_wpas_add_set_remove_support(dev):
100 """wpa_supplicant MESH add/set/remove network support"""
101 check_mesh_support(dev[0])
102 id = dev[0].add_network()
103 dev[0].set_network(id, "mode", "5")
104 dev[0].remove_network(id)
106 def add_open_mesh_network(dev, freq="2412", start=True, beacon_int=0,
107 basic_rates=None, chwidth=0):
108 id = dev.add_network()
109 dev.set_network(id, "mode", "5")
110 dev.set_network_quoted(id, "ssid", "wpas-mesh-open")
111 dev.set_network(id, "key_mgmt", "NONE")
113 dev.set_network(id, "frequency", freq)
115 dev.set_network(id, "max_oper_chwidth", str(chwidth))
117 dev.set_network(id, "beacon_int", str(beacon_int))
119 dev.set_network(id, "mesh_basic_rates", basic_rates)
121 dev.mesh_group_add(id)
124 def test_wpas_mesh_group_added(dev):
125 """wpa_supplicant MESH group add"""
126 check_mesh_support(dev[0])
127 add_open_mesh_network(dev[0])
129 # Check for MESH-GROUP-STARTED event
130 check_mesh_group_added(dev[0])
133 def test_wpas_mesh_group_remove(dev):
134 """wpa_supplicant MESH group remove"""
135 check_mesh_support(dev[0])
136 add_open_mesh_network(dev[0])
137 # Check for MESH-GROUP-STARTED event
138 check_mesh_group_added(dev[0])
139 dev[0].mesh_group_remove()
140 # Check for MESH-GROUP-REMOVED event
141 check_mesh_group_removed(dev[0])
142 dev[0].mesh_group_remove()
144 def test_wpas_mesh_peer_connected(dev):
145 """wpa_supplicant MESH peer connected"""
146 check_mesh_support(dev[0])
147 add_open_mesh_network(dev[0], beacon_int=160)
148 add_open_mesh_network(dev[1], beacon_int=160)
150 # Check for mesh joined
151 check_mesh_group_added(dev[0])
152 check_mesh_group_added(dev[1])
154 # Check for peer connected
155 check_mesh_peer_connected(dev[0])
156 check_mesh_peer_connected(dev[1])
159 def test_wpas_mesh_peer_disconnected(dev):
160 """wpa_supplicant MESH peer disconnected"""
161 check_mesh_support(dev[0])
162 add_open_mesh_network(dev[0])
163 add_open_mesh_network(dev[1])
165 # Check for mesh joined
166 check_mesh_group_added(dev[0])
167 check_mesh_group_added(dev[1])
169 # Check for peer connected
170 check_mesh_peer_connected(dev[0])
171 check_mesh_peer_connected(dev[1])
173 # Remove group on dev 1
174 dev[1].mesh_group_remove()
175 # Device 0 should get a disconnection event
176 check_mesh_peer_disconnected(dev[0])
179 def test_wpas_mesh_mode_scan(dev):
180 """wpa_supplicant MESH scan support"""
181 check_mesh_support(dev[0])
182 add_open_mesh_network(dev[0])
183 add_open_mesh_network(dev[1], beacon_int=175)
185 # Check for mesh joined
186 check_mesh_group_added(dev[0])
187 check_mesh_group_added(dev[1])
189 # Check for Mesh scan
190 check_mesh_scan(dev[0], "use_id=1", beacon_int=175)
192 def test_wpas_mesh_open(dev, apdev):
193 """wpa_supplicant open MESH network connectivity"""
194 check_mesh_support(dev[0])
195 add_open_mesh_network(dev[0], freq="2462", basic_rates="60 120 240")
196 add_open_mesh_network(dev[1], freq="2462", basic_rates="60 120 240")
198 # Check for mesh joined
199 check_mesh_group_added(dev[0])
200 check_mesh_group_added(dev[1])
202 # Check for peer connected
203 check_mesh_peer_connected(dev[0])
204 check_mesh_peer_connected(dev[1])
206 # Test connectivity 0->1 and 1->0
207 hwsim_utils.test_connectivity(dev[0], dev[1])
209 def test_wpas_mesh_open_no_auto(dev, apdev):
210 """wpa_supplicant open MESH network connectivity"""
211 check_mesh_support(dev[0])
212 id = add_open_mesh_network(dev[0], start=False)
213 dev[0].set_network(id, "dot11MeshMaxRetries", "16")
214 dev[0].set_network(id, "dot11MeshRetryTimeout", "255")
215 dev[0].mesh_group_add(id)
217 id = add_open_mesh_network(dev[1], start=False)
218 dev[1].set_network(id, "no_auto_peer", "1")
219 dev[1].mesh_group_add(id)
221 # Check for mesh joined
222 check_mesh_group_added(dev[0])
223 check_mesh_group_added(dev[1])
225 # Check for peer connected
226 check_mesh_peer_connected(dev[0], timeout=30)
227 check_mesh_peer_connected(dev[1])
229 # Test connectivity 0->1 and 1->0
230 hwsim_utils.test_connectivity(dev[0], dev[1])
232 def add_mesh_secure_net(dev, psk=True):
233 id = dev.add_network()
234 dev.set_network(id, "mode", "5")
235 dev.set_network_quoted(id, "ssid", "wpas-mesh-sec")
236 dev.set_network(id, "key_mgmt", "SAE")
237 dev.set_network(id, "frequency", "2412")
239 dev.set_network_quoted(id, "psk", "thisismypassphrase!")
242 def test_wpas_mesh_secure(dev, apdev):
243 """wpa_supplicant secure MESH network connectivity"""
244 check_mesh_support(dev[0], secure=True)
245 dev[0].request("SET sae_groups ")
246 id = add_mesh_secure_net(dev[0])
247 dev[0].mesh_group_add(id)
249 dev[1].request("SET sae_groups ")
250 id = add_mesh_secure_net(dev[1])
251 dev[1].mesh_group_add(id)
253 # Check for mesh joined
254 check_mesh_group_added(dev[0])
255 check_mesh_group_added(dev[1])
257 # Check for peer connected
258 check_mesh_peer_connected(dev[0])
259 check_mesh_peer_connected(dev[1])
261 # Test connectivity 0->1 and 1->0
262 hwsim_utils.test_connectivity(dev[0], dev[1])
264 def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
265 """wpa_supplicant secure MESH and SAE group mismatch"""
266 check_mesh_support(dev[0], secure=True)
267 addr0 = dev[0].p2p_interface_addr()
268 addr1 = dev[1].p2p_interface_addr()
269 addr2 = dev[2].p2p_interface_addr()
271 dev[0].request("SET sae_groups 19 25")
272 id = add_mesh_secure_net(dev[0])
273 dev[0].mesh_group_add(id)
275 dev[1].request("SET sae_groups 19")
276 id = add_mesh_secure_net(dev[1])
277 dev[1].mesh_group_add(id)
279 dev[2].request("SET sae_groups 26")
280 id = add_mesh_secure_net(dev[2])
281 dev[2].mesh_group_add(id)
283 check_mesh_group_added(dev[0])
284 check_mesh_group_added(dev[1])
285 check_mesh_group_added(dev[2])
287 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"])
289 raise Exception("Remote peer did not connect")
291 raise Exception("Unexpected peer connected: " + ev)
293 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"])
295 raise Exception("Remote peer did not connect")
297 raise Exception("Unexpected peer connected: " + ev)
299 ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
301 raise Exception("Unexpected peer connection at dev[2]: " + ev)
303 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
305 raise Exception("Unexpected peer connection: " + ev)
307 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
309 raise Exception("Unexpected peer connection: " + ev)
311 dev[0].request("SET sae_groups ")
312 dev[1].request("SET sae_groups ")
313 dev[2].request("SET sae_groups ")
315 def test_wpas_mesh_secure_sae_group_negotiation(dev, apdev):
316 """wpa_supplicant secure MESH and SAE group negotiation"""
317 check_mesh_support(dev[0], secure=True)
318 addr0 = dev[0].own_addr()
319 addr1 = dev[1].own_addr()
321 #dev[0].request("SET sae_groups 21 20 25 26")
322 dev[0].request("SET sae_groups 25")
323 id = add_mesh_secure_net(dev[0])
324 dev[0].mesh_group_add(id)
326 dev[1].request("SET sae_groups 19 25")
327 id = add_mesh_secure_net(dev[1])
328 dev[1].mesh_group_add(id)
330 check_mesh_group_added(dev[0])
331 check_mesh_group_added(dev[1])
333 check_mesh_peer_connected(dev[0])
334 check_mesh_peer_connected(dev[1])
336 dev[0].request("SET sae_groups ")
337 dev[1].request("SET sae_groups ")
339 def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
340 """wpa_supplicant secure MESH and missing SAE password"""
341 check_mesh_support(dev[0], secure=True)
342 id = add_mesh_secure_net(dev[0], psk=False)
343 dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
344 dev[0].mesh_group_add(id)
345 ev = dev[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
348 raise Exception("Timeout on mesh start event")
349 if "MESH-GROUP-STARTED" in ev:
350 raise Exception("Unexpected mesh group start")
351 ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.1)
353 raise Exception("Unexpected mesh group start")
355 def test_wpas_mesh_secure_no_auto(dev, apdev):
356 """wpa_supplicant secure MESH network connectivity"""
357 check_mesh_support(dev[0], secure=True)
358 dev[0].request("SET sae_groups 19")
359 id = add_mesh_secure_net(dev[0])
360 dev[0].mesh_group_add(id)
362 dev[1].request("SET sae_groups 19")
363 id = add_mesh_secure_net(dev[1])
364 dev[1].set_network(id, "no_auto_peer", "1")
365 dev[1].mesh_group_add(id)
367 # Check for mesh joined
368 check_mesh_group_added(dev[0])
369 check_mesh_group_added(dev[1])
371 # Check for peer connected
372 check_mesh_peer_connected(dev[0], timeout=30)
373 check_mesh_peer_connected(dev[1])
375 # Test connectivity 0->1 and 1->0
376 hwsim_utils.test_connectivity(dev[0], dev[1])
378 dev[0].request("SET sae_groups ")
379 dev[1].request("SET sae_groups ")
381 def test_wpas_mesh_secure_dropped_frame(dev, apdev):
382 """Secure mesh network connectivity when the first plink Open is dropped"""
383 check_mesh_support(dev[0], secure=True)
385 dev[0].request("SET ext_mgmt_frame_handling 1")
386 dev[0].request("SET sae_groups ")
387 id = add_mesh_secure_net(dev[0])
388 dev[0].mesh_group_add(id)
390 dev[1].request("SET sae_groups ")
391 id = add_mesh_secure_net(dev[1])
392 dev[1].mesh_group_add(id)
394 # Check for mesh joined
395 check_mesh_group_added(dev[0])
396 check_mesh_group_added(dev[1])
398 # Drop the first Action frame (plink Open) to test unexpected order of
399 # Confirm/Open messages.
404 raise Exception("Did not see Action frames")
405 rx_msg = dev[0].mgmt_rx()
407 raise Exception("MGMT-RX timeout")
408 if rx_msg['subtype'] == 13:
409 logger.info("Drop the first Action frame")
411 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'))):
412 raise Exception("MGMT_RX_PROCESS failed")
414 dev[0].request("SET ext_mgmt_frame_handling 0")
416 # Check for peer connected
417 check_mesh_peer_connected(dev[0])
418 check_mesh_peer_connected(dev[1])
420 # Test connectivity 0->1 and 1->0
421 hwsim_utils.test_connectivity(dev[0], dev[1])
423 def test_wpas_mesh_ctrl(dev):
424 """wpa_supplicant ctrl_iface mesh command error cases"""
425 check_mesh_support(dev[0])
426 if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"):
427 raise Exception("Unexpected MESH_GROUP_ADD success")
428 id = dev[0].add_network()
429 if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
430 raise Exception("Unexpected MESH_GROUP_ADD success")
431 dev[0].set_network(id, "mode", "5")
432 dev[0].set_network(id, "key_mgmt", "WPA-PSK")
433 if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
434 raise Exception("Unexpected MESH_GROUP_ADD success")
436 if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE foo"):
437 raise Exception("Unexpected MESH_GROUP_REMOVE success")
439 def test_wpas_mesh_dynamic_interface(dev):
440 """wpa_supplicant mesh with dynamic interface"""
441 check_mesh_support(dev[0])
445 mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
447 raise Exception("MESH_INTERFACE_ADD failed")
448 mesh1 = dev[1].request("MESH_INTERFACE_ADD")
450 raise Exception("MESH_INTERFACE_ADD failed")
452 wpas0 = WpaSupplicant(ifname=mesh0)
453 wpas1 = WpaSupplicant(ifname=mesh1)
454 logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
455 logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
457 add_open_mesh_network(wpas0)
458 add_open_mesh_network(wpas1)
459 check_mesh_group_added(wpas0)
460 check_mesh_group_added(wpas1)
461 check_mesh_peer_connected(wpas0)
462 check_mesh_peer_connected(wpas1)
463 hwsim_utils.test_connectivity(wpas0, wpas1)
465 # Must not allow MESH_GROUP_REMOVE on dynamic interface
466 if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh0):
467 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
468 if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh1):
469 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
471 # Must not allow MESH_GROUP_REMOVE on another radio interface
472 if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh1):
473 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
474 if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh0):
475 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
477 wpas0.remove_ifname()
478 wpas1.remove_ifname()
480 if "OK" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
481 raise Exception("MESH_GROUP_REMOVE failed")
482 if "OK" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
483 raise Exception("MESH_GROUP_REMOVE failed")
485 if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
486 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
487 if "FAIL" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
488 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
490 logger.info("Make sure another dynamic group can be added")
491 mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
493 raise Exception("MESH_INTERFACE_ADD failed")
494 mesh1 = dev[1].request("MESH_INTERFACE_ADD")
496 raise Exception("MESH_INTERFACE_ADD failed")
498 wpas0 = WpaSupplicant(ifname=mesh0)
499 wpas1 = WpaSupplicant(ifname=mesh1)
500 logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
501 logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
503 add_open_mesh_network(wpas0)
504 add_open_mesh_network(wpas1)
505 check_mesh_group_added(wpas0)
506 check_mesh_group_added(wpas1)
507 check_mesh_peer_connected(wpas0)
508 check_mesh_peer_connected(wpas1)
509 hwsim_utils.test_connectivity(wpas0, wpas1)
512 dev[0].request("MESH_GROUP_REMOVE " + mesh0)
514 dev[1].request("MESH_GROUP_REMOVE " + mesh1)
516 def test_wpas_mesh_max_peering(dev, apdev):
517 """Mesh max peering limit"""
518 check_mesh_support(dev[0])
520 dev[0].request("SET max_peer_links 1")
522 # first, connect dev[0] and dev[1]
523 add_open_mesh_network(dev[0])
524 add_open_mesh_network(dev[1])
526 ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
528 raise Exception("dev%d did not connect with any peer" % i)
530 # add dev[2] which will try to connect with both dev[0] and dev[1],
531 # but can complete connection only with dev[1]
532 add_open_mesh_network(dev[2])
533 for i in range(1, 3):
534 ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
536 raise Exception("dev%d did not connect the second peer" % i)
538 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
540 raise Exception("dev0 connection beyond max peering limit")
542 ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
544 raise Exception("dev2 reported unexpected peering: " + ev)
547 dev[i].mesh_group_remove()
548 check_mesh_group_removed(dev[i])
550 dev[0].request("SET max_peer_links 99")
552 def test_wpas_mesh_open_5ghz(dev, apdev):
553 """wpa_supplicant open MESH network on 5 GHz band"""
555 _test_wpas_mesh_open_5ghz(dev, apdev)
557 subprocess.call(['iw', 'reg', 'set', '00'])
558 dev[0].flush_scan_cache()
559 dev[1].flush_scan_cache()
561 def _test_wpas_mesh_open_5ghz(dev, apdev):
562 check_mesh_support(dev[0])
563 subprocess.call(['iw', 'reg', 'set', 'US'])
566 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
568 raise Exception("No regdom change event")
569 if "alpha2=US" in ev:
571 add_open_mesh_network(dev[i], freq="5180")
573 # Check for mesh joined
574 check_mesh_group_added(dev[0])
575 check_mesh_group_added(dev[1])
577 # Check for peer connected
578 check_mesh_peer_connected(dev[0])
579 check_mesh_peer_connected(dev[1])
581 # Test connectivity 0->1 and 1->0
582 hwsim_utils.test_connectivity(dev[0], dev[1])
584 def test_wpas_mesh_open_vht_80p80(dev, apdev):
585 """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
587 _test_wpas_mesh_open_vht_80p80(dev, apdev)
589 subprocess.call(['iw', 'reg', 'set', '00'])
590 dev[0].flush_scan_cache()
591 dev[1].flush_scan_cache()
593 def _test_wpas_mesh_open_vht_80p80(dev, apdev):
594 check_mesh_support(dev[0])
595 subprocess.call(['iw', 'reg', 'set', 'US'])
598 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
600 raise Exception("No regdom change event")
601 if "alpha2=US" in ev:
603 add_open_mesh_network(dev[i], freq="5180", chwidth=3)
605 # Check for mesh joined
606 check_mesh_group_added(dev[0])
607 check_mesh_group_added(dev[1])
609 # Check for peer connected
610 check_mesh_peer_connected(dev[0])
611 check_mesh_peer_connected(dev[1])
613 # Test connectivity 0->1 and 1->0
614 hwsim_utils.test_connectivity(dev[0], dev[1])
616 sig = dev[0].request("SIGNAL_POLL").splitlines()
617 if "WIDTH=80+80 MHz" not in sig:
618 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
619 if "CENTER_FRQ1=5210" not in sig:
620 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
621 if "CENTER_FRQ2=5775" not in sig:
622 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
624 sig = dev[1].request("SIGNAL_POLL").splitlines()
625 if "WIDTH=80+80 MHz" not in sig:
626 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
627 if "CENTER_FRQ1=5210" not in sig:
628 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
629 if "CENTER_FRQ2=5775" not in sig:
630 raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig))
632 def test_mesh_open_vht_160(dev, apdev):
633 """Open mesh network on VHT 160 MHz channel"""
635 _test_mesh_open_vht_160(dev, apdev)
637 subprocess.call(['iw', 'reg', 'set', '00'])
638 dev[0].flush_scan_cache()
639 dev[1].flush_scan_cache()
641 def _test_mesh_open_vht_160(dev, apdev):
642 check_mesh_support(dev[0])
643 subprocess.call(['iw', 'reg', 'set', 'ZA'])
646 ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
648 raise Exception("No regdom change event")
649 if "alpha2=ZA" in ev:
652 cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
653 reg = cmd.stdout.read()
654 if "@ 160)" not in reg:
655 raise HwsimSkip("160 MHz channel not supported in regulatory information")
657 add_open_mesh_network(dev[i], freq="5520", chwidth=2)
659 # Check for mesh joined
660 check_mesh_group_added(dev[0])
661 check_mesh_group_added(dev[1])
663 # Check for peer connected
664 check_mesh_peer_connected(dev[0])
665 check_mesh_peer_connected(dev[1])
667 # Test connectivity 0->1 and 1->0
668 hwsim_utils.test_connectivity(dev[0], dev[1])
670 sig = dev[0].request("SIGNAL_POLL").splitlines()
671 if "WIDTH=160 MHz" not in sig:
672 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
673 if "FREQUENCY=5520" not in sig:
674 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
676 sig = dev[1].request("SIGNAL_POLL").splitlines()
677 if "WIDTH=160 MHz" not in sig:
678 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
679 if "FREQUENCY=5520" not in sig:
680 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
682 def test_wpas_mesh_password_mismatch(dev, apdev):
683 """Mesh network and one device with mismatching password"""
684 check_mesh_support(dev[0], secure=True)
685 dev[0].request("SET sae_groups ")
686 id = add_mesh_secure_net(dev[0])
687 dev[0].mesh_group_add(id)
689 dev[1].request("SET sae_groups ")
690 id = add_mesh_secure_net(dev[1])
691 dev[1].mesh_group_add(id)
693 dev[2].request("SET sae_groups ")
694 id = add_mesh_secure_net(dev[2])
695 dev[2].set_network_quoted(id, "psk", "wrong password")
696 dev[2].mesh_group_add(id)
698 # The two peers with matching password need to be able to connect
699 check_mesh_group_added(dev[0])
700 check_mesh_group_added(dev[1])
701 check_mesh_peer_connected(dev[0])
702 check_mesh_peer_connected(dev[1])
704 ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
706 raise Exception("dev2 did not report auth failure (1)")
707 ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
709 raise Exception("dev2 did not report auth failure (2)")
712 ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
714 logger.info("dev0 did not report auth failure")
716 if "addr=" + dev[2].own_addr() not in ev:
717 raise Exception("Unexpected peer address in dev0 event: " + ev)
720 ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
722 logger.info("dev1 did not report auth failure")
724 if "addr=" + dev[2].own_addr() not in ev:
725 raise Exception("Unexpected peer address in dev1 event: " + ev)
728 hwsim_utils.test_connectivity(dev[0], dev[1])
732 hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1)
733 raise Exception("Data connectivity test passed unexpectedly")
735 if "data delivery failed" not in str(e):
739 raise Exception("Neither dev0 nor dev1 reported auth failure")
741 def test_wpas_mesh_password_mismatch_retry(dev, apdev, params):
742 """Mesh password mismatch and retry [long]"""
743 if not params['long']:
744 raise HwsimSkip("Skip test case with long duration due to --long not specified")
745 check_mesh_support(dev[0], secure=True)
746 dev[0].request("SET sae_groups ")
747 id = add_mesh_secure_net(dev[0])
748 dev[0].mesh_group_add(id)
750 dev[1].request("SET sae_groups ")
751 id = add_mesh_secure_net(dev[1])
752 dev[1].set_network_quoted(id, "psk", "wrong password")
753 dev[1].mesh_group_add(id)
755 # Check for mesh joined
756 check_mesh_group_added(dev[0])
757 check_mesh_group_added(dev[1])
760 ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
762 raise Exception("dev0 did not report auth failure (%d)" % i)
763 ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
765 raise Exception("dev1 did not report auth failure (%d)" % i)
767 ev = dev[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
769 raise Exception("dev0 did not report auth blocked")
770 ev = dev[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
772 raise Exception("dev1 did not report auth blocked")
774 def test_mesh_wpa_auth_init_oom(dev, apdev):
775 """Secure mesh network setup failing due to wpa_init() OOM"""
776 check_mesh_support(dev[0], secure=True)
777 dev[0].request("SET sae_groups ")
778 with alloc_fail(dev[0], 1, "wpa_init"):
779 id = add_mesh_secure_net(dev[0])
780 dev[0].mesh_group_add(id)
781 ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.2)
783 raise Exception("Unexpected mesh group start during OOM")
785 def test_mesh_wpa_init_fail(dev, apdev):
786 """Secure mesh network setup local failure"""
787 check_mesh_support(dev[0], secure=True)
788 dev[0].request("SET sae_groups ")
790 with fail_test(dev[0], 1, "os_get_random;=__mesh_rsn_auth_init"):
791 id = add_mesh_secure_net(dev[0])
792 dev[0].mesh_group_add(id)
793 wait_fail_trigger(dev[0], "GET_FAIL")
795 with alloc_fail(dev[0], 1, "mesh_rsn_auth_init"):
796 id = add_mesh_secure_net(dev[0])
797 dev[0].mesh_group_add(id)
798 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
800 def test_wpas_mesh_reconnect(dev, apdev):
801 """Secure mesh network plink counting during reconnection"""
802 check_mesh_support(dev[0])
804 _test_wpas_mesh_reconnect(dev)
806 dev[0].request("SET max_peer_links 99")
808 def _test_wpas_mesh_reconnect(dev):
809 dev[0].request("SET max_peer_links 2")
810 dev[0].request("SET sae_groups ")
811 id = add_mesh_secure_net(dev[0])
812 dev[0].set_network(id, "beacon_int", "100")
813 dev[0].mesh_group_add(id)
814 dev[1].request("SET sae_groups ")
815 id = add_mesh_secure_net(dev[1])
816 dev[1].mesh_group_add(id)
817 check_mesh_group_added(dev[0])
818 check_mesh_group_added(dev[1])
819 check_mesh_peer_connected(dev[0])
820 check_mesh_peer_connected(dev[1])
823 # Drop incoming management frames to avoid handling link close
824 dev[0].request("SET ext_mgmt_frame_handling 1")
825 dev[1].mesh_group_remove()
826 check_mesh_group_removed(dev[1])
827 dev[1].request("FLUSH")
828 dev[0].request("SET ext_mgmt_frame_handling 0")
829 id = add_mesh_secure_net(dev[1])
830 dev[1].mesh_group_add(id)
831 check_mesh_group_added(dev[1])
832 check_mesh_peer_connected(dev[1])
833 dev[0].dump_monitor()
834 dev[1].dump_monitor()
836 def test_wpas_mesh_gate_forwarding(dev, apdev, p):
837 """Mesh forwards traffic to unknown sta to mesh gates"""
838 addr0 = dev[0].own_addr()
839 addr1 = dev[1].own_addr()
840 addr2 = dev[2].own_addr()
841 external_sta = '02:11:22:33:44:55'
843 # start 3 node connected mesh
844 check_mesh_support(dev[0])
846 add_open_mesh_network(dev[i])
847 check_mesh_group_added(dev[i])
849 check_mesh_peer_connected(dev[i])
851 hwsim_utils.test_connectivity(dev[0], dev[1])
852 hwsim_utils.test_connectivity(dev[1], dev[2])
853 hwsim_utils.test_connectivity(dev[0], dev[2])
855 # dev0 and dev1 are mesh gates
856 subprocess.call(['iw', 'dev', dev[0].ifname, 'set', 'mesh_param',
857 'mesh_gate_announcements=1'])
858 subprocess.call(['iw', 'dev', dev[1].ifname, 'set', 'mesh_param',
859 'mesh_gate_announcements=1'])
861 # wait for gate announcement frames
864 # data frame from dev2 -> external sta should be sent to both gates
865 dev[2].request("DATA_TEST_CONFIG 1")
866 dev[2].request("DATA_TEST_TX {} {} 0".format(external_sta, addr2))
867 dev[2].request("DATA_TEST_CONFIG 0")
869 capfile = os.path.join(p['logdir'], "hwsim0.pcapng")
870 filt = "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2,
873 da = run_tshark(capfile, filt, [ "wlan.da" ])
874 if addr0 in da and addr1 in da:
875 logger.debug("Frames seen in tshark iteration %d" % i)
880 raise Exception("Frame to gate %s not observed" % addr0)
882 raise Exception("Frame to gate %s not observed" % addr1)
884 def test_wpas_mesh_pmksa_caching(dev, apdev):
885 """Secure mesh network and PMKSA caching"""
886 check_mesh_support(dev[0], secure=True)
887 dev[0].request("SET sae_groups ")
888 id = add_mesh_secure_net(dev[0])
889 dev[0].mesh_group_add(id)
891 dev[1].request("SET sae_groups ")
892 id = add_mesh_secure_net(dev[1])
893 dev[1].mesh_group_add(id)
895 # Check for mesh joined
896 check_mesh_group_added(dev[0])
897 check_mesh_group_added(dev[1])
899 # Check for peer connected
900 check_mesh_peer_connected(dev[0])
901 check_mesh_peer_connected(dev[1])
903 addr0 = dev[0].own_addr()
904 addr1 = dev[1].own_addr()
905 pmksa0 = dev[0].get_pmksa(addr1)
906 pmksa1 = dev[1].get_pmksa(addr0)
907 if pmksa0 is None or pmksa1 is None:
908 raise Exception("No PMKSA cache entry created")
909 if pmksa0['pmkid'] != pmksa1['pmkid']:
910 raise Exception("PMKID mismatch in PMKSA cache entries")
912 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
913 raise Exception("Failed to remove peer")
914 pmksa0b = dev[0].get_pmksa(addr1)
916 raise Exception("PMKSA cache entry not maintained")
919 if "FAIL" not in dev[0].request("MESH_PEER_ADD " + addr1):
920 raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
922 def test_wpas_mesh_pmksa_caching2(dev, apdev):
923 """Secure mesh network and PMKSA caching with no_auto_peer=1"""
924 check_mesh_support(dev[0], secure=True)
925 addr0 = dev[0].own_addr()
926 addr1 = dev[1].own_addr()
927 dev[0].request("SET sae_groups ")
928 id = add_mesh_secure_net(dev[0])
929 dev[0].set_network(id, "no_auto_peer", "1")
930 dev[0].mesh_group_add(id)
932 dev[1].request("SET sae_groups ")
933 id = add_mesh_secure_net(dev[1])
934 dev[1].set_network(id, "no_auto_peer", "1")
935 dev[1].mesh_group_add(id)
937 # Check for mesh joined
938 check_mesh_group_added(dev[0])
939 check_mesh_group_added(dev[1])
941 # Check for peer connected
942 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
944 raise Exception("Missing no-initiate message")
945 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
946 raise Exception("MESH_PEER_ADD failed")
947 check_mesh_peer_connected(dev[0])
948 check_mesh_peer_connected(dev[1])
950 pmksa0 = dev[0].get_pmksa(addr1)
951 pmksa1 = dev[1].get_pmksa(addr0)
952 if pmksa0 is None or pmksa1 is None:
953 raise Exception("No PMKSA cache entry created")
954 if pmksa0['pmkid'] != pmksa1['pmkid']:
955 raise Exception("PMKID mismatch in PMKSA cache entries")
957 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
958 raise Exception("Failed to remove peer")
959 pmksa0b = dev[0].get_pmksa(addr1)
961 raise Exception("PMKSA cache entry not maintained")
963 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
965 raise Exception("Missing no-initiate message (2)")
966 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
967 raise Exception("MESH_PEER_ADD failed (2)")
968 check_mesh_peer_connected(dev[0])
969 check_mesh_peer_connected(dev[1])
971 pmksa0c = dev[0].get_pmksa(addr1)
972 pmksa1c = dev[1].get_pmksa(addr0)
973 if pmksa0c is None or pmksa1c is None:
974 raise Exception("No PMKSA cache entry created (2)")
975 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
976 raise Exception("PMKID mismatch in PMKSA cache entries")
977 if pmksa0['pmkid'] != pmksa0c['pmkid']:
978 raise Exception("PMKID changed")
980 hwsim_utils.test_connectivity(dev[0], dev[1])
982 def test_wpas_mesh_pmksa_caching_no_match(dev, apdev):
983 """Secure mesh network and PMKSA caching with no PMKID match"""
984 check_mesh_support(dev[0], secure=True)
985 addr0 = dev[0].own_addr()
986 addr1 = dev[1].own_addr()
987 dev[0].request("SET sae_groups ")
988 id = add_mesh_secure_net(dev[0])
989 dev[0].set_network(id, "no_auto_peer", "1")
990 dev[0].mesh_group_add(id)
992 dev[1].request("SET sae_groups ")
993 id = add_mesh_secure_net(dev[1])
994 dev[1].set_network(id, "no_auto_peer", "1")
995 dev[1].mesh_group_add(id)
997 # Check for mesh joined
998 check_mesh_group_added(dev[0])
999 check_mesh_group_added(dev[1])
1001 # Check for peer connected
1002 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1004 raise Exception("Missing no-initiate message")
1005 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1006 raise Exception("MESH_PEER_ADD failed")
1007 check_mesh_peer_connected(dev[0])
1008 check_mesh_peer_connected(dev[1])
1010 pmksa0 = dev[0].get_pmksa(addr1)
1011 pmksa1 = dev[1].get_pmksa(addr0)
1012 if pmksa0 is None or pmksa1 is None:
1013 raise Exception("No PMKSA cache entry created")
1014 if pmksa0['pmkid'] != pmksa1['pmkid']:
1015 raise Exception("PMKID mismatch in PMKSA cache entries")
1017 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
1018 raise Exception("Failed to remove peer")
1020 if "OK" not in dev[1].request("PMKSA_FLUSH"):
1021 raise Exception("Failed to flush PMKSA cache")
1023 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1025 raise Exception("Missing no-initiate message (2)")
1026 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1027 raise Exception("MESH_PEER_ADD failed (2)")
1028 check_mesh_peer_connected(dev[0])
1029 check_mesh_peer_connected(dev[1])
1031 pmksa0c = dev[0].get_pmksa(addr1)
1032 pmksa1c = dev[1].get_pmksa(addr0)
1033 if pmksa0c is None or pmksa1c is None:
1034 raise Exception("No PMKSA cache entry created (2)")
1035 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
1036 raise Exception("PMKID mismatch in PMKSA cache entries")
1037 if pmksa0['pmkid'] == pmksa0c['pmkid']:
1038 raise Exception("PMKID did not change")
1040 hwsim_utils.test_connectivity(dev[0], dev[1])
1042 def test_mesh_oom(dev, apdev):
1043 """Mesh network setup failing due to OOM"""
1044 check_mesh_support(dev[0], secure=True)
1045 dev[0].request("SET sae_groups ")
1047 with alloc_fail(dev[0], 1, "mesh_config_create"):
1048 add_open_mesh_network(dev[0])
1049 ev = dev[0].wait_event(["Failed to init mesh"])
1051 raise Exception("Init failure not reported")
1053 with alloc_fail(dev[0], 4, "=wpa_supplicant_mesh_init"):
1054 add_open_mesh_network(dev[0], basic_rates="60 120 240")
1055 ev = dev[0].wait_event(["Failed to init mesh"])
1057 raise Exception("Init failure not reported")
1059 for i in range(1, 66):
1060 dev[0].dump_monitor()
1061 logger.info("Test instance %d" % i)
1063 with alloc_fail(dev[0], i, "wpa_supplicant_mesh_init"):
1064 add_open_mesh_network(dev[0])
1065 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
1066 ev = dev[0].wait_event(["Failed to init mesh",
1067 "MESH-GROUP-STARTED"])
1069 raise Exception("Init failure not reported")
1070 except Exception, e:
1073 logger.info("Ignore no-oom for i=%d" % i)
1075 with alloc_fail(dev[0], 5, "=wpa_supplicant_mesh_init"):
1076 id = add_mesh_secure_net(dev[0])
1077 dev[0].mesh_group_add(id)
1078 ev = dev[0].wait_event(["Failed to init mesh"])
1080 raise Exception("Init failure not reported")
1082 def test_mesh_add_interface_oom(dev):
1083 """wpa_supplicant mesh with dynamic interface addition failing"""
1084 check_mesh_support(dev[0])
1085 for i in range(1, 3):
1088 with alloc_fail(dev[0], i, "wpas_mesh_add_interface"):
1089 mesh = dev[0].request("MESH_INTERFACE_ADD").strip()
1091 if mesh and mesh != "FAIL":
1092 dev[0].request("MESH_GROUP_REMOVE " + mesh)
1094 def test_mesh_scan_oom(dev):
1095 """wpa_supplicant mesh scan results and OOM"""
1096 check_mesh_support(dev[0])
1097 add_open_mesh_network(dev[0])
1098 check_mesh_group_added(dev[0])
1100 dev[1].scan(freq="2412")
1101 res = dev[1].request("SCAN_RESULTS")
1104 for r in res.splitlines():
1107 bssid = r.split('\t')[0]
1109 bss = dev[1].get_bss(bssid)
1111 raise Exception("Could not get BSS entry for mesh")
1113 for i in range(1, 3):
1114 with alloc_fail(dev[1], i, "mesh_attr_text"):
1115 bss = dev[1].get_bss(bssid)
1117 raise Exception("Unexpected BSS result during OOM")
1119 def test_mesh_drv_fail(dev, apdev):
1120 """Mesh network setup failing due to driver command failure"""
1121 check_mesh_support(dev[0], secure=True)
1122 dev[0].request("SET sae_groups ")
1124 with fail_test(dev[0], 1, "nl80211_join_mesh"):
1125 add_open_mesh_network(dev[0])
1126 ev = dev[0].wait_event(["mesh join error"])
1128 raise Exception("Join failure not reported")
1130 dev[0].dump_monitor()
1131 with fail_test(dev[0], 1, "wpa_driver_nl80211_if_add"):
1132 if "FAIL" not in dev[0].request("MESH_INTERFACE_ADD").strip():
1133 raise Exception("Interface added unexpectedly")
1135 dev[0].dump_monitor()
1136 with fail_test(dev[0], 1, "wpa_driver_nl80211_init_mesh"):
1137 add_open_mesh_network(dev[0])
1138 ev = dev[0].wait_event(["Could not join mesh"])
1140 raise Exception("Join failure not reported")
1142 def test_mesh_sae_groups_invalid(dev, apdev):
1143 """Mesh with invalid SAE group configuration"""
1144 check_mesh_support(dev[0], secure=True)
1146 dev[0].request("SET sae_groups 25")
1147 id = add_mesh_secure_net(dev[0])
1148 dev[0].mesh_group_add(id)
1150 dev[1].request("SET sae_groups 123 122 121")
1151 id = add_mesh_secure_net(dev[1])
1152 dev[1].mesh_group_add(id)
1154 check_mesh_group_added(dev[0])
1155 check_mesh_group_added(dev[1])
1157 ev = dev[0].wait_event(["new peer notification"], timeout=10)
1159 raise Exception("dev[0] did not see peer")
1160 ev = dev[1].wait_event(["new peer notification"], timeout=10)
1162 raise Exception("dev[1] did not see peer")
1164 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
1166 raise Exception("Unexpected connection(0)")
1168 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
1170 raise Exception("Unexpected connection(1)")
1172 dev[0].request("SET sae_groups ")
1173 dev[1].request("SET sae_groups ")
1175 def test_mesh_sae_failure(dev, apdev):
1176 """Mesh and local SAE failures"""
1177 check_mesh_support(dev[0], secure=True)
1179 dev[0].request("SET sae_groups ")
1180 dev[1].request("SET sae_groups ")
1182 funcs = [ (1, "=mesh_rsn_auth_sae_sta", True),
1183 (1, "mesh_rsn_build_sae_commit;mesh_rsn_auth_sae_sta", False),
1184 (1, "auth_sae_init_committed;mesh_rsn_auth_sae_sta", True),
1185 (1, "=mesh_rsn_protect_frame", True),
1186 (2, "=mesh_rsn_protect_frame", True),
1187 (1, "aes_siv_encrypt;mesh_rsn_protect_frame", True),
1188 (1, "=mesh_rsn_process_ampe", True),
1189 (1, "aes_siv_decrypt;mesh_rsn_process_ampe", True) ]
1190 for count, func, success in funcs:
1191 id = add_mesh_secure_net(dev[0])
1192 dev[0].mesh_group_add(id)
1194 with alloc_fail(dev[1], count, func):
1195 id = add_mesh_secure_net(dev[1])
1196 dev[1].mesh_group_add(id)
1197 check_mesh_group_added(dev[0])
1198 check_mesh_group_added(dev[1])
1200 # retry is expected to work
1201 check_mesh_peer_connected(dev[0])
1202 check_mesh_peer_connected(dev[1])
1204 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1205 dev[0].mesh_group_remove()
1206 dev[1].mesh_group_remove()
1207 check_mesh_group_removed(dev[0])
1208 check_mesh_group_removed(dev[1])
1210 def test_mesh_failure(dev, apdev):
1211 """Mesh and local failures"""
1212 check_mesh_support(dev[0])
1214 funcs = [ (1, "ap_sta_add;mesh_mpm_add_peer", True),
1215 (1, "wpabuf_alloc;mesh_mpm_send_plink_action", True) ]
1216 for count, func, success in funcs:
1217 add_open_mesh_network(dev[0])
1219 with alloc_fail(dev[1], count, func):
1220 add_open_mesh_network(dev[1])
1221 check_mesh_group_added(dev[0])
1222 check_mesh_group_added(dev[1])
1224 # retry is expected to work
1225 check_mesh_peer_connected(dev[0])
1226 check_mesh_peer_connected(dev[1])
1228 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1229 dev[0].mesh_group_remove()
1230 dev[1].mesh_group_remove()
1231 check_mesh_group_removed(dev[0])
1232 check_mesh_group_removed(dev[1])
1234 funcs = [ (1, "mesh_mpm_init_link", True) ]
1235 for count, func, success in funcs:
1236 add_open_mesh_network(dev[0])
1238 with fail_test(dev[1], count, func):
1239 add_open_mesh_network(dev[1])
1240 check_mesh_group_added(dev[0])
1241 check_mesh_group_added(dev[1])
1243 # retry is expected to work
1244 check_mesh_peer_connected(dev[0])
1245 check_mesh_peer_connected(dev[1])
1247 wait_fail_trigger(dev[1], "GET_FAIL")
1248 dev[0].mesh_group_remove()
1249 dev[1].mesh_group_remove()
1250 check_mesh_group_removed(dev[0])
1251 check_mesh_group_removed(dev[1])
1253 def test_mesh_invalid_frequency(dev, apdev):
1254 """Mesh and invalid frequency configuration"""
1255 check_mesh_support(dev[0])
1256 add_open_mesh_network(dev[0], freq=None)
1257 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1258 "Could not join mesh"])
1259 if ev is None or "Could not join mesh" not in ev:
1260 raise Exception("Mesh join failure not reported")
1261 dev[0].request("REMOVE_NETWORK all")
1263 add_open_mesh_network(dev[0], freq="2413")
1264 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1265 "Could not join mesh"])
1266 if ev is None or "Could not join mesh" not in ev:
1267 raise Exception("Mesh join failure not reported")
1269 def test_mesh_default_beacon_int(dev, apdev):
1270 """Mesh and default beacon interval"""
1271 check_mesh_support(dev[0])
1273 dev[0].request("SET beacon_int 200")
1274 add_open_mesh_network(dev[0])
1275 check_mesh_group_added(dev[0])
1277 dev[0].request("SET beacon_int 0")