mesh_pathtbl.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /*
  2. * Copyright (c) 2008, 2009 open80211s Ltd.
  3. * Author: Luis Carlos Cobo <luisca@cozybit.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/etherdevice.h>
  10. #include <linux/list.h>
  11. #include <linux/random.h>
  12. #include <linux/slab.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/string.h>
  15. #include <net/mac80211.h>
  16. #include "wme.h"
  17. #include "ieee80211_i.h"
  18. #include "mesh.h"
  19. /* There will be initially 2^INIT_PATHS_SIZE_ORDER buckets */
  20. #define INIT_PATHS_SIZE_ORDER 2
  21. /* Keep the mean chain length below this constant */
  22. #define MEAN_CHAIN_LEN 2
  23. static inline bool mpath_expired(struct mesh_path *mpath)
  24. {
  25. return (mpath->flags & MESH_PATH_ACTIVE) &&
  26. time_after(jiffies, mpath->exp_time) &&
  27. !(mpath->flags & MESH_PATH_FIXED);
  28. }
  29. struct mpath_node {
  30. struct hlist_node list;
  31. struct rcu_head rcu;
  32. /* This indirection allows two different tables to point to the same
  33. * mesh_path structure, useful when resizing
  34. */
  35. struct mesh_path *mpath;
  36. };
  37. static inline struct mesh_table *resize_dereference_paths(
  38. struct ieee80211_sub_if_data *sdata,
  39. struct mesh_table __rcu *table)
  40. {
  41. return rcu_dereference_protected(table,
  42. lockdep_is_held(&sdata->u.mesh.pathtbl_resize_lock));
  43. }
  44. static inline struct mesh_table *resize_dereference_mesh_paths(
  45. struct ieee80211_sub_if_data *sdata)
  46. {
  47. return resize_dereference_paths(sdata, sdata->u.mesh.mesh_paths);
  48. }
  49. static inline struct mesh_table *resize_dereference_mpp_paths(
  50. struct ieee80211_sub_if_data *sdata)
  51. {
  52. return resize_dereference_paths(sdata, sdata->u.mesh.mpp_paths);
  53. }
  54. /*
  55. * CAREFUL -- "tbl" must not be an expression,
  56. * in particular not an rcu_dereference(), since
  57. * it's used twice. So it is illegal to do
  58. * for_each_mesh_entry(rcu_dereference(...), ...)
  59. */
  60. #define for_each_mesh_entry(tbl, node, i) \
  61. for (i = 0; i <= tbl->hash_mask; i++) \
  62. hlist_for_each_entry_rcu(node, &tbl->hash_buckets[i], list)
  63. static struct mesh_table *mesh_table_alloc(int size_order)
  64. {
  65. int i;
  66. struct mesh_table *newtbl;
  67. newtbl = kmalloc(sizeof(struct mesh_table), GFP_ATOMIC);
  68. if (!newtbl)
  69. return NULL;
  70. newtbl->hash_buckets = kzalloc(sizeof(struct hlist_head) *
  71. (1 << size_order), GFP_ATOMIC);
  72. if (!newtbl->hash_buckets) {
  73. kfree(newtbl);
  74. return NULL;
  75. }
  76. newtbl->hashwlock = kmalloc(sizeof(spinlock_t) *
  77. (1 << size_order), GFP_ATOMIC);
  78. if (!newtbl->hashwlock) {
  79. kfree(newtbl->hash_buckets);
  80. kfree(newtbl);
  81. return NULL;
  82. }
  83. newtbl->size_order = size_order;
  84. newtbl->hash_mask = (1 << size_order) - 1;
  85. atomic_set(&newtbl->entries, 0);
  86. get_random_bytes(&newtbl->hash_rnd,
  87. sizeof(newtbl->hash_rnd));
  88. for (i = 0; i <= newtbl->hash_mask; i++)
  89. spin_lock_init(&newtbl->hashwlock[i]);
  90. spin_lock_init(&newtbl->gates_lock);
  91. return newtbl;
  92. }
  93. static void __mesh_table_free(struct mesh_table *tbl)
  94. {
  95. kfree(tbl->hash_buckets);
  96. kfree(tbl->hashwlock);
  97. kfree(tbl);
  98. }
  99. static void mesh_table_free(struct mesh_table *tbl, bool free_leafs)
  100. {
  101. struct hlist_head *mesh_hash;
  102. struct hlist_node *p, *q;
  103. struct mpath_node *gate;
  104. int i;
  105. mesh_hash = tbl->hash_buckets;
  106. for (i = 0; i <= tbl->hash_mask; i++) {
  107. spin_lock_bh(&tbl->hashwlock[i]);
  108. hlist_for_each_safe(p, q, &mesh_hash[i]) {
  109. tbl->free_node(p, free_leafs);
  110. atomic_dec(&tbl->entries);
  111. }
  112. spin_unlock_bh(&tbl->hashwlock[i]);
  113. }
  114. if (free_leafs) {
  115. spin_lock_bh(&tbl->gates_lock);
  116. hlist_for_each_entry_safe(gate, q,
  117. tbl->known_gates, list) {
  118. hlist_del(&gate->list);
  119. kfree(gate);
  120. }
  121. kfree(tbl->known_gates);
  122. spin_unlock_bh(&tbl->gates_lock);
  123. }
  124. __mesh_table_free(tbl);
  125. }
  126. static int mesh_table_grow(struct mesh_table *oldtbl,
  127. struct mesh_table *newtbl)
  128. {
  129. struct hlist_head *oldhash;
  130. struct hlist_node *p, *q;
  131. int i;
  132. if (atomic_read(&oldtbl->entries)
  133. < MEAN_CHAIN_LEN * (oldtbl->hash_mask + 1))
  134. return -EAGAIN;
  135. newtbl->free_node = oldtbl->free_node;
  136. newtbl->copy_node = oldtbl->copy_node;
  137. newtbl->known_gates = oldtbl->known_gates;
  138. atomic_set(&newtbl->entries, atomic_read(&oldtbl->entries));
  139. oldhash = oldtbl->hash_buckets;
  140. for (i = 0; i <= oldtbl->hash_mask; i++)
  141. hlist_for_each(p, &oldhash[i])
  142. if (oldtbl->copy_node(p, newtbl) < 0)
  143. goto errcopy;
  144. return 0;
  145. errcopy:
  146. for (i = 0; i <= newtbl->hash_mask; i++) {
  147. hlist_for_each_safe(p, q, &newtbl->hash_buckets[i])
  148. oldtbl->free_node(p, 0);
  149. }
  150. return -ENOMEM;
  151. }
  152. static u32 mesh_table_hash(const u8 *addr, struct ieee80211_sub_if_data *sdata,
  153. struct mesh_table *tbl)
  154. {
  155. /* Use last four bytes of hw addr and interface index as hash index */
  156. return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex,
  157. tbl->hash_rnd) & tbl->hash_mask;
  158. }
  159. /**
  160. *
  161. * mesh_path_assign_nexthop - update mesh path next hop
  162. *
  163. * @mpath: mesh path to update
  164. * @sta: next hop to assign
  165. *
  166. * Locking: mpath->state_lock must be held when calling this function
  167. */
  168. void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
  169. {
  170. struct sk_buff *skb;
  171. struct ieee80211_hdr *hdr;
  172. unsigned long flags;
  173. rcu_assign_pointer(mpath->next_hop, sta);
  174. spin_lock_irqsave(&mpath->frame_queue.lock, flags);
  175. skb_queue_walk(&mpath->frame_queue, skb) {
  176. hdr = (struct ieee80211_hdr *) skb->data;
  177. memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN);
  178. memcpy(hdr->addr2, mpath->sdata->vif.addr, ETH_ALEN);
  179. ieee80211_mps_set_frame_flags(sta->sdata, sta, hdr);
  180. }
  181. spin_unlock_irqrestore(&mpath->frame_queue.lock, flags);
  182. }
  183. static void prepare_for_gate(struct sk_buff *skb, char *dst_addr,
  184. struct mesh_path *gate_mpath)
  185. {
  186. struct ieee80211_hdr *hdr;
  187. struct ieee80211s_hdr *mshdr;
  188. int mesh_hdrlen, hdrlen;
  189. char *next_hop;
  190. hdr = (struct ieee80211_hdr *) skb->data;
  191. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  192. mshdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
  193. if (!(mshdr->flags & MESH_FLAGS_AE)) {
  194. /* size of the fixed part of the mesh header */
  195. mesh_hdrlen = 6;
  196. /* make room for the two extended addresses */
  197. skb_push(skb, 2 * ETH_ALEN);
  198. memmove(skb->data, hdr, hdrlen + mesh_hdrlen);
  199. hdr = (struct ieee80211_hdr *) skb->data;
  200. /* we preserve the previous mesh header and only add
  201. * the new addreses */
  202. mshdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
  203. mshdr->flags = MESH_FLAGS_AE_A5_A6;
  204. memcpy(mshdr->eaddr1, hdr->addr3, ETH_ALEN);
  205. memcpy(mshdr->eaddr2, hdr->addr4, ETH_ALEN);
  206. }
  207. /* update next hop */
  208. hdr = (struct ieee80211_hdr *) skb->data;
  209. rcu_read_lock();
  210. next_hop = rcu_dereference(gate_mpath->next_hop)->sta.addr;
  211. memcpy(hdr->addr1, next_hop, ETH_ALEN);
  212. rcu_read_unlock();
  213. memcpy(hdr->addr2, gate_mpath->sdata->vif.addr, ETH_ALEN);
  214. memcpy(hdr->addr3, dst_addr, ETH_ALEN);
  215. }
  216. /**
  217. *
  218. * mesh_path_move_to_queue - Move or copy frames from one mpath queue to another
  219. *
  220. * This function is used to transfer or copy frames from an unresolved mpath to
  221. * a gate mpath. The function also adds the Address Extension field and
  222. * updates the next hop.
  223. *
  224. * If a frame already has an Address Extension field, only the next hop and
  225. * destination addresses are updated.
  226. *
  227. * The gate mpath must be an active mpath with a valid mpath->next_hop.
  228. *
  229. * @mpath: An active mpath the frames will be sent to (i.e. the gate)
  230. * @from_mpath: The failed mpath
  231. * @copy: When true, copy all the frames to the new mpath queue. When false,
  232. * move them.
  233. */
  234. static void mesh_path_move_to_queue(struct mesh_path *gate_mpath,
  235. struct mesh_path *from_mpath,
  236. bool copy)
  237. {
  238. struct sk_buff *skb, *fskb, *tmp;
  239. struct sk_buff_head failq;
  240. unsigned long flags;
  241. if (WARN_ON(gate_mpath == from_mpath))
  242. return;
  243. if (WARN_ON(!gate_mpath->next_hop))
  244. return;
  245. __skb_queue_head_init(&failq);
  246. spin_lock_irqsave(&from_mpath->frame_queue.lock, flags);
  247. skb_queue_splice_init(&from_mpath->frame_queue, &failq);
  248. spin_unlock_irqrestore(&from_mpath->frame_queue.lock, flags);
  249. skb_queue_walk_safe(&failq, fskb, tmp) {
  250. if (skb_queue_len(&gate_mpath->frame_queue) >=
  251. MESH_FRAME_QUEUE_LEN) {
  252. mpath_dbg(gate_mpath->sdata, "mpath queue full!\n");
  253. break;
  254. }
  255. skb = skb_copy(fskb, GFP_ATOMIC);
  256. if (WARN_ON(!skb))
  257. break;
  258. prepare_for_gate(skb, gate_mpath->dst, gate_mpath);
  259. skb_queue_tail(&gate_mpath->frame_queue, skb);
  260. if (copy)
  261. continue;
  262. __skb_unlink(fskb, &failq);
  263. kfree_skb(fskb);
  264. }
  265. mpath_dbg(gate_mpath->sdata, "Mpath queue for gate %pM has %d frames\n",
  266. gate_mpath->dst, skb_queue_len(&gate_mpath->frame_queue));
  267. if (!copy)
  268. return;
  269. spin_lock_irqsave(&from_mpath->frame_queue.lock, flags);
  270. skb_queue_splice(&failq, &from_mpath->frame_queue);
  271. spin_unlock_irqrestore(&from_mpath->frame_queue.lock, flags);
  272. }
  273. static struct mesh_path *mpath_lookup(struct mesh_table *tbl, const u8 *dst,
  274. struct ieee80211_sub_if_data *sdata)
  275. {
  276. struct mesh_path *mpath;
  277. struct hlist_head *bucket;
  278. struct mpath_node *node;
  279. bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
  280. hlist_for_each_entry_rcu(node, bucket, list) {
  281. mpath = node->mpath;
  282. if (ether_addr_equal(dst, mpath->dst)) {
  283. if (mpath_expired(mpath)) {
  284. spin_lock_bh(&mpath->state_lock);
  285. mpath->flags &= ~MESH_PATH_ACTIVE;
  286. spin_unlock_bh(&mpath->state_lock);
  287. }
  288. return mpath;
  289. }
  290. }
  291. return NULL;
  292. }
  293. /**
  294. * mesh_path_lookup - look up a path in the mesh path table
  295. * @sdata: local subif
  296. * @dst: hardware address (ETH_ALEN length) of destination
  297. *
  298. * Returns: pointer to the mesh path structure, or NULL if not found
  299. *
  300. * Locking: must be called within a read rcu section.
  301. */
  302. struct mesh_path *
  303. mesh_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst)
  304. {
  305. return mpath_lookup(rcu_dereference(sdata->u.mesh.mesh_paths), dst,
  306. sdata);
  307. }
  308. struct mesh_path *
  309. mpp_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst)
  310. {
  311. return mpath_lookup(rcu_dereference(sdata->u.mesh.mpp_paths), dst,
  312. sdata);
  313. }
  314. /**
  315. * mesh_path_lookup_by_idx - look up a path in the mesh path table by its index
  316. * @idx: index
  317. * @sdata: local subif, or NULL for all entries
  318. *
  319. * Returns: pointer to the mesh path structure, or NULL if not found.
  320. *
  321. * Locking: must be called within a read rcu section.
  322. */
  323. struct mesh_path *
  324. mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx)
  325. {
  326. struct mesh_table *tbl = rcu_dereference(sdata->u.mesh.mesh_paths);
  327. struct mpath_node *node;
  328. int i;
  329. int j = 0;
  330. for_each_mesh_entry(tbl, node, i) {
  331. if (j++ == idx) {
  332. if (mpath_expired(node->mpath)) {
  333. spin_lock_bh(&node->mpath->state_lock);
  334. node->mpath->flags &= ~MESH_PATH_ACTIVE;
  335. spin_unlock_bh(&node->mpath->state_lock);
  336. }
  337. return node->mpath;
  338. }
  339. }
  340. return NULL;
  341. }
  342. /**
  343. * mpp_path_lookup_by_idx - look up a path in the proxy path table by its index
  344. * @idx: index
  345. * @sdata: local subif, or NULL for all entries
  346. *
  347. * Returns: pointer to the proxy path structure, or NULL if not found.
  348. *
  349. * Locking: must be called within a read rcu section.
  350. */
  351. struct mesh_path *
  352. mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx)
  353. {
  354. struct mesh_table *tbl = rcu_dereference(sdata->u.mesh.mpp_paths);
  355. struct mpath_node *node;
  356. int i;
  357. int j = 0;
  358. for_each_mesh_entry(tbl, node, i) {
  359. if (j++ == idx)
  360. return node->mpath;
  361. }
  362. return NULL;
  363. }
  364. /**
  365. * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
  366. * @mpath: gate path to add to table
  367. */
  368. int mesh_path_add_gate(struct mesh_path *mpath)
  369. {
  370. struct mesh_table *tbl;
  371. struct mpath_node *gate, *new_gate;
  372. int err;
  373. rcu_read_lock();
  374. tbl = rcu_dereference(mpath->sdata->u.mesh.mesh_paths);
  375. hlist_for_each_entry_rcu(gate, tbl->known_gates, list)
  376. if (gate->mpath == mpath) {
  377. err = -EEXIST;
  378. goto err_rcu;
  379. }
  380. new_gate = kzalloc(sizeof(struct mpath_node), GFP_ATOMIC);
  381. if (!new_gate) {
  382. err = -ENOMEM;
  383. goto err_rcu;
  384. }
  385. mpath->is_gate = true;
  386. mpath->sdata->u.mesh.num_gates++;
  387. new_gate->mpath = mpath;
  388. spin_lock_bh(&tbl->gates_lock);
  389. hlist_add_head_rcu(&new_gate->list, tbl->known_gates);
  390. spin_unlock_bh(&tbl->gates_lock);
  391. mpath_dbg(mpath->sdata,
  392. "Mesh path: Recorded new gate: %pM. %d known gates\n",
  393. mpath->dst, mpath->sdata->u.mesh.num_gates);
  394. err = 0;
  395. err_rcu:
  396. rcu_read_unlock();
  397. return err;
  398. }
  399. /**
  400. * mesh_gate_del - remove a mesh gate from the list of known gates
  401. * @tbl: table which holds our list of known gates
  402. * @mpath: gate mpath
  403. *
  404. * Locking: must be called inside rcu_read_lock() section
  405. */
  406. static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
  407. {
  408. struct mpath_node *gate;
  409. struct hlist_node *q;
  410. hlist_for_each_entry_safe(gate, q, tbl->known_gates, list) {
  411. if (gate->mpath != mpath)
  412. continue;
  413. spin_lock_bh(&tbl->gates_lock);
  414. hlist_del_rcu(&gate->list);
  415. kfree_rcu(gate, rcu);
  416. spin_unlock_bh(&tbl->gates_lock);
  417. mpath->sdata->u.mesh.num_gates--;
  418. mpath->is_gate = false;
  419. mpath_dbg(mpath->sdata,
  420. "Mesh path: Deleted gate: %pM. %d known gates\n",
  421. mpath->dst, mpath->sdata->u.mesh.num_gates);
  422. break;
  423. }
  424. }
  425. /**
  426. * mesh_gate_num - number of gates known to this interface
  427. * @sdata: subif data
  428. */
  429. int mesh_gate_num(struct ieee80211_sub_if_data *sdata)
  430. {
  431. return sdata->u.mesh.num_gates;
  432. }
  433. /**
  434. * mesh_path_add - allocate and add a new path to the mesh path table
  435. * @dst: destination address of the path (ETH_ALEN length)
  436. * @sdata: local subif
  437. *
  438. * Returns: 0 on success
  439. *
  440. * State: the initial state of the new path is set to 0
  441. */
  442. struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
  443. const u8 *dst)
  444. {
  445. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  446. struct ieee80211_local *local = sdata->local;
  447. struct mesh_table *tbl;
  448. struct mesh_path *mpath, *new_mpath;
  449. struct mpath_node *node, *new_node;
  450. struct hlist_head *bucket;
  451. int grow = 0;
  452. int err;
  453. u32 hash_idx;
  454. if (ether_addr_equal(dst, sdata->vif.addr))
  455. /* never add ourselves as neighbours */
  456. return ERR_PTR(-ENOTSUPP);
  457. if (is_multicast_ether_addr(dst))
  458. return ERR_PTR(-ENOTSUPP);
  459. if (atomic_add_unless(&sdata->u.mesh.mpaths, 1, MESH_MAX_MPATHS) == 0)
  460. return ERR_PTR(-ENOSPC);
  461. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  462. tbl = resize_dereference_mesh_paths(sdata);
  463. hash_idx = mesh_table_hash(dst, sdata, tbl);
  464. bucket = &tbl->hash_buckets[hash_idx];
  465. spin_lock(&tbl->hashwlock[hash_idx]);
  466. hlist_for_each_entry(node, bucket, list) {
  467. mpath = node->mpath;
  468. if (ether_addr_equal(dst, mpath->dst))
  469. goto found;
  470. }
  471. err = -ENOMEM;
  472. new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC);
  473. if (!new_mpath)
  474. goto err_path_alloc;
  475. new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC);
  476. if (!new_node)
  477. goto err_node_alloc;
  478. memcpy(new_mpath->dst, dst, ETH_ALEN);
  479. eth_broadcast_addr(new_mpath->rann_snd_addr);
  480. new_mpath->is_root = false;
  481. new_mpath->sdata = sdata;
  482. new_mpath->flags = 0;
  483. skb_queue_head_init(&new_mpath->frame_queue);
  484. new_node->mpath = new_mpath;
  485. new_mpath->timer.data = (unsigned long) new_mpath;
  486. new_mpath->timer.function = mesh_path_timer;
  487. new_mpath->exp_time = jiffies;
  488. spin_lock_init(&new_mpath->state_lock);
  489. init_timer(&new_mpath->timer);
  490. hlist_add_head_rcu(&new_node->list, bucket);
  491. if (atomic_inc_return(&tbl->entries) >=
  492. MEAN_CHAIN_LEN * (tbl->hash_mask + 1))
  493. grow = 1;
  494. sdata->u.mesh.mesh_paths_generation++;
  495. if (grow) {
  496. set_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags);
  497. ieee80211_queue_work(&local->hw, &sdata->work);
  498. }
  499. mpath = new_mpath;
  500. found:
  501. spin_unlock(&tbl->hashwlock[hash_idx]);
  502. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  503. return mpath;
  504. err_node_alloc:
  505. kfree(new_mpath);
  506. err_path_alloc:
  507. atomic_dec(&sdata->u.mesh.mpaths);
  508. spin_unlock(&tbl->hashwlock[hash_idx]);
  509. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  510. return ERR_PTR(err);
  511. }
  512. static void mesh_table_free_rcu(struct rcu_head *rcu)
  513. {
  514. struct mesh_table *tbl = container_of(rcu, struct mesh_table, rcu_head);
  515. mesh_table_free(tbl, false);
  516. }
  517. void mesh_mpath_table_grow(struct ieee80211_sub_if_data *sdata)
  518. {
  519. struct mesh_table *oldtbl, *newtbl;
  520. write_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  521. oldtbl = resize_dereference_mesh_paths(sdata);
  522. newtbl = mesh_table_alloc(oldtbl->size_order + 1);
  523. if (!newtbl)
  524. goto out;
  525. if (mesh_table_grow(oldtbl, newtbl) < 0) {
  526. __mesh_table_free(newtbl);
  527. goto out;
  528. }
  529. rcu_assign_pointer(sdata->u.mesh.mesh_paths, newtbl);
  530. call_rcu(&oldtbl->rcu_head, mesh_table_free_rcu);
  531. out:
  532. write_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  533. }
  534. void mesh_mpp_table_grow(struct ieee80211_sub_if_data *sdata)
  535. {
  536. struct mesh_table *oldtbl, *newtbl;
  537. write_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  538. oldtbl = resize_dereference_mpp_paths(sdata);
  539. newtbl = mesh_table_alloc(oldtbl->size_order + 1);
  540. if (!newtbl)
  541. goto out;
  542. if (mesh_table_grow(oldtbl, newtbl) < 0) {
  543. __mesh_table_free(newtbl);
  544. goto out;
  545. }
  546. rcu_assign_pointer(sdata->u.mesh.mpp_paths, newtbl);
  547. call_rcu(&oldtbl->rcu_head, mesh_table_free_rcu);
  548. out:
  549. write_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  550. }
  551. int mpp_path_add(struct ieee80211_sub_if_data *sdata,
  552. const u8 *dst, const u8 *mpp)
  553. {
  554. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  555. struct ieee80211_local *local = sdata->local;
  556. struct mesh_table *tbl;
  557. struct mesh_path *mpath, *new_mpath;
  558. struct mpath_node *node, *new_node;
  559. struct hlist_head *bucket;
  560. int grow = 0;
  561. int err = 0;
  562. u32 hash_idx;
  563. if (ether_addr_equal(dst, sdata->vif.addr))
  564. /* never add ourselves as neighbours */
  565. return -ENOTSUPP;
  566. if (is_multicast_ether_addr(dst))
  567. return -ENOTSUPP;
  568. err = -ENOMEM;
  569. new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC);
  570. if (!new_mpath)
  571. goto err_path_alloc;
  572. new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC);
  573. if (!new_node)
  574. goto err_node_alloc;
  575. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  576. memcpy(new_mpath->dst, dst, ETH_ALEN);
  577. memcpy(new_mpath->mpp, mpp, ETH_ALEN);
  578. new_mpath->sdata = sdata;
  579. new_mpath->flags = 0;
  580. skb_queue_head_init(&new_mpath->frame_queue);
  581. new_node->mpath = new_mpath;
  582. init_timer(&new_mpath->timer);
  583. new_mpath->exp_time = jiffies;
  584. spin_lock_init(&new_mpath->state_lock);
  585. tbl = resize_dereference_mpp_paths(sdata);
  586. hash_idx = mesh_table_hash(dst, sdata, tbl);
  587. bucket = &tbl->hash_buckets[hash_idx];
  588. spin_lock(&tbl->hashwlock[hash_idx]);
  589. err = -EEXIST;
  590. hlist_for_each_entry(node, bucket, list) {
  591. mpath = node->mpath;
  592. if (ether_addr_equal(dst, mpath->dst))
  593. goto err_exists;
  594. }
  595. hlist_add_head_rcu(&new_node->list, bucket);
  596. if (atomic_inc_return(&tbl->entries) >=
  597. MEAN_CHAIN_LEN * (tbl->hash_mask + 1))
  598. grow = 1;
  599. spin_unlock(&tbl->hashwlock[hash_idx]);
  600. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  601. sdata->u.mesh.mpp_paths_generation++;
  602. if (grow) {
  603. set_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags);
  604. ieee80211_queue_work(&local->hw, &sdata->work);
  605. }
  606. return 0;
  607. err_exists:
  608. spin_unlock(&tbl->hashwlock[hash_idx]);
  609. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  610. kfree(new_node);
  611. err_node_alloc:
  612. kfree(new_mpath);
  613. err_path_alloc:
  614. return err;
  615. }
  616. /**
  617. * mesh_plink_broken - deactivates paths and sends perr when a link breaks
  618. *
  619. * @sta: broken peer link
  620. *
  621. * This function must be called from the rate control algorithm if enough
  622. * delivery errors suggest that a peer link is no longer usable.
  623. */
  624. void mesh_plink_broken(struct sta_info *sta)
  625. {
  626. struct mesh_table *tbl;
  627. static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  628. struct mesh_path *mpath;
  629. struct mpath_node *node;
  630. struct ieee80211_sub_if_data *sdata = sta->sdata;
  631. int i;
  632. rcu_read_lock();
  633. tbl = rcu_dereference(sdata->u.mesh.mesh_paths);
  634. for_each_mesh_entry(tbl, node, i) {
  635. mpath = node->mpath;
  636. if (rcu_access_pointer(mpath->next_hop) == sta &&
  637. mpath->flags & MESH_PATH_ACTIVE &&
  638. !(mpath->flags & MESH_PATH_FIXED)) {
  639. spin_lock_bh(&mpath->state_lock);
  640. mpath->flags &= ~MESH_PATH_ACTIVE;
  641. ++mpath->sn;
  642. spin_unlock_bh(&mpath->state_lock);
  643. mesh_path_error_tx(sdata,
  644. sdata->u.mesh.mshcfg.element_ttl,
  645. mpath->dst, mpath->sn,
  646. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE, bcast);
  647. }
  648. }
  649. rcu_read_unlock();
  650. }
  651. static void mesh_path_node_reclaim(struct rcu_head *rp)
  652. {
  653. struct mpath_node *node = container_of(rp, struct mpath_node, rcu);
  654. del_timer_sync(&node->mpath->timer);
  655. kfree(node->mpath);
  656. kfree(node);
  657. }
  658. /* needs to be called with the corresponding hashwlock taken */
  659. static void __mesh_path_del(struct mesh_table *tbl, struct mpath_node *node)
  660. {
  661. struct mesh_path *mpath = node->mpath;
  662. struct ieee80211_sub_if_data *sdata = node->mpath->sdata;
  663. spin_lock(&mpath->state_lock);
  664. mpath->flags |= MESH_PATH_RESOLVING;
  665. if (mpath->is_gate)
  666. mesh_gate_del(tbl, mpath);
  667. hlist_del_rcu(&node->list);
  668. call_rcu(&node->rcu, mesh_path_node_reclaim);
  669. spin_unlock(&mpath->state_lock);
  670. atomic_dec(&sdata->u.mesh.mpaths);
  671. atomic_dec(&tbl->entries);
  672. }
  673. /**
  674. * mesh_path_flush_by_nexthop - Deletes mesh paths if their next hop matches
  675. *
  676. * @sta: mesh peer to match
  677. *
  678. * RCU notes: this function is called when a mesh plink transitions from
  679. * PLINK_ESTAB to any other state, since PLINK_ESTAB state is the only one that
  680. * allows path creation. This will happen before the sta can be freed (because
  681. * sta_info_destroy() calls this) so any reader in a rcu read block will be
  682. * protected against the plink disappearing.
  683. */
  684. void mesh_path_flush_by_nexthop(struct sta_info *sta)
  685. {
  686. struct ieee80211_sub_if_data *sdata = sta->sdata;
  687. struct mesh_table *tbl;
  688. struct mesh_path *mpath;
  689. struct mpath_node *node;
  690. int i;
  691. rcu_read_lock();
  692. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  693. tbl = resize_dereference_mesh_paths(sdata);
  694. for_each_mesh_entry(tbl, node, i) {
  695. mpath = node->mpath;
  696. if (rcu_access_pointer(mpath->next_hop) == sta) {
  697. spin_lock(&tbl->hashwlock[i]);
  698. __mesh_path_del(tbl, node);
  699. spin_unlock(&tbl->hashwlock[i]);
  700. }
  701. }
  702. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  703. rcu_read_unlock();
  704. }
  705. static void mpp_flush_by_proxy(struct ieee80211_sub_if_data *sdata,
  706. const u8 *proxy)
  707. {
  708. struct mesh_table *tbl;
  709. struct mesh_path *mpp;
  710. struct mpath_node *node;
  711. int i;
  712. rcu_read_lock();
  713. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  714. tbl = resize_dereference_mpp_paths(sdata);
  715. for_each_mesh_entry(tbl, node, i) {
  716. mpp = node->mpath;
  717. if (ether_addr_equal(mpp->mpp, proxy)) {
  718. spin_lock(&tbl->hashwlock[i]);
  719. __mesh_path_del(tbl, node);
  720. spin_unlock(&tbl->hashwlock[i]);
  721. }
  722. }
  723. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  724. rcu_read_unlock();
  725. }
  726. static void table_flush_by_iface(struct mesh_table *tbl,
  727. struct ieee80211_sub_if_data *sdata)
  728. {
  729. struct mesh_path *mpath;
  730. struct mpath_node *node;
  731. int i;
  732. WARN_ON(!rcu_read_lock_held());
  733. for_each_mesh_entry(tbl, node, i) {
  734. mpath = node->mpath;
  735. spin_lock_bh(&tbl->hashwlock[i]);
  736. __mesh_path_del(tbl, node);
  737. spin_unlock_bh(&tbl->hashwlock[i]);
  738. }
  739. }
  740. /**
  741. * mesh_path_flush_by_iface - Deletes all mesh paths associated with a given iface
  742. *
  743. * This function deletes both mesh paths as well as mesh portal paths.
  744. *
  745. * @sdata: interface data to match
  746. *
  747. */
  748. void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
  749. {
  750. struct mesh_table *tbl;
  751. rcu_read_lock();
  752. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  753. tbl = resize_dereference_mesh_paths(sdata);
  754. table_flush_by_iface(tbl, sdata);
  755. tbl = resize_dereference_mpp_paths(sdata);
  756. table_flush_by_iface(tbl, sdata);
  757. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  758. rcu_read_unlock();
  759. }
  760. /**
  761. * table_path_del - delete a path from the mesh or mpp table
  762. *
  763. * @tbl: mesh or mpp path table
  764. * @sdata: local subif
  765. * @addr: dst address (ETH_ALEN length)
  766. *
  767. * Returns: 0 if successful
  768. */
  769. static int table_path_del(struct mesh_table __rcu *rcu_tbl,
  770. struct ieee80211_sub_if_data *sdata,
  771. const u8 *addr)
  772. {
  773. struct mesh_table *tbl;
  774. struct mesh_path *mpath;
  775. struct mpath_node *node;
  776. struct hlist_head *bucket;
  777. int hash_idx;
  778. int err = 0;
  779. tbl = resize_dereference_paths(sdata, rcu_tbl);
  780. hash_idx = mesh_table_hash(addr, sdata, tbl);
  781. bucket = &tbl->hash_buckets[hash_idx];
  782. spin_lock(&tbl->hashwlock[hash_idx]);
  783. hlist_for_each_entry(node, bucket, list) {
  784. mpath = node->mpath;
  785. if (ether_addr_equal(addr, mpath->dst)) {
  786. __mesh_path_del(tbl, node);
  787. goto enddel;
  788. }
  789. }
  790. err = -ENXIO;
  791. enddel:
  792. spin_unlock(&tbl->hashwlock[hash_idx]);
  793. return err;
  794. }
  795. /**
  796. * mesh_path_del - delete a mesh path from the table
  797. *
  798. * @addr: dst address (ETH_ALEN length)
  799. * @sdata: local subif
  800. *
  801. * Returns: 0 if successful
  802. */
  803. int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
  804. {
  805. int err = 0;
  806. /* flush relevant mpp entries first */
  807. mpp_flush_by_proxy(sdata, addr);
  808. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  809. err = table_path_del(sdata->u.mesh.mesh_paths, sdata, addr);
  810. sdata->u.mesh.mesh_paths_generation++;
  811. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  812. return err;
  813. }
  814. /**
  815. * mpp_path_del - delete a mesh proxy path from the table
  816. *
  817. * @addr: addr address (ETH_ALEN length)
  818. * @sdata: local subif
  819. *
  820. * Returns: 0 if successful
  821. */
  822. static int mpp_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
  823. {
  824. int err = 0;
  825. read_lock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  826. err = table_path_del(sdata->u.mesh.mpp_paths, sdata, addr);
  827. sdata->u.mesh.mpp_paths_generation++;
  828. read_unlock_bh(&sdata->u.mesh.pathtbl_resize_lock);
  829. return err;
  830. }
  831. /**
  832. * mesh_path_tx_pending - sends pending frames in a mesh path queue
  833. *
  834. * @mpath: mesh path to activate
  835. *
  836. * Locking: the state_lock of the mpath structure must NOT be held when calling
  837. * this function.
  838. */
  839. void mesh_path_tx_pending(struct mesh_path *mpath)
  840. {
  841. if (mpath->flags & MESH_PATH_ACTIVE)
  842. ieee80211_add_pending_skbs(mpath->sdata->local,
  843. &mpath->frame_queue);
  844. }
  845. /**
  846. * mesh_path_send_to_gates - sends pending frames to all known mesh gates
  847. *
  848. * @mpath: mesh path whose queue will be emptied
  849. *
  850. * If there is only one gate, the frames are transferred from the failed mpath
  851. * queue to that gate's queue. If there are more than one gates, the frames
  852. * are copied from each gate to the next. After frames are copied, the
  853. * mpath queues are emptied onto the transmission queue.
  854. */
  855. int mesh_path_send_to_gates(struct mesh_path *mpath)
  856. {
  857. struct ieee80211_sub_if_data *sdata = mpath->sdata;
  858. struct mesh_table *tbl;
  859. struct mesh_path *from_mpath = mpath;
  860. struct mpath_node *gate = NULL;
  861. bool copy = false;
  862. struct hlist_head *known_gates;
  863. rcu_read_lock();
  864. tbl = rcu_dereference(sdata->u.mesh.mesh_paths);
  865. known_gates = tbl->known_gates;
  866. rcu_read_unlock();
  867. if (!known_gates)
  868. return -EHOSTUNREACH;
  869. hlist_for_each_entry_rcu(gate, known_gates, list) {
  870. if (gate->mpath->flags & MESH_PATH_ACTIVE) {
  871. mpath_dbg(sdata, "Forwarding to %pM\n", gate->mpath->dst);
  872. mesh_path_move_to_queue(gate->mpath, from_mpath, copy);
  873. from_mpath = gate->mpath;
  874. copy = true;
  875. } else {
  876. mpath_dbg(sdata,
  877. "Not forwarding to %pM (flags %#x)\n",
  878. gate->mpath->dst, gate->mpath->flags);
  879. }
  880. }
  881. hlist_for_each_entry_rcu(gate, known_gates, list) {
  882. mpath_dbg(sdata, "Sending to %pM\n", gate->mpath->dst);
  883. mesh_path_tx_pending(gate->mpath);
  884. }
  885. return (from_mpath == mpath) ? -EHOSTUNREACH : 0;
  886. }
  887. /**
  888. * mesh_path_discard_frame - discard a frame whose path could not be resolved
  889. *
  890. * @skb: frame to discard
  891. * @sdata: network subif the frame was to be sent through
  892. *
  893. * Locking: the function must me called within a rcu_read_lock region
  894. */
  895. void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
  896. struct sk_buff *skb)
  897. {
  898. kfree_skb(skb);
  899. sdata->u.mesh.mshstats.dropped_frames_no_route++;
  900. }
  901. /**
  902. * mesh_path_flush_pending - free the pending queue of a mesh path
  903. *
  904. * @mpath: mesh path whose queue has to be freed
  905. *
  906. * Locking: the function must me called within a rcu_read_lock region
  907. */
  908. void mesh_path_flush_pending(struct mesh_path *mpath)
  909. {
  910. struct sk_buff *skb;
  911. while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL)
  912. mesh_path_discard_frame(mpath->sdata, skb);
  913. }
  914. /**
  915. * mesh_path_fix_nexthop - force a specific next hop for a mesh path
  916. *
  917. * @mpath: the mesh path to modify
  918. * @next_hop: the next hop to force
  919. *
  920. * Locking: this function must be called holding mpath->state_lock
  921. */
  922. void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop)
  923. {
  924. spin_lock_bh(&mpath->state_lock);
  925. mesh_path_assign_nexthop(mpath, next_hop);
  926. mpath->sn = 0xffff;
  927. mpath->metric = 0;
  928. mpath->hop_count = 0;
  929. mpath->exp_time = 0;
  930. mpath->flags |= MESH_PATH_FIXED;
  931. mesh_path_activate(mpath);
  932. spin_unlock_bh(&mpath->state_lock);
  933. mesh_path_tx_pending(mpath);
  934. }
  935. static void mesh_path_node_free(struct hlist_node *p, bool free_leafs)
  936. {
  937. struct mesh_path *mpath;
  938. struct mpath_node *node = hlist_entry(p, struct mpath_node, list);
  939. mpath = node->mpath;
  940. hlist_del_rcu(p);
  941. if (free_leafs) {
  942. del_timer_sync(&mpath->timer);
  943. kfree(mpath);
  944. }
  945. kfree(node);
  946. }
  947. static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
  948. {
  949. struct mesh_path *mpath;
  950. struct mpath_node *node, *new_node;
  951. u32 hash_idx;
  952. new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC);
  953. if (new_node == NULL)
  954. return -ENOMEM;
  955. node = hlist_entry(p, struct mpath_node, list);
  956. mpath = node->mpath;
  957. new_node->mpath = mpath;
  958. hash_idx = mesh_table_hash(mpath->dst, mpath->sdata, newtbl);
  959. hlist_add_head(&new_node->list,
  960. &newtbl->hash_buckets[hash_idx]);
  961. return 0;
  962. }
  963. int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata)
  964. {
  965. struct mesh_table *tbl_path, *tbl_mpp;
  966. int ret;
  967. tbl_path = mesh_table_alloc(INIT_PATHS_SIZE_ORDER);
  968. if (!tbl_path)
  969. return -ENOMEM;
  970. tbl_path->free_node = &mesh_path_node_free;
  971. tbl_path->copy_node = &mesh_path_node_copy;
  972. tbl_path->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC);
  973. if (!tbl_path->known_gates) {
  974. ret = -ENOMEM;
  975. goto free_path;
  976. }
  977. INIT_HLIST_HEAD(tbl_path->known_gates);
  978. tbl_mpp = mesh_table_alloc(INIT_PATHS_SIZE_ORDER);
  979. if (!tbl_mpp) {
  980. ret = -ENOMEM;
  981. goto free_path;
  982. }
  983. tbl_mpp->free_node = &mesh_path_node_free;
  984. tbl_mpp->copy_node = &mesh_path_node_copy;
  985. tbl_mpp->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC);
  986. if (!tbl_mpp->known_gates) {
  987. ret = -ENOMEM;
  988. goto free_mpp;
  989. }
  990. INIT_HLIST_HEAD(tbl_mpp->known_gates);
  991. rwlock_init(&sdata->u.mesh.pathtbl_resize_lock);
  992. /* Need no locking since this is during init */
  993. RCU_INIT_POINTER(sdata->u.mesh.mesh_paths, tbl_path);
  994. RCU_INIT_POINTER(sdata->u.mesh.mpp_paths, tbl_mpp);
  995. return 0;
  996. free_mpp:
  997. mesh_table_free(tbl_mpp, true);
  998. free_path:
  999. mesh_table_free(tbl_path, true);
  1000. return ret;
  1001. }
  1002. void mesh_path_expire(struct ieee80211_sub_if_data *sdata)
  1003. {
  1004. struct mesh_table *tbl;
  1005. struct mesh_path *mpath;
  1006. struct mpath_node *node;
  1007. int i;
  1008. rcu_read_lock();
  1009. tbl = rcu_dereference(sdata->u.mesh.mesh_paths);
  1010. for_each_mesh_entry(tbl, node, i) {
  1011. mpath = node->mpath;
  1012. if ((!(mpath->flags & MESH_PATH_RESOLVING)) &&
  1013. (!(mpath->flags & MESH_PATH_FIXED)) &&
  1014. time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
  1015. mesh_path_del(sdata, mpath->dst);
  1016. }
  1017. tbl = rcu_dereference(sdata->u.mesh.mpp_paths);
  1018. for_each_mesh_entry(tbl, node, i) {
  1019. mpath = node->mpath;
  1020. if ((!(mpath->flags & MESH_PATH_FIXED)) &&
  1021. time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
  1022. mpp_path_del(sdata, mpath->dst);
  1023. }
  1024. rcu_read_unlock();
  1025. }
  1026. void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata)
  1027. {
  1028. /* no need for locking during exit path */
  1029. mesh_table_free(rcu_dereference_protected(sdata->u.mesh.mesh_paths, 1),
  1030. true);
  1031. mesh_table_free(rcu_dereference_protected(sdata->u.mesh.mpp_paths, 1),
  1032. true);
  1033. }