aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_hwmp.c
diff options
context:
space:
mode:
authorRui Paulo <rpaulo@gmail.com>2009-11-09 18:46:55 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-13 17:43:56 -0500
commitd19b3bf6384e66ac6e11a61ee31ed2cfe149f4d8 (patch)
tree2ec825639458dafddecc7e3d0f83afff9cff0cfa /net/mac80211/mesh_hwmp.c
parentbe125c60e46e165fbfe33db36a4a9d943d560a5b (diff)
mac80211: replace "destination" with "target" to follow the spec
Resulting object files have the same MD5 as before. Signed-off-by: Rui Paulo <rpaulo@gmail.com> Signed-off-by: Javier Cardona <javier@cozybit.com> Reviewed-by: Andrey Yurovsky <andrey@cozybit.com> Tested-by: Brian Cavagnolo <brian@cozybit.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r--net/mac80211/mesh_hwmp.c221
1 files changed, 112 insertions, 109 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 7d36f3a741a..f03a27dfd61 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -56,33 +56,33 @@ static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae)
56#define PREQ_IE_TTL(x) (*(x + 2)) 56#define PREQ_IE_TTL(x) (*(x + 2))
57#define PREQ_IE_PREQ_ID(x) u32_field_get(x, 3, 0) 57#define PREQ_IE_PREQ_ID(x) u32_field_get(x, 3, 0)
58#define PREQ_IE_ORIG_ADDR(x) (x + 7) 58#define PREQ_IE_ORIG_ADDR(x) (x + 7)
59#define PREQ_IE_ORIG_DSN(x) u32_field_get(x, 13, 0); 59#define PREQ_IE_ORIG_SN(x) u32_field_get(x, 13, 0);
60#define PREQ_IE_LIFETIME(x) u32_field_get(x, 17, AE_F_SET(x)); 60#define PREQ_IE_LIFETIME(x) u32_field_get(x, 17, AE_F_SET(x));
61#define PREQ_IE_METRIC(x) u32_field_get(x, 21, AE_F_SET(x)); 61#define PREQ_IE_METRIC(x) u32_field_get(x, 21, AE_F_SET(x));
62#define PREQ_IE_DST_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26)) 62#define PREQ_IE_TARGET_F(x) (*(AE_F_SET(x) ? x + 32 : x + 26))
63#define PREQ_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27) 63#define PREQ_IE_TARGET_ADDR(x) (AE_F_SET(x) ? x + 33 : x + 27)
64#define PREQ_IE_DST_DSN(x) u32_field_get(x, 33, AE_F_SET(x)); 64#define PREQ_IE_TARGET_SN(x) u32_field_get(x, 33, AE_F_SET(x));
65 65
66 66
67#define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) 67#define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x)
68#define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) 68#define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x)
69#define PREP_IE_TTL(x) PREQ_IE_TTL(x) 69#define PREP_IE_TTL(x) PREQ_IE_TTL(x)
70#define PREP_IE_ORIG_ADDR(x) (x + 3) 70#define PREP_IE_ORIG_ADDR(x) (x + 3)
71#define PREP_IE_ORIG_DSN(x) u32_field_get(x, 9, 0); 71#define PREP_IE_ORIG_SN(x) u32_field_get(x, 9, 0);
72#define PREP_IE_LIFETIME(x) u32_field_get(x, 13, AE_F_SET(x)); 72#define PREP_IE_LIFETIME(x) u32_field_get(x, 13, AE_F_SET(x));
73#define PREP_IE_METRIC(x) u32_field_get(x, 17, AE_F_SET(x)); 73#define PREP_IE_METRIC(x) u32_field_get(x, 17, AE_F_SET(x));
74#define PREP_IE_DST_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21) 74#define PREP_IE_TARGET_ADDR(x) (AE_F_SET(x) ? x + 27 : x + 21)
75#define PREP_IE_DST_DSN(x) u32_field_get(x, 27, AE_F_SET(x)); 75#define PREP_IE_TARGET_SN(x) u32_field_get(x, 27, AE_F_SET(x));
76 76
77#define PERR_IE_TTL(x) (*(x)) 77#define PERR_IE_TTL(x) (*(x))
78#define PERR_IE_DST_FLAGS(x) (*(x + 2)) 78#define PERR_IE_TARGET_FLAGS(x) (*(x + 2))
79#define PERR_IE_DST_ADDR(x) (x + 3) 79#define PERR_IE_TARGET_ADDR(x) (x + 3)
80#define PERR_IE_DST_DSN(x) u32_field_get(x, 9, 0); 80#define PERR_IE_TARGET_SN(x) u32_field_get(x, 9, 0);
81#define PERR_IE_DST_RCODE(x) u16_field_get(x, 13, 0); 81#define PERR_IE_TARGET_RCODE(x) u16_field_get(x, 13, 0);
82 82
83#define MSEC_TO_TU(x) (x*1000/1024) 83#define MSEC_TO_TU(x) (x*1000/1024)
84#define DSN_GT(x, y) ((long) (y) - (long) (x) < 0) 84#define SN_GT(x, y) ((long) (y) - (long) (x) < 0)
85#define DSN_LT(x, y) ((long) (x) - (long) (y) < 0) 85#define SN_LT(x, y) ((long) (x) - (long) (y) < 0)
86 86
87#define net_traversal_jiffies(s) \ 87#define net_traversal_jiffies(s) \
88 msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) 88 msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime)
@@ -102,9 +102,10 @@ enum mpath_frame_type {
102}; 102};
103 103
104static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, 104static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
105 u8 *orig_addr, __le32 orig_dsn, u8 dst_flags, u8 *dst, 105 u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target,
106 __le32 dst_dsn, u8 *da, u8 hop_count, u8 ttl, __le32 lifetime, 106 __le32 target_sn, u8 *da, u8 hop_count, u8 ttl,__le32 lifetime,
107 __le32 metric, __le32 preq_id, struct ieee80211_sub_if_data *sdata) 107 __le32 metric, __le32 preq_id,
108 struct ieee80211_sub_if_data *sdata)
108{ 109{
109 struct ieee80211_local *local = sdata->local; 110 struct ieee80211_local *local = sdata->local;
110 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 111 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
@@ -133,13 +134,13 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
133 134
134 switch (action) { 135 switch (action) {
135 case MPATH_PREQ: 136 case MPATH_PREQ:
136 mhwmp_dbg("sending PREQ to %pM\n", dst); 137 mhwmp_dbg("sending PREQ to %pM\n", target);
137 ie_len = 37; 138 ie_len = 37;
138 pos = skb_put(skb, 2 + ie_len); 139 pos = skb_put(skb, 2 + ie_len);
139 *pos++ = WLAN_EID_PREQ; 140 *pos++ = WLAN_EID_PREQ;
140 break; 141 break;
141 case MPATH_PREP: 142 case MPATH_PREP:
142 mhwmp_dbg("sending PREP to %pM\n", dst); 143 mhwmp_dbg("sending PREP to %pM\n", target);
143 ie_len = 31; 144 ie_len = 31;
144 pos = skb_put(skb, 2 + ie_len); 145 pos = skb_put(skb, 2 + ie_len);
145 *pos++ = WLAN_EID_PREP; 146 *pos++ = WLAN_EID_PREP;
@@ -165,7 +166,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
165 } 166 }
166 memcpy(pos, orig_addr, ETH_ALEN); 167 memcpy(pos, orig_addr, ETH_ALEN);
167 pos += ETH_ALEN; 168 pos += ETH_ALEN;
168 memcpy(pos, &orig_dsn, 4); 169 memcpy(pos, &orig_sn, 4);
169 pos += 4; 170 pos += 4;
170 if (action != MPATH_RANN) { 171 if (action != MPATH_RANN) {
171 memcpy(pos, &lifetime, 4); 172 memcpy(pos, &lifetime, 4);
@@ -176,12 +177,12 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
176 if (action == MPATH_PREQ) { 177 if (action == MPATH_PREQ) {
177 /* destination count */ 178 /* destination count */
178 *pos++ = 1; 179 *pos++ = 1;
179 *pos++ = dst_flags; 180 *pos++ = target_flags;
180 } 181 }
181 if (action != MPATH_RANN) { 182 if (action != MPATH_RANN) {
182 memcpy(pos, dst, ETH_ALEN); 183 memcpy(pos, target, ETH_ALEN);
183 pos += ETH_ALEN; 184 pos += ETH_ALEN;
184 memcpy(pos, &dst_dsn, 4); 185 memcpy(pos, &target_sn, 4);
185 } 186 }
186 187
187 ieee80211_tx_skb(sdata, skb, 1); 188 ieee80211_tx_skb(sdata, skb, 1);
@@ -191,12 +192,14 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
191/** 192/**
192 * mesh_send_path error - Sends a PERR mesh management frame 193 * mesh_send_path error - Sends a PERR mesh management frame
193 * 194 *
194 * @dst: broken destination 195 * @target: broken destination
195 * @dst_dsn: dsn of the broken destination 196 * @target_sn: SN of the broken destination
197 * @target_rcode: reason code for this PERR
196 * @ra: node this frame is addressed to 198 * @ra: node this frame is addressed to
197 */ 199 */
198int mesh_path_error_tx(u8 ttl, u8 *dst, __le32 dst_dsn, __le16 dst_rcode, 200int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
199 u8 *ra, struct ieee80211_sub_if_data *sdata) 201 __le16 target_rcode, u8 *ra,
202 struct ieee80211_sub_if_data *sdata)
200{ 203{
201 struct ieee80211_local *local = sdata->local; 204 struct ieee80211_local *local = sdata->local;
202 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 205 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
@@ -234,16 +237,16 @@ int mesh_path_error_tx(u8 ttl, u8 *dst, __le32 dst_dsn, __le16 dst_rcode,
234 * bit 2 is set if we have a reason code 237 * bit 2 is set if we have a reason code
235 */ 238 */
236 *pos = 0; 239 *pos = 0;
237 if (!dst_dsn) 240 if (!target_sn)
238 *pos |= MP_F_USN; 241 *pos |= MP_F_USN;
239 if (dst_rcode) 242 if (target_rcode)
240 *pos |= MP_F_RCODE; 243 *pos |= MP_F_RCODE;
241 pos++; 244 pos++;
242 memcpy(pos, dst, ETH_ALEN); 245 memcpy(pos, target, ETH_ALEN);
243 pos += ETH_ALEN; 246 pos += ETH_ALEN;
244 memcpy(pos, &dst_dsn, 4); 247 memcpy(pos, &target_sn, 4);
245 pos += 4; 248 pos += 4;
246 memcpy(pos, &dst_rcode, 2); 249 memcpy(pos, &target_rcode, 2);
247 250
248 ieee80211_tx_skb(sdata, skb, 1); 251 ieee80211_tx_skb(sdata, skb, 1);
249 return 0; 252 return 0;
@@ -324,7 +327,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
324 struct sta_info *sta; 327 struct sta_info *sta;
325 bool fresh_info; 328 bool fresh_info;
326 u8 *orig_addr, *ta; 329 u8 *orig_addr, *ta;
327 u32 orig_dsn, orig_metric; 330 u32 orig_sn, orig_metric;
328 unsigned long orig_lifetime, exp_time; 331 unsigned long orig_lifetime, exp_time;
329 u32 last_hop_metric, new_metric; 332 u32 last_hop_metric, new_metric;
330 bool process = true; 333 bool process = true;
@@ -343,7 +346,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
343 switch (action) { 346 switch (action) {
344 case MPATH_PREQ: 347 case MPATH_PREQ:
345 orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); 348 orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie);
346 orig_dsn = PREQ_IE_ORIG_DSN(hwmp_ie); 349 orig_sn = PREQ_IE_ORIG_SN(hwmp_ie);
347 orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); 350 orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie);
348 orig_metric = PREQ_IE_METRIC(hwmp_ie); 351 orig_metric = PREQ_IE_METRIC(hwmp_ie);
349 break; 352 break;
@@ -356,7 +359,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
356 * information from both PREQ and PREP frames. 359 * information from both PREQ and PREP frames.
357 */ 360 */
358 orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); 361 orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie);
359 orig_dsn = PREP_IE_ORIG_DSN(hwmp_ie); 362 orig_sn = PREP_IE_ORIG_SN(hwmp_ie);
360 orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); 363 orig_lifetime = PREP_IE_LIFETIME(hwmp_ie);
361 orig_metric = PREP_IE_METRIC(hwmp_ie); 364 orig_metric = PREP_IE_METRIC(hwmp_ie);
362 break; 365 break;
@@ -382,9 +385,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
382 if (mpath->flags & MESH_PATH_FIXED) 385 if (mpath->flags & MESH_PATH_FIXED)
383 fresh_info = false; 386 fresh_info = false;
384 else if ((mpath->flags & MESH_PATH_ACTIVE) && 387 else if ((mpath->flags & MESH_PATH_ACTIVE) &&
385 (mpath->flags & MESH_PATH_DSN_VALID)) { 388 (mpath->flags & MESH_PATH_SN_VALID)) {
386 if (DSN_GT(mpath->dsn, orig_dsn) || 389 if (SN_GT(mpath->sn, orig_sn) ||
387 (mpath->dsn == orig_dsn && 390 (mpath->sn == orig_sn &&
388 action == MPATH_PREQ && 391 action == MPATH_PREQ &&
389 new_metric > mpath->metric)) { 392 new_metric > mpath->metric)) {
390 process = false; 393 process = false;
@@ -403,9 +406,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
403 406
404 if (fresh_info) { 407 if (fresh_info) {
405 mesh_path_assign_nexthop(mpath, sta); 408 mesh_path_assign_nexthop(mpath, sta);
406 mpath->flags |= MESH_PATH_DSN_VALID; 409 mpath->flags |= MESH_PATH_SN_VALID;
407 mpath->metric = new_metric; 410 mpath->metric = new_metric;
408 mpath->dsn = orig_dsn; 411 mpath->sn = orig_sn;
409 mpath->exp_time = time_after(mpath->exp_time, exp_time) 412 mpath->exp_time = time_after(mpath->exp_time, exp_time)
410 ? mpath->exp_time : exp_time; 413 ? mpath->exp_time : exp_time;
411 mesh_path_activate(mpath); 414 mesh_path_activate(mpath);
@@ -444,7 +447,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
444 447
445 if (fresh_info) { 448 if (fresh_info) {
446 mesh_path_assign_nexthop(mpath, sta); 449 mesh_path_assign_nexthop(mpath, sta);
447 mpath->flags &= ~MESH_PATH_DSN_VALID; 450 mpath->flags &= ~MESH_PATH_SN_VALID;
448 mpath->metric = last_hop_metric; 451 mpath->metric = last_hop_metric;
449 mpath->exp_time = time_after(mpath->exp_time, exp_time) 452 mpath->exp_time = time_after(mpath->exp_time, exp_time)
450 ? mpath->exp_time : exp_time; 453 ? mpath->exp_time : exp_time;
@@ -466,47 +469,47 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
466{ 469{
467 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 470 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
468 struct mesh_path *mpath; 471 struct mesh_path *mpath;
469 u8 *dst_addr, *orig_addr; 472 u8 *target_addr, *orig_addr;
470 u8 dst_flags, ttl; 473 u8 target_flags, ttl;
471 u32 orig_dsn, dst_dsn, lifetime; 474 u32 orig_sn, target_sn, lifetime;
472 bool reply = false; 475 bool reply = false;
473 bool forward = true; 476 bool forward = true;
474 477
475 /* Update destination DSN, if present */ 478 /* Update target SN, if present */
476 dst_addr = PREQ_IE_DST_ADDR(preq_elem); 479 target_addr = PREQ_IE_TARGET_ADDR(preq_elem);
477 orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); 480 orig_addr = PREQ_IE_ORIG_ADDR(preq_elem);
478 dst_dsn = PREQ_IE_DST_DSN(preq_elem); 481 target_sn = PREQ_IE_TARGET_SN(preq_elem);
479 orig_dsn = PREQ_IE_ORIG_DSN(preq_elem); 482 orig_sn = PREQ_IE_ORIG_SN(preq_elem);
480 dst_flags = PREQ_IE_DST_F(preq_elem); 483 target_flags = PREQ_IE_TARGET_F(preq_elem);
481 484
482 mhwmp_dbg("received PREQ from %pM\n", orig_addr); 485 mhwmp_dbg("received PREQ from %pM\n", orig_addr);
483 486
484 if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { 487 if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) {
485 mhwmp_dbg("PREQ is for us\n"); 488 mhwmp_dbg("PREQ is for us\n");
486 forward = false; 489 forward = false;
487 reply = true; 490 reply = true;
488 metric = 0; 491 metric = 0;
489 if (time_after(jiffies, ifmsh->last_dsn_update + 492 if (time_after(jiffies, ifmsh->last_sn_update +
490 net_traversal_jiffies(sdata)) || 493 net_traversal_jiffies(sdata)) ||
491 time_before(jiffies, ifmsh->last_dsn_update)) { 494 time_before(jiffies, ifmsh->last_sn_update)) {
492 dst_dsn = ++ifmsh->dsn; 495 target_sn = ++ifmsh->sn;
493 ifmsh->last_dsn_update = jiffies; 496 ifmsh->last_sn_update = jiffies;
494 } 497 }
495 } else { 498 } else {
496 rcu_read_lock(); 499 rcu_read_lock();
497 mpath = mesh_path_lookup(dst_addr, sdata); 500 mpath = mesh_path_lookup(target_addr, sdata);
498 if (mpath) { 501 if (mpath) {
499 if ((!(mpath->flags & MESH_PATH_DSN_VALID)) || 502 if ((!(mpath->flags & MESH_PATH_SN_VALID)) ||
500 DSN_LT(mpath->dsn, dst_dsn)) { 503 SN_LT(mpath->sn, target_sn)) {
501 mpath->dsn = dst_dsn; 504 mpath->sn = target_sn;
502 mpath->flags |= MESH_PATH_DSN_VALID; 505 mpath->flags |= MESH_PATH_SN_VALID;
503 } else if ((!(dst_flags & MP_F_DO)) && 506 } else if ((!(target_flags & MP_F_DO)) &&
504 (mpath->flags & MESH_PATH_ACTIVE)) { 507 (mpath->flags & MESH_PATH_ACTIVE)) {
505 reply = true; 508 reply = true;
506 metric = mpath->metric; 509 metric = mpath->metric;
507 dst_dsn = mpath->dsn; 510 target_sn = mpath->sn;
508 if (dst_flags & MP_F_RF) 511 if (target_flags & MP_F_RF)
509 dst_flags |= MP_F_DO; 512 target_flags |= MP_F_DO;
510 else 513 else
511 forward = false; 514 forward = false;
512 } 515 }
@@ -519,9 +522,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
519 ttl = ifmsh->mshcfg.dot11MeshTTL; 522 ttl = ifmsh->mshcfg.dot11MeshTTL;
520 if (ttl != 0) { 523 if (ttl != 0) {
521 mhwmp_dbg("replying to the PREQ\n"); 524 mhwmp_dbg("replying to the PREQ\n");
522 mesh_path_sel_frame_tx(MPATH_PREP, 0, dst_addr, 525 mesh_path_sel_frame_tx(MPATH_PREP, 0, target_addr,
523 cpu_to_le32(dst_dsn), 0, orig_addr, 526 cpu_to_le32(target_sn), 0, orig_addr,
524 cpu_to_le32(orig_dsn), mgmt->sa, 0, ttl, 527 cpu_to_le32(orig_sn), mgmt->sa, 0, ttl,
525 cpu_to_le32(lifetime), cpu_to_le32(metric), 528 cpu_to_le32(lifetime), cpu_to_le32(metric),
526 0, sdata); 529 0, sdata);
527 } else 530 } else
@@ -544,8 +547,8 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
544 preq_id = PREQ_IE_PREQ_ID(preq_elem); 547 preq_id = PREQ_IE_PREQ_ID(preq_elem);
545 hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; 548 hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1;
546 mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, 549 mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr,
547 cpu_to_le32(orig_dsn), dst_flags, dst_addr, 550 cpu_to_le32(orig_sn), target_flags, target_addr,
548 cpu_to_le32(dst_dsn), sdata->dev->broadcast, 551 cpu_to_le32(target_sn), sdata->dev->broadcast,
549 hopcount, ttl, cpu_to_le32(lifetime), 552 hopcount, ttl, cpu_to_le32(lifetime),
550 cpu_to_le32(metric), cpu_to_le32(preq_id), 553 cpu_to_le32(metric), cpu_to_le32(preq_id),
551 sdata); 554 sdata);
@@ -560,10 +563,10 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
560 u8 *prep_elem, u32 metric) 563 u8 *prep_elem, u32 metric)
561{ 564{
562 struct mesh_path *mpath; 565 struct mesh_path *mpath;
563 u8 *dst_addr, *orig_addr; 566 u8 *target_addr, *orig_addr;
564 u8 ttl, hopcount, flags; 567 u8 ttl, hopcount, flags;
565 u8 next_hop[ETH_ALEN]; 568 u8 next_hop[ETH_ALEN];
566 u32 dst_dsn, orig_dsn, lifetime; 569 u32 target_sn, orig_sn, lifetime;
567 570
568 mhwmp_dbg("received PREP from %pM\n", PREP_IE_ORIG_ADDR(prep_elem)); 571 mhwmp_dbg("received PREP from %pM\n", PREP_IE_ORIG_ADDR(prep_elem));
569 572
@@ -573,8 +576,8 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
573 * which corresponds with the originator of the PREQ which this PREP 576 * which corresponds with the originator of the PREQ which this PREP
574 * replies 577 * replies
575 */ 578 */
576 dst_addr = PREP_IE_DST_ADDR(prep_elem); 579 target_addr = PREP_IE_TARGET_ADDR(prep_elem);
577 if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) 580 if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0)
578 /* destination, no forwarding required */ 581 /* destination, no forwarding required */
579 return; 582 return;
580 583
@@ -585,7 +588,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
585 } 588 }
586 589
587 rcu_read_lock(); 590 rcu_read_lock();
588 mpath = mesh_path_lookup(dst_addr, sdata); 591 mpath = mesh_path_lookup(target_addr, sdata);
589 if (mpath) 592 if (mpath)
590 spin_lock_bh(&mpath->state_lock); 593 spin_lock_bh(&mpath->state_lock);
591 else 594 else
@@ -601,13 +604,13 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
601 lifetime = PREP_IE_LIFETIME(prep_elem); 604 lifetime = PREP_IE_LIFETIME(prep_elem);
602 hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; 605 hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1;
603 orig_addr = PREP_IE_ORIG_ADDR(prep_elem); 606 orig_addr = PREP_IE_ORIG_ADDR(prep_elem);
604 dst_dsn = PREP_IE_DST_DSN(prep_elem); 607 target_sn = PREP_IE_TARGET_SN(prep_elem);
605 orig_dsn = PREP_IE_ORIG_DSN(prep_elem); 608 orig_sn = PREP_IE_ORIG_SN(prep_elem);
606 609
607 mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, 610 mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr,
608 cpu_to_le32(orig_dsn), 0, dst_addr, 611 cpu_to_le32(orig_sn), 0, target_addr,
609 cpu_to_le32(dst_dsn), mpath->next_hop->sta.addr, hopcount, ttl, 612 cpu_to_le32(target_sn), mpath->next_hop->sta.addr, hopcount,
610 cpu_to_le32(lifetime), cpu_to_le32(metric), 613 ttl, cpu_to_le32(lifetime), cpu_to_le32(metric),
611 0, sdata); 614 0, sdata);
612 rcu_read_unlock(); 615 rcu_read_unlock();
613 616
@@ -627,10 +630,10 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
627 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 630 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
628 struct mesh_path *mpath; 631 struct mesh_path *mpath;
629 u8 ttl; 632 u8 ttl;
630 u8 *ta, *dst_addr; 633 u8 *ta, *target_addr;
631 u8 dst_flags; 634 u8 target_flags;
632 u32 dst_dsn; 635 u32 target_sn;
633 u16 dst_rcode; 636 u16 target_rcode;
634 637
635 ta = mgmt->sa; 638 ta = mgmt->sa;
636 ttl = PERR_IE_TTL(perr_elem); 639 ttl = PERR_IE_TTL(perr_elem);
@@ -639,24 +642,24 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
639 return; 642 return;
640 } 643 }
641 ttl--; 644 ttl--;
642 dst_flags = PERR_IE_DST_FLAGS(perr_elem); 645 target_flags = PERR_IE_TARGET_FLAGS(perr_elem);
643 dst_addr = PERR_IE_DST_ADDR(perr_elem); 646 target_addr = PERR_IE_TARGET_ADDR(perr_elem);
644 dst_dsn = PERR_IE_DST_DSN(perr_elem); 647 target_sn = PERR_IE_TARGET_SN(perr_elem);
645 dst_rcode = PERR_IE_DST_RCODE(perr_elem); 648 target_rcode = PERR_IE_TARGET_RCODE(perr_elem);
646 649
647 rcu_read_lock(); 650 rcu_read_lock();
648 mpath = mesh_path_lookup(dst_addr, sdata); 651 mpath = mesh_path_lookup(target_addr, sdata);
649 if (mpath) { 652 if (mpath) {
650 spin_lock_bh(&mpath->state_lock); 653 spin_lock_bh(&mpath->state_lock);
651 if (mpath->flags & MESH_PATH_ACTIVE && 654 if (mpath->flags & MESH_PATH_ACTIVE &&
652 memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && 655 memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 &&
653 (!(mpath->flags & MESH_PATH_DSN_VALID) || 656 (!(mpath->flags & MESH_PATH_SN_VALID) ||
654 DSN_GT(dst_dsn, mpath->dsn))) { 657 SN_GT(target_sn, mpath->sn))) {
655 mpath->flags &= ~MESH_PATH_ACTIVE; 658 mpath->flags &= ~MESH_PATH_ACTIVE;
656 mpath->dsn = dst_dsn; 659 mpath->sn = target_sn;
657 spin_unlock_bh(&mpath->state_lock); 660 spin_unlock_bh(&mpath->state_lock);
658 mesh_path_error_tx(ttl, dst_addr, cpu_to_le32(dst_dsn), 661 mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn),
659 cpu_to_le16(dst_rcode), 662 cpu_to_le16(target_rcode),
660 sdata->dev->broadcast, sdata); 663 sdata->dev->broadcast, sdata);
661 } else 664 } else
662 spin_unlock_bh(&mpath->state_lock); 665 spin_unlock_bh(&mpath->state_lock);
@@ -673,7 +676,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
673 u8 *ta; 676 u8 *ta;
674 u8 ttl, flags, hopcount; 677 u8 ttl, flags, hopcount;
675 u8 *orig_addr; 678 u8 *orig_addr;
676 u32 orig_dsn, metric; 679 u32 orig_sn, metric;
677 680
678 ta = mgmt->sa; 681 ta = mgmt->sa;
679 ttl = rann->rann_ttl; 682 ttl = rann->rann_ttl;
@@ -684,7 +687,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
684 ttl--; 687 ttl--;
685 flags = rann->rann_flags; 688 flags = rann->rann_flags;
686 orig_addr = rann->rann_addr; 689 orig_addr = rann->rann_addr;
687 orig_dsn = rann->rann_seq; 690 orig_sn = rann->rann_seq;
688 hopcount = rann->rann_hopcount; 691 hopcount = rann->rann_hopcount;
689 hopcount++; 692 hopcount++;
690 metric = rann->rann_metric; 693 metric = rann->rann_metric;
@@ -703,14 +706,14 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
703 mesh_queue_preq(mpath, 706 mesh_queue_preq(mpath,
704 PREQ_Q_F_START | PREQ_Q_F_REFRESH); 707 PREQ_Q_F_START | PREQ_Q_F_REFRESH);
705 } 708 }
706 if (mpath->dsn < orig_dsn) { 709 if (mpath->sn < orig_sn) {
707 mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, 710 mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
708 cpu_to_le32(orig_dsn), 711 cpu_to_le32(orig_sn),
709 0, NULL, 0, sdata->dev->broadcast, 712 0, NULL, 0, sdata->dev->broadcast,
710 hopcount, ttl, 0, 713 hopcount, ttl, 0,
711 cpu_to_le32(metric + mpath->metric), 714 cpu_to_le32(metric + mpath->metric),
712 0, sdata); 715 0, sdata);
713 mpath->dsn = orig_dsn; 716 mpath->sn = orig_sn;
714 } 717 }
715 rcu_read_unlock(); 718 rcu_read_unlock();
716} 719}
@@ -823,7 +826,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
823 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 826 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
824 struct mesh_preq_queue *preq_node; 827 struct mesh_preq_queue *preq_node;
825 struct mesh_path *mpath; 828 struct mesh_path *mpath;
826 u8 ttl, dst_flags; 829 u8 ttl, target_flags;
827 u32 lifetime; 830 u32 lifetime;
828 831
829 spin_lock_bh(&ifmsh->mesh_preq_queue_lock); 832 spin_lock_bh(&ifmsh->mesh_preq_queue_lock);
@@ -865,11 +868,11 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
865 868
866 ifmsh->last_preq = jiffies; 869 ifmsh->last_preq = jiffies;
867 870
868 if (time_after(jiffies, ifmsh->last_dsn_update + 871 if (time_after(jiffies, ifmsh->last_sn_update +
869 net_traversal_jiffies(sdata)) || 872 net_traversal_jiffies(sdata)) ||
870 time_before(jiffies, ifmsh->last_dsn_update)) { 873 time_before(jiffies, ifmsh->last_sn_update)) {
871 ++ifmsh->dsn; 874 ++ifmsh->sn;
872 sdata->u.mesh.last_dsn_update = jiffies; 875 sdata->u.mesh.last_sn_update = jiffies;
873 } 876 }
874 lifetime = default_lifetime(sdata); 877 lifetime = default_lifetime(sdata);
875 ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; 878 ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
@@ -880,14 +883,14 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
880 } 883 }
881 884
882 if (preq_node->flags & PREQ_Q_F_REFRESH) 885 if (preq_node->flags & PREQ_Q_F_REFRESH)
883 dst_flags = MP_F_DO; 886 target_flags = MP_F_DO;
884 else 887 else
885 dst_flags = MP_F_RF; 888 target_flags = MP_F_RF;
886 889
887 spin_unlock_bh(&mpath->state_lock); 890 spin_unlock_bh(&mpath->state_lock);
888 mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, 891 mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr,
889 cpu_to_le32(ifmsh->dsn), dst_flags, mpath->dst, 892 cpu_to_le32(ifmsh->sn), target_flags, mpath->dst,
890 cpu_to_le32(mpath->dsn), sdata->dev->broadcast, 0, 893 cpu_to_le32(mpath->sn), sdata->dev->broadcast, 0,
891 ttl, cpu_to_le32(lifetime), 0, 894 ttl, cpu_to_le32(lifetime), 0,
892 cpu_to_le32(ifmsh->preq_id++), sdata); 895 cpu_to_le32(ifmsh->preq_id++), sdata);
893 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); 896 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout);
@@ -914,15 +917,15 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
914 struct sk_buff *skb_to_free = NULL; 917 struct sk_buff *skb_to_free = NULL;
915 struct mesh_path *mpath; 918 struct mesh_path *mpath;
916 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 919 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
917 u8 *dst_addr = hdr->addr3; 920 u8 *target_addr = hdr->addr3;
918 int err = 0; 921 int err = 0;
919 922
920 rcu_read_lock(); 923 rcu_read_lock();
921 mpath = mesh_path_lookup(dst_addr, sdata); 924 mpath = mesh_path_lookup(target_addr, sdata);
922 925
923 if (!mpath) { 926 if (!mpath) {
924 mesh_path_add(dst_addr, sdata); 927 mesh_path_add(target_addr, sdata);
925 mpath = mesh_path_lookup(dst_addr, sdata); 928 mpath = mesh_path_lookup(target_addr, sdata);
926 if (!mpath) { 929 if (!mpath) {
927 sdata->u.mesh.mshstats.dropped_frames_no_route++; 930 sdata->u.mesh.mshstats.dropped_frames_no_route++;
928 err = -ENOSPC; 931 err = -ENOSPC;