mesh.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2008, 2009 open80211s Ltd.
  4. * Copyright (C) 2018 - 2020 Intel Corporation
  5. * Authors: Luis Carlos Cobo <luisca@cozybit.com>
  6. * Javier Cardona <javier@cozybit.com>
  7. */
  8. #include <linux/slab.h>
  9. #include <asm/unaligned.h>
  10. #include "ieee80211_i.h"
  11. #include "mesh.h"
  12. #include "driver-ops.h"
  13. static int mesh_allocated;
  14. static struct kmem_cache *rm_cache;
  15. bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
  16. {
  17. return (mgmt->u.action.u.mesh_action.action_code ==
  18. WLAN_MESH_ACTION_HWMP_PATH_SELECTION);
  19. }
  20. void ieee80211s_init(void)
  21. {
  22. mesh_allocated = 1;
  23. rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
  24. 0, 0, NULL);
  25. }
  26. void ieee80211s_stop(void)
  27. {
  28. if (!mesh_allocated)
  29. return;
  30. kmem_cache_destroy(rm_cache);
  31. }
  32. static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
  33. {
  34. struct ieee80211_sub_if_data *sdata =
  35. from_timer(sdata, t, u.mesh.housekeeping_timer);
  36. struct ieee80211_local *local = sdata->local;
  37. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  38. set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
  39. ieee80211_queue_work(&local->hw, &sdata->work);
  40. }
  41. /**
  42. * mesh_matches_local - check if the config of a mesh point matches ours
  43. *
  44. * @sdata: local mesh subif
  45. * @ie: information elements of a management frame from the mesh peer
  46. *
  47. * This function checks if the mesh configuration of a mesh point matches the
  48. * local mesh configuration, i.e. if both nodes belong to the same mesh network.
  49. */
  50. bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
  51. struct ieee802_11_elems *ie)
  52. {
  53. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  54. u32 basic_rates = 0;
  55. struct cfg80211_chan_def sta_chan_def;
  56. struct ieee80211_supported_band *sband;
  57. u32 vht_cap_info = 0;
  58. /*
  59. * As support for each feature is added, check for matching
  60. * - On mesh config capabilities
  61. * - Power Save Support En
  62. * - Sync support enabled
  63. * - Sync support active
  64. * - Sync support required from peer
  65. * - MDA enabled
  66. * - Power management control on fc
  67. */
  68. if (!(ifmsh->mesh_id_len == ie->mesh_id_len &&
  69. memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
  70. (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
  71. (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) &&
  72. (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) &&
  73. (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) &&
  74. (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)))
  75. return false;
  76. sband = ieee80211_get_sband(sdata);
  77. if (!sband)
  78. return false;
  79. ieee80211_sta_get_rates(sdata, ie, sband->band,
  80. &basic_rates);
  81. if (sdata->vif.bss_conf.basic_rates != basic_rates)
  82. return false;
  83. cfg80211_chandef_create(&sta_chan_def, sdata->vif.bss_conf.chandef.chan,
  84. NL80211_CHAN_NO_HT);
  85. ieee80211_chandef_ht_oper(ie->ht_operation, &sta_chan_def);
  86. if (ie->vht_cap_elem)
  87. vht_cap_info = le32_to_cpu(ie->vht_cap_elem->vht_cap_info);
  88. ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info,
  89. ie->vht_operation, ie->ht_operation,
  90. &sta_chan_def);
  91. ieee80211_chandef_he_6ghz_oper(sdata, ie->he_operation, &sta_chan_def);
  92. if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef,
  93. &sta_chan_def))
  94. return false;
  95. return true;
  96. }
  97. /**
  98. * mesh_peer_accepts_plinks - check if an mp is willing to establish peer links
  99. *
  100. * @ie: information elements of a management frame from the mesh peer
  101. */
  102. bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
  103. {
  104. return (ie->mesh_config->meshconf_cap &
  105. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
  106. }
  107. /**
  108. * mesh_accept_plinks_update - update accepting_plink in local mesh beacons
  109. *
  110. * @sdata: mesh interface in which mesh beacons are going to be updated
  111. *
  112. * Returns: beacon changed flag if the beacon content changed.
  113. */
  114. u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
  115. {
  116. bool free_plinks;
  117. u32 changed = 0;
  118. /* In case mesh_plink_free_count > 0 and mesh_plinktbl_capacity == 0,
  119. * the mesh interface might be able to establish plinks with peers that
  120. * are already on the table but are not on PLINK_ESTAB state. However,
  121. * in general the mesh interface is not accepting peer link requests
  122. * from new peers, and that must be reflected in the beacon
  123. */
  124. free_plinks = mesh_plink_availables(sdata);
  125. if (free_plinks != sdata->u.mesh.accepting_plinks) {
  126. sdata->u.mesh.accepting_plinks = free_plinks;
  127. changed = BSS_CHANGED_BEACON;
  128. }
  129. return changed;
  130. }
  131. /*
  132. * mesh_sta_cleanup - clean up any mesh sta state
  133. *
  134. * @sta: mesh sta to clean up.
  135. */
  136. void mesh_sta_cleanup(struct sta_info *sta)
  137. {
  138. struct ieee80211_sub_if_data *sdata = sta->sdata;
  139. u32 changed = mesh_plink_deactivate(sta);
  140. if (changed)
  141. ieee80211_mbss_info_change_notify(sdata, changed);
  142. }
  143. int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
  144. {
  145. int i;
  146. sdata->u.mesh.rmc = kmalloc(sizeof(struct mesh_rmc), GFP_KERNEL);
  147. if (!sdata->u.mesh.rmc)
  148. return -ENOMEM;
  149. sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1;
  150. for (i = 0; i < RMC_BUCKETS; i++)
  151. INIT_HLIST_HEAD(&sdata->u.mesh.rmc->bucket[i]);
  152. return 0;
  153. }
  154. void mesh_rmc_free(struct ieee80211_sub_if_data *sdata)
  155. {
  156. struct mesh_rmc *rmc = sdata->u.mesh.rmc;
  157. struct rmc_entry *p;
  158. struct hlist_node *n;
  159. int i;
  160. if (!sdata->u.mesh.rmc)
  161. return;
  162. for (i = 0; i < RMC_BUCKETS; i++) {
  163. hlist_for_each_entry_safe(p, n, &rmc->bucket[i], list) {
  164. hlist_del(&p->list);
  165. kmem_cache_free(rm_cache, p);
  166. }
  167. }
  168. kfree(rmc);
  169. sdata->u.mesh.rmc = NULL;
  170. }
  171. /**
  172. * mesh_rmc_check - Check frame in recent multicast cache and add if absent.
  173. *
  174. * @sdata: interface
  175. * @sa: source address
  176. * @mesh_hdr: mesh_header
  177. *
  178. * Returns: 0 if the frame is not in the cache, nonzero otherwise.
  179. *
  180. * Checks using the source address and the mesh sequence number if we have
  181. * received this frame lately. If the frame is not in the cache, it is added to
  182. * it.
  183. */
  184. int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
  185. const u8 *sa, struct ieee80211s_hdr *mesh_hdr)
  186. {
  187. struct mesh_rmc *rmc = sdata->u.mesh.rmc;
  188. u32 seqnum = 0;
  189. int entries = 0;
  190. u8 idx;
  191. struct rmc_entry *p;
  192. struct hlist_node *n;
  193. if (!rmc)
  194. return -1;
  195. /* Don't care about endianness since only match matters */
  196. memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
  197. idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask;
  198. hlist_for_each_entry_safe(p, n, &rmc->bucket[idx], list) {
  199. ++entries;
  200. if (time_after(jiffies, p->exp_time) ||
  201. entries == RMC_QUEUE_MAX_LEN) {
  202. hlist_del(&p->list);
  203. kmem_cache_free(rm_cache, p);
  204. --entries;
  205. } else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa))
  206. return -1;
  207. }
  208. p = kmem_cache_alloc(rm_cache, GFP_ATOMIC);
  209. if (!p)
  210. return 0;
  211. p->seqnum = seqnum;
  212. p->exp_time = jiffies + RMC_TIMEOUT;
  213. memcpy(p->sa, sa, ETH_ALEN);
  214. hlist_add_head(&p->list, &rmc->bucket[idx]);
  215. return 0;
  216. }
  217. int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
  218. struct sk_buff *skb)
  219. {
  220. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  221. u8 *pos, neighbors;
  222. u8 meshconf_len = sizeof(struct ieee80211_meshconf_ie);
  223. bool is_connected_to_gate = ifmsh->num_gates > 0 ||
  224. ifmsh->mshcfg.dot11MeshGateAnnouncementProtocol ||
  225. ifmsh->mshcfg.dot11MeshConnectedToMeshGate;
  226. bool is_connected_to_as = ifmsh->mshcfg.dot11MeshConnectedToAuthServer;
  227. if (skb_tailroom(skb) < 2 + meshconf_len)
  228. return -ENOMEM;
  229. pos = skb_put(skb, 2 + meshconf_len);
  230. *pos++ = WLAN_EID_MESH_CONFIG;
  231. *pos++ = meshconf_len;
  232. /* save a pointer for quick updates in pre-tbtt */
  233. ifmsh->meshconf_offset = pos - skb->data;
  234. /* Active path selection protocol ID */
  235. *pos++ = ifmsh->mesh_pp_id;
  236. /* Active path selection metric ID */
  237. *pos++ = ifmsh->mesh_pm_id;
  238. /* Congestion control mode identifier */
  239. *pos++ = ifmsh->mesh_cc_id;
  240. /* Synchronization protocol identifier */
  241. *pos++ = ifmsh->mesh_sp_id;
  242. /* Authentication Protocol identifier */
  243. *pos++ = ifmsh->mesh_auth_id;
  244. /* Mesh Formation Info - number of neighbors */
  245. neighbors = atomic_read(&ifmsh->estab_plinks);
  246. neighbors = min_t(int, neighbors, IEEE80211_MAX_MESH_PEERINGS);
  247. *pos++ = (is_connected_to_as << 7) |
  248. (neighbors << 1) |
  249. is_connected_to_gate;
  250. /* Mesh capability */
  251. *pos = 0x00;
  252. *pos |= ifmsh->mshcfg.dot11MeshForwarding ?
  253. IEEE80211_MESHCONF_CAPAB_FORWARDING : 0x00;
  254. *pos |= ifmsh->accepting_plinks ?
  255. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
  256. /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */
  257. *pos |= ifmsh->ps_peers_deep_sleep ?
  258. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
  259. return 0;
  260. }
  261. int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
  262. {
  263. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  264. u8 *pos;
  265. if (skb_tailroom(skb) < 2 + ifmsh->mesh_id_len)
  266. return -ENOMEM;
  267. pos = skb_put(skb, 2 + ifmsh->mesh_id_len);
  268. *pos++ = WLAN_EID_MESH_ID;
  269. *pos++ = ifmsh->mesh_id_len;
  270. if (ifmsh->mesh_id_len)
  271. memcpy(pos, ifmsh->mesh_id, ifmsh->mesh_id_len);
  272. return 0;
  273. }
  274. static int mesh_add_awake_window_ie(struct ieee80211_sub_if_data *sdata,
  275. struct sk_buff *skb)
  276. {
  277. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  278. u8 *pos;
  279. /* see IEEE802.11-2012 13.14.6 */
  280. if (ifmsh->ps_peers_light_sleep == 0 &&
  281. ifmsh->ps_peers_deep_sleep == 0 &&
  282. ifmsh->nonpeer_pm == NL80211_MESH_POWER_ACTIVE)
  283. return 0;
  284. if (skb_tailroom(skb) < 4)
  285. return -ENOMEM;
  286. pos = skb_put(skb, 2 + 2);
  287. *pos++ = WLAN_EID_MESH_AWAKE_WINDOW;
  288. *pos++ = 2;
  289. put_unaligned_le16(ifmsh->mshcfg.dot11MeshAwakeWindowDuration, pos);
  290. return 0;
  291. }
  292. int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
  293. struct sk_buff *skb)
  294. {
  295. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  296. u8 offset, len;
  297. const u8 *data;
  298. if (!ifmsh->ie || !ifmsh->ie_len)
  299. return 0;
  300. /* fast-forward to vendor IEs */
  301. offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
  302. if (offset < ifmsh->ie_len) {
  303. len = ifmsh->ie_len - offset;
  304. data = ifmsh->ie + offset;
  305. if (skb_tailroom(skb) < len)
  306. return -ENOMEM;
  307. skb_put_data(skb, data, len);
  308. }
  309. return 0;
  310. }
  311. int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
  312. {
  313. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  314. u8 len = 0;
  315. const u8 *data;
  316. if (!ifmsh->ie || !ifmsh->ie_len)
  317. return 0;
  318. /* find RSN IE */
  319. data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, ifmsh->ie_len);
  320. if (!data)
  321. return 0;
  322. len = data[1] + 2;
  323. if (skb_tailroom(skb) < len)
  324. return -ENOMEM;
  325. skb_put_data(skb, data, len);
  326. return 0;
  327. }
  328. static int mesh_add_ds_params_ie(struct ieee80211_sub_if_data *sdata,
  329. struct sk_buff *skb)
  330. {
  331. struct ieee80211_chanctx_conf *chanctx_conf;
  332. struct ieee80211_channel *chan;
  333. u8 *pos;
  334. if (skb_tailroom(skb) < 3)
  335. return -ENOMEM;
  336. rcu_read_lock();
  337. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  338. if (WARN_ON(!chanctx_conf)) {
  339. rcu_read_unlock();
  340. return -EINVAL;
  341. }
  342. chan = chanctx_conf->def.chan;
  343. rcu_read_unlock();
  344. pos = skb_put(skb, 2 + 1);
  345. *pos++ = WLAN_EID_DS_PARAMS;
  346. *pos++ = 1;
  347. *pos++ = ieee80211_frequency_to_channel(chan->center_freq);
  348. return 0;
  349. }
  350. int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
  351. struct sk_buff *skb)
  352. {
  353. struct ieee80211_supported_band *sband;
  354. u8 *pos;
  355. sband = ieee80211_get_sband(sdata);
  356. if (!sband)
  357. return -EINVAL;
  358. /* HT not allowed in 6 GHz */
  359. if (sband->band == NL80211_BAND_6GHZ)
  360. return 0;
  361. if (!sband->ht_cap.ht_supported ||
  362. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  363. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  364. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  365. return 0;
  366. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap))
  367. return -ENOMEM;
  368. pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap));
  369. ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, sband->ht_cap.cap);
  370. return 0;
  371. }
  372. int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
  373. struct sk_buff *skb)
  374. {
  375. struct ieee80211_local *local = sdata->local;
  376. struct ieee80211_chanctx_conf *chanctx_conf;
  377. struct ieee80211_channel *channel;
  378. struct ieee80211_supported_band *sband;
  379. struct ieee80211_sta_ht_cap *ht_cap;
  380. u8 *pos;
  381. rcu_read_lock();
  382. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  383. if (WARN_ON(!chanctx_conf)) {
  384. rcu_read_unlock();
  385. return -EINVAL;
  386. }
  387. channel = chanctx_conf->def.chan;
  388. rcu_read_unlock();
  389. sband = local->hw.wiphy->bands[channel->band];
  390. ht_cap = &sband->ht_cap;
  391. /* HT not allowed in 6 GHz */
  392. if (sband->band == NL80211_BAND_6GHZ)
  393. return 0;
  394. if (!ht_cap->ht_supported ||
  395. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  396. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  397. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  398. return 0;
  399. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_operation))
  400. return -ENOMEM;
  401. pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_operation));
  402. ieee80211_ie_build_ht_oper(pos, ht_cap, &sdata->vif.bss_conf.chandef,
  403. sdata->vif.bss_conf.ht_operation_mode,
  404. false);
  405. return 0;
  406. }
  407. int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
  408. struct sk_buff *skb)
  409. {
  410. struct ieee80211_supported_band *sband;
  411. u8 *pos;
  412. sband = ieee80211_get_sband(sdata);
  413. if (!sband)
  414. return -EINVAL;
  415. /* VHT not allowed in 6 GHz */
  416. if (sband->band == NL80211_BAND_6GHZ)
  417. return 0;
  418. if (!sband->vht_cap.vht_supported ||
  419. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  420. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  421. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  422. return 0;
  423. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_vht_cap))
  424. return -ENOMEM;
  425. pos = skb_put(skb, 2 + sizeof(struct ieee80211_vht_cap));
  426. ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, sband->vht_cap.cap);
  427. return 0;
  428. }
  429. int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
  430. struct sk_buff *skb)
  431. {
  432. struct ieee80211_local *local = sdata->local;
  433. struct ieee80211_chanctx_conf *chanctx_conf;
  434. struct ieee80211_channel *channel;
  435. struct ieee80211_supported_band *sband;
  436. struct ieee80211_sta_vht_cap *vht_cap;
  437. u8 *pos;
  438. rcu_read_lock();
  439. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  440. if (WARN_ON(!chanctx_conf)) {
  441. rcu_read_unlock();
  442. return -EINVAL;
  443. }
  444. channel = chanctx_conf->def.chan;
  445. rcu_read_unlock();
  446. sband = local->hw.wiphy->bands[channel->band];
  447. vht_cap = &sband->vht_cap;
  448. /* VHT not allowed in 6 GHz */
  449. if (sband->band == NL80211_BAND_6GHZ)
  450. return 0;
  451. if (!vht_cap->vht_supported ||
  452. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  453. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  454. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  455. return 0;
  456. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_vht_operation))
  457. return -ENOMEM;
  458. pos = skb_put(skb, 2 + sizeof(struct ieee80211_vht_operation));
  459. ieee80211_ie_build_vht_oper(pos, vht_cap,
  460. &sdata->vif.bss_conf.chandef);
  461. return 0;
  462. }
  463. int mesh_add_he_cap_ie(struct ieee80211_sub_if_data *sdata,
  464. struct sk_buff *skb, u8 ie_len)
  465. {
  466. const struct ieee80211_sta_he_cap *he_cap;
  467. struct ieee80211_supported_band *sband;
  468. u8 *pos;
  469. sband = ieee80211_get_sband(sdata);
  470. if (!sband)
  471. return -EINVAL;
  472. he_cap = ieee80211_get_he_iftype_cap(sband, NL80211_IFTYPE_MESH_POINT);
  473. if (!he_cap ||
  474. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  475. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  476. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  477. return 0;
  478. if (skb_tailroom(skb) < ie_len)
  479. return -ENOMEM;
  480. pos = skb_put(skb, ie_len);
  481. ieee80211_ie_build_he_cap(pos, he_cap, pos + ie_len);
  482. return 0;
  483. }
  484. int mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
  485. struct sk_buff *skb)
  486. {
  487. const struct ieee80211_sta_he_cap *he_cap;
  488. struct ieee80211_supported_band *sband;
  489. u32 len;
  490. u8 *pos;
  491. sband = ieee80211_get_sband(sdata);
  492. if (!sband)
  493. return -EINVAL;
  494. he_cap = ieee80211_get_he_iftype_cap(sband, NL80211_IFTYPE_MESH_POINT);
  495. if (!he_cap ||
  496. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
  497. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
  498. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
  499. return 0;
  500. len = 2 + 1 + sizeof(struct ieee80211_he_operation);
  501. if (sdata->vif.bss_conf.chandef.chan->band == NL80211_BAND_6GHZ)
  502. len += sizeof(struct ieee80211_he_6ghz_oper);
  503. if (skb_tailroom(skb) < len)
  504. return -ENOMEM;
  505. pos = skb_put(skb, len);
  506. ieee80211_ie_build_he_oper(pos, &sdata->vif.bss_conf.chandef);
  507. return 0;
  508. }
  509. int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,
  510. struct sk_buff *skb)
  511. {
  512. struct ieee80211_supported_band *sband;
  513. const struct ieee80211_sband_iftype_data *iftd;
  514. sband = ieee80211_get_sband(sdata);
  515. if (!sband)
  516. return -EINVAL;
  517. iftd = ieee80211_get_sband_iftype_data(sband,
  518. NL80211_IFTYPE_MESH_POINT);
  519. /* The device doesn't support HE in mesh mode or at all */
  520. if (!iftd)
  521. return 0;
  522. ieee80211_ie_build_he_6ghz_cap(sdata, skb);
  523. return 0;
  524. }
  525. static void ieee80211_mesh_path_timer(struct timer_list *t)
  526. {
  527. struct ieee80211_sub_if_data *sdata =
  528. from_timer(sdata, t, u.mesh.mesh_path_timer);
  529. ieee80211_queue_work(&sdata->local->hw, &sdata->work);
  530. }
  531. static void ieee80211_mesh_path_root_timer(struct timer_list *t)
  532. {
  533. struct ieee80211_sub_if_data *sdata =
  534. from_timer(sdata, t, u.mesh.mesh_path_root_timer);
  535. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  536. set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  537. ieee80211_queue_work(&sdata->local->hw, &sdata->work);
  538. }
  539. void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
  540. {
  541. if (ifmsh->mshcfg.dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)
  542. set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  543. else {
  544. clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  545. /* stop running timer */
  546. del_timer_sync(&ifmsh->mesh_path_root_timer);
  547. }
  548. }
  549. /**
  550. * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame
  551. * @hdr: 802.11 frame header
  552. * @fc: frame control field
  553. * @meshda: destination address in the mesh
  554. * @meshsa: source address in the mesh. Same as TA, as frame is
  555. * locally originated.
  556. *
  557. * Return the length of the 802.11 (does not include a mesh control header)
  558. */
  559. int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
  560. const u8 *meshda, const u8 *meshsa)
  561. {
  562. if (is_multicast_ether_addr(meshda)) {
  563. *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
  564. /* DA TA SA */
  565. memcpy(hdr->addr1, meshda, ETH_ALEN);
  566. memcpy(hdr->addr2, meshsa, ETH_ALEN);
  567. memcpy(hdr->addr3, meshsa, ETH_ALEN);
  568. return 24;
  569. } else {
  570. *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
  571. /* RA TA DA SA */
  572. eth_zero_addr(hdr->addr1); /* RA is resolved later */
  573. memcpy(hdr->addr2, meshsa, ETH_ALEN);
  574. memcpy(hdr->addr3, meshda, ETH_ALEN);
  575. memcpy(hdr->addr4, meshsa, ETH_ALEN);
  576. return 30;
  577. }
  578. }
  579. /**
  580. * ieee80211_new_mesh_header - create a new mesh header
  581. * @sdata: mesh interface to be used
  582. * @meshhdr: uninitialized mesh header
  583. * @addr4or5: 1st address in the ae header, which may correspond to address 4
  584. * (if addr6 is NULL) or address 5 (if addr6 is present). It may
  585. * be NULL.
  586. * @addr6: 2nd address in the ae header, which corresponds to addr6 of the
  587. * mesh frame
  588. *
  589. * Return the header length.
  590. */
  591. unsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
  592. struct ieee80211s_hdr *meshhdr,
  593. const char *addr4or5, const char *addr6)
  594. {
  595. if (WARN_ON(!addr4or5 && addr6))
  596. return 0;
  597. memset(meshhdr, 0, sizeof(*meshhdr));
  598. meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
  599. /* FIXME: racy -- TX on multiple queues can be concurrent */
  600. put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
  601. sdata->u.mesh.mesh_seqnum++;
  602. if (addr4or5 && !addr6) {
  603. meshhdr->flags |= MESH_FLAGS_AE_A4;
  604. memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
  605. return 2 * ETH_ALEN;
  606. } else if (addr4or5 && addr6) {
  607. meshhdr->flags |= MESH_FLAGS_AE_A5_A6;
  608. memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
  609. memcpy(meshhdr->eaddr2, addr6, ETH_ALEN);
  610. return 3 * ETH_ALEN;
  611. }
  612. return ETH_ALEN;
  613. }
  614. static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata)
  615. {
  616. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  617. u32 changed;
  618. if (ifmsh->mshcfg.plink_timeout > 0)
  619. ieee80211_sta_expire(sdata, ifmsh->mshcfg.plink_timeout * HZ);
  620. mesh_path_expire(sdata);
  621. changed = mesh_accept_plinks_update(sdata);
  622. ieee80211_mbss_info_change_notify(sdata, changed);
  623. mod_timer(&ifmsh->housekeeping_timer,
  624. round_jiffies(jiffies +
  625. IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
  626. }
  627. static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
  628. {
  629. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  630. u32 interval;
  631. mesh_path_tx_root_frame(sdata);
  632. if (ifmsh->mshcfg.dot11MeshHWMPRootMode == IEEE80211_PROACTIVE_RANN)
  633. interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
  634. else
  635. interval = ifmsh->mshcfg.dot11MeshHWMProotInterval;
  636. mod_timer(&ifmsh->mesh_path_root_timer,
  637. round_jiffies(TU_TO_EXP_TIME(interval)));
  638. }
  639. static int
  640. ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
  641. {
  642. struct beacon_data *bcn;
  643. int head_len, tail_len;
  644. struct sk_buff *skb;
  645. struct ieee80211_mgmt *mgmt;
  646. struct ieee80211_chanctx_conf *chanctx_conf;
  647. struct mesh_csa_settings *csa;
  648. enum nl80211_band band;
  649. u8 ie_len_he_cap;
  650. u8 *pos;
  651. struct ieee80211_sub_if_data *sdata;
  652. int hdr_len = offsetofend(struct ieee80211_mgmt, u.beacon);
  653. sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
  654. rcu_read_lock();
  655. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  656. band = chanctx_conf->def.chan->band;
  657. rcu_read_unlock();
  658. ie_len_he_cap = ieee80211_ie_len_he_cap(sdata,
  659. NL80211_IFTYPE_MESH_POINT);
  660. head_len = hdr_len +
  661. 2 + /* NULL SSID */
  662. /* Channel Switch Announcement */
  663. 2 + sizeof(struct ieee80211_channel_sw_ie) +
  664. /* Mesh Channel Switch Parameters */
  665. 2 + sizeof(struct ieee80211_mesh_chansw_params_ie) +
  666. /* Channel Switch Wrapper + Wide Bandwidth CSA IE */
  667. 2 + 2 + sizeof(struct ieee80211_wide_bw_chansw_ie) +
  668. 2 + sizeof(struct ieee80211_sec_chan_offs_ie) +
  669. 2 + 8 + /* supported rates */
  670. 2 + 3; /* DS params */
  671. tail_len = 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
  672. 2 + sizeof(struct ieee80211_ht_cap) +
  673. 2 + sizeof(struct ieee80211_ht_operation) +
  674. 2 + ifmsh->mesh_id_len +
  675. 2 + sizeof(struct ieee80211_meshconf_ie) +
  676. 2 + sizeof(__le16) + /* awake window */
  677. 2 + sizeof(struct ieee80211_vht_cap) +
  678. 2 + sizeof(struct ieee80211_vht_operation) +
  679. ie_len_he_cap +
  680. 2 + 1 + sizeof(struct ieee80211_he_operation) +
  681. sizeof(struct ieee80211_he_6ghz_oper) +
  682. 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa) +
  683. ifmsh->ie_len;
  684. bcn = kzalloc(sizeof(*bcn) + head_len + tail_len, GFP_KERNEL);
  685. /* need an skb for IE builders to operate on */
  686. skb = dev_alloc_skb(max(head_len, tail_len));
  687. if (!bcn || !skb)
  688. goto out_free;
  689. /*
  690. * pointers go into the block we allocated,
  691. * memory is | beacon_data | head | tail |
  692. */
  693. bcn->head = ((u8 *) bcn) + sizeof(*bcn);
  694. /* fill in the head */
  695. mgmt = skb_put_zero(skb, hdr_len);
  696. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  697. IEEE80211_STYPE_BEACON);
  698. eth_broadcast_addr(mgmt->da);
  699. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  700. memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
  701. ieee80211_mps_set_frame_flags(sdata, NULL, (void *) mgmt);
  702. mgmt->u.beacon.beacon_int =
  703. cpu_to_le16(sdata->vif.bss_conf.beacon_int);
  704. mgmt->u.beacon.capab_info |= cpu_to_le16(
  705. sdata->u.mesh.security ? WLAN_CAPABILITY_PRIVACY : 0);
  706. pos = skb_put(skb, 2);
  707. *pos++ = WLAN_EID_SSID;
  708. *pos++ = 0x0;
  709. rcu_read_lock();
  710. csa = rcu_dereference(ifmsh->csa);
  711. if (csa) {
  712. enum nl80211_channel_type ct;
  713. struct cfg80211_chan_def *chandef;
  714. int ie_len = 2 + sizeof(struct ieee80211_channel_sw_ie) +
  715. 2 + sizeof(struct ieee80211_mesh_chansw_params_ie);
  716. pos = skb_put_zero(skb, ie_len);
  717. *pos++ = WLAN_EID_CHANNEL_SWITCH;
  718. *pos++ = 3;
  719. *pos++ = 0x0;
  720. *pos++ = ieee80211_frequency_to_channel(
  721. csa->settings.chandef.chan->center_freq);
  722. bcn->cntdwn_current_counter = csa->settings.count;
  723. bcn->cntdwn_counter_offsets[0] = hdr_len + 6;
  724. *pos++ = csa->settings.count;
  725. *pos++ = WLAN_EID_CHAN_SWITCH_PARAM;
  726. *pos++ = 6;
  727. if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT) {
  728. *pos++ = ifmsh->mshcfg.dot11MeshTTL;
  729. *pos |= WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR;
  730. } else {
  731. *pos++ = ifmsh->chsw_ttl;
  732. }
  733. *pos++ |= csa->settings.block_tx ?
  734. WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT : 0x00;
  735. put_unaligned_le16(WLAN_REASON_MESH_CHAN, pos);
  736. pos += 2;
  737. put_unaligned_le16(ifmsh->pre_value, pos);
  738. pos += 2;
  739. switch (csa->settings.chandef.width) {
  740. case NL80211_CHAN_WIDTH_40:
  741. ie_len = 2 + sizeof(struct ieee80211_sec_chan_offs_ie);
  742. pos = skb_put_zero(skb, ie_len);
  743. *pos++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET; /* EID */
  744. *pos++ = 1; /* len */
  745. ct = cfg80211_get_chandef_type(&csa->settings.chandef);
  746. if (ct == NL80211_CHAN_HT40PLUS)
  747. *pos++ = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
  748. else
  749. *pos++ = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
  750. break;
  751. case NL80211_CHAN_WIDTH_80:
  752. case NL80211_CHAN_WIDTH_80P80:
  753. case NL80211_CHAN_WIDTH_160:
  754. /* Channel Switch Wrapper + Wide Bandwidth CSA IE */
  755. ie_len = 2 + 2 +
  756. sizeof(struct ieee80211_wide_bw_chansw_ie);
  757. pos = skb_put_zero(skb, ie_len);
  758. *pos++ = WLAN_EID_CHANNEL_SWITCH_WRAPPER; /* EID */
  759. *pos++ = 5; /* len */
  760. /* put sub IE */
  761. chandef = &csa->settings.chandef;
  762. ieee80211_ie_build_wide_bw_cs(pos, chandef);
  763. break;
  764. default:
  765. break;
  766. }
  767. }
  768. rcu_read_unlock();
  769. if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
  770. mesh_add_ds_params_ie(sdata, skb))
  771. goto out_free;
  772. bcn->head_len = skb->len;
  773. memcpy(bcn->head, skb->data, bcn->head_len);
  774. /* now the tail */
  775. skb_trim(skb, 0);
  776. bcn->tail = bcn->head + bcn->head_len;
  777. if (ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
  778. mesh_add_rsn_ie(sdata, skb) ||
  779. mesh_add_ht_cap_ie(sdata, skb) ||
  780. mesh_add_ht_oper_ie(sdata, skb) ||
  781. mesh_add_meshid_ie(sdata, skb) ||
  782. mesh_add_meshconf_ie(sdata, skb) ||
  783. mesh_add_awake_window_ie(sdata, skb) ||
  784. mesh_add_vht_cap_ie(sdata, skb) ||
  785. mesh_add_vht_oper_ie(sdata, skb) ||
  786. mesh_add_he_cap_ie(sdata, skb, ie_len_he_cap) ||
  787. mesh_add_he_oper_ie(sdata, skb) ||
  788. mesh_add_he_6ghz_cap_ie(sdata, skb) ||
  789. mesh_add_vendor_ies(sdata, skb))
  790. goto out_free;
  791. bcn->tail_len = skb->len;
  792. memcpy(bcn->tail, skb->data, bcn->tail_len);
  793. bcn->meshconf = (struct ieee80211_meshconf_ie *)
  794. (bcn->tail + ifmsh->meshconf_offset);
  795. dev_kfree_skb(skb);
  796. rcu_assign_pointer(ifmsh->beacon, bcn);
  797. return 0;
  798. out_free:
  799. kfree(bcn);
  800. dev_kfree_skb(skb);
  801. return -ENOMEM;
  802. }
  803. static int
  804. ieee80211_mesh_rebuild_beacon(struct ieee80211_sub_if_data *sdata)
  805. {
  806. struct beacon_data *old_bcn;
  807. int ret;
  808. old_bcn = rcu_dereference_protected(sdata->u.mesh.beacon,
  809. lockdep_is_held(&sdata->wdev.mtx));
  810. ret = ieee80211_mesh_build_beacon(&sdata->u.mesh);
  811. if (ret)
  812. /* just reuse old beacon */
  813. return ret;
  814. if (old_bcn)
  815. kfree_rcu(old_bcn, rcu_head);
  816. return 0;
  817. }
  818. void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  819. u32 changed)
  820. {
  821. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  822. unsigned long bits = changed;
  823. u32 bit;
  824. if (!bits)
  825. return;
  826. /* if we race with running work, worst case this work becomes a noop */
  827. for_each_set_bit(bit, &bits, sizeof(changed) * BITS_PER_BYTE)
  828. set_bit(bit, &ifmsh->mbss_changed);
  829. set_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags);
  830. ieee80211_queue_work(&sdata->local->hw, &sdata->work);
  831. }
  832. int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
  833. {
  834. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  835. struct ieee80211_local *local = sdata->local;
  836. u32 changed = BSS_CHANGED_BEACON |
  837. BSS_CHANGED_BEACON_ENABLED |
  838. BSS_CHANGED_HT |
  839. BSS_CHANGED_BASIC_RATES |
  840. BSS_CHANGED_BEACON_INT |
  841. BSS_CHANGED_MCAST_RATE;
  842. local->fif_other_bss++;
  843. /* mesh ifaces must set allmulti to forward mcast traffic */
  844. atomic_inc(&local->iff_allmultis);
  845. ieee80211_configure_filter(local);
  846. ifmsh->mesh_cc_id = 0; /* Disabled */
  847. /* register sync ops from extensible synchronization framework */
  848. ifmsh->sync_ops = ieee80211_mesh_sync_ops_get(ifmsh->mesh_sp_id);
  849. ifmsh->sync_offset_clockdrift_max = 0;
  850. set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
  851. ieee80211_mesh_root_setup(ifmsh);
  852. ieee80211_queue_work(&local->hw, &sdata->work);
  853. sdata->vif.bss_conf.ht_operation_mode =
  854. ifmsh->mshcfg.ht_opmode;
  855. sdata->vif.bss_conf.enable_beacon = true;
  856. changed |= ieee80211_mps_local_status_update(sdata);
  857. if (ieee80211_mesh_build_beacon(ifmsh)) {
  858. ieee80211_stop_mesh(sdata);
  859. return -ENOMEM;
  860. }
  861. ieee80211_recalc_dtim(local, sdata);
  862. ieee80211_bss_info_change_notify(sdata, changed);
  863. netif_carrier_on(sdata->dev);
  864. return 0;
  865. }
  866. void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
  867. {
  868. struct ieee80211_local *local = sdata->local;
  869. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  870. struct beacon_data *bcn;
  871. netif_carrier_off(sdata->dev);
  872. /* flush STAs and mpaths on this iface */
  873. sta_info_flush(sdata);
  874. ieee80211_free_keys(sdata, true);
  875. mesh_path_flush_by_iface(sdata);
  876. /* stop the beacon */
  877. ifmsh->mesh_id_len = 0;
  878. sdata->vif.bss_conf.enable_beacon = false;
  879. sdata->beacon_rate_set = false;
  880. clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
  881. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
  882. /* remove beacon */
  883. bcn = rcu_dereference_protected(ifmsh->beacon,
  884. lockdep_is_held(&sdata->wdev.mtx));
  885. RCU_INIT_POINTER(ifmsh->beacon, NULL);
  886. kfree_rcu(bcn, rcu_head);
  887. /* free all potentially still buffered group-addressed frames */
  888. local->total_ps_buffered -= skb_queue_len(&ifmsh->ps.bc_buf);
  889. skb_queue_purge(&ifmsh->ps.bc_buf);
  890. del_timer_sync(&sdata->u.mesh.housekeeping_timer);
  891. del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
  892. del_timer_sync(&sdata->u.mesh.mesh_path_timer);
  893. /* clear any mesh work (for next join) we may have accrued */
  894. ifmsh->wrkq_flags = 0;
  895. ifmsh->mbss_changed = 0;
  896. local->fif_other_bss--;
  897. atomic_dec(&local->iff_allmultis);
  898. ieee80211_configure_filter(local);
  899. }
  900. static void ieee80211_mesh_csa_mark_radar(struct ieee80211_sub_if_data *sdata)
  901. {
  902. int err;
  903. /* if the current channel is a DFS channel, mark the channel as
  904. * unavailable.
  905. */
  906. err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy,
  907. &sdata->vif.bss_conf.chandef,
  908. NL80211_IFTYPE_MESH_POINT);
  909. if (err > 0)
  910. cfg80211_radar_event(sdata->local->hw.wiphy,
  911. &sdata->vif.bss_conf.chandef, GFP_ATOMIC);
  912. }
  913. static bool
  914. ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
  915. struct ieee802_11_elems *elems, bool beacon)
  916. {
  917. struct cfg80211_csa_settings params;
  918. struct ieee80211_csa_ie csa_ie;
  919. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  920. struct ieee80211_supported_band *sband;
  921. int err;
  922. u32 sta_flags, vht_cap_info = 0;
  923. sdata_assert_lock(sdata);
  924. sband = ieee80211_get_sband(sdata);
  925. if (!sband)
  926. return false;
  927. sta_flags = 0;
  928. switch (sdata->vif.bss_conf.chandef.width) {
  929. case NL80211_CHAN_WIDTH_20_NOHT:
  930. sta_flags |= IEEE80211_STA_DISABLE_HT;
  931. fallthrough;
  932. case NL80211_CHAN_WIDTH_20:
  933. sta_flags |= IEEE80211_STA_DISABLE_40MHZ;
  934. fallthrough;
  935. case NL80211_CHAN_WIDTH_40:
  936. sta_flags |= IEEE80211_STA_DISABLE_VHT;
  937. break;
  938. default:
  939. break;
  940. }
  941. if (elems->vht_cap_elem)
  942. vht_cap_info =
  943. le32_to_cpu(elems->vht_cap_elem->vht_cap_info);
  944. memset(&params, 0, sizeof(params));
  945. err = ieee80211_parse_ch_switch_ie(sdata, elems, sband->band,
  946. vht_cap_info,
  947. sta_flags, sdata->vif.addr,
  948. &csa_ie);
  949. if (err < 0)
  950. return false;
  951. if (err)
  952. return false;
  953. /* Mark the channel unavailable if the reason for the switch is
  954. * regulatory.
  955. */
  956. if (csa_ie.reason_code == WLAN_REASON_MESH_CHAN_REGULATORY)
  957. ieee80211_mesh_csa_mark_radar(sdata);
  958. params.chandef = csa_ie.chandef;
  959. params.count = csa_ie.count;
  960. if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, &params.chandef,
  961. IEEE80211_CHAN_DISABLED) ||
  962. !cfg80211_reg_can_beacon(sdata->local->hw.wiphy, &params.chandef,
  963. NL80211_IFTYPE_MESH_POINT)) {
  964. sdata_info(sdata,
  965. "mesh STA %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), aborting\n",
  966. sdata->vif.addr,
  967. params.chandef.chan->center_freq,
  968. params.chandef.width,
  969. params.chandef.center_freq1,
  970. params.chandef.center_freq2);
  971. return false;
  972. }
  973. err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy,
  974. &params.chandef,
  975. NL80211_IFTYPE_MESH_POINT);
  976. if (err < 0)
  977. return false;
  978. if (err > 0 && !ifmsh->userspace_handles_dfs) {
  979. sdata_info(sdata,
  980. "mesh STA %pM switches to channel requiring DFS (%d MHz, width:%d, CF1/2: %d/%d MHz), aborting\n",
  981. sdata->vif.addr,
  982. params.chandef.chan->center_freq,
  983. params.chandef.width,
  984. params.chandef.center_freq1,
  985. params.chandef.center_freq2);
  986. return false;
  987. }
  988. params.radar_required = err;
  989. if (cfg80211_chandef_identical(&params.chandef,
  990. &sdata->vif.bss_conf.chandef)) {
  991. mcsa_dbg(sdata,
  992. "received csa with an identical chandef, ignoring\n");
  993. return true;
  994. }
  995. mcsa_dbg(sdata,
  996. "received channel switch announcement to go to channel %d MHz\n",
  997. params.chandef.chan->center_freq);
  998. params.block_tx = csa_ie.mode & WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT;
  999. if (beacon) {
  1000. ifmsh->chsw_ttl = csa_ie.ttl - 1;
  1001. if (ifmsh->pre_value >= csa_ie.pre_value)
  1002. return false;
  1003. ifmsh->pre_value = csa_ie.pre_value;
  1004. }
  1005. if (ifmsh->chsw_ttl >= ifmsh->mshcfg.dot11MeshTTL)
  1006. return false;
  1007. ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_REPEATER;
  1008. if (ieee80211_channel_switch(sdata->local->hw.wiphy, sdata->dev,
  1009. &params) < 0)
  1010. return false;
  1011. return true;
  1012. }
  1013. static void
  1014. ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata,
  1015. struct ieee80211_mgmt *mgmt, size_t len)
  1016. {
  1017. struct ieee80211_local *local = sdata->local;
  1018. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1019. struct sk_buff *presp;
  1020. struct beacon_data *bcn;
  1021. struct ieee80211_mgmt *hdr;
  1022. struct ieee802_11_elems elems;
  1023. size_t baselen;
  1024. u8 *pos;
  1025. pos = mgmt->u.probe_req.variable;
  1026. baselen = (u8 *) pos - (u8 *) mgmt;
  1027. if (baselen > len)
  1028. return;
  1029. ieee802_11_parse_elems(pos, len - baselen, false, &elems, mgmt->bssid,
  1030. NULL);
  1031. if (!elems.mesh_id)
  1032. return;
  1033. /* 802.11-2012 10.1.4.3.2 */
  1034. if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
  1035. !is_broadcast_ether_addr(mgmt->da)) ||
  1036. elems.ssid_len != 0)
  1037. return;
  1038. if (elems.mesh_id_len != 0 &&
  1039. (elems.mesh_id_len != ifmsh->mesh_id_len ||
  1040. memcmp(elems.mesh_id, ifmsh->mesh_id, ifmsh->mesh_id_len)))
  1041. return;
  1042. rcu_read_lock();
  1043. bcn = rcu_dereference(ifmsh->beacon);
  1044. if (!bcn)
  1045. goto out;
  1046. presp = dev_alloc_skb(local->tx_headroom +
  1047. bcn->head_len + bcn->tail_len);
  1048. if (!presp)
  1049. goto out;
  1050. skb_reserve(presp, local->tx_headroom);
  1051. skb_put_data(presp, bcn->head, bcn->head_len);
  1052. skb_put_data(presp, bcn->tail, bcn->tail_len);
  1053. hdr = (struct ieee80211_mgmt *) presp->data;
  1054. hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  1055. IEEE80211_STYPE_PROBE_RESP);
  1056. memcpy(hdr->da, mgmt->sa, ETH_ALEN);
  1057. IEEE80211_SKB_CB(presp)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
  1058. ieee80211_tx_skb(sdata, presp);
  1059. out:
  1060. rcu_read_unlock();
  1061. }
  1062. static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
  1063. u16 stype,
  1064. struct ieee80211_mgmt *mgmt,
  1065. size_t len,
  1066. struct ieee80211_rx_status *rx_status)
  1067. {
  1068. struct ieee80211_local *local = sdata->local;
  1069. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1070. struct ieee802_11_elems elems;
  1071. struct ieee80211_channel *channel;
  1072. size_t baselen;
  1073. int freq;
  1074. enum nl80211_band band = rx_status->band;
  1075. /* ignore ProbeResp to foreign address */
  1076. if (stype == IEEE80211_STYPE_PROBE_RESP &&
  1077. !ether_addr_equal(mgmt->da, sdata->vif.addr))
  1078. return;
  1079. baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
  1080. if (baselen > len)
  1081. return;
  1082. ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
  1083. false, &elems, mgmt->bssid, NULL);
  1084. /* ignore non-mesh or secure / unsecure mismatch */
  1085. if ((!elems.mesh_id || !elems.mesh_config) ||
  1086. (elems.rsn && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) ||
  1087. (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE))
  1088. return;
  1089. if (elems.ds_params)
  1090. freq = ieee80211_channel_to_frequency(elems.ds_params[0], band);
  1091. else
  1092. freq = rx_status->freq;
  1093. channel = ieee80211_get_channel(local->hw.wiphy, freq);
  1094. if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
  1095. return;
  1096. if (mesh_matches_local(sdata, &elems)) {
  1097. mpl_dbg(sdata, "rssi_threshold=%d,rx_status->signal=%d\n",
  1098. sdata->u.mesh.mshcfg.rssi_threshold, rx_status->signal);
  1099. if (!sdata->u.mesh.user_mpm ||
  1100. sdata->u.mesh.mshcfg.rssi_threshold == 0 ||
  1101. sdata->u.mesh.mshcfg.rssi_threshold < rx_status->signal)
  1102. mesh_neighbour_update(sdata, mgmt->sa, &elems,
  1103. rx_status);
  1104. if (ifmsh->csa_role != IEEE80211_MESH_CSA_ROLE_INIT &&
  1105. !sdata->vif.csa_active)
  1106. ieee80211_mesh_process_chnswitch(sdata, &elems, true);
  1107. }
  1108. if (ifmsh->sync_ops)
  1109. ifmsh->sync_ops->rx_bcn_presp(sdata,
  1110. stype, mgmt, &elems, rx_status);
  1111. }
  1112. int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata)
  1113. {
  1114. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1115. struct mesh_csa_settings *tmp_csa_settings;
  1116. int ret = 0;
  1117. int changed = 0;
  1118. /* Reset the TTL value and Initiator flag */
  1119. ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
  1120. ifmsh->chsw_ttl = 0;
  1121. /* Remove the CSA and MCSP elements from the beacon */
  1122. tmp_csa_settings = rcu_dereference_protected(ifmsh->csa,
  1123. lockdep_is_held(&sdata->wdev.mtx));
  1124. RCU_INIT_POINTER(ifmsh->csa, NULL);
  1125. if (tmp_csa_settings)
  1126. kfree_rcu(tmp_csa_settings, rcu_head);
  1127. ret = ieee80211_mesh_rebuild_beacon(sdata);
  1128. if (ret)
  1129. return -EINVAL;
  1130. changed |= BSS_CHANGED_BEACON;
  1131. mcsa_dbg(sdata, "complete switching to center freq %d MHz",
  1132. sdata->vif.bss_conf.chandef.chan->center_freq);
  1133. return changed;
  1134. }
  1135. int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
  1136. struct cfg80211_csa_settings *csa_settings)
  1137. {
  1138. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1139. struct mesh_csa_settings *tmp_csa_settings;
  1140. int ret = 0;
  1141. lockdep_assert_held(&sdata->wdev.mtx);
  1142. tmp_csa_settings = kmalloc(sizeof(*tmp_csa_settings),
  1143. GFP_ATOMIC);
  1144. if (!tmp_csa_settings)
  1145. return -ENOMEM;
  1146. memcpy(&tmp_csa_settings->settings, csa_settings,
  1147. sizeof(struct cfg80211_csa_settings));
  1148. rcu_assign_pointer(ifmsh->csa, tmp_csa_settings);
  1149. ret = ieee80211_mesh_rebuild_beacon(sdata);
  1150. if (ret) {
  1151. tmp_csa_settings = rcu_dereference(ifmsh->csa);
  1152. RCU_INIT_POINTER(ifmsh->csa, NULL);
  1153. kfree_rcu(tmp_csa_settings, rcu_head);
  1154. return ret;
  1155. }
  1156. return BSS_CHANGED_BEACON;
  1157. }
  1158. static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata,
  1159. struct ieee80211_mgmt *mgmt, size_t len,
  1160. struct ieee802_11_elems *elems)
  1161. {
  1162. struct ieee80211_mgmt *mgmt_fwd;
  1163. struct sk_buff *skb;
  1164. struct ieee80211_local *local = sdata->local;
  1165. skb = dev_alloc_skb(local->tx_headroom + len);
  1166. if (!skb)
  1167. return -ENOMEM;
  1168. skb_reserve(skb, local->tx_headroom);
  1169. mgmt_fwd = skb_put(skb, len);
  1170. elems->mesh_chansw_params_ie->mesh_ttl--;
  1171. elems->mesh_chansw_params_ie->mesh_flags &=
  1172. ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR;
  1173. memcpy(mgmt_fwd, mgmt, len);
  1174. eth_broadcast_addr(mgmt_fwd->da);
  1175. memcpy(mgmt_fwd->sa, sdata->vif.addr, ETH_ALEN);
  1176. memcpy(mgmt_fwd->bssid, sdata->vif.addr, ETH_ALEN);
  1177. ieee80211_tx_skb(sdata, skb);
  1178. return 0;
  1179. }
  1180. static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata,
  1181. struct ieee80211_mgmt *mgmt, size_t len)
  1182. {
  1183. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1184. struct ieee802_11_elems elems;
  1185. u16 pre_value;
  1186. bool fwd_csa = true;
  1187. size_t baselen;
  1188. u8 *pos;
  1189. if (mgmt->u.action.u.measurement.action_code !=
  1190. WLAN_ACTION_SPCT_CHL_SWITCH)
  1191. return;
  1192. pos = mgmt->u.action.u.chan_switch.variable;
  1193. baselen = offsetof(struct ieee80211_mgmt,
  1194. u.action.u.chan_switch.variable);
  1195. ieee802_11_parse_elems(pos, len - baselen, true, &elems,
  1196. mgmt->bssid, NULL);
  1197. if (!mesh_matches_local(sdata, &elems))
  1198. return;
  1199. ifmsh->chsw_ttl = elems.mesh_chansw_params_ie->mesh_ttl;
  1200. if (!--ifmsh->chsw_ttl)
  1201. fwd_csa = false;
  1202. pre_value = le16_to_cpu(elems.mesh_chansw_params_ie->mesh_pre_value);
  1203. if (ifmsh->pre_value >= pre_value)
  1204. return;
  1205. ifmsh->pre_value = pre_value;
  1206. if (!sdata->vif.csa_active &&
  1207. !ieee80211_mesh_process_chnswitch(sdata, &elems, false)) {
  1208. mcsa_dbg(sdata, "Failed to process CSA action frame");
  1209. return;
  1210. }
  1211. /* forward or re-broadcast the CSA frame */
  1212. if (fwd_csa) {
  1213. if (mesh_fwd_csa_frame(sdata, mgmt, len, &elems) < 0)
  1214. mcsa_dbg(sdata, "Failed to forward the CSA frame");
  1215. }
  1216. }
  1217. static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
  1218. struct ieee80211_mgmt *mgmt,
  1219. size_t len,
  1220. struct ieee80211_rx_status *rx_status)
  1221. {
  1222. switch (mgmt->u.action.category) {
  1223. case WLAN_CATEGORY_SELF_PROTECTED:
  1224. switch (mgmt->u.action.u.self_prot.action_code) {
  1225. case WLAN_SP_MESH_PEERING_OPEN:
  1226. case WLAN_SP_MESH_PEERING_CLOSE:
  1227. case WLAN_SP_MESH_PEERING_CONFIRM:
  1228. mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
  1229. break;
  1230. }
  1231. break;
  1232. case WLAN_CATEGORY_MESH_ACTION:
  1233. if (mesh_action_is_path_sel(mgmt))
  1234. mesh_rx_path_sel_frame(sdata, mgmt, len);
  1235. break;
  1236. case WLAN_CATEGORY_SPECTRUM_MGMT:
  1237. mesh_rx_csa_frame(sdata, mgmt, len);
  1238. break;
  1239. }
  1240. }
  1241. void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1242. struct sk_buff *skb)
  1243. {
  1244. struct ieee80211_rx_status *rx_status;
  1245. struct ieee80211_mgmt *mgmt;
  1246. u16 stype;
  1247. sdata_lock(sdata);
  1248. /* mesh already went down */
  1249. if (!sdata->u.mesh.mesh_id_len)
  1250. goto out;
  1251. rx_status = IEEE80211_SKB_RXCB(skb);
  1252. mgmt = (struct ieee80211_mgmt *) skb->data;
  1253. stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
  1254. switch (stype) {
  1255. case IEEE80211_STYPE_PROBE_RESP:
  1256. case IEEE80211_STYPE_BEACON:
  1257. ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len,
  1258. rx_status);
  1259. break;
  1260. case IEEE80211_STYPE_PROBE_REQ:
  1261. ieee80211_mesh_rx_probe_req(sdata, mgmt, skb->len);
  1262. break;
  1263. case IEEE80211_STYPE_ACTION:
  1264. ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status);
  1265. break;
  1266. }
  1267. out:
  1268. sdata_unlock(sdata);
  1269. }
  1270. static void mesh_bss_info_changed(struct ieee80211_sub_if_data *sdata)
  1271. {
  1272. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1273. u32 bit, changed = 0;
  1274. for_each_set_bit(bit, &ifmsh->mbss_changed,
  1275. sizeof(changed) * BITS_PER_BYTE) {
  1276. clear_bit(bit, &ifmsh->mbss_changed);
  1277. changed |= BIT(bit);
  1278. }
  1279. if (sdata->vif.bss_conf.enable_beacon &&
  1280. (changed & (BSS_CHANGED_BEACON |
  1281. BSS_CHANGED_HT |
  1282. BSS_CHANGED_BASIC_RATES |
  1283. BSS_CHANGED_BEACON_INT)))
  1284. if (ieee80211_mesh_rebuild_beacon(sdata))
  1285. return;
  1286. ieee80211_bss_info_change_notify(sdata, changed);
  1287. }
  1288. void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
  1289. {
  1290. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1291. sdata_lock(sdata);
  1292. /* mesh already went down */
  1293. if (!sdata->u.mesh.mesh_id_len)
  1294. goto out;
  1295. if (ifmsh->preq_queue_len &&
  1296. time_after(jiffies,
  1297. ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
  1298. mesh_path_start_discovery(sdata);
  1299. if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
  1300. ieee80211_mesh_housekeeping(sdata);
  1301. if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags))
  1302. ieee80211_mesh_rootpath(sdata);
  1303. if (test_and_clear_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags))
  1304. mesh_sync_adjust_tsf(sdata);
  1305. if (test_and_clear_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags))
  1306. mesh_bss_info_changed(sdata);
  1307. out:
  1308. sdata_unlock(sdata);
  1309. }
  1310. void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
  1311. {
  1312. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1313. static u8 zero_addr[ETH_ALEN] = {};
  1314. timer_setup(&ifmsh->housekeeping_timer,
  1315. ieee80211_mesh_housekeeping_timer, 0);
  1316. ifmsh->accepting_plinks = true;
  1317. atomic_set(&ifmsh->mpaths, 0);
  1318. mesh_rmc_init(sdata);
  1319. ifmsh->last_preq = jiffies;
  1320. ifmsh->next_perr = jiffies;
  1321. ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
  1322. /* Allocate all mesh structures when creating the first mesh interface. */
  1323. if (!mesh_allocated)
  1324. ieee80211s_init();
  1325. mesh_pathtbl_init(sdata);
  1326. timer_setup(&ifmsh->mesh_path_timer, ieee80211_mesh_path_timer, 0);
  1327. timer_setup(&ifmsh->mesh_path_root_timer,
  1328. ieee80211_mesh_path_root_timer, 0);
  1329. INIT_LIST_HEAD(&ifmsh->preq_queue.list);
  1330. skb_queue_head_init(&ifmsh->ps.bc_buf);
  1331. spin_lock_init(&ifmsh->mesh_preq_queue_lock);
  1332. spin_lock_init(&ifmsh->sync_offset_lock);
  1333. RCU_INIT_POINTER(ifmsh->beacon, NULL);
  1334. sdata->vif.bss_conf.bssid = zero_addr;
  1335. }
  1336. void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata)
  1337. {
  1338. mesh_rmc_free(sdata);
  1339. mesh_pathtbl_unregister(sdata);
  1340. }