diff options
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 413 |
1 files changed, 273 insertions, 140 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 29b82e98effa..833b2f3670c5 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2008 open80211s Ltd. | 2 | * Copyright (c) 2008, 2009 open80211s Ltd. |
3 | * Author: Luis Carlos Cobo <luisca@cozybit.com> | 3 | * Author: Luis Carlos Cobo <luisca@cozybit.com> |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
@@ -9,6 +9,12 @@ | |||
9 | 9 | ||
10 | #include "mesh.h" | 10 | #include "mesh.h" |
11 | 11 | ||
12 | #ifdef CONFIG_MAC80211_VERBOSE_MHWMP_DEBUG | ||
13 | #define mhwmp_dbg(fmt, args...) printk(KERN_DEBUG "Mesh HWMP: " fmt, ##args) | ||
14 | #else | ||
15 | #define mhwmp_dbg(fmt, args...) do { (void)(0); } while (0) | ||
16 | #endif | ||
17 | |||
12 | #define TEST_FRAME_LEN 8192 | 18 | #define TEST_FRAME_LEN 8192 |
13 | #define MAX_METRIC 0xffffffff | 19 | #define MAX_METRIC 0xffffffff |
14 | #define ARITH_SHIFT 8 | 20 | #define ARITH_SHIFT 8 |
@@ -21,6 +27,12 @@ | |||
21 | #define MP_F_DO 0x1 | 27 | #define MP_F_DO 0x1 |
22 | /* Reply and forward */ | 28 | /* Reply and forward */ |
23 | #define MP_F_RF 0x2 | 29 | #define MP_F_RF 0x2 |
30 | /* Unknown Sequence Number */ | ||
31 | #define MP_F_USN 0x01 | ||
32 | /* Reason code Present */ | ||
33 | #define MP_F_RCODE 0x02 | ||
34 | |||
35 | static void mesh_queue_preq(struct mesh_path *, u8); | ||
24 | 36 | ||
25 | static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | 37 | static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) |
26 | { | 38 | { |
@@ -29,6 +41,13 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
29 | return get_unaligned_le32(preq_elem + offset); | 41 | return get_unaligned_le32(preq_elem + offset); |
30 | } | 42 | } |
31 | 43 | ||
44 | static inline u32 u16_field_get(u8 *preq_elem, int offset, bool ae) | ||
45 | { | ||
46 | if (ae) | ||
47 | offset += 6; | ||
48 | return get_unaligned_le16(preq_elem + offset); | ||
49 | } | ||
50 | |||
32 | /* HWMP IE processing macros */ | 51 | /* HWMP IE processing macros */ |
33 | #define AE_F (1<<6) | 52 | #define AE_F (1<<6) |
34 | #define AE_F_SET(x) (*x & AE_F) | 53 | #define AE_F_SET(x) (*x & AE_F) |
@@ -37,30 +56,33 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
37 | #define PREQ_IE_TTL(x) (*(x + 2)) | 56 | #define PREQ_IE_TTL(x) (*(x + 2)) |
38 | #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) |
39 | #define PREQ_IE_ORIG_ADDR(x) (x + 7) | 58 | #define PREQ_IE_ORIG_ADDR(x) (x + 7) |
40 | #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); |
41 | #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)); |
42 | #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)); |
43 | #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)) |
44 | #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) |
45 | #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)); |
46 | 65 | ||
47 | 66 | ||
48 | #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) | 67 | #define PREP_IE_FLAGS(x) PREQ_IE_FLAGS(x) |
49 | #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) | 68 | #define PREP_IE_HOPCOUNT(x) PREQ_IE_HOPCOUNT(x) |
50 | #define PREP_IE_TTL(x) PREQ_IE_TTL(x) | 69 | #define PREP_IE_TTL(x) PREQ_IE_TTL(x) |
51 | #define PREP_IE_ORIG_ADDR(x) (x + 3) | 70 | #define PREP_IE_ORIG_ADDR(x) (x + 3) |
52 | #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); |
53 | #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)); |
54 | #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)); |
55 | #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) |
56 | #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)); |
57 | 76 | ||
58 | #define PERR_IE_DST_ADDR(x) (x + 2) | 77 | #define PERR_IE_TTL(x) (*(x)) |
59 | #define PERR_IE_DST_DSN(x) u32_field_get(x, 8, 0); | 78 | #define PERR_IE_TARGET_FLAGS(x) (*(x + 2)) |
79 | #define PERR_IE_TARGET_ADDR(x) (x + 3) | ||
80 | #define PERR_IE_TARGET_SN(x) u32_field_get(x, 9, 0); | ||
81 | #define PERR_IE_TARGET_RCODE(x) u16_field_get(x, 13, 0); | ||
60 | 82 | ||
61 | #define MSEC_TO_TU(x) (x*1000/1024) | 83 | #define MSEC_TO_TU(x) (x*1000/1024) |
62 | #define DSN_GT(x, y) ((long) (y) - (long) (x) < 0) | 84 | #define SN_GT(x, y) ((long) (y) - (long) (x) < 0) |
63 | #define DSN_LT(x, y) ((long) (x) - (long) (y) < 0) | 85 | #define SN_LT(x, y) ((long) (x) - (long) (y) < 0) |
64 | 86 | ||
65 | #define net_traversal_jiffies(s) \ | 87 | #define net_traversal_jiffies(s) \ |
66 | msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) | 88 | msecs_to_jiffies(s->u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime) |
@@ -75,13 +97,17 @@ static inline u32 u32_field_get(u8 *preq_elem, int offset, bool ae) | |||
75 | enum mpath_frame_type { | 97 | enum mpath_frame_type { |
76 | MPATH_PREQ = 0, | 98 | MPATH_PREQ = 0, |
77 | MPATH_PREP, | 99 | MPATH_PREP, |
78 | MPATH_PERR | 100 | MPATH_PERR, |
101 | MPATH_RANN | ||
79 | }; | 102 | }; |
80 | 103 | ||
104 | static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; | ||
105 | |||
81 | static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | 106 | static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, |
82 | u8 *orig_addr, __le32 orig_dsn, u8 dst_flags, u8 *dst, | 107 | u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target, |
83 | __le32 dst_dsn, u8 *da, u8 hop_count, u8 ttl, __le32 lifetime, | 108 | __le32 target_sn, const u8 *da, u8 hop_count, u8 ttl, |
84 | __le32 metric, __le32 preq_id, struct ieee80211_sub_if_data *sdata) | 109 | __le32 lifetime, __le32 metric, __le32 preq_id, |
110 | struct ieee80211_sub_if_data *sdata) | ||
85 | { | 111 | { |
86 | struct ieee80211_local *local = sdata->local; | 112 | struct ieee80211_local *local = sdata->local; |
87 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | 113 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
@@ -103,21 +129,30 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
103 | 129 | ||
104 | memcpy(mgmt->da, da, ETH_ALEN); | 130 | memcpy(mgmt->da, da, ETH_ALEN); |
105 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 131 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
106 | /* BSSID is left zeroed, wildcard value */ | 132 | /* BSSID == SA */ |
133 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | ||
107 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 134 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
108 | mgmt->u.action.u.mesh_action.action_code = action; | 135 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
109 | 136 | ||
110 | switch (action) { | 137 | switch (action) { |
111 | case MPATH_PREQ: | 138 | case MPATH_PREQ: |
139 | mhwmp_dbg("sending PREQ to %pM\n", target); | ||
112 | ie_len = 37; | 140 | ie_len = 37; |
113 | pos = skb_put(skb, 2 + ie_len); | 141 | pos = skb_put(skb, 2 + ie_len); |
114 | *pos++ = WLAN_EID_PREQ; | 142 | *pos++ = WLAN_EID_PREQ; |
115 | break; | 143 | break; |
116 | case MPATH_PREP: | 144 | case MPATH_PREP: |
145 | mhwmp_dbg("sending PREP to %pM\n", target); | ||
117 | ie_len = 31; | 146 | ie_len = 31; |
118 | pos = skb_put(skb, 2 + ie_len); | 147 | pos = skb_put(skb, 2 + ie_len); |
119 | *pos++ = WLAN_EID_PREP; | 148 | *pos++ = WLAN_EID_PREP; |
120 | break; | 149 | break; |
150 | case MPATH_RANN: | ||
151 | mhwmp_dbg("sending RANN from %pM\n", orig_addr); | ||
152 | ie_len = sizeof(struct ieee80211_rann_ie); | ||
153 | pos = skb_put(skb, 2 + ie_len); | ||
154 | *pos++ = WLAN_EID_RANN; | ||
155 | break; | ||
121 | default: | 156 | default: |
122 | kfree_skb(skb); | 157 | kfree_skb(skb); |
123 | return -ENOTSUPP; | 158 | return -ENOTSUPP; |
@@ -133,34 +168,40 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
133 | } | 168 | } |
134 | memcpy(pos, orig_addr, ETH_ALEN); | 169 | memcpy(pos, orig_addr, ETH_ALEN); |
135 | pos += ETH_ALEN; | 170 | pos += ETH_ALEN; |
136 | memcpy(pos, &orig_dsn, 4); | 171 | memcpy(pos, &orig_sn, 4); |
137 | pos += 4; | ||
138 | memcpy(pos, &lifetime, 4); | ||
139 | pos += 4; | 172 | pos += 4; |
173 | if (action != MPATH_RANN) { | ||
174 | memcpy(pos, &lifetime, 4); | ||
175 | pos += 4; | ||
176 | } | ||
140 | memcpy(pos, &metric, 4); | 177 | memcpy(pos, &metric, 4); |
141 | pos += 4; | 178 | pos += 4; |
142 | if (action == MPATH_PREQ) { | 179 | if (action == MPATH_PREQ) { |
143 | /* destination count */ | 180 | /* destination count */ |
144 | *pos++ = 1; | 181 | *pos++ = 1; |
145 | *pos++ = dst_flags; | 182 | *pos++ = target_flags; |
183 | } | ||
184 | if (action != MPATH_RANN) { | ||
185 | memcpy(pos, target, ETH_ALEN); | ||
186 | pos += ETH_ALEN; | ||
187 | memcpy(pos, &target_sn, 4); | ||
146 | } | 188 | } |
147 | memcpy(pos, dst, ETH_ALEN); | ||
148 | pos += ETH_ALEN; | ||
149 | memcpy(pos, &dst_dsn, 4); | ||
150 | 189 | ||
151 | ieee80211_tx_skb(sdata, skb, 1); | 190 | ieee80211_tx_skb(sdata, skb); |
152 | return 0; | 191 | return 0; |
153 | } | 192 | } |
154 | 193 | ||
155 | /** | 194 | /** |
156 | * mesh_send_path error - Sends a PERR mesh management frame | 195 | * mesh_send_path error - Sends a PERR mesh management frame |
157 | * | 196 | * |
158 | * @dst: broken destination | 197 | * @target: broken destination |
159 | * @dst_dsn: dsn of the broken destination | 198 | * @target_sn: SN of the broken destination |
199 | * @target_rcode: reason code for this PERR | ||
160 | * @ra: node this frame is addressed to | 200 | * @ra: node this frame is addressed to |
161 | */ | 201 | */ |
162 | int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | 202 | int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, |
163 | struct ieee80211_sub_if_data *sdata) | 203 | __le16 target_rcode, const u8 *ra, |
204 | struct ieee80211_sub_if_data *sdata) | ||
164 | { | 205 | { |
165 | struct ieee80211_local *local = sdata->local; | 206 | struct ieee80211_local *local = sdata->local; |
166 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | 207 | struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); |
@@ -184,20 +225,32 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | |||
184 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 225 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
185 | /* BSSID is left zeroed, wildcard value */ | 226 | /* BSSID is left zeroed, wildcard value */ |
186 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 227 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
187 | mgmt->u.action.u.mesh_action.action_code = MPATH_PERR; | 228 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
188 | ie_len = 12; | 229 | ie_len = 15; |
189 | pos = skb_put(skb, 2 + ie_len); | 230 | pos = skb_put(skb, 2 + ie_len); |
190 | *pos++ = WLAN_EID_PERR; | 231 | *pos++ = WLAN_EID_PERR; |
191 | *pos++ = ie_len; | 232 | *pos++ = ie_len; |
192 | /* mode flags, reserved */ | 233 | /* ttl */ |
193 | *pos++ = 0; | 234 | *pos++ = MESH_TTL; |
194 | /* number of destinations */ | 235 | /* number of destinations */ |
195 | *pos++ = 1; | 236 | *pos++ = 1; |
196 | memcpy(pos, dst, ETH_ALEN); | 237 | /* |
238 | * flags bit, bit 1 is unset if we know the sequence number and | ||
239 | * bit 2 is set if we have a reason code | ||
240 | */ | ||
241 | *pos = 0; | ||
242 | if (!target_sn) | ||
243 | *pos |= MP_F_USN; | ||
244 | if (target_rcode) | ||
245 | *pos |= MP_F_RCODE; | ||
246 | pos++; | ||
247 | memcpy(pos, target, ETH_ALEN); | ||
197 | pos += ETH_ALEN; | 248 | pos += ETH_ALEN; |
198 | memcpy(pos, &dst_dsn, 4); | 249 | memcpy(pos, &target_sn, 4); |
250 | pos += 4; | ||
251 | memcpy(pos, &target_rcode, 2); | ||
199 | 252 | ||
200 | ieee80211_tx_skb(sdata, skb, 1); | 253 | ieee80211_tx_skb(sdata, skb); |
201 | return 0; | 254 | return 0; |
202 | } | 255 | } |
203 | 256 | ||
@@ -269,18 +322,17 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, | |||
269 | */ | 322 | */ |
270 | static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | 323 | static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, |
271 | struct ieee80211_mgmt *mgmt, | 324 | struct ieee80211_mgmt *mgmt, |
272 | u8 *hwmp_ie) | 325 | u8 *hwmp_ie, enum mpath_frame_type action) |
273 | { | 326 | { |
274 | struct ieee80211_local *local = sdata->local; | 327 | struct ieee80211_local *local = sdata->local; |
275 | struct mesh_path *mpath; | 328 | struct mesh_path *mpath; |
276 | struct sta_info *sta; | 329 | struct sta_info *sta; |
277 | bool fresh_info; | 330 | bool fresh_info; |
278 | u8 *orig_addr, *ta; | 331 | u8 *orig_addr, *ta; |
279 | u32 orig_dsn, orig_metric; | 332 | u32 orig_sn, orig_metric; |
280 | unsigned long orig_lifetime, exp_time; | 333 | unsigned long orig_lifetime, exp_time; |
281 | u32 last_hop_metric, new_metric; | 334 | u32 last_hop_metric, new_metric; |
282 | bool process = true; | 335 | bool process = true; |
283 | u8 action = mgmt->u.action.u.mesh_action.action_code; | ||
284 | 336 | ||
285 | rcu_read_lock(); | 337 | rcu_read_lock(); |
286 | sta = sta_info_get(local, mgmt->sa); | 338 | sta = sta_info_get(local, mgmt->sa); |
@@ -296,7 +348,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
296 | switch (action) { | 348 | switch (action) { |
297 | case MPATH_PREQ: | 349 | case MPATH_PREQ: |
298 | orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); | 350 | orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); |
299 | orig_dsn = PREQ_IE_ORIG_DSN(hwmp_ie); | 351 | orig_sn = PREQ_IE_ORIG_SN(hwmp_ie); |
300 | orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); | 352 | orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); |
301 | orig_metric = PREQ_IE_METRIC(hwmp_ie); | 353 | orig_metric = PREQ_IE_METRIC(hwmp_ie); |
302 | break; | 354 | break; |
@@ -309,7 +361,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
309 | * information from both PREQ and PREP frames. | 361 | * information from both PREQ and PREP frames. |
310 | */ | 362 | */ |
311 | orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); | 363 | orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); |
312 | orig_dsn = PREP_IE_ORIG_DSN(hwmp_ie); | 364 | orig_sn = PREP_IE_ORIG_SN(hwmp_ie); |
313 | orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); | 365 | orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); |
314 | orig_metric = PREP_IE_METRIC(hwmp_ie); | 366 | orig_metric = PREP_IE_METRIC(hwmp_ie); |
315 | break; | 367 | break; |
@@ -335,9 +387,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
335 | if (mpath->flags & MESH_PATH_FIXED) | 387 | if (mpath->flags & MESH_PATH_FIXED) |
336 | fresh_info = false; | 388 | fresh_info = false; |
337 | else if ((mpath->flags & MESH_PATH_ACTIVE) && | 389 | else if ((mpath->flags & MESH_PATH_ACTIVE) && |
338 | (mpath->flags & MESH_PATH_DSN_VALID)) { | 390 | (mpath->flags & MESH_PATH_SN_VALID)) { |
339 | if (DSN_GT(mpath->dsn, orig_dsn) || | 391 | if (SN_GT(mpath->sn, orig_sn) || |
340 | (mpath->dsn == orig_dsn && | 392 | (mpath->sn == orig_sn && |
341 | action == MPATH_PREQ && | 393 | action == MPATH_PREQ && |
342 | new_metric > mpath->metric)) { | 394 | new_metric > mpath->metric)) { |
343 | process = false; | 395 | process = false; |
@@ -356,9 +408,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
356 | 408 | ||
357 | if (fresh_info) { | 409 | if (fresh_info) { |
358 | mesh_path_assign_nexthop(mpath, sta); | 410 | mesh_path_assign_nexthop(mpath, sta); |
359 | mpath->flags |= MESH_PATH_DSN_VALID; | 411 | mpath->flags |= MESH_PATH_SN_VALID; |
360 | mpath->metric = new_metric; | 412 | mpath->metric = new_metric; |
361 | mpath->dsn = orig_dsn; | 413 | mpath->sn = orig_sn; |
362 | mpath->exp_time = time_after(mpath->exp_time, exp_time) | 414 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
363 | ? mpath->exp_time : exp_time; | 415 | ? mpath->exp_time : exp_time; |
364 | mesh_path_activate(mpath); | 416 | mesh_path_activate(mpath); |
@@ -397,7 +449,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
397 | 449 | ||
398 | if (fresh_info) { | 450 | if (fresh_info) { |
399 | mesh_path_assign_nexthop(mpath, sta); | 451 | mesh_path_assign_nexthop(mpath, sta); |
400 | mpath->flags &= ~MESH_PATH_DSN_VALID; | 452 | mpath->flags &= ~MESH_PATH_SN_VALID; |
401 | mpath->metric = last_hop_metric; | 453 | mpath->metric = last_hop_metric; |
402 | mpath->exp_time = time_after(mpath->exp_time, exp_time) | 454 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
403 | ? mpath->exp_time : exp_time; | 455 | ? mpath->exp_time : exp_time; |
@@ -419,44 +471,47 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
419 | { | 471 | { |
420 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 472 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
421 | struct mesh_path *mpath; | 473 | struct mesh_path *mpath; |
422 | u8 *dst_addr, *orig_addr; | 474 | u8 *target_addr, *orig_addr; |
423 | u8 dst_flags, ttl; | 475 | u8 target_flags, ttl; |
424 | u32 orig_dsn, dst_dsn, lifetime; | 476 | u32 orig_sn, target_sn, lifetime; |
425 | bool reply = false; | 477 | bool reply = false; |
426 | bool forward = true; | 478 | bool forward = true; |
427 | 479 | ||
428 | /* Update destination DSN, if present */ | 480 | /* Update target SN, if present */ |
429 | dst_addr = PREQ_IE_DST_ADDR(preq_elem); | 481 | target_addr = PREQ_IE_TARGET_ADDR(preq_elem); |
430 | orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); | 482 | orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); |
431 | dst_dsn = PREQ_IE_DST_DSN(preq_elem); | 483 | target_sn = PREQ_IE_TARGET_SN(preq_elem); |
432 | orig_dsn = PREQ_IE_ORIG_DSN(preq_elem); | 484 | orig_sn = PREQ_IE_ORIG_SN(preq_elem); |
433 | dst_flags = PREQ_IE_DST_F(preq_elem); | 485 | target_flags = PREQ_IE_TARGET_F(preq_elem); |
434 | 486 | ||
435 | if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | 487 | mhwmp_dbg("received PREQ from %pM\n", orig_addr); |
488 | |||
489 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | ||
490 | mhwmp_dbg("PREQ is for us\n"); | ||
436 | forward = false; | 491 | forward = false; |
437 | reply = true; | 492 | reply = true; |
438 | metric = 0; | 493 | metric = 0; |
439 | if (time_after(jiffies, ifmsh->last_dsn_update + | 494 | if (time_after(jiffies, ifmsh->last_sn_update + |
440 | net_traversal_jiffies(sdata)) || | 495 | net_traversal_jiffies(sdata)) || |
441 | time_before(jiffies, ifmsh->last_dsn_update)) { | 496 | time_before(jiffies, ifmsh->last_sn_update)) { |
442 | dst_dsn = ++ifmsh->dsn; | 497 | target_sn = ++ifmsh->sn; |
443 | ifmsh->last_dsn_update = jiffies; | 498 | ifmsh->last_sn_update = jiffies; |
444 | } | 499 | } |
445 | } else { | 500 | } else { |
446 | rcu_read_lock(); | 501 | rcu_read_lock(); |
447 | mpath = mesh_path_lookup(dst_addr, sdata); | 502 | mpath = mesh_path_lookup(target_addr, sdata); |
448 | if (mpath) { | 503 | if (mpath) { |
449 | if ((!(mpath->flags & MESH_PATH_DSN_VALID)) || | 504 | if ((!(mpath->flags & MESH_PATH_SN_VALID)) || |
450 | DSN_LT(mpath->dsn, dst_dsn)) { | 505 | SN_LT(mpath->sn, target_sn)) { |
451 | mpath->dsn = dst_dsn; | 506 | mpath->sn = target_sn; |
452 | mpath->flags |= MESH_PATH_DSN_VALID; | 507 | mpath->flags |= MESH_PATH_SN_VALID; |
453 | } else if ((!(dst_flags & MP_F_DO)) && | 508 | } else if ((!(target_flags & MP_F_DO)) && |
454 | (mpath->flags & MESH_PATH_ACTIVE)) { | 509 | (mpath->flags & MESH_PATH_ACTIVE)) { |
455 | reply = true; | 510 | reply = true; |
456 | metric = mpath->metric; | 511 | metric = mpath->metric; |
457 | dst_dsn = mpath->dsn; | 512 | target_sn = mpath->sn; |
458 | if (dst_flags & MP_F_RF) | 513 | if (target_flags & MP_F_RF) |
459 | dst_flags |= MP_F_DO; | 514 | target_flags |= MP_F_DO; |
460 | else | 515 | else |
461 | forward = false; | 516 | forward = false; |
462 | } | 517 | } |
@@ -467,13 +522,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
467 | if (reply) { | 522 | if (reply) { |
468 | lifetime = PREQ_IE_LIFETIME(preq_elem); | 523 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
469 | ttl = ifmsh->mshcfg.dot11MeshTTL; | 524 | ttl = ifmsh->mshcfg.dot11MeshTTL; |
470 | if (ttl != 0) | 525 | if (ttl != 0) { |
471 | mesh_path_sel_frame_tx(MPATH_PREP, 0, dst_addr, | 526 | mhwmp_dbg("replying to the PREQ\n"); |
472 | cpu_to_le32(dst_dsn), 0, orig_addr, | 527 | mesh_path_sel_frame_tx(MPATH_PREP, 0, target_addr, |
473 | cpu_to_le32(orig_dsn), mgmt->sa, 0, ttl, | 528 | cpu_to_le32(target_sn), 0, orig_addr, |
529 | cpu_to_le32(orig_sn), mgmt->sa, 0, ttl, | ||
474 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 530 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
475 | 0, sdata); | 531 | 0, sdata); |
476 | else | 532 | } else |
477 | ifmsh->mshstats.dropped_frames_ttl++; | 533 | ifmsh->mshstats.dropped_frames_ttl++; |
478 | } | 534 | } |
479 | 535 | ||
@@ -487,13 +543,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
487 | ifmsh->mshstats.dropped_frames_ttl++; | 543 | ifmsh->mshstats.dropped_frames_ttl++; |
488 | return; | 544 | return; |
489 | } | 545 | } |
546 | mhwmp_dbg("forwarding the PREQ from %pM\n", orig_addr); | ||
490 | --ttl; | 547 | --ttl; |
491 | flags = PREQ_IE_FLAGS(preq_elem); | 548 | flags = PREQ_IE_FLAGS(preq_elem); |
492 | preq_id = PREQ_IE_PREQ_ID(preq_elem); | 549 | preq_id = PREQ_IE_PREQ_ID(preq_elem); |
493 | hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; | 550 | hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; |
494 | mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, | 551 | mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, |
495 | cpu_to_le32(orig_dsn), dst_flags, dst_addr, | 552 | cpu_to_le32(orig_sn), target_flags, target_addr, |
496 | cpu_to_le32(dst_dsn), sdata->dev->broadcast, | 553 | cpu_to_le32(target_sn), broadcast_addr, |
497 | hopcount, ttl, cpu_to_le32(lifetime), | 554 | hopcount, ttl, cpu_to_le32(lifetime), |
498 | cpu_to_le32(metric), cpu_to_le32(preq_id), | 555 | cpu_to_le32(metric), cpu_to_le32(preq_id), |
499 | sdata); | 556 | sdata); |
@@ -508,10 +565,12 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
508 | u8 *prep_elem, u32 metric) | 565 | u8 *prep_elem, u32 metric) |
509 | { | 566 | { |
510 | struct mesh_path *mpath; | 567 | struct mesh_path *mpath; |
511 | u8 *dst_addr, *orig_addr; | 568 | u8 *target_addr, *orig_addr; |
512 | u8 ttl, hopcount, flags; | 569 | u8 ttl, hopcount, flags; |
513 | u8 next_hop[ETH_ALEN]; | 570 | u8 next_hop[ETH_ALEN]; |
514 | u32 dst_dsn, orig_dsn, lifetime; | 571 | u32 target_sn, orig_sn, lifetime; |
572 | |||
573 | mhwmp_dbg("received PREP from %pM\n", PREP_IE_ORIG_ADDR(prep_elem)); | ||
515 | 574 | ||
516 | /* Note that we divert from the draft nomenclature and denominate | 575 | /* Note that we divert from the draft nomenclature and denominate |
517 | * destination to what the draft refers to as origininator. So in this | 576 | * destination to what the draft refers to as origininator. So in this |
@@ -519,8 +578,8 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
519 | * which corresponds with the originator of the PREQ which this PREP | 578 | * which corresponds with the originator of the PREQ which this PREP |
520 | * replies | 579 | * replies |
521 | */ | 580 | */ |
522 | dst_addr = PREP_IE_DST_ADDR(prep_elem); | 581 | target_addr = PREP_IE_TARGET_ADDR(prep_elem); |
523 | if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) | 582 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) |
524 | /* destination, no forwarding required */ | 583 | /* destination, no forwarding required */ |
525 | return; | 584 | return; |
526 | 585 | ||
@@ -531,7 +590,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
531 | } | 590 | } |
532 | 591 | ||
533 | rcu_read_lock(); | 592 | rcu_read_lock(); |
534 | mpath = mesh_path_lookup(dst_addr, sdata); | 593 | mpath = mesh_path_lookup(target_addr, sdata); |
535 | if (mpath) | 594 | if (mpath) |
536 | spin_lock_bh(&mpath->state_lock); | 595 | spin_lock_bh(&mpath->state_lock); |
537 | else | 596 | else |
@@ -547,13 +606,13 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
547 | lifetime = PREP_IE_LIFETIME(prep_elem); | 606 | lifetime = PREP_IE_LIFETIME(prep_elem); |
548 | hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; | 607 | hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; |
549 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); | 608 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); |
550 | dst_dsn = PREP_IE_DST_DSN(prep_elem); | 609 | target_sn = PREP_IE_TARGET_SN(prep_elem); |
551 | orig_dsn = PREP_IE_ORIG_DSN(prep_elem); | 610 | orig_sn = PREP_IE_ORIG_SN(prep_elem); |
552 | 611 | ||
553 | mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, | 612 | mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, |
554 | cpu_to_le32(orig_dsn), 0, dst_addr, | 613 | cpu_to_le32(orig_sn), 0, target_addr, |
555 | cpu_to_le32(dst_dsn), mpath->next_hop->sta.addr, hopcount, ttl, | 614 | cpu_to_le32(target_sn), mpath->next_hop->sta.addr, hopcount, |
556 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 615 | ttl, cpu_to_le32(lifetime), cpu_to_le32(metric), |
557 | 0, sdata); | 616 | 0, sdata); |
558 | rcu_read_unlock(); | 617 | rcu_read_unlock(); |
559 | 618 | ||
@@ -570,32 +629,96 @@ fail: | |||
570 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | 629 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, |
571 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) | 630 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) |
572 | { | 631 | { |
632 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
573 | struct mesh_path *mpath; | 633 | struct mesh_path *mpath; |
574 | u8 *ta, *dst_addr; | 634 | u8 ttl; |
575 | u32 dst_dsn; | 635 | u8 *ta, *target_addr; |
636 | u8 target_flags; | ||
637 | u32 target_sn; | ||
638 | u16 target_rcode; | ||
576 | 639 | ||
577 | ta = mgmt->sa; | 640 | ta = mgmt->sa; |
578 | dst_addr = PERR_IE_DST_ADDR(perr_elem); | 641 | ttl = PERR_IE_TTL(perr_elem); |
579 | dst_dsn = PERR_IE_DST_DSN(perr_elem); | 642 | if (ttl <= 1) { |
643 | ifmsh->mshstats.dropped_frames_ttl++; | ||
644 | return; | ||
645 | } | ||
646 | ttl--; | ||
647 | target_flags = PERR_IE_TARGET_FLAGS(perr_elem); | ||
648 | target_addr = PERR_IE_TARGET_ADDR(perr_elem); | ||
649 | target_sn = PERR_IE_TARGET_SN(perr_elem); | ||
650 | target_rcode = PERR_IE_TARGET_RCODE(perr_elem); | ||
651 | |||
580 | rcu_read_lock(); | 652 | rcu_read_lock(); |
581 | mpath = mesh_path_lookup(dst_addr, sdata); | 653 | mpath = mesh_path_lookup(target_addr, sdata); |
582 | if (mpath) { | 654 | if (mpath) { |
583 | spin_lock_bh(&mpath->state_lock); | 655 | spin_lock_bh(&mpath->state_lock); |
584 | if (mpath->flags & MESH_PATH_ACTIVE && | 656 | if (mpath->flags & MESH_PATH_ACTIVE && |
585 | memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && | 657 | memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && |
586 | (!(mpath->flags & MESH_PATH_DSN_VALID) || | 658 | (!(mpath->flags & MESH_PATH_SN_VALID) || |
587 | DSN_GT(dst_dsn, mpath->dsn))) { | 659 | SN_GT(target_sn, mpath->sn))) { |
588 | mpath->flags &= ~MESH_PATH_ACTIVE; | 660 | mpath->flags &= ~MESH_PATH_ACTIVE; |
589 | mpath->dsn = dst_dsn; | 661 | mpath->sn = target_sn; |
590 | spin_unlock_bh(&mpath->state_lock); | 662 | spin_unlock_bh(&mpath->state_lock); |
591 | mesh_path_error_tx(dst_addr, cpu_to_le32(dst_dsn), | 663 | mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), |
592 | sdata->dev->broadcast, sdata); | 664 | cpu_to_le16(target_rcode), |
665 | broadcast_addr, sdata); | ||
593 | } else | 666 | } else |
594 | spin_unlock_bh(&mpath->state_lock); | 667 | spin_unlock_bh(&mpath->state_lock); |
595 | } | 668 | } |
596 | rcu_read_unlock(); | 669 | rcu_read_unlock(); |
597 | } | 670 | } |
598 | 671 | ||
672 | static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, | ||
673 | struct ieee80211_mgmt *mgmt, | ||
674 | struct ieee80211_rann_ie *rann) | ||
675 | { | ||
676 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
677 | struct mesh_path *mpath; | ||
678 | u8 *ta; | ||
679 | u8 ttl, flags, hopcount; | ||
680 | u8 *orig_addr; | ||
681 | u32 orig_sn, metric; | ||
682 | |||
683 | ta = mgmt->sa; | ||
684 | ttl = rann->rann_ttl; | ||
685 | if (ttl <= 1) { | ||
686 | ifmsh->mshstats.dropped_frames_ttl++; | ||
687 | return; | ||
688 | } | ||
689 | ttl--; | ||
690 | flags = rann->rann_flags; | ||
691 | orig_addr = rann->rann_addr; | ||
692 | orig_sn = rann->rann_seq; | ||
693 | hopcount = rann->rann_hopcount; | ||
694 | hopcount++; | ||
695 | metric = rann->rann_metric; | ||
696 | mhwmp_dbg("received RANN from %pM\n", orig_addr); | ||
697 | |||
698 | rcu_read_lock(); | ||
699 | mpath = mesh_path_lookup(orig_addr, sdata); | ||
700 | if (!mpath) { | ||
701 | mesh_path_add(orig_addr, sdata); | ||
702 | mpath = mesh_path_lookup(orig_addr, sdata); | ||
703 | if (!mpath) { | ||
704 | rcu_read_unlock(); | ||
705 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | ||
706 | return; | ||
707 | } | ||
708 | mesh_queue_preq(mpath, | ||
709 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); | ||
710 | } | ||
711 | if (mpath->sn < orig_sn) { | ||
712 | mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, | ||
713 | cpu_to_le32(orig_sn), | ||
714 | 0, NULL, 0, broadcast_addr, | ||
715 | hopcount, ttl, 0, | ||
716 | cpu_to_le32(metric + mpath->metric), | ||
717 | 0, sdata); | ||
718 | mpath->sn = orig_sn; | ||
719 | } | ||
720 | rcu_read_unlock(); | ||
721 | } | ||
599 | 722 | ||
600 | 723 | ||
601 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | 724 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, |
@@ -614,34 +737,34 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | |||
614 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, | 737 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, |
615 | len - baselen, &elems); | 738 | len - baselen, &elems); |
616 | 739 | ||
617 | switch (mgmt->u.action.u.mesh_action.action_code) { | 740 | if (elems.preq) { |
618 | case MPATH_PREQ: | 741 | if (elems.preq_len != 37) |
619 | if (!elems.preq || elems.preq_len != 37) | ||
620 | /* Right now we support just 1 destination and no AE */ | 742 | /* Right now we support just 1 destination and no AE */ |
621 | return; | 743 | return; |
622 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq); | 744 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq, |
623 | if (!last_hop_metric) | 745 | MPATH_PREQ); |
624 | return; | 746 | if (last_hop_metric) |
625 | hwmp_preq_frame_process(sdata, mgmt, elems.preq, last_hop_metric); | 747 | hwmp_preq_frame_process(sdata, mgmt, elems.preq, |
626 | break; | 748 | last_hop_metric); |
627 | case MPATH_PREP: | 749 | } |
628 | if (!elems.prep || elems.prep_len != 31) | 750 | if (elems.prep) { |
751 | if (elems.prep_len != 31) | ||
629 | /* Right now we support no AE */ | 752 | /* Right now we support no AE */ |
630 | return; | 753 | return; |
631 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep); | 754 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep, |
632 | if (!last_hop_metric) | 755 | MPATH_PREP); |
633 | return; | 756 | if (last_hop_metric) |
634 | hwmp_prep_frame_process(sdata, mgmt, elems.prep, last_hop_metric); | 757 | hwmp_prep_frame_process(sdata, mgmt, elems.prep, |
635 | break; | 758 | last_hop_metric); |
636 | case MPATH_PERR: | 759 | } |
637 | if (!elems.perr || elems.perr_len != 12) | 760 | if (elems.perr) { |
761 | if (elems.perr_len != 15) | ||
638 | /* Right now we support only one destination per PERR */ | 762 | /* Right now we support only one destination per PERR */ |
639 | return; | 763 | return; |
640 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); | 764 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); |
641 | default: | ||
642 | return; | ||
643 | } | 765 | } |
644 | 766 | if (elems.rann) | |
767 | hwmp_rann_frame_process(sdata, mgmt, elems.rann); | ||
645 | } | 768 | } |
646 | 769 | ||
647 | /** | 770 | /** |
@@ -661,7 +784,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
661 | 784 | ||
662 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); | 785 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); |
663 | if (!preq_node) { | 786 | if (!preq_node) { |
664 | printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n"); | 787 | mhwmp_dbg("could not allocate PREQ node\n"); |
665 | return; | 788 | return; |
666 | } | 789 | } |
667 | 790 | ||
@@ -670,7 +793,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
670 | spin_unlock(&ifmsh->mesh_preq_queue_lock); | 793 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
671 | kfree(preq_node); | 794 | kfree(preq_node); |
672 | if (printk_ratelimit()) | 795 | if (printk_ratelimit()) |
673 | printk(KERN_DEBUG "Mesh HWMP: PREQ node queue full\n"); | 796 | mhwmp_dbg("PREQ node queue full\n"); |
674 | return; | 797 | return; |
675 | } | 798 | } |
676 | 799 | ||
@@ -705,7 +828,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
705 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 828 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
706 | struct mesh_preq_queue *preq_node; | 829 | struct mesh_preq_queue *preq_node; |
707 | struct mesh_path *mpath; | 830 | struct mesh_path *mpath; |
708 | u8 ttl, dst_flags; | 831 | u8 ttl, target_flags; |
709 | u32 lifetime; | 832 | u32 lifetime; |
710 | 833 | ||
711 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); | 834 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); |
@@ -747,11 +870,11 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
747 | 870 | ||
748 | ifmsh->last_preq = jiffies; | 871 | ifmsh->last_preq = jiffies; |
749 | 872 | ||
750 | if (time_after(jiffies, ifmsh->last_dsn_update + | 873 | if (time_after(jiffies, ifmsh->last_sn_update + |
751 | net_traversal_jiffies(sdata)) || | 874 | net_traversal_jiffies(sdata)) || |
752 | time_before(jiffies, ifmsh->last_dsn_update)) { | 875 | time_before(jiffies, ifmsh->last_sn_update)) { |
753 | ++ifmsh->dsn; | 876 | ++ifmsh->sn; |
754 | sdata->u.mesh.last_dsn_update = jiffies; | 877 | sdata->u.mesh.last_sn_update = jiffies; |
755 | } | 878 | } |
756 | lifetime = default_lifetime(sdata); | 879 | lifetime = default_lifetime(sdata); |
757 | ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; | 880 | ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
@@ -762,14 +885,14 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
762 | } | 885 | } |
763 | 886 | ||
764 | if (preq_node->flags & PREQ_Q_F_REFRESH) | 887 | if (preq_node->flags & PREQ_Q_F_REFRESH) |
765 | dst_flags = MP_F_DO; | 888 | target_flags = MP_F_DO; |
766 | else | 889 | else |
767 | dst_flags = MP_F_RF; | 890 | target_flags = MP_F_RF; |
768 | 891 | ||
769 | spin_unlock_bh(&mpath->state_lock); | 892 | spin_unlock_bh(&mpath->state_lock); |
770 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, | 893 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, |
771 | cpu_to_le32(ifmsh->dsn), dst_flags, mpath->dst, | 894 | cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, |
772 | cpu_to_le32(mpath->dsn), sdata->dev->broadcast, 0, | 895 | cpu_to_le32(mpath->sn), broadcast_addr, 0, |
773 | ttl, cpu_to_le32(lifetime), 0, | 896 | ttl, cpu_to_le32(lifetime), 0, |
774 | cpu_to_le32(ifmsh->preq_id++), sdata); | 897 | cpu_to_le32(ifmsh->preq_id++), sdata); |
775 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); | 898 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); |
@@ -796,15 +919,15 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
796 | struct sk_buff *skb_to_free = NULL; | 919 | struct sk_buff *skb_to_free = NULL; |
797 | struct mesh_path *mpath; | 920 | struct mesh_path *mpath; |
798 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 921 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
799 | u8 *dst_addr = hdr->addr3; | 922 | u8 *target_addr = hdr->addr3; |
800 | int err = 0; | 923 | int err = 0; |
801 | 924 | ||
802 | rcu_read_lock(); | 925 | rcu_read_lock(); |
803 | mpath = mesh_path_lookup(dst_addr, sdata); | 926 | mpath = mesh_path_lookup(target_addr, sdata); |
804 | 927 | ||
805 | if (!mpath) { | 928 | if (!mpath) { |
806 | mesh_path_add(dst_addr, sdata); | 929 | mesh_path_add(target_addr, sdata); |
807 | mpath = mesh_path_lookup(dst_addr, sdata); | 930 | mpath = mesh_path_lookup(target_addr, sdata); |
808 | if (!mpath) { | 931 | if (!mpath) { |
809 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | 932 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
810 | err = -ENOSPC; | 933 | err = -ENOSPC; |
@@ -813,17 +936,16 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
813 | } | 936 | } |
814 | 937 | ||
815 | if (mpath->flags & MESH_PATH_ACTIVE) { | 938 | if (mpath->flags & MESH_PATH_ACTIVE) { |
816 | if (time_after(jiffies, mpath->exp_time + | 939 | if (time_after(jiffies, |
817 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) | 940 | mpath->exp_time + |
818 | && !memcmp(sdata->dev->dev_addr, hdr->addr4, | 941 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && |
819 | ETH_ALEN) | 942 | !memcmp(sdata->dev->dev_addr, hdr->addr4, ETH_ALEN) && |
820 | && !(mpath->flags & MESH_PATH_RESOLVING) | 943 | !(mpath->flags & MESH_PATH_RESOLVING) && |
821 | && !(mpath->flags & MESH_PATH_FIXED)) { | 944 | !(mpath->flags & MESH_PATH_FIXED)) { |
822 | mesh_queue_preq(mpath, | 945 | mesh_queue_preq(mpath, |
823 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); | 946 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); |
824 | } | 947 | } |
825 | memcpy(hdr->addr1, mpath->next_hop->sta.addr, | 948 | memcpy(hdr->addr1, mpath->next_hop->sta.addr, ETH_ALEN); |
826 | ETH_ALEN); | ||
827 | } else { | 949 | } else { |
828 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 950 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
829 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { | 951 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { |
@@ -882,3 +1004,14 @@ void mesh_path_timer(unsigned long data) | |||
882 | endmpathtimer: | 1004 | endmpathtimer: |
883 | rcu_read_unlock(); | 1005 | rcu_read_unlock(); |
884 | } | 1006 | } |
1007 | |||
1008 | void | ||
1009 | mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) | ||
1010 | { | ||
1011 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
1012 | |||
1013 | mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->dev->dev_addr, | ||
1014 | cpu_to_le32(++ifmsh->sn), | ||
1015 | 0, NULL, 0, broadcast_addr, | ||
1016 | 0, MESH_TTL, 0, 0, 0, sdata); | ||
1017 | } | ||