]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_wpas_mesh.py
0e80a5a21bed9cac0f66b1e86868b8ec03d4f3fa
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()
18 from wpasupplicant
import WpaSupplicant
19 from utils
import HwsimSkip
, alloc_fail
, fail_test
, wait_fail_trigger
, \
20 radiotap_build
, start_monitor
, stop_monitor
21 from tshark
import run_tshark
, run_tshark_json
22 from test_ap_ht
import set_world_reg
23 from test_sae
import build_sae_commit
, sae_rx_commit_token_req
24 from hwsim_utils
import set_group_map
26 def check_mesh_support(dev
, secure
=False):
27 if "MESH" not in dev
.get_capability("modes"):
28 raise HwsimSkip("Driver does not support mesh")
29 if secure
and "SAE" not in dev
.get_capability("auth_alg"):
30 raise HwsimSkip("SAE not supported")
32 def check_mesh_scan(dev
, params
, other_started
=False, beacon_int
=0):
35 id = dev
.request("SCAN " + params
)
37 raise Exception("Failed to start scan")
41 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-STARTED"])
43 raise Exception("Other scan did not start")
44 if "id=" + str(id) in ev
:
45 raise Exception("Own scan id unexpectedly included in start event")
47 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
49 raise Exception("Other scan did not complete")
50 if "id=" + str(id) in ev
:
52 "Own scan id unexpectedly included in completed event")
54 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-STARTED"])
56 raise Exception("Scan did not start")
57 if "id=" + str(id) not in ev
:
58 raise Exception("Scan id not included in start event")
60 ev
= dev
.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
62 raise Exception("Scan did not complete")
63 if "id=" + str(id) not in ev
:
64 raise Exception("Scan id not included in completed event")
66 res
= dev
.request("SCAN_RESULTS")
68 if res
.find("[MESH]") < 0:
69 raise Exception("Scan did not contain a MESH network")
71 bssid
= res
.splitlines()[1].split(' ')[0]
72 bss
= dev
.get_bss(bssid
)
74 raise Exception("Could not get BSS entry for mesh")
75 if 'mesh_capability' not in bss
:
76 raise Exception("mesh_capability missing from BSS entry")
78 if 'beacon_int' not in bss
:
79 raise Exception("beacon_int missing from BSS entry")
80 if str(beacon_int
) != bss
['beacon_int']:
81 raise Exception("Unexpected beacon_int in BSS entry: " + bss
['beacon_int'])
82 if '[MESH]' not in bss
['flags']:
83 raise Exception("BSS output did not include MESH flag")
85 def check_mesh_group_added(dev
):
86 ev
= dev
.wait_event(["MESH-GROUP-STARTED"])
88 raise Exception("Test exception: Couldn't join mesh")
91 def check_mesh_group_removed(dev
):
92 ev
= dev
.wait_event(["MESH-GROUP-REMOVED"])
94 raise Exception("Test exception: Couldn't leave mesh")
97 def check_mesh_peer_connected(dev
, timeout
=10):
98 ev
= dev
.wait_event(["MESH-PEER-CONNECTED"], timeout
=timeout
)
100 raise Exception("Test exception: Remote peer did not connect.")
103 def check_mesh_peer_disconnected(dev
):
104 ev
= dev
.wait_event(["MESH-PEER-DISCONNECTED"])
106 raise Exception("Test exception: Peer disconnect event not detected.")
108 def check_mesh_joined2(dev
):
109 check_mesh_group_added(dev
[0])
110 check_mesh_group_added(dev
[1])
112 def check_mesh_connected2(dev
, timeout0
=10, connectivity
=False):
113 check_mesh_peer_connected(dev
[0], timeout
=timeout0
)
114 check_mesh_peer_connected(dev
[1])
116 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
118 def check_mesh_joined_connected(dev
, connectivity
=False, timeout0
=10):
119 check_mesh_joined2(dev
)
120 check_mesh_connected2(dev
, timeout0
=timeout0
, connectivity
=connectivity
)
122 def test_wpas_add_set_remove_support(dev
):
123 """wpa_supplicant MESH add/set/remove network support"""
124 check_mesh_support(dev
[0])
125 id = dev
[0].add_network()
126 dev
[0].set_network(id, "mode", "5")
127 dev
[0].remove_network(id)
129 def add_open_mesh_network(dev
, freq
="2412", start
=True, beacon_int
=0,
130 basic_rates
=None, chwidth
=-1, disable_vht
=False,
132 id = dev
.add_network()
133 dev
.set_network(id, "mode", "5")
134 dev
.set_network_quoted(id, "ssid", "wpas-mesh-open")
135 dev
.set_network(id, "key_mgmt", "NONE")
137 dev
.set_network(id, "frequency", freq
)
139 dev
.set_network(id, "max_oper_chwidth", str(chwidth
))
141 dev
.set_network(id, "beacon_int", str(beacon_int
))
143 dev
.set_network(id, "mesh_basic_rates", basic_rates
)
145 dev
.set_network(id, "disable_vht", "1")
147 dev
.set_network(id, "disable_ht40", "1")
149 dev
.mesh_group_add(id)
152 def test_wpas_mesh_group_added(dev
):
153 """wpa_supplicant MESH group add"""
154 check_mesh_support(dev
[0])
155 add_open_mesh_network(dev
[0])
157 # Check for MESH-GROUP-STARTED event
158 check_mesh_group_added(dev
[0])
161 def test_wpas_mesh_group_remove(dev
):
162 """wpa_supplicant MESH group remove"""
163 check_mesh_support(dev
[0])
164 add_open_mesh_network(dev
[0])
165 # Check for MESH-GROUP-STARTED event
166 check_mesh_group_added(dev
[0])
167 dev
[0].mesh_group_remove()
168 # Check for MESH-GROUP-REMOVED event
169 check_mesh_group_removed(dev
[0])
170 dev
[0].mesh_group_remove()
172 def test_wpas_mesh_peer_connected(dev
):
173 """wpa_supplicant MESH peer connected"""
174 check_mesh_support(dev
[0])
175 add_open_mesh_network(dev
[0], beacon_int
=160)
176 add_open_mesh_network(dev
[1], beacon_int
=160)
177 check_mesh_joined_connected(dev
)
179 def test_wpas_mesh_peer_disconnected(dev
):
180 """wpa_supplicant MESH peer disconnected"""
181 check_mesh_support(dev
[0])
182 add_open_mesh_network(dev
[0])
183 add_open_mesh_network(dev
[1])
184 check_mesh_joined_connected(dev
)
186 # Remove group on dev 1
187 dev
[1].mesh_group_remove()
188 # Device 0 should get a disconnection event
189 check_mesh_peer_disconnected(dev
[0])
192 def test_wpas_mesh_mode_scan(dev
):
193 """wpa_supplicant MESH scan support"""
194 check_mesh_support(dev
[0])
195 add_open_mesh_network(dev
[0])
196 add_open_mesh_network(dev
[1], beacon_int
=175)
198 check_mesh_joined2(dev
)
200 # Check for Mesh scan
201 check_mesh_scan(dev
[0], "use_id=1 freq=2412", beacon_int
=175)
203 def test_wpas_mesh_open(dev
, apdev
):
204 """wpa_supplicant open MESH network connectivity"""
205 check_mesh_support(dev
[0])
206 add_open_mesh_network(dev
[0], freq
="2462", basic_rates
="60 120 240")
207 add_open_mesh_network(dev
[1], freq
="2462", basic_rates
="60 120 240")
209 check_mesh_joined_connected(dev
, connectivity
=True)
211 state
= dev
[0].get_status_field("wpa_state")
212 if state
!= "COMPLETED":
213 raise Exception("Unexpected wpa_state on dev0: " + state
)
214 state
= dev
[1].get_status_field("wpa_state")
215 if state
!= "COMPLETED":
216 raise Exception("Unexpected wpa_state on dev1: " + state
)
218 mode
= dev
[0].get_status_field("mode")
220 raise Exception("Unexpected mode: " + mode
)
222 def test_wpas_mesh_open_no_auto(dev
, apdev
):
223 """wpa_supplicant open MESH network connectivity"""
224 check_mesh_support(dev
[0])
225 id = add_open_mesh_network(dev
[0], start
=False)
226 dev
[0].set_network(id, "dot11MeshMaxRetries", "16")
227 dev
[0].set_network(id, "dot11MeshRetryTimeout", "255")
228 dev
[0].mesh_group_add(id)
230 id = add_open_mesh_network(dev
[1], start
=False)
231 dev
[1].set_network(id, "no_auto_peer", "1")
232 dev
[1].mesh_group_add(id)
234 check_mesh_joined_connected(dev
, connectivity
=True, timeout0
=30)
236 def test_mesh_open_no_auto2(dev
, apdev
):
237 """Open mesh network connectivity, no_auto on both peers"""
238 check_mesh_support(dev
[0])
239 id = add_open_mesh_network(dev
[0], start
=False)
240 dev
[0].set_network(id, "no_auto_peer", "1")
241 dev
[0].mesh_group_add(id)
243 id = add_open_mesh_network(dev
[1], start
=False)
244 dev
[1].set_network(id, "no_auto_peer", "1")
245 dev
[1].mesh_group_add(id)
247 check_mesh_joined2(dev
)
249 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
251 raise Exception("Missing no-initiate message")
252 addr1
= dev
[1].own_addr()
253 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
254 raise Exception("MESH_PEER_ADD failed")
255 if "FAIL" not in dev
[0].request("MESH_PEER_ADD ff:ff:ff:ff:ff:ff"):
256 raise Exception("MESH_PEER_ADD with unknown STA succeeded")
257 check_mesh_connected2(dev
, timeout0
=30)
258 if "FAIL" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
259 raise Exception("MESH_PEER_ADD succeeded for connected STA")
260 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
262 def test_mesh_open_rssi_threshold(dev
, apdev
):
263 """Open mesh network with RSSI threshold"""
264 check_mesh_support(dev
[0])
266 _test_mesh_open_rssi_threshold(dev
, apdev
, -255, -255)
267 _test_mesh_open_rssi_threshold(dev
, apdev
, 0, 0)
268 _test_mesh_open_rssi_threshold(dev
, apdev
, 1, 0)
270 def _test_mesh_open_rssi_threshold(dev
, apdev
, value
, expected
):
271 id = add_open_mesh_network(dev
[0], start
=False)
272 dev
[0].set_network(id, "mesh_rssi_threshold", str(value
))
273 dev
[0].mesh_group_add(id)
274 check_mesh_group_added(dev
[0])
276 cmd
= subprocess
.Popen(["iw", "dev", dev
[0].ifname
, "get", "mesh_param",
277 "mesh_rssi_threshold"], stdout
=subprocess
.PIPE
)
278 mesh_rssi_threshold
= int(cmd
.stdout
.read().decode().split(" ")[0])
280 dev
[0].mesh_group_remove()
281 check_mesh_group_removed(dev
[0])
283 if mesh_rssi_threshold
!= expected
:
284 raise Exception("mesh_rssi_threshold should be " + str(expected
) +
285 ": " + str(mesh_rssi_threshold
))
287 def add_mesh_secure_net(dev
, psk
=True, pmf
=False, pairwise
=None, group
=None,
289 sae_password
=False, sae_password_id
=None, ocv
=False):
290 id = dev
.add_network()
291 dev
.set_network(id, "mode", "5")
292 dev
.set_network_quoted(id, "ssid", "wpas-mesh-sec")
293 dev
.set_network(id, "key_mgmt", "SAE")
294 dev
.set_network(id, "frequency", "2412")
296 dev
.set_network_quoted(id, "sae_password", "thisismypassphrase!")
298 dev
.set_network_quoted(id, "sae_password_id", sae_password_id
)
300 dev
.set_network_quoted(id, "psk", "thisismypassphrase!")
302 dev
.set_network(id, "ieee80211w", "2")
304 dev
.set_network(id, "pairwise", pairwise
)
306 dev
.set_network(id, "group", group
)
308 dev
.set_network(id, "group_mgmt", group_mgmt
)
311 dev
.set_network(id, "ocv", "1")
312 except Exception as e
:
313 if "SET_NETWORK failed" in str(e
):
314 raise HwsimSkip("OCV not supported")
318 def test_wpas_mesh_secure(dev
, apdev
):
319 """wpa_supplicant secure MESH network connectivity"""
320 check_mesh_support(dev
[0], secure
=True)
321 dev
[0].request("SET sae_groups ")
322 id = add_mesh_secure_net(dev
[0])
323 dev
[0].mesh_group_add(id)
325 dev
[1].request("SET sae_groups ")
326 id = add_mesh_secure_net(dev
[1])
327 dev
[1].mesh_group_add(id)
329 check_mesh_joined_connected(dev
, connectivity
=True)
331 state
= dev
[0].get_status_field("wpa_state")
332 if state
!= "COMPLETED":
333 raise Exception("Unexpected wpa_state on dev0: " + state
)
334 state
= dev
[1].get_status_field("wpa_state")
335 if state
!= "COMPLETED":
336 raise Exception("Unexpected wpa_state on dev1: " + state
)
338 def test_wpas_mesh_secure_sae_password(dev
, apdev
):
339 """wpa_supplicant secure mesh using sae_password"""
340 check_mesh_support(dev
[0], secure
=True)
341 dev
[0].request("SET sae_groups ")
342 id = add_mesh_secure_net(dev
[0], psk
=False, sae_password
=True)
343 dev
[0].mesh_group_add(id)
345 dev
[1].request("SET sae_groups ")
346 id = add_mesh_secure_net(dev
[1])
347 dev
[1].mesh_group_add(id)
349 check_mesh_joined_connected(dev
, connectivity
=True)
351 def test_wpas_mesh_secure_sae_password_id(dev
, apdev
):
352 """Secure mesh using sae_password and password identifier"""
353 check_mesh_support(dev
[0], secure
=True)
354 dev
[0].request("SET sae_groups ")
355 id = add_mesh_secure_net(dev
[0], psk
=False, sae_password
=True,
356 sae_password_id
="pw id")
357 dev
[0].mesh_group_add(id)
359 dev
[1].request("SET sae_groups ")
360 id = add_mesh_secure_net(dev
[1], sae_password
=True,
361 sae_password_id
="pw id")
362 dev
[1].mesh_group_add(id)
364 check_mesh_joined_connected(dev
, connectivity
=True)
366 def test_wpas_mesh_secure_sae_password_id_mismatch(dev
, apdev
):
367 """Secure mesh using sae_password and password identifier mismatch"""
368 check_mesh_support(dev
[0], secure
=True)
369 dev
[0].request("SET sae_groups ")
370 id = add_mesh_secure_net(dev
[0], psk
=False, sae_password
=True,
371 sae_password_id
="pw id")
372 dev
[0].mesh_group_add(id)
374 dev
[1].request("SET sae_groups ")
375 id = add_mesh_secure_net(dev
[1], sae_password
=True,
376 sae_password_id
="wrong")
377 dev
[1].mesh_group_add(id)
379 check_mesh_joined2(dev
)
381 ev
= dev
[0].wait_event(["CTRL-EVENT-SAE-UNKNOWN-PASSWORD-IDENTIFIER"],
384 raise Exception("Unknown Password Identifier not noticed")
386 def test_mesh_secure_pmf(dev
, apdev
):
387 """Secure mesh network connectivity with PMF enabled"""
388 check_mesh_support(dev
[0], secure
=True)
389 dev
[0].request("SET sae_groups ")
390 id = add_mesh_secure_net(dev
[0], pmf
=True)
391 dev
[0].mesh_group_add(id)
393 dev
[1].request("SET sae_groups ")
394 id = add_mesh_secure_net(dev
[1], pmf
=True)
395 dev
[1].mesh_group_add(id)
397 check_mesh_joined_connected(dev
, connectivity
=True)
399 def test_mesh_secure_ocv(dev
, apdev
):
400 """Secure mesh network connectivity with OCV enabled"""
401 check_mesh_support(dev
[0], secure
=True)
402 dev
[0].request("SET sae_groups ")
403 id = add_mesh_secure_net(dev
[0], pmf
=True, ocv
=True)
404 dev
[0].mesh_group_add(id)
405 dev
[1].request("SET sae_groups ")
406 id = add_mesh_secure_net(dev
[1], pmf
=True, ocv
=True)
407 dev
[1].mesh_group_add(id)
409 check_mesh_joined_connected(dev
, connectivity
=True)
411 def test_mesh_secure_ocv_compat(dev
, apdev
):
412 """Secure mesh network where only one peer has OCV enabled"""
413 check_mesh_support(dev
[0], secure
=True)
414 dev
[0].request("SET sae_groups ")
415 id = add_mesh_secure_net(dev
[0], pmf
=True, ocv
=True)
416 dev
[0].mesh_group_add(id)
417 dev
[1].request("SET sae_groups ")
418 id = add_mesh_secure_net(dev
[1], pmf
=True, ocv
=False)
419 dev
[1].mesh_group_add(id)
421 check_mesh_joined_connected(dev
, connectivity
=True)
423 def set_reg(dev
, country
):
424 subprocess
.call(['iw', 'reg', 'set', country
])
427 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
429 raise Exception("No regdom change event")
430 if "alpha2=" + country
in ev
:
433 def clear_reg_setting(dev
):
434 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
435 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
436 subprocess
.call(['iw', 'reg', 'set', '00'])
437 dev
[0].flush_scan_cache()
438 dev
[1].flush_scan_cache()
440 def test_mesh_secure_ocv_mix_legacy(dev
, apdev
):
441 """Mesh network with a VHT STA and a legacy STA under OCV"""
443 run_mesh_secure_ocv_mix_legacy(dev
, apdev
)
445 clear_reg_setting(dev
)
447 def run_mesh_secure_ocv_mix_legacy(dev
, apdev
):
448 check_mesh_support(dev
[0], secure
=True)
451 dev
[0].request("SET sae_groups ")
452 id = add_mesh_secure_net(dev
[0], pmf
=True, ocv
=True)
453 dev
[0].set_network(id, "frequency", "5200")
454 dev
[0].set_network(id, "max_oper_chwidth", "2")
455 dev
[0].mesh_group_add(id)
457 dev
[1].request("SET sae_groups ")
458 id = add_mesh_secure_net(dev
[1], pmf
=True, ocv
=True)
459 dev
[1].set_network(id, "frequency", "5200")
460 dev
[1].set_network(id, "disable_vht", "1")
461 dev
[1].set_network(id, "disable_ht40", "1")
462 dev
[1].mesh_group_add(id)
464 check_mesh_joined_connected(dev
, connectivity
=True)
466 def test_mesh_secure_ocv_mix_ht(dev
, apdev
):
467 """Mesh network with a VHT STA and a HT STA under OCV"""
469 run_mesh_secure_ocv_mix_ht(dev
, apdev
)
471 clear_reg_setting(dev
)
473 def run_mesh_secure_ocv_mix_ht(dev
, apdev
):
474 check_mesh_support(dev
[0], secure
=True)
477 dev
[0].request("SET sae_groups ")
478 id = add_mesh_secure_net(dev
[0], pmf
=True, ocv
=True)
479 dev
[0].set_network(id, "frequency", "5200")
480 dev
[0].set_network(id, "max_oper_chwidth", "2")
481 dev
[0].mesh_group_add(id)
483 dev
[1].request("SET sae_groups ")
484 id = add_mesh_secure_net(dev
[1], pmf
=True, ocv
=True)
485 dev
[1].set_network(id, "frequency", "5200")
486 dev
[1].set_network(id, "disable_vht", "1")
487 dev
[1].mesh_group_add(id)
489 check_mesh_joined_connected(dev
, connectivity
=True)
491 def run_mesh_secure(dev
, cipher
, pmf
=False, group_mgmt
=None):
492 if cipher
not in dev
[0].get_capability("pairwise"):
493 raise HwsimSkip("Cipher %s not supported" % cipher
)
494 check_mesh_support(dev
[0], secure
=True)
495 dev
[0].request("SET sae_groups ")
496 id = add_mesh_secure_net(dev
[0], pairwise
=cipher
, group
=cipher
, pmf
=pmf
,
497 group_mgmt
=group_mgmt
)
498 dev
[0].mesh_group_add(id)
500 dev
[1].request("SET sae_groups ")
501 id = add_mesh_secure_net(dev
[1], pairwise
=cipher
, group
=cipher
, pmf
=pmf
,
502 group_mgmt
=group_mgmt
)
503 dev
[1].mesh_group_add(id)
505 check_mesh_joined_connected(dev
, connectivity
=True)
507 def test_mesh_secure_ccmp(dev
, apdev
):
508 """Secure mesh with CCMP"""
509 run_mesh_secure(dev
, "CCMP")
511 def test_mesh_secure_gcmp(dev
, apdev
):
512 """Secure mesh with GCMP"""
513 run_mesh_secure(dev
, "GCMP")
515 def test_mesh_secure_gcmp_256(dev
, apdev
):
516 """Secure mesh with GCMP-256"""
517 run_mesh_secure(dev
, "GCMP-256")
519 def test_mesh_secure_ccmp_256(dev
, apdev
):
520 """Secure mesh with CCMP-256"""
521 run_mesh_secure(dev
, "CCMP-256")
523 def test_mesh_secure_ccmp_cmac(dev
, apdev
):
524 """Secure mesh with CCMP-128 and BIP-CMAC-128"""
525 run_mesh_secure(dev
, "CCMP", pmf
=True, group_mgmt
="AES-128-CMAC")
527 def test_mesh_secure_gcmp_gmac(dev
, apdev
):
528 """Secure mesh with GCMP-128 and BIP-GMAC-128"""
529 run_mesh_secure(dev
, "GCMP", pmf
=True, group_mgmt
="BIP-GMAC-128")
531 def test_mesh_secure_ccmp_256_cmac_256(dev
, apdev
):
532 """Secure mesh with CCMP-256 and BIP-CMAC-256"""
533 run_mesh_secure(dev
, "CCMP-256", pmf
=True, group_mgmt
="BIP-CMAC-256")
535 def test_mesh_secure_gcmp_256_gmac_256(dev
, apdev
):
536 """Secure mesh with GCMP-256 and BIP-GMAC-256"""
537 run_mesh_secure(dev
, "GCMP-256", pmf
=True, group_mgmt
="BIP-GMAC-256")
539 def test_mesh_secure_invalid_pairwise_cipher(dev
, apdev
):
540 """Secure mesh and invalid group cipher"""
541 check_mesh_support(dev
[0], secure
=True)
542 dev
[0].request("SET sae_groups ")
543 id = add_mesh_secure_net(dev
[0], pairwise
="TKIP", group
="CCMP")
544 if dev
[0].mesh_group_add(id) != None:
545 raise Exception("Unexpected group add success")
546 ev
= dev
[0].wait_event(["mesh: Invalid pairwise cipher"], timeout
=1)
548 raise Exception("Invalid pairwise cipher not reported")
550 def test_mesh_secure_invalid_group_cipher(dev
, apdev
):
551 """Secure mesh and invalid group cipher"""
552 check_mesh_support(dev
[0], secure
=True)
553 dev
[0].request("SET sae_groups ")
554 id = add_mesh_secure_net(dev
[0], pairwise
="CCMP", group
="TKIP")
555 if dev
[0].mesh_group_add(id) != None:
556 raise Exception("Unexpected group add success")
557 ev
= dev
[0].wait_event(["mesh: Invalid group cipher"], timeout
=1)
559 raise Exception("Invalid group cipher not reported")
561 def test_wpas_mesh_secure_sae_group_mismatch(dev
, apdev
):
562 """wpa_supplicant secure MESH and SAE group mismatch"""
563 check_mesh_support(dev
[0], secure
=True)
564 addr0
= dev
[0].p2p_interface_addr()
565 addr1
= dev
[1].p2p_interface_addr()
566 addr2
= dev
[2].p2p_interface_addr()
568 dev
[0].request("SET sae_groups 19 25")
569 id = add_mesh_secure_net(dev
[0])
570 dev
[0].mesh_group_add(id)
572 dev
[1].request("SET sae_groups 19")
573 id = add_mesh_secure_net(dev
[1])
574 dev
[1].mesh_group_add(id)
576 dev
[2].request("SET sae_groups 26")
577 id = add_mesh_secure_net(dev
[2])
578 dev
[2].mesh_group_add(id)
580 check_mesh_group_added(dev
[0])
581 check_mesh_group_added(dev
[1])
582 check_mesh_group_added(dev
[2])
584 ev
= dev
[0].wait_event(["MESH-PEER-CONNECTED"])
586 raise Exception("Remote peer did not connect")
588 raise Exception("Unexpected peer connected: " + ev
)
590 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"])
592 raise Exception("Remote peer did not connect")
594 raise Exception("Unexpected peer connected: " + ev
)
596 ev
= dev
[2].wait_event(["MESH-PEER-CONNECTED"], timeout
=1)
598 raise Exception("Unexpected peer connection at dev[2]: " + ev
)
600 ev
= dev
[0].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
602 raise Exception("Unexpected peer connection: " + ev
)
604 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
606 raise Exception("Unexpected peer connection: " + ev
)
608 dev
[0].request("SET sae_groups ")
609 dev
[1].request("SET sae_groups ")
610 dev
[2].request("SET sae_groups ")
612 def test_wpas_mesh_secure_sae_group_negotiation(dev
, apdev
):
613 """wpa_supplicant secure MESH and SAE group negotiation"""
614 check_mesh_support(dev
[0], secure
=True)
615 addr0
= dev
[0].own_addr()
616 addr1
= dev
[1].own_addr()
618 #dev[0].request("SET sae_groups 21 20 25 26")
619 dev
[0].request("SET sae_groups 26")
620 id = add_mesh_secure_net(dev
[0])
621 dev
[0].mesh_group_add(id)
623 dev
[1].request("SET sae_groups 19 26")
624 id = add_mesh_secure_net(dev
[1])
625 dev
[1].mesh_group_add(id)
627 check_mesh_joined_connected(dev
)
629 dev
[0].request("SET sae_groups ")
630 dev
[1].request("SET sae_groups ")
632 def test_wpas_mesh_secure_sae_missing_password(dev
, apdev
):
633 """wpa_supplicant secure MESH and missing SAE password"""
634 check_mesh_support(dev
[0], secure
=True)
635 id = add_mesh_secure_net(dev
[0], psk
=False)
636 dev
[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
637 dev
[0].mesh_group_add(id)
638 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
641 raise Exception("Timeout on mesh start event")
642 if "MESH-GROUP-STARTED" in ev
:
643 raise Exception("Unexpected mesh group start")
644 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED"], timeout
=0.1)
646 raise Exception("Unexpected mesh group start")
648 def test_wpas_mesh_secure_no_auto(dev
, apdev
):
649 """wpa_supplicant secure MESH network connectivity"""
650 check_mesh_support(dev
[0], secure
=True)
651 dev
[0].request("SET sae_groups 19")
652 id = add_mesh_secure_net(dev
[0])
653 dev
[0].mesh_group_add(id)
655 dev
[1].request("SET sae_groups 19")
656 id = add_mesh_secure_net(dev
[1])
657 dev
[1].set_network(id, "no_auto_peer", "1")
658 dev
[1].mesh_group_add(id)
660 check_mesh_joined_connected(dev
, connectivity
=True)
662 dev
[0].request("SET sae_groups ")
663 dev
[1].request("SET sae_groups ")
665 def test_wpas_mesh_secure_dropped_frame(dev
, apdev
):
666 """Secure mesh network connectivity when the first plink Open is dropped"""
667 check_mesh_support(dev
[0], secure
=True)
669 dev
[0].request("SET ext_mgmt_frame_handling 1")
670 dev
[0].request("SET sae_groups ")
671 id = add_mesh_secure_net(dev
[0])
672 dev
[0].mesh_group_add(id)
674 dev
[1].request("SET sae_groups ")
675 id = add_mesh_secure_net(dev
[1])
676 dev
[1].mesh_group_add(id)
678 check_mesh_joined2(dev
)
680 # Drop the first Action frame (plink Open) to test unexpected order of
681 # Confirm/Open messages.
686 raise Exception("Did not see Action frames")
687 rx_msg
= dev
[0].mgmt_rx()
689 raise Exception("MGMT-RX timeout")
690 if rx_msg
['subtype'] == 13:
691 logger
.info("Drop the first Action frame")
693 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
694 rx_msg
['freq'], rx_msg
['datarate'], rx_msg
['ssi_signal'], binascii
.hexlify(rx_msg
['frame']).decode())):
695 raise Exception("MGMT_RX_PROCESS failed")
697 dev
[0].request("SET ext_mgmt_frame_handling 0")
699 check_mesh_connected2(dev
, connectivity
=True)
701 def test_mesh_secure_fail(dev
, apdev
):
702 """Secure mesh network connectivity failure"""
703 check_mesh_support(dev
[0], secure
=True)
704 dev
[0].request("SET sae_groups ")
705 id = add_mesh_secure_net(dev
[0], pmf
=True)
706 dev
[0].mesh_group_add(id)
708 dev
[1].request("SET sae_groups ")
709 id = add_mesh_secure_net(dev
[1], pmf
=True)
711 with
fail_test(dev
[0], 1, "wpa_driver_nl80211_sta_add;mesh_mpm_auth_peer"):
712 dev
[1].mesh_group_add(id)
714 check_mesh_joined_connected(dev
)
716 def test_wpas_mesh_ctrl(dev
):
717 """wpa_supplicant ctrl_iface mesh command error cases"""
718 check_mesh_support(dev
[0])
719 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD 123"):
720 raise Exception("Unexpected MESH_GROUP_ADD success")
721 id = dev
[0].add_network()
722 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD %d" % id):
723 raise Exception("Unexpected MESH_GROUP_ADD success")
724 dev
[0].set_network(id, "mode", "5")
725 dev
[0].set_network(id, "key_mgmt", "WPA-PSK")
726 if "FAIL" not in dev
[0].request("MESH_GROUP_ADD %d" % id):
727 raise Exception("Unexpected MESH_GROUP_ADD success")
729 if "FAIL" not in dev
[0].request("MESH_GROUP_REMOVE foo"):
730 raise Exception("Unexpected MESH_GROUP_REMOVE success")
732 def test_wpas_mesh_dynamic_interface(dev
):
733 """wpa_supplicant mesh with dynamic interface"""
734 check_mesh_support(dev
[0])
738 mesh0
= dev
[0].request("MESH_INTERFACE_ADD ifname=mesh0")
740 raise Exception("MESH_INTERFACE_ADD failed")
741 mesh1
= dev
[1].request("MESH_INTERFACE_ADD")
743 raise Exception("MESH_INTERFACE_ADD failed")
745 wpas0
= WpaSupplicant(ifname
=mesh0
)
746 wpas1
= WpaSupplicant(ifname
=mesh1
)
747 logger
.info(mesh0
+ " address " + wpas0
.get_status_field("address"))
748 logger
.info(mesh1
+ " address " + wpas1
.get_status_field("address"))
750 add_open_mesh_network(wpas0
)
751 add_open_mesh_network(wpas1
)
752 check_mesh_joined_connected([wpas0
, wpas1
], connectivity
=True)
754 # Must not allow MESH_GROUP_REMOVE on dynamic interface
755 if "FAIL" not in wpas0
.request("MESH_GROUP_REMOVE " + mesh0
):
756 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
757 if "FAIL" not in wpas1
.request("MESH_GROUP_REMOVE " + mesh1
):
758 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
760 # Must not allow MESH_GROUP_REMOVE on another radio interface
761 if "FAIL" not in wpas0
.request("MESH_GROUP_REMOVE " + mesh1
):
762 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
763 if "FAIL" not in wpas1
.request("MESH_GROUP_REMOVE " + mesh0
):
764 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
766 wpas0
.remove_ifname()
767 wpas1
.remove_ifname()
769 if "OK" not in dev
[0].request("MESH_GROUP_REMOVE " + mesh0
):
770 raise Exception("MESH_GROUP_REMOVE failed")
771 if "OK" not in dev
[1].request("MESH_GROUP_REMOVE " + mesh1
):
772 raise Exception("MESH_GROUP_REMOVE failed")
774 if "FAIL" not in dev
[0].request("MESH_GROUP_REMOVE " + mesh0
):
775 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
776 if "FAIL" not in dev
[1].request("MESH_GROUP_REMOVE " + mesh1
):
777 raise Exception("Invalid MESH_GROUP_REMOVE accepted")
779 logger
.info("Make sure another dynamic group can be added")
780 mesh0
= dev
[0].request("MESH_INTERFACE_ADD ifname=mesh0")
782 raise Exception("MESH_INTERFACE_ADD failed")
783 mesh1
= dev
[1].request("MESH_INTERFACE_ADD")
785 raise Exception("MESH_INTERFACE_ADD failed")
787 wpas0
= WpaSupplicant(ifname
=mesh0
)
788 wpas1
= WpaSupplicant(ifname
=mesh1
)
789 logger
.info(mesh0
+ " address " + wpas0
.get_status_field("address"))
790 logger
.info(mesh1
+ " address " + wpas1
.get_status_field("address"))
792 add_open_mesh_network(wpas0
)
793 add_open_mesh_network(wpas1
)
794 check_mesh_joined_connected([wpas0
, wpas1
], connectivity
=True)
797 dev
[0].request("MESH_GROUP_REMOVE " + mesh0
)
799 dev
[1].request("MESH_GROUP_REMOVE " + mesh1
)
801 def test_wpas_mesh_dynamic_interface_remove(dev
):
802 """wpa_supplicant mesh with dynamic interface and removal"""
803 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
804 wpas
.interface_add("wlan5")
805 check_mesh_support(wpas
)
806 mesh5
= wpas
.request("MESH_INTERFACE_ADD ifname=mesh5")
808 raise Exception("MESH_INTERFACE_ADD failed")
810 wpas5
= WpaSupplicant(ifname
=mesh5
)
811 logger
.info(mesh5
+ " address " + wpas5
.get_status_field("address"))
812 add_open_mesh_network(wpas5
)
813 add_open_mesh_network(dev
[0])
814 check_mesh_joined_connected([wpas5
, dev
[0]], connectivity
=True)
816 # Remove the main interface while mesh interface is in use
817 wpas
.interface_remove("wlan5")
819 def test_wpas_mesh_max_peering(dev
, apdev
, params
):
820 """Mesh max peering limit"""
821 check_mesh_support(dev
[0])
823 dev
[0].request("SET max_peer_links 1")
825 # first, connect dev[0] and dev[1]
826 add_open_mesh_network(dev
[0])
827 add_open_mesh_network(dev
[1])
829 ev
= dev
[i
].wait_event(["MESH-PEER-CONNECTED"])
831 raise Exception("dev%d did not connect with any peer" % i
)
833 # add dev[2] which will try to connect with both dev[0] and dev[1],
834 # but can complete connection only with dev[1]
835 add_open_mesh_network(dev
[2])
836 for i
in range(1, 3):
837 ev
= dev
[i
].wait_event(["MESH-PEER-CONNECTED"])
839 raise Exception("dev%d did not connect the second peer" % i
)
841 ev
= dev
[0].wait_event(["MESH-PEER-CONNECTED"], timeout
=1)
843 raise Exception("dev0 connection beyond max peering limit")
845 ev
= dev
[2].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
847 raise Exception("dev2 reported unexpected peering: " + ev
)
850 dev
[i
].mesh_group_remove()
851 check_mesh_group_removed(dev
[i
])
853 dev
[0].request("SET max_peer_links 99")
855 addr0
= dev
[0].own_addr()
856 addr1
= dev
[1].own_addr()
857 addr2
= dev
[2].own_addr()
859 capfile
= os
.path
.join(params
['logdir'], "hwsim0.pcapng")
860 filt
= "wlan.fc.type_subtype == 8"
861 out
= run_tshark(capfile
, filt
, ["wlan.sa", "wlan.mesh.config.cap"])
862 pkts
= out
.splitlines()
867 addr
, cap
= pkt
.split('\t')
883 logger
.info("one: " + str(one
))
884 logger
.info("zero: " + str(zero
))
886 # It looks like tshark parser was broken at some point for
887 # wlan.mesh.config.cap which is now (tshark 2.6.3) pointing to incorrect
888 # field (same as wlan.mesh.config.ps_protocol). This used to work with
891 # For now, assume the capability field ends up being the last octet of
895 addrs
= [addr0
, addr1
, addr2
]
898 out
= run_tshark_json(capfile
, filt
+ " && wlan.sa == " + addr
)
899 pkts
= json
.loads(out
)
901 wlan
= pkt
["_source"]["layers"]["wlan"]
902 if "wlan.tagged.all" not in wlan
:
905 tagged
= wlan
["wlan.tagged.all"]
906 if "wlan.tag" not in tagged
:
909 wlan_tag
= tagged
["wlan.tag"]
910 if "wlan.mesh.config.ps_protocol_raw" not in wlan_tag
:
913 frame
= pkt
["_source"]["layers"]["frame_raw"][0]
914 cap_offset
= wlan_tag
["wlan.mesh.config.ps_protocol_raw"][1] + 6
915 cap
= int(frame
[(cap_offset
* 2):(cap_offset
* 2 + 2)], 16)
920 logger
.info("one: " + str(one
))
921 logger
.info("zero: " + str(zero
))
923 raise Exception("Accepting Additional Mesh Peerings not cleared")
925 raise Exception("Accepting Additional Mesh Peerings was not set in the first Beacon frame")
926 if zero
[1] > 0 or zero
[2] > 0 or one
[1] == 0 or one
[2] == 0:
927 raise Exception("Unexpected value in Accepting Additional Mesh Peerings from other STAs")
929 def test_wpas_mesh_open_5ghz(dev
, apdev
):
930 """wpa_supplicant open MESH network on 5 GHz band"""
932 _test_wpas_mesh_open_5ghz(dev
, apdev
)
934 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
935 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
936 subprocess
.call(['iw', 'reg', 'set', '00'])
937 dev
[0].flush_scan_cache()
938 dev
[1].flush_scan_cache()
940 def _test_wpas_mesh_open_5ghz(dev
, apdev
):
941 check_mesh_support(dev
[0])
942 subprocess
.call(['iw', 'reg', 'set', 'US'])
945 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
947 raise Exception("No regdom change event")
948 if "alpha2=US" in ev
:
950 add_open_mesh_network(dev
[i
], freq
="5180")
952 check_mesh_joined_connected(dev
, connectivity
=True)
954 dev
[0].mesh_group_remove()
955 dev
[1].mesh_group_remove()
956 check_mesh_group_removed(dev
[0])
957 check_mesh_group_removed(dev
[1])
958 dev
[0].dump_monitor()
959 dev
[1].dump_monitor()
961 def test_wpas_mesh_open_5ghz_coex(dev
, apdev
):
962 """Mesh network on 5 GHz band and 20/40 coex change"""
964 _test_wpas_mesh_open_5ghz_coex(dev
, apdev
)
966 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
967 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
968 set_world_reg(apdev0
=apdev
[0], dev0
=dev
[0])
969 dev
[0].flush_scan_cache()
970 dev
[1].flush_scan_cache()
972 def _test_wpas_mesh_open_5ghz_coex(dev
, apdev
):
973 check_mesh_support(dev
[0])
974 subprocess
.call(['iw', 'reg', 'set', 'US'])
976 # Start a 20 MHz BSS on channel 40 that would be the secondary channel of
977 # HT40+ mesh on channel 36.
978 params
= {"ssid": "test-ht40",
981 "country_code": "US"}
982 hapd
= hostapd
.add_ap(apdev
[0], params
)
983 bssid
= hapd
.own_addr()
987 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
989 raise Exception("No regdom change event")
990 if "alpha2=US" in ev
:
992 dev
[i
].scan_for_bss(bssid
, freq
=5200)
993 add_open_mesh_network(dev
[i
], freq
="5180")
995 check_mesh_joined_connected(dev
)
997 freq
= dev
[0].get_status_field("freq")
999 raise Exception("Unexpected STATUS freq=" + freq
)
1000 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1001 if "FREQUENCY=5200" not in sig
:
1002 raise Exception("Unexpected SIGNAL_POLL output: " + str(sig
))
1005 dev
[0].mesh_group_remove()
1006 dev
[1].mesh_group_remove()
1007 check_mesh_group_removed(dev
[0])
1008 check_mesh_group_removed(dev
[1])
1009 dev
[0].dump_monitor()
1010 dev
[1].dump_monitor()
1012 def test_wpas_mesh_open_ht40(dev
, apdev
):
1013 """Mesh and HT40 support difference"""
1015 _test_wpas_mesh_open_ht40(dev
, apdev
)
1017 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
1018 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
1019 dev
[2].request("MESH_GROUP_REMOVE " + dev
[2].ifname
)
1020 subprocess
.call(['iw', 'reg', 'set', '00'])
1021 dev
[0].flush_scan_cache()
1022 dev
[1].flush_scan_cache()
1023 dev
[2].flush_scan_cache()
1025 def _test_wpas_mesh_open_ht40(dev
, apdev
):
1026 check_mesh_support(dev
[0])
1027 subprocess
.call(['iw', 'reg', 'set', 'US'])
1030 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
1032 raise Exception("No regdom change event")
1033 if "alpha2=US" in ev
:
1035 add_open_mesh_network(dev
[i
], freq
="5180", disable_vht
=True,
1036 disable_ht40
=(i
== 2))
1038 check_mesh_group_added(dev
[0])
1039 check_mesh_group_added(dev
[1])
1040 check_mesh_group_added(dev
[2])
1042 check_mesh_peer_connected(dev
[0])
1043 check_mesh_peer_connected(dev
[1])
1044 check_mesh_peer_connected(dev
[2])
1046 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1047 hwsim_utils
.test_connectivity(dev
[0], dev
[2])
1048 hwsim_utils
.test_connectivity(dev
[1], dev
[2])
1050 dev
[0].mesh_group_remove()
1051 dev
[1].mesh_group_remove()
1052 dev
[2].mesh_group_remove()
1053 check_mesh_group_removed(dev
[0])
1054 check_mesh_group_removed(dev
[1])
1055 check_mesh_group_removed(dev
[2])
1056 dev
[0].dump_monitor()
1057 dev
[1].dump_monitor()
1058 dev
[2].dump_monitor()
1060 def test_wpas_mesh_open_vht40(dev
, apdev
):
1061 """wpa_supplicant open MESH network on VHT 40 MHz channel"""
1063 _test_wpas_mesh_open_vht40(dev
, apdev
)
1065 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
1066 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
1067 subprocess
.call(['iw', 'reg', 'set', '00'])
1068 dev
[0].flush_scan_cache()
1069 dev
[1].flush_scan_cache()
1071 def _test_wpas_mesh_open_vht40(dev
, apdev
):
1072 check_mesh_support(dev
[0])
1073 subprocess
.call(['iw', 'reg', 'set', 'US'])
1076 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
1078 raise Exception("No regdom change event")
1079 if "alpha2=US" in ev
:
1081 add_open_mesh_network(dev
[i
], freq
="5180", chwidth
=0)
1083 check_mesh_joined_connected(dev
, connectivity
=True)
1085 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1086 if "WIDTH=40 MHz" not in sig
:
1087 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1088 if "CENTER_FRQ1=5190" not in sig
:
1089 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1091 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
1092 if "WIDTH=40 MHz" not in sig
:
1093 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig
))
1094 if "CENTER_FRQ1=5190" not in sig
:
1095 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig
))
1097 dev
[0].mesh_group_remove()
1098 dev
[1].mesh_group_remove()
1099 check_mesh_group_removed(dev
[0])
1100 check_mesh_group_removed(dev
[1])
1101 dev
[0].dump_monitor()
1102 dev
[1].dump_monitor()
1104 def test_wpas_mesh_open_vht20(dev
, apdev
):
1105 """wpa_supplicant open MESH network on VHT 20 MHz channel"""
1107 _test_wpas_mesh_open_vht20(dev
, apdev
)
1109 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
1110 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
1111 subprocess
.call(['iw', 'reg', 'set', '00'])
1112 dev
[0].flush_scan_cache()
1113 dev
[1].flush_scan_cache()
1115 def _test_wpas_mesh_open_vht20(dev
, apdev
):
1116 check_mesh_support(dev
[0])
1117 subprocess
.call(['iw', 'reg', 'set', 'US'])
1120 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
1122 raise Exception("No regdom change event")
1123 if "alpha2=US" in ev
:
1125 add_open_mesh_network(dev
[i
], freq
="5180", chwidth
=0, disable_ht40
=True)
1127 check_mesh_joined_connected(dev
, connectivity
=True)
1129 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1130 if "WIDTH=20 MHz" not in sig
:
1131 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1132 if "CENTER_FRQ1=5180" not in sig
:
1133 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1135 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
1136 if "WIDTH=20 MHz" not in sig
:
1137 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig
))
1138 if "CENTER_FRQ1=5180" not in sig
:
1139 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig
))
1141 dev
[0].mesh_group_remove()
1142 dev
[1].mesh_group_remove()
1143 check_mesh_group_removed(dev
[0])
1144 check_mesh_group_removed(dev
[1])
1145 dev
[0].dump_monitor()
1146 dev
[1].dump_monitor()
1148 def test_wpas_mesh_open_vht_80p80(dev
, apdev
):
1149 """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
1151 _test_wpas_mesh_open_vht_80p80(dev
, apdev
)
1153 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
1154 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
1155 subprocess
.call(['iw', 'reg', 'set', '00'])
1156 dev
[0].flush_scan_cache()
1157 dev
[1].flush_scan_cache()
1159 def _test_wpas_mesh_open_vht_80p80(dev
, apdev
):
1160 check_mesh_support(dev
[0])
1161 subprocess
.call(['iw', 'reg', 'set', 'US'])
1164 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
1166 raise Exception("No regdom change event")
1167 if "alpha2=US" in ev
:
1169 add_open_mesh_network(dev
[i
], freq
="5180", chwidth
=3)
1171 check_mesh_joined_connected(dev
, connectivity
=True)
1173 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1174 if "WIDTH=80+80 MHz" not in sig
:
1175 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1176 if "CENTER_FRQ1=5210" not in sig
:
1177 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1178 if "CENTER_FRQ2=5775" not in sig
:
1179 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
1181 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
1182 if "WIDTH=80+80 MHz" not in sig
:
1183 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig
))
1184 if "CENTER_FRQ1=5210" not in sig
:
1185 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig
))
1186 if "CENTER_FRQ2=5775" not in sig
:
1187 raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig
))
1189 dev
[0].mesh_group_remove()
1190 dev
[1].mesh_group_remove()
1191 check_mesh_group_removed(dev
[0])
1192 check_mesh_group_removed(dev
[1])
1193 dev
[0].dump_monitor()
1194 dev
[1].dump_monitor()
1196 def test_mesh_open_vht_160(dev
, apdev
):
1197 """Open mesh network on VHT 160 MHz channel"""
1199 _test_mesh_open_vht_160(dev
, apdev
)
1201 dev
[0].request("MESH_GROUP_REMOVE " + dev
[0].ifname
)
1202 dev
[1].request("MESH_GROUP_REMOVE " + dev
[1].ifname
)
1203 subprocess
.call(['iw', 'reg', 'set', '00'])
1204 dev
[0].flush_scan_cache()
1205 dev
[1].flush_scan_cache()
1207 def _test_mesh_open_vht_160(dev
, apdev
):
1208 check_mesh_support(dev
[0])
1209 subprocess
.call(['iw', 'reg', 'set', 'ZA'])
1212 ev
= dev
[i
].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=5)
1214 raise Exception("No regdom change event")
1215 if "alpha2=ZA" in ev
:
1218 cmd
= subprocess
.Popen(["iw", "reg", "get"], stdout
=subprocess
.PIPE
)
1219 reg
= cmd
.stdout
.read()
1221 for entry
in reg
.splitlines():
1222 entry
= entry
.decode()
1223 if "@ 160)" in entry
and "DFS" not in entry
:
1227 raise HwsimSkip("160 MHz channel without DFS not supported in regulatory information")
1229 add_open_mesh_network(dev
[i
], freq
="5520", chwidth
=2)
1231 check_mesh_joined_connected(dev
, connectivity
=True)
1232 dev
[0].dump_monitor()
1233 dev
[1].dump_monitor()
1235 sig
= dev
[0].request("SIGNAL_POLL").splitlines()
1236 if "WIDTH=160 MHz" not in sig
:
1237 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1238 if "FREQUENCY=5520" not in sig
:
1239 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1241 sig
= dev
[1].request("SIGNAL_POLL").splitlines()
1242 if "WIDTH=160 MHz" not in sig
:
1243 raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig
))
1244 if "FREQUENCY=5520" not in sig
:
1245 raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig
))
1247 dev
[0].mesh_group_remove()
1248 dev
[1].mesh_group_remove()
1249 check_mesh_group_removed(dev
[0])
1250 check_mesh_group_removed(dev
[1])
1251 dev
[0].dump_monitor()
1252 dev
[1].dump_monitor()
1254 def test_wpas_mesh_password_mismatch(dev
, apdev
):
1255 """Mesh network and one device with mismatching password"""
1256 check_mesh_support(dev
[0], secure
=True)
1257 dev
[0].request("SET sae_groups ")
1258 id = add_mesh_secure_net(dev
[0])
1259 dev
[0].mesh_group_add(id)
1261 dev
[1].request("SET sae_groups ")
1262 id = add_mesh_secure_net(dev
[1])
1263 dev
[1].mesh_group_add(id)
1265 dev
[2].request("SET sae_groups ")
1266 id = add_mesh_secure_net(dev
[2])
1267 dev
[2].set_network_quoted(id, "psk", "wrong password")
1268 dev
[2].mesh_group_add(id)
1270 # The two peers with matching password need to be able to connect
1271 check_mesh_joined_connected(dev
)
1273 ev
= dev
[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
1275 raise Exception("dev2 did not report auth failure (1)")
1276 ev
= dev
[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
1278 raise Exception("dev2 did not report auth failure (2)")
1279 dev
[2].dump_monitor()
1282 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=5)
1284 logger
.info("dev0 did not report auth failure")
1286 if "addr=" + dev
[2].own_addr() not in ev
:
1287 raise Exception("Unexpected peer address in dev0 event: " + ev
)
1289 dev
[0].dump_monitor()
1291 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=5)
1293 logger
.info("dev1 did not report auth failure")
1295 if "addr=" + dev
[2].own_addr() not in ev
:
1296 raise Exception("Unexpected peer address in dev1 event: " + ev
)
1298 dev
[1].dump_monitor()
1300 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1304 hwsim_utils
.test_connectivity(dev
[i
], dev
[2], timeout
=1)
1305 raise Exception("Data connectivity test passed unexpectedly")
1306 except Exception as e
:
1307 if "data delivery failed" not in str(e
):
1311 raise Exception("Neither dev0 nor dev1 reported auth failure")
1313 def test_wpas_mesh_password_mismatch_retry(dev
, apdev
, params
):
1314 """Mesh password mismatch and retry [long]"""
1315 if not params
['long']:
1316 raise HwsimSkip("Skip test case with long duration due to --long not specified")
1317 check_mesh_support(dev
[0], secure
=True)
1318 dev
[0].request("SET sae_groups ")
1319 id = add_mesh_secure_net(dev
[0])
1320 dev
[0].mesh_group_add(id)
1322 dev
[1].request("SET sae_groups ")
1323 id = add_mesh_secure_net(dev
[1])
1324 dev
[1].set_network_quoted(id, "psk", "wrong password")
1325 dev
[1].mesh_group_add(id)
1327 check_mesh_joined2(dev
)
1330 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
1332 raise Exception("dev0 did not report auth failure (%d)" % i
)
1333 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout
=20)
1335 raise Exception("dev1 did not report auth failure (%d)" % i
)
1337 ev
= dev
[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout
=10)
1339 raise Exception("dev0 did not report auth blocked")
1340 ev
= dev
[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout
=10)
1342 raise Exception("dev1 did not report auth blocked")
1344 def test_mesh_wpa_auth_init_oom(dev
, apdev
):
1345 """Secure mesh network setup failing due to wpa_init() OOM"""
1346 check_mesh_support(dev
[0], secure
=True)
1347 dev
[0].request("SET sae_groups ")
1348 with
alloc_fail(dev
[0], 1, "wpa_init"):
1349 id = add_mesh_secure_net(dev
[0])
1350 dev
[0].mesh_group_add(id)
1351 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED"], timeout
=0.2)
1353 raise Exception("Unexpected mesh group start during OOM")
1355 def test_mesh_wpa_init_fail(dev
, apdev
):
1356 """Secure mesh network setup local failure"""
1357 check_mesh_support(dev
[0], secure
=True)
1358 check_mesh_support(dev
[1], secure
=True)
1359 check_mesh_support(dev
[2], secure
=True)
1360 dev
[0].request("SET sae_groups ")
1362 with
fail_test(dev
[0], 1, "os_get_random;=__mesh_rsn_auth_init"):
1363 id = add_mesh_secure_net(dev
[0])
1364 dev
[0].mesh_group_add(id)
1365 wait_fail_trigger(dev
[0], "GET_FAIL")
1367 dev
[0].dump_monitor()
1368 with
alloc_fail(dev
[0], 1, "mesh_rsn_auth_init"):
1369 id = add_mesh_secure_net(dev
[0])
1370 dev
[0].mesh_group_add(id)
1371 wait_fail_trigger(dev
[0], "GET_ALLOC_FAIL")
1373 dev
[0].dump_monitor()
1374 with
fail_test(dev
[0], 1, "os_get_random;mesh_rsn_init_ampe_sta"):
1375 id = add_mesh_secure_net(dev
[0])
1376 dev
[0].mesh_group_add(id)
1377 dev
[1].request("SET sae_groups ")
1378 id = add_mesh_secure_net(dev
[1])
1379 dev
[1].mesh_group_add(id)
1380 wait_fail_trigger(dev
[0], "GET_FAIL")
1382 with
fail_test(dev
[0], 2, "=omac1_aes_vector;aes_siv_encrypt"):
1383 id = add_mesh_secure_net(dev
[2])
1384 dev
[0].mesh_group_add(id)
1385 dev
[2].request("SET sae_groups ")
1386 id = add_mesh_secure_net(dev
[2])
1387 dev
[2].mesh_group_add(id)
1388 wait_fail_trigger(dev
[0], "GET_FAIL")
1390 def test_wpas_mesh_reconnect(dev
, apdev
):
1391 """Secure mesh network plink counting during reconnection"""
1392 check_mesh_support(dev
[0])
1394 _test_wpas_mesh_reconnect(dev
)
1396 dev
[0].request("SET max_peer_links 99")
1398 def _test_wpas_mesh_reconnect(dev
):
1399 dev
[0].request("SET max_peer_links 2")
1400 dev
[0].request("SET sae_groups ")
1401 id = add_mesh_secure_net(dev
[0])
1402 dev
[0].set_network(id, "beacon_int", "100")
1403 dev
[0].mesh_group_add(id)
1404 dev
[1].request("SET sae_groups ")
1405 id = add_mesh_secure_net(dev
[1])
1406 dev
[1].mesh_group_add(id)
1407 check_mesh_joined_connected(dev
)
1410 # Drop incoming management frames to avoid handling link close
1411 dev
[0].request("SET ext_mgmt_frame_handling 1")
1412 dev
[1].mesh_group_remove()
1413 check_mesh_group_removed(dev
[1])
1414 dev
[1].request("FLUSH")
1415 dev
[0].request("SET ext_mgmt_frame_handling 0")
1416 id = add_mesh_secure_net(dev
[1])
1417 dev
[1].mesh_group_add(id)
1418 check_mesh_group_added(dev
[1])
1419 check_mesh_peer_connected(dev
[1])
1420 dev
[0].dump_monitor()
1421 dev
[1].dump_monitor()
1423 def test_wpas_mesh_gate_forwarding(dev
, apdev
, p
):
1424 """Mesh forwards traffic to unknown sta to mesh gates"""
1425 addr0
= dev
[0].own_addr()
1426 addr1
= dev
[1].own_addr()
1427 addr2
= dev
[2].own_addr()
1428 external_sta
= '02:11:22:33:44:55'
1430 # start 3 node connected mesh
1431 check_mesh_support(dev
[0])
1433 add_open_mesh_network(dev
[i
])
1434 check_mesh_group_added(dev
[i
])
1436 check_mesh_peer_connected(dev
[i
])
1438 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1439 hwsim_utils
.test_connectivity(dev
[1], dev
[2])
1440 hwsim_utils
.test_connectivity(dev
[0], dev
[2])
1442 # dev0 and dev1 are mesh gates
1443 subprocess
.call(['iw', 'dev', dev
[0].ifname
, 'set', 'mesh_param',
1444 'mesh_gate_announcements=1'])
1445 subprocess
.call(['iw', 'dev', dev
[1].ifname
, 'set', 'mesh_param',
1446 'mesh_gate_announcements=1'])
1448 # wait for gate announcement frames
1451 # data frame from dev2 -> external sta should be sent to both gates
1452 dev
[2].request("DATA_TEST_CONFIG 1")
1453 dev
[2].request("DATA_TEST_TX {} {} 0".format(external_sta
, addr2
))
1454 dev
[2].request("DATA_TEST_CONFIG 0")
1456 capfile
= os
.path
.join(p
['logdir'], "hwsim0.pcapng")
1457 filt
= "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2
,
1461 da
= run_tshark(capfile
, filt
, ["wlan.da"])
1462 if addr0
in da
and addr1
in da
:
1463 logger
.debug("Frames seen in tshark iteration %d" % i
)
1467 if addr0
not in da
and addr1
not in da
:
1468 filt
= "wlan.sa==%s" % addr2
1469 mesh
= run_tshark(capfile
, filt
, ["wlan.mesh.control_field"])
1471 # Wireshark regression in mesh control field parsing:
1472 # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=15521
1473 raise HwsimSkip("tshark bug 15521")
1475 raise Exception("Frame to gate %s not observed" % addr0
)
1477 raise Exception("Frame to gate %s not observed" % addr1
)
1479 def test_wpas_mesh_pmksa_caching(dev
, apdev
):
1480 """Secure mesh network and PMKSA caching"""
1481 check_mesh_support(dev
[0], secure
=True)
1482 dev
[0].request("SET sae_groups ")
1483 id = add_mesh_secure_net(dev
[0])
1484 dev
[0].mesh_group_add(id)
1486 dev
[1].request("SET sae_groups ")
1487 id = add_mesh_secure_net(dev
[1])
1488 dev
[1].mesh_group_add(id)
1490 check_mesh_joined_connected(dev
)
1492 addr0
= dev
[0].own_addr()
1493 addr1
= dev
[1].own_addr()
1494 pmksa0
= dev
[0].get_pmksa(addr1
)
1495 pmksa1
= dev
[1].get_pmksa(addr0
)
1496 if pmksa0
is None or pmksa1
is None:
1497 raise Exception("No PMKSA cache entry created")
1498 if pmksa0
['pmkid'] != pmksa1
['pmkid']:
1499 raise Exception("PMKID mismatch in PMKSA cache entries")
1501 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
1502 raise Exception("Failed to remove peer")
1503 pmksa0b
= dev
[0].get_pmksa(addr1
)
1505 raise Exception("PMKSA cache entry not maintained")
1508 if "FAIL" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1509 raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
1511 def test_wpas_mesh_pmksa_caching2(dev
, apdev
):
1512 """Secure mesh network and PMKSA caching with no_auto_peer=1"""
1513 check_mesh_support(dev
[0], secure
=True)
1514 addr0
= dev
[0].own_addr()
1515 addr1
= dev
[1].own_addr()
1516 dev
[0].request("SET sae_groups ")
1517 id = add_mesh_secure_net(dev
[0])
1518 dev
[0].set_network(id, "no_auto_peer", "1")
1519 dev
[0].mesh_group_add(id)
1521 dev
[1].request("SET sae_groups ")
1522 id = add_mesh_secure_net(dev
[1])
1523 dev
[1].set_network(id, "no_auto_peer", "1")
1524 dev
[1].mesh_group_add(id)
1526 check_mesh_joined2(dev
)
1528 # Check for peer connected
1529 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1531 raise Exception("Missing no-initiate message")
1532 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1533 raise Exception("MESH_PEER_ADD failed")
1534 check_mesh_connected2(dev
)
1536 pmksa0
= dev
[0].get_pmksa(addr1
)
1537 pmksa1
= dev
[1].get_pmksa(addr0
)
1538 if pmksa0
is None or pmksa1
is None:
1539 raise Exception("No PMKSA cache entry created")
1540 if pmksa0
['pmkid'] != pmksa1
['pmkid']:
1541 raise Exception("PMKID mismatch in PMKSA cache entries")
1543 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
1544 raise Exception("Failed to remove peer")
1545 pmksa0b
= dev
[0].get_pmksa(addr1
)
1547 raise Exception("PMKSA cache entry not maintained")
1549 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1551 raise Exception("Missing no-initiate message (2)")
1552 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1553 raise Exception("MESH_PEER_ADD failed (2)")
1554 check_mesh_connected2(dev
)
1556 pmksa0c
= dev
[0].get_pmksa(addr1
)
1557 pmksa1c
= dev
[1].get_pmksa(addr0
)
1558 if pmksa0c
is None or pmksa1c
is None:
1559 raise Exception("No PMKSA cache entry created (2)")
1560 if pmksa0c
['pmkid'] != pmksa1c
['pmkid']:
1561 raise Exception("PMKID mismatch in PMKSA cache entries")
1562 if pmksa0
['pmkid'] != pmksa0c
['pmkid']:
1563 raise Exception("PMKID changed")
1565 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1567 def test_wpas_mesh_pmksa_caching_no_match(dev
, apdev
):
1568 """Secure mesh network and PMKSA caching with no PMKID match"""
1569 check_mesh_support(dev
[0], secure
=True)
1570 addr0
= dev
[0].own_addr()
1571 addr1
= dev
[1].own_addr()
1572 dev
[0].request("SET sae_groups ")
1573 id = add_mesh_secure_net(dev
[0])
1574 dev
[0].set_network(id, "no_auto_peer", "1")
1575 dev
[0].mesh_group_add(id)
1577 dev
[1].request("SET sae_groups ")
1578 id = add_mesh_secure_net(dev
[1])
1579 dev
[1].set_network(id, "no_auto_peer", "1")
1580 dev
[1].mesh_group_add(id)
1582 check_mesh_joined2(dev
)
1584 # Check for peer connected
1585 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1587 raise Exception("Missing no-initiate message")
1588 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1589 raise Exception("MESH_PEER_ADD failed")
1590 check_mesh_connected2(dev
)
1592 pmksa0
= dev
[0].get_pmksa(addr1
)
1593 pmksa1
= dev
[1].get_pmksa(addr0
)
1594 if pmksa0
is None or pmksa1
is None:
1595 raise Exception("No PMKSA cache entry created")
1596 if pmksa0
['pmkid'] != pmksa1
['pmkid']:
1597 raise Exception("PMKID mismatch in PMKSA cache entries")
1599 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
1600 raise Exception("Failed to remove peer")
1602 if "OK" not in dev
[1].request("PMKSA_FLUSH"):
1603 raise Exception("Failed to flush PMKSA cache")
1605 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1607 raise Exception("Missing no-initiate message (2)")
1608 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1609 raise Exception("MESH_PEER_ADD failed (2)")
1610 check_mesh_connected2(dev
)
1612 pmksa0c
= dev
[0].get_pmksa(addr1
)
1613 pmksa1c
= dev
[1].get_pmksa(addr0
)
1614 if pmksa0c
is None or pmksa1c
is None:
1615 raise Exception("No PMKSA cache entry created (2)")
1616 if pmksa0c
['pmkid'] != pmksa1c
['pmkid']:
1617 raise Exception("PMKID mismatch in PMKSA cache entries")
1618 if pmksa0
['pmkid'] == pmksa0c
['pmkid']:
1619 raise Exception("PMKID did not change")
1621 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1623 def test_mesh_pmksa_caching_oom(dev
, apdev
):
1624 """Secure mesh network and PMKSA caching failing due to OOM"""
1625 check_mesh_support(dev
[0], secure
=True)
1626 addr0
= dev
[0].own_addr()
1627 addr1
= dev
[1].own_addr()
1628 dev
[0].request("SET sae_groups ")
1629 id = add_mesh_secure_net(dev
[0])
1630 dev
[0].set_network(id, "no_auto_peer", "1")
1631 dev
[0].mesh_group_add(id)
1633 dev
[1].request("SET sae_groups ")
1634 id = add_mesh_secure_net(dev
[1])
1635 dev
[1].set_network(id, "no_auto_peer", "1")
1636 dev
[1].mesh_group_add(id)
1638 check_mesh_joined2(dev
)
1640 # Check for peer connected
1641 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1643 raise Exception("Missing no-initiate message")
1644 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1645 raise Exception("MESH_PEER_ADD failed")
1646 check_mesh_connected2(dev
)
1648 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
1649 raise Exception("Failed to remove peer")
1650 pmksa0b
= dev
[0].get_pmksa(addr1
)
1652 raise Exception("PMKSA cache entry not maintained")
1654 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
1656 raise Exception("Missing no-initiate message (2)")
1658 with
alloc_fail(dev
[0], 1, "wpa_auth_sta_init;mesh_rsn_auth_sae_sta"):
1659 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
1660 raise Exception("MESH_PEER_ADD failed (2)")
1661 wait_fail_trigger(dev
[0], "GET_ALLOC_FAIL")
1663 def test_wpas_mesh_pmksa_caching_ext(dev
, apdev
):
1664 """Secure mesh network and PMKSA caching and external storage"""
1665 check_mesh_support(dev
[0], secure
=True)
1666 dev
[0].request("SET sae_groups ")
1667 id = add_mesh_secure_net(dev
[0])
1668 dev
[0].mesh_group_add(id)
1670 dev
[1].request("SET sae_groups ")
1671 id = add_mesh_secure_net(dev
[1])
1672 dev
[1].mesh_group_add(id)
1674 check_mesh_joined_connected(dev
)
1675 dev
[0].dump_monitor()
1676 dev
[1].dump_monitor()
1678 addr0
= dev
[0].own_addr()
1679 addr1
= dev
[1].own_addr()
1680 pmksa0
= dev
[0].get_pmksa(addr1
)
1681 pmksa1
= dev
[1].get_pmksa(addr0
)
1682 if pmksa0
is None or pmksa1
is None:
1683 raise Exception("No PMKSA cache entry created")
1684 if pmksa0
['pmkid'] != pmksa1
['pmkid']:
1685 raise Exception("PMKID mismatch in PMKSA cache entries")
1687 res1
= dev
[1].request("MESH_PMKSA_GET any")
1688 res2
= dev
[1].request("MESH_PMKSA_GET " + addr0
)
1689 logger
.info("MESH_PMKSA_GET: " + res1
)
1690 if "UNKNOWN COMMAND" in res1
:
1691 raise HwsimSkip("MESH_PMKSA_GET not supported in the build")
1692 logger
.info("MESH_PMKSA_GET: " + res2
)
1693 if pmksa0
['pmkid'] not in res1
:
1694 raise Exception("PMKID not included in PMKSA entry")
1696 raise Exception("Unexpected difference in MESH_PMKSA_GET output")
1698 dev
[1].mesh_group_remove()
1699 check_mesh_group_removed(dev
[1])
1700 check_mesh_peer_disconnected(dev
[0])
1701 dev
[0].dump_monitor()
1702 dev
[1].dump_monitor()
1703 res
= dev
[1].get_pmksa(addr0
)
1705 raise Exception("Unexpected PMKSA cache entry remaining")
1708 if "OK" not in dev
[1].request("MESH_PMKSA_ADD " + res2
):
1709 raise Exception("MESH_PMKSA_ADD failed")
1710 dev
[1].mesh_group_add(id)
1711 check_mesh_group_added(dev
[1])
1712 check_mesh_peer_connected(dev
[1])
1713 check_mesh_peer_connected(dev
[0])
1715 dev
[0].dump_monitor()
1716 dev
[1].dump_monitor()
1717 pmksa1b
= dev
[1].get_pmksa(addr0
)
1719 raise Exception("No PMKSA cache entry created after external storage restore")
1720 if pmksa1
['pmkid'] != pmksa1b
['pmkid']:
1721 raise Exception("PMKID mismatch in PMKSA cache entries after external storage restore")
1723 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
1725 res
= dev
[1].request("MESH_PMKSA_GET foo")
1726 if "FAIL" not in res
:
1727 raise Exception("Invalid MESH_PMKSA_GET accepted")
1729 dev
[1].mesh_group_remove()
1730 check_mesh_group_removed(dev
[1])
1731 dev
[0].dump_monitor()
1732 dev
[1].dump_monitor()
1733 dev
[1].request("REMOVE_NETWORK all")
1734 res
= dev
[1].request("MESH_PMKSA_GET any")
1735 if "FAIL" not in res
:
1736 raise Exception("MESH_PMKSA_GET accepted when not in mesh")
1739 "02:02:02:02:02:02",
1740 "02:02:02:02:02:02 q",
1741 "02:02:02:02:02:02 c3d51a7ccfca0c6d5287291a7169d79b",
1742 "02:02:02:02:02:02 c3d51a7ccfca0c6d5287291a7169d79b q",
1743 "02:02:02:02:02:02 c3d51a7ccfca0c6d5287291a7169d79b 1bed4fa22ece7997ca1bdc8b829019fe63acac91cba3405522c24c91f7cfb49f",
1744 "02:02:02:02:02:02 c3d51a7ccfca0c6d5287291a7169d79b 1bed4fa22ece7997ca1bdc8b829019fe63acac91cba3405522c24c91f7cfb49f q"]
1746 if "FAIL" not in dev
[1].request("MESH_PMKSA_ADD " + t
):
1747 raise Exception("Invalid MESH_PMKSA_ADD accepted")
1749 def test_mesh_oom(dev
, apdev
):
1750 """Mesh network setup failing due to OOM"""
1751 check_mesh_support(dev
[0], secure
=True)
1752 dev
[0].request("SET sae_groups ")
1754 with
alloc_fail(dev
[0], 1, "mesh_config_create"):
1755 add_open_mesh_network(dev
[0])
1756 ev
= dev
[0].wait_event(["Failed to init mesh"])
1758 raise Exception("Init failure not reported")
1760 with
alloc_fail(dev
[0], 2, "=wpa_supplicant_mesh_init"):
1761 add_open_mesh_network(dev
[0], basic_rates
="60 120 240")
1762 ev
= dev
[0].wait_event(["Failed to init mesh"])
1764 raise Exception("Init failure not reported")
1766 for i
in range(1, 66):
1767 dev
[0].dump_monitor()
1768 logger
.info("Test instance %d" % i
)
1770 with
alloc_fail(dev
[0], i
, "wpa_supplicant_mesh_init"):
1771 add_open_mesh_network(dev
[0])
1772 wait_fail_trigger(dev
[0], "GET_ALLOC_FAIL")
1773 ev
= dev
[0].wait_event(["Failed to init mesh",
1774 "MESH-GROUP-STARTED"])
1776 raise Exception("Init failure not reported")
1777 except Exception as e
:
1780 logger
.info("Ignore no-oom for i=%d" % i
)
1782 with
alloc_fail(dev
[0], 2, "=wpa_supplicant_mesh_init"):
1783 id = add_mesh_secure_net(dev
[0])
1784 dev
[0].mesh_group_add(id)
1785 ev
= dev
[0].wait_event(["Failed to init mesh"])
1787 raise Exception("Init failure not reported")
1789 def test_mesh_add_interface_oom(dev
):
1790 """wpa_supplicant mesh with dynamic interface addition failing"""
1791 check_mesh_support(dev
[0])
1792 for i
in range(1, 3):
1795 with
alloc_fail(dev
[0], i
, "wpas_mesh_add_interface"):
1796 mesh
= dev
[0].request("MESH_INTERFACE_ADD").strip()
1798 if mesh
and mesh
!= "FAIL":
1799 dev
[0].request("MESH_GROUP_REMOVE " + mesh
)
1801 def test_mesh_scan_oom(dev
):
1802 """wpa_supplicant mesh scan results and OOM"""
1803 check_mesh_support(dev
[0])
1804 add_open_mesh_network(dev
[0])
1805 check_mesh_group_added(dev
[0])
1807 dev
[1].scan(freq
="2412")
1808 res
= dev
[1].request("SCAN_RESULTS")
1811 for r
in res
.splitlines():
1814 bssid
= r
.split('\t')[0]
1816 bss
= dev
[1].get_bss(bssid
)
1818 raise Exception("Could not get BSS entry for mesh")
1820 for i
in range(1, 3):
1821 with
alloc_fail(dev
[1], i
, "mesh_attr_text"):
1822 bss
= dev
[1].get_bss(bssid
)
1823 if bss
and "mesh_id" in bss
:
1824 raise Exception("Unexpected BSS result during OOM")
1826 def test_mesh_drv_fail(dev
, apdev
):
1827 """Mesh network setup failing due to driver command failure"""
1828 check_mesh_support(dev
[0], secure
=True)
1829 dev
[0].request("SET sae_groups ")
1831 with
fail_test(dev
[0], 1, "nl80211_join_mesh"):
1832 add_open_mesh_network(dev
[0])
1833 ev
= dev
[0].wait_event(["mesh join error"])
1835 raise Exception("Join failure not reported")
1837 dev
[0].dump_monitor()
1838 with
fail_test(dev
[0], 1, "wpa_driver_nl80211_if_add"):
1839 if "FAIL" not in dev
[0].request("MESH_INTERFACE_ADD").strip():
1840 raise Exception("Interface added unexpectedly")
1842 dev
[0].dump_monitor()
1843 with
fail_test(dev
[0], 1, "wpa_driver_nl80211_init_mesh"):
1844 add_open_mesh_network(dev
[0])
1845 ev
= dev
[0].wait_event(["Could not join mesh"])
1847 raise Exception("Join failure not reported")
1849 def test_mesh_sae_groups_invalid(dev
, apdev
):
1850 """Mesh with invalid SAE group configuration"""
1851 check_mesh_support(dev
[0], secure
=True)
1853 dev
[0].request("SET sae_groups 26")
1854 id = add_mesh_secure_net(dev
[0])
1855 dev
[0].mesh_group_add(id)
1857 dev
[1].request("SET sae_groups 123 122 121")
1858 id = add_mesh_secure_net(dev
[1])
1859 dev
[1].mesh_group_add(id)
1861 check_mesh_joined2(dev
)
1863 ev
= dev
[0].wait_event(["new peer notification"], timeout
=10)
1865 raise Exception("dev[0] did not see peer")
1866 ev
= dev
[1].wait_event(["new peer notification"], timeout
=10)
1868 raise Exception("dev[1] did not see peer")
1870 ev
= dev
[0].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
1872 raise Exception("Unexpected connection(0)")
1874 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
1876 raise Exception("Unexpected connection(1)")
1878 # Additional coverage in mesh_rsn_sae_group() with non-zero
1879 # wpa_s->mesh_rsn->sae_group_index.
1880 dev
[0].dump_monitor()
1881 dev
[1].dump_monitor()
1882 dev
[2].request("SET sae_groups ")
1883 id = add_mesh_secure_net(dev
[2])
1884 dev
[2].mesh_group_add(id)
1885 check_mesh_group_added(dev
[2])
1886 check_mesh_peer_connected(dev
[0])
1887 check_mesh_peer_connected(dev
[2])
1888 ev
= dev
[1].wait_event(["new peer notification"], timeout
=10)
1890 raise Exception("dev[1] did not see peer(2)")
1891 dev
[0].dump_monitor()
1892 dev
[1].dump_monitor()
1893 dev
[2].dump_monitor()
1895 dev
[0].request("SET sae_groups ")
1896 dev
[1].request("SET sae_groups ")
1897 dev
[2].request("SET sae_groups ")
1899 def test_mesh_sae_failure(dev
, apdev
):
1900 """Mesh and local SAE failures"""
1901 check_mesh_support(dev
[0], secure
=True)
1903 dev
[0].request("SET sae_groups ")
1904 dev
[1].request("SET sae_groups ")
1906 funcs
= [(1, "=mesh_rsn_auth_sae_sta", True),
1907 (1, "mesh_rsn_build_sae_commit;mesh_rsn_auth_sae_sta", False),
1908 (1, "auth_sae_init_committed;mesh_rsn_auth_sae_sta", True),
1909 (1, "=mesh_rsn_protect_frame", True),
1910 (2, "=mesh_rsn_protect_frame", True),
1911 (1, "aes_siv_encrypt;mesh_rsn_protect_frame", True),
1912 (1, "=mesh_rsn_process_ampe", True),
1913 (1, "aes_siv_decrypt;mesh_rsn_process_ampe", True)]
1914 for count
, func
, success
in funcs
:
1915 id = add_mesh_secure_net(dev
[0])
1916 dev
[0].mesh_group_add(id)
1918 with
alloc_fail(dev
[1], count
, func
):
1919 id = add_mesh_secure_net(dev
[1])
1920 dev
[1].mesh_group_add(id)
1921 check_mesh_joined2(dev
)
1923 # retry is expected to work
1924 check_mesh_connected2(dev
)
1926 wait_fail_trigger(dev
[1], "GET_ALLOC_FAIL")
1927 dev
[0].mesh_group_remove()
1928 dev
[1].mesh_group_remove()
1929 check_mesh_group_removed(dev
[0])
1930 check_mesh_group_removed(dev
[1])
1932 def test_mesh_failure(dev
, apdev
):
1933 """Mesh and local failures"""
1934 check_mesh_support(dev
[0])
1936 funcs
= [(1, "ap_sta_add;mesh_mpm_add_peer", True),
1937 (1, "wpabuf_alloc;mesh_mpm_send_plink_action", True)]
1938 for count
, func
, success
in funcs
:
1939 add_open_mesh_network(dev
[0])
1941 with
alloc_fail(dev
[1], count
, func
):
1942 add_open_mesh_network(dev
[1])
1943 check_mesh_joined2(dev
)
1945 # retry is expected to work
1946 check_mesh_connected2(dev
)
1948 wait_fail_trigger(dev
[1], "GET_ALLOC_FAIL")
1949 dev
[0].mesh_group_remove()
1950 dev
[1].mesh_group_remove()
1951 check_mesh_group_removed(dev
[0])
1952 check_mesh_group_removed(dev
[1])
1954 funcs
= [(1, "mesh_mpm_init_link", True)]
1955 for count
, func
, success
in funcs
:
1956 add_open_mesh_network(dev
[0])
1958 with
fail_test(dev
[1], count
, func
):
1959 add_open_mesh_network(dev
[1])
1960 check_mesh_joined2(dev
)
1962 # retry is expected to work
1963 check_mesh_connected2(dev
)
1965 wait_fail_trigger(dev
[1], "GET_FAIL")
1966 dev
[0].mesh_group_remove()
1967 dev
[1].mesh_group_remove()
1968 check_mesh_group_removed(dev
[0])
1969 check_mesh_group_removed(dev
[1])
1971 def test_mesh_invalid_frequency(dev
, apdev
):
1972 """Mesh and invalid frequency configuration"""
1973 check_mesh_support(dev
[0])
1974 add_open_mesh_network(dev
[0], freq
=None)
1975 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED",
1976 "Could not join mesh"])
1977 if ev
is None or "Could not join mesh" not in ev
:
1978 raise Exception("Mesh join failure not reported")
1979 dev
[0].request("REMOVE_NETWORK all")
1981 add_open_mesh_network(dev
[0], freq
="2413")
1982 ev
= dev
[0].wait_event(["MESH-GROUP-STARTED",
1983 "Could not join mesh"])
1984 if ev
is None or "Could not join mesh" not in ev
:
1985 raise Exception("Mesh join failure not reported")
1987 def test_mesh_default_beacon_int(dev
, apdev
):
1988 """Mesh and default beacon interval"""
1989 check_mesh_support(dev
[0])
1991 dev
[0].request("SET beacon_int 200")
1992 add_open_mesh_network(dev
[0])
1993 check_mesh_group_added(dev
[0])
1995 dev
[0].request("SET beacon_int 0")
1997 def test_mesh_scan_parse_error(dev
, apdev
):
1998 """Mesh scan element parse error"""
1999 check_mesh_support(dev
[0])
2000 params
= {"ssid": "open",
2001 "beacon_int": "2000"}
2002 hapd
= hostapd
.add_ap(apdev
[0], params
)
2003 bssid
= apdev
[0]['bssid']
2004 hapd
.set('vendor_elements', 'dd0201')
2006 dev
[0].scan(freq
=2412)
2007 if bssid
in dev
[0].request("SCAN_RESULTS"):
2009 # This will fail in IE parsing due to the truncated IE in the Probe
2011 bss
= dev
[0].request("BSS " + bssid
)
2013 def test_mesh_missing_mic(dev
, apdev
):
2014 """Secure mesh network and missing MIC"""
2015 check_mesh_support(dev
[0], secure
=True)
2017 dev
[0].request("SET ext_mgmt_frame_handling 1")
2018 dev
[0].request("SET sae_groups ")
2019 id = add_mesh_secure_net(dev
[0])
2020 dev
[0].mesh_group_add(id)
2022 dev
[1].request("SET sae_groups ")
2023 id = add_mesh_secure_net(dev
[1])
2024 dev
[1].mesh_group_add(id)
2026 check_mesh_joined2(dev
)
2033 raise Exception("Did not see Action frames")
2034 rx_msg
= dev
[0].mgmt_rx()
2036 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
2039 raise Exception("MGMT-RX timeout")
2040 if rx_msg
['subtype'] == 13:
2041 payload
= rx_msg
['payload']
2042 frame
= rx_msg
['frame']
2043 (categ
, action
) = struct
.unpack('BB', payload
[0:2])
2044 if categ
== 15 and action
== 1 and remove_mic
:
2046 pos
= frame
.find(b
'\x8c\x10')
2048 raise Exception("Could not find MIC element")
2049 logger
.info("Found MIC at %d" % pos
)
2051 rx_msg
['frame'] = frame
[0:pos
]
2053 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
2054 rx_msg
['freq'], rx_msg
['datarate'], rx_msg
['ssi_signal'], binascii
.hexlify(rx_msg
['frame']).decode())):
2055 raise Exception("MGMT_RX_PROCESS failed")
2056 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
2060 def test_mesh_pmkid_mismatch(dev
, apdev
):
2061 """Secure mesh network and PMKID mismatch"""
2062 check_mesh_support(dev
[0], secure
=True)
2063 addr0
= dev
[0].own_addr()
2064 addr1
= dev
[1].own_addr()
2065 dev
[0].request("SET sae_groups ")
2066 id = add_mesh_secure_net(dev
[0])
2067 dev
[0].set_network(id, "no_auto_peer", "1")
2068 dev
[0].mesh_group_add(id)
2070 dev
[1].request("SET sae_groups ")
2071 id = add_mesh_secure_net(dev
[1])
2072 dev
[1].set_network(id, "no_auto_peer", "1")
2073 dev
[1].mesh_group_add(id)
2075 check_mesh_joined2(dev
)
2077 # Check for peer connected
2078 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
2080 raise Exception("Missing no-initiate message")
2081 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
2082 raise Exception("MESH_PEER_ADD failed")
2083 check_mesh_connected2(dev
)
2085 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
2086 raise Exception("Failed to remove peer")
2088 ev
= dev
[0].wait_event(["will not initiate new peer link"], timeout
=10)
2090 raise Exception("Missing no-initiate message (2)")
2091 dev
[0].dump_monitor()
2092 dev
[1].dump_monitor()
2093 dev
[0].request("SET ext_mgmt_frame_handling 1")
2094 if "OK" not in dev
[0].request("MESH_PEER_ADD " + addr1
):
2095 raise Exception("MESH_PEER_ADD failed (2)")
2102 raise Exception("Did not see Action frames")
2103 rx_msg
= dev
[0].mgmt_rx()
2105 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.1)
2108 raise Exception("MGMT-RX timeout")
2109 if rx_msg
['subtype'] == 13:
2110 payload
= rx_msg
['payload']
2111 frame
= rx_msg
['frame']
2112 (categ
, action
) = struct
.unpack('BB', payload
[0:2])
2113 if categ
== 15 and action
== 1 and break_pmkid
:
2115 pos
= frame
.find(b
'\x75\x14')
2117 raise Exception("Could not find Mesh Peering Management element")
2118 logger
.info("Found Mesh Peering Management element at %d" % pos
)
2119 # Break PMKID to hit "Mesh RSN: Invalid PMKID (Chosen PMK did
2120 # not match calculated PMKID)"
2121 rx_msg
['frame'] = frame
[0:pos
+ 6] + b
'\x00\x00\x00\x00' + frame
[pos
+ 10:]
2123 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
2124 rx_msg
['freq'], rx_msg
['datarate'], rx_msg
['ssi_signal'], binascii
.hexlify(rx_msg
['frame']).decode())):
2125 raise Exception("MGMT_RX_PROCESS failed")
2126 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
2130 def test_mesh_peering_proto(dev
, apdev
):
2131 """Mesh peering management protocol testing"""
2132 check_mesh_support(dev
[0])
2134 dev
[0].request("SET ext_mgmt_frame_handling 1")
2135 add_open_mesh_network(dev
[0], beacon_int
=160)
2136 add_open_mesh_network(dev
[1], beacon_int
=160)
2143 raise Exception("Did not see Action frames")
2144 rx_msg
= dev
[0].mgmt_rx()
2146 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
2149 raise Exception("MGMT-RX timeout")
2150 if rx_msg
['subtype'] == 13:
2151 payload
= rx_msg
['payload']
2152 frame
= rx_msg
['frame']
2153 (categ
, action
) = struct
.unpack('BB', payload
[0:2])
2154 if categ
== 15 and action
== 1 and test
== 1:
2156 pos
= frame
.find(b
'\x75\x04')
2158 raise Exception("Could not find Mesh Peering Management element")
2159 logger
.info("Found Mesh Peering Management element at %d" % pos
)
2160 # Remove the element to hit
2161 # "MPM: No Mesh Peering Management element"
2162 rx_msg
['frame'] = frame
[0:pos
]
2164 elif categ
== 15 and action
== 1 and test
== 2:
2166 pos
= frame
.find(b
'\x72\x0e')
2168 raise Exception("Could not find Mesh ID element")
2169 logger
.info("Found Mesh ID element at %d" % pos
)
2170 # Remove the element to hit
2171 # "MPM: No Mesh ID or Mesh Configuration element"
2172 rx_msg
['frame'] = frame
[0:pos
] + frame
[pos
+ 16:]
2174 elif categ
== 15 and action
== 1 and test
== 3:
2176 pos
= frame
.find(b
'\x72\x0e')
2178 raise Exception("Could not find Mesh ID element")
2179 logger
.info("Found Mesh ID element at %d" % pos
)
2180 # Replace Mesh ID to hit "MPM: Mesh ID or Mesh Configuration
2181 # element do not match local MBSS"
2182 rx_msg
['frame'] = frame
[0:pos
] + b
'\x72\x0etest-test-test' + frame
[pos
+ 16:]
2184 elif categ
== 15 and action
== 1 and test
== 4:
2187 # "MPM: Ignore too short action frame 1 ie_len 0"
2188 rx_msg
['frame'] = frame
[0:26]
2190 elif categ
== 15 and action
== 1 and test
== 5:
2192 # Truncate IEs to hit
2193 # "MPM: Failed to parse PLINK IEs"
2194 rx_msg
['frame'] = frame
[0:30]
2196 elif categ
== 15 and action
== 1 and test
== 6:
2198 pos
= frame
.find(b
'\x75\x04')
2200 raise Exception("Could not find Mesh Peering Management element")
2201 logger
.info("Found Mesh Peering Management element at %d" % pos
)
2202 # Truncate the element to hit
2203 # "MPM: Invalid peer mgmt ie" and
2204 # "MPM: Mesh parsing rejected frame"
2205 rx_msg
['frame'] = frame
[0:pos
] + b
'\x75\x00\x00\x00' + frame
[pos
+ 6:]
2207 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
2208 rx_msg
['freq'], rx_msg
['datarate'], rx_msg
['ssi_signal'], binascii
.hexlify(rx_msg
['frame']).decode())):
2209 raise Exception("MGMT_RX_PROCESS failed")
2210 ev
= dev
[1].wait_event(["MESH-PEER-CONNECTED"], timeout
=0.01)
2215 raise Exception("Not all test frames completed")
2217 def test_mesh_mpm_init_proto(dev
, apdev
):
2218 """Mesh peering management protocol testing for peer addition"""
2219 check_mesh_support(dev
[0])
2220 add_open_mesh_network(dev
[0])
2221 check_mesh_group_added(dev
[0])
2222 dev
[0].dump_monitor()
2224 dev
[0].request("SET ext_mgmt_frame_handling 1")
2226 addr
= "020000000100"
2227 hdr
= "d000ac00020000000000" + addr
+ addr
+ "1000"
2229 supp_rates
= "010802040b168c129824"
2230 ext_supp_rates
= "3204b048606c"
2231 mesh_id
= "720e777061732d6d6573682d6f70656e"
2232 mesh_conf
= "710701010001000009"
2233 mpm
= "75040000079d"
2234 ht_capab
= "2d1a7c001bffff000000000000000000000100000000000000000000"
2235 ht_oper
= "3d160b000000000000000000000000000000000000000000"
2237 dev
[0].request("NOTE no supported rates")
2238 frame
= hdr
+ fixed
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2239 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2240 raise Exception("MGMT_RX_PROCESS failed")
2242 dev
[0].request("NOTE Invalid supported rates element length 33+0")
2243 long_supp_rates
= "012100112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"
2244 frame
= hdr
+ fixed
+ long_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2245 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2246 raise Exception("MGMT_RX_PROCESS failed")
2248 dev
[0].request("NOTE Too short mesh config")
2249 short_mesh_conf
= "710401010001"
2250 frame
= hdr
+ fixed
+ supp_rates
+ mesh_id
+ short_mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2251 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2252 raise Exception("MGMT_RX_PROCESS failed")
2254 dev
[0].request("NOTE Add STA failure")
2255 frame
= hdr
+ fixed
+ supp_rates
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2256 with
fail_test(dev
[0], 1, "wpa_driver_nl80211_sta_add"):
2257 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2258 raise Exception("MGMT_RX_PROCESS failed")
2260 dev
[0].request("NOTE Send Action failure")
2261 with
fail_test(dev
[0], 1, "driver_nl80211_send_action"):
2262 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2263 raise Exception("MGMT_RX_PROCESS failed")
2265 dev
[0].request("NOTE Set STA failure")
2266 addr
= "020000000101"
2267 hdr
= "d000ac00020000000000" + addr
+ addr
+ "1000"
2268 frame
= hdr
+ fixed
+ supp_rates
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2269 with
fail_test(dev
[0], 2, "wpa_driver_nl80211_sta_add"):
2270 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2271 raise Exception("MGMT_RX_PROCESS failed")
2273 dev
[0].request("NOTE ap_sta_add OOM")
2274 addr
= "020000000102"
2275 hdr
= "d000ac00020000000000" + addr
+ addr
+ "1000"
2276 frame
= hdr
+ fixed
+ supp_rates
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2277 with
alloc_fail(dev
[0], 1, "ap_sta_add"):
2278 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2279 raise Exception("MGMT_RX_PROCESS failed")
2281 dev
[0].request("NOTE hostapd_get_aid() failure")
2282 addr
= "020000000103"
2283 hdr
= "d000ac00020000000000" + addr
+ addr
+ "1000"
2284 frame
= hdr
+ fixed
+ supp_rates
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2285 with
fail_test(dev
[0], 1, "hostapd_get_aid"):
2286 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2287 raise Exception("MGMT_RX_PROCESS failed")
2289 if "OK" not in dev
[0].request("MESH_PEER_REMOVE 02:00:00:00:01:00"):
2290 raise Exception("Failed to remove peer")
2291 if "FAIL" not in dev
[0].request("MESH_PEER_REMOVE 02:00:00:00:01:02"):
2292 raise Exception("Unexpected MESH_PEER_REMOVE success")
2293 if "FAIL" not in dev
[1].request("MESH_PEER_REMOVE 02:00:00:00:01:02"):
2294 raise Exception("Unexpected MESH_PEER_REMOVE success(2)")
2295 if "FAIL" not in dev
[1].request("MESH_PEER_ADD 02:00:00:00:01:02"):
2296 raise Exception("Unexpected MESH_PEER_ADD success")
2298 def test_mesh_holding(dev
, apdev
):
2299 """Mesh MPM FSM and HOLDING state event OPN_ACPT"""
2300 check_mesh_support(dev
[0])
2301 add_open_mesh_network(dev
[0])
2302 add_open_mesh_network(dev
[1])
2303 check_mesh_joined_connected(dev
)
2305 addr0
= dev
[0].own_addr()
2306 addr1
= dev
[1].own_addr()
2308 dev
[0].request("SET ext_mgmt_frame_handling 1")
2309 if "OK" not in dev
[0].request("MESH_PEER_REMOVE " + addr1
):
2310 raise Exception("Failed to remove peer")
2312 rx_msg
= dev
[0].mgmt_rx()
2314 raise Exception("MGMT-RX timeout")
2315 if rx_msg
['subtype'] != 13:
2316 raise Exception("Unexpected management frame")
2317 payload
= rx_msg
['payload']
2318 (categ
, action
) = struct
.unpack('BB', payload
[0:2])
2319 if categ
!= 0x0f or action
!= 0x03:
2320 raise Exception("Did not see Mesh Peering Close")
2322 peer_lid
= binascii
.hexlify(payload
[-6:-4]).decode()
2323 my_lid
= binascii
.hexlify(payload
[-4:-2]).decode()
2325 # Drop Mesh Peering Close and instead, process an unexpected Mesh Peering
2326 # Open to trigger transmission of another Mesh Peering Close in the HOLDING
2327 # state based on an OPN_ACPT event.
2329 dst
= addr0
.replace(':', '')
2330 src
= addr1
.replace(':', '')
2331 hdr
= "d000ac00" + dst
+ src
+ src
+ "1000"
2333 supp_rates
= "010802040b168c129824"
2334 ext_supp_rates
= "3204b048606c"
2335 mesh_id
= "720e777061732d6d6573682d6f70656e"
2336 mesh_conf
= "710701010001000009"
2337 mpm
= "7504" + my_lid
+ peer_lid
2338 ht_capab
= "2d1a7c001bffff000000000000000000000100000000000000000000"
2339 ht_oper
= "3d160b000000000000000000000000000000000000000000"
2341 frame
= hdr
+ fixed
+ supp_rates
+ ext_supp_rates
+ mesh_id
+ mesh_conf
+ mpm
+ ht_capab
+ ht_oper
2342 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % frame
):
2343 raise Exception("MGMT_RX_PROCESS failed")
2346 def test_mesh_cnf_rcvd_event_cls_acpt(dev
, apdev
):
2347 """Mesh peering management protocol testing - CLS_ACPT event in CNF_RCVD"""
2348 check_mesh_support(dev
[0])
2349 add_open_mesh_network(dev
[0])
2350 check_mesh_group_added(dev
[0])
2351 dev
[0].dump_monitor()
2353 dev
[0].request("SET ext_mgmt_frame_handling 1")
2354 add_open_mesh_network(dev
[1])
2355 check_mesh_group_added(dev
[1])
2357 addr0
= dev
[0].own_addr()
2358 addr1
= dev
[1].own_addr()
2360 rx_msg
= dev
[0].mgmt_rx()
2361 # Drop Mesh Peering Open
2363 rx_msg
= dev
[0].mgmt_rx()
2364 # Allow Mesh Peering Confirm to go through
2365 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
2366 rx_msg
['freq'], rx_msg
['datarate'], rx_msg
['ssi_signal'], binascii
.hexlify(rx_msg
['frame']).decode())):
2367 raise Exception("MGMT_RX_PROCESS failed")
2369 payload
= rx_msg
['payload']
2370 peer_lid
= binascii
.hexlify(payload
[51:53]).decode()
2371 my_lid
= binascii
.hexlify(payload
[53:55]).decode()
2373 dst
= addr0
.replace(':', '')
2374 src
= addr1
.replace(':', '')
2375 hdr
= "d000ac00" + dst
+ src
+ src
+ "1000"
2377 mesh_id
= "720e777061732d6d6573682d6f70656e"
2378 mpm
= "75080000" + peer_lid
+ my_lid
+ "3700"
2379 frame
= hdr
+ fixed
+ mesh_id
+ mpm
2381 # Inject Mesh Peering Close to hit "state CNF_RCVD event CLS_ACPT" to
2382 # HOLDING transition.
2383 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + frame
):
2384 raise Exception("MGMT_RX_PROCESS failed")
2386 def test_mesh_opn_snt_event_cls_acpt(dev
, apdev
):
2387 """Mesh peering management protocol testing - CLS_ACPT event in OPN_SNT"""
2388 check_mesh_support(dev
[0])
2389 add_open_mesh_network(dev
[0])
2390 check_mesh_group_added(dev
[0])
2391 dev
[0].dump_monitor()
2393 dev
[0].request("SET ext_mgmt_frame_handling 1")
2394 add_open_mesh_network(dev
[1])
2395 check_mesh_group_added(dev
[1])
2397 addr0
= dev
[0].own_addr()
2398 addr1
= dev
[1].own_addr()
2400 rx_msg
= dev
[0].mgmt_rx()
2401 # Drop Mesh Peering Open
2403 rx_msg
= dev
[0].mgmt_rx()
2404 # Drop Mesh Peering Confirm
2406 payload
= rx_msg
['payload']
2408 my_lid
= binascii
.hexlify(payload
[53:55]).decode()
2410 dst
= addr0
.replace(':', '')
2411 src
= addr1
.replace(':', '')
2412 hdr
= "d000ac00" + dst
+ src
+ src
+ "1000"
2414 mesh_id
= "720e777061732d6d6573682d6f70656e"
2415 mpm
= "75080000" + peer_lid
+ my_lid
+ "3700"
2416 frame
= hdr
+ fixed
+ mesh_id
+ mpm
2418 # Inject Mesh Peering Close to hit "state OPN_SNTevent CLS_ACPT" to
2419 # HOLDING transition.
2420 if "OK" not in dev
[0].request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=" + frame
):
2421 raise Exception("MGMT_RX_PROCESS failed")
2423 def test_mesh_select_network(dev
):
2424 """Mesh network and SELECT_NETWORK"""
2425 check_mesh_support(dev
[0])
2426 id0
= add_open_mesh_network(dev
[0], start
=False)
2427 id1
= add_open_mesh_network(dev
[1], start
=False)
2428 dev
[0].select_network(id0
)
2429 dev
[1].select_network(id1
)
2430 check_mesh_joined_connected(dev
, connectivity
=True)
2432 def test_mesh_forwarding(dev
):
2433 """Mesh with two stations that can't reach each other directly"""
2435 set_group_map(dev
[0], 1)
2436 set_group_map(dev
[1], 3)
2437 set_group_map(dev
[2], 2)
2438 check_mesh_support(dev
[0])
2440 add_open_mesh_network(dev
[i
])
2441 check_mesh_group_added(dev
[i
])
2443 check_mesh_peer_connected(dev
[i
])
2445 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
2446 hwsim_utils
.test_connectivity(dev
[1], dev
[2])
2447 hwsim_utils
.test_connectivity(dev
[0], dev
[2])
2450 set_group_map(dev
[0], 1)
2451 set_group_map(dev
[1], 1)
2452 set_group_map(dev
[2], 1)
2454 def test_mesh_forwarding_secure(dev
):
2455 """Mesh with two stations that can't reach each other directly (RSN)"""
2456 check_mesh_support(dev
[0], secure
=True)
2458 set_group_map(dev
[0], 1)
2459 set_group_map(dev
[1], 3)
2460 set_group_map(dev
[2], 2)
2462 dev
[i
].request("SET sae_groups ")
2463 id = add_mesh_secure_net(dev
[i
])
2464 dev
[i
].mesh_group_add(id)
2465 check_mesh_group_added(dev
[i
])
2467 check_mesh_peer_connected(dev
[i
])
2469 hwsim_utils
.test_connectivity(dev
[0], dev
[1])
2470 hwsim_utils
.test_connectivity(dev
[1], dev
[2])
2471 hwsim_utils
.test_connectivity(dev
[0], dev
[2])
2474 set_group_map(dev
[0], 1)
2475 set_group_map(dev
[1], 1)
2476 set_group_map(dev
[2], 1)
2478 def test_mesh_sae_anti_clogging(dev
, apdev
):
2479 """Mesh using SAE and anti-clogging"""
2481 run_mesh_sae_anti_clogging(dev
, apdev
)
2483 stop_monitor(apdev
[1]["ifname"])
2485 def run_mesh_sae_anti_clogging(dev
, apdev
):
2486 check_mesh_support(dev
[0], secure
=True)
2487 check_mesh_support(dev
[1], secure
=True)
2488 check_mesh_support(dev
[2], secure
=True)
2490 sock
= start_monitor(apdev
[1]["ifname"])
2491 radiotap
= radiotap_build()
2493 dev
[0].request("SET sae_groups 21")
2494 id = add_mesh_secure_net(dev
[0])
2495 dev
[0].mesh_group_add(id)
2496 check_mesh_group_added(dev
[0])
2498 # This flood of SAE authentication frames is from not yet known mesh STAs,
2499 # so the messages get dropped.
2500 addr0
= binascii
.unhexlify(dev
[0].own_addr().replace(':', ''))
2502 addr
= binascii
.unhexlify("f2%010x" % i
)
2503 frame
= build_sae_commit(addr0
, addr
)
2504 sock
.send(radiotap
+ frame
)
2506 dev
[1].request("SET sae_groups 21")
2507 id = add_mesh_secure_net(dev
[1])
2508 dev
[1].mesh_group_add(id)
2509 check_mesh_group_added(dev
[1])
2510 check_mesh_connected2(dev
)
2512 # Inject Beacon frames to make the sources of the second flood known to the
2514 bcn1
= binascii
.unhexlify("80000000" + "ffffffffffff")
2515 bcn2
= binascii
.unhexlify("0000dd20c44015840500e80310000000010882848b968c1298240301010504000200003204b048606c30140100000fac040100000fac040100000fac0800002d1afe131bffff0000000000000000000001000000000000000000003d16010000000000ffff0000000000000000000000000000720d777061732d6d6573682d736563710701010001010009")
2517 addr
= binascii
.unhexlify("f4%010x" % i
)
2518 frame
= bcn1
+ addr
+ addr
+ bcn2
2519 sock
.send(radiotap
+ frame
)
2521 # This flood of SAE authentication frames is from known mesh STAs, so the
2522 # target will need to process these.
2524 addr
= binascii
.unhexlify("f4%010x" % i
)
2525 frame
= build_sae_commit(addr0
, addr
)
2526 sock
.send(radiotap
+ frame
)
2528 dev
[2].request("SET sae_groups 21")
2529 id = add_mesh_secure_net(dev
[2])
2530 dev
[2].mesh_group_add(id)
2531 check_mesh_group_added(dev
[2])
2532 check_mesh_peer_connected(dev
[2])
2533 check_mesh_peer_connected(dev
[0])
2535 def test_mesh_link_probe(dev
, apdev
, params
):
2536 """Mesh link probing"""
2537 addr0
= dev
[0].own_addr()
2538 addr1
= dev
[1].own_addr()
2539 addr2
= dev
[2].own_addr()
2541 check_mesh_support(dev
[0])
2543 add_open_mesh_network(dev
[i
])
2544 check_mesh_group_added(dev
[i
])
2546 check_mesh_peer_connected(dev
[i
])
2548 res
= dev
[0].request("MESH_LINK_PROBE " + addr1
)
2550 raise HwsimSkip("MESH_LINK_PROBE kernel side support missing")
2551 dev
[0].request("MESH_LINK_PROBE " + addr2
+ " payload=aabbccdd")
2552 dev
[1].request("MESH_LINK_PROBE " + addr0
+ " payload=bbccddee")
2553 dev
[1].request("MESH_LINK_PROBE " + addr2
+ " payload=ccddeeff")
2554 dev
[2].request("MESH_LINK_PROBE " + addr0
+ " payload=aaaa")
2555 dev
[2].request("MESH_LINK_PROBE " + addr1
+ " payload=000102030405060708090a0b0c0d0e0f")
2557 capfile
= os
.path
.join(params
['logdir'], "hwsim0.pcapng")
2558 filt
= "wlan.fc == 0x8803"
2560 out
= run_tshark(capfile
, filt
, ["wlan.sa", "wlan.da"])
2561 if len(out
.splitlines()) >= 6:
2564 for i
in [addr0
, addr1
, addr2
]:
2565 for j
in [addr0
, addr1
, addr2
]:
2568 if i
+ "\t" + j
not in out
:
2569 raise Exception("Did not see probe %s --> %s" % (i
, j
))