diff options
author | David S. Miller <davem@davemloft.net> | 2009-11-18 13:55:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-18 13:55:32 -0500 |
commit | dfef948ed2ba69cf041840b5e860d6b4e16fa0b1 (patch) | |
tree | eab385cabe589346bcf19385c997ab8dabaef7bd /net/mac80211/mesh_hwmp.c | |
parent | ea31ba359c55e0734ff895692185d4c50cf0c537 (diff) | |
parent | c85e9d7739fc8d879c4293ea020760926d6f87cd (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 388 |
1 files changed, 260 insertions, 128 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 29b82e98effa..5c67e7b8790f 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,15 @@ 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 | ||
81 | static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | 104 | 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, | 105 | u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target, |
83 | __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, |
84 | __le32 metric, __le32 preq_id, struct ieee80211_sub_if_data *sdata) | 107 | __le32 metric, __le32 preq_id, |
108 | struct ieee80211_sub_if_data *sdata) | ||
85 | { | 109 | { |
86 | struct ieee80211_local *local = sdata->local; | 110 | struct ieee80211_local *local = sdata->local; |
87 | 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); |
@@ -103,21 +127,30 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
103 | 127 | ||
104 | memcpy(mgmt->da, da, ETH_ALEN); | 128 | memcpy(mgmt->da, da, ETH_ALEN); |
105 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 129 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
106 | /* BSSID is left zeroed, wildcard value */ | 130 | /* BSSID == SA */ |
131 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | ||
107 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 132 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
108 | mgmt->u.action.u.mesh_action.action_code = action; | 133 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
109 | 134 | ||
110 | switch (action) { | 135 | switch (action) { |
111 | case MPATH_PREQ: | 136 | case MPATH_PREQ: |
137 | mhwmp_dbg("sending PREQ to %pM\n", target); | ||
112 | ie_len = 37; | 138 | ie_len = 37; |
113 | pos = skb_put(skb, 2 + ie_len); | 139 | pos = skb_put(skb, 2 + ie_len); |
114 | *pos++ = WLAN_EID_PREQ; | 140 | *pos++ = WLAN_EID_PREQ; |
115 | break; | 141 | break; |
116 | case MPATH_PREP: | 142 | case MPATH_PREP: |
143 | mhwmp_dbg("sending PREP to %pM\n", target); | ||
117 | ie_len = 31; | 144 | ie_len = 31; |
118 | pos = skb_put(skb, 2 + ie_len); | 145 | pos = skb_put(skb, 2 + ie_len); |
119 | *pos++ = WLAN_EID_PREP; | 146 | *pos++ = WLAN_EID_PREP; |
120 | break; | 147 | break; |
148 | case MPATH_RANN: | ||
149 | mhwmp_dbg("sending RANN from %pM\n", orig_addr); | ||
150 | ie_len = sizeof(struct ieee80211_rann_ie); | ||
151 | pos = skb_put(skb, 2 + ie_len); | ||
152 | *pos++ = WLAN_EID_RANN; | ||
153 | break; | ||
121 | default: | 154 | default: |
122 | kfree_skb(skb); | 155 | kfree_skb(skb); |
123 | return -ENOTSUPP; | 156 | return -ENOTSUPP; |
@@ -133,20 +166,24 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
133 | } | 166 | } |
134 | memcpy(pos, orig_addr, ETH_ALEN); | 167 | memcpy(pos, orig_addr, ETH_ALEN); |
135 | pos += ETH_ALEN; | 168 | pos += ETH_ALEN; |
136 | memcpy(pos, &orig_dsn, 4); | 169 | memcpy(pos, &orig_sn, 4); |
137 | pos += 4; | ||
138 | memcpy(pos, &lifetime, 4); | ||
139 | pos += 4; | 170 | pos += 4; |
171 | if (action != MPATH_RANN) { | ||
172 | memcpy(pos, &lifetime, 4); | ||
173 | pos += 4; | ||
174 | } | ||
140 | memcpy(pos, &metric, 4); | 175 | memcpy(pos, &metric, 4); |
141 | pos += 4; | 176 | pos += 4; |
142 | if (action == MPATH_PREQ) { | 177 | if (action == MPATH_PREQ) { |
143 | /* destination count */ | 178 | /* destination count */ |
144 | *pos++ = 1; | 179 | *pos++ = 1; |
145 | *pos++ = dst_flags; | 180 | *pos++ = target_flags; |
181 | } | ||
182 | if (action != MPATH_RANN) { | ||
183 | memcpy(pos, target, ETH_ALEN); | ||
184 | pos += ETH_ALEN; | ||
185 | memcpy(pos, &target_sn, 4); | ||
146 | } | 186 | } |
147 | memcpy(pos, dst, ETH_ALEN); | ||
148 | pos += ETH_ALEN; | ||
149 | memcpy(pos, &dst_dsn, 4); | ||
150 | 187 | ||
151 | ieee80211_tx_skb(sdata, skb, 1); | 188 | ieee80211_tx_skb(sdata, skb, 1); |
152 | return 0; | 189 | return 0; |
@@ -155,11 +192,13 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
155 | /** | 192 | /** |
156 | * mesh_send_path error - Sends a PERR mesh management frame | 193 | * mesh_send_path error - Sends a PERR mesh management frame |
157 | * | 194 | * |
158 | * @dst: broken destination | 195 | * @target: broken destination |
159 | * @dst_dsn: dsn of the broken destination | 196 | * @target_sn: SN of the broken destination |
197 | * @target_rcode: reason code for this PERR | ||
160 | * @ra: node this frame is addressed to | 198 | * @ra: node this frame is addressed to |
161 | */ | 199 | */ |
162 | int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | 200 | int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, |
201 | __le16 target_rcode, u8 *ra, | ||
163 | struct ieee80211_sub_if_data *sdata) | 202 | struct ieee80211_sub_if_data *sdata) |
164 | { | 203 | { |
165 | struct ieee80211_local *local = sdata->local; | 204 | struct ieee80211_local *local = sdata->local; |
@@ -184,18 +223,30 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | |||
184 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 223 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
185 | /* BSSID is left zeroed, wildcard value */ | 224 | /* BSSID is left zeroed, wildcard value */ |
186 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; | 225 | mgmt->u.action.category = MESH_PATH_SEL_CATEGORY; |
187 | mgmt->u.action.u.mesh_action.action_code = MPATH_PERR; | 226 | mgmt->u.action.u.mesh_action.action_code = MESH_PATH_SEL_ACTION; |
188 | ie_len = 12; | 227 | ie_len = 15; |
189 | pos = skb_put(skb, 2 + ie_len); | 228 | pos = skb_put(skb, 2 + ie_len); |
190 | *pos++ = WLAN_EID_PERR; | 229 | *pos++ = WLAN_EID_PERR; |
191 | *pos++ = ie_len; | 230 | *pos++ = ie_len; |
192 | /* mode flags, reserved */ | 231 | /* ttl */ |
193 | *pos++ = 0; | 232 | *pos++ = MESH_TTL; |
194 | /* number of destinations */ | 233 | /* number of destinations */ |
195 | *pos++ = 1; | 234 | *pos++ = 1; |
196 | memcpy(pos, dst, ETH_ALEN); | 235 | /* |
236 | * flags bit, bit 1 is unset if we know the sequence number and | ||
237 | * bit 2 is set if we have a reason code | ||
238 | */ | ||
239 | *pos = 0; | ||
240 | if (!target_sn) | ||
241 | *pos |= MP_F_USN; | ||
242 | if (target_rcode) | ||
243 | *pos |= MP_F_RCODE; | ||
244 | pos++; | ||
245 | memcpy(pos, target, ETH_ALEN); | ||
197 | pos += ETH_ALEN; | 246 | pos += ETH_ALEN; |
198 | memcpy(pos, &dst_dsn, 4); | 247 | memcpy(pos, &target_sn, 4); |
248 | pos += 4; | ||
249 | memcpy(pos, &target_rcode, 2); | ||
199 | 250 | ||
200 | ieee80211_tx_skb(sdata, skb, 1); | 251 | ieee80211_tx_skb(sdata, skb, 1); |
201 | return 0; | 252 | return 0; |
@@ -269,18 +320,17 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, | |||
269 | */ | 320 | */ |
270 | static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | 321 | static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, |
271 | struct ieee80211_mgmt *mgmt, | 322 | struct ieee80211_mgmt *mgmt, |
272 | u8 *hwmp_ie) | 323 | u8 *hwmp_ie, enum mpath_frame_type action) |
273 | { | 324 | { |
274 | struct ieee80211_local *local = sdata->local; | 325 | struct ieee80211_local *local = sdata->local; |
275 | struct mesh_path *mpath; | 326 | struct mesh_path *mpath; |
276 | struct sta_info *sta; | 327 | struct sta_info *sta; |
277 | bool fresh_info; | 328 | bool fresh_info; |
278 | u8 *orig_addr, *ta; | 329 | u8 *orig_addr, *ta; |
279 | u32 orig_dsn, orig_metric; | 330 | u32 orig_sn, orig_metric; |
280 | unsigned long orig_lifetime, exp_time; | 331 | unsigned long orig_lifetime, exp_time; |
281 | u32 last_hop_metric, new_metric; | 332 | u32 last_hop_metric, new_metric; |
282 | bool process = true; | 333 | bool process = true; |
283 | u8 action = mgmt->u.action.u.mesh_action.action_code; | ||
284 | 334 | ||
285 | rcu_read_lock(); | 335 | rcu_read_lock(); |
286 | sta = sta_info_get(local, mgmt->sa); | 336 | sta = sta_info_get(local, mgmt->sa); |
@@ -296,7 +346,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
296 | switch (action) { | 346 | switch (action) { |
297 | case MPATH_PREQ: | 347 | case MPATH_PREQ: |
298 | orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); | 348 | orig_addr = PREQ_IE_ORIG_ADDR(hwmp_ie); |
299 | orig_dsn = PREQ_IE_ORIG_DSN(hwmp_ie); | 349 | orig_sn = PREQ_IE_ORIG_SN(hwmp_ie); |
300 | orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); | 350 | orig_lifetime = PREQ_IE_LIFETIME(hwmp_ie); |
301 | orig_metric = PREQ_IE_METRIC(hwmp_ie); | 351 | orig_metric = PREQ_IE_METRIC(hwmp_ie); |
302 | break; | 352 | break; |
@@ -309,7 +359,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
309 | * information from both PREQ and PREP frames. | 359 | * information from both PREQ and PREP frames. |
310 | */ | 360 | */ |
311 | orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); | 361 | orig_addr = PREP_IE_ORIG_ADDR(hwmp_ie); |
312 | orig_dsn = PREP_IE_ORIG_DSN(hwmp_ie); | 362 | orig_sn = PREP_IE_ORIG_SN(hwmp_ie); |
313 | orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); | 363 | orig_lifetime = PREP_IE_LIFETIME(hwmp_ie); |
314 | orig_metric = PREP_IE_METRIC(hwmp_ie); | 364 | orig_metric = PREP_IE_METRIC(hwmp_ie); |
315 | break; | 365 | break; |
@@ -335,9 +385,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
335 | if (mpath->flags & MESH_PATH_FIXED) | 385 | if (mpath->flags & MESH_PATH_FIXED) |
336 | fresh_info = false; | 386 | fresh_info = false; |
337 | else if ((mpath->flags & MESH_PATH_ACTIVE) && | 387 | else if ((mpath->flags & MESH_PATH_ACTIVE) && |
338 | (mpath->flags & MESH_PATH_DSN_VALID)) { | 388 | (mpath->flags & MESH_PATH_SN_VALID)) { |
339 | if (DSN_GT(mpath->dsn, orig_dsn) || | 389 | if (SN_GT(mpath->sn, orig_sn) || |
340 | (mpath->dsn == orig_dsn && | 390 | (mpath->sn == orig_sn && |
341 | action == MPATH_PREQ && | 391 | action == MPATH_PREQ && |
342 | new_metric > mpath->metric)) { | 392 | new_metric > mpath->metric)) { |
343 | process = false; | 393 | process = false; |
@@ -356,9 +406,9 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
356 | 406 | ||
357 | if (fresh_info) { | 407 | if (fresh_info) { |
358 | mesh_path_assign_nexthop(mpath, sta); | 408 | mesh_path_assign_nexthop(mpath, sta); |
359 | mpath->flags |= MESH_PATH_DSN_VALID; | 409 | mpath->flags |= MESH_PATH_SN_VALID; |
360 | mpath->metric = new_metric; | 410 | mpath->metric = new_metric; |
361 | mpath->dsn = orig_dsn; | 411 | mpath->sn = orig_sn; |
362 | mpath->exp_time = time_after(mpath->exp_time, exp_time) | 412 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
363 | ? mpath->exp_time : exp_time; | 413 | ? mpath->exp_time : exp_time; |
364 | mesh_path_activate(mpath); | 414 | mesh_path_activate(mpath); |
@@ -397,7 +447,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
397 | 447 | ||
398 | if (fresh_info) { | 448 | if (fresh_info) { |
399 | mesh_path_assign_nexthop(mpath, sta); | 449 | mesh_path_assign_nexthop(mpath, sta); |
400 | mpath->flags &= ~MESH_PATH_DSN_VALID; | 450 | mpath->flags &= ~MESH_PATH_SN_VALID; |
401 | mpath->metric = last_hop_metric; | 451 | mpath->metric = last_hop_metric; |
402 | mpath->exp_time = time_after(mpath->exp_time, exp_time) | 452 | mpath->exp_time = time_after(mpath->exp_time, exp_time) |
403 | ? mpath->exp_time : exp_time; | 453 | ? mpath->exp_time : exp_time; |
@@ -419,44 +469,47 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
419 | { | 469 | { |
420 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 470 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
421 | struct mesh_path *mpath; | 471 | struct mesh_path *mpath; |
422 | u8 *dst_addr, *orig_addr; | 472 | u8 *target_addr, *orig_addr; |
423 | u8 dst_flags, ttl; | 473 | u8 target_flags, ttl; |
424 | u32 orig_dsn, dst_dsn, lifetime; | 474 | u32 orig_sn, target_sn, lifetime; |
425 | bool reply = false; | 475 | bool reply = false; |
426 | bool forward = true; | 476 | bool forward = true; |
427 | 477 | ||
428 | /* Update destination DSN, if present */ | 478 | /* Update target SN, if present */ |
429 | dst_addr = PREQ_IE_DST_ADDR(preq_elem); | 479 | target_addr = PREQ_IE_TARGET_ADDR(preq_elem); |
430 | orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); | 480 | orig_addr = PREQ_IE_ORIG_ADDR(preq_elem); |
431 | dst_dsn = PREQ_IE_DST_DSN(preq_elem); | 481 | target_sn = PREQ_IE_TARGET_SN(preq_elem); |
432 | orig_dsn = PREQ_IE_ORIG_DSN(preq_elem); | 482 | orig_sn = PREQ_IE_ORIG_SN(preq_elem); |
433 | dst_flags = PREQ_IE_DST_F(preq_elem); | 483 | target_flags = PREQ_IE_TARGET_F(preq_elem); |
434 | 484 | ||
435 | if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | 485 | mhwmp_dbg("received PREQ from %pM\n", orig_addr); |
486 | |||
487 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) { | ||
488 | mhwmp_dbg("PREQ is for us\n"); | ||
436 | forward = false; | 489 | forward = false; |
437 | reply = true; | 490 | reply = true; |
438 | metric = 0; | 491 | metric = 0; |
439 | if (time_after(jiffies, ifmsh->last_dsn_update + | 492 | if (time_after(jiffies, ifmsh->last_sn_update + |
440 | net_traversal_jiffies(sdata)) || | 493 | net_traversal_jiffies(sdata)) || |
441 | time_before(jiffies, ifmsh->last_dsn_update)) { | 494 | time_before(jiffies, ifmsh->last_sn_update)) { |
442 | dst_dsn = ++ifmsh->dsn; | 495 | target_sn = ++ifmsh->sn; |
443 | ifmsh->last_dsn_update = jiffies; | 496 | ifmsh->last_sn_update = jiffies; |
444 | } | 497 | } |
445 | } else { | 498 | } else { |
446 | rcu_read_lock(); | 499 | rcu_read_lock(); |
447 | mpath = mesh_path_lookup(dst_addr, sdata); | 500 | mpath = mesh_path_lookup(target_addr, sdata); |
448 | if (mpath) { | 501 | if (mpath) { |
449 | if ((!(mpath->flags & MESH_PATH_DSN_VALID)) || | 502 | if ((!(mpath->flags & MESH_PATH_SN_VALID)) || |
450 | DSN_LT(mpath->dsn, dst_dsn)) { | 503 | SN_LT(mpath->sn, target_sn)) { |
451 | mpath->dsn = dst_dsn; | 504 | mpath->sn = target_sn; |
452 | mpath->flags |= MESH_PATH_DSN_VALID; | 505 | mpath->flags |= MESH_PATH_SN_VALID; |
453 | } else if ((!(dst_flags & MP_F_DO)) && | 506 | } else if ((!(target_flags & MP_F_DO)) && |
454 | (mpath->flags & MESH_PATH_ACTIVE)) { | 507 | (mpath->flags & MESH_PATH_ACTIVE)) { |
455 | reply = true; | 508 | reply = true; |
456 | metric = mpath->metric; | 509 | metric = mpath->metric; |
457 | dst_dsn = mpath->dsn; | 510 | target_sn = mpath->sn; |
458 | if (dst_flags & MP_F_RF) | 511 | if (target_flags & MP_F_RF) |
459 | dst_flags |= MP_F_DO; | 512 | target_flags |= MP_F_DO; |
460 | else | 513 | else |
461 | forward = false; | 514 | forward = false; |
462 | } | 515 | } |
@@ -467,13 +520,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
467 | if (reply) { | 520 | if (reply) { |
468 | lifetime = PREQ_IE_LIFETIME(preq_elem); | 521 | lifetime = PREQ_IE_LIFETIME(preq_elem); |
469 | ttl = ifmsh->mshcfg.dot11MeshTTL; | 522 | ttl = ifmsh->mshcfg.dot11MeshTTL; |
470 | if (ttl != 0) | 523 | if (ttl != 0) { |
471 | mesh_path_sel_frame_tx(MPATH_PREP, 0, dst_addr, | 524 | mhwmp_dbg("replying to the PREQ\n"); |
472 | cpu_to_le32(dst_dsn), 0, orig_addr, | 525 | mesh_path_sel_frame_tx(MPATH_PREP, 0, target_addr, |
473 | cpu_to_le32(orig_dsn), mgmt->sa, 0, ttl, | 526 | cpu_to_le32(target_sn), 0, orig_addr, |
527 | cpu_to_le32(orig_sn), mgmt->sa, 0, ttl, | ||
474 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 528 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
475 | 0, sdata); | 529 | 0, sdata); |
476 | else | 530 | } else |
477 | ifmsh->mshstats.dropped_frames_ttl++; | 531 | ifmsh->mshstats.dropped_frames_ttl++; |
478 | } | 532 | } |
479 | 533 | ||
@@ -487,13 +541,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
487 | ifmsh->mshstats.dropped_frames_ttl++; | 541 | ifmsh->mshstats.dropped_frames_ttl++; |
488 | return; | 542 | return; |
489 | } | 543 | } |
544 | mhwmp_dbg("forwarding the PREQ from %pM\n", orig_addr); | ||
490 | --ttl; | 545 | --ttl; |
491 | flags = PREQ_IE_FLAGS(preq_elem); | 546 | flags = PREQ_IE_FLAGS(preq_elem); |
492 | preq_id = PREQ_IE_PREQ_ID(preq_elem); | 547 | preq_id = PREQ_IE_PREQ_ID(preq_elem); |
493 | hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; | 548 | hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; |
494 | mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, | 549 | mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, |
495 | cpu_to_le32(orig_dsn), dst_flags, dst_addr, | 550 | cpu_to_le32(orig_sn), target_flags, target_addr, |
496 | cpu_to_le32(dst_dsn), sdata->dev->broadcast, | 551 | cpu_to_le32(target_sn), sdata->dev->broadcast, |
497 | hopcount, ttl, cpu_to_le32(lifetime), | 552 | hopcount, ttl, cpu_to_le32(lifetime), |
498 | cpu_to_le32(metric), cpu_to_le32(preq_id), | 553 | cpu_to_le32(metric), cpu_to_le32(preq_id), |
499 | sdata); | 554 | sdata); |
@@ -508,10 +563,12 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
508 | u8 *prep_elem, u32 metric) | 563 | u8 *prep_elem, u32 metric) |
509 | { | 564 | { |
510 | struct mesh_path *mpath; | 565 | struct mesh_path *mpath; |
511 | u8 *dst_addr, *orig_addr; | 566 | u8 *target_addr, *orig_addr; |
512 | u8 ttl, hopcount, flags; | 567 | u8 ttl, hopcount, flags; |
513 | u8 next_hop[ETH_ALEN]; | 568 | u8 next_hop[ETH_ALEN]; |
514 | u32 dst_dsn, orig_dsn, lifetime; | 569 | u32 target_sn, orig_sn, lifetime; |
570 | |||
571 | mhwmp_dbg("received PREP from %pM\n", PREP_IE_ORIG_ADDR(prep_elem)); | ||
515 | 572 | ||
516 | /* Note that we divert from the draft nomenclature and denominate | 573 | /* Note that we divert from the draft nomenclature and denominate |
517 | * destination to what the draft refers to as origininator. So in this | 574 | * destination to what the draft refers to as origininator. So in this |
@@ -519,8 +576,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 | 576 | * which corresponds with the originator of the PREQ which this PREP |
520 | * replies | 577 | * replies |
521 | */ | 578 | */ |
522 | dst_addr = PREP_IE_DST_ADDR(prep_elem); | 579 | target_addr = PREP_IE_TARGET_ADDR(prep_elem); |
523 | if (memcmp(dst_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) | 580 | if (memcmp(target_addr, sdata->dev->dev_addr, ETH_ALEN) == 0) |
524 | /* destination, no forwarding required */ | 581 | /* destination, no forwarding required */ |
525 | return; | 582 | return; |
526 | 583 | ||
@@ -531,7 +588,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
531 | } | 588 | } |
532 | 589 | ||
533 | rcu_read_lock(); | 590 | rcu_read_lock(); |
534 | mpath = mesh_path_lookup(dst_addr, sdata); | 591 | mpath = mesh_path_lookup(target_addr, sdata); |
535 | if (mpath) | 592 | if (mpath) |
536 | spin_lock_bh(&mpath->state_lock); | 593 | spin_lock_bh(&mpath->state_lock); |
537 | else | 594 | else |
@@ -547,13 +604,13 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
547 | lifetime = PREP_IE_LIFETIME(prep_elem); | 604 | lifetime = PREP_IE_LIFETIME(prep_elem); |
548 | hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; | 605 | hopcount = PREP_IE_HOPCOUNT(prep_elem) + 1; |
549 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); | 606 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); |
550 | dst_dsn = PREP_IE_DST_DSN(prep_elem); | 607 | target_sn = PREP_IE_TARGET_SN(prep_elem); |
551 | orig_dsn = PREP_IE_ORIG_DSN(prep_elem); | 608 | orig_sn = PREP_IE_ORIG_SN(prep_elem); |
552 | 609 | ||
553 | mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, | 610 | mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, |
554 | cpu_to_le32(orig_dsn), 0, dst_addr, | 611 | cpu_to_le32(orig_sn), 0, target_addr, |
555 | cpu_to_le32(dst_dsn), mpath->next_hop->sta.addr, hopcount, ttl, | 612 | cpu_to_le32(target_sn), mpath->next_hop->sta.addr, hopcount, |
556 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 613 | ttl, cpu_to_le32(lifetime), cpu_to_le32(metric), |
557 | 0, sdata); | 614 | 0, sdata); |
558 | rcu_read_unlock(); | 615 | rcu_read_unlock(); |
559 | 616 | ||
@@ -570,25 +627,39 @@ fail: | |||
570 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | 627 | static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, |
571 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) | 628 | struct ieee80211_mgmt *mgmt, u8 *perr_elem) |
572 | { | 629 | { |
630 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
573 | struct mesh_path *mpath; | 631 | struct mesh_path *mpath; |
574 | u8 *ta, *dst_addr; | 632 | u8 ttl; |
575 | u32 dst_dsn; | 633 | u8 *ta, *target_addr; |
634 | u8 target_flags; | ||
635 | u32 target_sn; | ||
636 | u16 target_rcode; | ||
576 | 637 | ||
577 | ta = mgmt->sa; | 638 | ta = mgmt->sa; |
578 | dst_addr = PERR_IE_DST_ADDR(perr_elem); | 639 | ttl = PERR_IE_TTL(perr_elem); |
579 | dst_dsn = PERR_IE_DST_DSN(perr_elem); | 640 | if (ttl <= 1) { |
641 | ifmsh->mshstats.dropped_frames_ttl++; | ||
642 | return; | ||
643 | } | ||
644 | ttl--; | ||
645 | target_flags = PERR_IE_TARGET_FLAGS(perr_elem); | ||
646 | target_addr = PERR_IE_TARGET_ADDR(perr_elem); | ||
647 | target_sn = PERR_IE_TARGET_SN(perr_elem); | ||
648 | target_rcode = PERR_IE_TARGET_RCODE(perr_elem); | ||
649 | |||
580 | rcu_read_lock(); | 650 | rcu_read_lock(); |
581 | mpath = mesh_path_lookup(dst_addr, sdata); | 651 | mpath = mesh_path_lookup(target_addr, sdata); |
582 | if (mpath) { | 652 | if (mpath) { |
583 | spin_lock_bh(&mpath->state_lock); | 653 | spin_lock_bh(&mpath->state_lock); |
584 | if (mpath->flags & MESH_PATH_ACTIVE && | 654 | if (mpath->flags & MESH_PATH_ACTIVE && |
585 | memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && | 655 | memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && |
586 | (!(mpath->flags & MESH_PATH_DSN_VALID) || | 656 | (!(mpath->flags & MESH_PATH_SN_VALID) || |
587 | DSN_GT(dst_dsn, mpath->dsn))) { | 657 | SN_GT(target_sn, mpath->sn))) { |
588 | mpath->flags &= ~MESH_PATH_ACTIVE; | 658 | mpath->flags &= ~MESH_PATH_ACTIVE; |
589 | mpath->dsn = dst_dsn; | 659 | mpath->sn = target_sn; |
590 | spin_unlock_bh(&mpath->state_lock); | 660 | spin_unlock_bh(&mpath->state_lock); |
591 | mesh_path_error_tx(dst_addr, cpu_to_le32(dst_dsn), | 661 | mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), |
662 | cpu_to_le16(target_rcode), | ||
592 | sdata->dev->broadcast, sdata); | 663 | sdata->dev->broadcast, sdata); |
593 | } else | 664 | } else |
594 | spin_unlock_bh(&mpath->state_lock); | 665 | spin_unlock_bh(&mpath->state_lock); |
@@ -596,6 +667,56 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | |||
596 | rcu_read_unlock(); | 667 | rcu_read_unlock(); |
597 | } | 668 | } |
598 | 669 | ||
670 | static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, | ||
671 | struct ieee80211_mgmt *mgmt, | ||
672 | struct ieee80211_rann_ie *rann) | ||
673 | { | ||
674 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
675 | struct mesh_path *mpath; | ||
676 | u8 *ta; | ||
677 | u8 ttl, flags, hopcount; | ||
678 | u8 *orig_addr; | ||
679 | u32 orig_sn, metric; | ||
680 | |||
681 | ta = mgmt->sa; | ||
682 | ttl = rann->rann_ttl; | ||
683 | if (ttl <= 1) { | ||
684 | ifmsh->mshstats.dropped_frames_ttl++; | ||
685 | return; | ||
686 | } | ||
687 | ttl--; | ||
688 | flags = rann->rann_flags; | ||
689 | orig_addr = rann->rann_addr; | ||
690 | orig_sn = rann->rann_seq; | ||
691 | hopcount = rann->rann_hopcount; | ||
692 | hopcount++; | ||
693 | metric = rann->rann_metric; | ||
694 | mhwmp_dbg("received RANN from %pM\n", orig_addr); | ||
695 | |||
696 | rcu_read_lock(); | ||
697 | mpath = mesh_path_lookup(orig_addr, sdata); | ||
698 | if (!mpath) { | ||
699 | mesh_path_add(orig_addr, sdata); | ||
700 | mpath = mesh_path_lookup(orig_addr, sdata); | ||
701 | if (!mpath) { | ||
702 | rcu_read_unlock(); | ||
703 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | ||
704 | return; | ||
705 | } | ||
706 | mesh_queue_preq(mpath, | ||
707 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); | ||
708 | } | ||
709 | if (mpath->sn < orig_sn) { | ||
710 | mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, | ||
711 | cpu_to_le32(orig_sn), | ||
712 | 0, NULL, 0, sdata->dev->broadcast, | ||
713 | hopcount, ttl, 0, | ||
714 | cpu_to_le32(metric + mpath->metric), | ||
715 | 0, sdata); | ||
716 | mpath->sn = orig_sn; | ||
717 | } | ||
718 | rcu_read_unlock(); | ||
719 | } | ||
599 | 720 | ||
600 | 721 | ||
601 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | 722 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, |
@@ -614,34 +735,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, | 735 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, |
615 | len - baselen, &elems); | 736 | len - baselen, &elems); |
616 | 737 | ||
617 | switch (mgmt->u.action.u.mesh_action.action_code) { | 738 | if (elems.preq) { |
618 | case MPATH_PREQ: | 739 | if (elems.preq_len != 37) |
619 | if (!elems.preq || elems.preq_len != 37) | ||
620 | /* Right now we support just 1 destination and no AE */ | 740 | /* Right now we support just 1 destination and no AE */ |
621 | return; | 741 | return; |
622 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq); | 742 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.preq, |
623 | if (!last_hop_metric) | 743 | MPATH_PREQ); |
624 | return; | 744 | if (last_hop_metric) |
625 | hwmp_preq_frame_process(sdata, mgmt, elems.preq, last_hop_metric); | 745 | hwmp_preq_frame_process(sdata, mgmt, elems.preq, |
626 | break; | 746 | last_hop_metric); |
627 | case MPATH_PREP: | 747 | } |
628 | if (!elems.prep || elems.prep_len != 31) | 748 | if (elems.prep) { |
749 | if (elems.prep_len != 31) | ||
629 | /* Right now we support no AE */ | 750 | /* Right now we support no AE */ |
630 | return; | 751 | return; |
631 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep); | 752 | last_hop_metric = hwmp_route_info_get(sdata, mgmt, elems.prep, |
632 | if (!last_hop_metric) | 753 | MPATH_PREP); |
633 | return; | 754 | if (last_hop_metric) |
634 | hwmp_prep_frame_process(sdata, mgmt, elems.prep, last_hop_metric); | 755 | hwmp_prep_frame_process(sdata, mgmt, elems.prep, |
635 | break; | 756 | last_hop_metric); |
636 | case MPATH_PERR: | 757 | } |
637 | if (!elems.perr || elems.perr_len != 12) | 758 | if (elems.perr) { |
759 | if (elems.perr_len != 15) | ||
638 | /* Right now we support only one destination per PERR */ | 760 | /* Right now we support only one destination per PERR */ |
639 | return; | 761 | return; |
640 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); | 762 | hwmp_perr_frame_process(sdata, mgmt, elems.perr); |
641 | default: | ||
642 | return; | ||
643 | } | 763 | } |
644 | 764 | if (elems.rann) | |
765 | hwmp_rann_frame_process(sdata, mgmt, elems.rann); | ||
645 | } | 766 | } |
646 | 767 | ||
647 | /** | 768 | /** |
@@ -661,7 +782,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
661 | 782 | ||
662 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); | 783 | preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC); |
663 | if (!preq_node) { | 784 | if (!preq_node) { |
664 | printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n"); | 785 | mhwmp_dbg("could not allocate PREQ node\n"); |
665 | return; | 786 | return; |
666 | } | 787 | } |
667 | 788 | ||
@@ -670,7 +791,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
670 | spin_unlock(&ifmsh->mesh_preq_queue_lock); | 791 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
671 | kfree(preq_node); | 792 | kfree(preq_node); |
672 | if (printk_ratelimit()) | 793 | if (printk_ratelimit()) |
673 | printk(KERN_DEBUG "Mesh HWMP: PREQ node queue full\n"); | 794 | mhwmp_dbg("PREQ node queue full\n"); |
674 | return; | 795 | return; |
675 | } | 796 | } |
676 | 797 | ||
@@ -705,7 +826,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
705 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 826 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
706 | struct mesh_preq_queue *preq_node; | 827 | struct mesh_preq_queue *preq_node; |
707 | struct mesh_path *mpath; | 828 | struct mesh_path *mpath; |
708 | u8 ttl, dst_flags; | 829 | u8 ttl, target_flags; |
709 | u32 lifetime; | 830 | u32 lifetime; |
710 | 831 | ||
711 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); | 832 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); |
@@ -747,11 +868,11 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
747 | 868 | ||
748 | ifmsh->last_preq = jiffies; | 869 | ifmsh->last_preq = jiffies; |
749 | 870 | ||
750 | if (time_after(jiffies, ifmsh->last_dsn_update + | 871 | if (time_after(jiffies, ifmsh->last_sn_update + |
751 | net_traversal_jiffies(sdata)) || | 872 | net_traversal_jiffies(sdata)) || |
752 | time_before(jiffies, ifmsh->last_dsn_update)) { | 873 | time_before(jiffies, ifmsh->last_sn_update)) { |
753 | ++ifmsh->dsn; | 874 | ++ifmsh->sn; |
754 | sdata->u.mesh.last_dsn_update = jiffies; | 875 | sdata->u.mesh.last_sn_update = jiffies; |
755 | } | 876 | } |
756 | lifetime = default_lifetime(sdata); | 877 | lifetime = default_lifetime(sdata); |
757 | ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; | 878 | ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
@@ -762,14 +883,14 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
762 | } | 883 | } |
763 | 884 | ||
764 | if (preq_node->flags & PREQ_Q_F_REFRESH) | 885 | if (preq_node->flags & PREQ_Q_F_REFRESH) |
765 | dst_flags = MP_F_DO; | 886 | target_flags = MP_F_DO; |
766 | else | 887 | else |
767 | dst_flags = MP_F_RF; | 888 | target_flags = MP_F_RF; |
768 | 889 | ||
769 | spin_unlock_bh(&mpath->state_lock); | 890 | spin_unlock_bh(&mpath->state_lock); |
770 | 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, |
771 | cpu_to_le32(ifmsh->dsn), dst_flags, mpath->dst, | 892 | cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, |
772 | cpu_to_le32(mpath->dsn), sdata->dev->broadcast, 0, | 893 | cpu_to_le32(mpath->sn), sdata->dev->broadcast, 0, |
773 | ttl, cpu_to_le32(lifetime), 0, | 894 | ttl, cpu_to_le32(lifetime), 0, |
774 | cpu_to_le32(ifmsh->preq_id++), sdata); | 895 | cpu_to_le32(ifmsh->preq_id++), sdata); |
775 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); | 896 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); |
@@ -796,15 +917,15 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
796 | struct sk_buff *skb_to_free = NULL; | 917 | struct sk_buff *skb_to_free = NULL; |
797 | struct mesh_path *mpath; | 918 | struct mesh_path *mpath; |
798 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 919 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
799 | u8 *dst_addr = hdr->addr3; | 920 | u8 *target_addr = hdr->addr3; |
800 | int err = 0; | 921 | int err = 0; |
801 | 922 | ||
802 | rcu_read_lock(); | 923 | rcu_read_lock(); |
803 | mpath = mesh_path_lookup(dst_addr, sdata); | 924 | mpath = mesh_path_lookup(target_addr, sdata); |
804 | 925 | ||
805 | if (!mpath) { | 926 | if (!mpath) { |
806 | mesh_path_add(dst_addr, sdata); | 927 | mesh_path_add(target_addr, sdata); |
807 | mpath = mesh_path_lookup(dst_addr, sdata); | 928 | mpath = mesh_path_lookup(target_addr, sdata); |
808 | if (!mpath) { | 929 | if (!mpath) { |
809 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | 930 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
810 | err = -ENOSPC; | 931 | err = -ENOSPC; |
@@ -882,3 +1003,14 @@ void mesh_path_timer(unsigned long data) | |||
882 | endmpathtimer: | 1003 | endmpathtimer: |
883 | rcu_read_unlock(); | 1004 | rcu_read_unlock(); |
884 | } | 1005 | } |
1006 | |||
1007 | void | ||
1008 | mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) | ||
1009 | { | ||
1010 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
1011 | |||
1012 | mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->dev->dev_addr, | ||
1013 | cpu_to_le32(++ifmsh->sn), | ||
1014 | 0, NULL, 0, sdata->dev->broadcast, | ||
1015 | 0, MESH_TTL, 0, 0, 0, sdata); | ||
1016 | } | ||