[package] broadcom-wl: implement wepauth in wlc and support it in broadcom.sh, allows...
[openwrt.git] / package / madwifi / patches / 370-wdsvap.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -124,7 +124,7 @@ enum {
4 };
5
6 static struct ieee80211vap *ath_vap_create(struct ieee80211com *,
7 - const char *, int, int, struct net_device *);
8 + const char *, int, int, struct net_device *, struct ieee80211vap *);
9 static void ath_vap_delete(struct ieee80211vap *);
10 static int ath_init(struct net_device *);
11 static int ath_set_ack_bitrate(struct ath_softc *, int);
12 @@ -1123,8 +1123,6 @@ ath_attach(u_int16_t devid, struct net_d
13 autocreatemode = IEEE80211_M_IBSS;
14 else if (!strcmp(autocreate, "ahdemo"))
15 autocreatemode = IEEE80211_M_AHDEMO;
16 - else if (!strcmp(autocreate, "wds"))
17 - autocreatemode = IEEE80211_M_WDS;
18 else if (!strcmp(autocreate, "monitor"))
19 autocreatemode = IEEE80211_M_MONITOR;
20 else {
21 @@ -1137,7 +1135,7 @@ ath_attach(u_int16_t devid, struct net_d
22 if (autocreatemode != -1) {
23 rtnl_lock();
24 vap = ieee80211_create_vap(ic, "ath%d", dev,
25 - autocreatemode, 0);
26 + autocreatemode, 0, NULL);
27 rtnl_unlock();
28 if (vap == NULL)
29 EPRINTF(sc, "Autocreation of %s VAP failed.", autocreate);
30 @@ -1230,14 +1228,14 @@ ath_detach(struct net_device *dev)
31
32 static struct ieee80211vap *
33 ath_vap_create(struct ieee80211com *ic, const char *name,
34 - int opmode, int flags, struct net_device *mdev)
35 + int opmode, int flags, struct net_device *mdev, struct ieee80211vap *master)
36 {
37 struct ath_softc *sc = ic->ic_dev->priv;
38 struct ath_hal *ah = sc->sc_ah;
39 struct net_device *dev;
40 struct ath_vap *avp;
41 struct ieee80211vap *vap;
42 - int ic_opmode;
43 + int ic_opmode = IEEE80211_M_STA;
44
45 if (ic->ic_dev->flags & IFF_RUNNING) {
46 /* needs to disable hardware too */
47 @@ -1271,8 +1269,12 @@ ath_vap_create(struct ieee80211com *ic,
48 } else
49 ic_opmode = opmode;
50 break;
51 - case IEEE80211_M_HOSTAP:
52 case IEEE80211_M_WDS:
53 + ic_opmode = ic->ic_opmode;
54 + if (!master)
55 + return NULL;
56 + break;
57 + case IEEE80211_M_HOSTAP:
58 /* permit multiple APs and/or WDS links */
59 /* XXX sta+ap for repeater/bridge application */
60 if ((sc->sc_nvaps != 0) && (ic->ic_opmode == IEEE80211_M_STA))
61 @@ -1304,7 +1306,7 @@ ath_vap_create(struct ieee80211com *ic,
62 }
63
64 avp = dev->priv;
65 - ieee80211_vap_setup(ic, dev, name, opmode, flags);
66 + ieee80211_vap_setup(ic, dev, name, opmode, flags, master);
67 /* override with driver methods */
68 vap = &avp->av_vap;
69 avp->av_newstate = vap->iv_newstate;
70 @@ -4209,8 +4211,7 @@ ath_calcrxfilter(struct ath_softc *sc)
71 if (ic->ic_opmode == IEEE80211_M_STA ||
72 sc->sc_opmode == HAL_M_IBSS || /* NB: AHDEMO too */
73 (sc->sc_nostabeacons) || sc->sc_scanning ||
74 - ((ic->ic_opmode == IEEE80211_M_HOSTAP) &&
75 - (ic->ic_protmode != IEEE80211_PROT_NONE)))
76 + (ic->ic_opmode == IEEE80211_M_HOSTAP))
77 rfilt |= HAL_RX_FILTER_BEACON;
78 if (sc->sc_nmonvaps > 0)
79 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
80 @@ -9032,8 +9033,6 @@ ath_calibrate(unsigned long arg)
81 * set sc->beacons if we might need to restart
82 * them after ath_reset. */
83 if (!sc->sc_beacons &&
84 - (TAILQ_FIRST(&ic->ic_vaps)->iv_opmode !=
85 - IEEE80211_M_WDS) &&
86 !txcont_was_active &&
87 !sc->sc_dfs_cac) {
88 sc->sc_beacons = 1;
89 --- a/net80211/ieee80211.c
90 +++ b/net80211/ieee80211.c
91 @@ -373,10 +373,25 @@ void
92 ieee80211_ifdetach(struct ieee80211com *ic)
93 {
94 struct ieee80211vap *vap;
95 + int count;
96 +
97 + /* bring down all vaps */
98 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
99 + ieee80211_stop(vap->iv_dev);
100 + }
101 +
102 + /* wait for all subifs to disappear */
103 + do {
104 + schedule();
105 + rtnl_lock();
106 + count = ic->ic_subifs;
107 + rtnl_unlock();
108 + } while (count > 0);
109
110 rtnl_lock();
111 - while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL)
112 + while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL) {
113 ic->ic_vap_delete(vap);
114 + }
115 rtnl_unlock();
116
117 del_timer(&ic->ic_dfs_excl_timer);
118 @@ -396,7 +411,7 @@ EXPORT_SYMBOL(ieee80211_ifdetach);
119
120 int
121 ieee80211_vap_setup(struct ieee80211com *ic, struct net_device *dev,
122 - const char *name, int opmode, int flags)
123 + const char *name, int opmode, int flags, struct ieee80211vap *master)
124 {
125 #define IEEE80211_C_OPMODE \
126 (IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | IEEE80211_C_AHDEMO | \
127 @@ -510,9 +525,18 @@ ieee80211_vap_setup(struct ieee80211com
128
129 vap->iv_monitor_crc_errors = 0;
130 vap->iv_monitor_phy_errors = 0;
131 + TAILQ_INIT(&vap->iv_wdslinks);
132
133 - IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_myaddr);
134 - IEEE80211_ADDR_COPY(vap->iv_bssid, ic->ic_myaddr);
135 + if (master && (vap->iv_opmode == IEEE80211_M_WDS)) {
136 + vap->iv_master = master;
137 + TAILQ_INSERT_TAIL(&master->iv_wdslinks, vap, iv_wdsnext);
138 + /* use the same BSSID as the master interface */
139 + IEEE80211_ADDR_COPY(vap->iv_myaddr, vap->iv_master->iv_myaddr);
140 + IEEE80211_ADDR_COPY(vap->iv_bssid, vap->iv_master->iv_myaddr);
141 + } else {
142 + IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_myaddr);
143 + IEEE80211_ADDR_COPY(vap->iv_bssid, ic->ic_myaddr);
144 + }
145 /* NB: Defer setting dev_addr so driver can override */
146
147 ieee80211_crypto_vattach(vap);
148 @@ -547,7 +571,8 @@ ieee80211_vap_attach(struct ieee80211vap
149 ifmedia_set(&vap->iv_media, imr.ifm_active);
150
151 IEEE80211_LOCK_IRQ(ic);
152 - TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next);
153 + if (vap->iv_opmode != IEEE80211_M_WDS)
154 + TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next);
155 IEEE80211_UNLOCK_IRQ(ic);
156
157 IEEE80211_ADDR_COPY(dev->dev_addr, vap->iv_myaddr);
158 @@ -579,10 +604,27 @@ ieee80211_vap_detach(struct ieee80211vap
159 {
160 struct ieee80211com *ic = vap->iv_ic;
161 struct net_device *dev = vap->iv_dev;
162 + struct ieee80211vap *avp;
163 +
164 + /* Drop all WDS links that belong to this vap */
165 + while ((avp = TAILQ_FIRST(&vap->iv_wdslinks)) != NULL) {
166 + if (avp->iv_state != IEEE80211_S_INIT)
167 + ieee80211_stop(avp->iv_dev);
168 + ic->ic_vap_delete(avp);
169 + }
170
171 IEEE80211_CANCEL_TQUEUE(&vap->iv_stajoin1tq);
172 IEEE80211_LOCK_IRQ(ic);
173 - TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
174 + if (vap->iv_wdsnode) {
175 + vap->iv_wdsnode->ni_subif = NULL;
176 + ieee80211_unref_node(&vap->iv_wdsnode);
177 + }
178 + if ((vap->iv_opmode == IEEE80211_M_WDS) &&
179 + (vap->iv_master != NULL))
180 + TAILQ_REMOVE(&vap->iv_master->iv_wdslinks, vap, iv_wdsnext);
181 + else
182 + TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
183 +
184 if (TAILQ_EMPTY(&ic->ic_vaps)) /* reset to supported mode */
185 ic->ic_opmode = IEEE80211_M_STA;
186 IEEE80211_UNLOCK_IRQ(ic);
187 --- a/net80211/ieee80211_ioctl.h
188 +++ b/net80211/ieee80211_ioctl.h
189 @@ -474,7 +474,7 @@ struct ieee80211req {
190 #define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */
191 #define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */
192 #define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */
193 -#define IEEE80211_IOC_DELMAC 55 /* del sta from MAC ACL table */
194 +#define IEEE80211_IOC_SETMAC 55 /* set interface wds mac addr */
195 #define IEEE80211_IOC_FF 56 /* ATH fast frames (on, off) */
196 #define IEEE80211_IOC_TURBOP 57 /* ATH turbo' (on, off) */
197 #define IEEE80211_IOC_APPIEBUF 58 /* IE in the management frame */
198 @@ -552,8 +552,8 @@ struct ieee80211req_scan_result {
199 #define IEEE80211_IOCTL_HALMAP (SIOCIWFIRSTPRIV+21)
200 #define IEEE80211_IOCTL_ADDMAC (SIOCIWFIRSTPRIV+22)
201 #define IEEE80211_IOCTL_DELMAC (SIOCIWFIRSTPRIV+24)
202 -#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
203 -#define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
204 +#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+25)
205 +#define IEEE80211_IOCTL_WDSSETMAC (SIOCIWFIRSTPRIV+26)
206 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
207 #define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
208
209 @@ -649,6 +649,7 @@ enum {
210 IEEE80211_PARAM_BGSCAN_THRESH = 79, /* bg scan rssi threshold */
211 IEEE80211_PARAM_RSSI_DIS_THR = 80, /* rssi threshold for disconnection */
212 IEEE80211_PARAM_RSSI_DIS_COUNT = 81, /* counter for rssi threshold */
213 + IEEE80211_PARAM_WDS_SEP = 82, /* move wds stations into separate interfaces */
214 };
215
216 #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
217 --- a/net80211/ieee80211_linux.h
218 +++ b/net80211/ieee80211_linux.h
219 @@ -81,6 +81,12 @@ set_quality(struct iw_quality *iq, u_int
220 #endif
221 }
222
223 +#ifndef container_of
224 +#define container_of(ptr, type, member) ({ \
225 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
226 + (type *)( (char *)__mptr - offsetof(type,member) );})
227 +#endif
228 +
229 /*
230 * Task deferral
231 *
232 @@ -113,6 +119,29 @@ typedef void *IEEE80211_TQUEUE_ARG;
233
234 #define IEEE80211_RESCHEDULE schedule
235
236 +#include <linux/sched.h>
237 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
238 +#include <linux/tqueue.h>
239 +#define work_struct tq_struct
240 +#define schedule_work(t) schedule_task((t))
241 +#define flush_scheduled_work() flush_scheduled_tasks()
242 +#define IEEE80211_INIT_WORK(t, f) do { \
243 + memset((t), 0, sizeof(struct tq_struct)); \
244 + (t)->routine = (void (*)(void*)) (f); \
245 + (t)->data=(void *) (t); \
246 +} while (0)
247 +#else
248 +#include <linux/workqueue.h>
249 +
250 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
251 +#define IEEE80211_INIT_WORK(_t, _f) INIT_WORK((_t), (void (*)(void *))(_f), (_t));
252 +#else
253 +#define IEEE80211_INIT_WORK(_t, _f) INIT_WORK((_t), (_f));
254 +#endif
255 +
256 +#endif /* KERNEL_VERSION < 2.5.41 */
257 +
258 +
259 /* Locking */
260 /* NB: beware, spin_is_locked() is not usefully defined for !(DEBUG || SMP)
261 * because spinlocks do not exist in this configuration. Instead IRQs
262 @@ -167,6 +196,14 @@ typedef spinlock_t ieee80211com_lock_t;
263 IEEE80211_VAPS_LOCK_ASSERT(_ic); \
264 spin_unlock_bh(&(_ic)->ic_vapslock); \
265 } while (0)
266 +#define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \
267 + unsigned long __ilockflags; \
268 + IEEE80211_VAPS_LOCK_CHECK(_ic); \
269 + spin_lock_irqsave(&(_ic)->ic_vapslock, __ilockflags);
270 +#define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \
271 + IEEE80211_VAPS_LOCK_ASSERT(_ic); \
272 + spin_unlock_irqrestore(&(_ic)->ic_vapslock, __ilockflags); \
273 +} while (0)
274
275 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
276 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) \
277 @@ -650,5 +687,5 @@ struct ifreq;
278 int ieee80211_ioctl_create_vap(struct ieee80211com *, struct ifreq *,
279 struct net_device *);
280 struct ieee80211vap *ieee80211_create_vap(struct ieee80211com *, char *,
281 - struct net_device *, int, int);
282 + struct net_device *, int, int, struct ieee80211vap *);
283 #endif /* _NET80211_IEEE80211_LINUX_H_ */
284 --- a/net80211/ieee80211_var.h
285 +++ b/net80211/ieee80211_var.h
286 @@ -187,6 +187,12 @@ struct ieee80211vap {
287 struct ieee80211_proc_entry *iv_proc_entries;
288 struct vlan_group *iv_vlgrp; /* vlan group state */
289
290 + /* list of wds links */
291 + TAILQ_HEAD(, ieee80211vap) iv_wdslinks;
292 + TAILQ_ENTRY(ieee80211vap) iv_wdsnext;
293 + struct ieee80211vap *iv_master;
294 + struct ieee80211_node *iv_wdsnode;
295 +
296 TAILQ_ENTRY(ieee80211vap) iv_next; /* list of vap instances */
297 struct ieee80211com *iv_ic; /* back ptr to common state */
298 u_int32_t iv_debug; /* debug msg flags */
299 @@ -316,6 +322,7 @@ struct ieee80211com {
300 u_int8_t ic_myaddr[IEEE80211_ADDR_LEN];
301 struct timer_list ic_inact; /* mgmt/inactivity timer */
302
303 + unsigned int ic_subifs;
304 u_int32_t ic_flags; /* state flags */
305 u_int32_t ic_flags_ext; /* extension of state flags */
306 u_int32_t ic_caps; /* capabilities */
307 @@ -447,7 +454,7 @@ struct ieee80211com {
308 atomic_t ic_node_counter;
309 /* Virtual AP create/delete */
310 struct ieee80211vap *(*ic_vap_create)(struct ieee80211com *,
311 - const char *, int, int, struct net_device *);
312 + const char *, int, int, struct net_device *, struct ieee80211vap *);
313 void (*ic_vap_delete)(struct ieee80211vap *);
314
315 /* Send/recv 802.11 management frame */
316 @@ -619,6 +626,7 @@ MALLOC_DECLARE(M_80211_VAP);
317 #define IEEE80211_FEXT_DROPUNENC_EAPOL 0x00000800 /* CONF: drop unencrypted eapol frames */
318 #define IEEE80211_FEXT_APPIE_UPDATE 0x00001000 /* STATE: beacon APP IE updated */
319 #define IEEE80211_FEXT_BGSCAN_THR 0x00002000 /* bgscan due to low rssi */
320 +#define IEEE80211_FEXT_WDSSEP 0x00004000 /* move wds clients into separate interfaces */
321
322 #define IEEE80211_COM_UAPSD_ENABLE(_ic) ((_ic)->ic_flags_ext |= IEEE80211_FEXT_UAPSD)
323 #define IEEE80211_COM_UAPSD_DISABLE(_ic) ((_ic)->ic_flags_ext &= ~IEEE80211_FEXT_UAPSD)
324 @@ -703,7 +711,7 @@ MALLOC_DECLARE(M_80211_VAP);
325 int ieee80211_ifattach(struct ieee80211com *);
326 void ieee80211_ifdetach(struct ieee80211com *);
327 int ieee80211_vap_setup(struct ieee80211com *, struct net_device *,
328 - const char *, int, int);
329 + const char *, int, int, struct ieee80211vap *);
330 int ieee80211_vap_attach(struct ieee80211vap *, ifm_change_cb_t, ifm_stat_cb_t);
331 void ieee80211_vap_detach(struct ieee80211vap *);
332 void ieee80211_mark_dfs(struct ieee80211com *, struct ieee80211_channel *);
333 --- a/net80211/ieee80211_wireless.c
334 +++ b/net80211/ieee80211_wireless.c
335 @@ -2190,7 +2190,7 @@ ieee80211_setupxr(struct ieee80211vap *v
336 ieee80211_scan_flush(ic); /* NB: could optimize */
337
338 if (!(xrvap = ic->ic_vap_create(ic, name, IEEE80211_M_HOSTAP,
339 - IEEE80211_VAP_XR | IEEE80211_CLONE_BSSID, dev)))
340 + IEEE80211_VAP_XR | IEEE80211_CLONE_BSSID, dev, NULL)))
341 return;
342
343 /* We use iv_xrvap to link to the parent VAP as well */
344 @@ -2867,6 +2867,14 @@ ieee80211_ioctl_setparam(struct net_devi
345 else
346 vap->iv_minrateindex = 0;
347 break;
348 + case IEEE80211_PARAM_WDS_SEP:
349 + if (vap->iv_opmode != IEEE80211_M_HOSTAP)
350 + retv = -EINVAL;
351 + else if (value)
352 + vap->iv_flags_ext |= IEEE80211_FEXT_WDSSEP;
353 + else
354 + vap->iv_flags_ext &= ~IEEE80211_FEXT_WDSSEP;
355 + break;
356 #ifdef ATH_REVERSE_ENGINEERING
357 case IEEE80211_PARAM_DUMPREGS:
358 ieee80211_dump_registers(dev, info, w, extra);
359 @@ -3223,6 +3231,9 @@ ieee80211_ioctl_getparam(struct net_devi
360 case IEEE80211_PARAM_MINRATE:
361 param[0] = vap->iv_minrateindex;
362 break;
363 + case IEEE80211_PARAM_WDS_SEP:
364 + param[0] = !!(vap->iv_flags_ext & IEEE80211_FEXT_WDSSEP);
365 + break;
366 default:
367 return -EOPNOTSUPP;
368 }
369 @@ -3801,74 +3812,54 @@ ieee80211_ioctl_setmlme(struct net_devic
370 return 0;
371 }
372
373 +#define WDSNAME ".wds%d"
374 static int
375 -ieee80211_ioctl_wdsmac(struct net_device *dev, struct iw_request_info *info,
376 +ieee80211_ioctl_wdsaddmac(struct net_device *dev, struct iw_request_info *info,
377 void *w, char *extra)
378 {
379 struct ieee80211vap *vap = dev->priv;
380 struct sockaddr *sa = (struct sockaddr *)extra;
381 + struct ieee80211com *ic = vap->iv_ic;
382 + struct ieee80211vap *avp;
383 + char *name;
384
385 - if (!IEEE80211_ADDR_NULL(vap->wds_mac)) {
386 - printk("%s: Failed to add WDS MAC: " MAC_FMT "\n", dev->name,
387 - MAC_ADDR(sa->sa_data));
388 - printk("%s: Device already has WDS mac address attached,"
389 - " remove first\n", dev->name);
390 - return -1;
391 - }
392 -
393 - memcpy(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
394 + if (vap->iv_opmode != IEEE80211_M_HOSTAP)
395 + return -EINVAL;
396
397 - printk("%s: Added WDS MAC: " MAC_FMT "\n", dev->name,
398 - MAC_ADDR(vap->wds_mac));
399 + name = kmalloc(strlen(vap->iv_dev->name) + sizeof(WDSNAME) + 1, GFP_KERNEL);
400 + if (!name)
401 + return -ENOMEM;
402
403 - if (IS_UP(vap->iv_dev)) {
404 - /* Force us back to scan state to force us to go back through RUN
405 - * state and create/pin the WDS peer node into memory. */
406 - return ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
407 - }
408 + strcpy(name, vap->iv_dev->name);
409 + strcat(name, WDSNAME);
410 + avp = ieee80211_create_vap(ic, name, ic->ic_dev, IEEE80211_M_WDS, 0, vap);
411 + kfree(name);
412 + if (!avp)
413 + return -ENOMEM;
414
415 + memcpy(avp->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
416 return 0;
417 }
418 +#undef WDSNAME
419
420 static int
421 -ieee80211_ioctl_wdsdelmac(struct net_device *dev, struct iw_request_info *info,
422 +ieee80211_ioctl_wdssetmac(struct net_device *dev, struct iw_request_info *info,
423 void *w, char *extra)
424 {
425 struct ieee80211vap *vap = dev->priv;
426 struct sockaddr *sa = (struct sockaddr *)extra;
427 - struct ieee80211com *ic = vap->iv_ic;
428 - struct ieee80211_node *wds_ni;
429
430 - /* WDS Mac address filed already? */
431 - if (IEEE80211_ADDR_NULL(vap->wds_mac))
432 - return 0;
433 + if (vap->iv_opmode != IEEE80211_M_WDS)
434 + return -EINVAL;
435
436 - /* Compare suplied MAC address with WDS MAC of this interface
437 - * remove when mac address is known
438 - */
439 - if (memcmp(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN) == 0) {
440 - if (IS_UP(vap->iv_dev)) {
441 - wds_ni = ieee80211_find_txnode(vap, vap->wds_mac);
442 - if (wds_ni != NULL) {
443 - /* Release reference created by find node */
444 - ieee80211_unref_node(&wds_ni);
445 - /* Release reference created by transition to RUN state,
446 - * [pinning peer node into the table] */
447 - ieee80211_unref_node(&wds_ni);
448 - }
449 - }
450 - memset(vap->wds_mac, 0x00, IEEE80211_ADDR_LEN);
451 - if (IS_UP(vap->iv_dev)) {
452 - /* This leaves a dead WDS node, until started again */
453 - return ic->ic_reset(ic->ic_dev);
454 - }
455 - return 0;
456 + memcpy(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
457 + if (IS_UP(vap->iv_dev)) {
458 + /* Force us back to scan state to force us to go back through RUN
459 + * state and create/pin the WDS peer node into memory. */
460 + return ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
461 }
462
463 - printk("%s: WDS MAC address " MAC_FMT " is not known by this interface\n",
464 - dev->name, MAC_ADDR(sa->sa_data));
465 -
466 - return -1;
467 + return 0;
468 }
469
470 /*
471 @@ -4470,6 +4461,8 @@ get_sta_space(void *arg, struct ieee8021
472 struct ieee80211vap *vap = ni->ni_vap;
473 size_t ielen;
474
475 + if (req->vap->iv_wdsnode && ni->ni_subif)
476 + vap = ni->ni_subif;
477 if (vap != req->vap && vap != req->vap->iv_xrvap) /* only entries for this vap */
478 return;
479 if ((vap->iv_opmode == IEEE80211_M_HOSTAP ||
480 @@ -4489,6 +4482,8 @@ get_sta_info(void *arg, struct ieee80211
481 size_t ielen, len;
482 u_int8_t *cp;
483
484 + if (req->vap->iv_wdsnode && ni->ni_subif)
485 + vap = ni->ni_subif;
486 if (vap != req->vap && vap != req->vap->iv_xrvap) /* only entries for this vap (or) xrvap */
487 return;
488 if ((vap->iv_opmode == IEEE80211_M_HOSTAP ||
489 @@ -5391,8 +5386,8 @@ static const struct iw_priv_args ieee802
490 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "kickmac"},
491 { IEEE80211_IOCTL_WDSADDMAC,
492 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_add" },
493 - { IEEE80211_IOCTL_WDSDELMAC,
494 - IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_del" },
495 + { IEEE80211_IOCTL_WDSSETMAC,
496 + IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_set" },
497 { IEEE80211_IOCTL_SETCHANLIST,
498 IW_PRIV_TYPE_CHANLIST | IW_PRIV_SIZE_FIXED, 0,"setchanlist" },
499 { IEEE80211_IOCTL_GETCHANLIST,
500 @@ -5790,6 +5785,10 @@ static const struct iw_priv_args ieee802
501 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
502 { IEEE80211_IOCTL_SETSCANLIST,
503 IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
504 + { IEEE80211_PARAM_WDS_SEP,
505 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wdssep"},
506 + { IEEE80211_PARAM_WDS_SEP,
507 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_wdssep"},
508
509 #ifdef ATH_REVERSE_ENGINEERING
510 /*
511 @@ -5884,8 +5883,8 @@ static const iw_handler ieee80211_priv_h
512 #endif
513 set_priv(IEEE80211_IOCTL_ADDMAC, ieee80211_ioctl_addmac),
514 set_priv(IEEE80211_IOCTL_DELMAC, ieee80211_ioctl_delmac),
515 - set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
516 - set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
517 + set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsaddmac),
518 + set_priv(IEEE80211_IOCTL_WDSSETMAC, ieee80211_ioctl_wdssetmac),
519 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
520 set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
521 #ifdef ATH_REVERSE_ENGINEERING
522 @@ -5913,6 +5912,8 @@ static int
523 ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
524 {
525 struct ieee80211vap *vap = dev->priv;
526 + struct ieee80211com *ic = vap->iv_ic;
527 + struct ieee80211_node *ni;
528
529 switch (cmd) {
530 case SIOCG80211STATS:
531 @@ -5921,8 +5922,20 @@ ieee80211_ioctl(struct net_device *dev,
532 case SIOC80211IFDESTROY:
533 if (!capable(CAP_NET_ADMIN))
534 return -EPERM;
535 + /* drop all node subifs */
536 + TAILQ_FOREACH(ni, &ic->ic_sta.nt_node, ni_list) {
537 + struct ieee80211vap *avp = ni->ni_subif;
538 +
539 + if (ni->ni_vap != vap)
540 + continue;
541 + if (!avp)
542 + continue;
543 + ni->ni_subif = NULL;
544 + ieee80211_stop(avp->iv_dev);
545 + ic->ic_vap_delete(avp);
546 + }
547 ieee80211_stop(vap->iv_dev); /* force state before cleanup */
548 - vap->iv_ic->ic_vap_delete(vap);
549 + ic->ic_vap_delete(vap);
550 return 0;
551 case IEEE80211_IOCTL_GETKEY:
552 return ieee80211_ioctl_getkey(dev, (struct iwreq *) ifr);
553 @@ -5956,7 +5969,7 @@ ieee80211_ioctl_create_vap(struct ieee80
554
555 strncpy(name, cp.icp_name, sizeof(name));
556
557 - vap = ieee80211_create_vap(ic, name, mdev, cp.icp_opmode, cp.icp_flags);
558 + vap = ieee80211_create_vap(ic, name, mdev, cp.icp_opmode, cp.icp_flags, NULL);
559 if (vap == NULL)
560 return -EIO;
561
562 @@ -5973,9 +5986,9 @@ EXPORT_SYMBOL(ieee80211_ioctl_create_vap
563 */
564 struct ieee80211vap*
565 ieee80211_create_vap(struct ieee80211com *ic, char *name,
566 - struct net_device *mdev, int opmode, int opflags)
567 + struct net_device *mdev, int opmode, int opflags, struct ieee80211vap *master)
568 {
569 - return ic->ic_vap_create(ic, name, opmode, opflags, mdev);
570 + return ic->ic_vap_create(ic, name, opmode, opflags, mdev, master);
571 }
572 EXPORT_SYMBOL(ieee80211_create_vap);
573
574 --- a/net80211/ieee80211_input.c
575 +++ b/net80211/ieee80211_input.c
576 @@ -199,8 +199,10 @@ ieee80211_input(struct ieee80211vap * va
577 {
578 #define HAS_SEQ(type) ((type & 0x4) == 0)
579 struct ieee80211_node * ni = ni_or_null;
580 - struct ieee80211com *ic = vap->iv_ic;
581 - struct net_device *dev = vap->iv_dev;
582 + struct ieee80211com *ic;
583 + struct net_device *dev;
584 + struct ieee80211_node *ni_wds = NULL;
585 + struct net_device_stats *stats;
586 struct ieee80211_frame *wh;
587 struct ieee80211_key *key;
588 struct ether_header *eh;
589 @@ -212,6 +214,19 @@ ieee80211_input(struct ieee80211vap * va
590 u_int8_t *bssid;
591 u_int16_t rxseq;
592
593 + type = -1; /* undefined */
594 +
595 + if (!vap)
596 + goto out;
597 +
598 + ic = vap->iv_ic;
599 + if (!ic)
600 + goto out;
601 +
602 + dev = vap->iv_dev;
603 + if (!dev)
604 + goto out;
605 +
606 /* initialize ni as in the previous API */
607 if (ni_or_null == NULL) {
608 /* This function does not 'own' vap->iv_bss, so we cannot
609 @@ -227,7 +242,6 @@ ieee80211_input(struct ieee80211vap * va
610
611 /* XXX adjust device in sk_buff? */
612
613 - type = -1; /* undefined */
614 /*
615 * In monitor mode, send everything directly to bpf.
616 * Also do not process frames w/o i_addr2 any further.
617 @@ -434,7 +448,7 @@ ieee80211_input(struct ieee80211vap * va
618
619 switch (type) {
620 case IEEE80211_FC0_TYPE_DATA:
621 - hdrspace = ieee80211_hdrspace(ic, wh);
622 + hdrspace = ieee80211_hdrsize(wh);
623 if (skb->len < hdrspace) {
624 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY,
625 wh, "data", "too short: len %u, expecting %u",
626 @@ -444,16 +458,24 @@ ieee80211_input(struct ieee80211vap * va
627 }
628 switch (vap->iv_opmode) {
629 case IEEE80211_M_STA:
630 - if ((dir != IEEE80211_FC1_DIR_FROMDS) &&
631 - (!((vap->iv_flags_ext & IEEE80211_FEXT_WDS) &&
632 - (dir == IEEE80211_FC1_DIR_DSTODS)))) {
633 + switch(dir) {
634 + case IEEE80211_FC1_DIR_FROMDS:
635 + break;
636 + case IEEE80211_FC1_DIR_DSTODS:
637 + if (vap->iv_flags_ext & IEEE80211_FEXT_WDS)
638 + break;
639 + default:
640 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY,
641 wh, "data", "invalid dir 0x%x", dir);
642 vap->iv_stats.is_rx_wrongdir++;
643 goto out;
644 }
645
646 - if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
647 + if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
648 + /* ignore 3-addr mcast if we're WDS STA */
649 + if (vap->iv_flags_ext & IEEE80211_FEXT_WDS)
650 + goto out;
651 +
652 /* Discard multicast if IFF_MULTICAST not set */
653 if ((0 != memcmp(wh->i_addr3, dev->broadcast, ETH_ALEN)) &&
654 (0 == (dev->flags & IFF_MULTICAST))) {
655 @@ -481,24 +503,10 @@ ieee80211_input(struct ieee80211vap * va
656 vap->iv_stats.is_rx_mcastecho++;
657 goto out;
658 }
659 - /*
660 - * if it is brodcasted by me on behalf of
661 - * a station behind me, drop it.
662 - */
663 - if (vap->iv_flags_ext & IEEE80211_FEXT_WDS) {
664 - struct ieee80211_node_table *nt;
665 - struct ieee80211_node *ni_wds;
666 - nt = &ic->ic_sta;
667 - ni_wds = ieee80211_find_wds_node(nt, wh->i_addr3);
668 - if (ni_wds) {
669 - ieee80211_unref_node(&ni_wds);
670 - IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
671 - wh, NULL, "%s",
672 - "multicast echo originated from node behind me");
673 - vap->iv_stats.is_rx_mcastecho++;
674 - goto out;
675 - }
676 - }
677 + } else {
678 + /* Same BSSID, but not meant for us to receive */
679 + if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr))
680 + goto out;
681 }
682 break;
683 case IEEE80211_M_IBSS:
684 @@ -540,16 +548,28 @@ ieee80211_input(struct ieee80211vap * va
685 vap->iv_stats.is_rx_notassoc++;
686 goto err;
687 }
688 +
689 /*
690 * If we're a 4 address packet, make sure we have an entry in
691 * the node table for the packet source address (addr4).
692 * If not, add one.
693 */
694 + /* check for wds link first */
695 + if ((dir == IEEE80211_FC1_DIR_DSTODS) && !ni->ni_subif) {
696 + if (vap->iv_flags_ext & IEEE80211_FEXT_WDSSEP) {
697 + ieee80211_wds_addif(ni);
698 + /* we must drop frames here until the interface has
699 + * been fully separated, otherwise a bridge might get
700 + * confused */
701 + goto err;
702 + }
703 + }
704 +
705 /* XXX: Useless node mgmt API; make better */
706 - if (dir == IEEE80211_FC1_DIR_DSTODS) {
707 - struct ieee80211_node_table *nt;
708 + if ((dir == IEEE80211_FC1_DIR_DSTODS) && !vap->iv_wdsnode &&
709 + !ni_wds && !ni->ni_subif) {
710 + struct ieee80211_node_table *nt = &ic->ic_sta;
711 struct ieee80211_frame_addr4 *wh4;
712 - struct ieee80211_node *ni_wds;
713
714 if (!(vap->iv_flags_ext & IEEE80211_FEXT_WDS)) {
715 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
716 @@ -557,7 +577,6 @@ ieee80211_input(struct ieee80211vap * va
717 goto err;
718 }
719 wh4 = (struct ieee80211_frame_addr4 *)skb->data;
720 - nt = &ic->ic_sta;
721 ni_wds = ieee80211_find_wds_node(nt, wh4->i_addr4);
722 /* Last call increments ref count if !NULL */
723 if ((ni_wds != NULL) && (ni_wds != ni)) {
724 @@ -608,6 +627,11 @@ ieee80211_input(struct ieee80211vap * va
725 goto out;
726 }
727
728 + /* check if there is any data left */
729 + hdrspace = ieee80211_hdrspace(ic, wh);
730 + if (skb->len < hdrspace)
731 + goto out;
732 +
733 /*
734 * Handle privacy requirements. Note that we
735 * must not be preempted from here until after
736 @@ -680,8 +704,12 @@ ieee80211_input(struct ieee80211vap * va
737 if (! accept_data_frame(vap, ni, key, skb, eh))
738 goto out;
739
740 - vap->iv_devstats.rx_packets++;
741 - vap->iv_devstats.rx_bytes += skb->len;
742 + if (ni->ni_subif && ((eh)->ether_type != __constant_htons(ETHERTYPE_PAE)))
743 + stats = &ni->ni_subif->iv_devstats;
744 + else
745 + stats = &vap->iv_devstats;
746 + stats->rx_packets++;
747 + stats->rx_bytes += skb->len;
748 IEEE80211_NODE_STAT(ni, rx_data);
749 IEEE80211_NODE_STAT_ADD(ni, rx_bytes, skb->len);
750 ic->ic_lastdata = jiffies;
751 @@ -1114,6 +1142,18 @@ ieee80211_deliver_data(struct ieee80211_
752 dev = vap->iv_xrvap->iv_dev;
753 #endif
754
755 + /* if the node has a wds subif, move data frames there,
756 + * but keep EAP traffic on the master */
757 + if (ni->ni_subif && ((eh)->ether_type != __constant_htons(ETHERTYPE_PAE))) {
758 + if (ni->ni_vap == ni->ni_subif) {
759 + ieee80211_dev_kfree_skb(&skb);
760 + return;
761 + } else {
762 + vap = ni->ni_subif;
763 + dev = vap->iv_dev;
764 + }
765 + }
766 +
767 /* perform as a bridge within the vap */
768 /* XXX intra-vap bridging only */
769 if (vap->iv_opmode == IEEE80211_M_HOSTAP &&
770 @@ -1139,7 +1179,16 @@ ieee80211_deliver_data(struct ieee80211_
771 if (ni1 != NULL) {
772 if (ni1->ni_vap == vap &&
773 ieee80211_node_is_authorized(ni1) &&
774 + !ni1->ni_subif &&
775 ni1 != vap->iv_bss) {
776 +
777 + /* tried to bridge to a subif, drop the packet */
778 + if (ni->ni_subif) {
779 + ieee80211_unref_node(&ni1);
780 + ieee80211_dev_kfree_skb(&skb);
781 + return;
782 + }
783 +
784 skb1 = skb;
785 skb = NULL;
786 }
787 @@ -3084,8 +3133,7 @@ ieee80211_recv_mgmt(struct ieee80211vap
788 (vap->iv_opmode == IEEE80211_M_STA && ni->ni_associd) ||
789 (vap->iv_opmode == IEEE80211_M_IBSS) ||
790 ((subtype == IEEE80211_FC0_SUBTYPE_BEACON) &&
791 - (vap->iv_opmode == IEEE80211_M_HOSTAP) &&
792 - (ic->ic_protmode != IEEE80211_PROT_NONE)))) {
793 + (vap->iv_opmode == IEEE80211_M_HOSTAP)))) {
794 vap->iv_stats.is_rx_mgtdiscard++;
795 return;
796 }
797 @@ -3471,13 +3519,54 @@ ieee80211_recv_mgmt(struct ieee80211vap
798 */
799 if (ic->ic_flags & IEEE80211_F_SCAN) {
800 ieee80211_add_scan(vap, &scan, wh, subtype, rssi, rtsf);
801 - return;
802 }
803 - if ((vap->iv_opmode == IEEE80211_M_IBSS) &&
804 - (scan.capinfo & IEEE80211_CAPINFO_IBSS)) {
805 + /* NB: Behavior of WDS-Link and Ad-Hoc is very similar here:
806 + * When we receive a beacon that belongs to the AP that we're
807 + * connected to, use it to refresh the local node info.
808 + * If no node is found, go through the vap's wds link table
809 + * and try to find the sub-vap that is interested in this address
810 + */
811 + if (((vap->iv_opmode == IEEE80211_M_IBSS) &&
812 + (scan.capinfo & IEEE80211_CAPINFO_IBSS)) ||
813 + (((vap->iv_opmode == IEEE80211_M_HOSTAP) ||
814 + (vap->iv_opmode == IEEE80211_M_WDS)) &&
815 + (scan.capinfo & IEEE80211_CAPINFO_ESS))) {
816 + struct ieee80211vap *avp = NULL;
817 + int found = 0;
818 +
819 + IEEE80211_LOCK_IRQ(vap->iv_ic);
820 + if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
821 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
822 + if (!memcmp(avp->wds_mac, wh->i_addr2, IEEE80211_ADDR_LEN)) {
823 + if (avp->iv_state != IEEE80211_S_RUN)
824 + continue;
825 + found = 1;
826 + break;
827 + }
828 + }
829 + if (found)
830 + ni = ni_or_null = avp->iv_wdsnode;
831 + } else if (vap->iv_opmode == IEEE80211_M_WDS) {
832 + found = 1;
833 + ni = ni_or_null = vap->iv_wdsnode;
834 + }
835 + IEEE80211_UNLOCK_IRQ(vap->iv_ic);
836 +
837 + if (!found)
838 + break;
839 +
840 if (ni_or_null == NULL) {
841 - /* Create a new entry in the neighbor table. */
842 - ni = ieee80211_add_neighbor(vap, wh, &scan);
843 + if (avp) {
844 + IEEE80211_LOCK_IRQ(ic);
845 + ni = ieee80211_add_neighbor(avp, wh, &scan);
846 + /* force assoc */
847 + ni->ni_associd |= 0xc000;
848 + avp->iv_wdsnode = ieee80211_ref_node(ni);
849 + IEEE80211_UNLOCK_IRQ(ic);
850 + } else if (vap->iv_opmode == IEEE80211_M_IBSS) {
851 + /* Create a new entry in the neighbor table. */
852 + ni = ieee80211_add_neighbor(vap, wh, &scan);
853 + }
854 } else {
855 /*
856 * Copy data from beacon to neighbor table.
857 @@ -3490,6 +3579,7 @@ ieee80211_recv_mgmt(struct ieee80211vap
858 IEEE80211_ADDR_COPY(ni->ni_bssid, wh->i_addr3);
859 memcpy(ni->ni_tstamp.data, scan.tstamp,
860 sizeof(ni->ni_tstamp));
861 + ni->ni_inact = ni->ni_inact_reload;
862 ni->ni_intval =
863 IEEE80211_BINTVAL_SANITISE(scan.bintval);
864 ni->ni_capinfo = scan.capinfo;
865 --- a/net80211/ieee80211_node.c
866 +++ b/net80211/ieee80211_node.c
867 @@ -47,6 +47,7 @@
868 #include <linux/netdevice.h>
869 #include <linux/etherdevice.h>
870 #include <linux/random.h>
871 +#include <linux/rtnetlink.h>
872
873 #include "if_media.h"
874
875 @@ -236,7 +237,11 @@ void
876 ieee80211_node_vdetach(struct ieee80211vap *vap)
877 {
878 struct ieee80211com *ic = vap->iv_ic;
879 + struct ieee80211_node *ni;
880
881 + ni = vap->iv_wdsnode;
882 + if (ni)
883 + ni->ni_subif = NULL;
884 ieee80211_node_table_reset(&ic->ic_sta, vap);
885 if (vap->iv_bss != NULL) {
886 ieee80211_unref_node(&vap->iv_bss);
887 @@ -309,7 +314,7 @@ ieee80211_create_ibss(struct ieee80211va
888 /* Check to see if we already have a node for this mac
889 * NB: we gain a node reference here
890 */
891 - ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr);
892 + ni = ieee80211_find_txnode(vap, vap->iv_myaddr);
893 if (ni == NULL) {
894 ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr);
895 IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
896 @@ -831,12 +836,18 @@ node_table_leave_locked(struct ieee80211
897 LIST_REMOVE(ni, ni_hash);
898 }
899 ni->ni_table = NULL;
900 + if (ni->ni_vap->iv_wdsnode == ni) {
901 +#ifdef IEEE80211_DEBUG_REFCNT
902 + ieee80211_unref_node_debug(&ni->ni_vap->iv_wdsnode, func, line);
903 +#else
904 + ieee80211_unref_node(&ni->ni_vap->iv_wdsnode);
905 +#endif
906 + }
907 #ifdef IEEE80211_DEBUG_REFCNT
908 ieee80211_unref_node_debug(&ni, func, line);
909 #else
910 ieee80211_unref_node(&ni);
911 #endif
912 -
913 }
914
915 /* This is overridden by ath_node_alloc in ath/if_ath.c, and so
916 @@ -1134,6 +1145,65 @@ ieee80211_alloc_node(struct ieee80211vap
917 return ni;
918 }
919
920 +#define WDSIFNAME ".sta%d"
921 +static void
922 +ieee80211_wds_do_addif(struct work_struct *work)
923 +{
924 + struct ieee80211_node *ni = container_of(work, struct ieee80211_node, ni_create);
925 + struct ieee80211vap *vap = ni->ni_vap;
926 + struct ieee80211com *ic = vap->iv_ic;
927 + struct ieee80211vap *avp = NULL;
928 + char *name;
929 +
930 + rtnl_lock();
931 + /* did we get cancelled by the destroy call? */
932 + if (!ni->ni_subif)
933 + goto done;
934 +
935 + ni->ni_subif = NULL;
936 + name = kmalloc(strlen(vap->iv_dev->name) + sizeof(WDSIFNAME) + 1, GFP_KERNEL);
937 + if (!name)
938 + goto done;
939 +
940 + strcpy(name, vap->iv_dev->name);
941 + strcat(name, WDSIFNAME);
942 + avp = ieee80211_create_vap(ic, name, ic->ic_dev, IEEE80211_M_WDS, 0, vap);
943 + kfree(name);
944 + if (!avp)
945 + goto done;
946 +
947 + memcpy(avp->wds_mac, ni->ni_bssid, IEEE80211_ADDR_LEN);
948 + avp->iv_wdsnode = ieee80211_ref_node(ni);
949 + ni->ni_subif = avp;
950 + ic->ic_subifs++;
951 +
952 +done:
953 + if (avp) {
954 + IEEE80211_VAPS_LOCK_IRQ(ic);
955 + avp->iv_newstate(vap, IEEE80211_S_RUN, -1);
956 + IEEE80211_VAPS_UNLOCK_IRQ(ic);
957 + }
958 + rtnl_unlock();
959 + ieee80211_unref_node(&ni);
960 +}
961 +#undef WDSIFNAME
962 +
963 +void ieee80211_wds_addif(struct ieee80211_node *ni)
964 +{
965 + /* check if the node is split out already,
966 + * or if we're in progress of setting up a new interface already */
967 + if (ni->ni_subif)
968 + return;
969 +
970 + if (!ni->ni_table)
971 + return;
972 +
973 + ieee80211_ref_node(ni);
974 + ni->ni_subif = ni->ni_vap;
975 + IEEE80211_INIT_WORK(&ni->ni_create, ieee80211_wds_do_addif);
976 + schedule_work(&ni->ni_create);
977 +}
978 +
979 /* Add wds address to the node table */
980 int
981 #ifdef IEEE80211_DEBUG_REFCNT
982 @@ -1553,22 +1623,39 @@ ieee80211_find_rxnode(struct ieee80211co
983 ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PS_POLL)
984 struct ieee80211_node_table *nt;
985 struct ieee80211_node *ni;
986 + struct ieee80211vap *vap, *avp;
987 + const u_int8_t *addr;
988 +
989 + if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/)
990 + addr = wh->i_addr1;
991 + else
992 + addr = wh->i_addr2;
993 +
994 + if (IEEE80211_IS_MULTICAST(addr))
995 + return NULL;
996
997 /* XXX check ic_bss first in station mode */
998 /* XXX 4-address frames? */
999 nt = &ic->ic_sta;
1000 IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
1001 - if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/)
1002 -#ifdef IEEE80211_DEBUG_REFCNT
1003 - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr1, func, line);
1004 -#else
1005 - ni = ieee80211_find_node_locked(nt, wh->i_addr1);
1006 -#endif
1007 - else
1008 + if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) {
1009 + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
1010 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
1011 + if (!IEEE80211_ADDR_EQ(addr, avp->wds_mac))
1012 + continue;
1013 +
1014 + if (avp->iv_wdsnode)
1015 + return ieee80211_ref_node(avp->iv_wdsnode);
1016 + else
1017 + return NULL;
1018 + }
1019 + }
1020 + }
1021 +
1022 #ifdef IEEE80211_DEBUG_REFCNT
1023 - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr2, func, line);
1024 + ni = ieee80211_find_node_locked_debug(nt, addr, func, line);
1025 #else
1026 - ni = ieee80211_find_node_locked(nt, wh->i_addr2);
1027 + ni = ieee80211_find_node_locked(nt, addr);
1028 #endif
1029 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
1030
1031 @@ -1596,9 +1683,19 @@ ieee80211_find_txnode_debug(struct ieee8
1032 ieee80211_find_txnode(struct ieee80211vap *vap, const u_int8_t *mac)
1033 #endif
1034 {
1035 + struct ieee80211com *ic = vap->iv_ic;
1036 struct ieee80211_node_table *nt;
1037 struct ieee80211_node *ni = NULL;
1038
1039 + IEEE80211_LOCK_IRQ(ic);
1040 + if (vap->iv_opmode == IEEE80211_M_WDS) {
1041 + if (vap->iv_wdsnode && (vap->iv_state == IEEE80211_S_RUN))
1042 + return ieee80211_ref_node(vap->iv_wdsnode);
1043 + else
1044 + return NULL;
1045 + }
1046 + IEEE80211_UNLOCK_IRQ(ic);
1047 +
1048 /*
1049 * The destination address should be in the node table
1050 * unless we are operating in station mode or this is a
1051 @@ -1669,6 +1766,11 @@ ieee80211_free_node(struct ieee80211_nod
1052 {
1053 struct ieee80211vap *vap = ni->ni_vap;
1054
1055 + IEEE80211_LOCK_IRQ(ni->ni_ic);
1056 + if (vap && ni == vap->iv_wdsnode)
1057 + vap->iv_wdsnode = NULL;
1058 + IEEE80211_UNLOCK_IRQ(ni->ni_ic);
1059 +
1060 atomic_dec(&ni->ni_ic->ic_node_counter);
1061 node_print_message(IEEE80211_MSG_NODE|IEEE80211_MSG_NODE_REF,
1062 1 /* show counter */,
1063 @@ -1781,22 +1883,6 @@ restart:
1064 jiffies > ni->ni_rxfragstamp + HZ) {
1065 ieee80211_dev_kfree_skb(&ni->ni_rxfrag);
1066 }
1067 - /*
1068 - * Special case ourself; we may be idle for extended periods
1069 - * of time and regardless reclaiming our state is wrong.
1070 - * Special case a WDS link: it may be dead or idle, but it is
1071 - * never ok to reclaim it, as this will block transmissions
1072 - * and nobody will recreate the node when the WDS peer is
1073 - * available again. */
1074 - if ((ni == ni->ni_vap->iv_bss) ||
1075 - (ni->ni_vap->iv_opmode == IEEE80211_M_WDS &&
1076 - !memcmp(ni->ni_macaddr, ni->ni_vap->wds_mac, ETH_ALEN)))
1077 - {
1078 - /* NB: don't permit it to go negative */
1079 - if (ni->ni_inact > 0)
1080 - ni->ni_inact--;
1081 - continue;
1082 - }
1083 ni->ni_inact--;
1084 if (ni->ni_associd != 0 || isadhoc) {
1085 struct ieee80211vap *vap = ni->ni_vap;
1086 @@ -2263,6 +2349,35 @@ ieee80211_node_leave_11g(struct ieee8021
1087 }
1088 }
1089
1090 +static void
1091 +ieee80211_subif_destroy(struct work_struct *work)
1092 +{
1093 + struct ieee80211_node *ni = container_of(work, struct ieee80211_node, ni_destroy);
1094 + struct ieee80211vap *vap;
1095 + struct ieee80211com *ic;
1096 +
1097 + /* wait for full initialization before we start the teardown
1098 + * otherwise we could leak interfaces */
1099 + while (ni->ni_subif == ni->ni_vap)
1100 + schedule();
1101 +
1102 + rtnl_lock();
1103 + vap = ni->ni_subif;
1104 +
1105 + if (!vap)
1106 + goto done;
1107 +
1108 + ic = vap->iv_ic;
1109 + ni->ni_subif = NULL;
1110 + ieee80211_stop(vap->iv_dev);
1111 + ic->ic_vap_delete(vap);
1112 + ic->ic_subifs--;
1113 +
1114 +done:
1115 + ieee80211_unref_node(&ni);
1116 + rtnl_unlock();
1117 +}
1118 +
1119 /*
1120 * Handle bookkeeping for a station/neighbor leaving
1121 * the bss when operating in ap or adhoc modes.
1122 @@ -2279,6 +2394,12 @@ ieee80211_node_leave(struct ieee80211_no
1123 ni, "station with aid %d leaves (refcnt %u)",
1124 IEEE80211_NODE_AID(ni), atomic_read(&ni->ni_refcnt));
1125
1126 + if (ni->ni_subif) {
1127 + ieee80211_ref_node(ni);
1128 + IEEE80211_INIT_WORK(&ni->ni_destroy, ieee80211_subif_destroy);
1129 + schedule_work(&ni->ni_destroy);
1130 + }
1131 +
1132 /* From this point onwards we can no longer find the node,
1133 * so no more references are generated
1134 */
1135 --- a/net80211/ieee80211_output.c
1136 +++ b/net80211/ieee80211_output.c
1137 @@ -246,15 +246,16 @@ ieee80211_hardstart(struct sk_buff *skb,
1138 * things like power save.
1139 */
1140 eh = (struct ether_header *)skb->data;
1141 - if (vap->iv_opmode == IEEE80211_M_WDS)
1142 - ni = ieee80211_find_txnode(vap, vap->wds_mac);
1143 - else
1144 - ni = ieee80211_find_txnode(vap, eh->ether_dhost);
1145 + ni = ieee80211_find_txnode(vap, eh->ether_dhost);
1146 if (ni == NULL) {
1147 /* NB: ieee80211_find_txnode does stat+msg */
1148 goto bad;
1149 }
1150
1151 + if (ni->ni_subif && (vap != ni->ni_subif) &&
1152 + ((eh)->ether_type != __constant_htons(ETHERTYPE_PAE)))
1153 + goto bad;
1154 +
1155 /* calculate priority so drivers can find the TX queue */
1156 if (ieee80211_classify(ni, skb)) {
1157 IEEE80211_NOTE(vap, IEEE80211_MSG_OUTPUT, ni,
1158 @@ -334,20 +335,33 @@ void ieee80211_parent_queue_xmit(struct
1159 * constructing a frame as it sets i_fc[1]; other bits can
1160 * then be or'd in.
1161 */
1162 -static void
1163 +static struct ieee80211_frame *
1164 ieee80211_send_setup(struct ieee80211vap *vap,
1165 struct ieee80211_node *ni,
1166 - struct ieee80211_frame *wh,
1167 + struct sk_buff *skb,
1168 int type,
1169 const u_int8_t sa[IEEE80211_ADDR_LEN],
1170 const u_int8_t da[IEEE80211_ADDR_LEN],
1171 const u_int8_t bssid[IEEE80211_ADDR_LEN])
1172 {
1173 #define WH4(wh) ((struct ieee80211_frame_addr4 *)wh)
1174 + struct ieee80211_frame *wh;
1175 + int len = sizeof(struct ieee80211_frame);
1176 + int opmode = vap->iv_opmode;
1177
1178 + if ((type & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA) {
1179 + if ((opmode == IEEE80211_M_STA) &&
1180 + (vap->iv_flags_ext & IEEE80211_FEXT_WDS))
1181 + opmode = IEEE80211_M_WDS;
1182 +
1183 + if (opmode == IEEE80211_M_WDS)
1184 + len = sizeof(struct ieee80211_frame_addr4);
1185 + }
1186 +
1187 + wh = (struct ieee80211_frame *)skb_push(skb, len);
1188 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | type;
1189 if ((type & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA) {
1190 - switch (vap->iv_opmode) {
1191 + switch (opmode) {
1192 case IEEE80211_M_STA:
1193 wh->i_fc[1] = IEEE80211_FC1_DIR_TODS;
1194 IEEE80211_ADDR_COPY(wh->i_addr1, bssid);
1195 @@ -389,6 +403,8 @@ ieee80211_send_setup(struct ieee80211vap
1196 *(__le16 *)&wh->i_seq[0] =
1197 htole16(ni->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT);
1198 ni->ni_txseqs[0]++;
1199 +
1200 + return wh;
1201 #undef WH4
1202 }
1203
1204 @@ -410,9 +426,7 @@ ieee80211_mgmt_output(struct ieee80211_n
1205
1206 SKB_CB(skb)->ni = ni;
1207
1208 - wh = (struct ieee80211_frame *)
1209 - skb_push(skb, sizeof(struct ieee80211_frame));
1210 - ieee80211_send_setup(vap, ni, wh,
1211 + wh = ieee80211_send_setup(vap, ni, skb,
1212 IEEE80211_FC0_TYPE_MGT | type,
1213 vap->iv_myaddr, ni->ni_macaddr, vap->iv_bssid);
1214 /* XXX power management */
1215 @@ -458,6 +472,9 @@ ieee80211_send_nulldata(struct ieee80211
1216 struct ieee80211_frame *wh;
1217 u_int8_t *frm;
1218
1219 + if (ni->ni_subif)
1220 + vap = ni->ni_subif;
1221 +
1222 skb = ieee80211_getmgtframe(&frm, 0);
1223 if (skb == NULL) {
1224 /* XXX debug msg */
1225 @@ -466,9 +483,7 @@ ieee80211_send_nulldata(struct ieee80211
1226 return -ENOMEM;
1227 }
1228
1229 - wh = (struct ieee80211_frame *)
1230 - skb_push(skb, sizeof(struct ieee80211_frame));
1231 - ieee80211_send_setup(vap, ni, wh,
1232 + wh = ieee80211_send_setup(vap, ni, skb,
1233 IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA,
1234 vap->iv_myaddr, ni->ni_macaddr, vap->iv_bssid);
1235 /* NB: power management bit is never sent by an AP */
1236 @@ -506,6 +521,7 @@ ieee80211_send_qosnulldata(struct ieee80
1237 struct sk_buff *skb;
1238 struct ieee80211_qosframe *qwh;
1239 u_int8_t *frm;
1240 + u_int8_t *i_qos;
1241 int tid;
1242
1243 skb = ieee80211_getmgtframe(&frm, 2);
1244 @@ -517,11 +533,12 @@ ieee80211_send_qosnulldata(struct ieee80
1245 SKB_CB(skb)->ni = ieee80211_ref_node(ni);
1246
1247 skb->priority = ac;
1248 - qwh = (struct ieee80211_qosframe *)skb_push(skb, sizeof(struct ieee80211_qosframe));
1249
1250 - qwh = (struct ieee80211_qosframe *)skb->data;
1251 + /* grab a pointer to QoS control and also compensate for the header length
1252 + * difference between QoS and non-QoS frame */
1253 + i_qos = skb_push(skb, sizeof(struct ieee80211_qosframe) - sizeof(struct ieee80211_frame));
1254
1255 - ieee80211_send_setup(vap, ni, (struct ieee80211_frame *)qwh,
1256 + qwh = (struct ieee80211_qosframe *) ieee80211_send_setup(vap, ni, skb,
1257 IEEE80211_FC0_TYPE_DATA,
1258 vap->iv_myaddr, /* SA */
1259 ni->ni_macaddr, /* DA */
1260 @@ -535,10 +552,10 @@ ieee80211_send_qosnulldata(struct ieee80
1261
1262 /* map from access class/queue to 11e header priority value */
1263 tid = WME_AC_TO_TID(ac);
1264 - qwh->i_qos[0] = tid & IEEE80211_QOS_TID;
1265 + i_qos[0] = tid & IEEE80211_QOS_TID;
1266 if (ic->ic_wme.wme_wmeChanParams.cap_wmeParams[ac].wmep_noackPolicy)
1267 qwh->i_qos[0] |= (1 << IEEE80211_QOS_ACKPOLICY_S) & IEEE80211_QOS_ACKPOLICY;
1268 - qwh->i_qos[1] = 0;
1269 + i_qos[1] = 0;
1270
1271 IEEE80211_NODE_STAT(ni, tx_data);
1272
1273 @@ -780,6 +797,8 @@ ieee80211_encap(struct ieee80211_node *n
1274 hdrsize = sizeof(struct ieee80211_frame);
1275
1276 SKB_CB(skb)->auth_pkt = (eh.ether_type == __constant_htons(ETHERTYPE_PAE));
1277 + if (ni->ni_subif)
1278 + vap = ni->ni_subif;
1279
1280 switch (vap->iv_opmode) {
1281 case IEEE80211_M_IBSS:
1282 @@ -788,7 +807,7 @@ ieee80211_encap(struct ieee80211_node *n
1283 break;
1284 case IEEE80211_M_WDS:
1285 use4addr = 1;
1286 - ismulticast = IEEE80211_IS_MULTICAST(ni->ni_macaddr);
1287 + ismulticast = 0;
1288 break;
1289 case IEEE80211_M_HOSTAP:
1290 if (!IEEE80211_IS_MULTICAST(eh.ether_dhost) &&
1291 @@ -799,20 +818,9 @@ ieee80211_encap(struct ieee80211_node *n
1292 ismulticast = IEEE80211_IS_MULTICAST(eh.ether_dhost);
1293 break;
1294 case IEEE80211_M_STA:
1295 - if ((vap->iv_flags_ext & IEEE80211_FEXT_WDS) &&
1296 - !IEEE80211_ADDR_EQ(eh.ether_shost, vap->iv_myaddr)) {
1297 + if (vap->iv_flags_ext & IEEE80211_FEXT_WDS) {
1298 use4addr = 1;
1299 - ismulticast = IEEE80211_IS_MULTICAST(ni->ni_macaddr);
1300 - /* Add a WDS entry to the station VAP */
1301 - if (IEEE80211_IS_MULTICAST(eh.ether_dhost)) {
1302 - struct ieee80211_node_table *nt = &ic->ic_sta;
1303 - struct ieee80211_node *ni_wds
1304 - = ieee80211_find_wds_node(nt, eh.ether_shost);
1305 - if (ni_wds)
1306 - ieee80211_unref_node(&ni_wds);
1307 - else
1308 - ieee80211_add_wds_addr(nt, ni, eh.ether_shost, 0);
1309 - }
1310 + ismulticast = 0;
1311 } else
1312 ismulticast = IEEE80211_IS_MULTICAST(vap->iv_bssid);
1313 break;
1314 @@ -973,7 +981,7 @@ ieee80211_encap(struct ieee80211_node *n
1315 break;
1316 case IEEE80211_M_WDS:
1317 wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS;
1318 - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr);
1319 + IEEE80211_ADDR_COPY(wh->i_addr1, vap->wds_mac);
1320 IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr);
1321 IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost);
1322 IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, eh.ether_shost);
1323 @@ -1683,9 +1691,7 @@ ieee80211_send_probereq(struct ieee80211
1324
1325 SKB_CB(skb)->ni = ieee80211_ref_node(ni);
1326
1327 - wh = (struct ieee80211_frame *)
1328 - skb_push(skb, sizeof(struct ieee80211_frame));
1329 - ieee80211_send_setup(vap, ni, wh,
1330 + wh = ieee80211_send_setup(vap, ni, skb,
1331 IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_REQ,
1332 sa, da, bssid);
1333 /* XXX power management? */
1334 --- a/tools/athkey.c
1335 +++ b/tools/athkey.c
1336 @@ -118,7 +118,7 @@ set80211priv(const char *dev, int op, vo
1337 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
1338 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
1339 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
1340 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
1341 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
1342 IOCTL_ERR(IEEE80211_IOCTL_READREG),
1343 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
1344 };
1345 --- a/tools/athchans.c
1346 +++ b/tools/athchans.c
1347 @@ -118,7 +118,7 @@ set80211priv(const char *dev, int op, vo
1348 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
1349 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
1350 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
1351 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
1352 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
1353 IOCTL_ERR(IEEE80211_IOCTL_READREG),
1354 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
1355 };
1356 --- a/tools/wlanconfig.c
1357 +++ b/tools/wlanconfig.c
1358 @@ -968,7 +968,7 @@ do80211priv(struct iwreq *iwr, const cha
1359 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
1360 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
1361 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
1362 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
1363 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
1364 IOCTL_ERR(IEEE80211_IOCTL_READREG),
1365 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
1366 };
1367 --- a/net80211/ieee80211_proto.c
1368 +++ b/net80211/ieee80211_proto.c
1369 @@ -979,6 +979,12 @@ ieee80211_init(struct net_device *dev, i
1370 "start running (state=%d)\n", vap->iv_state);
1371
1372
1373 + if (vap->iv_master && vap->iv_master->iv_state == IEEE80211_S_INIT) {
1374 + int ret = ieee80211_init(vap->iv_master->iv_dev, forcescan);
1375 + if (ret < 0)
1376 + return ret;
1377 + }
1378 +
1379 if ((dev->flags & IFF_RUNNING) == 0) {
1380 if (ic->ic_nopened++ == 0 &&
1381 (parent->flags & IFF_RUNNING) == 0)
1382 @@ -1081,6 +1087,8 @@ ieee80211_init(struct net_device *dev, i
1383 int
1384 ieee80211_open(struct net_device *dev)
1385 {
1386 + struct ieee80211vap *vap = dev->priv;
1387 +
1388 return ieee80211_init(dev, 0);
1389 }
1390
1391 @@ -1090,7 +1098,7 @@ ieee80211_open(struct net_device *dev)
1392 void
1393 ieee80211_start_running(struct ieee80211com *ic)
1394 {
1395 - struct ieee80211vap *vap;
1396 + struct ieee80211vap *vap, *avp;
1397 struct net_device *dev;
1398
1399 /* XXX locking */
1400 @@ -1099,6 +1107,16 @@ ieee80211_start_running(struct ieee80211
1401 /* NB: avoid recursion */
1402 if ((dev->flags & IFF_UP) && !(dev->flags & IFF_RUNNING))
1403 ieee80211_open(dev);
1404 +
1405 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
1406 + if (avp->iv_wdsnode && avp->iv_wdsnode->ni_subif == avp)
1407 + continue;
1408 +
1409 + dev = avp->iv_dev;
1410 + /* NB: avoid recursion */
1411 + if ((dev->flags & IFF_UP) && !(dev->flags & IFF_RUNNING))
1412 + ieee80211_open(dev);
1413 + }
1414 }
1415 }
1416 EXPORT_SYMBOL(ieee80211_start_running);
1417 @@ -1116,11 +1134,43 @@ ieee80211_stop(struct net_device *dev)
1418 struct ieee80211vap *vap = dev->priv;
1419 struct ieee80211com *ic = vap->iv_ic;
1420 struct net_device *parent = ic->ic_dev;
1421 + struct ieee80211_node *tni, *ni;
1422 + struct ieee80211vap *avp;
1423
1424 IEEE80211_DPRINTF(vap,
1425 IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
1426 "%s\n", "stop running");
1427
1428 + if (vap->iv_wdsnode && !vap->iv_wdsnode->ni_subif)
1429 + ieee80211_unref_node(&vap->iv_wdsnode);
1430 +
1431 + /* stop wds interfaces */
1432 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_next) {
1433 + if (avp->iv_state != IEEE80211_S_INIT)
1434 + ieee80211_stop(avp->iv_dev);
1435 + }
1436 +
1437 + /* get rid of all wds nodes while we're still locked */
1438 + do {
1439 + ni = NULL;
1440 +
1441 + IEEE80211_NODE_TABLE_LOCK_IRQ(&ic->ic_sta);
1442 + TAILQ_FOREACH(tni, &ic->ic_sta.nt_node, ni_list) {
1443 + if (tni->ni_vap != vap)
1444 + continue;
1445 + if (!tni->ni_subif)
1446 + continue;
1447 + ni = tni;
1448 + break;
1449 + }
1450 + IEEE80211_NODE_TABLE_UNLOCK_IRQ(&ic->ic_sta);
1451 +
1452 + if (!ni)
1453 + break;
1454 +
1455 + ieee80211_node_leave(ni);
1456 + } while (1);
1457 +
1458 ieee80211_new_state(vap, IEEE80211_S_INIT, -1);
1459 if (dev->flags & IFF_RUNNING) {
1460 dev->flags &= ~IFF_RUNNING; /* mark us stopped */
1461 @@ -1148,7 +1198,7 @@ EXPORT_SYMBOL(ieee80211_stop);
1462 void
1463 ieee80211_stop_running(struct ieee80211com *ic)
1464 {
1465 - struct ieee80211vap *vap;
1466 + struct ieee80211vap *vap, *avp;
1467 struct net_device *dev;
1468
1469 /* XXX locking */
1470 @@ -1156,6 +1206,12 @@ ieee80211_stop_running(struct ieee80211c
1471 dev = vap->iv_dev;
1472 if (dev->flags & IFF_RUNNING) /* NB: avoid recursion */
1473 ieee80211_stop(dev);
1474 +
1475 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
1476 + dev = avp->iv_dev;
1477 + if (dev->flags & IFF_RUNNING) /* NB: avoid recursion */
1478 + ieee80211_stop(dev);
1479 + }
1480 }
1481 }
1482 EXPORT_SYMBOL(ieee80211_stop_running);
1483 @@ -1342,9 +1398,9 @@ ieee80211_new_state(struct ieee80211vap
1484 struct ieee80211com *ic = vap->iv_ic;
1485 int rc;
1486
1487 - IEEE80211_VAPS_LOCK_BH(ic);
1488 + IEEE80211_VAPS_LOCK_IRQ(ic);
1489 rc = vap->iv_newstate(vap, nstate, arg);
1490 - IEEE80211_VAPS_UNLOCK_BH(ic);
1491 + IEEE80211_VAPS_UNLOCK_IRQ(ic);
1492 return rc;
1493 }
1494
1495 @@ -1557,57 +1613,12 @@ __ieee80211_newstate(struct ieee80211vap
1496 switch (ostate) {
1497 case IEEE80211_S_INIT:
1498 if (vap->iv_opmode == IEEE80211_M_MONITOR ||
1499 - vap->iv_opmode == IEEE80211_M_WDS ||
1500 vap->iv_opmode == IEEE80211_M_HOSTAP) {
1501 /*
1502 * Already have a channel; bypass the
1503 * scan and startup immediately.
1504 */
1505 ieee80211_create_ibss(vap, ic->ic_curchan);
1506 -
1507 - /* In WDS mode, allocate and initialize peer node. */
1508 - if (vap->iv_opmode == IEEE80211_M_WDS) {
1509 - /* XXX: This is horribly non-atomic. */
1510 - struct ieee80211_node *wds_ni =
1511 - ieee80211_find_node(&ic->ic_sta,
1512 - vap->wds_mac);
1513 -
1514 - if (wds_ni == NULL) {
1515 - wds_ni = ieee80211_alloc_node_table(
1516 - vap,
1517 - vap->wds_mac);
1518 - if (wds_ni != NULL) {
1519 - ieee80211_add_wds_addr(
1520 - &ic->ic_sta,
1521 - wds_ni,
1522 - vap->wds_mac,
1523 - 1);
1524 - ieee80211_ref_node(wds_ni); /* pin in memory */
1525 - }
1526 - else
1527 - IEEE80211_DPRINTF(
1528 - vap,
1529 - IEEE80211_MSG_NODE,
1530 - "%s: Unable to "
1531 - "allocate node for "
1532 - "WDS: " MAC_FMT "\n",
1533 - __func__,
1534 - MAC_ADDR(
1535 - vap->wds_mac)
1536 - );
1537 - }
1538 -
1539 - if (wds_ni != NULL) {
1540 - ieee80211_node_authorize(wds_ni);
1541 - wds_ni->ni_chan =
1542 - vap->iv_bss->ni_chan;
1543 - wds_ni->ni_capinfo =
1544 - ni->ni_capinfo;
1545 - wds_ni->ni_associd = 1;
1546 - wds_ni->ni_ath_flags =
1547 - vap->iv_ath_cap;
1548 - }
1549 - }
1550 break;
1551 }
1552 /* fall thru... */
1553 @@ -1675,6 +1686,7 @@ __ieee80211_newstate(struct ieee80211vap
1554 */
1555 if (ni->ni_authmode != IEEE80211_AUTH_8021X)
1556 ieee80211_node_authorize(ni);
1557 +
1558 #ifdef ATH_SUPERG_XR
1559 /*
1560 * fire a timer to bring up XR vap if configured.
1561 @@ -1808,6 +1820,11 @@ ieee80211_newstate(struct ieee80211vap *
1562 ieee80211_state_name[dstate]);
1563
1564 ieee80211_update_link_status(vap, nstate, ostate);
1565 +
1566 + if ((nstate != IEEE80211_S_RUN) && vap->iv_wdsnode &&
1567 + !vap->iv_wdsnode->ni_subif)
1568 + ieee80211_unref_node(&vap->iv_wdsnode);
1569 +
1570 switch (nstate) {
1571 case IEEE80211_S_AUTH:
1572 case IEEE80211_S_ASSOC:
1573 @@ -1930,8 +1947,15 @@ ieee80211_newstate(struct ieee80211vap *
1574 if (ostate == IEEE80211_S_SCAN ||
1575 ostate == IEEE80211_S_AUTH ||
1576 ostate == IEEE80211_S_ASSOC) {
1577 +
1578 /* Transition (S_SCAN|S_AUTH|S_ASSOC) -> S_RUN */
1579 __ieee80211_newstate(vap, nstate, arg);
1580 +
1581 + /* if we're in wds, let the ap know that we're doing this */
1582 + if ((vap->iv_opmode == IEEE80211_M_STA) &&
1583 + (vap->iv_flags_ext & IEEE80211_FEXT_WDS))
1584 + ieee80211_send_nulldata(ieee80211_ref_node(vap->iv_bss));
1585 +
1586 /* Then bring up all other vaps pending on the scan */
1587 dstate = get_dominant_state(ic);
1588 if (dstate == IEEE80211_S_RUN) {
1589 --- a/ath/if_athvar.h
1590 +++ b/ath/if_athvar.h
1591 @@ -79,28 +79,6 @@ typedef void *TQUEUE_ARG;
1592 #define tasklet_enable(t) do { (void) t; local_bh_enable(); } while (0)
1593 #endif /* !DECLARE_TASKLET */
1594
1595 -#include <linux/sched.h>
1596 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
1597 -#include <linux/tqueue.h>
1598 -#define work_struct tq_struct
1599 -#define schedule_work(t) schedule_task((t))
1600 -#define flush_scheduled_work() flush_scheduled_tasks()
1601 -#define ATH_INIT_WORK(t, f) do { \
1602 - memset((t), 0, sizeof(struct tq_struct)); \
1603 - (t)->routine = (void (*)(void*)) (f); \
1604 - (t)->data=(void *) (t); \
1605 -} while (0)
1606 -#else
1607 -#include <linux/workqueue.h>
1608 -
1609 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
1610 -#define ATH_INIT_WORK(_t, _f) INIT_WORK((_t), (void (*)(void *))(_f), (_t));
1611 -#else
1612 -#define ATH_INIT_WORK(_t, _f) INIT_WORK((_t), (_f));
1613 -#endif
1614 -
1615 -#endif /* KERNEL_VERSION < 2.5.41 */
1616 -
1617 /*
1618 * Guess how the interrupt handler should work.
1619 */
1620 --- a/net80211/ieee80211_linux.c
1621 +++ b/net80211/ieee80211_linux.c
1622 @@ -145,7 +145,7 @@ ieee80211_getmgtframe(u_int8_t **frm, u_
1623 struct sk_buff *skb;
1624 u_int len;
1625
1626 - len = roundup(sizeof(struct ieee80211_frame) + pktlen, 4);
1627 + len = roundup(sizeof(struct ieee80211_frame_addr4) + pktlen, 4);
1628 #ifdef IEEE80211_DEBUG_REFCNT
1629 skb = ieee80211_dev_alloc_skb_debug(len + align - 1, func, line);
1630 #else
1631 @@ -161,7 +161,7 @@ ieee80211_getmgtframe(u_int8_t **frm, u_
1632 SKB_CB(skb)->flags = 0;
1633 SKB_CB(skb)->next = NULL;
1634
1635 - skb_reserve(skb, sizeof(struct ieee80211_frame));
1636 + skb_reserve(skb, sizeof(struct ieee80211_frame_addr4));
1637 *frm = skb_put(skb, pktlen);
1638 }
1639 return skb;
1640 --- a/net80211/ieee80211_node.h
1641 +++ b/net80211/ieee80211_node.h
1642 @@ -92,11 +92,13 @@ struct ath_softc;
1643 * the ieee80211com structure.
1644 */
1645 struct ieee80211_node {
1646 - struct ieee80211vap *ni_vap;
1647 + struct ieee80211vap *ni_vap, *ni_subif;
1648 struct ieee80211com *ni_ic;
1649 struct ieee80211_node_table *ni_table;
1650 TAILQ_ENTRY(ieee80211_node) ni_list;
1651 LIST_ENTRY(ieee80211_node) ni_hash;
1652 + struct work_struct ni_create; /* task for creating a subif */
1653 + struct work_struct ni_destroy; /* task for destroying a subif */
1654 atomic_t ni_refcnt;
1655 u_int ni_scangen; /* gen# for timeout scan */
1656 u_int8_t ni_authmode; /* authentication algorithm */
1657 @@ -430,5 +432,6 @@ void ieee80211_node_join(struct ieee8021
1658 void ieee80211_node_leave(struct ieee80211_node *);
1659 u_int8_t ieee80211_getrssi(struct ieee80211com *);
1660 int32_t ieee80211_get_node_count(struct ieee80211com *);
1661 +void ieee80211_wds_addif(struct ieee80211_node *ni);
1662 #endif /* _NET80211_IEEE80211_NODE_H_ */
1663
This page took 0.111872 seconds and 5 git commands to generate.