3b8a5224988e60d2bfb2c32f5afd7a7ce3b92ea5
[openwrt.git] / package / madwifi / patches / 393-mbss_vap_auth.patch
1 --- a/net80211/ieee80211_node.c
2 +++ b/net80211/ieee80211_node.c
3 @@ -123,6 +123,9 @@ static void ieee80211_node_table_cleanup
4 static void ieee80211_node_table_reset(struct ieee80211_node_table *,
5 struct ieee80211vap *);
6
7 +static struct ieee80211_node *
8 +lookup_rxnode(struct ieee80211com *ic, struct ieee80211vap *vap, const u_int8_t *addr);
9 +
10 MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state");
11
12 void
13 @@ -697,7 +700,7 @@ ieee80211_sta_join(struct ieee80211vap *
14 struct ieee80211com *ic = vap->iv_ic;
15 struct ieee80211_node *ni;
16
17 - ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr);
18 + ni = lookup_rxnode(ic, vap, se->se_macaddr);
19 if (ni == NULL) {
20 ni = ieee80211_alloc_node_table(vap, se->se_macaddr);
21 IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
22 @@ -1391,6 +1394,53 @@ ieee80211_add_neighbor(struct ieee80211v
23 return ni;
24 }
25
26 +struct ieee80211vap *
27 +ieee80211_find_rxvap(struct ieee80211com *ic, const u_int8_t *mac)
28 +{
29 + struct ieee80211vap *vap;
30 +
31 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
32 + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, mac))
33 + return vap;
34 + }
35 + return NULL;
36 +}
37 +EXPORT_SYMBOL(ieee80211_find_rxvap);
38 +
39 +static struct ieee80211_node *
40 +lookup_rxnode(struct ieee80211com *ic, struct ieee80211vap *vap,
41 + const u_int8_t *addr)
42 +{
43 + struct ieee80211_node_table *nt;
44 + struct ieee80211_node *ni = NULL;
45 + int use_bss = 0;
46 + int hash;
47 +
48 + nt = &ic->ic_sta;
49 + IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
50 + hash = IEEE80211_NODE_HASH(addr);
51 + LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
52 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, addr)) {
53 + /* allow multiple nodes on different vaps */
54 + if (vap && (ni->ni_vap != vap))
55 + continue;
56 +
57 + ieee80211_ref_node(ni);
58 + goto out;
59 + }
60 + }
61 +
62 + /* no match found */
63 + ni = NULL;
64 +
65 +out:
66 + IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
67 + return ni;
68 +#undef IS_PSPOLL
69 +#undef IS_CTL
70 +}
71 +
72 +
73 /*
74 * Return the node for the sender of a frame; if the sender is unknown return
75 * NULL. The caller is expected to deal with this. (The frame is sent to all
76 @@ -1400,10 +1450,10 @@ ieee80211_add_neighbor(struct ieee80211v
77 */
78 struct ieee80211_node *
79 #ifdef IEEE80211_DEBUG_REFCNT
80 -ieee80211_find_rxnode_debug(struct ieee80211com *ic,
81 +ieee80211_find_rxnode_debug(struct ieee80211com *ic, struct ieee80211vap *vap,
82 const struct ieee80211_frame_min *wh, const char *func, int line)
83 #else
84 -ieee80211_find_rxnode(struct ieee80211com *ic,
85 +ieee80211_find_rxnode(struct ieee80211com *ic, struct ieee80211vap *vap,
86 const struct ieee80211_frame_min *wh)
87 #endif
88 {
89 @@ -1411,9 +1461,8 @@ ieee80211_find_rxnode(struct ieee80211co
90 ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL)
91 #define IS_PSPOLL(wh) \
92 ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PS_POLL)
93 - struct ieee80211_node_table *nt;
94 - struct ieee80211_node *ni;
95 - struct ieee80211vap *vap, *avp;
96 + struct ieee80211_node *ni = NULL;
97 + struct ieee80211vap *avp;
98 const u_int8_t *addr;
99
100 if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/)
101 @@ -1426,32 +1475,24 @@ ieee80211_find_rxnode(struct ieee80211co
102
103 /* XXX check ic_bss first in station mode */
104 /* XXX 4-address frames? */
105 - nt = &ic->ic_sta;
106 - IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
107 if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) {
108 - TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
109 + if (vap) { /* assume unicast if vap is set, mcast not supported for wds */
110 TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
111 - if (!IEEE80211_ADDR_EQ(addr, avp->wds_mac))
112 + if (!IEEE80211_ADDR_EQ(addr, avp->wds_mac) ||
113 + !IEEE80211_ADDR_EQ(wh->i_addr1, avp->iv_myaddr))
114 continue;
115
116 if (avp->iv_wdsnode)
117 - return ieee80211_ref_node(avp->iv_wdsnode);
118 - else
119 - return NULL;
120 + ni = ieee80211_ref_node(avp->iv_wdsnode);
121 }
122 + if (!(vap->iv_flags_ext & IEEE80211_FEXT_WDS))
123 + return NULL;
124 + } else {
125 + return NULL;
126 }
127 }
128
129 -#ifdef IEEE80211_DEBUG_REFCNT
130 - ni = ieee80211_find_node_locked_debug(nt, addr, func, line);
131 -#else
132 - ni = ieee80211_find_node_locked(nt, addr);
133 -#endif
134 - IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
135 -
136 - return ni;
137 -#undef IS_PSPOLL
138 -#undef IS_CTL
139 + return lookup_rxnode(ic, vap, addr);
140 }
141 #ifdef IEEE80211_DEBUG_REFCNT
142 EXPORT_SYMBOL(ieee80211_find_rxnode_debug);
143 @@ -1476,15 +1517,14 @@ ieee80211_find_txnode(struct ieee80211va
144 struct ieee80211com *ic = vap->iv_ic;
145 struct ieee80211_node_table *nt;
146 struct ieee80211_node *ni = NULL;
147 + int hash;
148
149 - IEEE80211_LOCK_IRQ(ic);
150 if (vap->iv_opmode == IEEE80211_M_WDS) {
151 if (vap->iv_wdsnode && (vap->iv_state == IEEE80211_S_RUN))
152 return ieee80211_ref_node(vap->iv_wdsnode);
153 else
154 return NULL;
155 }
156 - IEEE80211_UNLOCK_IRQ(ic);
157
158 /*
159 * The destination address should be in the node table
160 @@ -1502,11 +1542,22 @@ ieee80211_find_txnode(struct ieee80211va
161 /* XXX: Can't hold lock across dup_bss due to recursive locking. */
162 nt = &vap->iv_ic->ic_sta;
163 IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
164 + hash = IEEE80211_NODE_HASH(mac);
165 + LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
166 + if (ni->ni_vap != vap)
167 + continue;
168 +
169 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, mac)) {
170 #ifdef IEEE80211_DEBUG_REFCNT
171 - ni = ieee80211_find_node_locked_debug(nt, mac, func, line);
172 + ieee80211_ref_node_debug(ni, func, line);
173 #else
174 - ni = ieee80211_find_node_locked(nt, mac);
175 + ieee80211_ref_node(ni);
176 #endif
177 + goto found;
178 + }
179 + }
180 + ni = NULL;
181 +found:
182 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
183
184 if (ni == NULL) {
185 @@ -1961,13 +2012,29 @@ remove_worse_nodes(void *arg, struct iee
186 }
187 }
188
189 +static void
190 +remove_duplicate_nodes(void *arg, struct ieee80211_node *ni)
191 +{
192 + struct ieee80211_node *rni = arg;
193 +
194 + if (ni == rni)
195 + return;
196 +
197 + if (ni->ni_vap == rni->ni_vap)
198 + return;
199 +
200 + ieee80211_node_leave(ni);
201 +}
202 +
203 void
204 ieee80211_node_join(struct ieee80211_node *ni, int resp)
205 {
206 struct ieee80211com *ic = ni->ni_ic;
207 struct ieee80211vap *vap = ni->ni_vap;
208 + struct ieee80211_node *tni;
209 int newassoc;
210
211 + ieee80211_iterate_nodes(&ic->ic_sta, remove_duplicate_nodes, ni);
212 if (ni->ni_associd == 0) {
213 u_int16_t aid;
214
215 --- a/net80211/ieee80211_input.c
216 +++ b/net80211/ieee80211_input.c
217 @@ -216,16 +216,14 @@ ieee80211_input(struct ieee80211vap * va
218
219 type = -1; /* undefined */
220
221 - if (!vap)
222 - goto out;
223 + if (!vap || !vap->iv_bss || !vap->iv_dev || !vap->iv_ic)
224 + goto discard;
225
226 ic = vap->iv_ic;
227 - if (!ic)
228 - goto out;
229 -
230 dev = vap->iv_dev;
231 - if (!dev)
232 - goto out;
233 +
234 + if ((vap->iv_dev->flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
235 + goto discard;
236
237 /* initialize ni as in the previous API */
238 if (ni_or_null == NULL) {
239 @@ -233,9 +231,10 @@ ieee80211_input(struct ieee80211vap * va
240 * guarantee its existence during the following call, hence
241 * briefly grab our own reference. */
242 ni = ieee80211_ref_node(vap->iv_bss);
243 + KASSERT(ni != NULL, ("null node"));
244 + } else {
245 + ni->ni_inact = ni->ni_inact_reload;
246 }
247 - KASSERT(ni != NULL, ("null node"));
248 - ni->ni_inact = ni->ni_inact_reload;
249
250 KASSERT(skb->len >= sizeof(struct ieee80211_frame_min),
251 ("frame length too short: %u", skb->len));
252 @@ -848,10 +847,11 @@ ieee80211_input(struct ieee80211vap * va
253 err:
254 vap->iv_devstats.rx_errors++;
255 out:
256 - if (skb != NULL)
257 - ieee80211_dev_kfree_skb(&skb);
258 if (ni_or_null == NULL)
259 ieee80211_unref_node(&ni);
260 +discard:
261 + if (skb != NULL)
262 + ieee80211_dev_kfree_skb(&skb);
263 return type;
264 #undef HAS_SEQ
265 }
266 @@ -933,16 +933,23 @@ int
267 ieee80211_input_all(struct ieee80211com *ic,
268 struct sk_buff *skb, int rssi, u_int64_t rtsf)
269 {
270 + struct ieee80211_frame_min *wh = (struct ieee80211_frame_min *) skb->data;
271 struct ieee80211vap *vap;
272 int type = -1;
273
274 /* XXX locking */
275 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
276 + struct ieee80211_node *ni = NULL;
277 struct sk_buff *skb1;
278
279 if ((vap->iv_dev->flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
280 continue;
281
282 + if ((vap->iv_opmode == IEEE80211_M_HOSTAP) &&
283 + !IEEE80211_IS_MULTICAST(wh->i_addr1))
284 + continue;
285 +
286 + ni = ieee80211_find_rxnode(ic, vap, wh);
287 if (TAILQ_NEXT(vap, iv_next) != NULL) {
288 skb1 = skb_copy(skb, GFP_ATOMIC);
289 if (skb1 == NULL) {
290 @@ -954,8 +961,10 @@ ieee80211_input_all(struct ieee80211com
291 skb1 = skb;
292 skb = NULL;
293 }
294 - type = ieee80211_input(vap, NULL, skb1, rssi, rtsf);
295 + type = ieee80211_input(vap, ni, skb1, rssi, rtsf);
296 }
297 +
298 +out:
299 if (skb != NULL) /* no vaps, reclaim skb */
300 ieee80211_dev_kfree_skb(&skb);
301 return type;
302 @@ -1146,11 +1155,9 @@ ieee80211_deliver_data(struct ieee80211_
303 * sending it will not work; just let it be
304 * delivered normally.
305 */
306 - struct ieee80211_node *ni1 = ieee80211_find_node(
307 - &vap->iv_ic->ic_sta, eh->ether_dhost);
308 + struct ieee80211_node *ni1 = ieee80211_find_txnode(vap, eh->ether_dhost);
309 if (ni1 != NULL) {
310 - if (ni1->ni_vap == vap &&
311 - ieee80211_node_is_authorized(ni1) &&
312 + if (ieee80211_node_is_authorized(ni1) &&
313 !ni1->ni_subif &&
314 ni1 != vap->iv_bss) {
315
316 --- a/ath/if_ath.c
317 +++ b/ath/if_ath.c
318 @@ -6577,9 +6577,8 @@ ath_recv_mgmt(struct ieee80211vap * vap,
319
320 sc->sc_recv_mgmt(vap, ni_or_null, skb, subtype, rssi, rtsf);
321
322 -
323 /* Lookup the new node if any (this grabs a reference to it) */
324 - ni = ieee80211_find_rxnode(vap->iv_ic,
325 + ni = ieee80211_find_rxnode(vap->iv_ic, vap,
326 (const struct ieee80211_frame_min *)skb->data);
327 if (ni == NULL) {
328 DPRINTF(sc, ATH_DEBUG_BEACON, "Dropping; node unknown.\n");
329 @@ -6734,7 +6733,9 @@ ath_rx_poll(struct net_device *dev, int
330 struct ath_desc *ds;
331 struct ath_rx_status *rs;
332 struct sk_buff *skb = NULL;
333 + struct ieee80211vap *vap;
334 struct ieee80211_node *ni;
335 + const struct ieee80211_frame_min *wh;
336 unsigned int len;
337 int type;
338 u_int phyerr;
339 @@ -6889,12 +6890,15 @@ rx_accept:
340 skb_trim(skb, skb->len - IEEE80211_CRC_LEN);
341
342 if (mic_fail) {
343 + wh = (const struct ieee80211_frame_min *) skb->data;
344 +
345 /* Ignore control frames which are reported with mic error */
346 - if ((((struct ieee80211_frame *)skb->data)->i_fc[0] &
347 + if ((wh->i_fc[0] &
348 IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL)
349 goto drop_micfail;
350
351 - ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
352 + vap = ieee80211_find_rxvap(ic, wh->i_addr1);
353 + ni = ieee80211_find_rxnode(ic, vap, wh);
354
355 if (ni && ni->ni_table) {
356 ieee80211_check_mic(ni, skb);
357 @@ -6956,11 +6960,24 @@ drop_micfail:
358 * for its use. If the sender is unknown spam the
359 * frame; it'll be dropped where it's not wanted.
360 */
361 - if (rs->rs_keyix != HAL_RXKEYIX_INVALID &&
362 + wh = (const struct ieee80211_frame_min *) skb->data;
363 + if ((rs->rs_keyix != HAL_RXKEYIX_INVALID) &&
364 (ni = sc->sc_keyixmap[rs->rs_keyix]) != NULL) {
365 /* Fast path: node is present in the key map;
366 * grab a reference for processing the frame. */
367 - ni = ieee80211_ref_node(ni);
368 + ieee80211_ref_node(ni);
369 + if ((ATH_GET_VAP_ID(wh->i_addr1) !=
370 + ATH_GET_VAP_ID(ni->ni_vap->iv_myaddr)) ||
371 + ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
372 + IEEE80211_FC1_DIR_DSTODS)) {
373 + /* key cache node lookup is fast, but it can
374 + * lead to problems in multi-bss (foreign vap
375 + * node reference) or wds (wdsap node ref instead
376 + * of base ap node ref).
377 + * use slowpath lookup in both cases
378 + */
379 + goto lookup_slowpath;
380 + }
381 ATH_RSSI_LPF(ATH_NODE(ni)->an_avgrssi, rs->rs_rssi);
382 type = ieee80211_input(ni->ni_vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
383 ieee80211_unref_node(&ni);
384 @@ -6969,24 +6986,35 @@ drop_micfail:
385 * No key index or no entry, do a lookup and
386 * add the node to the mapping table if possible.
387 */
388 - ni = ieee80211_find_rxnode(ic,
389 - (const struct ieee80211_frame_min *)skb->data);
390 +
391 +lookup_slowpath:
392 + vap = ieee80211_find_rxvap(ic, wh->i_addr1);
393 + if (vap)
394 + ni = ieee80211_find_rxnode(ic, vap, wh);
395 + else
396 + ni = NULL;
397 +
398 if (ni != NULL) {
399 ieee80211_keyix_t keyix;
400
401 ATH_RSSI_LPF(ATH_NODE(ni)->an_avgrssi, rs->rs_rssi);
402 - type = ieee80211_input(ni->ni_vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
403 + type = ieee80211_input(vap, ni, skb, rs->rs_rssi, bf->bf_tsf);
404 /*
405 * If the station has a key cache slot assigned
406 * update the key->node mapping table.
407 */
408 keyix = ni->ni_ucastkey.wk_keyix;
409 if (keyix != IEEE80211_KEYIX_NONE &&
410 - sc->sc_keyixmap[keyix] == NULL)
411 + sc->sc_keyixmap[keyix] == NULL) {
412 sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni);
413 + }
414 ieee80211_unref_node(&ni);
415 - } else
416 - type = ieee80211_input_all(ic, skb, rs->rs_rssi, bf->bf_tsf);
417 + } else {
418 + if (vap)
419 + type = ieee80211_input(vap, NULL, skb, rs->rs_rssi, bf->bf_tsf);
420 + else
421 + type = ieee80211_input_all(ic, skb, rs->rs_rssi, bf->bf_tsf);
422 + }
423 }
424
425 if (sc->sc_diversity) {
426 --- a/net80211/ieee80211_node.h
427 +++ b/net80211/ieee80211_node.h
428 @@ -286,15 +286,18 @@ struct ieee80211_node *ieee80211_find_no
429 const u_int8_t *);
430 #endif /* #ifdef IEEE80211_DEBUG_REFCNT */
431
432 +struct ieee80211vap *
433 +ieee80211_find_rxvap(struct ieee80211com *ic, const u_int8_t *mac);
434 +
435 /* Returns a ieee80211_node* with refcount incremented, if found */
436 #ifdef IEEE80211_DEBUG_REFCNT
437 -#define ieee80211_find_rxnode(_nt, _wh) \
438 - ieee80211_find_rxnode_debug(_nt, _wh, __func__, __LINE__)
439 +#define ieee80211_find_rxnode(_nt, _vap, _wh) \
440 + ieee80211_find_rxnode_debug(_nt, _vap, _wh, __func__, __LINE__)
441 struct ieee80211_node *ieee80211_find_rxnode_debug(struct ieee80211com *,
442 - const struct ieee80211_frame_min *, const char *, int);
443 + struct ieee80211vap *, const struct ieee80211_frame_min *, const char *, int);
444 #else
445 struct ieee80211_node *ieee80211_find_rxnode(struct ieee80211com *,
446 - const struct ieee80211_frame_min *);
447 + struct ieee80211vap *, const struct ieee80211_frame_min *);
448 #endif /* #ifdef IEEE80211_DEBUG_REFCNT */
449
450 /* Returns a ieee80211_node* with refcount incremented, if found */
This page took 0.059566 seconds and 3 git commands to generate.