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