test_wpas_mesh.py 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  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 struct
  10. import subprocess
  11. import time
  12. import hwsim_utils
  13. import hostapd
  14. from wpasupplicant import WpaSupplicant
  15. from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
  16. from tshark import run_tshark
  17. def check_mesh_support(dev, secure=False):
  18. if "MESH" not in dev.get_capability("modes"):
  19. raise HwsimSkip("Driver does not support mesh")
  20. if secure and "SAE" not in dev.get_capability("auth_alg"):
  21. raise HwsimSkip("SAE not supported")
  22. def check_mesh_scan(dev, params, other_started=False, beacon_int=0):
  23. if not other_started:
  24. dev.dump_monitor()
  25. id = dev.request("SCAN " + params)
  26. if "FAIL" in id:
  27. raise Exception("Failed to start scan")
  28. id = int(id)
  29. if other_started:
  30. ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
  31. if ev is None:
  32. raise Exception("Other scan did not start")
  33. if "id=" + str(id) in ev:
  34. raise Exception("Own scan id unexpectedly included in start event")
  35. ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
  36. if ev is None:
  37. raise Exception("Other scan did not complete")
  38. if "id=" + str(id) in ev:
  39. raise Exception(
  40. "Own scan id unexpectedly included in completed event")
  41. ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
  42. if ev is None:
  43. raise Exception("Scan did not start")
  44. if "id=" + str(id) not in ev:
  45. raise Exception("Scan id not included in start event")
  46. ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
  47. if ev is None:
  48. raise Exception("Scan did not complete")
  49. if "id=" + str(id) not in ev:
  50. raise Exception("Scan id not included in completed event")
  51. res = dev.request("SCAN_RESULTS")
  52. if res.find("[MESH]") < 0:
  53. raise Exception("Scan did not contain a MESH network")
  54. bssid = res.splitlines()[1].split(' ')[0]
  55. bss = dev.get_bss(bssid)
  56. if bss is None:
  57. raise Exception("Could not get BSS entry for mesh")
  58. if 'mesh_capability' not in bss:
  59. raise Exception("mesh_capability missing from BSS entry")
  60. if beacon_int:
  61. if 'beacon_int' not in bss:
  62. raise Exception("beacon_int missing from BSS entry")
  63. if str(beacon_int) != bss['beacon_int']:
  64. raise Exception("Unexpected beacon_int in BSS entry: " + bss['beacon_int'])
  65. def check_mesh_group_added(dev):
  66. ev = dev.wait_event(["MESH-GROUP-STARTED"])
  67. if ev is None:
  68. raise Exception("Test exception: Couldn't join mesh")
  69. def check_mesh_group_removed(dev):
  70. ev = dev.wait_event(["MESH-GROUP-REMOVED"])
  71. if ev is None:
  72. raise Exception("Test exception: Couldn't leave mesh")
  73. def check_mesh_peer_connected(dev, timeout=10):
  74. ev = dev.wait_event(["MESH-PEER-CONNECTED"], timeout=timeout)
  75. if ev is None:
  76. raise Exception("Test exception: Remote peer did not connect.")
  77. def check_mesh_peer_disconnected(dev):
  78. ev = dev.wait_event(["MESH-PEER-DISCONNECTED"])
  79. if ev is None:
  80. raise Exception("Test exception: Peer disconnect event not detected.")
  81. def test_wpas_add_set_remove_support(dev):
  82. """wpa_supplicant MESH add/set/remove network support"""
  83. check_mesh_support(dev[0])
  84. id = dev[0].add_network()
  85. dev[0].set_network(id, "mode", "5")
  86. dev[0].remove_network(id)
  87. def add_open_mesh_network(dev, freq="2412", start=True, beacon_int=0,
  88. basic_rates=None, chwidth=0):
  89. id = dev.add_network()
  90. dev.set_network(id, "mode", "5")
  91. dev.set_network_quoted(id, "ssid", "wpas-mesh-open")
  92. dev.set_network(id, "key_mgmt", "NONE")
  93. if freq:
  94. dev.set_network(id, "frequency", freq)
  95. if chwidth > 0:
  96. dev.set_network(id, "max_oper_chwidth", str(chwidth))
  97. if beacon_int:
  98. dev.set_network(id, "beacon_int", str(beacon_int))
  99. if basic_rates:
  100. dev.set_network(id, "mesh_basic_rates", basic_rates)
  101. if start:
  102. dev.mesh_group_add(id)
  103. return id
  104. def test_wpas_mesh_group_added(dev):
  105. """wpa_supplicant MESH group add"""
  106. check_mesh_support(dev[0])
  107. add_open_mesh_network(dev[0])
  108. # Check for MESH-GROUP-STARTED event
  109. check_mesh_group_added(dev[0])
  110. def test_wpas_mesh_group_remove(dev):
  111. """wpa_supplicant MESH group remove"""
  112. check_mesh_support(dev[0])
  113. add_open_mesh_network(dev[0])
  114. # Check for MESH-GROUP-STARTED event
  115. check_mesh_group_added(dev[0])
  116. dev[0].mesh_group_remove()
  117. # Check for MESH-GROUP-REMOVED event
  118. check_mesh_group_removed(dev[0])
  119. dev[0].mesh_group_remove()
  120. def test_wpas_mesh_peer_connected(dev):
  121. """wpa_supplicant MESH peer connected"""
  122. check_mesh_support(dev[0])
  123. add_open_mesh_network(dev[0], beacon_int=160)
  124. add_open_mesh_network(dev[1], beacon_int=160)
  125. # Check for mesh joined
  126. check_mesh_group_added(dev[0])
  127. check_mesh_group_added(dev[1])
  128. # Check for peer connected
  129. check_mesh_peer_connected(dev[0])
  130. check_mesh_peer_connected(dev[1])
  131. def test_wpas_mesh_peer_disconnected(dev):
  132. """wpa_supplicant MESH peer disconnected"""
  133. check_mesh_support(dev[0])
  134. add_open_mesh_network(dev[0])
  135. add_open_mesh_network(dev[1])
  136. # Check for mesh joined
  137. check_mesh_group_added(dev[0])
  138. check_mesh_group_added(dev[1])
  139. # Check for peer connected
  140. check_mesh_peer_connected(dev[0])
  141. check_mesh_peer_connected(dev[1])
  142. # Remove group on dev 1
  143. dev[1].mesh_group_remove()
  144. # Device 0 should get a disconnection event
  145. check_mesh_peer_disconnected(dev[0])
  146. def test_wpas_mesh_mode_scan(dev):
  147. """wpa_supplicant MESH scan support"""
  148. check_mesh_support(dev[0])
  149. add_open_mesh_network(dev[0])
  150. add_open_mesh_network(dev[1], beacon_int=175)
  151. # Check for mesh joined
  152. check_mesh_group_added(dev[0])
  153. check_mesh_group_added(dev[1])
  154. # Check for Mesh scan
  155. check_mesh_scan(dev[0], "use_id=1", beacon_int=175)
  156. def test_wpas_mesh_open(dev, apdev):
  157. """wpa_supplicant open MESH network connectivity"""
  158. check_mesh_support(dev[0])
  159. add_open_mesh_network(dev[0], freq="2462", basic_rates="60 120 240")
  160. add_open_mesh_network(dev[1], freq="2462", basic_rates="60 120 240")
  161. # Check for mesh joined
  162. check_mesh_group_added(dev[0])
  163. check_mesh_group_added(dev[1])
  164. # Check for peer connected
  165. check_mesh_peer_connected(dev[0])
  166. check_mesh_peer_connected(dev[1])
  167. # Test connectivity 0->1 and 1->0
  168. hwsim_utils.test_connectivity(dev[0], dev[1])
  169. def test_wpas_mesh_open_no_auto(dev, apdev):
  170. """wpa_supplicant open MESH network connectivity"""
  171. check_mesh_support(dev[0])
  172. id = add_open_mesh_network(dev[0], start=False)
  173. dev[0].set_network(id, "dot11MeshMaxRetries", "16")
  174. dev[0].set_network(id, "dot11MeshRetryTimeout", "255")
  175. dev[0].mesh_group_add(id)
  176. id = add_open_mesh_network(dev[1], start=False)
  177. dev[1].set_network(id, "no_auto_peer", "1")
  178. dev[1].mesh_group_add(id)
  179. # Check for mesh joined
  180. check_mesh_group_added(dev[0])
  181. check_mesh_group_added(dev[1])
  182. # Check for peer connected
  183. check_mesh_peer_connected(dev[0], timeout=30)
  184. check_mesh_peer_connected(dev[1])
  185. # Test connectivity 0->1 and 1->0
  186. hwsim_utils.test_connectivity(dev[0], dev[1])
  187. def add_mesh_secure_net(dev, psk=True):
  188. id = dev.add_network()
  189. dev.set_network(id, "mode", "5")
  190. dev.set_network_quoted(id, "ssid", "wpas-mesh-sec")
  191. dev.set_network(id, "key_mgmt", "SAE")
  192. dev.set_network(id, "frequency", "2412")
  193. if psk:
  194. dev.set_network_quoted(id, "psk", "thisismypassphrase!")
  195. return id
  196. def test_wpas_mesh_secure(dev, apdev):
  197. """wpa_supplicant secure MESH network connectivity"""
  198. check_mesh_support(dev[0], secure=True)
  199. dev[0].request("SET sae_groups ")
  200. id = add_mesh_secure_net(dev[0])
  201. dev[0].mesh_group_add(id)
  202. dev[1].request("SET sae_groups ")
  203. id = add_mesh_secure_net(dev[1])
  204. dev[1].mesh_group_add(id)
  205. # Check for mesh joined
  206. check_mesh_group_added(dev[0])
  207. check_mesh_group_added(dev[1])
  208. # Check for peer connected
  209. check_mesh_peer_connected(dev[0])
  210. check_mesh_peer_connected(dev[1])
  211. # Test connectivity 0->1 and 1->0
  212. hwsim_utils.test_connectivity(dev[0], dev[1])
  213. def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev):
  214. """wpa_supplicant secure MESH and SAE group mismatch"""
  215. check_mesh_support(dev[0], secure=True)
  216. addr0 = dev[0].p2p_interface_addr()
  217. addr1 = dev[1].p2p_interface_addr()
  218. addr2 = dev[2].p2p_interface_addr()
  219. dev[0].request("SET sae_groups 19 25")
  220. id = add_mesh_secure_net(dev[0])
  221. dev[0].mesh_group_add(id)
  222. dev[1].request("SET sae_groups 19")
  223. id = add_mesh_secure_net(dev[1])
  224. dev[1].mesh_group_add(id)
  225. dev[2].request("SET sae_groups 26")
  226. id = add_mesh_secure_net(dev[2])
  227. dev[2].mesh_group_add(id)
  228. check_mesh_group_added(dev[0])
  229. check_mesh_group_added(dev[1])
  230. check_mesh_group_added(dev[2])
  231. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"])
  232. if ev is None:
  233. raise Exception("Remote peer did not connect")
  234. if addr1 not in ev:
  235. raise Exception("Unexpected peer connected: " + ev)
  236. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"])
  237. if ev is None:
  238. raise Exception("Remote peer did not connect")
  239. if addr0 not in ev:
  240. raise Exception("Unexpected peer connected: " + ev)
  241. ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
  242. if ev is not None:
  243. raise Exception("Unexpected peer connection at dev[2]: " + ev)
  244. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  245. if ev is not None:
  246. raise Exception("Unexpected peer connection: " + ev)
  247. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  248. if ev is not None:
  249. raise Exception("Unexpected peer connection: " + ev)
  250. dev[0].request("SET sae_groups ")
  251. dev[1].request("SET sae_groups ")
  252. dev[2].request("SET sae_groups ")
  253. def test_wpas_mesh_secure_sae_group_negotiation(dev, apdev):
  254. """wpa_supplicant secure MESH and SAE group negotiation"""
  255. check_mesh_support(dev[0], secure=True)
  256. addr0 = dev[0].own_addr()
  257. addr1 = dev[1].own_addr()
  258. #dev[0].request("SET sae_groups 21 20 25 26")
  259. dev[0].request("SET sae_groups 25")
  260. id = add_mesh_secure_net(dev[0])
  261. dev[0].mesh_group_add(id)
  262. dev[1].request("SET sae_groups 19 25")
  263. id = add_mesh_secure_net(dev[1])
  264. dev[1].mesh_group_add(id)
  265. check_mesh_group_added(dev[0])
  266. check_mesh_group_added(dev[1])
  267. check_mesh_peer_connected(dev[0])
  268. check_mesh_peer_connected(dev[1])
  269. dev[0].request("SET sae_groups ")
  270. dev[1].request("SET sae_groups ")
  271. def test_wpas_mesh_secure_sae_missing_password(dev, apdev):
  272. """wpa_supplicant secure MESH and missing SAE password"""
  273. check_mesh_support(dev[0], secure=True)
  274. id = add_mesh_secure_net(dev[0], psk=False)
  275. dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a")
  276. dev[0].mesh_group_add(id)
  277. ev = dev[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"],
  278. timeout=5)
  279. if ev is None:
  280. raise Exception("Timeout on mesh start event")
  281. if "MESH-GROUP-STARTED" in ev:
  282. raise Exception("Unexpected mesh group start")
  283. ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.1)
  284. if ev is not None:
  285. raise Exception("Unexpected mesh group start")
  286. def test_wpas_mesh_secure_no_auto(dev, apdev):
  287. """wpa_supplicant secure MESH network connectivity"""
  288. check_mesh_support(dev[0], secure=True)
  289. dev[0].request("SET sae_groups 19")
  290. id = add_mesh_secure_net(dev[0])
  291. dev[0].mesh_group_add(id)
  292. dev[1].request("SET sae_groups 19")
  293. id = add_mesh_secure_net(dev[1])
  294. dev[1].set_network(id, "no_auto_peer", "1")
  295. dev[1].mesh_group_add(id)
  296. # Check for mesh joined
  297. check_mesh_group_added(dev[0])
  298. check_mesh_group_added(dev[1])
  299. # Check for peer connected
  300. check_mesh_peer_connected(dev[0], timeout=30)
  301. check_mesh_peer_connected(dev[1])
  302. # Test connectivity 0->1 and 1->0
  303. hwsim_utils.test_connectivity(dev[0], dev[1])
  304. dev[0].request("SET sae_groups ")
  305. dev[1].request("SET sae_groups ")
  306. def test_wpas_mesh_secure_dropped_frame(dev, apdev):
  307. """Secure mesh network connectivity when the first plink Open is dropped"""
  308. check_mesh_support(dev[0], secure=True)
  309. dev[0].request("SET ext_mgmt_frame_handling 1")
  310. dev[0].request("SET sae_groups ")
  311. id = add_mesh_secure_net(dev[0])
  312. dev[0].mesh_group_add(id)
  313. dev[1].request("SET sae_groups ")
  314. id = add_mesh_secure_net(dev[1])
  315. dev[1].mesh_group_add(id)
  316. # Check for mesh joined
  317. check_mesh_group_added(dev[0])
  318. check_mesh_group_added(dev[1])
  319. # Drop the first Action frame (plink Open) to test unexpected order of
  320. # Confirm/Open messages.
  321. count = 0
  322. while True:
  323. count += 1
  324. if count > 10:
  325. raise Exception("Did not see Action frames")
  326. rx_msg = dev[0].mgmt_rx()
  327. if rx_msg is None:
  328. raise Exception("MGMT-RX timeout")
  329. if rx_msg['subtype'] == 13:
  330. logger.info("Drop the first Action frame")
  331. break
  332. 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'))):
  333. raise Exception("MGMT_RX_PROCESS failed")
  334. dev[0].request("SET ext_mgmt_frame_handling 0")
  335. # Check for peer connected
  336. check_mesh_peer_connected(dev[0])
  337. check_mesh_peer_connected(dev[1])
  338. # Test connectivity 0->1 and 1->0
  339. hwsim_utils.test_connectivity(dev[0], dev[1])
  340. def test_wpas_mesh_ctrl(dev):
  341. """wpa_supplicant ctrl_iface mesh command error cases"""
  342. check_mesh_support(dev[0])
  343. if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"):
  344. raise Exception("Unexpected MESH_GROUP_ADD success")
  345. id = dev[0].add_network()
  346. if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
  347. raise Exception("Unexpected MESH_GROUP_ADD success")
  348. dev[0].set_network(id, "mode", "5")
  349. dev[0].set_network(id, "key_mgmt", "WPA-PSK")
  350. if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id):
  351. raise Exception("Unexpected MESH_GROUP_ADD success")
  352. if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE foo"):
  353. raise Exception("Unexpected MESH_GROUP_REMOVE success")
  354. def test_wpas_mesh_dynamic_interface(dev):
  355. """wpa_supplicant mesh with dynamic interface"""
  356. check_mesh_support(dev[0])
  357. mesh0 = None
  358. mesh1 = None
  359. try:
  360. mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
  361. if "FAIL" in mesh0:
  362. raise Exception("MESH_INTERFACE_ADD failed")
  363. mesh1 = dev[1].request("MESH_INTERFACE_ADD")
  364. if "FAIL" in mesh1:
  365. raise Exception("MESH_INTERFACE_ADD failed")
  366. wpas0 = WpaSupplicant(ifname=mesh0)
  367. wpas1 = WpaSupplicant(ifname=mesh1)
  368. logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
  369. logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
  370. add_open_mesh_network(wpas0)
  371. add_open_mesh_network(wpas1)
  372. check_mesh_group_added(wpas0)
  373. check_mesh_group_added(wpas1)
  374. check_mesh_peer_connected(wpas0)
  375. check_mesh_peer_connected(wpas1)
  376. hwsim_utils.test_connectivity(wpas0, wpas1)
  377. # Must not allow MESH_GROUP_REMOVE on dynamic interface
  378. if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh0):
  379. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  380. if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh1):
  381. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  382. # Must not allow MESH_GROUP_REMOVE on another radio interface
  383. if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh1):
  384. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  385. if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh0):
  386. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  387. wpas0.remove_ifname()
  388. wpas1.remove_ifname()
  389. if "OK" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
  390. raise Exception("MESH_GROUP_REMOVE failed")
  391. if "OK" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
  392. raise Exception("MESH_GROUP_REMOVE failed")
  393. if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0):
  394. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  395. if "FAIL" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1):
  396. raise Exception("Invalid MESH_GROUP_REMOVE accepted")
  397. logger.info("Make sure another dynamic group can be added")
  398. mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0")
  399. if "FAIL" in mesh0:
  400. raise Exception("MESH_INTERFACE_ADD failed")
  401. mesh1 = dev[1].request("MESH_INTERFACE_ADD")
  402. if "FAIL" in mesh1:
  403. raise Exception("MESH_INTERFACE_ADD failed")
  404. wpas0 = WpaSupplicant(ifname=mesh0)
  405. wpas1 = WpaSupplicant(ifname=mesh1)
  406. logger.info(mesh0 + " address " + wpas0.get_status_field("address"))
  407. logger.info(mesh1 + " address " + wpas1.get_status_field("address"))
  408. add_open_mesh_network(wpas0)
  409. add_open_mesh_network(wpas1)
  410. check_mesh_group_added(wpas0)
  411. check_mesh_group_added(wpas1)
  412. check_mesh_peer_connected(wpas0)
  413. check_mesh_peer_connected(wpas1)
  414. hwsim_utils.test_connectivity(wpas0, wpas1)
  415. finally:
  416. if mesh0:
  417. dev[0].request("MESH_GROUP_REMOVE " + mesh0)
  418. if mesh1:
  419. dev[1].request("MESH_GROUP_REMOVE " + mesh1)
  420. def test_wpas_mesh_max_peering(dev, apdev):
  421. """Mesh max peering limit"""
  422. check_mesh_support(dev[0])
  423. try:
  424. dev[0].request("SET max_peer_links 1")
  425. # first, connect dev[0] and dev[1]
  426. add_open_mesh_network(dev[0])
  427. add_open_mesh_network(dev[1])
  428. for i in range(2):
  429. ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
  430. if ev is None:
  431. raise Exception("dev%d did not connect with any peer" % i)
  432. # add dev[2] which will try to connect with both dev[0] and dev[1],
  433. # but can complete connection only with dev[1]
  434. add_open_mesh_network(dev[2])
  435. for i in range(1, 3):
  436. ev = dev[i].wait_event(["MESH-PEER-CONNECTED"])
  437. if ev is None:
  438. raise Exception("dev%d did not connect the second peer" % i)
  439. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=1)
  440. if ev is not None:
  441. raise Exception("dev0 connection beyond max peering limit")
  442. ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  443. if ev is not None:
  444. raise Exception("dev2 reported unexpected peering: " + ev)
  445. for i in range(3):
  446. dev[i].mesh_group_remove()
  447. check_mesh_group_removed(dev[i])
  448. finally:
  449. dev[0].request("SET max_peer_links 99")
  450. def test_wpas_mesh_open_5ghz(dev, apdev):
  451. """wpa_supplicant open MESH network on 5 GHz band"""
  452. try:
  453. _test_wpas_mesh_open_5ghz(dev, apdev)
  454. finally:
  455. subprocess.call(['iw', 'reg', 'set', '00'])
  456. dev[0].flush_scan_cache()
  457. dev[1].flush_scan_cache()
  458. def _test_wpas_mesh_open_5ghz(dev, apdev):
  459. check_mesh_support(dev[0])
  460. subprocess.call(['iw', 'reg', 'set', 'US'])
  461. for i in range(2):
  462. for j in range(5):
  463. ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
  464. if ev is None:
  465. raise Exception("No regdom change event")
  466. if "alpha2=US" in ev:
  467. break
  468. add_open_mesh_network(dev[i], freq="5180")
  469. # Check for mesh joined
  470. check_mesh_group_added(dev[0])
  471. check_mesh_group_added(dev[1])
  472. # Check for peer connected
  473. check_mesh_peer_connected(dev[0])
  474. check_mesh_peer_connected(dev[1])
  475. # Test connectivity 0->1 and 1->0
  476. hwsim_utils.test_connectivity(dev[0], dev[1])
  477. def test_wpas_mesh_open_vht_80p80(dev, apdev):
  478. """wpa_supplicant open MESH network on VHT 80+80 MHz channel"""
  479. try:
  480. _test_wpas_mesh_open_vht_80p80(dev, apdev)
  481. finally:
  482. subprocess.call(['iw', 'reg', 'set', '00'])
  483. dev[0].flush_scan_cache()
  484. dev[1].flush_scan_cache()
  485. def _test_wpas_mesh_open_vht_80p80(dev, apdev):
  486. check_mesh_support(dev[0])
  487. subprocess.call(['iw', 'reg', 'set', 'US'])
  488. for i in range(2):
  489. for j in range(5):
  490. ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
  491. if ev is None:
  492. raise Exception("No regdom change event")
  493. if "alpha2=US" in ev:
  494. break
  495. add_open_mesh_network(dev[i], freq="5180", chwidth=3)
  496. # Check for mesh joined
  497. check_mesh_group_added(dev[0])
  498. check_mesh_group_added(dev[1])
  499. # Check for peer connected
  500. check_mesh_peer_connected(dev[0])
  501. check_mesh_peer_connected(dev[1])
  502. # Test connectivity 0->1 and 1->0
  503. hwsim_utils.test_connectivity(dev[0], dev[1])
  504. sig = dev[0].request("SIGNAL_POLL").splitlines()
  505. if "WIDTH=80+80 MHz" not in sig:
  506. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  507. if "CENTER_FRQ1=5210" not in sig:
  508. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  509. if "CENTER_FRQ2=5775" not in sig:
  510. raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
  511. sig = dev[1].request("SIGNAL_POLL").splitlines()
  512. if "WIDTH=80+80 MHz" not in sig:
  513. raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
  514. if "CENTER_FRQ1=5210" not in sig:
  515. raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
  516. if "CENTER_FRQ2=5775" not in sig:
  517. raise Exception("Unexpected SIGNAL_POLL value(4b): " + str(sig))
  518. def test_mesh_open_vht_160(dev, apdev):
  519. """Open mesh network on VHT 160 MHz channel"""
  520. try:
  521. _test_mesh_open_vht_160(dev, apdev)
  522. finally:
  523. subprocess.call(['iw', 'reg', 'set', '00'])
  524. dev[0].flush_scan_cache()
  525. dev[1].flush_scan_cache()
  526. def _test_mesh_open_vht_160(dev, apdev):
  527. check_mesh_support(dev[0])
  528. subprocess.call(['iw', 'reg', 'set', 'ZA'])
  529. for i in range(2):
  530. for j in range(5):
  531. ev = dev[i].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=5)
  532. if ev is None:
  533. raise Exception("No regdom change event")
  534. if "alpha2=ZA" in ev:
  535. break
  536. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  537. reg = cmd.stdout.read()
  538. if "@ 160)" not in reg:
  539. raise HwsimSkip("160 MHz channel not supported in regulatory information")
  540. add_open_mesh_network(dev[i], freq="5520", chwidth=2)
  541. # Check for mesh joined
  542. check_mesh_group_added(dev[0])
  543. check_mesh_group_added(dev[1])
  544. # Check for peer connected
  545. check_mesh_peer_connected(dev[0])
  546. check_mesh_peer_connected(dev[1])
  547. # Test connectivity 0->1 and 1->0
  548. hwsim_utils.test_connectivity(dev[0], dev[1])
  549. sig = dev[0].request("SIGNAL_POLL").splitlines()
  550. if "WIDTH=160 MHz" not in sig:
  551. raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
  552. if "FREQUENCY=5520" not in sig:
  553. raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
  554. sig = dev[1].request("SIGNAL_POLL").splitlines()
  555. if "WIDTH=160 MHz" not in sig:
  556. raise Exception("Unexpected SIGNAL_POLL value(2b): " + str(sig))
  557. if "FREQUENCY=5520" not in sig:
  558. raise Exception("Unexpected SIGNAL_POLL value(3b): " + str(sig))
  559. def test_wpas_mesh_password_mismatch(dev, apdev):
  560. """Mesh network and one device with mismatching password"""
  561. check_mesh_support(dev[0], secure=True)
  562. dev[0].request("SET sae_groups ")
  563. id = add_mesh_secure_net(dev[0])
  564. dev[0].mesh_group_add(id)
  565. dev[1].request("SET sae_groups ")
  566. id = add_mesh_secure_net(dev[1])
  567. dev[1].mesh_group_add(id)
  568. dev[2].request("SET sae_groups ")
  569. id = add_mesh_secure_net(dev[2])
  570. dev[2].set_network_quoted(id, "psk", "wrong password")
  571. dev[2].mesh_group_add(id)
  572. # The two peers with matching password need to be able to connect
  573. check_mesh_group_added(dev[0])
  574. check_mesh_group_added(dev[1])
  575. check_mesh_peer_connected(dev[0])
  576. check_mesh_peer_connected(dev[1])
  577. ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  578. if ev is None:
  579. raise Exception("dev2 did not report auth failure (1)")
  580. ev = dev[2].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  581. if ev is None:
  582. raise Exception("dev2 did not report auth failure (2)")
  583. count = 0
  584. ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
  585. if ev is None:
  586. logger.info("dev0 did not report auth failure")
  587. else:
  588. if "addr=" + dev[2].own_addr() not in ev:
  589. raise Exception("Unexpected peer address in dev0 event: " + ev)
  590. count += 1
  591. ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=1)
  592. if ev is None:
  593. logger.info("dev1 did not report auth failure")
  594. else:
  595. if "addr=" + dev[2].own_addr() not in ev:
  596. raise Exception("Unexpected peer address in dev1 event: " + ev)
  597. count += 1
  598. hwsim_utils.test_connectivity(dev[0], dev[1])
  599. for i in range(2):
  600. try:
  601. hwsim_utils.test_connectivity(dev[i], dev[2], timeout=1)
  602. raise Exception("Data connectivity test passed unexpectedly")
  603. except Exception, e:
  604. if "data delivery failed" not in str(e):
  605. raise
  606. if count == 0:
  607. raise Exception("Neither dev0 nor dev1 reported auth failure")
  608. def test_wpas_mesh_password_mismatch_retry(dev, apdev, params):
  609. """Mesh password mismatch and retry [long]"""
  610. if not params['long']:
  611. raise HwsimSkip("Skip test case with long duration due to --long not specified")
  612. check_mesh_support(dev[0], secure=True)
  613. dev[0].request("SET sae_groups ")
  614. id = add_mesh_secure_net(dev[0])
  615. dev[0].mesh_group_add(id)
  616. dev[1].request("SET sae_groups ")
  617. id = add_mesh_secure_net(dev[1])
  618. dev[1].set_network_quoted(id, "psk", "wrong password")
  619. dev[1].mesh_group_add(id)
  620. # Check for mesh joined
  621. check_mesh_group_added(dev[0])
  622. check_mesh_group_added(dev[1])
  623. for i in range(4):
  624. ev = dev[0].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  625. if ev is None:
  626. raise Exception("dev0 did not report auth failure (%d)" % i)
  627. ev = dev[1].wait_event(["MESH-SAE-AUTH-FAILURE"], timeout=20)
  628. if ev is None:
  629. raise Exception("dev1 did not report auth failure (%d)" % i)
  630. ev = dev[0].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
  631. if ev is None:
  632. raise Exception("dev0 did not report auth blocked")
  633. ev = dev[1].wait_event(["MESH-SAE-AUTH-BLOCKED"], timeout=10)
  634. if ev is None:
  635. raise Exception("dev1 did not report auth blocked")
  636. def test_mesh_wpa_auth_init_oom(dev, apdev):
  637. """Secure mesh network setup failing due to wpa_init() OOM"""
  638. check_mesh_support(dev[0], secure=True)
  639. dev[0].request("SET sae_groups ")
  640. with alloc_fail(dev[0], 1, "wpa_init"):
  641. id = add_mesh_secure_net(dev[0])
  642. dev[0].mesh_group_add(id)
  643. ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.2)
  644. if ev is not None:
  645. raise Exception("Unexpected mesh group start during OOM")
  646. def test_mesh_wpa_init_fail(dev, apdev):
  647. """Secure mesh network setup local failure"""
  648. check_mesh_support(dev[0], secure=True)
  649. dev[0].request("SET sae_groups ")
  650. with fail_test(dev[0], 1, "os_get_random;=__mesh_rsn_auth_init"):
  651. id = add_mesh_secure_net(dev[0])
  652. dev[0].mesh_group_add(id)
  653. wait_fail_trigger(dev[0], "GET_FAIL")
  654. dev[0].dump_monitor()
  655. with alloc_fail(dev[0], 1, "mesh_rsn_auth_init"):
  656. id = add_mesh_secure_net(dev[0])
  657. dev[0].mesh_group_add(id)
  658. wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
  659. dev[0].dump_monitor()
  660. with fail_test(dev[0], 1, "os_get_random;mesh_rsn_init_ampe_sta"):
  661. id = add_mesh_secure_net(dev[0])
  662. dev[0].mesh_group_add(id)
  663. dev[1].request("SET sae_groups ")
  664. id = add_mesh_secure_net(dev[1])
  665. dev[1].mesh_group_add(id)
  666. wait_fail_trigger(dev[0], "GET_FAIL")
  667. def test_wpas_mesh_reconnect(dev, apdev):
  668. """Secure mesh network plink counting during reconnection"""
  669. check_mesh_support(dev[0])
  670. try:
  671. _test_wpas_mesh_reconnect(dev)
  672. finally:
  673. dev[0].request("SET max_peer_links 99")
  674. def _test_wpas_mesh_reconnect(dev):
  675. dev[0].request("SET max_peer_links 2")
  676. dev[0].request("SET sae_groups ")
  677. id = add_mesh_secure_net(dev[0])
  678. dev[0].set_network(id, "beacon_int", "100")
  679. dev[0].mesh_group_add(id)
  680. dev[1].request("SET sae_groups ")
  681. id = add_mesh_secure_net(dev[1])
  682. dev[1].mesh_group_add(id)
  683. check_mesh_group_added(dev[0])
  684. check_mesh_group_added(dev[1])
  685. check_mesh_peer_connected(dev[0])
  686. check_mesh_peer_connected(dev[1])
  687. for i in range(3):
  688. # Drop incoming management frames to avoid handling link close
  689. dev[0].request("SET ext_mgmt_frame_handling 1")
  690. dev[1].mesh_group_remove()
  691. check_mesh_group_removed(dev[1])
  692. dev[1].request("FLUSH")
  693. dev[0].request("SET ext_mgmt_frame_handling 0")
  694. id = add_mesh_secure_net(dev[1])
  695. dev[1].mesh_group_add(id)
  696. check_mesh_group_added(dev[1])
  697. check_mesh_peer_connected(dev[1])
  698. dev[0].dump_monitor()
  699. dev[1].dump_monitor()
  700. def test_wpas_mesh_gate_forwarding(dev, apdev, p):
  701. """Mesh forwards traffic to unknown sta to mesh gates"""
  702. addr0 = dev[0].own_addr()
  703. addr1 = dev[1].own_addr()
  704. addr2 = dev[2].own_addr()
  705. external_sta = '02:11:22:33:44:55'
  706. # start 3 node connected mesh
  707. check_mesh_support(dev[0])
  708. for i in range(3):
  709. add_open_mesh_network(dev[i])
  710. check_mesh_group_added(dev[i])
  711. for i in range(3):
  712. check_mesh_peer_connected(dev[i])
  713. hwsim_utils.test_connectivity(dev[0], dev[1])
  714. hwsim_utils.test_connectivity(dev[1], dev[2])
  715. hwsim_utils.test_connectivity(dev[0], dev[2])
  716. # dev0 and dev1 are mesh gates
  717. subprocess.call(['iw', 'dev', dev[0].ifname, 'set', 'mesh_param',
  718. 'mesh_gate_announcements=1'])
  719. subprocess.call(['iw', 'dev', dev[1].ifname, 'set', 'mesh_param',
  720. 'mesh_gate_announcements=1'])
  721. # wait for gate announcement frames
  722. time.sleep(1)
  723. # data frame from dev2 -> external sta should be sent to both gates
  724. dev[2].request("DATA_TEST_CONFIG 1")
  725. dev[2].request("DATA_TEST_TX {} {} 0".format(external_sta, addr2))
  726. dev[2].request("DATA_TEST_CONFIG 0")
  727. capfile = os.path.join(p['logdir'], "hwsim0.pcapng")
  728. filt = "wlan.sa==%s && wlan_mgt.fixed.mesh_addr5==%s" % (addr2,
  729. external_sta)
  730. for i in range(15):
  731. da = run_tshark(capfile, filt, [ "wlan.da" ])
  732. if addr0 in da and addr1 in da:
  733. logger.debug("Frames seen in tshark iteration %d" % i)
  734. break
  735. time.sleep(0.3)
  736. if addr0 not in da:
  737. raise Exception("Frame to gate %s not observed" % addr0)
  738. if addr1 not in da:
  739. raise Exception("Frame to gate %s not observed" % addr1)
  740. def test_wpas_mesh_pmksa_caching(dev, apdev):
  741. """Secure mesh network and PMKSA caching"""
  742. check_mesh_support(dev[0], secure=True)
  743. dev[0].request("SET sae_groups ")
  744. id = add_mesh_secure_net(dev[0])
  745. dev[0].mesh_group_add(id)
  746. dev[1].request("SET sae_groups ")
  747. id = add_mesh_secure_net(dev[1])
  748. dev[1].mesh_group_add(id)
  749. # Check for mesh joined
  750. check_mesh_group_added(dev[0])
  751. check_mesh_group_added(dev[1])
  752. # Check for peer connected
  753. check_mesh_peer_connected(dev[0])
  754. check_mesh_peer_connected(dev[1])
  755. addr0 = dev[0].own_addr()
  756. addr1 = dev[1].own_addr()
  757. pmksa0 = dev[0].get_pmksa(addr1)
  758. pmksa1 = dev[1].get_pmksa(addr0)
  759. if pmksa0 is None or pmksa1 is None:
  760. raise Exception("No PMKSA cache entry created")
  761. if pmksa0['pmkid'] != pmksa1['pmkid']:
  762. raise Exception("PMKID mismatch in PMKSA cache entries")
  763. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  764. raise Exception("Failed to remove peer")
  765. pmksa0b = dev[0].get_pmksa(addr1)
  766. if pmksa0b is None:
  767. raise Exception("PMKSA cache entry not maintained")
  768. time.sleep(0.1)
  769. if "FAIL" not in dev[0].request("MESH_PEER_ADD " + addr1):
  770. raise Exception("MESH_PEER_ADD unexpectedly succeeded in no_auto_peer=0 case")
  771. def test_wpas_mesh_pmksa_caching2(dev, apdev):
  772. """Secure mesh network and PMKSA caching with no_auto_peer=1"""
  773. check_mesh_support(dev[0], secure=True)
  774. addr0 = dev[0].own_addr()
  775. addr1 = dev[1].own_addr()
  776. dev[0].request("SET sae_groups ")
  777. id = add_mesh_secure_net(dev[0])
  778. dev[0].set_network(id, "no_auto_peer", "1")
  779. dev[0].mesh_group_add(id)
  780. dev[1].request("SET sae_groups ")
  781. id = add_mesh_secure_net(dev[1])
  782. dev[1].set_network(id, "no_auto_peer", "1")
  783. dev[1].mesh_group_add(id)
  784. # Check for mesh joined
  785. check_mesh_group_added(dev[0])
  786. check_mesh_group_added(dev[1])
  787. # Check for peer connected
  788. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  789. if ev is None:
  790. raise Exception("Missing no-initiate message")
  791. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  792. raise Exception("MESH_PEER_ADD failed")
  793. check_mesh_peer_connected(dev[0])
  794. check_mesh_peer_connected(dev[1])
  795. pmksa0 = dev[0].get_pmksa(addr1)
  796. pmksa1 = dev[1].get_pmksa(addr0)
  797. if pmksa0 is None or pmksa1 is None:
  798. raise Exception("No PMKSA cache entry created")
  799. if pmksa0['pmkid'] != pmksa1['pmkid']:
  800. raise Exception("PMKID mismatch in PMKSA cache entries")
  801. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  802. raise Exception("Failed to remove peer")
  803. pmksa0b = dev[0].get_pmksa(addr1)
  804. if pmksa0b is None:
  805. raise Exception("PMKSA cache entry not maintained")
  806. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  807. if ev is None:
  808. raise Exception("Missing no-initiate message (2)")
  809. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  810. raise Exception("MESH_PEER_ADD failed (2)")
  811. check_mesh_peer_connected(dev[0])
  812. check_mesh_peer_connected(dev[1])
  813. pmksa0c = dev[0].get_pmksa(addr1)
  814. pmksa1c = dev[1].get_pmksa(addr0)
  815. if pmksa0c is None or pmksa1c is None:
  816. raise Exception("No PMKSA cache entry created (2)")
  817. if pmksa0c['pmkid'] != pmksa1c['pmkid']:
  818. raise Exception("PMKID mismatch in PMKSA cache entries")
  819. if pmksa0['pmkid'] != pmksa0c['pmkid']:
  820. raise Exception("PMKID changed")
  821. hwsim_utils.test_connectivity(dev[0], dev[1])
  822. def test_wpas_mesh_pmksa_caching_no_match(dev, apdev):
  823. """Secure mesh network and PMKSA caching with no PMKID match"""
  824. check_mesh_support(dev[0], secure=True)
  825. addr0 = dev[0].own_addr()
  826. addr1 = dev[1].own_addr()
  827. dev[0].request("SET sae_groups ")
  828. id = add_mesh_secure_net(dev[0])
  829. dev[0].set_network(id, "no_auto_peer", "1")
  830. dev[0].mesh_group_add(id)
  831. dev[1].request("SET sae_groups ")
  832. id = add_mesh_secure_net(dev[1])
  833. dev[1].set_network(id, "no_auto_peer", "1")
  834. dev[1].mesh_group_add(id)
  835. # Check for mesh joined
  836. check_mesh_group_added(dev[0])
  837. check_mesh_group_added(dev[1])
  838. # Check for peer connected
  839. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  840. if ev is None:
  841. raise Exception("Missing no-initiate message")
  842. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  843. raise Exception("MESH_PEER_ADD failed")
  844. check_mesh_peer_connected(dev[0])
  845. check_mesh_peer_connected(dev[1])
  846. pmksa0 = dev[0].get_pmksa(addr1)
  847. pmksa1 = dev[1].get_pmksa(addr0)
  848. if pmksa0 is None or pmksa1 is None:
  849. raise Exception("No PMKSA cache entry created")
  850. if pmksa0['pmkid'] != pmksa1['pmkid']:
  851. raise Exception("PMKID mismatch in PMKSA cache entries")
  852. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  853. raise Exception("Failed to remove peer")
  854. if "OK" not in dev[1].request("PMKSA_FLUSH"):
  855. raise Exception("Failed to flush PMKSA cache")
  856. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  857. if ev is None:
  858. raise Exception("Missing no-initiate message (2)")
  859. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  860. raise Exception("MESH_PEER_ADD failed (2)")
  861. check_mesh_peer_connected(dev[0])
  862. check_mesh_peer_connected(dev[1])
  863. pmksa0c = dev[0].get_pmksa(addr1)
  864. pmksa1c = dev[1].get_pmksa(addr0)
  865. if pmksa0c is None or pmksa1c is None:
  866. raise Exception("No PMKSA cache entry created (2)")
  867. if pmksa0c['pmkid'] != pmksa1c['pmkid']:
  868. raise Exception("PMKID mismatch in PMKSA cache entries")
  869. if pmksa0['pmkid'] == pmksa0c['pmkid']:
  870. raise Exception("PMKID did not change")
  871. hwsim_utils.test_connectivity(dev[0], dev[1])
  872. def test_mesh_pmksa_caching_oom(dev, apdev):
  873. """Secure mesh network and PMKSA caching failing due to OOM"""
  874. check_mesh_support(dev[0], secure=True)
  875. addr0 = dev[0].own_addr()
  876. addr1 = dev[1].own_addr()
  877. dev[0].request("SET sae_groups ")
  878. id = add_mesh_secure_net(dev[0])
  879. dev[0].set_network(id, "no_auto_peer", "1")
  880. dev[0].mesh_group_add(id)
  881. dev[1].request("SET sae_groups ")
  882. id = add_mesh_secure_net(dev[1])
  883. dev[1].set_network(id, "no_auto_peer", "1")
  884. dev[1].mesh_group_add(id)
  885. # Check for mesh joined
  886. check_mesh_group_added(dev[0])
  887. check_mesh_group_added(dev[1])
  888. # Check for peer connected
  889. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  890. if ev is None:
  891. raise Exception("Missing no-initiate message")
  892. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  893. raise Exception("MESH_PEER_ADD failed")
  894. check_mesh_peer_connected(dev[0])
  895. check_mesh_peer_connected(dev[1])
  896. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  897. raise Exception("Failed to remove peer")
  898. pmksa0b = dev[0].get_pmksa(addr1)
  899. if pmksa0b is None:
  900. raise Exception("PMKSA cache entry not maintained")
  901. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  902. if ev is None:
  903. raise Exception("Missing no-initiate message (2)")
  904. with alloc_fail(dev[0], 1, "wpa_auth_sta_init;mesh_rsn_auth_sae_sta"):
  905. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  906. raise Exception("MESH_PEER_ADD failed (2)")
  907. wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
  908. def test_mesh_oom(dev, apdev):
  909. """Mesh network setup failing due to OOM"""
  910. check_mesh_support(dev[0], secure=True)
  911. dev[0].request("SET sae_groups ")
  912. with alloc_fail(dev[0], 1, "mesh_config_create"):
  913. add_open_mesh_network(dev[0])
  914. ev = dev[0].wait_event(["Failed to init mesh"])
  915. if ev is None:
  916. raise Exception("Init failure not reported")
  917. with alloc_fail(dev[0], 4, "=wpa_supplicant_mesh_init"):
  918. add_open_mesh_network(dev[0], basic_rates="60 120 240")
  919. ev = dev[0].wait_event(["Failed to init mesh"])
  920. if ev is None:
  921. raise Exception("Init failure not reported")
  922. for i in range(1, 66):
  923. dev[0].dump_monitor()
  924. logger.info("Test instance %d" % i)
  925. try:
  926. with alloc_fail(dev[0], i, "wpa_supplicant_mesh_init"):
  927. add_open_mesh_network(dev[0])
  928. wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
  929. ev = dev[0].wait_event(["Failed to init mesh",
  930. "MESH-GROUP-STARTED"])
  931. if ev is None:
  932. raise Exception("Init failure not reported")
  933. except Exception, e:
  934. if i < 15:
  935. raise
  936. logger.info("Ignore no-oom for i=%d" % i)
  937. with alloc_fail(dev[0], 5, "=wpa_supplicant_mesh_init"):
  938. id = add_mesh_secure_net(dev[0])
  939. dev[0].mesh_group_add(id)
  940. ev = dev[0].wait_event(["Failed to init mesh"])
  941. if ev is None:
  942. raise Exception("Init failure not reported")
  943. def test_mesh_add_interface_oom(dev):
  944. """wpa_supplicant mesh with dynamic interface addition failing"""
  945. check_mesh_support(dev[0])
  946. for i in range(1, 3):
  947. mesh = None
  948. try:
  949. with alloc_fail(dev[0], i, "wpas_mesh_add_interface"):
  950. mesh = dev[0].request("MESH_INTERFACE_ADD").strip()
  951. finally:
  952. if mesh and mesh != "FAIL":
  953. dev[0].request("MESH_GROUP_REMOVE " + mesh)
  954. def test_mesh_scan_oom(dev):
  955. """wpa_supplicant mesh scan results and OOM"""
  956. check_mesh_support(dev[0])
  957. add_open_mesh_network(dev[0])
  958. check_mesh_group_added(dev[0])
  959. for i in range(5):
  960. dev[1].scan(freq="2412")
  961. res = dev[1].request("SCAN_RESULTS")
  962. if "[MESH]" in res:
  963. break
  964. for r in res.splitlines():
  965. if "[MESH]" in r:
  966. break
  967. bssid = r.split('\t')[0]
  968. bss = dev[1].get_bss(bssid)
  969. if bss is None:
  970. raise Exception("Could not get BSS entry for mesh")
  971. for i in range(1, 3):
  972. with alloc_fail(dev[1], i, "mesh_attr_text"):
  973. bss = dev[1].get_bss(bssid)
  974. if bss is not None:
  975. raise Exception("Unexpected BSS result during OOM")
  976. def test_mesh_drv_fail(dev, apdev):
  977. """Mesh network setup failing due to driver command failure"""
  978. check_mesh_support(dev[0], secure=True)
  979. dev[0].request("SET sae_groups ")
  980. with fail_test(dev[0], 1, "nl80211_join_mesh"):
  981. add_open_mesh_network(dev[0])
  982. ev = dev[0].wait_event(["mesh join error"])
  983. if ev is None:
  984. raise Exception("Join failure not reported")
  985. dev[0].dump_monitor()
  986. with fail_test(dev[0], 1, "wpa_driver_nl80211_if_add"):
  987. if "FAIL" not in dev[0].request("MESH_INTERFACE_ADD").strip():
  988. raise Exception("Interface added unexpectedly")
  989. dev[0].dump_monitor()
  990. with fail_test(dev[0], 1, "wpa_driver_nl80211_init_mesh"):
  991. add_open_mesh_network(dev[0])
  992. ev = dev[0].wait_event(["Could not join mesh"])
  993. if ev is None:
  994. raise Exception("Join failure not reported")
  995. def test_mesh_sae_groups_invalid(dev, apdev):
  996. """Mesh with invalid SAE group configuration"""
  997. check_mesh_support(dev[0], secure=True)
  998. dev[0].request("SET sae_groups 25")
  999. id = add_mesh_secure_net(dev[0])
  1000. dev[0].mesh_group_add(id)
  1001. dev[1].request("SET sae_groups 123 122 121")
  1002. id = add_mesh_secure_net(dev[1])
  1003. dev[1].mesh_group_add(id)
  1004. check_mesh_group_added(dev[0])
  1005. check_mesh_group_added(dev[1])
  1006. ev = dev[0].wait_event(["new peer notification"], timeout=10)
  1007. if ev is None:
  1008. raise Exception("dev[0] did not see peer")
  1009. ev = dev[1].wait_event(["new peer notification"], timeout=10)
  1010. if ev is None:
  1011. raise Exception("dev[1] did not see peer")
  1012. ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  1013. if ev is not None:
  1014. raise Exception("Unexpected connection(0)")
  1015. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  1016. if ev is not None:
  1017. raise Exception("Unexpected connection(1)")
  1018. dev[0].request("SET sae_groups ")
  1019. dev[1].request("SET sae_groups ")
  1020. def test_mesh_sae_failure(dev, apdev):
  1021. """Mesh and local SAE failures"""
  1022. check_mesh_support(dev[0], secure=True)
  1023. dev[0].request("SET sae_groups ")
  1024. dev[1].request("SET sae_groups ")
  1025. funcs = [ (1, "=mesh_rsn_auth_sae_sta", True),
  1026. (1, "mesh_rsn_build_sae_commit;mesh_rsn_auth_sae_sta", False),
  1027. (1, "auth_sae_init_committed;mesh_rsn_auth_sae_sta", True),
  1028. (1, "=mesh_rsn_protect_frame", True),
  1029. (2, "=mesh_rsn_protect_frame", True),
  1030. (1, "aes_siv_encrypt;mesh_rsn_protect_frame", True),
  1031. (1, "=mesh_rsn_process_ampe", True),
  1032. (1, "aes_siv_decrypt;mesh_rsn_process_ampe", True) ]
  1033. for count, func, success in funcs:
  1034. id = add_mesh_secure_net(dev[0])
  1035. dev[0].mesh_group_add(id)
  1036. with alloc_fail(dev[1], count, func):
  1037. id = add_mesh_secure_net(dev[1])
  1038. dev[1].mesh_group_add(id)
  1039. check_mesh_group_added(dev[0])
  1040. check_mesh_group_added(dev[1])
  1041. if success:
  1042. # retry is expected to work
  1043. check_mesh_peer_connected(dev[0])
  1044. check_mesh_peer_connected(dev[1])
  1045. else:
  1046. wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
  1047. dev[0].mesh_group_remove()
  1048. dev[1].mesh_group_remove()
  1049. check_mesh_group_removed(dev[0])
  1050. check_mesh_group_removed(dev[1])
  1051. def test_mesh_failure(dev, apdev):
  1052. """Mesh and local failures"""
  1053. check_mesh_support(dev[0])
  1054. funcs = [ (1, "ap_sta_add;mesh_mpm_add_peer", True),
  1055. (1, "wpabuf_alloc;mesh_mpm_send_plink_action", True) ]
  1056. for count, func, success in funcs:
  1057. add_open_mesh_network(dev[0])
  1058. with alloc_fail(dev[1], count, func):
  1059. add_open_mesh_network(dev[1])
  1060. check_mesh_group_added(dev[0])
  1061. check_mesh_group_added(dev[1])
  1062. if success:
  1063. # retry is expected to work
  1064. check_mesh_peer_connected(dev[0])
  1065. check_mesh_peer_connected(dev[1])
  1066. else:
  1067. wait_fail_trigger(dev[1], "GET_ALLOC_FAIL")
  1068. dev[0].mesh_group_remove()
  1069. dev[1].mesh_group_remove()
  1070. check_mesh_group_removed(dev[0])
  1071. check_mesh_group_removed(dev[1])
  1072. funcs = [ (1, "mesh_mpm_init_link", True) ]
  1073. for count, func, success in funcs:
  1074. add_open_mesh_network(dev[0])
  1075. with fail_test(dev[1], count, func):
  1076. add_open_mesh_network(dev[1])
  1077. check_mesh_group_added(dev[0])
  1078. check_mesh_group_added(dev[1])
  1079. if success:
  1080. # retry is expected to work
  1081. check_mesh_peer_connected(dev[0])
  1082. check_mesh_peer_connected(dev[1])
  1083. else:
  1084. wait_fail_trigger(dev[1], "GET_FAIL")
  1085. dev[0].mesh_group_remove()
  1086. dev[1].mesh_group_remove()
  1087. check_mesh_group_removed(dev[0])
  1088. check_mesh_group_removed(dev[1])
  1089. def test_mesh_invalid_frequency(dev, apdev):
  1090. """Mesh and invalid frequency configuration"""
  1091. check_mesh_support(dev[0])
  1092. add_open_mesh_network(dev[0], freq=None)
  1093. ev = dev[0].wait_event(["MESH-GROUP-STARTED",
  1094. "Could not join mesh"])
  1095. if ev is None or "Could not join mesh" not in ev:
  1096. raise Exception("Mesh join failure not reported")
  1097. dev[0].request("REMOVE_NETWORK all")
  1098. add_open_mesh_network(dev[0], freq="2413")
  1099. ev = dev[0].wait_event(["MESH-GROUP-STARTED",
  1100. "Could not join mesh"])
  1101. if ev is None or "Could not join mesh" not in ev:
  1102. raise Exception("Mesh join failure not reported")
  1103. def test_mesh_default_beacon_int(dev, apdev):
  1104. """Mesh and default beacon interval"""
  1105. check_mesh_support(dev[0])
  1106. try:
  1107. dev[0].request("SET beacon_int 200")
  1108. add_open_mesh_network(dev[0])
  1109. check_mesh_group_added(dev[0])
  1110. finally:
  1111. dev[0].request("SET beacon_int 0")
  1112. def test_mesh_scan_parse_error(dev, apdev):
  1113. """Mesh scan element parse error"""
  1114. check_mesh_support(dev[0])
  1115. params = { "ssid": "open",
  1116. "beacon_int": "2000" }
  1117. hapd = hostapd.add_ap(apdev[0], params)
  1118. bssid = apdev[0]['bssid']
  1119. hapd.set('vendor_elements', 'dd0201')
  1120. for i in range(10):
  1121. dev[0].scan(freq=2412)
  1122. if bssid in dev[0].request("SCAN_RESULTS"):
  1123. break
  1124. # This will fail in IE parsing due to the truncated IE in the Probe
  1125. # Response frame.
  1126. bss = dev[0].request("BSS " + bssid)
  1127. def test_mesh_missing_mic(dev, apdev):
  1128. """Secure mesh network and missing MIC"""
  1129. check_mesh_support(dev[0], secure=True)
  1130. dev[0].request("SET ext_mgmt_frame_handling 1")
  1131. dev[0].request("SET sae_groups ")
  1132. id = add_mesh_secure_net(dev[0])
  1133. dev[0].mesh_group_add(id)
  1134. dev[1].request("SET sae_groups ")
  1135. id = add_mesh_secure_net(dev[1])
  1136. dev[1].mesh_group_add(id)
  1137. # Check for mesh joined
  1138. check_mesh_group_added(dev[0])
  1139. check_mesh_group_added(dev[1])
  1140. count = 0
  1141. remove_mic = True
  1142. while True:
  1143. count += 1
  1144. if count > 15:
  1145. raise Exception("Did not see Action frames")
  1146. rx_msg = dev[0].mgmt_rx()
  1147. if rx_msg is None:
  1148. raise Exception("MGMT-RX timeout")
  1149. if rx_msg['subtype'] == 13:
  1150. payload = rx_msg['payload']
  1151. frame = rx_msg['frame']
  1152. (categ, action) = struct.unpack('BB', payload[0:2])
  1153. if categ == 15 and action == 1 and remove_mic:
  1154. # Mesh Peering Open
  1155. pos = frame.find('\x8c\x10')
  1156. if not pos:
  1157. raise Exception("Could not find MIC element")
  1158. logger.info("Found MIC at %d" % pos)
  1159. # Remove MIC
  1160. rx_msg['frame'] = frame[0:pos]
  1161. remove_mic = False
  1162. 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'))):
  1163. raise Exception("MGMT_RX_PROCESS failed")
  1164. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  1165. if ev:
  1166. break
  1167. def test_mesh_pmkid_mismatch(dev, apdev):
  1168. """Secure mesh network and PMKID mismatch"""
  1169. check_mesh_support(dev[0], secure=True)
  1170. addr0 = dev[0].own_addr()
  1171. addr1 = dev[1].own_addr()
  1172. dev[0].request("SET sae_groups ")
  1173. id = add_mesh_secure_net(dev[0])
  1174. dev[0].set_network(id, "no_auto_peer", "1")
  1175. dev[0].mesh_group_add(id)
  1176. dev[1].request("SET sae_groups ")
  1177. id = add_mesh_secure_net(dev[1])
  1178. dev[1].set_network(id, "no_auto_peer", "1")
  1179. dev[1].mesh_group_add(id)
  1180. # Check for mesh joined
  1181. check_mesh_group_added(dev[0])
  1182. check_mesh_group_added(dev[1])
  1183. # Check for peer connected
  1184. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  1185. if ev is None:
  1186. raise Exception("Missing no-initiate message")
  1187. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  1188. raise Exception("MESH_PEER_ADD failed")
  1189. check_mesh_peer_connected(dev[0])
  1190. check_mesh_peer_connected(dev[1])
  1191. if "OK" not in dev[0].request("MESH_PEER_REMOVE " + addr1):
  1192. raise Exception("Failed to remove peer")
  1193. ev = dev[0].wait_event(["will not initiate new peer link"], timeout=10)
  1194. if ev is None:
  1195. raise Exception("Missing no-initiate message (2)")
  1196. dev[0].dump_monitor()
  1197. dev[1].dump_monitor()
  1198. dev[0].request("SET ext_mgmt_frame_handling 1")
  1199. if "OK" not in dev[0].request("MESH_PEER_ADD " + addr1):
  1200. raise Exception("MESH_PEER_ADD failed (2)")
  1201. count = 0
  1202. break_pmkid = True
  1203. while True:
  1204. count += 1
  1205. if count > 50:
  1206. raise Exception("Did not see Action frames")
  1207. rx_msg = dev[0].mgmt_rx()
  1208. if rx_msg is None:
  1209. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1)
  1210. if ev:
  1211. break
  1212. raise Exception("MGMT-RX timeout")
  1213. if rx_msg['subtype'] == 13:
  1214. payload = rx_msg['payload']
  1215. frame = rx_msg['frame']
  1216. (categ, action) = struct.unpack('BB', payload[0:2])
  1217. if categ == 15 and action == 1 and break_pmkid:
  1218. # Mesh Peering Open
  1219. pos = frame.find('\x75\x14')
  1220. if not pos:
  1221. raise Exception("Could not find Mesh Peering Management element")
  1222. logger.info("Found Mesh Peering Management element at %d" % pos)
  1223. # Break PMKID to hit "Mesh RSN: Invalid PMKID (Chosen PMK did
  1224. # not match calculated PMKID)"
  1225. rx_msg['frame'] = frame[0:pos + 6] + '\x00\x00\x00\x00' + frame[pos + 10:]
  1226. break_pmkid = False
  1227. 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'))):
  1228. raise Exception("MGMT_RX_PROCESS failed")
  1229. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  1230. if ev:
  1231. break
  1232. def test_mesh_peering_proto(dev, apdev):
  1233. """Mesh peering management protocol testing"""
  1234. check_mesh_support(dev[0])
  1235. dev[0].request("SET ext_mgmt_frame_handling 1")
  1236. add_open_mesh_network(dev[0], beacon_int=160)
  1237. add_open_mesh_network(dev[1], beacon_int=160)
  1238. count = 0
  1239. test = 1
  1240. while True:
  1241. count += 1
  1242. if count > 50:
  1243. raise Exception("Did not see Action frames")
  1244. rx_msg = dev[0].mgmt_rx()
  1245. if rx_msg is None:
  1246. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  1247. if ev:
  1248. break
  1249. raise Exception("MGMT-RX timeout")
  1250. if rx_msg['subtype'] == 13:
  1251. payload = rx_msg['payload']
  1252. frame = rx_msg['frame']
  1253. (categ, action) = struct.unpack('BB', payload[0:2])
  1254. if categ == 15 and action == 1 and test == 1:
  1255. # Mesh Peering Open
  1256. pos = frame.find('\x75\x04')
  1257. if not pos:
  1258. raise Exception("Could not find Mesh Peering Management element")
  1259. logger.info("Found Mesh Peering Management element at %d" % pos)
  1260. # Remove the element to hit
  1261. # "MPM: No Mesh Peering Management element"
  1262. rx_msg['frame'] = frame[0:pos]
  1263. test += 1
  1264. elif categ == 15 and action == 1 and test == 2:
  1265. # Mesh Peering Open
  1266. pos = frame.find('\x72\x0e')
  1267. if not pos:
  1268. raise Exception("Could not find Mesh ID element")
  1269. logger.info("Found Mesh ID element at %d" % pos)
  1270. # Remove the element to hit
  1271. # "MPM: No Mesh ID or Mesh Configuration element"
  1272. rx_msg['frame'] = frame[0:pos] + frame[pos + 16:]
  1273. test += 1
  1274. elif categ == 15 and action == 1 and test == 3:
  1275. # Mesh Peering Open
  1276. pos = frame.find('\x72\x0e')
  1277. if not pos:
  1278. raise Exception("Could not find Mesh ID element")
  1279. logger.info("Found Mesh ID element at %d" % pos)
  1280. # Replace Mesh ID to hit "MPM: Mesh ID or Mesh Configuration
  1281. # element do not match local MBSS"
  1282. rx_msg['frame'] = frame[0:pos] + '\x72\x0etest-test-test' + frame[pos + 16:]
  1283. test += 1
  1284. elif categ == 15 and action == 1 and test == 4:
  1285. # Mesh Peering Open
  1286. # Remove IEs to hit
  1287. # "MPM: Ignore too short action frame 1 ie_len 0"
  1288. rx_msg['frame'] = frame[0:26]
  1289. test += 1
  1290. elif categ == 15 and action == 1 and test == 5:
  1291. # Mesh Peering Open
  1292. # Truncate IEs to hit
  1293. # "MPM: Failed to parse PLINK IEs"
  1294. rx_msg['frame'] = frame[0:30]
  1295. test += 1
  1296. elif categ == 15 and action == 1 and test == 6:
  1297. # Mesh Peering Open
  1298. pos = frame.find('\x75\x04')
  1299. if not pos:
  1300. raise Exception("Could not find Mesh Peering Management element")
  1301. logger.info("Found Mesh Peering Management element at %d" % pos)
  1302. # Truncate the element to hit
  1303. # "MPM: Invalid peer mgmt ie" and
  1304. # "MPM: Mesh parsing rejected frame"
  1305. rx_msg['frame'] = frame[0:pos] + '\x75\x00\x00\x00' + frame[pos + 6:]
  1306. test += 1
  1307. 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'))):
  1308. raise Exception("MGMT_RX_PROCESS failed")
  1309. ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.01)
  1310. if ev:
  1311. break
  1312. if test != 7:
  1313. raise Exception("Not all test frames completed")