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 dev[0].dump_monitor()
797 with alloc_fail(dev[0], 1, "mesh_rsn_auth_init"):
798 id = add_mesh_secure_net(dev[0])
799 dev[0].mesh_group_add(id)
800 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
802 dev[0].dump_monitor()
803 with fail_test(dev[0], 1, "os_get_random;mesh_rsn_init_ampe_sta"):
804 id = add_mesh_secure_net(dev[0])
805 dev[0].mesh_group_add(id)
806 dev[1].request("SET sae_groups ")
807 id = add_mesh_secure_net(dev[1])
808 dev[1].mesh_group_add(id)
809 wait_fail_trigger(dev[0], "GET_FAIL")
811 def test_wpas_mesh_reconnect(dev, apdev):
812 """Secure mesh network plink counting during reconnection"""
813 check_mesh_support(dev[0])
815 _test_wpas_mesh_reconnect(dev)
817 dev[0].request("SET max_peer_links 99")
819 def _test_wpas_mesh_reconnect(dev):
820 dev[0].request("SET max_peer_links 2")
821 dev[0].request("SET sae_groups ")
822 id = add_mesh_secure_net(dev[0])
823 dev[0].set_network(id, "beacon_int", "100")
824 dev[0].mesh_group_add(id)
825 dev[1].request("SET sae_groups ")
826 id = add_mesh_secure_net(dev[1])
827 dev[1].mesh_group_add(id)
828 check_mesh_group_added(dev[0])
829 check_mesh_group_added(dev[1])
830 check_mesh_peer_connected(dev[0])
831 check_mesh_peer_connected(dev[1])
834 # Drop incoming management frames to avoid handling link close
835 dev[0].request("SET ext_mgmt_frame_handling 1")
836 dev[1].mesh_group_remove()
837 check_mesh_group_removed(dev[1])
838 dev[1].request("FLUSH")
839 dev[0].request("SET ext_mgmt_frame_handling 0")
840 id = add_mesh_secure_net(dev[1])
841 dev[1].mesh_group_add(id)
842 check_mesh_group_added(dev[1])
843 check_mesh_peer_connected(dev[1])
844 dev[0].dump_monitor()
845 dev[1].dump_monitor()
847 def test_wpas_mesh_gate_forwarding(dev, apdev, p):
848 """Mesh forwards traffic to unknown sta to mesh gates"""
849 addr0 = dev[0].own_addr()
850 addr1 = dev[1].own_addr()
851 addr2 = dev[2].own_addr()
852 external_sta = '02:11:22:33:44:55'
854 # start 3 node connected mesh
855 check_mesh_support(dev[0])
857 add_open_mesh_network(dev[i])
858 check_mesh_group_added(dev[i])
860 check_mesh_peer_connected(dev[i])
862 hwsim_utils.test_connectivity(dev[0], dev[1])
863 hwsim_utils.test_connectivity(dev[1], dev[2])
864 hwsim_utils.test_connectivity(dev[0], dev[2])
866 # dev0 and dev1 are mesh gates
867 subprocess.call(['iw', 'dev', dev[0].ifname, 'set', 'mesh_param',
868 'mesh_gate_announcements=1'])
869 subprocess.call(['iw', 'dev', dev[1].ifname, 'set', 'mesh_param',
870 'mesh_gate_announcements=1'])
872 # wait for gate announcement frames
875 # data frame from dev2 -> external sta should be sent to both gates
876 dev[2].request("DATA_TEST_CONFIG 1")
877 dev[2].request("DATA_TEST_TX {} {} 0".format(external_sta, addr2))
878 dev[2].request("DATA_TEST_CONFIG 0")
880 capfile = os.path.join(p['logdir'], "hwsim0.pcapng")
881 filt = "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2,
884 da = run_tshark(capfile, filt, [ "wlan.da" ])
885 if addr0 in da and addr1 in da:
886 logger.debug("Frames seen in tshark iteration %d" % i)
891 raise Exception("Frame to gate %s not observed" % addr0)
893 raise Exception("Frame to gate %s not observed" % addr1)
895 def test_wpas_mesh_pmksa_caching(dev, apdev):
896 """Secure mesh network and PMKSA caching"""
897 check_mesh_support(dev[0], secure=True)
898 dev[0].request("SET sae_groups ")
899 id = add_mesh_secure_net(dev[0])
900 dev[0].mesh_group_add(id)
902 dev[1].request("SET sae_groups ")
903 id = add_mesh_secure_net(dev[1])
904 dev[1].mesh_group_add(id)
906 # Check for mesh joined
907 check_mesh_group_added(dev[0])
908 check_mesh_group_added(dev[1])
910 # Check for peer connected
911 check_mesh_peer_connected(dev[0])
912 check_mesh_peer_connected(dev[1])
914 addr0 = dev[0].own_addr()
915 addr1 = dev[1].own_addr()
916 pmksa0 = dev[0].get_pmksa(addr1)
917 pmksa1 = dev[1].get_pmksa(addr0)
918 if pmksa0 is None or pmksa1 is None:
919 raise Exception("No PMKSA cache entry created")
920 if pmksa0['pmkid'] != pmksa1['pmkid']:
921 raise Exception("PMKID mismatch in PMKSA cache entries")
923 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
924 raise Exception("Failed to remove peer")
925 pmksa0b = dev[0].get_pmksa(addr1)
927 raise Exception("PMKSA cache entry not maintained")
930 if "FAIL" not in dev[0].request("MESH_PEER_ADD " + addr1):
931 raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
933 def test_wpas_mesh_pmksa_caching2(dev, apdev):
934 """Secure mesh network and PMKSA caching with no_auto_peer=1"""
935 check_mesh_support(dev[0], secure=True)
936 addr0 = dev[0].own_addr()
937 addr1 = dev[1].own_addr()
938 dev[0].request("SET sae_groups ")
939 id = add_mesh_secure_net(dev[0])
940 dev[0].set_network(id, "no_auto_peer", "1")
941 dev[0].mesh_group_add(id)
943 dev[1].request("SET sae_groups ")
944 id = add_mesh_secure_net(dev[1])
945 dev[1].set_network(id, "no_auto_peer", "1")
946 dev[1].mesh_group_add(id)
948 # Check for mesh joined
949 check_mesh_group_added(dev[0])
950 check_mesh_group_added(dev[1])
952 # Check for peer connected
953 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
955 raise Exception("Missing no-initiate message")
956 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
957 raise Exception("MESH_PEER_ADD failed")
958 check_mesh_peer_connected(dev[0])
959 check_mesh_peer_connected(dev[1])
961 pmksa0 = dev[0].get_pmksa(addr1)
962 pmksa1 = dev[1].get_pmksa(addr0)
963 if pmksa0 is None or pmksa1 is None:
964 raise Exception("No PMKSA cache entry created")
965 if pmksa0['pmkid'] != pmksa1['pmkid']:
966 raise Exception("PMKID mismatch in PMKSA cache entries")
968 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
969 raise Exception("Failed to remove peer")
970 pmksa0b = dev[0].get_pmksa(addr1)
972 raise Exception("PMKSA cache entry not maintained")
974 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
976 raise Exception("Missing no-initiate message (2)")
977 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
978 raise Exception("MESH_PEER_ADD failed (2)")
979 check_mesh_peer_connected(dev[0])
980 check_mesh_peer_connected(dev[1])
982 pmksa0c = dev[0].get_pmksa(addr1)
983 pmksa1c = dev[1].get_pmksa(addr0)
984 if pmksa0c is None or pmksa1c is None:
985 raise Exception("No PMKSA cache entry created (2)")
986 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
987 raise Exception("PMKID mismatch in PMKSA cache entries")
988 if pmksa0['pmkid'] != pmksa0c['pmkid']:
989 raise Exception("PMKID changed")
991 hwsim_utils.test_connectivity(dev[0], dev[1])
993 def test_wpas_mesh_pmksa_caching_no_match(dev, apdev):
994 """Secure mesh network and PMKSA caching with no PMKID match"""
995 check_mesh_support(dev[0], secure=True)
996 addr0 = dev[0].own_addr()
997 addr1 = dev[1].own_addr()
998 dev[0].request("SET sae_groups ")
999 id = add_mesh_secure_net(dev[0])
1000 dev[0].set_network(id, "no_auto_peer", "1")
1001 dev[0].mesh_group_add(id)
1003 dev[1].request("SET sae_groups ")
1004 id = add_mesh_secure_net(dev[1])
1005 dev[1].set_network(id, "no_auto_peer", "1")
1006 dev[1].mesh_group_add(id)
1008 # Check for mesh joined
1009 check_mesh_group_added(dev[0])
1010 check_mesh_group_added(dev[1])
1012 # Check for peer connected
1013 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1015 raise Exception("Missing no-initiate message")
1016 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1017 raise Exception("MESH_PEER_ADD failed")
1018 check_mesh_peer_connected(dev[0])
1019 check_mesh_peer_connected(dev[1])
1021 pmksa0 = dev[0].get_pmksa(addr1)
1022 pmksa1 = dev[1].get_pmksa(addr0)
1023 if pmksa0 is None or pmksa1 is None:
1024 raise Exception("No PMKSA cache entry created")
1025 if pmksa0['pmkid'] != pmksa1['pmkid']:
1026 raise Exception("PMKID mismatch in PMKSA cache entries")
1028 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
1029 raise Exception("Failed to remove peer")
1031 if "OK" not in dev[1].request("PMKSA_FLUSH"):
1032 raise Exception("Failed to flush PMKSA cache")
1034 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1036 raise Exception("Missing no-initiate message (2)")
1037 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1038 raise Exception("MESH_PEER_ADD failed (2)")
1039 check_mesh_peer_connected(dev[0])
1040 check_mesh_peer_connected(dev[1])
1042 pmksa0c = dev[0].get_pmksa(addr1)
1043 pmksa1c = dev[1].get_pmksa(addr0)
1044 if pmksa0c is None or pmksa1c is None:
1045 raise Exception("No PMKSA cache entry created (2)")
1046 if pmksa0c['pmkid'] != pmksa1c['pmkid']:
1047 raise Exception("PMKID mismatch in PMKSA cache entries")
1048 if pmksa0['pmkid'] == pmksa0c['pmkid']:
1049 raise Exception("PMKID did not change")
1051 hwsim_utils.test_connectivity(dev[0], dev[1])
1053 def test_mesh_pmksa_caching_oom(dev, apdev):
1054 """Secure mesh network and PMKSA caching failing due to OOM"""
1055 check_mesh_support(dev[0], secure=True)
1056 addr0 = dev[0].own_addr()
1057 addr1 = dev[1].own_addr()
1058 dev[0].request("SET sae_groups ")
1059 id = add_mesh_secure_net(dev[0])
1060 dev[0].set_network(id, "no_auto_peer", "1")
1061 dev[0].mesh_group_add(id)
1063 dev[1].request("SET sae_groups ")
1064 id = add_mesh_secure_net(dev[1])
1065 dev[1].set_network(id, "no_auto_peer", "1")
1066 dev[1].mesh_group_add(id)
1068 # Check for mesh joined
1069 check_mesh_group_added(dev[0])
1070 check_mesh_group_added(dev[1])
1072 # Check for peer connected
1073 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1075 raise Exception("Missing no-initiate message")
1076 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1077 raise Exception("MESH_PEER_ADD failed")
1078 check_mesh_peer_connected(dev[0])
1079 check_mesh_peer_connected(dev[1])
1081 if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
1082 raise Exception("Failed to remove peer")
1083 pmksa0b = dev[0].get_pmksa(addr1)
1085 raise Exception("PMKSA cache entry not maintained")
1087 ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
1089 raise Exception("Missing no-initiate message (2)")
1091 with alloc_fail(dev[0], 1, "wpa_auth_sta_init;mesh_rsn_auth_sae_sta"):
1092 if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
1093 raise Exception("MESH_PEER_ADD failed (2)")
1094 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
1096 def test_mesh_oom(dev, apdev):
1097 """Mesh network setup failing due to OOM"""
1098 check_mesh_support(dev[0], secure=True)
1099 dev[0].request("SET sae_groups ")
1101 with alloc_fail(dev[0], 1, "mesh_config_create"):
1102 add_open_mesh_network(dev[0])
1103 ev = dev[0].wait_event(["Failed to init mesh"])
1105 raise Exception("Init failure not reported")
1107 with alloc_fail(dev[0], 4, "=wpa_supplicant_mesh_init"):
1108 add_open_mesh_network(dev[0], basic_rates="60 120 240")
1109 ev = dev[0].wait_event(["Failed to init mesh"])
1111 raise Exception("Init failure not reported")
1113 for i in range(1, 66):
1114 dev[0].dump_monitor()
1115 logger.info("Test instance %d" % i)
1117 with alloc_fail(dev[0], i, "wpa_supplicant_mesh_init"):
1118 add_open_mesh_network(dev[0])
1119 wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
1120 ev = dev[0].wait_event(["Failed to init mesh",
1121 "MESH-GROUP-STARTED"])
1123 raise Exception("Init failure not reported")
1124 except Exception, e:
1127 logger.info("Ignore no-oom for i=%d" % i)
1129 with alloc_fail(dev[0], 5, "=wpa_supplicant_mesh_init"):
1130 id = add_mesh_secure_net(dev[0])
1131 dev[0].mesh_group_add(id)
1132 ev = dev[0].wait_event(["Failed to init mesh"])
1134 raise Exception("Init failure not reported")
1136 def test_mesh_add_interface_oom(dev):
1137 """wpa_supplicant mesh with dynamic interface addition failing"""
1138 check_mesh_support(dev[0])
1139 for i in range(1, 3):
1142 with alloc_fail(dev[0], i, "wpas_mesh_add_interface"):
1143 mesh = dev[0].request("MESH_INTERFACE_ADD").strip()
1145 if mesh and mesh != "FAIL":
1146 dev[0].request("MESH_GROUP_REMOVE " + mesh)
1148 def test_mesh_scan_oom(dev):
1149 """wpa_supplicant mesh scan results and OOM"""
1150 check_mesh_support(dev[0])
1151 add_open_mesh_network(dev[0])
1152 check_mesh_group_added(dev[0])
1154 dev[1].scan(freq="2412")
1155 res = dev[1].request("SCAN_RESULTS")
1158 for r in res.splitlines():
1161 bssid = r.split('\t')[0]
1163 bss = dev[1].get_bss(bssid)
1165 raise Exception("Could not get BSS entry for mesh")
1167 for i in range(1, 3):
1168 with alloc_fail(dev[1], i, "mesh_attr_text"):
1169 bss = dev[1].get_bss(bssid)
1171 raise Exception("Unexpected BSS result during OOM")
1173 def test_mesh_drv_fail(dev, apdev):
1174 """Mesh network setup failing due to driver command failure"""
1175 check_mesh_support(dev[0], secure=True)
1176 dev[0].request("SET sae_groups ")
1178 with fail_test(dev[0], 1, "nl80211_join_mesh"):
1179 add_open_mesh_network(dev[0])
1180 ev = dev[0].wait_event(["mesh join error"])
1182 raise Exception("Join failure not reported")
1184 dev[0].dump_monitor()
1185 with fail_test(dev[0], 1, "wpa_driver_nl80211_if_add"):
1186 if "FAIL" not in dev[0].request("MESH_INTERFACE_ADD").strip():
1187 raise Exception("Interface added unexpectedly")
1189 dev[0].dump_monitor()
1190 with fail_test(dev[0], 1, "wpa_driver_nl80211_init_mesh"):
1191 add_open_mesh_network(dev[0])
1192 ev = dev[0].wait_event(["Could not join mesh"])
1194 raise Exception("Join failure not reported")
1196 def test_mesh_sae_groups_invalid(dev, apdev):
1197 """Mesh with invalid SAE group configuration"""
1198 check_mesh_support(dev[0], secure=True)
1200 dev[0].request("SET sae_groups 25")
1201 id = add_mesh_secure_net(dev[0])
1202 dev[0].mesh_group_add(id)
1204 dev[1].request("SET sae_groups 123 122 121")
1205 id = add_mesh_secure_net(dev[1])
1206 dev[1].mesh_group_add(id)
1208 check_mesh_group_added(dev[0])
1209 check_mesh_group_added(dev[1])
1211 ev = dev[0].wait_event(["new peer notification"], timeout=10)
1213 raise Exception("dev[0] did not see peer")
1214 ev = dev[1].wait_event(["new peer notification"], timeout=10)
1216 raise Exception("dev[1] did not see peer")
1218 ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
1220 raise Exception("Unexpected connection(0)")
1222 ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
1224 raise Exception("Unexpected connection(1)")
1226 dev[0].request("SET sae_groups ")
1227 dev[1].request("SET sae_groups ")
1229 def test_mesh_sae_failure(dev, apdev):
1230 """Mesh and local SAE failures"""
1231 check_mesh_support(dev[0], secure=True)
1233 dev[0].request("SET sae_groups ")
1234 dev[1].request("SET sae_groups ")
1236 funcs = [ (1, "=mesh_rsn_auth_sae_sta", True),
1237 (1, "mesh_rsn_build_sae_commit;mesh_rsn_auth_sae_sta", False),
1238 (1, "auth_sae_init_committed;mesh_rsn_auth_sae_sta", True),
1239 (1, "=mesh_rsn_protect_frame", True),
1240 (2, "=mesh_rsn_protect_frame", True),
1241 (1, "aes_siv_encrypt;mesh_rsn_protect_frame", True),
1242 (1, "=mesh_rsn_process_ampe", True),
1243 (1, "aes_siv_decrypt;mesh_rsn_process_ampe", True) ]
1244 for count, func, success in funcs:
1245 id = add_mesh_secure_net(dev[0])
1246 dev[0].mesh_group_add(id)
1248 with alloc_fail(dev[1], count, func):
1249 id = add_mesh_secure_net(dev[1])
1250 dev[1].mesh_group_add(id)
1251 check_mesh_group_added(dev[0])
1252 check_mesh_group_added(dev[1])
1254 # retry is expected to work
1255 check_mesh_peer_connected(dev[0])
1256 check_mesh_peer_connected(dev[1])
1258 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1259 dev[0].mesh_group_remove()
1260 dev[1].mesh_group_remove()
1261 check_mesh_group_removed(dev[0])
1262 check_mesh_group_removed(dev[1])
1264 def test_mesh_failure(dev, apdev):
1265 """Mesh and local failures"""
1266 check_mesh_support(dev[0])
1268 funcs = [ (1, "ap_sta_add;mesh_mpm_add_peer", True),
1269 (1, "wpabuf_alloc;mesh_mpm_send_plink_action", True) ]
1270 for count, func, success in funcs:
1271 add_open_mesh_network(dev[0])
1273 with alloc_fail(dev[1], count, func):
1274 add_open_mesh_network(dev[1])
1275 check_mesh_group_added(dev[0])
1276 check_mesh_group_added(dev[1])
1278 # retry is expected to work
1279 check_mesh_peer_connected(dev[0])
1280 check_mesh_peer_connected(dev[1])
1282 wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
1283 dev[0].mesh_group_remove()
1284 dev[1].mesh_group_remove()
1285 check_mesh_group_removed(dev[0])
1286 check_mesh_group_removed(dev[1])
1288 funcs = [ (1, "mesh_mpm_init_link", True) ]
1289 for count, func, success in funcs:
1290 add_open_mesh_network(dev[0])
1292 with fail_test(dev[1], count, func):
1293 add_open_mesh_network(dev[1])
1294 check_mesh_group_added(dev[0])
1295 check_mesh_group_added(dev[1])
1297 # retry is expected to work
1298 check_mesh_peer_connected(dev[0])
1299 check_mesh_peer_connected(dev[1])
1301 wait_fail_trigger(dev[1], "GET_FAIL")
1302 dev[0].mesh_group_remove()
1303 dev[1].mesh_group_remove()
1304 check_mesh_group_removed(dev[0])
1305 check_mesh_group_removed(dev[1])
1307 def test_mesh_invalid_frequency(dev, apdev):
1308 """Mesh and invalid frequency configuration"""
1309 check_mesh_support(dev[0])
1310 add_open_mesh_network(dev[0], freq=None)
1311 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1312 "Could not join mesh"])
1313 if ev is None or "Could not join mesh" not in ev:
1314 raise Exception("Mesh join failure not reported")
1315 dev[0].request("REMOVE_NETWORK all")
1317 add_open_mesh_network(dev[0], freq="2413")
1318 ev = dev[0].wait_event(["MESH-GROUP-STARTED",
1319 "Could not join mesh"])
1320 if ev is None or "Could not join mesh" not in ev:
1321 raise Exception("Mesh join failure not reported")
1323 def test_mesh_default_beacon_int(dev, apdev):
1324 """Mesh and default beacon interval"""
1325 check_mesh_support(dev[0])
1327 dev[0].request("SET beacon_int 200")
1328 add_open_mesh_network(dev[0])
1329 check_mesh_group_added(dev[0])
1331 dev[0].request("SET beacon_int 0")
1333 def test_mesh_scan_parse_error(dev, apdev):
1334 """Mesh scan element parse error"""
1335 check_mesh_support(dev[0])
1336 params = { "ssid": "open",
1337 "beacon_int": "2000" }
1338 hapd = hostapd.add_ap(apdev[0], params)
1339 bssid = apdev[0]['bssid']
1340 hapd.set('vendor_elements', 'dd0201')
1342 dev[0].scan(freq=2412)
1343 if bssid in dev[0].request("SCAN_RESULTS"):
1345 # This will fail in IE parsing due to the truncated IE in the Probe
1347 bss = dev[0].request("BSS " + bssid)