test_wpas_mesh.py 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. # wpa_supplicant mesh mode tests
  2. # Copyright (c) 2014, cozybit Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import os
  9. import subprocess
  10. import time
  11. import hwsim_utils
  12. from wpasupplicant import WpaSupplicant
  13. from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
  14. from tshark import run_tshark
  15. def check_mesh_support(dev, secure=False):
  16. if "MESH" not in dev.get_capability("modes"):
  17. raise HwsimSkip("Driver does not support mesh")
  18. if secure and "SAE" not in dev.get_capability("auth_alg"):
  19. raise HwsimSkip("SAE not supported")
  20. def check_mesh_scan(dev, params, other_started=False, beacon_int=0):
  21. if not other_started:
  22. dev.dump_monitor()
  23. id = dev.request("SCAN " + params)
  24. if "FAIL" in id:
  25. raise Exception("Failed to start scan")
  26. id = int(id)
  27. if other_started:
  28. ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
  29. if ev is None:
  30. raise Exception("Other scan did not start")
  31. if "id=" + str(id) in ev:
  32. raise Exception("Own scan id unexpectedly included in start event")
  33. ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
  34. if ev is None:
  35. raise Exception("Other scan did not complete")
  36. if "id=" + str(id) in ev:
  37. raise Exception(
  38. "Own scan id unexpectedly included in completed event")
  39. ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
  40. if ev is None:
  41. raise Exception("Scan did not start")
  42. if "id=" + str(id) not in ev:
  43. raise Exception("Scan id not included in start event")
  44. ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
  45. if ev is None:
  46. raise Exception("Scan did not complete")
  47. if "id=" + str(id) not in ev:
  48. raise Exception("Scan id not included in completed event")
  49. res = dev.request("SCAN_RESULTS")
  50. if res.find("[MESH]") < 0:
  51. raise Exception("Scan did not contain a MESH network")
  52. bssid = res.splitlines()[1].split(' ')[0]
  53. bss = dev.get_bss(bssid)
  54. if bss is None:
  55. raise Exception("Could not get BSS entry for mesh")
  56. if 'mesh_capability' not in bss:
  57. raise Exception("mesh_capability missing from BSS entry")
  58. if beacon_int:
  59. if 'beacon_int' not in bss:
  60. raise Exception("beacon_int missing from BSS entry")
  61. if str(beacon_int) != bss['beacon_int']:
  62. raise Exception("Unexpected beacon_int in BSS entry: " + bss['beacon_int'])
  63. def check_mesh_group_added(dev):
  64. ev = dev.wait_event(["MESH-GROUP-STARTED"])
  65. if ev is None:
  66. raise Exception("Test exception: Couldn't join mesh")
  67. def check_mesh_group_removed(dev):
  68. ev = dev.wait_event(["MESH-GROUP-REMOVED"])
  69. if ev is None:
  70. raise Exception("Test exception: Couldn't leave mesh")
  71. def check_mesh_peer_connected(dev, timeout=10):
  72. ev = dev.wait_event(["MESH-PEER-CONNECTED"], timeout=timeout)
  73. if ev is None:
  74. raise Exception("Test exception: Remote peer did not connect.")
  75. def check_mesh_peer_disconnected(dev):
  76. ev = dev.wait_event(["MESH-PEER-DISCONNECTED"])
  77. if ev is None:
  78. raise Exception("Test exception: Peer disconnect event not detected.")
  79. def test_wpas_add_set_remove_support(dev):
  80. """wpa_supplicant MESH add/set/remove network support"""
  81. check_mesh_support(dev[0])
  82. id = dev[0].add_network()
  83. dev[0].set_network(id, "mode", "5")
  84. dev[0].remove_network(id)
  85. def add_open_mesh_network(dev, freq="2412", start=True, beacon_int=0,
  86. basic_rates=None, chwidth=0):
  87. id = dev.add_network()
  88. dev.set_network(id, "mode", "5")
  89. dev.set_network_quoted(id, "ssid", "wpas-mesh-open")
  90. dev.set_network(id, "key_mgmt", "NONE")
  91. dev.set_network(id, "frequency", freq)
  92. if chwidth > 0:
  93. dev.set_network(id, "max_oper_chwidth", str(chwidth))
  94. if beacon_int:
  95. dev.set_network(id, "beacon_int", str(beacon_int))
  96. if basic_rates:
  97. dev.set_network(id, "mesh_basic_rates", basic_rates)
  98. if start:
  99. dev.mesh_group_add(id)
  100. return id
  101. def test_wpas_mesh_group_added(dev):
  102. """wpa_supplicant MESH group add"""
  103. check_mesh_support(dev[0])
  104. add_open_mesh_network(dev[0])
  105. # Check for MESH-GROUP-STARTED event
  106. check_mesh_group_added(dev[0])
  107. def test_wpas_mesh_group_remove(dev):
  108. """wpa_supplicant MESH group remove"""
  109. check_mesh_support(dev[0])
  110. add_open_mesh_network(dev[0])
  111. # Check for MESH-GROUP-STARTED event
  112. check_mesh_group_added(dev[0])
  113. dev[0].mesh_group_remove()
  114. # Check for MESH-GROUP-REMOVED event
  115. check_mesh_group_removed(dev[0])
  116. dev[0].mesh_group_remove()
  117. def test_wpas_mesh_peer_connected(dev):
  118. """wpa_supplicant MESH peer connected"""
  119. check_mesh_support(dev[0])
  120. add_open_mesh_network(dev[0], beacon_int=160)
  121. add_open_mesh_network(dev[1], beacon_int=160)
  122. # Check for mesh joined
  123. check_mesh_group_added(dev[0])
  124. check_mesh_group_added(dev[1])
  125. # Check for peer connected
  126. check_mesh_peer_connected(dev[0])
  127. check_mesh_peer_connected(dev[1])
  128. def test_wpas_mesh_peer_disconnected(dev):
  129. """wpa_supplicant MESH peer disconnected"""
  130. check_mesh_support(dev[0])
  131. add_open_mesh_network(dev[0])
  132. add_open_mesh_network(dev[1])
  133. # Check for mesh joined
  134. check_mesh_group_added(dev[0])
  135. check_mesh_group_added(dev[1])
  136. # Check for peer connected
  137. check_mesh_peer_connected(dev[0])
  138. check_mesh_peer_connected(dev[1])
  139. # Remove group on dev 1
  140. dev[1].mesh_group_remove()
  141. # Device 0 should get a disconnection event
  142. check_mesh_peer_disconnected(dev[0])
  143. def test_wpas_mesh_mode_scan(dev):
  144. """wpa_supplicant MESH scan support"""
  145. check_mesh_support(dev[0])
  146. add_open_mesh_network(dev[0])
  147. add_open_mesh_network(dev[1], beacon_int=175)
  148. # Check for mesh joined
  149. check_mesh_group_added(dev[0])
  150. check_mesh_group_added(dev[1])
  151. # Check for Mesh scan
  152. check_mesh_scan(dev[0], "use_id=1", beacon_int=175)
  153. def test_wpas_mesh_open(dev, apdev):
  154. """wpa_supplicant open MESH network connectivity"""
  155. check_mesh_support(dev[0])
  156. add_open_mesh_network(dev[0], freq="2462", basic_rates="60 120 240")
  157. add_open_mesh_network(dev[1], freq="2462", basic_rates="60 120 240")
  158. # Check for mesh joined
  159. check_mesh_group_added(dev[0])
  160. check_mesh_group_added(dev[1])
  161. # Check for peer connected
  162. check_mesh_peer_connected(dev[0])
  163. check_mesh_peer_connected(dev[1])
  164. # Test connectivity 0->1 and 1->0
  165. hwsim_utils.test_connectivity(dev[0], dev[1])
  166. def test_wpas_mesh_open_no_auto(dev, apdev):
  167. """wpa_supplicant open MESH network connectivity"""
  168. check_mesh_support(dev[0])
  169. id = add_open_mesh_network(dev[0], start=False)
  170. dev[0].set_network(id, "dot11MeshMaxRetries", "16")
  171. dev[0].set_network(id, "dot11MeshRetryTimeout", "255")
  172. dev[0].mesh_group_add(id)
  173. id = add_open_mesh_network(dev[1], start=False)
  174. dev[1].set_network(id, "no_auto_peer", "1")
  175. dev[1].mesh_group_add(id)
  176. # Check for mesh joined
  177. check_mesh_group_added(dev[0])
  178. check_mesh_group_added(dev[1])
  179. # Check for peer connected
  180. check_mesh_peer_connected(dev[0], timeout=30)
  181. check_mesh_peer_connected(dev[1])
  182. # Test connectivity 0->1 and 1->0
  183. hwsim_utils.test_connectivity(dev[0], dev[1])
  184. def add_mesh_secure_net(dev, psk=True):
  185. id = dev.add_network()
  186. dev.set_network(id, "mode", "5")
  187. dev.set_network_quoted(id, "ssid", "wpas-mesh-sec")
  188. dev.set_network(id, "key_mgmt", "SAE")
  189. dev.set_network(id, "frequency", "2412")
  190. if psk:
  191. dev.set_network_quoted(id, "psk", "thisismypassphrase!")
  192. return id
  193. def test_wpas_mesh_secure(dev, apdev):
  194. """wpa_supplicant secure MESH network connectivity"""
  195. check_mesh_support(dev[0], secure=True)
  196. dev[0].request("SET sae_groups ")
  197. id = add_mesh_secure_net(dev[0])
  198. dev[0].mesh_group_add(id)
  199. dev[1].request("SET sae_groups ")
  200. id = add_mesh_secure_net(dev[1])
  201. dev[1].mesh_group_add(id)
  202. # Check for mesh joined
  203. check_mesh_group_added(dev[0])
  204. check_mesh_group_added(dev[1])
  205. # Check for peer connected
  206. check_mesh_peer_connected(dev[0])
  207. check_mesh_peer_connected(dev[1])
  208. # Test connectivity 0->1 and 1->0
  209. hwsim_utils.test_connectivity(dev[0], dev[1])
  210. def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
  211. """wpa_supplicant secure MESH and SAE group mismatch"""
  212. check_mesh_support(dev[0], secure=True)
  213. addr0 = dev[0].p2p_interface_addr()
  214. addr1 = dev[1].p2p_interface_addr()
  215. addr2 = dev[2].p2p_interface_addr()
  216. dev[0].request("SET sae_groups 19 25")
  217. id = add_mesh_secure_net(dev[0])
  218. dev[0].mesh_group_add(id)
  219. dev[1].request("SET sae_groups 19")
  220. id = add_mesh_secure_net(dev[1])
  221. dev[1].mesh_group_add(id)
  222. dev[2].request("SET sae_groups 26")
  223. id = add_mesh_secure_net(dev[2])
  224. dev[2].mesh_group_add(id)
  225. check_mesh_group_added(dev[0])
  226. check_mesh_group_added(dev[1])
  227. check_mesh_group_added(dev[2])
  228. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"])
  229. if ev is None:
  230. raise Exception("Remote peer did not connect")
  231. if addr1 not in ev:
  232. raise Exception("Unexpected peer connected: " + ev)
  233. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"])
  234. if ev is None:
  235. raise Exception("Remote peer did not connect")
  236. if addr0 not in ev:
  237. raise Exception("Unexpected peer connected: " + ev)
  238. ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
  239. if ev is not None:
  240. raise Exception("Unexpected peer connection at dev[2]: " + ev)
  241. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  242. if ev is not None:
  243. raise Exception("Unexpected peer connection: " + ev)
  244. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  245. if ev is not None:
  246. raise Exception("Unexpected peer connection: " + ev)
  247. dev[0].request("SET sae_groups ")
  248. dev[1].request("SET sae_groups ")
  249. dev[2].request("SET sae_groups ")
  250. def test_wpas_mesh_secure_sae_group_negotiation(dev, apdev):
  251. """wpa_supplicant secure MESH and SAE group negotiation"""
  252. check_mesh_support(dev[0], secure=True)
  253. addr0 = dev[0].own_addr()
  254. addr1 = dev[1].own_addr()
  255. #dev[0].request("SET sae_groups 21 20 25 26")
  256. dev[0].request("SET sae_groups 25")
  257. id = add_mesh_secure_net(dev[0])
  258. dev[0].mesh_group_add(id)
  259. dev[1].request("SET sae_groups 19 25")
  260. id = add_mesh_secure_net(dev[1])
  261. dev[1].mesh_group_add(id)
  262. check_mesh_group_added(dev[0])
  263. check_mesh_group_added(dev[1])
  264. check_mesh_peer_connected(dev[0])
  265. check_mesh_peer_connected(dev[1])
  266. dev[0].request("SET sae_groups ")
  267. dev[1].request("SET sae_groups ")
  268. def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
  269. """wpa_supplicant secure MESH and missing SAE password"""
  270. check_mesh_support(dev[0], secure=True)
  271. id = add_mesh_secure_net(dev[0], psk=False)
  272. dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
  273. dev[0].mesh_group_add(id)
  274. ev = dev[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
  275. timeout=5)
  276. if ev is None:
  277. raise Exception("Timeout on mesh start event")
  278. if "MESH-GROUP-STARTED" in ev:
  279. raise Exception("Unexpected mesh group start")
  280. ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.1)
  281. if ev is not None:
  282. raise Exception("Unexpected mesh group start")
  283. def test_wpas_mesh_secure_no_auto(dev, apdev):
  284. """wpa_supplicant secure MESH network connectivity"""
  285. check_mesh_support(dev[0], secure=True)
  286. dev[0].request("SET sae_groups 19")
  287. id = add_mesh_secure_net(dev[0])
  288. dev[0].mesh_group_add(id)
  289. dev[1].request("SET sae_groups 19")
  290. id = add_mesh_secure_net(dev[1])
  291. dev[1].set_network(id, "no_auto_peer", "1")
  292. dev[1].mesh_group_add(id)
  293. # Check for mesh joined
  294. check_mesh_group_added(dev[0])
  295. check_mesh_group_added(dev[1])
  296. # Check for peer connected
  297. check_mesh_peer_connected(dev[0], timeout=30)
  298. check_mesh_peer_connected(dev[1])
  299. # Test connectivity 0->1 and 1->0
  300. hwsim_utils.test_connectivity(dev[0], dev[1])
  301. dev[0].request("SET sae_groups ")
  302. dev[1].request("SET sae_groups ")
  303. def test_wpas_mesh_secure_dropped_frame(dev, apdev):
  304. """Secure mesh network connectivity when the first plink Open is dropped"""
  305. check_mesh_support(dev[0], secure=True)
  306. dev[0].request("SET ext_mgmt_frame_handling 1")
  307. dev[0].request("SET sae_groups ")
  308. id = add_mesh_secure_net(dev[0])
  309. dev[0].mesh_group_add(id)
  310. dev[1].request("SET sae_groups ")
  311. id = add_mesh_secure_net(dev[1])
  312. dev[1].mesh_group_add(id)
  313. # Check for mesh joined
  314. check_mesh_group_added(dev[0])
  315. check_mesh_group_added(dev[1])
  316. # Drop the first Action frame (plink Open) to test unexpected order of
  317. # Confirm/Open messages.
  318. count = 0
  319. while True:
  320. count += 1
  321. if count > 10:
  322. raise Exception("Did not see Action frames")
  323. rx_msg = dev[0].mgmt_rx()
  324. if rx_msg is None:
  325. raise Exception("MGMT-RX timeout")
  326. if rx_msg['subtype'] == 13:
  327. logger.info("Drop the first Action frame")
  328. break
  329. if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
  330. raise Exception("MGMT_RX_PROCESS failed")
  331. dev[0].request("SET ext_mgmt_frame_handling 0")
  332. # Check for peer connected
  333. check_mesh_peer_connected(dev[0])
  334. check_mesh_peer_connected(dev[1])
  335. # Test connectivity 0->1 and 1->0
  336. hwsim_utils.test_connectivity(dev[0], dev[1])
  337. def test_wpas_mesh_ctrl(dev):
  338. """wpa_supplicant ctrl_iface mesh command error cases"""
  339. check_mesh_support(dev[0])
  340. if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"):
  341. raise Exception("Unexpected MESH_GROUP_ADD success")
  342. id = dev[0].add_network()
  343. if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
  344. raise Exception("Unexpected MESH_GROUP_ADD success")
  345. dev[0].set_network(id, "mode", "5")
  346. dev[0].set_network(id, "key_mgmt", "WPA-PSK")
  347. if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
  348. raise Exception("Unexpected MESH_GROUP_ADD success")
  349. if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE foo"):
  350. raise Exception("Unexpected MESH_GROUP_REMOVE success")
  351. def test_wpas_mesh_dynamic_interface(dev):
  352. """wpa_supplicant mesh with dynamic interface"""
  353. check_mesh_support(dev[0])
  354. mesh0 = None
  355. mesh1 = None
  356. try:
  357. mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
  358. if "FAIL" in mesh0:
  359. raise Exception("MESH_INTERFACE_ADD failed")
  360. mesh1 = dev[1].request("MESH_INTERFACE_ADD")
  361. if "FAIL" in mesh1:
  362. raise Exception("MESH_INTERFACE_ADD failed")
  363. wpas0 = WpaSupplicant(ifname=mesh0)
  364. wpas1 = WpaSupplicant(ifname=mesh1)
  365. logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
  366. logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
  367. add_open_mesh_network(wpas0)
  368. add_open_mesh_network(wpas1)
  369. check_mesh_group_added(wpas0)
  370. check_mesh_group_added(wpas1)
  371. check_mesh_peer_connected(wpas0)
  372. check_mesh_peer_connected(wpas1)
  373. hwsim_utils.test_connectivity(wpas0, wpas1)
  374. # Must not allow MESH_GROUP_REMOVE on dynamic interface
  375. if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh0):
  376. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  377. if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh1):
  378. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  379. # Must not allow MESH_GROUP_REMOVE on another radio interface
  380. if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh1):
  381. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  382. if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh0):
  383. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  384. wpas0.remove_ifname()
  385. wpas1.remove_ifname()
  386. if "OK" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
  387. raise Exception("MESH_GROUP_REMOVE failed")
  388. if "OK" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
  389. raise Exception("MESH_GROUP_REMOVE failed")
  390. if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
  391. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  392. if "FAIL" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
  393. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  394. logger.info("Make sure another dynamic group can be added")
  395. mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
  396. if "FAIL" in mesh0:
  397. raise Exception("MESH_INTERFACE_ADD failed")
  398. mesh1 = dev[1].request("MESH_INTERFACE_ADD")
  399. if "FAIL" in mesh1:
  400. raise Exception("MESH_INTERFACE_ADD failed")
  401. wpas0 = WpaSupplicant(ifname=mesh0)
  402. wpas1 = WpaSupplicant(ifname=mesh1)
  403. logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
  404. logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
  405. add_open_mesh_network(wpas0)
  406. add_open_mesh_network(wpas1)
  407. check_mesh_group_added(wpas0)
  408. check_mesh_group_added(wpas1)
  409. check_mesh_peer_connected(wpas0)
  410. check_mesh_peer_connected(wpas1)
  411. hwsim_utils.test_connectivity(wpas0, wpas1)
  412. finally:
  413. if mesh0:
  414. dev[0].request("MESH_GROUP_REMOVE " + mesh0)
  415. if mesh1:
  416. dev[1].request("MESH_GROUP_REMOVE " + mesh1)
  417. def test_wpas_mesh_max_peering(dev, apdev):
  418. """Mesh max peering limit"""
  419. check_mesh_support(dev[0])
  420. try:
  421. dev[0].request("SET max_peer_links 1")
  422. # first, connect dev[0] and dev[1]
  423. add_open_mesh_network(dev[0])
  424. add_open_mesh_network(dev[1])
  425. for i in range(2):
  426. ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
  427. if ev is None:
  428. raise Exception("dev%d did not connect with any peer" % i)
  429. # add dev[2] which will try to connect with both dev[0] and dev[1],
  430. # but can complete connection only with dev[1]
  431. add_open_mesh_network(dev[2])
  432. for i in range(1, 3):
  433. ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
  434. if ev is None:
  435. raise Exception("dev%d did not connect the second peer" % i)
  436. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
  437. if ev is not None:
  438. raise Exception("dev0 connection beyond max peering limit")
  439. ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  440. if ev is not None:
  441. raise Exception("dev2 reported unexpected peering: " + ev)
  442. for i in range(3):
  443. dev[i].mesh_group_remove()
  444. check_mesh_group_removed(dev[i])
  445. finally:
  446. dev[0].request("SET max_peer_links 99")
  447. def test_wpas_mesh_open_5ghz(dev, apdev):
  448. """wpa_supplicant open MESH network on 5 GHz band"""
  449. try:
  450. _test_wpas_mesh_open_5ghz(dev, apdev)
  451. finally:
  452. subprocess.call(['iw', 'reg', 'set', '00'])
  453. dev[0].flush_scan_cache()
  454. dev[1].flush_scan_cache()
  455. def _test_wpas_mesh_open_5ghz(dev, apdev):
  456. check_mesh_support(dev[0])
  457. subprocess.call(['iw', 'reg', 'set', 'US'])
  458. for i in range(2):
  459. for j in range(5):
  460. ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
  461. if ev is None:
  462. raise Exception("No regdom change event")
  463. if "alpha2=US" in ev:
  464. break
  465. add_open_mesh_network(dev[i], freq="5180")
  466. # Check for mesh joined
  467. check_mesh_group_added(dev[0])
  468. check_mesh_group_added(dev[1])
  469. # Check for peer connected
  470. check_mesh_peer_connected(dev[0])
  471. check_mesh_peer_connected(dev[1])
  472. # Test connectivity 0->1 and 1->0
  473. hwsim_utils.test_connectivity(dev[0], dev[1])
  474. def test_wpas_mesh_open_vht_80p80(dev, apdev):
  475. """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
  476. try:
  477. _test_wpas_mesh_open_vht_80p80(dev, apdev)
  478. finally:
  479. subprocess.call(['iw', 'reg', 'set', '00'])
  480. dev[0].flush_scan_cache()
  481. dev[1].flush_scan_cache()
  482. def _test_wpas_mesh_open_vht_80p80(dev, apdev):
  483. check_mesh_support(dev[0])
  484. subprocess.call(['iw', 'reg', 'set', 'US'])
  485. for i in range(2):
  486. for j in range(5):
  487. ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
  488. if ev is None:
  489. raise Exception("No regdom change event")
  490. if "alpha2=US" in ev:
  491. break
  492. add_open_mesh_network(dev[i], freq="5180", chwidth=3)
  493. # Check for mesh joined
  494. check_mesh_group_added(dev[0])
  495. check_mesh_group_added(dev[1])
  496. # Check for peer connected
  497. check_mesh_peer_connected(dev[0])
  498. check_mesh_peer_connected(dev[1])
  499. # Test connectivity 0->1 and 1->0
  500. hwsim_utils.test_connectivity(dev[0], dev[1])
  501. sig = dev[0].request("SIGNAL_POLL").splitlines()
  502. if "WIDTH=80+80 MHz" not in sig:
  503. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  504. if "CENTER_FRQ1=5210" not in sig:
  505. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  506. if "CENTER_FRQ2=5775" not in sig:
  507. raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
  508. sig = dev[1].request("SIGNAL_POLL").splitlines()
  509. if "WIDTH=80+80 MHz" not in sig:
  510. raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
  511. if "CENTER_FRQ1=5210" not in sig:
  512. raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
  513. if "CENTER_FRQ2=5775" not in sig:
  514. raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig))
  515. def test_wpas_mesh_password_mismatch(dev, apdev):
  516. """Mesh network and one device with mismatching password"""
  517. check_mesh_support(dev[0], secure=True)
  518. dev[0].request("SET sae_groups ")
  519. id = add_mesh_secure_net(dev[0])
  520. dev[0].mesh_group_add(id)
  521. dev[1].request("SET sae_groups ")
  522. id = add_mesh_secure_net(dev[1])
  523. dev[1].mesh_group_add(id)
  524. dev[2].request("SET sae_groups ")
  525. id = add_mesh_secure_net(dev[2])
  526. dev[2].set_network_quoted(id, "psk", "wrong password")
  527. dev[2].mesh_group_add(id)
  528. # The two peers with matching password need to be able to connect
  529. check_mesh_group_added(dev[0])
  530. check_mesh_group_added(dev[1])
  531. check_mesh_peer_connected(dev[0])
  532. check_mesh_peer_connected(dev[1])
  533. ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  534. if ev is None:
  535. raise Exception("dev2 did not report auth failure (1)")
  536. ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  537. if ev is None:
  538. raise Exception("dev2 did not report auth failure (2)")
  539. count = 0
  540. ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
  541. if ev is None:
  542. logger.info("dev0 did not report auth failure")
  543. else:
  544. if "addr=" + dev[2].own_addr() not in ev:
  545. raise Exception("Unexpected peer address in dev0 event: " + ev)
  546. count += 1
  547. ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
  548. if ev is None:
  549. logger.info("dev1 did not report auth failure")
  550. else:
  551. if "addr=" + dev[2].own_addr() not in ev:
  552. raise Exception("Unexpected peer address in dev1 event: " + ev)
  553. count += 1
  554. hwsim_utils.test_connectivity(dev[0], dev[1])
  555. for i in range(2):
  556. try:
  557. hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1)
  558. raise Exception("Data connectivity test passed unexpectedly")
  559. except Exception, e:
  560. if "data delivery failed" not in str(e):
  561. raise
  562. if count == 0:
  563. raise Exception("Neither dev0 nor dev1 reported auth failure")
  564. def test_wpas_mesh_password_mismatch_retry(dev, apdev, params):
  565. """Mesh password mismatch and retry [long]"""
  566. if not params['long']:
  567. raise HwsimSkip("Skip test case with long duration due to --long not specified")
  568. check_mesh_support(dev[0], secure=True)
  569. dev[0].request("SET sae_groups ")
  570. id = add_mesh_secure_net(dev[0])
  571. dev[0].mesh_group_add(id)
  572. dev[1].request("SET sae_groups ")
  573. id = add_mesh_secure_net(dev[1])
  574. dev[1].set_network_quoted(id, "psk", "wrong password")
  575. dev[1].mesh_group_add(id)
  576. # Check for mesh joined
  577. check_mesh_group_added(dev[0])
  578. check_mesh_group_added(dev[1])
  579. for i in range(4):
  580. ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  581. if ev is None:
  582. raise Exception("dev0 did not report auth failure (%d)" % i)
  583. ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  584. if ev is None:
  585. raise Exception("dev1 did not report auth failure (%d)" % i)
  586. ev = dev[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
  587. if ev is None:
  588. raise Exception("dev0 did not report auth blocked")
  589. ev = dev[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
  590. if ev is None:
  591. raise Exception("dev1 did not report auth blocked")
  592. def test_mesh_wpa_auth_init_oom(dev, apdev):
  593. """Secure mesh network setup failing due to wpa_init() OOM"""
  594. check_mesh_support(dev[0], secure=True)
  595. dev[0].request("SET sae_groups ")
  596. with alloc_fail(dev[0], 1, "wpa_init"):
  597. id = add_mesh_secure_net(dev[0])
  598. dev[0].mesh_group_add(id)
  599. ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.2)
  600. if ev is not None:
  601. raise Exception("Unexpected mesh group start during OOM")
  602. def test_mesh_wpa_init_fail(dev, apdev):
  603. """Secure mesh network setup local failure"""
  604. check_mesh_support(dev[0], secure=True)
  605. dev[0].request("SET sae_groups ")
  606. with fail_test(dev[0], 1, "os_get_random;=__mesh_rsn_auth_init"):
  607. id = add_mesh_secure_net(dev[0])
  608. dev[0].mesh_group_add(id)
  609. wait_fail_trigger(dev[0], "GET_FAIL")
  610. with alloc_fail(dev[0], 1, "mesh_rsn_auth_init"):
  611. id = add_mesh_secure_net(dev[0])
  612. dev[0].mesh_group_add(id)
  613. wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
  614. def test_wpas_mesh_reconnect(dev, apdev):
  615. """Secure mesh network plink counting during reconnection"""
  616. check_mesh_support(dev[0])
  617. try:
  618. _test_wpas_mesh_reconnect(dev)
  619. finally:
  620. dev[0].request("SET max_peer_links 99")
  621. def _test_wpas_mesh_reconnect(dev):
  622. dev[0].request("SET max_peer_links 2")
  623. dev[0].request("SET sae_groups ")
  624. id = add_mesh_secure_net(dev[0])
  625. dev[0].set_network(id, "beacon_int", "100")
  626. dev[0].mesh_group_add(id)
  627. dev[1].request("SET sae_groups ")
  628. id = add_mesh_secure_net(dev[1])
  629. dev[1].mesh_group_add(id)
  630. check_mesh_group_added(dev[0])
  631. check_mesh_group_added(dev[1])
  632. check_mesh_peer_connected(dev[0])
  633. check_mesh_peer_connected(dev[1])
  634. for i in range(3):
  635. # Drop incoming management frames to avoid handling link close
  636. dev[0].request("SET ext_mgmt_frame_handling 1")
  637. dev[1].mesh_group_remove()
  638. check_mesh_group_removed(dev[1])
  639. dev[1].request("FLUSH")
  640. dev[0].request("SET ext_mgmt_frame_handling 0")
  641. id = add_mesh_secure_net(dev[1])
  642. dev[1].mesh_group_add(id)
  643. check_mesh_group_added(dev[1])
  644. check_mesh_peer_connected(dev[1])
  645. dev[0].dump_monitor()
  646. dev[1].dump_monitor()
  647. def test_wpas_mesh_gate_forwarding(dev, apdev, p):
  648. """Mesh forwards traffic to unknown sta to mesh gates"""
  649. addr0 = dev[0].own_addr()
  650. addr1 = dev[1].own_addr()
  651. addr2 = dev[2].own_addr()
  652. external_sta = '02:11:22:33:44:55'
  653. # start 3 node connected mesh
  654. check_mesh_support(dev[0])
  655. for i in range(3):
  656. add_open_mesh_network(dev[i])
  657. check_mesh_group_added(dev[i])
  658. for i in range(3):
  659. check_mesh_peer_connected(dev[i])
  660. hwsim_utils.test_connectivity(dev[0], dev[1])
  661. hwsim_utils.test_connectivity(dev[1], dev[2])
  662. hwsim_utils.test_connectivity(dev[0], dev[2])
  663. # dev0 and dev1 are mesh gates
  664. subprocess.call(['iw', 'dev', dev[0].ifname, 'set', 'mesh_param',
  665. 'mesh_gate_announcements=1'])
  666. subprocess.call(['iw', 'dev', dev[1].ifname, 'set', 'mesh_param',
  667. 'mesh_gate_announcements=1'])
  668. # wait for gate announcement frames
  669. time.sleep(1)
  670. # data frame from dev2 -> external sta should be sent to both gates
  671. dev[2].request("DATA_TEST_CONFIG 1")
  672. dev[2].request("DATA_TEST_TX {} {} 0".format(external_sta, addr2))
  673. dev[2].request("DATA_TEST_CONFIG 0")
  674. capfile = os.path.join(p['logdir'], "hwsim0.pcapng")
  675. filt = "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2,
  676. external_sta)
  677. for i in range(15):
  678. da = run_tshark(capfile, filt, [ "wlan.da" ])
  679. if addr0 in da and addr1 in da:
  680. logger.debug("Frames seen in tshark iteration %d" % i)
  681. break
  682. time.sleep(0.3)
  683. if addr0 not in da:
  684. raise Exception("Frame to gate %s not observed" % addr0)
  685. if addr1 not in da:
  686. raise Exception("Frame to gate %s not observed" % addr1)
  687. def test_wpas_mesh_pmksa_caching(dev, apdev):
  688. """Secure mesh network and PMKSA caching"""
  689. check_mesh_support(dev[0], secure=True)
  690. dev[0].request("SET sae_groups ")
  691. id = add_mesh_secure_net(dev[0])
  692. dev[0].mesh_group_add(id)
  693. dev[1].request("SET sae_groups ")
  694. id = add_mesh_secure_net(dev[1])
  695. dev[1].mesh_group_add(id)
  696. # Check for mesh joined
  697. check_mesh_group_added(dev[0])
  698. check_mesh_group_added(dev[1])
  699. # Check for peer connected
  700. check_mesh_peer_connected(dev[0])
  701. check_mesh_peer_connected(dev[1])
  702. addr0 = dev[0].own_addr()
  703. addr1 = dev[1].own_addr()
  704. pmksa0 = dev[0].get_pmksa(addr1)
  705. pmksa1 = dev[1].get_pmksa(addr0)
  706. if pmksa0 is None or pmksa1 is None:
  707. raise Exception("No PMKSA cache entry created")
  708. if pmksa0['pmkid'] != pmksa1['pmkid']:
  709. raise Exception("PMKID mismatch in PMKSA cache entries")
  710. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  711. raise Exception("Failed to remove peer")
  712. pmksa0b = dev[0].get_pmksa(addr1)
  713. if pmksa0b is None:
  714. raise Exception("PMKSA cache entry not maintained")
  715. time.sleep(0.1)
  716. if "FAIL" not in dev[0].request("MESH_PEER_ADD " + addr1):
  717. raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
  718. def test_wpas_mesh_pmksa_caching2(dev, apdev):
  719. """Secure mesh network and PMKSA caching with no_auto_peer=1"""
  720. check_mesh_support(dev[0], secure=True)
  721. addr0 = dev[0].own_addr()
  722. addr1 = dev[1].own_addr()
  723. dev[0].request("SET sae_groups ")
  724. id = add_mesh_secure_net(dev[0])
  725. dev[0].set_network(id, "no_auto_peer", "1")
  726. dev[0].mesh_group_add(id)
  727. dev[1].request("SET sae_groups ")
  728. id = add_mesh_secure_net(dev[1])
  729. dev[1].set_network(id, "no_auto_peer", "1")
  730. dev[1].mesh_group_add(id)
  731. # Check for mesh joined
  732. check_mesh_group_added(dev[0])
  733. check_mesh_group_added(dev[1])
  734. # Check for peer connected
  735. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  736. if ev is None:
  737. raise Exception("Missing no-initiate message")
  738. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  739. raise Exception("MESH_PEER_ADD failed")
  740. check_mesh_peer_connected(dev[0])
  741. check_mesh_peer_connected(dev[1])
  742. pmksa0 = dev[0].get_pmksa(addr1)
  743. pmksa1 = dev[1].get_pmksa(addr0)
  744. if pmksa0 is None or pmksa1 is None:
  745. raise Exception("No PMKSA cache entry created")
  746. if pmksa0['pmkid'] != pmksa1['pmkid']:
  747. raise Exception("PMKID mismatch in PMKSA cache entries")
  748. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  749. raise Exception("Failed to remove peer")
  750. pmksa0b = dev[0].get_pmksa(addr1)
  751. if pmksa0b is None:
  752. raise Exception("PMKSA cache entry not maintained")
  753. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  754. if ev is None:
  755. raise Exception("Missing no-initiate message (2)")
  756. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  757. raise Exception("MESH_PEER_ADD failed (2)")
  758. check_mesh_peer_connected(dev[0])
  759. check_mesh_peer_connected(dev[1])
  760. pmksa0c = dev[0].get_pmksa(addr1)
  761. pmksa1c = dev[1].get_pmksa(addr0)
  762. if pmksa0c is None or pmksa1c is None:
  763. raise Exception("No PMKSA cache entry created (2)")
  764. if pmksa0c['pmkid'] != pmksa1c['pmkid']:
  765. raise Exception("PMKID mismatch in PMKSA cache entries")
  766. if pmksa0['pmkid'] != pmksa0c['pmkid']:
  767. raise Exception("PMKID changed")
  768. hwsim_utils.test_connectivity(dev[0], dev[1])
  769. def test_wpas_mesh_pmksa_caching_no_match(dev, apdev):
  770. """Secure mesh network and PMKSA caching with no PMKID match"""
  771. check_mesh_support(dev[0], secure=True)
  772. addr0 = dev[0].own_addr()
  773. addr1 = dev[1].own_addr()
  774. dev[0].request("SET sae_groups ")
  775. id = add_mesh_secure_net(dev[0])
  776. dev[0].set_network(id, "no_auto_peer", "1")
  777. dev[0].mesh_group_add(id)
  778. dev[1].request("SET sae_groups ")
  779. id = add_mesh_secure_net(dev[1])
  780. dev[1].set_network(id, "no_auto_peer", "1")
  781. dev[1].mesh_group_add(id)
  782. # Check for mesh joined
  783. check_mesh_group_added(dev[0])
  784. check_mesh_group_added(dev[1])
  785. # Check for peer connected
  786. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  787. if ev is None:
  788. raise Exception("Missing no-initiate message")
  789. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  790. raise Exception("MESH_PEER_ADD failed")
  791. check_mesh_peer_connected(dev[0])
  792. check_mesh_peer_connected(dev[1])
  793. pmksa0 = dev[0].get_pmksa(addr1)
  794. pmksa1 = dev[1].get_pmksa(addr0)
  795. if pmksa0 is None or pmksa1 is None:
  796. raise Exception("No PMKSA cache entry created")
  797. if pmksa0['pmkid'] != pmksa1['pmkid']:
  798. raise Exception("PMKID mismatch in PMKSA cache entries")
  799. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  800. raise Exception("Failed to remove peer")
  801. if "OK" not in dev[1].request("PMKSA_FLUSH"):
  802. raise Exception("Failed to flush PMKSA cache")
  803. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  804. if ev is None:
  805. raise Exception("Missing no-initiate message (2)")
  806. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  807. raise Exception("MESH_PEER_ADD failed (2)")
  808. check_mesh_peer_connected(dev[0])
  809. check_mesh_peer_connected(dev[1])
  810. pmksa0c = dev[0].get_pmksa(addr1)
  811. pmksa1c = dev[1].get_pmksa(addr0)
  812. if pmksa0c is None or pmksa1c is None:
  813. raise Exception("No PMKSA cache entry created (2)")
  814. if pmksa0c['pmkid'] != pmksa1c['pmkid']:
  815. raise Exception("PMKID mismatch in PMKSA cache entries")
  816. if pmksa0['pmkid'] == pmksa0c['pmkid']:
  817. raise Exception("PMKID did not change")
  818. hwsim_utils.test_connectivity(dev[0], dev[1])
  819. def test_mesh_oom(dev, apdev):
  820. """Mesh network setup failing due to OOM"""
  821. check_mesh_support(dev[0], secure=True)
  822. dev[0].request("SET sae_groups ")
  823. with alloc_fail(dev[0], 1, "mesh_config_create"):
  824. add_open_mesh_network(dev[0])
  825. ev = dev[0].wait_event(["Failed to init mesh"])
  826. if ev is None:
  827. raise Exception("Init failure not reported")
  828. for i in range(1, 65):
  829. with alloc_fail(dev[0], i, "wpa_supplicant_mesh_init"):
  830. add_open_mesh_network(dev[0])
  831. wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
  832. ev = dev[0].wait_event(["Failed to init mesh",
  833. "MESH-GROUP-STARTED"])
  834. if ev is None:
  835. raise Exception("Init failure not reported")
  836. def test_mesh_add_interface_oom(dev):
  837. """wpa_supplicant mesh with dynamic interface addition failing"""
  838. check_mesh_support(dev[0])
  839. for i in range(1, 3):
  840. mesh = None
  841. try:
  842. with alloc_fail(dev[0], i, "wpas_mesh_add_interface"):
  843. mesh = dev[0].request("MESH_INTERFACE_ADD").strip()
  844. finally:
  845. if mesh and mesh != "FAIL":
  846. dev[0].request("MESH_GROUP_REMOVE " + mesh)
  847. def test_mesh_scan_oom(dev):
  848. """wpa_supplicant mesh scan results and OOM"""
  849. check_mesh_support(dev[0])
  850. add_open_mesh_network(dev[0])
  851. check_mesh_group_added(dev[0])
  852. for i in range(5):
  853. dev[1].scan(freq="2412")
  854. res = dev[1].request("SCAN_RESULTS")
  855. if "[MESH]" in res:
  856. break
  857. for r in res.splitlines():
  858. if "[MESH]" in r:
  859. break
  860. bssid = r.split('\t')[0]
  861. bss = dev[1].get_bss(bssid)
  862. if bss is None:
  863. raise Exception("Could not get BSS entry for mesh")
  864. for i in range(1, 3):
  865. with alloc_fail(dev[1], i, "mesh_attr_text"):
  866. bss = dev[1].get_bss(bssid)
  867. if bss is not None:
  868. raise Exception("Unexpected BSS result during OOM")
  869. def test_mesh_sae_groups_invalid(dev, apdev):
  870. """Mesh with invalid SAE group configuration"""
  871. check_mesh_support(dev[0], secure=True)
  872. dev[0].request("SET sae_groups 25")
  873. id = add_mesh_secure_net(dev[0])
  874. dev[0].mesh_group_add(id)
  875. dev[1].request("SET sae_groups 123 122 121")
  876. id = add_mesh_secure_net(dev[1])
  877. dev[1].mesh_group_add(id)
  878. check_mesh_group_added(dev[0])
  879. check_mesh_group_added(dev[1])
  880. ev = dev[0].wait_event(["new peer notification"], timeout=10)
  881. if ev is None:
  882. raise Exception("dev[0] did not see peer")
  883. ev = dev[1].wait_event(["new peer notification"], timeout=10)
  884. if ev is None:
  885. raise Exception("dev[1] did not see peer")
  886. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  887. if ev is not None:
  888. raise Exception("Unexpected connection(0)")
  889. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  890. if ev is not None:
  891. raise Exception("Unexpected connection(1)")
  892. dev[0].request("SET sae_groups ")
  893. dev[1].request("SET sae_groups ")