mesh.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. /*
  2. * Copyright (c) 2008, 2009 open80211s Ltd.
  3. * Authors: Luis Carlos Cobo <luisca@cozybit.com>
  4. * Javier Cardona <javier@cozybit.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/slab.h>
  11. #include <asm/unaligned.h>
  12. #include "ieee80211_i.h"
  13. #include "mesh.h"
  14. #define TMR_RUNNING_HK 0
  15. #define TMR_RUNNING_MP 1
  16. #define TMR_RUNNING_MPR 2
  17. static int mesh_allocated;
  18. static struct kmem_cache *rm_cache;
  19. bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
  20. {
  21. return (mgmt->u.action.u.mesh_action.action_code ==
  22. WLAN_MESH_ACTION_HWMP_PATH_SELECTION);
  23. }
  24. void ieee80211s_init(void)
  25. {
  26. mesh_pathtbl_init();
  27. mesh_allocated = 1;
  28. rm_cache = kmem_cache_create("mesh_rmc", sizeof(struct rmc_entry),
  29. 0, 0, NULL);
  30. }
  31. void ieee80211s_stop(void)
  32. {
  33. if (!mesh_allocated)
  34. return;
  35. mesh_pathtbl_unregister();
  36. kmem_cache_destroy(rm_cache);
  37. }
  38. static void ieee80211_mesh_housekeeping_timer(unsigned long data)
  39. {
  40. struct ieee80211_sub_if_data *sdata = (void *) data;
  41. struct ieee80211_local *local = sdata->local;
  42. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  43. set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
  44. if (local->quiescing) {
  45. set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
  46. return;
  47. }
  48. ieee80211_queue_work(&local->hw, &sdata->work);
  49. }
  50. /**
  51. * mesh_matches_local - check if the config of a mesh point matches ours
  52. *
  53. * @sdata: local mesh subif
  54. * @ie: information elements of a management frame from the mesh peer
  55. *
  56. * This function checks if the mesh configuration of a mesh point matches the
  57. * local mesh configuration, i.e. if both nodes belong to the same mesh network.
  58. */
  59. bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
  60. struct ieee802_11_elems *ie)
  61. {
  62. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  63. struct ieee80211_local *local = sdata->local;
  64. u32 basic_rates = 0;
  65. struct cfg80211_chan_def sta_chan_def;
  66. /*
  67. * As support for each feature is added, check for matching
  68. * - On mesh config capabilities
  69. * - Power Save Support En
  70. * - Sync support enabled
  71. * - Sync support active
  72. * - Sync support required from peer
  73. * - MDA enabled
  74. * - Power management control on fc
  75. */
  76. if (!(ifmsh->mesh_id_len == ie->mesh_id_len &&
  77. memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
  78. (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
  79. (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) &&
  80. (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) &&
  81. (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) &&
  82. (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)))
  83. return false;
  84. ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata),
  85. &basic_rates);
  86. if (sdata->vif.bss_conf.basic_rates != basic_rates)
  87. return false;
  88. ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan,
  89. ie->ht_operation, &sta_chan_def);
  90. if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef,
  91. &sta_chan_def))
  92. return false;
  93. return true;
  94. }
  95. /**
  96. * mesh_peer_accepts_plinks - check if an mp is willing to establish peer links
  97. *
  98. * @ie: information elements of a management frame from the mesh peer
  99. */
  100. bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
  101. {
  102. return (ie->mesh_config->meshconf_cap &
  103. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
  104. }
  105. /**
  106. * mesh_accept_plinks_update - update accepting_plink in local mesh beacons
  107. *
  108. * @sdata: mesh interface in which mesh beacons are going to be updated
  109. *
  110. * Returns: beacon changed flag if the beacon content changed.
  111. */
  112. u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
  113. {
  114. bool free_plinks;
  115. u32 changed = 0;
  116. /* In case mesh_plink_free_count > 0 and mesh_plinktbl_capacity == 0,
  117. * the mesh interface might be able to establish plinks with peers that
  118. * are already on the table but are not on PLINK_ESTAB state. However,
  119. * in general the mesh interface is not accepting peer link requests
  120. * from new peers, and that must be reflected in the beacon
  121. */
  122. free_plinks = mesh_plink_availables(sdata);
  123. if (free_plinks != sdata->u.mesh.accepting_plinks) {
  124. sdata->u.mesh.accepting_plinks = free_plinks;
  125. changed = BSS_CHANGED_BEACON;
  126. }
  127. return changed;
  128. }
  129. /*
  130. * mesh_sta_cleanup - clean up any mesh sta state
  131. *
  132. * @sta: mesh sta to clean up.
  133. */
  134. void mesh_sta_cleanup(struct sta_info *sta)
  135. {
  136. struct ieee80211_sub_if_data *sdata = sta->sdata;
  137. u32 changed;
  138. /*
  139. * maybe userspace handles peer allocation and peering, but in either
  140. * case the beacon is still generated by the kernel and we might need
  141. * an update.
  142. */
  143. changed = mesh_accept_plinks_update(sdata);
  144. if (sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
  145. changed |= mesh_plink_deactivate(sta);
  146. del_timer_sync(&sta->plink_timer);
  147. }
  148. if (changed)
  149. ieee80211_mbss_info_change_notify(sdata, changed);
  150. }
  151. int mesh_rmc_init(struct ieee80211_sub_if_data *sdata)
  152. {
  153. int i;
  154. sdata->u.mesh.rmc = kmalloc(sizeof(struct mesh_rmc), GFP_KERNEL);
  155. if (!sdata->u.mesh.rmc)
  156. return -ENOMEM;
  157. sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1;
  158. for (i = 0; i < RMC_BUCKETS; i++)
  159. INIT_LIST_HEAD(&sdata->u.mesh.rmc->bucket[i]);
  160. return 0;
  161. }
  162. void mesh_rmc_free(struct ieee80211_sub_if_data *sdata)
  163. {
  164. struct mesh_rmc *rmc = sdata->u.mesh.rmc;
  165. struct rmc_entry *p, *n;
  166. int i;
  167. if (!sdata->u.mesh.rmc)
  168. return;
  169. for (i = 0; i < RMC_BUCKETS; i++) {
  170. list_for_each_entry_safe(p, n, &rmc->bucket[i], list) {
  171. list_del(&p->list);
  172. kmem_cache_free(rm_cache, p);
  173. }
  174. }
  175. kfree(rmc);
  176. sdata->u.mesh.rmc = NULL;
  177. }
  178. /**
  179. * mesh_rmc_check - Check frame in recent multicast cache and add if absent.
  180. *
  181. * @sdata: interface
  182. * @sa: source address
  183. * @mesh_hdr: mesh_header
  184. *
  185. * Returns: 0 if the frame is not in the cache, nonzero otherwise.
  186. *
  187. * Checks using the source address and the mesh sequence number if we have
  188. * received this frame lately. If the frame is not in the cache, it is added to
  189. * it.
  190. */
  191. int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
  192. const u8 *sa, struct ieee80211s_hdr *mesh_hdr)
  193. {
  194. struct mesh_rmc *rmc = sdata->u.mesh.rmc;
  195. u32 seqnum = 0;
  196. int entries = 0;
  197. u8 idx;
  198. struct rmc_entry *p, *n;
  199. /* Don't care about endianness since only match matters */
  200. memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
  201. idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask;
  202. list_for_each_entry_safe(p, n, &rmc->bucket[idx], list) {
  203. ++entries;
  204. if (time_after(jiffies, p->exp_time) ||
  205. entries == RMC_QUEUE_MAX_LEN) {
  206. list_del(&p->list);
  207. kmem_cache_free(rm_cache, p);
  208. --entries;
  209. } else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa))
  210. return -1;
  211. }
  212. p = kmem_cache_alloc(rm_cache, GFP_ATOMIC);
  213. if (!p)
  214. return 0;
  215. p->seqnum = seqnum;
  216. p->exp_time = jiffies + RMC_TIMEOUT;
  217. memcpy(p->sa, sa, ETH_ALEN);
  218. list_add(&p->list, &rmc->bucket[idx]);
  219. return 0;
  220. }
  221. int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
  222. struct sk_buff *skb)
  223. {
  224. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  225. u8 *pos, neighbors;
  226. u8 meshconf_len = sizeof(struct ieee80211_meshconf_ie);
  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. /* Active path selection protocol ID */
  233. *pos++ = ifmsh->mesh_pp_id;
  234. /* Active path selection metric ID */
  235. *pos++ = ifmsh->mesh_pm_id;
  236. /* Congestion control mode identifier */
  237. *pos++ = ifmsh->mesh_cc_id;
  238. /* Synchronization protocol identifier */
  239. *pos++ = ifmsh->mesh_sp_id;
  240. /* Authentication Protocol identifier */
  241. *pos++ = ifmsh->mesh_auth_id;
  242. /* Mesh Formation Info - number of neighbors */
  243. neighbors = atomic_read(&ifmsh->estab_plinks);
  244. /* Number of neighbor mesh STAs or 15 whichever is smaller */
  245. neighbors = (neighbors > 15) ? 15 : neighbors;
  246. *pos++ = neighbors << 1;
  247. /* Mesh capability */
  248. *pos = IEEE80211_MESHCONF_CAPAB_FORWARDING;
  249. *pos |= ifmsh->accepting_plinks ?
  250. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
  251. /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */
  252. *pos |= ifmsh->ps_peers_deep_sleep ?
  253. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
  254. *pos++ |= ifmsh->adjusting_tbtt ?
  255. IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00;
  256. *pos++ = 0x00;
  257. return 0;
  258. }
  259. int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
  260. {
  261. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  262. u8 *pos;
  263. if (skb_tailroom(skb) < 2 + ifmsh->mesh_id_len)
  264. return -ENOMEM;
  265. pos = skb_put(skb, 2 + ifmsh->mesh_id_len);
  266. *pos++ = WLAN_EID_MESH_ID;
  267. *pos++ = ifmsh->mesh_id_len;
  268. if (ifmsh->mesh_id_len)
  269. memcpy(pos, ifmsh->mesh_id, ifmsh->mesh_id_len);
  270. return 0;
  271. }
  272. static int mesh_add_awake_window_ie(struct ieee80211_sub_if_data *sdata,
  273. struct sk_buff *skb)
  274. {
  275. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  276. u8 *pos;
  277. /* see IEEE802.11-2012 13.14.6 */
  278. if (ifmsh->ps_peers_light_sleep == 0 &&
  279. ifmsh->ps_peers_deep_sleep == 0 &&
  280. ifmsh->nonpeer_pm == NL80211_MESH_POWER_ACTIVE)
  281. return 0;
  282. if (skb_tailroom(skb) < 4)
  283. return -ENOMEM;
  284. pos = skb_put(skb, 2 + 2);
  285. *pos++ = WLAN_EID_MESH_AWAKE_WINDOW;
  286. *pos++ = 2;
  287. put_unaligned_le16(ifmsh->mshcfg.dot11MeshAwakeWindowDuration, pos);
  288. return 0;
  289. }
  290. int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
  291. struct sk_buff *skb)
  292. {
  293. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  294. u8 offset, len;
  295. const u8 *data;
  296. if (!ifmsh->ie || !ifmsh->ie_len)
  297. return 0;
  298. /* fast-forward to vendor IEs */
  299. offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
  300. if (offset) {
  301. len = ifmsh->ie_len - offset;
  302. data = ifmsh->ie + offset;
  303. if (skb_tailroom(skb) < len)
  304. return -ENOMEM;
  305. memcpy(skb_put(skb, len), data, len);
  306. }
  307. return 0;
  308. }
  309. int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
  310. {
  311. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  312. u8 len = 0;
  313. const u8 *data;
  314. if (!ifmsh->ie || !ifmsh->ie_len)
  315. return 0;
  316. /* find RSN IE */
  317. data = ifmsh->ie;
  318. while (data < ifmsh->ie + ifmsh->ie_len) {
  319. if (*data == WLAN_EID_RSN) {
  320. len = data[1] + 2;
  321. break;
  322. }
  323. data++;
  324. }
  325. if (len) {
  326. if (skb_tailroom(skb) < len)
  327. return -ENOMEM;
  328. memcpy(skb_put(skb, len), data, len);
  329. }
  330. return 0;
  331. }
  332. static int mesh_add_ds_params_ie(struct ieee80211_sub_if_data *sdata,
  333. struct sk_buff *skb)
  334. {
  335. struct ieee80211_chanctx_conf *chanctx_conf;
  336. struct ieee80211_channel *chan;
  337. u8 *pos;
  338. if (skb_tailroom(skb) < 3)
  339. return -ENOMEM;
  340. rcu_read_lock();
  341. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  342. if (WARN_ON(!chanctx_conf)) {
  343. rcu_read_unlock();
  344. return -EINVAL;
  345. }
  346. chan = chanctx_conf->def.chan;
  347. rcu_read_unlock();
  348. pos = skb_put(skb, 2 + 1);
  349. *pos++ = WLAN_EID_DS_PARAMS;
  350. *pos++ = 1;
  351. *pos++ = ieee80211_frequency_to_channel(chan->center_freq);
  352. return 0;
  353. }
  354. int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
  355. struct sk_buff *skb)
  356. {
  357. struct ieee80211_local *local = sdata->local;
  358. enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
  359. struct ieee80211_supported_band *sband;
  360. u8 *pos;
  361. sband = local->hw.wiphy->bands[band];
  362. if (!sband->ht_cap.ht_supported ||
  363. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
  364. return 0;
  365. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap))
  366. return -ENOMEM;
  367. pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap));
  368. ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, sband->ht_cap.cap);
  369. return 0;
  370. }
  371. int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
  372. struct sk_buff *skb)
  373. {
  374. struct ieee80211_local *local = sdata->local;
  375. struct ieee80211_chanctx_conf *chanctx_conf;
  376. struct ieee80211_channel *channel;
  377. enum nl80211_channel_type channel_type =
  378. cfg80211_get_chandef_type(&sdata->vif.bss_conf.chandef);
  379. struct ieee80211_supported_band *sband;
  380. struct ieee80211_sta_ht_cap *ht_cap;
  381. u8 *pos;
  382. rcu_read_lock();
  383. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  384. if (WARN_ON(!chanctx_conf)) {
  385. rcu_read_unlock();
  386. return -EINVAL;
  387. }
  388. channel = chanctx_conf->def.chan;
  389. rcu_read_unlock();
  390. sband = local->hw.wiphy->bands[channel->band];
  391. ht_cap = &sband->ht_cap;
  392. if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT)
  393. return 0;
  394. if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_operation))
  395. return -ENOMEM;
  396. pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_operation));
  397. ieee80211_ie_build_ht_oper(pos, ht_cap, &sdata->vif.bss_conf.chandef,
  398. sdata->vif.bss_conf.ht_operation_mode);
  399. return 0;
  400. }
  401. static void ieee80211_mesh_path_timer(unsigned long data)
  402. {
  403. struct ieee80211_sub_if_data *sdata =
  404. (struct ieee80211_sub_if_data *) data;
  405. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  406. struct ieee80211_local *local = sdata->local;
  407. if (local->quiescing) {
  408. set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
  409. return;
  410. }
  411. ieee80211_queue_work(&local->hw, &sdata->work);
  412. }
  413. static void ieee80211_mesh_path_root_timer(unsigned long data)
  414. {
  415. struct ieee80211_sub_if_data *sdata =
  416. (struct ieee80211_sub_if_data *) data;
  417. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  418. struct ieee80211_local *local = sdata->local;
  419. set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  420. if (local->quiescing) {
  421. set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
  422. return;
  423. }
  424. ieee80211_queue_work(&local->hw, &sdata->work);
  425. }
  426. void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
  427. {
  428. if (ifmsh->mshcfg.dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)
  429. set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  430. else {
  431. clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
  432. /* stop running timer */
  433. del_timer_sync(&ifmsh->mesh_path_root_timer);
  434. }
  435. }
  436. /**
  437. * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame
  438. * @hdr: 802.11 frame header
  439. * @fc: frame control field
  440. * @meshda: destination address in the mesh
  441. * @meshsa: source address address in the mesh. Same as TA, as frame is
  442. * locally originated.
  443. *
  444. * Return the length of the 802.11 (does not include a mesh control header)
  445. */
  446. int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
  447. const u8 *meshda, const u8 *meshsa)
  448. {
  449. if (is_multicast_ether_addr(meshda)) {
  450. *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
  451. /* DA TA SA */
  452. memcpy(hdr->addr1, meshda, ETH_ALEN);
  453. memcpy(hdr->addr2, meshsa, ETH_ALEN);
  454. memcpy(hdr->addr3, meshsa, ETH_ALEN);
  455. return 24;
  456. } else {
  457. *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
  458. /* RA TA DA SA */
  459. memset(hdr->addr1, 0, ETH_ALEN); /* RA is resolved later */
  460. memcpy(hdr->addr2, meshsa, ETH_ALEN);
  461. memcpy(hdr->addr3, meshda, ETH_ALEN);
  462. memcpy(hdr->addr4, meshsa, ETH_ALEN);
  463. return 30;
  464. }
  465. }
  466. /**
  467. * ieee80211_new_mesh_header - create a new mesh header
  468. * @sdata: mesh interface to be used
  469. * @meshhdr: uninitialized mesh header
  470. * @addr4or5: 1st address in the ae header, which may correspond to address 4
  471. * (if addr6 is NULL) or address 5 (if addr6 is present). It may
  472. * be NULL.
  473. * @addr6: 2nd address in the ae header, which corresponds to addr6 of the
  474. * mesh frame
  475. *
  476. * Return the header length.
  477. */
  478. int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
  479. struct ieee80211s_hdr *meshhdr,
  480. const char *addr4or5, const char *addr6)
  481. {
  482. if (WARN_ON(!addr4or5 && addr6))
  483. return 0;
  484. memset(meshhdr, 0, sizeof(*meshhdr));
  485. meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
  486. /* FIXME: racy -- TX on multiple queues can be concurrent */
  487. put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
  488. sdata->u.mesh.mesh_seqnum++;
  489. if (addr4or5 && !addr6) {
  490. meshhdr->flags |= MESH_FLAGS_AE_A4;
  491. memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
  492. return 2 * ETH_ALEN;
  493. } else if (addr4or5 && addr6) {
  494. meshhdr->flags |= MESH_FLAGS_AE_A5_A6;
  495. memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
  496. memcpy(meshhdr->eaddr2, addr6, ETH_ALEN);
  497. return 3 * ETH_ALEN;
  498. }
  499. return ETH_ALEN;
  500. }
  501. static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata)
  502. {
  503. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  504. u32 changed;
  505. ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT);
  506. mesh_path_expire(sdata);
  507. changed = mesh_accept_plinks_update(sdata);
  508. ieee80211_mbss_info_change_notify(sdata, changed);
  509. mod_timer(&ifmsh->housekeeping_timer,
  510. round_jiffies(jiffies +
  511. IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
  512. }
  513. static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
  514. {
  515. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  516. u32 interval;
  517. mesh_path_tx_root_frame(sdata);
  518. if (ifmsh->mshcfg.dot11MeshHWMPRootMode == IEEE80211_PROACTIVE_RANN)
  519. interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
  520. else
  521. interval = ifmsh->mshcfg.dot11MeshHWMProotInterval;
  522. mod_timer(&ifmsh->mesh_path_root_timer,
  523. round_jiffies(TU_TO_EXP_TIME(interval)));
  524. }
  525. #ifdef CONFIG_PM
  526. void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
  527. {
  528. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  529. /* use atomic bitops in case all timers fire at the same time */
  530. if (del_timer_sync(&ifmsh->housekeeping_timer))
  531. set_bit(TMR_RUNNING_HK, &ifmsh->timers_running);
  532. if (del_timer_sync(&ifmsh->mesh_path_timer))
  533. set_bit(TMR_RUNNING_MP, &ifmsh->timers_running);
  534. if (del_timer_sync(&ifmsh->mesh_path_root_timer))
  535. set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running);
  536. }
  537. void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
  538. {
  539. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  540. if (test_and_clear_bit(TMR_RUNNING_HK, &ifmsh->timers_running))
  541. add_timer(&ifmsh->housekeeping_timer);
  542. if (test_and_clear_bit(TMR_RUNNING_MP, &ifmsh->timers_running))
  543. add_timer(&ifmsh->mesh_path_timer);
  544. if (test_and_clear_bit(TMR_RUNNING_MPR, &ifmsh->timers_running))
  545. add_timer(&ifmsh->mesh_path_root_timer);
  546. ieee80211_mesh_root_setup(ifmsh);
  547. }
  548. #endif
  549. static int
  550. ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
  551. {
  552. struct beacon_data *bcn;
  553. int head_len, tail_len;
  554. struct sk_buff *skb;
  555. struct ieee80211_mgmt *mgmt;
  556. struct ieee80211_chanctx_conf *chanctx_conf;
  557. enum ieee80211_band band;
  558. u8 *pos;
  559. struct ieee80211_sub_if_data *sdata;
  560. int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +
  561. sizeof(mgmt->u.beacon);
  562. sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
  563. rcu_read_lock();
  564. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  565. band = chanctx_conf->def.chan->band;
  566. rcu_read_unlock();
  567. head_len = hdr_len +
  568. 2 + /* NULL SSID */
  569. 2 + 8 + /* supported rates */
  570. 2 + 3; /* DS params */
  571. tail_len = 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
  572. 2 + sizeof(struct ieee80211_ht_cap) +
  573. 2 + sizeof(struct ieee80211_ht_operation) +
  574. 2 + ifmsh->mesh_id_len +
  575. 2 + sizeof(struct ieee80211_meshconf_ie) +
  576. 2 + sizeof(__le16) + /* awake window */
  577. ifmsh->ie_len;
  578. bcn = kzalloc(sizeof(*bcn) + head_len + tail_len, GFP_KERNEL);
  579. /* need an skb for IE builders to operate on */
  580. skb = dev_alloc_skb(max(head_len, tail_len));
  581. if (!bcn || !skb)
  582. goto out_free;
  583. /*
  584. * pointers go into the block we allocated,
  585. * memory is | beacon_data | head | tail |
  586. */
  587. bcn->head = ((u8 *) bcn) + sizeof(*bcn);
  588. /* fill in the head */
  589. mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
  590. memset(mgmt, 0, hdr_len);
  591. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  592. IEEE80211_STYPE_BEACON);
  593. eth_broadcast_addr(mgmt->da);
  594. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  595. memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
  596. ieee80211_mps_set_frame_flags(sdata, NULL, (void *) mgmt);
  597. mgmt->u.beacon.beacon_int =
  598. cpu_to_le16(sdata->vif.bss_conf.beacon_int);
  599. mgmt->u.beacon.capab_info |= cpu_to_le16(
  600. sdata->u.mesh.security ? WLAN_CAPABILITY_PRIVACY : 0);
  601. pos = skb_put(skb, 2);
  602. *pos++ = WLAN_EID_SSID;
  603. *pos++ = 0x0;
  604. if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
  605. mesh_add_ds_params_ie(sdata, skb))
  606. goto out_free;
  607. bcn->head_len = skb->len;
  608. memcpy(bcn->head, skb->data, bcn->head_len);
  609. /* now the tail */
  610. skb_trim(skb, 0);
  611. bcn->tail = bcn->head + bcn->head_len;
  612. if (ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
  613. mesh_add_rsn_ie(sdata, skb) ||
  614. mesh_add_ht_cap_ie(sdata, skb) ||
  615. mesh_add_ht_oper_ie(sdata, skb) ||
  616. mesh_add_meshid_ie(sdata, skb) ||
  617. mesh_add_meshconf_ie(sdata, skb) ||
  618. mesh_add_awake_window_ie(sdata, skb) ||
  619. mesh_add_vendor_ies(sdata, skb))
  620. goto out_free;
  621. bcn->tail_len = skb->len;
  622. memcpy(bcn->tail, skb->data, bcn->tail_len);
  623. dev_kfree_skb(skb);
  624. rcu_assign_pointer(ifmsh->beacon, bcn);
  625. return 0;
  626. out_free:
  627. kfree(bcn);
  628. dev_kfree_skb(skb);
  629. return -ENOMEM;
  630. }
  631. static int
  632. ieee80211_mesh_rebuild_beacon(struct ieee80211_if_mesh *ifmsh)
  633. {
  634. struct ieee80211_sub_if_data *sdata;
  635. struct beacon_data *old_bcn;
  636. int ret;
  637. sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
  638. mutex_lock(&ifmsh->mtx);
  639. old_bcn = rcu_dereference_protected(ifmsh->beacon,
  640. lockdep_is_held(&ifmsh->mtx));
  641. ret = ieee80211_mesh_build_beacon(ifmsh);
  642. if (ret)
  643. /* just reuse old beacon */
  644. goto out;
  645. if (old_bcn)
  646. kfree_rcu(old_bcn, rcu_head);
  647. out:
  648. mutex_unlock(&ifmsh->mtx);
  649. return ret;
  650. }
  651. void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  652. u32 changed)
  653. {
  654. if (sdata->vif.bss_conf.enable_beacon &&
  655. (changed & (BSS_CHANGED_BEACON |
  656. BSS_CHANGED_HT |
  657. BSS_CHANGED_BASIC_RATES |
  658. BSS_CHANGED_BEACON_INT)))
  659. if (ieee80211_mesh_rebuild_beacon(&sdata->u.mesh))
  660. return;
  661. ieee80211_bss_info_change_notify(sdata, changed);
  662. }
  663. int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
  664. {
  665. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  666. struct ieee80211_local *local = sdata->local;
  667. u32 changed = BSS_CHANGED_BEACON |
  668. BSS_CHANGED_BEACON_ENABLED |
  669. BSS_CHANGED_HT |
  670. BSS_CHANGED_BASIC_RATES |
  671. BSS_CHANGED_BEACON_INT;
  672. enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
  673. local->fif_other_bss++;
  674. /* mesh ifaces must set allmulti to forward mcast traffic */
  675. atomic_inc(&local->iff_allmultis);
  676. ieee80211_configure_filter(local);
  677. ifmsh->mesh_cc_id = 0; /* Disabled */
  678. ifmsh->mesh_auth_id = 0; /* Disabled */
  679. /* register sync ops from extensible synchronization framework */
  680. ifmsh->sync_ops = ieee80211_mesh_sync_ops_get(ifmsh->mesh_sp_id);
  681. ifmsh->adjusting_tbtt = false;
  682. ifmsh->sync_offset_clockdrift_max = 0;
  683. set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
  684. ieee80211_mesh_root_setup(ifmsh);
  685. ieee80211_queue_work(&local->hw, &sdata->work);
  686. sdata->vif.bss_conf.ht_operation_mode =
  687. ifmsh->mshcfg.ht_opmode;
  688. sdata->vif.bss_conf.enable_beacon = true;
  689. sdata->vif.bss_conf.basic_rates =
  690. ieee80211_mandatory_rates(local, band);
  691. changed |= ieee80211_mps_local_status_update(sdata);
  692. if (ieee80211_mesh_build_beacon(ifmsh)) {
  693. ieee80211_stop_mesh(sdata);
  694. return -ENOMEM;
  695. }
  696. ieee80211_bss_info_change_notify(sdata, changed);
  697. netif_carrier_on(sdata->dev);
  698. return 0;
  699. }
  700. void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
  701. {
  702. struct ieee80211_local *local = sdata->local;
  703. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  704. struct beacon_data *bcn;
  705. netif_carrier_off(sdata->dev);
  706. /* stop the beacon */
  707. ifmsh->mesh_id_len = 0;
  708. sdata->vif.bss_conf.enable_beacon = false;
  709. clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
  710. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
  711. mutex_lock(&ifmsh->mtx);
  712. bcn = rcu_dereference_protected(ifmsh->beacon,
  713. lockdep_is_held(&ifmsh->mtx));
  714. rcu_assign_pointer(ifmsh->beacon, NULL);
  715. kfree_rcu(bcn, rcu_head);
  716. mutex_unlock(&ifmsh->mtx);
  717. /* flush STAs and mpaths on this iface */
  718. sta_info_flush(sdata);
  719. mesh_path_flush_by_iface(sdata);
  720. /* free all potentially still buffered group-addressed frames */
  721. local->total_ps_buffered -= skb_queue_len(&ifmsh->ps.bc_buf);
  722. skb_queue_purge(&ifmsh->ps.bc_buf);
  723. del_timer_sync(&sdata->u.mesh.housekeeping_timer);
  724. del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
  725. del_timer_sync(&sdata->u.mesh.mesh_path_timer);
  726. /*
  727. * If the timer fired while we waited for it, it will have
  728. * requeued the work. Now the work will be running again
  729. * but will not rearm the timer again because it checks
  730. * whether the interface is running, which, at this point,
  731. * it no longer is.
  732. */
  733. cancel_work_sync(&sdata->work);
  734. local->fif_other_bss--;
  735. atomic_dec(&local->iff_allmultis);
  736. ieee80211_configure_filter(local);
  737. sdata->u.mesh.timers_running = 0;
  738. }
  739. static void
  740. ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata,
  741. struct ieee80211_mgmt *mgmt, size_t len)
  742. {
  743. struct ieee80211_local *local = sdata->local;
  744. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  745. struct sk_buff *presp;
  746. struct beacon_data *bcn;
  747. struct ieee80211_mgmt *hdr;
  748. struct ieee802_11_elems elems;
  749. size_t baselen;
  750. u8 *pos, *end;
  751. end = ((u8 *) mgmt) + len;
  752. pos = mgmt->u.probe_req.variable;
  753. baselen = (u8 *) pos - (u8 *) mgmt;
  754. if (baselen > len)
  755. return;
  756. ieee802_11_parse_elems(pos, len - baselen, &elems);
  757. /* 802.11-2012 10.1.4.3.2 */
  758. if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
  759. !is_broadcast_ether_addr(mgmt->da)) ||
  760. elems.ssid_len != 0)
  761. return;
  762. if (elems.mesh_id_len != 0 &&
  763. (elems.mesh_id_len != ifmsh->mesh_id_len ||
  764. memcmp(elems.mesh_id, ifmsh->mesh_id, ifmsh->mesh_id_len)))
  765. return;
  766. rcu_read_lock();
  767. bcn = rcu_dereference(ifmsh->beacon);
  768. if (!bcn)
  769. goto out;
  770. presp = dev_alloc_skb(local->tx_headroom +
  771. bcn->head_len + bcn->tail_len);
  772. if (!presp)
  773. goto out;
  774. skb_reserve(presp, local->tx_headroom);
  775. memcpy(skb_put(presp, bcn->head_len), bcn->head, bcn->head_len);
  776. memcpy(skb_put(presp, bcn->tail_len), bcn->tail, bcn->tail_len);
  777. hdr = (struct ieee80211_mgmt *) presp->data;
  778. hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  779. IEEE80211_STYPE_PROBE_RESP);
  780. memcpy(hdr->da, mgmt->sa, ETH_ALEN);
  781. IEEE80211_SKB_CB(presp)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
  782. ieee80211_tx_skb(sdata, presp);
  783. out:
  784. rcu_read_unlock();
  785. }
  786. static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
  787. u16 stype,
  788. struct ieee80211_mgmt *mgmt,
  789. size_t len,
  790. struct ieee80211_rx_status *rx_status)
  791. {
  792. struct ieee80211_local *local = sdata->local;
  793. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  794. struct ieee802_11_elems elems;
  795. struct ieee80211_channel *channel;
  796. size_t baselen;
  797. int freq;
  798. enum ieee80211_band band = rx_status->band;
  799. /* ignore ProbeResp to foreign address */
  800. if (stype == IEEE80211_STYPE_PROBE_RESP &&
  801. !ether_addr_equal(mgmt->da, sdata->vif.addr))
  802. return;
  803. baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
  804. if (baselen > len)
  805. return;
  806. ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
  807. &elems);
  808. /* ignore non-mesh or secure / unsecure mismatch */
  809. if ((!elems.mesh_id || !elems.mesh_config) ||
  810. (elems.rsn && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) ||
  811. (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE))
  812. return;
  813. if (elems.ds_params && elems.ds_params_len == 1)
  814. freq = ieee80211_channel_to_frequency(elems.ds_params[0], band);
  815. else
  816. freq = rx_status->freq;
  817. channel = ieee80211_get_channel(local->hw.wiphy, freq);
  818. if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
  819. return;
  820. if (mesh_matches_local(sdata, &elems))
  821. mesh_neighbour_update(sdata, mgmt->sa, &elems);
  822. if (ifmsh->sync_ops)
  823. ifmsh->sync_ops->rx_bcn_presp(sdata,
  824. stype, mgmt, &elems, rx_status);
  825. }
  826. static void ieee80211_mesh_rx_mgmt_action(struct ieee80211_sub_if_data *sdata,
  827. struct ieee80211_mgmt *mgmt,
  828. size_t len,
  829. struct ieee80211_rx_status *rx_status)
  830. {
  831. switch (mgmt->u.action.category) {
  832. case WLAN_CATEGORY_SELF_PROTECTED:
  833. switch (mgmt->u.action.u.self_prot.action_code) {
  834. case WLAN_SP_MESH_PEERING_OPEN:
  835. case WLAN_SP_MESH_PEERING_CLOSE:
  836. case WLAN_SP_MESH_PEERING_CONFIRM:
  837. mesh_rx_plink_frame(sdata, mgmt, len, rx_status);
  838. break;
  839. }
  840. break;
  841. case WLAN_CATEGORY_MESH_ACTION:
  842. if (mesh_action_is_path_sel(mgmt))
  843. mesh_rx_path_sel_frame(sdata, mgmt, len);
  844. break;
  845. }
  846. }
  847. void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  848. struct sk_buff *skb)
  849. {
  850. struct ieee80211_rx_status *rx_status;
  851. struct ieee80211_mgmt *mgmt;
  852. u16 stype;
  853. rx_status = IEEE80211_SKB_RXCB(skb);
  854. mgmt = (struct ieee80211_mgmt *) skb->data;
  855. stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
  856. switch (stype) {
  857. case IEEE80211_STYPE_PROBE_RESP:
  858. case IEEE80211_STYPE_BEACON:
  859. ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len,
  860. rx_status);
  861. break;
  862. case IEEE80211_STYPE_PROBE_REQ:
  863. ieee80211_mesh_rx_probe_req(sdata, mgmt, skb->len);
  864. break;
  865. case IEEE80211_STYPE_ACTION:
  866. ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status);
  867. break;
  868. }
  869. }
  870. void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata)
  871. {
  872. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  873. if (ifmsh->preq_queue_len &&
  874. time_after(jiffies,
  875. ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
  876. mesh_path_start_discovery(sdata);
  877. if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
  878. mesh_mpath_table_grow();
  879. if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags))
  880. mesh_mpp_table_grow();
  881. if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
  882. ieee80211_mesh_housekeeping(sdata);
  883. if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags))
  884. ieee80211_mesh_rootpath(sdata);
  885. if (test_and_clear_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags))
  886. mesh_sync_adjust_tbtt(sdata);
  887. }
  888. void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
  889. {
  890. struct ieee80211_sub_if_data *sdata;
  891. rcu_read_lock();
  892. list_for_each_entry_rcu(sdata, &local->interfaces, list)
  893. if (ieee80211_vif_is_mesh(&sdata->vif))
  894. ieee80211_queue_work(&local->hw, &sdata->work);
  895. rcu_read_unlock();
  896. }
  897. void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
  898. {
  899. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  900. static u8 zero_addr[ETH_ALEN] = {};
  901. setup_timer(&ifmsh->housekeeping_timer,
  902. ieee80211_mesh_housekeeping_timer,
  903. (unsigned long) sdata);
  904. ifmsh->accepting_plinks = true;
  905. ifmsh->preq_id = 0;
  906. ifmsh->sn = 0;
  907. ifmsh->num_gates = 0;
  908. atomic_set(&ifmsh->mpaths, 0);
  909. mesh_rmc_init(sdata);
  910. ifmsh->last_preq = jiffies;
  911. ifmsh->next_perr = jiffies;
  912. /* Allocate all mesh structures when creating the first mesh interface. */
  913. if (!mesh_allocated)
  914. ieee80211s_init();
  915. setup_timer(&ifmsh->mesh_path_timer,
  916. ieee80211_mesh_path_timer,
  917. (unsigned long) sdata);
  918. setup_timer(&ifmsh->mesh_path_root_timer,
  919. ieee80211_mesh_path_root_timer,
  920. (unsigned long) sdata);
  921. INIT_LIST_HEAD(&ifmsh->preq_queue.list);
  922. skb_queue_head_init(&ifmsh->ps.bc_buf);
  923. spin_lock_init(&ifmsh->mesh_preq_queue_lock);
  924. spin_lock_init(&ifmsh->sync_offset_lock);
  925. RCU_INIT_POINTER(ifmsh->beacon, NULL);
  926. mutex_init(&ifmsh->mtx);
  927. sdata->vif.bss_conf.bssid = zero_addr;
  928. }