]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_wpas_mesh.py
7f9cd83960dcf6eeee5b8dc3e1b6e49f38873124
3 # wpa_supplicant mesh mode tests
4 # Copyright (c) 2014, cozybit Inc.
6 # This software may be distributed under the terms of the BSD license.
7 # See README for more details.
10 logger
= logging
.getLogger()
16 from wpasupplicant
import WpaSupplicant
17 from utils
import HwsimSkip
, alloc_fail
18 from tshark
import run_tshark
20 def check_mesh_support(dev
, secure
=False):
21 if "MESH" not in dev
.get_capability("modes"):
22 raise HwsimSkip("Driver does not support mesh")
23 if secure
and "SAE" not in dev
.get_capability("auth_alg"):
24 raise HwsimSkip("SAE not supported")
26 def check_mesh_scan(dev
, params
, other_started
=False, beacon_int
=0):
29 id = dev
.request("SCAN " + params
)
31 raise Exception("Failed to start scan")
35 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-STARTED"])
37 raise Exception("Other scan did not start")
38 if "id=" + str(id) in ev
:
39 raise Exception("Own scan id unexpectedly included in start event")
41 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
43 raise Exception("Other scan did not complete")
44 if "id=" + str(id) in ev
:
46 "Own scan id unexpectedly included in completed event")
48 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-STARTED"])
50 raise Exception("Scan did not start")
51 if "id=" + str(id) not in ev
:
52 raise Exception("Scan id not included in start event")
54 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
56 raise Exception("Scan did not complete")
57 if "id=" + str(id) not in ev
:
58 raise Exception("Scan id not included in completed event")
60 res
= dev
.request("SCAN_RESULTS")
62 if res
.find("[MESH]") < 0:
63 raise Exception("Scan did not contain a MESH network")
65 bssid
= res
.splitlines()[1].split(' ')[0]
66 bss
= dev
.get_bss(bssid
)
68 raise Exception("Could not get BSS entry for mesh")
69 if 'mesh_capability' not in bss
:
70 raise Exception("mesh_capability missing from BSS entry")
72 if 'beacon_int' not in bss
:
73 raise Exception("beacon_int missing from BSS entry")
74 if str(beacon_int
) != bss
['beacon_int']:
75 raise Exception("Unexpected beacon_int in BSS entry: " + bss
['beacon_int'])
77 def check_mesh_group_added(dev
):
78 ev
= dev
.wait_event(["MESH-GROUP-STARTED"])
80 raise Exception("Test exception: Couldn't join mesh")
83 def check_mesh_group_removed(dev
):
84 ev
= dev
.wait_event(["MESH-GROUP-REMOVED"])
86 raise Exception("Test exception: Couldn't leave mesh")
89 def check_mesh_peer_connected(dev
, timeout
=10):
90 ev
= dev
.wait_event(["MESH-PEER-CONNECTED"], timeout
=timeout
)
92 raise Exception("Test exception: Remote peer did not connect.")
95 def check_mesh_peer_disconnected(dev
):
96 ev
= dev
.wait_event(["MESH-PEER-DISCONNECTED"])
98 raise Exception("Test exception: Peer disconnect event not detected.")
101 def test_wpas_add_set_remove_support(dev
):
102 """wpa_supplicant MESH add/set/remove network support"""
103 check_mesh_support(dev
[0])
104 id = dev
[0].add_network()
105 dev
[0].set_network(id, "mode", "5")
106 dev
[0].remove_network(id)
108 def add_open_mesh_network(dev
, freq
="2412", start
=True, beacon_int
=0,
109 basic_rates
=None, chwidth
=0):
110 id = dev
.add_network()
111 dev
.set_network(id, "mode", "5")
112 dev
.set_network_quoted(id, "ssid", "wpas-mesh-open")
113 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_missing_password(dev
, apdev
):
317 """wpa_supplicant secure MESH and missing SAE password"""
318 check_mesh_support(dev
[0], secure
=True)
319 id = add_mesh_secure_net(dev
[0], psk
=False)
320 dev
[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
321 dev
[0].mesh_group_add(id)
322 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
325 raise Exception("Timeout on mesh start event")
326 if "MESH-GROUP-STARTED" in ev
:
327 raise Exception("Unexpected mesh group start")
328 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED"], timeout
=0.1)
330 raise Exception("Unexpected mesh group start")
332 def test_wpas_mesh_secure_no_auto(dev
, apdev
):
333 """wpa_supplicant secure MESH network connectivity"""
334 check_mesh_support(dev
[0], secure
=True)
335 dev
[0].request("SET sae_groups 19")
336 id = add_mesh_secure_net(dev
[0])
337 dev
[0].mesh_group_add(id)
339 dev
[1].request("SET sae_groups 19")
340 id = add_mesh_secure_net(dev
[1])
341 dev
[1].set_network(id, "no_auto_peer", "1")
342 dev
[1].mesh_group_add(id)
344 # Check for mesh joined
345 check_mesh_group_added(dev
[0])
346 check_mesh_group_added(dev
[1])
348 # Check for peer connected
349 check_mesh_peer_connected(dev
[0], timeout
=30)
350 check_mesh_peer_connected(dev
[1])
352 # Test connectivity 0->1 and 1->0
353 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
355 dev
[0].request("SET sae_groups ")
356 dev
[1].request("SET sae_groups ")
358 def test_wpas_mesh_ctrl(dev
):
359 """wpa_supplicant ctrl_iface mesh command error cases"""
360 check_mesh_support(dev
[0])
361 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD 123"):
362 raise Exception("Unexpected MESH_GROUP_ADD success")
363 id = dev
[0].add_network()
364 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD %d" % id):
365 raise Exception("Unexpected MESH_GROUP_ADD success")
366 dev
[0].set_network(id, "mode", "5")
367 dev
[0].set_network(id, "key_mgmt", "WPA-PSK")
368 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD %d" % id):
369 raise Exception("Unexpected MESH_GROUP_ADD success")
371 if "FAIL" not in dev
[0].request("MESH_GROUP_REMOVE foo"):
372 raise Exception("Unexpected MESH_GROUP_REMOVE success")
374 def test_wpas_mesh_dynamic_interface(dev
):
375 """wpa_supplicant mesh with dynamic interface"""
376 check_mesh_support(dev
[0])
380 mesh0
= dev
[0].request("MESH_INTERFACE_ADD ifname=mesh0")
382 raise Exception("MESH_INTERFACE_ADD failed")
383 mesh1
= dev
[1].request("MESH_INTERFACE_ADD")
385 raise Exception("MESH_INTERFACE_ADD failed")
387 wpas0
= WpaSupplicant(ifname
=mesh0
)
388 wpas1
= WpaSupplicant(ifname
=mesh1
)
389 logger
.info(mesh0
+ " address " + wpas0
.get_status_field("address"))
390 logger
.info(mesh1
+ " address " + wpas1
.get_status_field("address"))
392 add_open_mesh_network(wpas0
)
393 add_open_mesh_network(wpas1
)
394 check_mesh_group_added(wpas0
)
395 check_mesh_group_added(wpas1
)
396 check_mesh_peer_connected(wpas0
)
397 check_mesh_peer_connected(wpas1
)
398 hwsim_utils
.test_connectivity(wpas0
, wpas1
)
400 # Must not allow MESH_GROUP_REMOVE on dynamic interface
401 if "FAIL" not in wpas0
.request("MESH_GROUP_REMOVE " + mesh0
):
402 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
403 if "FAIL" not in wpas1
.request("MESH_GROUP_REMOVE " + mesh1
):
404 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
406 # Must not allow MESH_GROUP_REMOVE on another radio interface
407 if "FAIL" not in wpas0
.request("MESH_GROUP_REMOVE " + mesh1
):
408 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
409 if "FAIL" not in wpas1
.request("MESH_GROUP_REMOVE " + mesh0
):
410 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
412 wpas0
.remove_ifname()
413 wpas1
.remove_ifname()
415 if "OK" not in dev
[0].request("MESH_GROUP_REMOVE " + mesh0
):
416 raise Exception("MESH_GROUP_REMOVE failed")
417 if "OK" not in dev
[1].request("MESH_GROUP_REMOVE " + mesh1
):
418 raise Exception("MESH_GROUP_REMOVE failed")
420 if "FAIL" not in dev
[0].request("MESH_GROUP_REMOVE " + mesh0
):
421 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
422 if "FAIL" not in dev
[1].request("MESH_GROUP_REMOVE " + mesh1
):
423 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
425 logger
.info("Make sure another dynamic group can be added")
426 mesh0
= dev
[0].request("MESH_INTERFACE_ADD ifname=mesh0")
428 raise Exception("MESH_INTERFACE_ADD failed")
429 mesh1
= dev
[1].request("MESH_INTERFACE_ADD")
431 raise Exception("MESH_INTERFACE_ADD failed")
433 wpas0
= WpaSupplicant(ifname
=mesh0
)
434 wpas1
= WpaSupplicant(ifname
=mesh1
)
435 logger
.info(mesh0
+ " address " + wpas0
.get_status_field("address"))
436 logger
.info(mesh1
+ " address " + wpas1
.get_status_field("address"))
438 add_open_mesh_network(wpas0
)
439 add_open_mesh_network(wpas1
)
440 check_mesh_group_added(wpas0
)
441 check_mesh_group_added(wpas1
)
442 check_mesh_peer_connected(wpas0
)
443 check_mesh_peer_connected(wpas1
)
444 hwsim_utils
.test_connectivity(wpas0
, wpas1
)
447 dev
[0].request("MESH_GROUP_REMOVE " + mesh0
)
449 dev
[1].request("MESH_GROUP_REMOVE " + mesh1
)
451 def test_wpas_mesh_max_peering(dev
, apdev
):
452 """Mesh max peering limit"""
453 check_mesh_support(dev
[0])
455 dev
[0].request("SET max_peer_links 1")
457 # first, connect dev[0] and dev[1]
458 add_open_mesh_network(dev
[0])
459 add_open_mesh_network(dev
[1])
461 ev
= dev
[i
].wait_event(["MESH-PEER-CONNECTED"])
463 raise Exception("dev%d did not connect with any peer" % i
)
465 # add dev[2] which will try to connect with both dev[0] and dev[1],
466 # but can complete connection only with dev[1]
467 add_open_mesh_network(dev
[2])
468 for i
in range(1, 3):
469 ev
= dev
[i
].wait_event(["MESH-PEER-CONNECTED"])
471 raise Exception("dev%d did not connect the second peer" % i
)
473 ev
= dev
[0].wait_event(["MESH-PEER-CONNECTED"], timeout
=1)
475 raise Exception("dev0 connection beyond max peering limit")
477 ev
= dev
[2].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
479 raise Exception("dev2 reported unexpected peering: " + ev
)
482 dev
[i
].mesh_group_remove()
483 check_mesh_group_removed(dev
[i
])
485 dev
[0].request("SET max_peer_links 99")
487 def test_wpas_mesh_open_5ghz(dev
, apdev
):
488 """wpa_supplicant open MESH network on 5 GHz band"""
490 _test_wpas_mesh_open_5ghz(dev
, apdev
)
492 subprocess
.call(['iw', 'reg', 'set', '00'])
493 dev
[0].flush_scan_cache()
494 dev
[1].flush_scan_cache()
496 def _test_wpas_mesh_open_5ghz(dev
, apdev
):
497 check_mesh_support(dev
[0])
498 subprocess
.call(['iw', 'reg', 'set', 'US'])
501 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
503 raise Exception("No regdom change event")
504 if "alpha2=US" in ev
:
506 add_open_mesh_network(dev
[i
], freq
="5180")
508 # Check for mesh joined
509 check_mesh_group_added(dev
[0])
510 check_mesh_group_added(dev
[1])
512 # Check for peer connected
513 check_mesh_peer_connected(dev
[0])
514 check_mesh_peer_connected(dev
[1])
516 # Test connectivity 0->1 and 1->0
517 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
519 def test_wpas_mesh_open_vht_80p80(dev
, apdev
):
520 """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
522 _test_wpas_mesh_open_vht_80p80(dev
, apdev
)
524 subprocess
.call(['iw', 'reg', 'set', '00'])
525 dev
[0].flush_scan_cache()
526 dev
[1].flush_scan_cache()
528 def _test_wpas_mesh_open_vht_80p80(dev
, apdev
):
529 check_mesh_support(dev
[0])
530 subprocess
.call(['iw', 'reg', 'set', 'US'])
533 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
535 raise Exception("No regdom change event")
536 if "alpha2=US" in ev
:
538 add_open_mesh_network(dev
[i
], freq
="5180", chwidth
=3)
540 # Check for mesh joined
541 check_mesh_group_added(dev
[0])
542 check_mesh_group_added(dev
[1])
544 # Check for peer connected
545 check_mesh_peer_connected(dev
[0])
546 check_mesh_peer_connected(dev
[1])
548 # Test connectivity 0->1 and 1->0
549 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
551 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
552 if "WIDTH=80+80 MHz" not in sig
:
553 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
554 if "CENTER_FRQ1=5210" not in sig
:
555 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
556 if "CENTER_FRQ2=5775" not in sig
:
557 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
559 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
560 if "WIDTH=80+80 MHz" not in sig
:
561 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig
))
562 if "CENTER_FRQ1=5210" not in sig
:
563 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig
))
564 if "CENTER_FRQ2=5775" not in sig
:
565 raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig
))
567 def test_wpas_mesh_password_mismatch(dev
, apdev
):
568 """Mesh network and one device with mismatching password"""
569 check_mesh_support(dev
[0], secure
=True)
570 dev
[0].request("SET sae_groups ")
571 id = add_mesh_secure_net(dev
[0])
572 dev
[0].mesh_group_add(id)
574 dev
[1].request("SET sae_groups ")
575 id = add_mesh_secure_net(dev
[1])
576 dev
[1].mesh_group_add(id)
578 dev
[2].request("SET sae_groups ")
579 id = add_mesh_secure_net(dev
[2])
580 dev
[2].set_network_quoted(id, "psk", "wrong password")
581 dev
[2].mesh_group_add(id)
583 # The two peers with matching password need to be able to connect
584 check_mesh_group_added(dev
[0])
585 check_mesh_group_added(dev
[1])
586 check_mesh_peer_connected(dev
[0])
587 check_mesh_peer_connected(dev
[1])
589 ev
= dev
[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
591 raise Exception("dev2 did not report auth failure (1)")
592 ev
= dev
[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
594 raise Exception("dev2 did not report auth failure (2)")
597 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=1)
599 logger
.info("dev0 did not report auth failure")
601 if "addr=" + dev
[2].own_addr() not in ev
:
602 raise Exception("Unexpected peer address in dev0 event: " + ev
)
605 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=1)
607 logger
.info("dev1 did not report auth failure")
609 if "addr=" + dev
[2].own_addr() not in ev
:
610 raise Exception("Unexpected peer address in dev1 event: " + ev
)
613 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
617 hwsim_utils
.test_connectivity(dev
[i
], dev
[2], timeout
=1)
618 raise Exception("Data connectivity test passed unexpectedly")
620 if "data delivery failed" not in str(e
):
624 raise Exception("Neither dev0 nor dev1 reported auth failure")
626 def test_wpas_mesh_password_mismatch_retry(dev
, apdev
, params
):
627 """Mesh password mismatch and retry [long]"""
628 if not params
['long']:
629 raise HwsimSkip("Skip test case with long duration due to --long not specified")
630 check_mesh_support(dev
[0], secure
=True)
631 dev
[0].request("SET sae_groups ")
632 id = add_mesh_secure_net(dev
[0])
633 dev
[0].mesh_group_add(id)
635 dev
[1].request("SET sae_groups ")
636 id = add_mesh_secure_net(dev
[1])
637 dev
[1].set_network_quoted(id, "psk", "wrong password")
638 dev
[1].mesh_group_add(id)
640 # Check for mesh joined
641 check_mesh_group_added(dev
[0])
642 check_mesh_group_added(dev
[1])
645 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
647 raise Exception("dev0 did not report auth failure (%d)" % i
)
648 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
650 raise Exception("dev1 did not report auth failure (%d)" % i
)
652 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout
=10)
654 raise Exception("dev0 did not report auth blocked")
655 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout
=10)
657 raise Exception("dev1 did not report auth blocked")
659 def test_mesh_wpa_auth_init_oom(dev
, apdev
):
660 """Secure mesh network setup failing due to wpa_init() OOM"""
661 check_mesh_support(dev
[0], secure
=True)
662 dev
[0].request("SET sae_groups ")
663 with
alloc_fail(dev
[0], 1, "wpa_init"):
664 id = add_mesh_secure_net(dev
[0])
665 dev
[0].mesh_group_add(id)
666 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED"], timeout
=0.2)
668 raise Exception("Unexpected mesh group start during OOM")
670 def test_wpas_mesh_reconnect(dev
, apdev
):
671 """Secure mesh network plink counting during reconnection"""
672 check_mesh_support(dev
[0])
674 _test_wpas_mesh_reconnect(dev
)
676 dev
[0].request("SET max_peer_links 99")
678 def _test_wpas_mesh_reconnect(dev
):
679 dev
[0].request("SET max_peer_links 2")
680 dev
[0].request("SET sae_groups ")
681 id = add_mesh_secure_net(dev
[0])
682 dev
[0].set_network(id, "beacon_int", "100")
683 dev
[0].mesh_group_add(id)
684 dev
[1].request("SET sae_groups ")
685 id = add_mesh_secure_net(dev
[1])
686 dev
[1].mesh_group_add(id)
687 check_mesh_group_added(dev
[0])
688 check_mesh_group_added(dev
[1])
689 check_mesh_peer_connected(dev
[0])
690 check_mesh_peer_connected(dev
[1])
693 # Drop incoming management frames to avoid handling link close
694 dev
[0].request("SET ext_mgmt_frame_handling 1")
695 dev
[1].mesh_group_remove()
696 check_mesh_group_removed(dev
[1])
697 dev
[1].request("FLUSH")
698 dev
[0].request("SET ext_mgmt_frame_handling 0")
699 id = add_mesh_secure_net(dev
[1])
700 dev
[1].mesh_group_add(id)
701 check_mesh_group_added(dev
[1])
702 check_mesh_peer_connected(dev
[1])
703 dev
[0].dump_monitor()
704 dev
[1].dump_monitor()
706 def test_wpas_mesh_gate_forwarding(dev
, apdev
, p
):
707 """Mesh forwards traffic to unknown sta to mesh gates"""
708 addr0
= dev
[0].own_addr()
709 addr1
= dev
[1].own_addr()
710 addr2
= dev
[2].own_addr()
711 external_sta
= '02:11:22:33:44:55'
713 # start 3 node connected mesh
714 check_mesh_support(dev
[0])
716 add_open_mesh_network(dev
[i
])
717 check_mesh_group_added(dev
[i
])
719 check_mesh_peer_connected(dev
[i
])
721 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
722 hwsim_utils
.test_connectivity(dev
[1], dev
[2])
723 hwsim_utils
.test_connectivity(dev
[0], dev
[2])
725 # dev0 and dev1 are mesh gates
726 subprocess
.call(['iw', 'dev', dev
[0].ifname
, 'set', 'mesh_param',
727 'mesh_gate_announcements=1'])
728 subprocess
.call(['iw', 'dev', dev
[1].ifname
, 'set', 'mesh_param',
729 'mesh_gate_announcements=1'])
731 # wait for gate announcement frames
734 # data frame from dev2 -> external sta should be sent to both gates
735 dev
[2].request("DATA_TEST_CONFIG 1")
736 dev
[2].request("DATA_TEST_TX {} {} 0".format(external_sta
, addr2
))
737 dev
[2].request("DATA_TEST_CONFIG 0")
739 capfile
= os
.path
.join(p
['logdir'], "hwsim0.pcapng")
740 filt
= "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2
,
743 da
= run_tshark(capfile
, filt
, [ "wlan.da" ])
744 if addr0
in da
and addr1
in da
:
745 logger
.debug("Frames seen in tshark iteration %d" % i
)
750 raise Exception("Frame to gate %s not observed" % addr0
)
752 raise Exception("Frame to gate %s not observed" % addr1
)