mesh_hwmp.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  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/slab.h>
  10. #include "wme.h"
  11. #include "mesh.h"
  12. #ifdef CONFIG_MAC80211_VERBOSE_MHWMP_DEBUG
  13. #define mhwmp_dbg(fmt, args...) \
  14. printk(KERN_DEBUG "Mesh HWMP (%s): " fmt "\n", sdata->name, ##args)
  15. #else
  16. #define mhwmp_dbg(fmt, args...) do { (void)(0); } while (0)
  17. #endif
  18. #define TEST_FRAME_LEN 8192
  19. #define MAX_METRIC 0xffffffff
  20. #define ARITH_SHIFT 8
  21. /* Number of frames buffered per destination for unresolved destinations */
  22. #define MESH_FRAME_QUEUE_LEN 10
  23. #define MAX_PREQ_QUEUE_LEN 64
  24. /* Destination only */
  25. #define MP_F_DO 0x1
  26. /* Reply and forward */
  27. #define MP_F_RF 0x2
  28. /* Unknown Sequence Number */
  29. #define MP_F_USN 0x01
  30. /* Reason code Present */
  31. #define MP_F_RCODE 0x02
  32. static void mesh_queue_preq(struct mesh_path *, u8);
  33. static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae)
  34. {
  35. if (ae)
  36. offset += 6;
  37. return get_unaligned_le32(preq_elem + offset);
  38. }
  39. static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae)
  40. {
  41. if (ae)
  42. offset += 6;
  43. return get_unaligned_le16(preq_elem + offset);
  44. }
  45. /* HWMP IE processing macros */
  46. #define AE_F (1<<6)
  47. #define AE_F_SET(x) (*x & AE_F)
  48. #define PREQ_IE_FLAGS(x) (*(x))
  49. #define PREQ_IE_HOPCOUNT(x) (*(x + 1))
  50. #define PREQ_IE_TTL(x) (*(x + 2))
  51. #define PREQ_IE_PREQ_ID(x) u32_field_get(x, 3, 0)
  52. #define PREQ_IE_ORIG_ADDR(x) (x + 7)
  53. #define PREQ_IE_ORIG_SN(x) u32_field_get(x, 13, 0)
  54. #define PREQ_IE_LIFETIME(x) u32_field_get(x, 17, AE_F_SET(x))
  55. #define PREQ_IE_METRIC(x) u32_field_get(x, 21, AE_F_SET(x))
  56. #define PREQ_IE_TARGET_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26))
  57. #define PREQ_IE_TARGET_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27)
  58. #define PREQ_IE_TARGET_SN(x) u32_field_get(x, 33, AE_F_SET(x))
  59. #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x)
  60. #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x)
  61. #define PREP_IE_TTL(x) PREQ_IE_TTL(x)
  62. #define PREP_IE_ORIG_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21)
  63. #define PREP_IE_ORIG_SN(x) u32_field_get(x, 27, AE_F_SET(x))
  64. #define PREP_IE_LIFETIME(x) u32_field_get(x, 13, AE_F_SET(x))
  65. #define PREP_IE_METRIC(x) u32_field_get(x, 17, AE_F_SET(x))
  66. #define PREP_IE_TARGET_ADDR(x) (x + 3)
  67. #define PREP_IE_TARGET_SN(x) u32_field_get(x, 9, 0)
  68. #define PERR_IE_TTL(x) (*(x))
  69. #define PERR_IE_TARGET_FLAGS(x) (*(x + 2))
  70. #define PERR_IE_TARGET_ADDR(x) (x + 3)
  71. #define PERR_IE_TARGET_SN(x) u32_field_get(x, 9, 0)
  72. #define PERR_IE_TARGET_RCODE(x) u16_field_get(x, 13, 0)
  73. #define MSEC_TO_TU(x) (x*1000/1024)
  74. #define SN_GT(x, y) ((long) (y) - (long) (x) < 0)
  75. #define SN_LT(x, y) ((long) (x) - (long) (y) < 0)
  76. #define net_traversal_jiffies(s) \
  77. msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime)
  78. #define default_lifetime(s) \
  79. MSEC_TO_TU(s->u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout)
  80. #define min_preq_int_jiff(s) \
  81. (msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval))
  82. #define max_preq_retries(s) (s->u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries)
  83. #define disc_timeout_jiff(s) \
  84. msecs_to_jiffies(sdata->u.mesh.mshcfg.min_discovery_timeout)
  85. enum mpath_frame_type {
  86. MPATH_PREQ = 0,
  87. MPATH_PREP,
  88. MPATH_PERR,
  89. MPATH_RANN
  90. };
  91. static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  92. static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
  93. u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target,
  94. __le32 target_sn, const u8 *da, u8 hop_count, u8 ttl,
  95. __le32 lifetime, __le32 metric, __le32 preq_id,
  96. struct ieee80211_sub_if_data *sdata)
  97. {
  98. struct ieee80211_local *local = sdata->local;
  99. struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
  100. struct ieee80211_mgmt *mgmt;
  101. u8 *pos;
  102. int ie_len;
  103. if (!skb)
  104. return -1;
  105. skb_reserve(skb, local->hw.extra_tx_headroom);
  106. /* 25 is the size of the common mgmt part (24) plus the size of the
  107. * common action part (1)
  108. */
  109. mgmt = (struct ieee80211_mgmt *)
  110. skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
  111. memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
  112. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  113. IEEE80211_STYPE_ACTION);
  114. memcpy(mgmt->da, da, ETH_ALEN);
  115. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  116. /* BSSID == SA */
  117. memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
  118. mgmt->u.action.category = WLAN_CATEGORY_MESH_ACTION;
  119. mgmt->u.action.u.mesh_action.action_code =
  120. WLAN_MESH_ACTION_HWMP_PATH_SELECTION;
  121. switch (action) {
  122. case MPATH_PREQ:
  123. mhwmp_dbg("sending PREQ to %pM", target);
  124. ie_len = 37;
  125. pos = skb_put(skb, 2 + ie_len);
  126. *pos++ = WLAN_EID_PREQ;
  127. break;
  128. case MPATH_PREP:
  129. mhwmp_dbg("sending PREP to %pM", target);
  130. ie_len = 31;
  131. pos = skb_put(skb, 2 + ie_len);
  132. *pos++ = WLAN_EID_PREP;
  133. break;
  134. case MPATH_RANN:
  135. mhwmp_dbg("sending RANN from %pM", orig_addr);
  136. ie_len = sizeof(struct ieee80211_rann_ie);
  137. pos = skb_put(skb, 2 + ie_len);
  138. *pos++ = WLAN_EID_RANN;
  139. break;
  140. default:
  141. kfree_skb(skb);
  142. return -ENOTSUPP;
  143. break;
  144. }
  145. *pos++ = ie_len;
  146. *pos++ = flags;
  147. *pos++ = hop_count;
  148. *pos++ = ttl;
  149. if (action == MPATH_PREP) {
  150. memcpy(pos, target, ETH_ALEN);
  151. pos += ETH_ALEN;
  152. memcpy(pos, &target_sn, 4);
  153. pos += 4;
  154. } else {
  155. if (action == MPATH_PREQ) {
  156. memcpy(pos, &preq_id, 4);
  157. pos += 4;
  158. }
  159. memcpy(pos, orig_addr, ETH_ALEN);
  160. pos += ETH_ALEN;
  161. memcpy(pos, &orig_sn, 4);
  162. pos += 4;
  163. }
  164. memcpy(pos, &lifetime, 4); /* interval for RANN */
  165. pos += 4;
  166. memcpy(pos, &metric, 4);
  167. pos += 4;
  168. if (action == MPATH_PREQ) {
  169. *pos++ = 1; /* destination count */
  170. *pos++ = target_flags;
  171. memcpy(pos, target, ETH_ALEN);
  172. pos += ETH_ALEN;
  173. memcpy(pos, &target_sn, 4);
  174. pos += 4;
  175. } else if (action == MPATH_PREP) {
  176. memcpy(pos, orig_addr, ETH_ALEN);
  177. pos += ETH_ALEN;
  178. memcpy(pos, &orig_sn, 4);
  179. pos += 4;
  180. }
  181. ieee80211_tx_skb(sdata, skb);
  182. return 0;
  183. }
  184. /* Headroom is not adjusted. Caller should ensure that skb has sufficient
  185. * headroom in case the frame is encrypted. */
  186. static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
  187. struct sk_buff *skb)
  188. {
  189. struct ieee80211_local *local = sdata->local;
  190. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  191. skb_set_mac_header(skb, 0);
  192. skb_set_network_header(skb, 0);
  193. skb_set_transport_header(skb, 0);
  194. /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
  195. skb_set_queue_mapping(skb, IEEE80211_AC_VO);
  196. skb->priority = 7;
  197. info->control.vif = &sdata->vif;
  198. ieee80211_set_qos_hdr(local, skb);
  199. }
  200. /**
  201. * mesh_send_path error - Sends a PERR mesh management frame
  202. *
  203. * @target: broken destination
  204. * @target_sn: SN of the broken destination
  205. * @target_rcode: reason code for this PERR
  206. * @ra: node this frame is addressed to
  207. *
  208. * Note: This function may be called with driver locks taken that the driver
  209. * also acquires in the TX path. To avoid a deadlock we don't transmit the
  210. * frame directly but add it to the pending queue instead.
  211. */
  212. int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
  213. __le16 target_rcode, const u8 *ra,
  214. struct ieee80211_sub_if_data *sdata)
  215. {
  216. struct ieee80211_local *local = sdata->local;
  217. struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
  218. struct ieee80211_mgmt *mgmt;
  219. u8 *pos;
  220. int ie_len;
  221. if (!skb)
  222. return -1;
  223. skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom);
  224. /* 25 is the size of the common mgmt part (24) plus the size of the
  225. * common action part (1)
  226. */
  227. mgmt = (struct ieee80211_mgmt *)
  228. skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
  229. memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
  230. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  231. IEEE80211_STYPE_ACTION);
  232. memcpy(mgmt->da, ra, ETH_ALEN);
  233. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  234. /* BSSID == SA */
  235. memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
  236. mgmt->u.action.category = WLAN_CATEGORY_MESH_ACTION;
  237. mgmt->u.action.u.mesh_action.action_code =
  238. WLAN_MESH_ACTION_HWMP_PATH_SELECTION;
  239. ie_len = 15;
  240. pos = skb_put(skb, 2 + ie_len);
  241. *pos++ = WLAN_EID_PERR;
  242. *pos++ = ie_len;
  243. /* ttl */
  244. *pos++ = ttl;
  245. /* number of destinations */
  246. *pos++ = 1;
  247. /*
  248. * flags bit, bit 1 is unset if we know the sequence number and
  249. * bit 2 is set if we have a reason code
  250. */
  251. *pos = 0;
  252. if (!target_sn)
  253. *pos |= MP_F_USN;
  254. if (target_rcode)
  255. *pos |= MP_F_RCODE;
  256. pos++;
  257. memcpy(pos, target, ETH_ALEN);
  258. pos += ETH_ALEN;
  259. memcpy(pos, &target_sn, 4);
  260. pos += 4;
  261. memcpy(pos, &target_rcode, 2);
  262. /* see note in function header */
  263. prepare_frame_for_deferred_tx(sdata, skb);
  264. ieee80211_add_pending_skb(local, skb);
  265. return 0;
  266. }
  267. void ieee80211s_update_metric(struct ieee80211_local *local,
  268. struct sta_info *stainfo, struct sk_buff *skb)
  269. {
  270. struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
  271. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  272. int failed;
  273. if (!ieee80211_is_data(hdr->frame_control))
  274. return;
  275. failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
  276. /* moving average, scaled to 100 */
  277. stainfo->fail_avg = ((80 * stainfo->fail_avg + 5) / 100 + 20 * failed);
  278. if (stainfo->fail_avg > 95)
  279. mesh_plink_broken(stainfo);
  280. }
  281. static u32 airtime_link_metric_get(struct ieee80211_local *local,
  282. struct sta_info *sta)
  283. {
  284. struct ieee80211_supported_band *sband;
  285. /* This should be adjusted for each device */
  286. int device_constant = 1 << ARITH_SHIFT;
  287. int test_frame_len = TEST_FRAME_LEN << ARITH_SHIFT;
  288. int s_unit = 1 << ARITH_SHIFT;
  289. int rate, err;
  290. u32 tx_time, estimated_retx;
  291. u64 result;
  292. sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
  293. if (sta->fail_avg >= 100)
  294. return MAX_METRIC;
  295. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
  296. return MAX_METRIC;
  297. err = (sta->fail_avg << ARITH_SHIFT) / 100;
  298. /* bitrate is in units of 100 Kbps, while we need rate in units of
  299. * 1Mbps. This will be corrected on tx_time computation.
  300. */
  301. rate = sband->bitrates[sta->last_tx_rate.idx].bitrate;
  302. tx_time = (device_constant + 10 * test_frame_len / rate);
  303. estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
  304. result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
  305. return (u32)result;
  306. }
  307. /**
  308. * hwmp_route_info_get - Update routing info to originator and transmitter
  309. *
  310. * @sdata: local mesh subif
  311. * @mgmt: mesh management frame
  312. * @hwmp_ie: hwmp information element (PREP or PREQ)
  313. *
  314. * This function updates the path routing information to the originator and the
  315. * transmitter of a HWMP PREQ or PREP frame.
  316. *
  317. * Returns: metric to frame originator or 0 if the frame should not be further
  318. * processed
  319. *
  320. * Notes: this function is the only place (besides user-provided info) where
  321. * path routing information is updated.
  322. */
  323. static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
  324. struct ieee80211_mgmt *mgmt,
  325. u8 *hwmp_ie, enum mpath_frame_type action)
  326. {
  327. struct ieee80211_local *local = sdata->local;
  328. struct mesh_path *mpath;
  329. struct sta_info *sta;
  330. bool fresh_info;
  331. u8 *orig_addr, *ta;
  332. u32 orig_sn, orig_metric;
  333. unsigned long orig_lifetime, exp_time;
  334. u32 last_hop_metric, new_metric;
  335. bool process = true;
  336. rcu_read_lock();
  337. sta = sta_info_get(sdata, mgmt->sa);
  338. if (!sta) {
  339. rcu_read_unlock();
  340. return 0;
  341. }
  342. last_hop_metric = airtime_link_metric_get(local, sta);
  343. /* Update and check originator routing info */
  344. fresh_info = true;
  345. switch (action) {
  346. case MPATH_PREQ:
  347. orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie);
  348. orig_sn = PREQ_IE_ORIG_SN(hwmp_ie);
  349. orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie);
  350. orig_metric = PREQ_IE_METRIC(hwmp_ie);
  351. break;
  352. case MPATH_PREP:
  353. /* Originator here refers to the MP that was the destination in
  354. * the Path Request. The draft refers to that MP as the
  355. * destination address, even though usually it is the origin of
  356. * the PREP frame. We divert from the nomenclature in the draft
  357. * so that we can easily use a single function to gather path
  358. * information from both PREQ and PREP frames.
  359. */
  360. orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie);
  361. orig_sn = PREP_IE_ORIG_SN(hwmp_ie);
  362. orig_lifetime = PREP_IE_LIFETIME(hwmp_ie);
  363. orig_metric = PREP_IE_METRIC(hwmp_ie);
  364. break;
  365. default:
  366. rcu_read_unlock();
  367. return 0;
  368. }
  369. new_metric = orig_metric + last_hop_metric;
  370. if (new_metric < orig_metric)
  371. new_metric = MAX_METRIC;
  372. exp_time = TU_TO_EXP_TIME(orig_lifetime);
  373. if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) {
  374. /* This MP is the originator, we are not interested in this
  375. * frame, except for updating transmitter's path info.
  376. */
  377. process = false;
  378. fresh_info = false;
  379. } else {
  380. mpath = mesh_path_lookup(orig_addr, sdata);
  381. if (mpath) {
  382. spin_lock_bh(&mpath->state_lock);
  383. if (mpath->flags & MESH_PATH_FIXED)
  384. fresh_info = false;
  385. else if ((mpath->flags & MESH_PATH_ACTIVE) &&
  386. (mpath->flags & MESH_PATH_SN_VALID)) {
  387. if (SN_GT(mpath->sn, orig_sn) ||
  388. (mpath->sn == orig_sn &&
  389. new_metric >= mpath->metric)) {
  390. process = false;
  391. fresh_info = false;
  392. }
  393. }
  394. } else {
  395. mesh_path_add(orig_addr, sdata);
  396. mpath = mesh_path_lookup(orig_addr, sdata);
  397. if (!mpath) {
  398. rcu_read_unlock();
  399. return 0;
  400. }
  401. spin_lock_bh(&mpath->state_lock);
  402. }
  403. if (fresh_info) {
  404. mesh_path_assign_nexthop(mpath, sta);
  405. mpath->flags |= MESH_PATH_SN_VALID;
  406. mpath->metric = new_metric;
  407. mpath->sn = orig_sn;
  408. mpath->exp_time = time_after(mpath->exp_time, exp_time)
  409. ? mpath->exp_time : exp_time;
  410. mesh_path_activate(mpath);
  411. spin_unlock_bh(&mpath->state_lock);
  412. mesh_path_tx_pending(mpath);
  413. /* draft says preq_id should be saved to, but there does
  414. * not seem to be any use for it, skipping by now
  415. */
  416. } else
  417. spin_unlock_bh(&mpath->state_lock);
  418. }
  419. /* Update and check transmitter routing info */
  420. ta = mgmt->sa;
  421. if (memcmp(orig_addr, ta, ETH_ALEN) == 0)
  422. fresh_info = false;
  423. else {
  424. fresh_info = true;
  425. mpath = mesh_path_lookup(ta, sdata);
  426. if (mpath) {
  427. spin_lock_bh(&mpath->state_lock);
  428. if ((mpath->flags & MESH_PATH_FIXED) ||
  429. ((mpath->flags & MESH_PATH_ACTIVE) &&
  430. (last_hop_metric > mpath->metric)))
  431. fresh_info = false;
  432. } else {
  433. mesh_path_add(ta, sdata);
  434. mpath = mesh_path_lookup(ta, sdata);
  435. if (!mpath) {
  436. rcu_read_unlock();
  437. return 0;
  438. }
  439. spin_lock_bh(&mpath->state_lock);
  440. }
  441. if (fresh_info) {
  442. mesh_path_assign_nexthop(mpath, sta);
  443. mpath->metric = last_hop_metric;
  444. mpath->exp_time = time_after(mpath->exp_time, exp_time)
  445. ? mpath->exp_time : exp_time;
  446. mesh_path_activate(mpath);
  447. spin_unlock_bh(&mpath->state_lock);
  448. mesh_path_tx_pending(mpath);
  449. } else
  450. spin_unlock_bh(&mpath->state_lock);
  451. }
  452. rcu_read_unlock();
  453. return process ? new_metric : 0;
  454. }
  455. static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
  456. struct ieee80211_mgmt *mgmt,
  457. u8 *preq_elem, u32 metric)
  458. {
  459. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  460. struct mesh_path *mpath;
  461. u8 *target_addr, *orig_addr;
  462. u8 target_flags, ttl;
  463. u32 orig_sn, target_sn, lifetime;
  464. bool reply = false;
  465. bool forward = true;
  466. /* Update target SN, if present */
  467. target_addr = PREQ_IE_TARGET_ADDR(preq_elem);
  468. orig_addr = PREQ_IE_ORIG_ADDR(preq_elem);
  469. target_sn = PREQ_IE_TARGET_SN(preq_elem);
  470. orig_sn = PREQ_IE_ORIG_SN(preq_elem);
  471. target_flags = PREQ_IE_TARGET_F(preq_elem);
  472. mhwmp_dbg("received PREQ from %pM", orig_addr);
  473. if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) {
  474. mhwmp_dbg("PREQ is for us");
  475. forward = false;
  476. reply = true;
  477. metric = 0;
  478. if (time_after(jiffies, ifmsh->last_sn_update +
  479. net_traversal_jiffies(sdata)) ||
  480. time_before(jiffies, ifmsh->last_sn_update)) {
  481. target_sn = ++ifmsh->sn;
  482. ifmsh->last_sn_update = jiffies;
  483. }
  484. } else {
  485. rcu_read_lock();
  486. mpath = mesh_path_lookup(target_addr, sdata);
  487. if (mpath) {
  488. if ((!(mpath->flags & MESH_PATH_SN_VALID)) ||
  489. SN_LT(mpath->sn, target_sn)) {
  490. mpath->sn = target_sn;
  491. mpath->flags |= MESH_PATH_SN_VALID;
  492. } else if ((!(target_flags & MP_F_DO)) &&
  493. (mpath->flags & MESH_PATH_ACTIVE)) {
  494. reply = true;
  495. metric = mpath->metric;
  496. target_sn = mpath->sn;
  497. if (target_flags & MP_F_RF)
  498. target_flags |= MP_F_DO;
  499. else
  500. forward = false;
  501. }
  502. }
  503. rcu_read_unlock();
  504. }
  505. if (reply) {
  506. lifetime = PREQ_IE_LIFETIME(preq_elem);
  507. ttl = ifmsh->mshcfg.element_ttl;
  508. if (ttl != 0) {
  509. mhwmp_dbg("replying to the PREQ");
  510. mesh_path_sel_frame_tx(MPATH_PREP, 0, target_addr,
  511. cpu_to_le32(target_sn), 0, orig_addr,
  512. cpu_to_le32(orig_sn), mgmt->sa, 0, ttl,
  513. cpu_to_le32(lifetime), cpu_to_le32(metric),
  514. 0, sdata);
  515. } else
  516. ifmsh->mshstats.dropped_frames_ttl++;
  517. }
  518. if (forward) {
  519. u32 preq_id;
  520. u8 hopcount, flags;
  521. ttl = PREQ_IE_TTL(preq_elem);
  522. lifetime = PREQ_IE_LIFETIME(preq_elem);
  523. if (ttl <= 1) {
  524. ifmsh->mshstats.dropped_frames_ttl++;
  525. return;
  526. }
  527. mhwmp_dbg("forwarding the PREQ from %pM", orig_addr);
  528. --ttl;
  529. flags = PREQ_IE_FLAGS(preq_elem);
  530. preq_id = PREQ_IE_PREQ_ID(preq_elem);
  531. hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1;
  532. mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr,
  533. cpu_to_le32(orig_sn), target_flags, target_addr,
  534. cpu_to_le32(target_sn), broadcast_addr,
  535. hopcount, ttl, cpu_to_le32(lifetime),
  536. cpu_to_le32(metric), cpu_to_le32(preq_id),
  537. sdata);
  538. ifmsh->mshstats.fwded_mcast++;
  539. ifmsh->mshstats.fwded_frames++;
  540. }
  541. }
  542. static inline struct sta_info *
  543. next_hop_deref_protected(struct mesh_path *mpath)
  544. {
  545. return rcu_dereference_protected(mpath->next_hop,
  546. lockdep_is_held(&mpath->state_lock));
  547. }
  548. static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
  549. struct ieee80211_mgmt *mgmt,
  550. u8 *prep_elem, u32 metric)
  551. {
  552. struct mesh_path *mpath;
  553. u8 *target_addr, *orig_addr;
  554. u8 ttl, hopcount, flags;
  555. u8 next_hop[ETH_ALEN];
  556. u32 target_sn, orig_sn, lifetime;
  557. mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem));
  558. /* Note that we divert from the draft nomenclature and denominate
  559. * destination to what the draft refers to as origininator. So in this
  560. * function destnation refers to the final destination of the PREP,
  561. * which corresponds with the originator of the PREQ which this PREP
  562. * replies
  563. */
  564. target_addr = PREP_IE_TARGET_ADDR(prep_elem);
  565. if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0)
  566. /* destination, no forwarding required */
  567. return;
  568. ttl = PREP_IE_TTL(prep_elem);
  569. if (ttl <= 1) {
  570. sdata->u.mesh.mshstats.dropped_frames_ttl++;
  571. return;
  572. }
  573. rcu_read_lock();
  574. mpath = mesh_path_lookup(target_addr, sdata);
  575. if (mpath)
  576. spin_lock_bh(&mpath->state_lock);
  577. else
  578. goto fail;
  579. if (!(mpath->flags & MESH_PATH_ACTIVE)) {
  580. spin_unlock_bh(&mpath->state_lock);
  581. goto fail;
  582. }
  583. memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN);
  584. spin_unlock_bh(&mpath->state_lock);
  585. --ttl;
  586. flags = PREP_IE_FLAGS(prep_elem);
  587. lifetime = PREP_IE_LIFETIME(prep_elem);
  588. hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1;
  589. orig_addr = PREP_IE_ORIG_ADDR(prep_elem);
  590. target_sn = PREP_IE_TARGET_SN(prep_elem);
  591. orig_sn = PREP_IE_ORIG_SN(prep_elem);
  592. mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr,
  593. cpu_to_le32(orig_sn), 0, target_addr,
  594. cpu_to_le32(target_sn), next_hop, hopcount,
  595. ttl, cpu_to_le32(lifetime), cpu_to_le32(metric),
  596. 0, sdata);
  597. rcu_read_unlock();
  598. sdata->u.mesh.mshstats.fwded_unicast++;
  599. sdata->u.mesh.mshstats.fwded_frames++;
  600. return;
  601. fail:
  602. rcu_read_unlock();
  603. sdata->u.mesh.mshstats.dropped_frames_no_route++;
  604. }
  605. static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
  606. struct ieee80211_mgmt *mgmt, u8 *perr_elem)
  607. {
  608. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  609. struct mesh_path *mpath;
  610. u8 ttl;
  611. u8 *ta, *target_addr;
  612. u32 target_sn;
  613. u16 target_rcode;
  614. ta = mgmt->sa;
  615. ttl = PERR_IE_TTL(perr_elem);
  616. if (ttl <= 1) {
  617. ifmsh->mshstats.dropped_frames_ttl++;
  618. return;
  619. }
  620. ttl--;
  621. target_addr = PERR_IE_TARGET_ADDR(perr_elem);
  622. target_sn = PERR_IE_TARGET_SN(perr_elem);
  623. target_rcode = PERR_IE_TARGET_RCODE(perr_elem);
  624. rcu_read_lock();
  625. mpath = mesh_path_lookup(target_addr, sdata);
  626. if (mpath) {
  627. spin_lock_bh(&mpath->state_lock);
  628. if (mpath->flags & MESH_PATH_ACTIVE &&
  629. memcmp(ta, next_hop_deref_protected(mpath)->sta.addr,
  630. ETH_ALEN) == 0 &&
  631. (!(mpath->flags & MESH_PATH_SN_VALID) ||
  632. SN_GT(target_sn, mpath->sn))) {
  633. mpath->flags &= ~MESH_PATH_ACTIVE;
  634. mpath->sn = target_sn;
  635. spin_unlock_bh(&mpath->state_lock);
  636. mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn),
  637. cpu_to_le16(target_rcode),
  638. broadcast_addr, sdata);
  639. } else
  640. spin_unlock_bh(&mpath->state_lock);
  641. }
  642. rcu_read_unlock();
  643. }
  644. static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
  645. struct ieee80211_mgmt *mgmt,
  646. struct ieee80211_rann_ie *rann)
  647. {
  648. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  649. struct mesh_path *mpath;
  650. u8 ttl, flags, hopcount;
  651. u8 *orig_addr;
  652. u32 orig_sn, metric;
  653. u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
  654. bool root_is_gate;
  655. ttl = rann->rann_ttl;
  656. if (ttl <= 1) {
  657. ifmsh->mshstats.dropped_frames_ttl++;
  658. return;
  659. }
  660. ttl--;
  661. flags = rann->rann_flags;
  662. root_is_gate = !!(flags & RANN_FLAG_IS_GATE);
  663. orig_addr = rann->rann_addr;
  664. orig_sn = rann->rann_seq;
  665. hopcount = rann->rann_hopcount;
  666. hopcount++;
  667. metric = rann->rann_metric;
  668. /* Ignore our own RANNs */
  669. if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0)
  670. return;
  671. mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr,
  672. root_is_gate);
  673. rcu_read_lock();
  674. mpath = mesh_path_lookup(orig_addr, sdata);
  675. if (!mpath) {
  676. mesh_path_add(orig_addr, sdata);
  677. mpath = mesh_path_lookup(orig_addr, sdata);
  678. if (!mpath) {
  679. rcu_read_unlock();
  680. sdata->u.mesh.mshstats.dropped_frames_no_route++;
  681. return;
  682. }
  683. }
  684. if ((!(mpath->flags & (MESH_PATH_ACTIVE | MESH_PATH_RESOLVING)) ||
  685. time_after(jiffies, mpath->exp_time - 1*HZ)) &&
  686. !(mpath->flags & MESH_PATH_FIXED)) {
  687. mhwmp_dbg("%s time to refresh root mpath %pM", sdata->name,
  688. orig_addr);
  689. mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH);
  690. }
  691. if (mpath->sn < orig_sn) {
  692. mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
  693. cpu_to_le32(orig_sn),
  694. 0, NULL, 0, broadcast_addr,
  695. hopcount, ttl, cpu_to_le32(interval),
  696. cpu_to_le32(metric + mpath->metric),
  697. 0, sdata);
  698. mpath->sn = orig_sn;
  699. }
  700. if (root_is_gate)
  701. mesh_path_add_gate(mpath);
  702. rcu_read_unlock();
  703. }
  704. void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
  705. struct ieee80211_mgmt *mgmt,
  706. size_t len)
  707. {
  708. struct ieee802_11_elems elems;
  709. size_t baselen;
  710. u32 last_hop_metric;
  711. /* need action_code */
  712. if (len < IEEE80211_MIN_ACTION_SIZE + 1)
  713. return;
  714. baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt;
  715. ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable,
  716. len - baselen, &elems);
  717. if (elems.preq) {
  718. if (elems.preq_len != 37)
  719. /* Right now we support just 1 destination and no AE */
  720. return;
  721. last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq,
  722. MPATH_PREQ);
  723. if (last_hop_metric)
  724. hwmp_preq_frame_process(sdata, mgmt, elems.preq,
  725. last_hop_metric);
  726. }
  727. if (elems.prep) {
  728. if (elems.prep_len != 31)
  729. /* Right now we support no AE */
  730. return;
  731. last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep,
  732. MPATH_PREP);
  733. if (last_hop_metric)
  734. hwmp_prep_frame_process(sdata, mgmt, elems.prep,
  735. last_hop_metric);
  736. }
  737. if (elems.perr) {
  738. if (elems.perr_len != 15)
  739. /* Right now we support only one destination per PERR */
  740. return;
  741. hwmp_perr_frame_process(sdata, mgmt, elems.perr);
  742. }
  743. if (elems.rann)
  744. hwmp_rann_frame_process(sdata, mgmt, elems.rann);
  745. }
  746. /**
  747. * mesh_queue_preq - queue a PREQ to a given destination
  748. *
  749. * @mpath: mesh path to discover
  750. * @flags: special attributes of the PREQ to be sent
  751. *
  752. * Locking: the function must be called from within a rcu read lock block.
  753. *
  754. */
  755. static void mesh_queue_preq(struct mesh_path *mpath, u8 flags)
  756. {
  757. struct ieee80211_sub_if_data *sdata = mpath->sdata;
  758. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  759. struct mesh_preq_queue *preq_node;
  760. preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC);
  761. if (!preq_node) {
  762. mhwmp_dbg("could not allocate PREQ node");
  763. return;
  764. }
  765. spin_lock_bh(&ifmsh->mesh_preq_queue_lock);
  766. if (ifmsh->preq_queue_len == MAX_PREQ_QUEUE_LEN) {
  767. spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
  768. kfree(preq_node);
  769. if (printk_ratelimit())
  770. mhwmp_dbg("PREQ node queue full");
  771. return;
  772. }
  773. memcpy(preq_node->dst, mpath->dst, ETH_ALEN);
  774. preq_node->flags = flags;
  775. list_add_tail(&preq_node->list, &ifmsh->preq_queue.list);
  776. ++ifmsh->preq_queue_len;
  777. spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
  778. if (time_after(jiffies, ifmsh->last_preq + min_preq_int_jiff(sdata)))
  779. ieee80211_queue_work(&sdata->local->hw, &sdata->work);
  780. else if (time_before(jiffies, ifmsh->last_preq)) {
  781. /* avoid long wait if did not send preqs for a long time
  782. * and jiffies wrapped around
  783. */
  784. ifmsh->last_preq = jiffies - min_preq_int_jiff(sdata) - 1;
  785. ieee80211_queue_work(&sdata->local->hw, &sdata->work);
  786. } else
  787. mod_timer(&ifmsh->mesh_path_timer, ifmsh->last_preq +
  788. min_preq_int_jiff(sdata));
  789. }
  790. /**
  791. * mesh_path_start_discovery - launch a path discovery from the PREQ queue
  792. *
  793. * @sdata: local mesh subif
  794. */
  795. void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
  796. {
  797. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  798. struct mesh_preq_queue *preq_node;
  799. struct mesh_path *mpath;
  800. u8 ttl, target_flags;
  801. u32 lifetime;
  802. spin_lock_bh(&ifmsh->mesh_preq_queue_lock);
  803. if (!ifmsh->preq_queue_len ||
  804. time_before(jiffies, ifmsh->last_preq +
  805. min_preq_int_jiff(sdata))) {
  806. spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
  807. return;
  808. }
  809. preq_node = list_first_entry(&ifmsh->preq_queue.list,
  810. struct mesh_preq_queue, list);
  811. list_del(&preq_node->list);
  812. --ifmsh->preq_queue_len;
  813. spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
  814. rcu_read_lock();
  815. mpath = mesh_path_lookup(preq_node->dst, sdata);
  816. if (!mpath)
  817. goto enddiscovery;
  818. spin_lock_bh(&mpath->state_lock);
  819. if (preq_node->flags & PREQ_Q_F_START) {
  820. if (mpath->flags & MESH_PATH_RESOLVING) {
  821. spin_unlock_bh(&mpath->state_lock);
  822. goto enddiscovery;
  823. } else {
  824. mpath->flags &= ~MESH_PATH_RESOLVED;
  825. mpath->flags |= MESH_PATH_RESOLVING;
  826. mpath->discovery_retries = 0;
  827. mpath->discovery_timeout = disc_timeout_jiff(sdata);
  828. }
  829. } else if (!(mpath->flags & MESH_PATH_RESOLVING) ||
  830. mpath->flags & MESH_PATH_RESOLVED) {
  831. mpath->flags &= ~MESH_PATH_RESOLVING;
  832. spin_unlock_bh(&mpath->state_lock);
  833. goto enddiscovery;
  834. }
  835. ifmsh->last_preq = jiffies;
  836. if (time_after(jiffies, ifmsh->last_sn_update +
  837. net_traversal_jiffies(sdata)) ||
  838. time_before(jiffies, ifmsh->last_sn_update)) {
  839. ++ifmsh->sn;
  840. sdata->u.mesh.last_sn_update = jiffies;
  841. }
  842. lifetime = default_lifetime(sdata);
  843. ttl = sdata->u.mesh.mshcfg.element_ttl;
  844. if (ttl == 0) {
  845. sdata->u.mesh.mshstats.dropped_frames_ttl++;
  846. spin_unlock_bh(&mpath->state_lock);
  847. goto enddiscovery;
  848. }
  849. if (preq_node->flags & PREQ_Q_F_REFRESH)
  850. target_flags = MP_F_DO;
  851. else
  852. target_flags = MP_F_RF;
  853. spin_unlock_bh(&mpath->state_lock);
  854. mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr,
  855. cpu_to_le32(ifmsh->sn), target_flags, mpath->dst,
  856. cpu_to_le32(mpath->sn), broadcast_addr, 0,
  857. ttl, cpu_to_le32(lifetime), 0,
  858. cpu_to_le32(ifmsh->preq_id++), sdata);
  859. mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout);
  860. enddiscovery:
  861. rcu_read_unlock();
  862. kfree(preq_node);
  863. }
  864. /**
  865. * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame
  866. *
  867. * @skb: 802.11 frame to be sent
  868. * @sdata: network subif the frame will be sent through
  869. *
  870. * Returns: 0 if the next hop was found. Nonzero otherwise. If no next hop is
  871. * found, the function will start a path discovery and queue the frame so it is
  872. * sent when the path is resolved. This means the caller must not free the skb
  873. * in this case.
  874. */
  875. int mesh_nexthop_lookup(struct sk_buff *skb,
  876. struct ieee80211_sub_if_data *sdata)
  877. {
  878. struct sk_buff *skb_to_free = NULL;
  879. struct mesh_path *mpath;
  880. struct sta_info *next_hop;
  881. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  882. u8 *target_addr = hdr->addr3;
  883. int err = 0;
  884. rcu_read_lock();
  885. mpath = mesh_path_lookup(target_addr, sdata);
  886. if (!mpath) {
  887. mesh_path_add(target_addr, sdata);
  888. mpath = mesh_path_lookup(target_addr, sdata);
  889. if (!mpath) {
  890. sdata->u.mesh.mshstats.dropped_frames_no_route++;
  891. err = -ENOSPC;
  892. goto endlookup;
  893. }
  894. }
  895. if (mpath->flags & MESH_PATH_ACTIVE) {
  896. if (time_after(jiffies,
  897. mpath->exp_time -
  898. msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) &&
  899. !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) &&
  900. !(mpath->flags & MESH_PATH_RESOLVING) &&
  901. !(mpath->flags & MESH_PATH_FIXED)) {
  902. mesh_queue_preq(mpath,
  903. PREQ_Q_F_START | PREQ_Q_F_REFRESH);
  904. }
  905. next_hop = rcu_dereference(mpath->next_hop);
  906. if (next_hop)
  907. memcpy(hdr->addr1, next_hop->sta.addr, ETH_ALEN);
  908. else
  909. err = -ENOENT;
  910. } else {
  911. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  912. if (!(mpath->flags & MESH_PATH_RESOLVING)) {
  913. /* Start discovery only if it is not running yet */
  914. mesh_queue_preq(mpath, PREQ_Q_F_START);
  915. }
  916. if (skb_queue_len(&mpath->frame_queue) >=
  917. MESH_FRAME_QUEUE_LEN)
  918. skb_to_free = skb_dequeue(&mpath->frame_queue);
  919. info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
  920. skb_queue_tail(&mpath->frame_queue, skb);
  921. if (skb_to_free)
  922. mesh_path_discard_frame(skb_to_free, sdata);
  923. err = -ENOENT;
  924. }
  925. endlookup:
  926. rcu_read_unlock();
  927. return err;
  928. }
  929. void mesh_path_timer(unsigned long data)
  930. {
  931. struct mesh_path *mpath = (void *) data;
  932. struct ieee80211_sub_if_data *sdata = mpath->sdata;
  933. int ret;
  934. if (sdata->local->quiescing)
  935. return;
  936. spin_lock_bh(&mpath->state_lock);
  937. if (mpath->flags & MESH_PATH_RESOLVED ||
  938. (!(mpath->flags & MESH_PATH_RESOLVING))) {
  939. mpath->flags &= ~(MESH_PATH_RESOLVING | MESH_PATH_RESOLVED);
  940. spin_unlock_bh(&mpath->state_lock);
  941. } else if (mpath->discovery_retries < max_preq_retries(sdata)) {
  942. ++mpath->discovery_retries;
  943. mpath->discovery_timeout *= 2;
  944. spin_unlock_bh(&mpath->state_lock);
  945. mesh_queue_preq(mpath, 0);
  946. } else {
  947. mpath->flags = 0;
  948. mpath->exp_time = jiffies;
  949. spin_unlock_bh(&mpath->state_lock);
  950. if (!mpath->is_gate && mesh_gate_num(sdata) > 0) {
  951. ret = mesh_path_send_to_gates(mpath);
  952. if (ret)
  953. mhwmp_dbg("no gate was reachable");
  954. } else
  955. mesh_path_flush_pending(mpath);
  956. }
  957. }
  958. void
  959. mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
  960. {
  961. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  962. u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
  963. u8 flags;
  964. flags = (ifmsh->mshcfg.dot11MeshGateAnnouncementProtocol)
  965. ? RANN_FLAG_IS_GATE : 0;
  966. mesh_path_sel_frame_tx(MPATH_RANN, flags, sdata->vif.addr,
  967. cpu_to_le32(++ifmsh->sn),
  968. 0, NULL, 0, broadcast_addr,
  969. 0, sdata->u.mesh.mshcfg.element_ttl,
  970. cpu_to_le32(interval), 0, 0, sdata);
  971. }