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);
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;
22 if (autocreatemode != -1) {
24 vap = ieee80211_create_vap(ic, "ath%d", dev,
26 + autocreatemode, 0, NULL);
29 EPRINTF(sc, "Autocreation of %s VAP failed.", autocreate);
30 @@ -1230,14 +1228,14 @@
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)
37 struct ath_softc *sc = ic->ic_dev->priv;
38 struct ath_hal *ah = sc->sc_ah;
39 struct net_device *dev;
41 struct ieee80211vap *vap;
43 + int ic_opmode = IEEE80211_M_STA;
45 if (ic->ic_dev->flags & IFF_RUNNING) {
46 /* needs to disable hardware too */
47 @@ -1271,8 +1269,12 @@
51 - case IEEE80211_M_HOSTAP:
55 + ic_opmode = ic->ic_opmode;
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))
65 - ieee80211_vap_setup(ic, dev, name, opmode, flags);
66 + ieee80211_vap_setup(ic, dev, name, opmode, flags, master);
67 /* override with driver methods */
69 avp->av_newstate = vap->iv_newstate;
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 |
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 !=
89 --- a/net80211/ieee80211.c
90 +++ b/net80211/ieee80211.c
94 ieee80211_vap_setup(struct ieee80211com *ic, struct net_device *dev,
95 - const char *name, int opmode, int flags)
96 + const char *name, int opmode, int flags, struct ieee80211vap *master)
98 #define IEEE80211_C_OPMODE \
99 (IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | IEEE80211_C_AHDEMO | \
102 vap->iv_monitor_crc_errors = 0;
103 vap->iv_monitor_phy_errors = 0;
104 + TAILQ_INIT(&vap->iv_wdslinks);
106 - IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_myaddr);
107 - IEEE80211_ADDR_COPY(vap->iv_bssid, ic->ic_myaddr);
108 + if (master && (vap->iv_opmode == IEEE80211_M_WDS)) {
109 + vap->iv_master = master;
110 + TAILQ_INSERT_TAIL(&master->iv_wdslinks, vap, iv_wdsnext);
111 + /* use the same BSSID as the master interface */
112 + IEEE80211_ADDR_COPY(vap->iv_myaddr, vap->iv_master->iv_myaddr);
113 + IEEE80211_ADDR_COPY(vap->iv_bssid, vap->iv_master->iv_myaddr);
115 + IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_myaddr);
116 + IEEE80211_ADDR_COPY(vap->iv_bssid, ic->ic_myaddr);
118 /* NB: Defer setting dev_addr so driver can override */
120 ieee80211_crypto_vattach(vap);
122 ifmedia_set(&vap->iv_media, imr.ifm_active);
124 IEEE80211_LOCK_IRQ(ic);
125 - TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next);
126 + if (vap->iv_opmode != IEEE80211_M_WDS)
127 + TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next);
128 IEEE80211_UNLOCK_IRQ(ic);
130 IEEE80211_ADDR_COPY(dev->dev_addr, vap->iv_myaddr);
131 @@ -579,10 +589,24 @@
133 struct ieee80211com *ic = vap->iv_ic;
134 struct net_device *dev = vap->iv_dev;
135 + struct ieee80211vap *avp;
137 + /* Drop all WDS links that belong to this vap */
138 + while ((avp = TAILQ_FIRST(&vap->iv_wdslinks)) != NULL) {
139 + ieee80211_stop(avp->iv_dev);
140 + ic->ic_vap_delete(avp);
143 IEEE80211_CANCEL_TQUEUE(&vap->iv_stajoin1tq);
144 IEEE80211_LOCK_IRQ(ic);
145 - TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
146 + if (vap->iv_wdsnode)
147 + ieee80211_unref_node(&vap->iv_wdsnode);
148 + if ((vap->iv_opmode == IEEE80211_M_WDS) &&
149 + (vap->iv_master != NULL))
150 + TAILQ_REMOVE(&vap->iv_master->iv_wdslinks, vap, iv_wdsnext);
152 + TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
154 if (TAILQ_EMPTY(&ic->ic_vaps)) /* reset to supported mode */
155 ic->ic_opmode = IEEE80211_M_STA;
156 IEEE80211_UNLOCK_IRQ(ic);
157 --- a/net80211/ieee80211_ioctl.h
158 +++ b/net80211/ieee80211_ioctl.h
160 #define IEEE80211_IOC_DTIM_PERIOD 52 /* DTIM period (beacons) */
161 #define IEEE80211_IOC_BEACON_INTERVAL 53 /* beacon interval (ms) */
162 #define IEEE80211_IOC_ADDMAC 54 /* add sta to MAC ACL table */
163 -#define IEEE80211_IOC_DELMAC 55 /* del sta from MAC ACL table */
164 +#define IEEE80211_IOC_SETMAC 55 /* set interface wds mac addr */
165 #define IEEE80211_IOC_FF 56 /* ATH fast frames (on, off) */
166 #define IEEE80211_IOC_TURBOP 57 /* ATH turbo' (on, off) */
167 #define IEEE80211_IOC_APPIEBUF 58 /* IE in the management frame */
169 #define IEEE80211_IOCTL_HALMAP (SIOCIWFIRSTPRIV+21)
170 #define IEEE80211_IOCTL_ADDMAC (SIOCIWFIRSTPRIV+22)
171 #define IEEE80211_IOCTL_DELMAC (SIOCIWFIRSTPRIV+24)
172 -#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
173 -#define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
174 +#define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+25)
175 +#define IEEE80211_IOCTL_WDSSETMAC (SIOCIWFIRSTPRIV+26)
176 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
177 #define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
179 --- a/net80211/ieee80211_linux.h
180 +++ b/net80211/ieee80211_linux.h
182 int ieee80211_ioctl_create_vap(struct ieee80211com *, struct ifreq *,
183 struct net_device *);
184 struct ieee80211vap *ieee80211_create_vap(struct ieee80211com *, char *,
185 - struct net_device *, int, int);
186 + struct net_device *, int, int, struct ieee80211vap *);
187 #endif /* _NET80211_IEEE80211_LINUX_H_ */
188 --- a/net80211/ieee80211_var.h
189 +++ b/net80211/ieee80211_var.h
191 struct ieee80211_proc_entry *iv_proc_entries;
192 struct vlan_group *iv_vlgrp; /* vlan group state */
194 + /* list of wds links */
195 + TAILQ_HEAD(, ieee80211vap) iv_wdslinks;
196 + TAILQ_ENTRY(ieee80211vap) iv_wdsnext;
197 + struct ieee80211vap *iv_master;
198 + struct ieee80211_node *iv_wdsnode;
200 TAILQ_ENTRY(ieee80211vap) iv_next; /* list of vap instances */
201 struct ieee80211com *iv_ic; /* back ptr to common state */
202 u_int32_t iv_debug; /* debug msg flags */
204 atomic_t ic_node_counter;
205 /* Virtual AP create/delete */
206 struct ieee80211vap *(*ic_vap_create)(struct ieee80211com *,
207 - const char *, int, int, struct net_device *);
208 + const char *, int, int, struct net_device *, struct ieee80211vap *);
209 void (*ic_vap_delete)(struct ieee80211vap *);
211 /* Send/recv 802.11 management frame */
213 int ieee80211_ifattach(struct ieee80211com *);
214 void ieee80211_ifdetach(struct ieee80211com *);
215 int ieee80211_vap_setup(struct ieee80211com *, struct net_device *,
216 - const char *, int, int);
217 + const char *, int, int, struct ieee80211vap *);
218 int ieee80211_vap_attach(struct ieee80211vap *, ifm_change_cb_t, ifm_stat_cb_t);
219 void ieee80211_vap_detach(struct ieee80211vap *);
220 void ieee80211_mark_dfs(struct ieee80211com *, struct ieee80211_channel *);
221 --- a/net80211/ieee80211_wireless.c
222 +++ b/net80211/ieee80211_wireless.c
223 @@ -2190,7 +2190,7 @@
224 ieee80211_scan_flush(ic); /* NB: could optimize */
226 if (!(xrvap = ic->ic_vap_create(ic, name, IEEE80211_M_HOSTAP,
227 - IEEE80211_VAP_XR | IEEE80211_CLONE_BSSID, dev)))
228 + IEEE80211_VAP_XR | IEEE80211_CLONE_BSSID, dev, NULL)))
231 /* We use iv_xrvap to link to the parent VAP as well */
232 @@ -3801,74 +3801,51 @@
236 +#define WDSNAME ".wds%d"
238 -ieee80211_ioctl_wdsmac(struct net_device *dev, struct iw_request_info *info,
239 +ieee80211_ioctl_wdsaddmac(struct net_device *dev, struct iw_request_info *info,
240 void *w, char *extra)
242 struct ieee80211vap *vap = dev->priv;
243 struct sockaddr *sa = (struct sockaddr *)extra;
244 + struct ieee80211com *ic = vap->iv_ic;
245 + struct ieee80211vap *avp;
248 - if (!IEEE80211_ADDR_NULL(vap->wds_mac)) {
249 - printk("%s: Failed to add WDS MAC: " MAC_FMT "\n", dev->name,
250 - MAC_ADDR(sa->sa_data));
251 - printk("%s: Device already has WDS mac address attached,"
252 - " remove first\n", dev->name);
256 - memcpy(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
258 - printk("%s: Added WDS MAC: " MAC_FMT "\n", dev->name,
259 - MAC_ADDR(vap->wds_mac));
260 + name = kmalloc(strlen(vap->iv_dev->name) + sizeof(WDSNAME) + 1, GFP_KERNEL);
264 - if (IS_UP(vap->iv_dev)) {
265 - /* Force us back to scan state to force us to go back through RUN
266 - * state and create/pin the WDS peer node into memory. */
267 - return ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
269 + strcpy(name, vap->iv_dev->name);
270 + strcat(name, WDSNAME);
271 + avp = ieee80211_create_vap(ic, name, ic->ic_dev, IEEE80211_M_WDS, 0, vap);
276 + memcpy(avp->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
282 -ieee80211_ioctl_wdsdelmac(struct net_device *dev, struct iw_request_info *info,
283 +ieee80211_ioctl_wdssetmac(struct net_device *dev, struct iw_request_info *info,
284 void *w, char *extra)
286 struct ieee80211vap *vap = dev->priv;
287 struct sockaddr *sa = (struct sockaddr *)extra;
288 - struct ieee80211com *ic = vap->iv_ic;
289 - struct ieee80211_node *wds_ni;
291 - /* WDS Mac address filed already? */
292 - if (IEEE80211_ADDR_NULL(vap->wds_mac))
294 + if (vap->iv_opmode != IEEE80211_M_WDS)
297 - /* Compare suplied MAC address with WDS MAC of this interface
298 - * remove when mac address is known
300 - if (memcmp(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN) == 0) {
301 - if (IS_UP(vap->iv_dev)) {
302 - wds_ni = ieee80211_find_txnode(vap, vap->wds_mac);
303 - if (wds_ni != NULL) {
304 - /* Release reference created by find node */
305 - ieee80211_unref_node(&wds_ni);
306 - /* Release reference created by transition to RUN state,
307 - * [pinning peer node into the table] */
308 - ieee80211_unref_node(&wds_ni);
311 - memset(vap->wds_mac, 0x00, IEEE80211_ADDR_LEN);
312 - if (IS_UP(vap->iv_dev)) {
313 - /* This leaves a dead WDS node, until started again */
314 - return ic->ic_reset(ic->ic_dev);
317 + memcpy(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN);
318 + if (IS_UP(vap->iv_dev)) {
319 + /* Force us back to scan state to force us to go back through RUN
320 + * state and create/pin the WDS peer node into memory. */
321 + return ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
324 - printk("%s: WDS MAC address " MAC_FMT " is not known by this interface\n",
325 - dev->name, MAC_ADDR(sa->sa_data));
332 @@ -5391,8 +5368,8 @@
333 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "kickmac"},
334 { IEEE80211_IOCTL_WDSADDMAC,
335 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_add" },
336 - { IEEE80211_IOCTL_WDSDELMAC,
337 - IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_del" },
338 + { IEEE80211_IOCTL_WDSSETMAC,
339 + IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_set" },
340 { IEEE80211_IOCTL_SETCHANLIST,
341 IW_PRIV_TYPE_CHANLIST | IW_PRIV_SIZE_FIXED, 0,"setchanlist" },
342 { IEEE80211_IOCTL_GETCHANLIST,
343 @@ -5884,8 +5861,8 @@
345 set_priv(IEEE80211_IOCTL_ADDMAC, ieee80211_ioctl_addmac),
346 set_priv(IEEE80211_IOCTL_DELMAC, ieee80211_ioctl_delmac),
347 - set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
348 - set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
349 + set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsaddmac),
350 + set_priv(IEEE80211_IOCTL_WDSSETMAC, ieee80211_ioctl_wdssetmac),
351 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
352 set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
353 #ifdef ATH_REVERSE_ENGINEERING
354 @@ -5956,7 +5933,7 @@
356 strncpy(name, cp.icp_name, sizeof(name));
358 - vap = ieee80211_create_vap(ic, name, mdev, cp.icp_opmode, cp.icp_flags);
359 + vap = ieee80211_create_vap(ic, name, mdev, cp.icp_opmode, cp.icp_flags, NULL);
363 @@ -5973,9 +5950,9 @@
366 ieee80211_create_vap(struct ieee80211com *ic, char *name,
367 - struct net_device *mdev, int opmode, int opflags)
368 + struct net_device *mdev, int opmode, int opflags, struct ieee80211vap *master)
370 - return ic->ic_vap_create(ic, name, opmode, opflags, mdev);
371 + return ic->ic_vap_create(ic, name, opmode, opflags, mdev, master);
373 EXPORT_SYMBOL(ieee80211_create_vap);
375 --- a/net80211/ieee80211_input.c
376 +++ b/net80211/ieee80211_input.c
378 struct ieee80211_node * ni = ni_or_null;
379 struct ieee80211com *ic = vap->iv_ic;
380 struct net_device *dev = vap->iv_dev;
381 + struct ieee80211_node *ni_wds = NULL;
382 struct ieee80211_frame *wh;
383 struct ieee80211_key *key;
384 struct ether_header *eh;
385 @@ -545,11 +546,29 @@
386 * the node table for the packet source address (addr4).
389 - /* XXX: Useless node mgmt API; make better */
391 + /* check for wds link first */
392 if (dir == IEEE80211_FC1_DIR_DSTODS) {
393 - struct ieee80211_node_table *nt;
394 + struct ieee80211vap *avp;
396 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
397 + if (!memcmp(avp->wds_mac, wh->i_addr2, IEEE80211_ADDR_LEN)) {
398 + IEEE80211_LOCK_IRQ(ni->ni_ic);
399 + ni_wds = avp->iv_wdsnode;
400 + IEEE80211_UNLOCK_IRQ(ni->ni_ic);
404 + if (ni_wds != NULL) {
405 + ieee80211_unref_node(&ni);
406 + ni = ieee80211_ref_node(ni_wds);
410 + /* XXX: Useless node mgmt API; make better */
411 + if ((dir == IEEE80211_FC1_DIR_DSTODS) && !ni_wds) {
412 + struct ieee80211_node_table *nt = &ic->ic_sta;
413 struct ieee80211_frame_addr4 *wh4;
414 - struct ieee80211_node *ni_wds;
416 if (!(vap->iv_flags_ext & IEEE80211_FEXT_WDS)) {
417 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
421 wh4 = (struct ieee80211_frame_addr4 *)skb->data;
423 ni_wds = ieee80211_find_wds_node(nt, wh4->i_addr4);
424 /* Last call increments ref count if !NULL */
425 if ((ni_wds != NULL) && (ni_wds != ni)) {
426 @@ -3084,8 +3102,7 @@
427 (vap->iv_opmode == IEEE80211_M_STA && ni->ni_associd) ||
428 (vap->iv_opmode == IEEE80211_M_IBSS) ||
429 ((subtype == IEEE80211_FC0_SUBTYPE_BEACON) &&
430 - (vap->iv_opmode == IEEE80211_M_HOSTAP) &&
431 - (ic->ic_protmode != IEEE80211_PROT_NONE)))) {
432 + (vap->iv_opmode == IEEE80211_M_HOSTAP)))) {
433 vap->iv_stats.is_rx_mgtdiscard++;
436 @@ -3471,13 +3488,53 @@
438 if (ic->ic_flags & IEEE80211_F_SCAN) {
439 ieee80211_add_scan(vap, &scan, wh, subtype, rssi, rtsf);
442 - if ((vap->iv_opmode == IEEE80211_M_IBSS) &&
443 - (scan.capinfo & IEEE80211_CAPINFO_IBSS)) {
444 + /* NB: Behavior of WDS-Link and Ad-Hoc is very similar here:
445 + * When we receive a beacon that belongs to the AP that we're
446 + * connected to, use it to refresh the local node info.
447 + * If no node is found, go through the vap's wds link table
448 + * and try to find the sub-vap that is interested in this address
450 + if (((vap->iv_opmode == IEEE80211_M_IBSS) &&
451 + (scan.capinfo & IEEE80211_CAPINFO_IBSS)) ||
452 + (((vap->iv_opmode == IEEE80211_M_HOSTAP) ||
453 + (vap->iv_opmode == IEEE80211_M_WDS)) &&
454 + (scan.capinfo & IEEE80211_CAPINFO_ESS))) {
455 + struct ieee80211vap *avp = NULL;
457 + IEEE80211_LOCK_IRQ(vap->iv_ic);
458 + if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
461 + TAILQ_FOREACH(avp, &vap->iv_wdslinks, iv_wdsnext) {
462 + if (!memcmp(avp->wds_mac, wh->i_addr2, IEEE80211_ADDR_LEN)) {
468 + if (!avp->iv_wdsnode)
470 + ni = ni_or_null = avp->iv_wdsnode;
475 + IEEE80211_UNLOCK_IRQ(vap->iv_ic);
478 if (ni_or_null == NULL) {
479 - /* Create a new entry in the neighbor table. */
480 - ni = ieee80211_add_neighbor(vap, wh, &scan);
482 + IEEE80211_LOCK_IRQ(ic);
483 + ni = ieee80211_add_neighbor(avp, wh, &scan);
485 + ni->ni_associd |= 0xc000;
486 + avp->iv_wdsnode = ieee80211_ref_node(ni);
487 + IEEE80211_UNLOCK_IRQ(ic);
488 + } else if (vap->iv_opmode == IEEE80211_M_IBSS) {
489 + /* Create a new entry in the neighbor table. */
490 + ni = ieee80211_add_neighbor(vap, wh, &scan);
494 * Copy data from beacon to neighbor table.
495 @@ -3490,6 +3547,7 @@
496 IEEE80211_ADDR_COPY(ni->ni_bssid, wh->i_addr3);
497 memcpy(ni->ni_tstamp.data, scan.tstamp,
498 sizeof(ni->ni_tstamp));
499 + ni->ni_inact = ni->ni_inact_reload;
501 IEEE80211_BINTVAL_SANITISE(scan.bintval);
502 ni->ni_capinfo = scan.capinfo;
503 --- a/net80211/ieee80211_node.c
504 +++ b/net80211/ieee80211_node.c
505 @@ -1553,22 +1553,24 @@
506 ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PS_POLL)
507 struct ieee80211_node_table *nt;
508 struct ieee80211_node *ni;
509 + const u_int8_t *addr;
511 + if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/)
512 + addr = wh->i_addr1;
514 + addr = wh->i_addr2;
516 + if (IEEE80211_IS_MULTICAST(addr))
519 /* XXX check ic_bss first in station mode */
520 /* XXX 4-address frames? */
522 IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
523 - if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/)
524 #ifdef IEEE80211_DEBUG_REFCNT
525 - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr1, func, line);
526 + ni = ieee80211_find_node_locked_debug(nt, addr, func, line);
528 - ni = ieee80211_find_node_locked(nt, wh->i_addr1);
531 -#ifdef IEEE80211_DEBUG_REFCNT
532 - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr2, func, line);
534 - ni = ieee80211_find_node_locked(nt, wh->i_addr2);
535 + ni = ieee80211_find_node_locked(nt, addr);
537 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
539 @@ -1669,6 +1671,11 @@
541 struct ieee80211vap *vap = ni->ni_vap;
543 + IEEE80211_LOCK_IRQ(ni->ni_ic);
544 + if (vap && ni == vap->iv_wdsnode)
545 + vap->iv_wdsnode = NULL;
546 + IEEE80211_UNLOCK_IRQ(ni->ni_ic);
548 atomic_dec(&ni->ni_ic->ic_node_counter);
549 node_print_message(IEEE80211_MSG_NODE|IEEE80211_MSG_NODE_REF,
550 1 /* show counter */,
551 @@ -1781,22 +1788,6 @@
552 jiffies > ni->ni_rxfragstamp + HZ) {
553 ieee80211_dev_kfree_skb(&ni->ni_rxfrag);
556 - * Special case ourself; we may be idle for extended periods
557 - * of time and regardless reclaiming our state is wrong.
558 - * Special case a WDS link: it may be dead or idle, but it is
559 - * never ok to reclaim it, as this will block transmissions
560 - * and nobody will recreate the node when the WDS peer is
561 - * available again. */
562 - if ((ni == ni->ni_vap->iv_bss) ||
563 - (ni->ni_vap->iv_opmode == IEEE80211_M_WDS &&
564 - !memcmp(ni->ni_macaddr, ni->ni_vap->wds_mac, ETH_ALEN)))
566 - /* NB: don't permit it to go negative */
567 - if (ni->ni_inact > 0)
572 if (ni->ni_associd != 0 || isadhoc) {
573 struct ieee80211vap *vap = ni->ni_vap;
574 --- a/net80211/ieee80211_output.c
575 +++ b/net80211/ieee80211_output.c
576 @@ -246,10 +246,16 @@
577 * things like power save.
579 eh = (struct ether_header *)skb->data;
580 - if (vap->iv_opmode == IEEE80211_M_WDS)
581 - ni = ieee80211_find_txnode(vap, vap->wds_mac);
583 + if (vap->iv_opmode == IEEE80211_M_WDS) {
584 + IEEE80211_LOCK_IRQ(ic);
585 + ni = vap->iv_wdsnode;
586 + IEEE80211_UNLOCK_IRQ(ic);
589 + ni = ieee80211_ref_node(vap->iv_wdsnode);
591 ni = ieee80211_find_txnode(vap, eh->ether_dhost);
594 /* NB: ieee80211_find_txnode does stat+msg */
598 case IEEE80211_M_WDS:
600 - ismulticast = IEEE80211_IS_MULTICAST(ni->ni_macaddr);
603 case IEEE80211_M_HOSTAP:
604 if (!IEEE80211_IS_MULTICAST(eh.ether_dhost) &&
607 case IEEE80211_M_WDS:
608 wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS;
609 - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr);
610 + IEEE80211_ADDR_COPY(wh->i_addr1, vap->wds_mac);
611 IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr);
612 IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost);
613 IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, eh.ether_shost);
617 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
618 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
619 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
620 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
621 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
622 IOCTL_ERR(IEEE80211_IOCTL_READREG),
623 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
625 --- a/tools/athchans.c
626 +++ b/tools/athchans.c
628 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
629 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
630 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
631 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
632 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
633 IOCTL_ERR(IEEE80211_IOCTL_READREG),
634 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
636 --- a/tools/wlanconfig.c
637 +++ b/tools/wlanconfig.c
639 IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
640 IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
641 IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
642 - IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
643 + IOCTL_ERR(IEEE80211_IOCTL_WDSSETMAC),
644 IOCTL_ERR(IEEE80211_IOCTL_READREG),
645 IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
647 --- a/net80211/ieee80211_proto.c
648 +++ b/net80211/ieee80211_proto.c
649 @@ -1557,57 +1557,12 @@
651 case IEEE80211_S_INIT:
652 if (vap->iv_opmode == IEEE80211_M_MONITOR ||
653 - vap->iv_opmode == IEEE80211_M_WDS ||
654 vap->iv_opmode == IEEE80211_M_HOSTAP) {
656 * Already have a channel; bypass the
657 * scan and startup immediately.
659 ieee80211_create_ibss(vap, ic->ic_curchan);
661 - /* In WDS mode, allocate and initialize peer node. */
662 - if (vap->iv_opmode == IEEE80211_M_WDS) {
663 - /* XXX: This is horribly non-atomic. */
664 - struct ieee80211_node *wds_ni =
665 - ieee80211_find_node(&ic->ic_sta,
668 - if (wds_ni == NULL) {
669 - wds_ni = ieee80211_alloc_node_table(
672 - if (wds_ni != NULL) {
673 - ieee80211_add_wds_addr(
678 - ieee80211_ref_node(wds_ni); /* pin in memory */
683 - IEEE80211_MSG_NODE,
685 - "allocate node for "
686 - "WDS: " MAC_FMT "\n",
693 - if (wds_ni != NULL) {
694 - ieee80211_node_authorize(wds_ni);
696 - vap->iv_bss->ni_chan;
697 - wds_ni->ni_capinfo =
699 - wds_ni->ni_associd = 1;
700 - wds_ni->ni_ath_flags =