Ticket #907: madwifi-refcnt.11.diff
| File madwifi-refcnt.11.diff, 91.2 kB (added by mike.taylor@apprion.com, 5 years ago) |
|---|
-
svn.madwifi.org-trunk-2115/ath/if_ath.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: if_ath.c 2 104 2007-02-13 05:54:52Z proski$36 * $Id: if_ath.c 2064 2007-02-01 20:49:37Z mentor $ 37 37 */ 38 38 39 39 /* … … 159 159 static int ath_desc_alloc(struct ath_softc *); 160 160 static void ath_desc_free(struct ath_softc *); 161 161 static void ath_desc_swap(struct ath_desc *); 162 static struct ieee80211_node *ath_node_alloc(struct ieee80211_node_table *, 163 struct ieee80211vap *); 162 static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *); 164 163 static void ath_node_cleanup(struct ieee80211_node *); 165 164 static void ath_node_free(struct ieee80211_node *); 166 165 static u_int8_t ath_node_getrssi(const struct ieee80211_node *); … … 432 431 * built with an ah.h that does not correspond to the HAL 433 432 * module loaded in the kernel. 434 433 */ 435 ah = _ath_hal_attach(devid, sc, tag, sc->sc_iobase, &status); 434 ah = _ath_hal_attach(devid, sc, tag, 435 (__force HAL_BUS_HANDLE) sc->sc_iobase, 436 &status); 436 437 if (ah == NULL) { 437 438 printk(KERN_ERR "%s: unable to attach hardware: '%s' (HAL status %u)\n", 438 439 dev->name, ath_get_hal_status_desc(status), status); … … 2451 2452 if (ath_tx_start(sc->sc_dev, ni, bf_ff, bf_ff->bf_skb, 0) == 0) 2452 2453 continue; 2453 2454 bad: 2454 ieee80211_ free_node(ni);2455 ieee80211_unref_node(&ni); 2455 2456 if (bf_ff->bf_skb != NULL) { 2456 2457 dev_kfree_skb(bf_ff->bf_skb); 2457 2458 bf_ff->bf_skb = NULL; … … 2592 2593 ATH_FF_MAGIC_PUT(skb); 2593 2594 2594 2595 /* decrement extra node reference made when an_tx_ffbuf[] was set */ 2595 //ieee80211_ free_node(ni); /* XXX where was it set ? */2596 //ieee80211_unref_node(&ni); /* XXX where was it set ? */ 2596 2597 2597 2598 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 2598 2599 "%s: aggregating fast-frame\n", __func__); … … 2651 2652 ff_flushbad: 2652 2653 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 2653 2654 "%s: ff stageq flush failure\n", __func__); 2654 ieee80211_ free_node(ni);2655 ieee80211_unref_node(&ni); 2655 2656 if (bf_ff->bf_skb) { 2656 2657 dev_kfree_skb(bf_ff->bf_skb); 2657 2658 bf_ff->bf_skb = NULL; … … 2776 2777 tbf->bf_node = NULL; 2777 2778 2778 2779 if (ni != NULL) 2779 ieee80211_ free_node(ni);2780 ieee80211_unref_node(&ni); 2780 2781 2781 2782 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 2782 2783 } … … 2858 2859 /* fall thru... */ 2859 2860 bad: 2860 2861 if (ni != NULL) 2861 ieee80211_ free_node(ni);2862 ieee80211_unref_node(&ni); 2862 2863 if (bf != NULL) { 2863 2864 bf->bf_skb = NULL; 2864 2865 bf->bf_node = NULL; … … 3244 3245 */ 3245 3246 ni = sc->sc_keyixmap[keyix]; 3246 3247 if (ni != NULL) { 3247 ieee80211_ free_node(ni);3248 ieee80211_unref_node(&ni); 3248 3249 sc->sc_keyixmap[keyix] = NULL; 3249 3250 } 3250 3251 /* … … 3255 3256 ath_hal_keyreset(ah, keyix + 32); /* RX key */ 3256 3257 ni = sc->sc_keyixmap[keyix + 32]; 3257 3258 if (ni != NULL) { /* as above... */ 3258 ieee80211_ free_node(ni);3259 ieee80211_unref_node(&ni); 3259 3260 sc->sc_keyixmap[keyix + 32] = NULL; 3260 3261 } 3261 3262 } … … 3268 3269 ath_hal_keyreset(ah, keyix + rxkeyoff); 3269 3270 ni = sc->sc_keyixmap[keyix + rxkeyoff]; 3270 3271 if (ni != NULL) { /* as above... */ 3271 ieee80211_ free_node(ni);3272 ieee80211_unref_node(&ni); 3272 3273 sc->sc_keyixmap[keyix + rxkeyoff] = NULL; 3273 3274 } 3274 3275 } … … 3824 3825 dev_kfree_skb(bf->bf_skb); 3825 3826 bf->bf_skb = NULL; 3826 3827 } 3827 if (bf->bf_node != NULL) { 3828 ieee80211_free_node(bf->bf_node); 3829 bf->bf_node = NULL; 3830 } 3828 if (bf->bf_node != NULL) 3829 ieee80211_unref_node(&bf->bf_node); 3831 3830 3832 3831 /* 3833 3832 * NB: the beacon data buffer must be 32-bit aligned; … … 4371 4370 dev_kfree_skb(bf->bf_skb); 4372 4371 bf->bf_skb = NULL; 4373 4372 } 4374 if (bf->bf_node != NULL) { 4375 ieee80211_free_node(bf->bf_node); 4376 bf->bf_node = NULL; 4377 } 4373 if (bf->bf_node != NULL) 4374 ieee80211_unref_node(&bf->bf_node); 4378 4375 STAILQ_INSERT_TAIL(&sc->sc_bbuf, bf, bf_list); 4379 4376 } 4380 4377 … … 4393 4390 dev_kfree_skb(bf->bf_skb); 4394 4391 bf->bf_skb = NULL; 4395 4392 } 4396 if (bf->bf_node != NULL) { 4397 ieee80211_free_node(bf->bf_node); 4398 bf->bf_node = NULL; 4399 } 4393 if (bf->bf_node != NULL) 4394 ieee80211_unref_node(&bf->bf_node); 4400 4395 } 4401 4396 } 4402 4397 … … 4681 4676 /* 4682 4677 * Reclaim node reference. 4683 4678 */ 4684 ieee80211_ free_node(ni);4679 ieee80211_unref_node(&ni); 4685 4680 } 4686 4681 } 4687 4682 … … 4740 4735 } 4741 4736 4742 4737 static struct ieee80211_node * 4743 ath_node_alloc(struct ieee80211 _node_table *nt,struct ieee80211vap *vap)4738 ath_node_alloc(struct ieee80211vap *vap) 4744 4739 { 4745 struct ath_softc *sc = nt->nt_ic->ic_dev->priv;4740 struct ath_softc *sc = vap->iv_ic->ic_dev->priv; 4746 4741 const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; 4747 4742 struct ath_node *an; 4748 4743 4749 4744 an = kmalloc(space, GFP_ATOMIC); 4750 if (an == NULL) 4751 return NULL; 4752 memset(an, 0, space); 4753 an->an_decomp_index = INVALID_DECOMP_INDEX; 4754 an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 4755 an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 4756 an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 4757 an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 4758 /* 4759 * ath_rate_node_init needs a VAP pointer in node 4760 * to decide which mgt rate to use 4761 */ 4762 an->an_node.ni_vap = vap; 4763 sc->sc_rc->ops->node_init(sc, an); 4764 4765 /* U-APSD init */ 4766 STAILQ_INIT(&an->an_uapsd_q); 4767 an->an_uapsd_qdepth = 0; 4768 STAILQ_INIT(&an->an_uapsd_overflowq); 4769 an->an_uapsd_overflowqdepth = 0; 4770 ATH_NODE_UAPSD_LOCK_INIT(an); 4745 if (an != NULL) { 4746 memset(an, 0, space); 4747 an->an_decomp_index = INVALID_DECOMP_INDEX; 4748 an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 4749 an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 4750 an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 4751 an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 4752 /* 4753 * ath_rate_node_init needs a vap pointer in node 4754 * to decide which mgt rate to use 4755 */ 4756 an->an_node.ni_vap = vap; 4757 sc->sc_rc->ops->node_init(sc, an); 4771 4758 4772 DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 4773 return &an->an_node; 4759 /* U-APSD init */ 4760 STAILQ_INIT(&an->an_uapsd_q); 4761 an->an_uapsd_qdepth = 0; 4762 STAILQ_INIT(&an->an_uapsd_overflowq); 4763 an->an_uapsd_overflowqdepth = 0; 4764 ATH_NODE_UAPSD_LOCK_INIT(an); 4765 4766 DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 4767 return &an->an_node; 4768 } else { 4769 return NULL; 4770 } 4774 4771 } 4775 4772 4776 4773 static void … … 4780 4777 struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 4781 4778 struct ath_node *an = ATH_NODE(ni); 4782 4779 struct ath_buf *bf; 4780 struct ieee80211_cb *cb = NULL; 4783 4781 4784 4782 /* 4785 4783 * U-APSD cleanup … … 4794 4792 while (an->an_uapsd_qdepth) { 4795 4793 bf = STAILQ_FIRST(&an->an_uapsd_q); 4796 4794 STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 4797 bf->bf_desc->ds_link = (u_int32_t)NULL;4798 4795 4796 cb = (struct ieee80211_cb *) bf->bf_skb->cb; 4797 ieee80211_unref_node(&cb->ni); 4799 4798 dev_kfree_skb_any(bf->bf_skb); 4799 4800 bf->bf_desc->ds_link = 0; 4800 4801 bf->bf_skb = NULL; 4801 4802 bf->bf_node = NULL; 4803 4802 4804 ATH_TXBUF_LOCK_IRQ(sc); 4803 4805 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 4804 4806 ATH_TXBUF_UNLOCK_IRQ(sc); 4805 ieee80211_free_node(ni);4806 4807 4807 4808 an->an_uapsd_qdepth--; 4808 4809 } … … 4810 4811 while (an->an_uapsd_overflowqdepth) { 4811 4812 bf = STAILQ_FIRST(&an->an_uapsd_overflowq); 4812 4813 STAILQ_REMOVE_HEAD(&an->an_uapsd_overflowq, bf_list); 4813 bf->bf_desc->ds_link = (u_int32_t)NULL;4814 4814 4815 cb = (struct ieee80211_cb *) bf->bf_skb->cb; 4816 ieee80211_unref_node(&cb->ni); 4815 4817 dev_kfree_skb_any(bf->bf_skb); 4818 4816 4819 bf->bf_skb = NULL; 4817 4820 bf->bf_node = NULL; 4821 bf->bf_desc->ds_link = 0; 4822 4818 4823 ATH_TXBUF_LOCK_IRQ(sc); 4819 4824 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 4820 4825 ATH_TXBUF_UNLOCK_IRQ(sc); 4821 ieee80211_free_node(ni);4822 4826 4823 4827 an->an_uapsd_overflowqdepth--; 4824 4828 } 4825 4829 4830 // Clean up node-specific rate things - this currently appears to always be a no-op 4831 sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); 4832 4826 4833 ATH_NODE_UAPSD_LOCK_IRQ(an); 4827 4834 sc->sc_node_cleanup(ni); 4828 4835 ATH_NODE_UAPSD_UNLOCK_IRQ(an); … … 4833 4840 { 4834 4841 struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 4835 4842 4836 sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni));4837 4843 sc->sc_node_free(ni); 4838 4844 #ifdef ATH_SUPERG_XR 4839 4845 ath_grppoll_period_update(sc); … … 5716 5722 ATH_RSSI_LPF(an->an_avgrssi, ds->ds_rxstat.rs_rssi); 5717 5723 type = ieee80211_input(ni, skb, 5718 5724 ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); 5719 ieee80211_ free_node(ni);5725 ieee80211_unref_node(&ni); 5720 5726 } else { 5721 5727 /* 5722 5728 * No key index or no entry, do a lookup and … … 5741 5747 if (keyix != IEEE80211_KEYIX_NONE && 5742 5748 sc->sc_keyixmap[keyix] == NULL) 5743 5749 sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni); 5744 ieee80211_ free_node(ni);5750 ieee80211_unref_node(&ni); 5745 5751 } else 5746 5752 type = ieee80211_input_all(ic, skb, 5747 5753 ds->ds_rxstat.rs_rssi, … … 6541 6547 STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 6542 6548 dev_kfree_skb(lastbuf->bf_skb); 6543 6549 lastbuf->bf_skb = NULL; 6544 ieee80211_free_node(lastbuf->bf_node); 6545 lastbuf->bf_node = NULL; 6550 ieee80211_unref_node(&lastbuf->bf_node); 6546 6551 ATH_TXBUF_LOCK_IRQ(sc); 6547 6552 STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list); 6548 6553 ATH_TXBUF_UNLOCK_IRQ(sc); … … 7293 7298 * this is a DEAUTH message that was sent and the 7294 7299 * node was timed out due to inactivity. 7295 7300 */ 7296 ieee80211_ free_node(ni);7301 ieee80211_unref_node(&ni); 7297 7302 } 7298 7303 7299 7304 bus_unmap_single(sc->sc_bdev, bf->bf_skbaddr, … … 7541 7546 } 7542 7547 #endif /* ATH_SUPERG_FF */ 7543 7548 if (bf->bf_node) 7544 ieee80211_ free_node(bf->bf_node);7549 ieee80211_unref_node(&bf->bf_node); 7545 7550 7546 7551 bf->bf_skb = NULL; 7547 7552 bf->bf_node = NULL; -
svn.madwifi.org-trunk-2115/ath/if_athvar.h
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: if_athvar.h 2 104 2007-02-13 05:54:52Z proski $36 * $Id: if_athvar.h 2000 2007-01-26 01:59:37Z proski $ 37 37 */ 38 38 39 39 /* -
svn.madwifi.org-trunk-2115/ath_hal/ah_os.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: ah_os.c 20 65 2007-02-01 23:14:59Z proski$36 * $Id: ah_os.c 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 #include "opt_ah.h" 39 39 -
svn.madwifi.org-trunk-2115/ath_hal/ah_osdep.h
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: ah_osdep.h 2062 2007-02-01 20:47:22Z proski $36 * $Id: ah_osdep.h 1890 2007-01-11 02:52:41Z proski $ 37 37 */ 38 38 #ifndef _ATH_AH_OSDEP_H_ 39 39 #define _ATH_AH_OSDEP_H_ … … 54 54 #define __packed __attribute__((__packed__)) 55 55 #endif 56 56 57 /* Replace non-annotated HAL_BUS_HANDLE from ah.h */58 typedef void __iomem* ath_iomem_t;59 #define HAL_BUS_HANDLE ath_iomem_t60 61 57 #endif /* _ATH_AH_OSDEP_H_ */ -
svn.madwifi.org-trunk-2115/ath_hal/ah_os.h
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: ah_os.h 20 62 2007-02-01 20:47:22Z proski $36 * $Id: ah_os.h 2014 2007-01-30 00:50:37Z proski $ 37 37 */ 38 38 #ifndef _ATH_AH_OS_H_ 39 39 #define _ATH_AH_OS_H_ … … 147 147 #if (AH_BYTE_ORDER == AH_BIG_ENDIAN) 148 148 #define _OS_REG_WRITE(_ah, _reg, _val) do { \ 149 149 (0x4000 <= (_reg) && (_reg) < 0x5000) ? \ 150 writel((_val), ( _ah)->ah_sh + (_reg)) : \151 __raw_writel((_val), ( _ah)->ah_sh + (_reg)); \150 writel((_val), (void __force __iomem *)((_ah)->ah_sh + (_reg))) : \ 151 __raw_writel((_val), (void __force __iomem *)((_ah)->ah_sh + (_reg))); \ 152 152 } while (0) 153 153 #define _OS_REG_READ(_ah, _reg) \ 154 154 ((0x4000 <= (_reg) && (_reg) < 0x5000) ? \ 155 readl(( _ah)->ah_sh + (_reg)) : \156 __raw_readl(( _ah)->ah_sh + (_reg)))155 readl((void __force __iomem *)((_ah)->ah_sh + (_reg))) : \ 156 __raw_readl((void __force __iomem *)((_ah)->ah_sh + (_reg)))) 157 157 #else /* AH_LITTLE_ENDIAN */ 158 158 #define _OS_REG_WRITE(_ah, _reg, _val) do { \ 159 writel(_val, ( _ah)->ah_sh + (_reg));\159 writel(_val, (void __force __iomem *)((_ah)->ah_sh + (_reg))); \ 160 160 } while (0) 161 161 #define _OS_REG_READ(_ah, _reg) \ 162 readl(( _ah)->ah_sh + (_reg))162 readl((void __force __iomem *)((_ah)->ah_sh + (_reg))) 163 163 #endif /* AH_BYTE_ORDER */ 164 164 165 165 #if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ) -
svn.madwifi.org-trunk-2115/include/compat.h
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: compat.h 2 110 2007-02-14 04:18:36Z proski$36 * $Id: compat.h 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 #ifndef _ATH_COMPAT_H_ 39 39 #define _ATH_COMPAT_H_ -
svn.madwifi.org-trunk-2115/net80211/ieee80211.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211.c 2109 2007-02-14 03:40:19Z scottr$32 * $Id: ieee80211.c 1849 2006-12-08 17:20:08Z proski $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB -
svn.madwifi.org-trunk-2115/net80211/ieee80211_crypto_ccmp.c
old new 28 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 30 * 31 * $Id: ieee80211_crypto_ccmp.c 2112 2007-02-14 04:26:06Z proski $31 * $Id: ieee80211_crypto_ccmp.c 1769 2006-10-24 15:30:26Z proski $ 32 32 */ 33 33 34 34 /* -
svn.madwifi.org-trunk-2115/net80211/ieee80211_debug.h
old new 1 /*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * Alternatively, this software may be distributed under the terms of the 18 * GNU General Public License ("GPL") version 2 as published by the Free 19 * Software Foundation. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * $Id: ieee80211_var.h 1969 2007-01-16 03:05:18Z scottr $ 33 */ 34 #ifndef _NET80211_IEEE80211_DEBUG_H_ 35 #define _NET80211_IEEE80211_DEBUG_H_ 36 37 #define IEEE80211_DEBUG 38 #define IEEE80211_DEBUG_REFCNT /* node refcnt stuff */ 39 40 #include <net80211/ieee80211.h> 41 42 #define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ 43 #define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalent */ 44 #define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ 45 #define IEEE80211_MSG_INPUT 0x08000000 /* input handling */ 46 #define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */ 47 #define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */ 48 #define IEEE80211_MSG_NODE 0x01000000 /* node handling */ 49 #define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */ 50 #define IEEE80211_MSG_AUTH 0x00400000 /* authentication handling */ 51 #define IEEE80211_MSG_SCAN 0x00200000 /* scanning */ 52 #define IEEE80211_MSG_OUTPUT 0x00100000 /* output handling */ 53 #define IEEE80211_MSG_STATE 0x00080000 /* state machine */ 54 #define IEEE80211_MSG_POWER 0x00040000 /* power save handling */ 55 #define IEEE80211_MSG_DOT1X 0x00020000 /* 802.1x authenticator */ 56 #define IEEE80211_MSG_DOT1XSM 0x00010000 /* 802.1x state machine */ 57 #define IEEE80211_MSG_RADIUS 0x00008000 /* 802.1x radius client */ 58 #define IEEE80211_MSG_RADDUMP 0x00004000 /* dump 802.1x radius packets */ 59 #define IEEE80211_MSG_RADKEYS 0x00002000 /* dump 802.1x keys */ 60 #define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */ 61 #define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */ 62 #define IEEE80211_MSG_WME 0x00000400 /* WME protocol */ 63 #define IEEE80211_MSG_SUPG 0x00000200 /* SUPERG */ 64 #define IEEE80211_MSG_DOTH 0x00000100 /* 11.h */ 65 #define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */ 66 #define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */ 67 68 #define IEEE80211_MSG_ANY 0xffffffff /* anything */ 69 70 #ifdef IEEE80211_DEBUG 71 int ieee80211_msg_is_reported(struct ieee80211vap *, unsigned int msg); 72 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) do { \ 73 if (ieee80211_msg_is_reported(_vap, _m)) \ 74 ieee80211_note(_vap, _fmt, __VA_ARGS__); \ 75 } while (0) 76 #define IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) do { \ 77 if (ieee80211_msg_is_reported(_vap, _m)) \ 78 ieee80211_note_mac(_vap, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\ 79 } while (0) 80 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) do { \ 81 if (ieee80211_msg_is_reported(_vap, _m)) \ 82 ieee80211_note_mac(_vap, _mac, _fmt, __VA_ARGS__); \ 83 } while (0) 84 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) do { \ 85 if (ieee80211_msg_is_reported(_vap, _m)) \ 86 ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__); \ 87 } while (0) 88 struct ieee80211vap; 89 struct ieee80211_frame; 90 void ieee80211_note(struct ieee80211vap *, const char *, ...); 91 void ieee80211_note_mac(struct ieee80211vap *, 92 const u_int8_t mac[IEEE80211_ADDR_LEN], const char *, ...); 93 void ieee80211_note_frame(struct ieee80211vap *, 94 const struct ieee80211_frame *, const char *, ...); 95 #define ieee80211_msg_debug(_vap) \ 96 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_DEBUG) 97 #define ieee80211_msg_dumppkts(_vap) \ 98 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_DUMPPKTS) 99 #define ieee80211_msg_input(_vap) \ 100 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_INPUT) 101 #define ieee80211_msg_radius(_vap) \ 102 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADIUS) 103 #define ieee80211_msg_dumpradius(_vap) \ 104 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADDUMP) 105 #define ieee80211_msg_dumpradkeys(_vap) \ 106 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADKEYS) 107 #define ieee80211_msg_scan(_vap) \ 108 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_SCAN) 109 #define ieee80211_msg_assoc(_vap) \ 110 ieee80211_msg_is_reported(_vap, IEEE80211_MSG_ASSOC) 111 #else /* IEEE80211_DEBUG */ 112 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) 113 #define IEEE80211_NOTE(_vap, _m, _wh, _fmt, ...) 114 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) 115 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) 116 #endif /* IEEE80211_DEBUG */ 117 118 #endif /* _NET80211_IEEE80211_DEBUG_H_ */ 119 -
svn.madwifi.org-trunk-2115/net80211/ieee80211_input.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_input.c 20 69 2007-02-02 20:01:51Z mentor $32 * $Id: ieee80211_input.c 2093 2007-02-07 21:06:25Z mentor $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB … … 489 489 nt = &ic->ic_sta; 490 490 ni_wds = ieee80211_find_wds_node(nt, wh->i_addr3); 491 491 if (ni_wds) { 492 ieee80211_ free_node(ni_wds); /* Decr ref count */492 ieee80211_unref_node(&ni_wds); /* Decr ref count */ 493 493 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, 494 494 wh, NULL, "%s", 495 495 "multicast echo originated from node behind me"); … … 569 569 if (ni_wds == NULL) 570 570 ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); 571 571 else 572 ieee80211_ free_node(ni_wds); /* Decr ref count */572 ieee80211_unref_node(&ni_wds); /* Decr ref count */ 573 573 } 574 574 575 575 /* … … 928 928 } 929 929 ni = ieee80211_ref_node(vap->iv_bss); 930 930 type = ieee80211_input(ni, skb1, rssi, rstamp); 931 ieee80211_ free_node(ni);931 ieee80211_unref_node(&ni); 932 932 } 933 933 if (skb != NULL) /* no vaps, reclaim skb */ 934 934 dev_kfree_skb(skb); … … 978 978 } 979 979 980 980 /* 981 * Use this lock to make sure ni->ni_rxfrag is982 * not freed by the timer process while we use it.983 * XXX bogus984 */985 IEEE80211_NODE_LOCK_IRQ(ni->ni_table);986 987 /*988 981 * Update the time stamp. As a side effect, it 989 982 * also makes sure that the timer will not change 990 983 * ni->ni_rxfrag for at least 1 second, or in 991 984 * other words, for the remaining of this function. 985 * XXX HUGE HORRIFIC HACK 992 986 */ 993 987 ni->ni_rxfragstamp = jiffies; 994 988 995 IEEE80211_NODE_UNLOCK_IRQ(ni->ni_table);996 997 989 /* 998 990 * Validate that fragment is in order and 999 991 * related to the previous ones. … … 1122 1114 skb = NULL; 1123 1115 } 1124 1116 /* XXX statistic? */ 1125 ieee80211_ free_node(ni1);1117 ieee80211_unref_node(&ni1); 1126 1118 } 1127 1119 } 1128 1120 if (skb1 != NULL) { … … 1246 1238 int rssi, u_int32_t rstamp, u_int16_t seq, u_int16_t status) 1247 1239 { 1248 1240 struct ieee80211vap *vap = ni->ni_vap; 1241 unsigned int tmpnode = 0; 1249 1242 1250 1243 if (ni->ni_authmode == IEEE80211_AUTH_SHARED) { 1251 1244 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, … … 1253 1246 "bad sta auth mode %u", ni->ni_authmode); 1254 1247 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ 1255 1248 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 1256 /* XXX hack to workaround calling convention */1257 1258 /* XXX To send the frame to the requesting STA, we have to1259 * create a node for the station that we're going to reject.1260 * The node will be freed automatically */1261 1249 if (ni == vap->iv_bss) { 1262 ni = ieee80211_dup_bss(vap, wh->i_addr2 );1250 ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 1263 1251 if (ni == NULL) 1264 1252 return; 1265 1253 1266 1254 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 1267 1255 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), 1268 1256 ieee80211_node_refcnt(ni)); 1257 tmpnode = 1; 1269 1258 } 1270 1259 IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, 1271 1260 (seq + 1) | (IEEE80211_STATUS_ALG << 16)); 1261 1262 if (tmpnode) 1263 ieee80211_unref_node(&ni); 1272 1264 return; 1273 1265 } 1274 1266 } … … 1296 1288 } 1297 1289 /* always accept open authentication requests */ 1298 1290 if (ni == vap->iv_bss) { 1299 ni = ieee80211_dup_bss(vap, wh->i_addr2 );1291 ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 1300 1292 if (ni == NULL) 1301 1293 return; 1302 1294 1303 1295 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 1304 1296 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), 1305 1297 ieee80211_node_refcnt(ni)); 1306 1307 } else if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) 1308 (void) ieee80211_ref_node(ni); 1309 /* 1310 * Mark the node as referenced to reflect that it's 1311 * reference count has been bumped to ensure it remains 1312 * after the transaction completes. 1313 */ 1314 ni->ni_flags |= IEEE80211_NODE_AREF; 1315 1298 tmpnode = 1; 1299 } 1300 1316 1301 IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, seq + 1); 1317 1302 IEEE80211_NOTE(vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, 1318 1303 ni, "station authenticated (%s)", "open"); … … 1322 1307 */ 1323 1308 if (ni->ni_authmode != IEEE80211_AUTH_8021X) 1324 1309 ieee80211_node_authorize(ni); 1310 if (tmpnode) 1311 ieee80211_unref_node(&ni); 1325 1312 break; 1326 1313 1327 1314 case IEEE80211_M_STA: … … 1360 1347 int istmp; 1361 1348 1362 1349 if (ni == vap->iv_bss) { 1363 ni = ieee80211_ tmp_node(vap, mac);1350 ni = ieee80211_dup_bss(vap, mac, 1); 1364 1351 if (ni == NULL) { 1365 1352 /* XXX msg */ 1366 1353 return; … … 1370 1357 istmp = 0; 1371 1358 IEEE80211_SEND_MGMT(ni, subtype, arg); 1372 1359 if (istmp) 1373 ieee80211_ free_node(ni);1360 ieee80211_unref_node(&ni); 1374 1361 } 1375 1362 1376 1363 static int … … 1396 1383 { 1397 1384 struct ieee80211vap *vap = ni->ni_vap; 1398 1385 u_int8_t *challenge; 1399 int allocbs , estatus;1386 int allocbs = 0, estatus = 0; 1400 1387 1401 1388 /* 1402 1389 * NB: this can happen as we allow pre-shared key … … 1406 1393 * ordering in which case this check would just be 1407 1394 * for sanity/consistency. 1408 1395 */ 1409 estatus = 0; /* NB: silence compiler */1410 1396 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { 1411 1397 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1412 1398 ni->ni_macaddr, "shared key auth", … … 1486 1472 switch (seq) { 1487 1473 case IEEE80211_AUTH_SHARED_REQUEST: 1488 1474 if (ni == vap->iv_bss) { 1489 ni = ieee80211_dup_bss(vap, wh->i_addr2 );1475 ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 1490 1476 if (ni == NULL) { 1491 1477 /* NB: no way to return an error */ 1492 1478 return; … … 1497 1483 ieee80211_node_refcnt(ni)); 1498 1484 1499 1485 allocbs = 1; 1500 } else {1501 if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0)1502 (void) ieee80211_ref_node(ni);1503 allocbs = 0;1504 1486 } 1505 /* 1506 * Mark the node as referenced to reflect that it's 1507 * reference count has been bumped to ensure it remains 1508 * after the transaction completes. 1509 */ 1510 ni->ni_flags |= IEEE80211_NODE_AREF; 1487 1511 1488 ni->ni_rssi = rssi; 1512 1489 ni->ni_rstamp = rstamp; 1513 1490 ni->ni_last_rx = jiffies; … … 1601 1578 } 1602 1579 return; 1603 1580 bad: 1604 /* 1605 * Send an error response; but only when operating as an AP. 1606 */ 1581 /* Send an error response; but only when operating as an AP. */ 1607 1582 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 1608 1583 /* XXX hack to workaround calling convention */ 1609 1584 ieee80211_send_error(ni, wh->i_addr2, 1610 1585 IEEE80211_FC0_SUBTYPE_AUTH, 1611 1586 (seq + 1) | (estatus<<16)); 1587 ieee80211_node_leave(ni); 1612 1588 } else if (vap->iv_opmode == IEEE80211_M_STA) { 1613 1589 /* 1614 1590 * Kick the state machine. This short-circuits … … 2072 2048 /* optional RSN capabilities */ 2073 2049 if (len > 2) 2074 2050 rsn_parm->rsn_caps = LE_READ_2(frm); 2075 /* XXX PMKID */2051 /* XXX PMKID */ 2076 2052 2077 2053 return 0; 2078 2054 } … … 2566 2542 u_int8_t *frm, *efrm; 2567 2543 u_int8_t *ssid, *rates, *xrates, *wpa, *rsn, *wme, *ath; 2568 2544 u_int8_t rate; 2569 int reassoc, resp, allocbs ;2545 int reassoc, resp, allocbs = 0; 2570 2546 u_int8_t qosinfo; 2571 2547 2572 2548 wh = (struct ieee80211_frame *) skb->data; … … 2962 2938 ni = ieee80211_fakeup_adhoc_node(vap, 2963 2939 wh->i_addr2); 2964 2940 } else { 2965 ni = ieee80211_ tmp_node(vap, wh->i_addr2);2941 ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 2966 2942 } 2967 2943 if (ni == NULL) 2968 2944 return; 2969 2945 allocbs = 1; 2970 } else2971 allocbs = 0; 2946 } 2947 2972 2948 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2, 2973 2949 "%s", "recv probe req"); 2974 2950 ni->ni_rssi = rssi; … … 2991 2967 * Temporary node created just to send a 2992 2968 * response, reclaim immediately 2993 2969 */ 2994 ieee80211_ free_node(ni);2970 ieee80211_unref_node(&ni); 2995 2971 } else if (ath != NULL) 2996 2972 ieee80211_saveath(ni, ath); 2997 2973 break; … … 3021 2997 ni = vap->iv_xrvap->iv_bss; 3022 2998 else { 3023 2999 ieee80211_node_leave(ni); 3000 /* This would be a stupid place to add a node to the table 3001 * XR stuff needs work anyway 3002 */ 3024 3003 ieee80211_node_reset(ni, vap->iv_xrvap); 3025 3004 } 3026 3005 vap = vap->iv_xrvap; … … 3033 3012 #endif 3034 3013 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2, 3035 3014 "recv auth frame with algorithm %d seq %d", algo, seq); 3036 /* 3037 * Consult the ACL policy module if setup. 3038 */ 3015 /* Consult the ACL policy module if setup. */ 3039 3016 if (vap->iv_acl != NULL && 3040 3017 !vap->iv_acl->iac_check(vap, wh->i_addr2)) { 3041 3018 IEEE80211_DISCARD(vap, IEEE80211_MSG_ACL, … … 3068 3045 /* XXX not right */ 3069 3046 ieee80211_send_error(ni, wh->i_addr2, 3070 3047 IEEE80211_FC0_SUBTYPE_AUTH, 3071 (seq +1) | (IEEE80211_STATUS_ALG << 16));3048 (seq + 1) | (IEEE80211_STATUS_ALG << 16)); 3072 3049 } 3073 3050 return; 3074 3051 } -
svn.madwifi.org-trunk-2115/net80211/ieee80211_linux.h
old new 24 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 26 * 27 * $Id: ieee80211_linux.h 20 33 2007-01-31 03:27:59Z proski$27 * $Id: ieee80211_linux.h 2064 2007-02-01 20:49:37Z mentor $ 28 28 */ 29 29 #ifndef _NET80211_IEEE80211_LINUX_H_ 30 30 #define _NET80211_IEEE80211_LINUX_H_ … … 63 63 64 64 #define IEEE80211_RESCHEDULE schedule 65 65 66 /* Locking */ 67 /* NB: beware, spin_is_locked() is not usefully defined for !(DEBUG || SMP) 68 * because spinlocks do not exist in this configuration. Instead IRQs 69 * or pre-emption are simply disabled, as this is all that is needed. 70 */ 71 66 72 /* 67 73 * Beacon handler locking definitions. 68 74 * Beacon locking … … 85 91 #define IEEE80211_LOCK(_ic) spin_lock(&(_ic)->ic_comlock) 86 92 #define IEEE80211_UNLOCK(_ic) spin_unlock(&(_ic)->ic_comlock) 87 93 88 /* NB: beware, spin_is_locked() is unusable for !SMP */ 89 #if defined(CONFIG_SMP) 94 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 90 95 #define IEEE80211_LOCK_ASSERT(_ic) \ 91 96 KASSERT(spin_is_locked(&(_ic)->ic_comlock),("ieee80211com not locked!")) 92 97 #else 93 98 #define IEEE80211_LOCK_ASSERT(_ic) 94 99 #endif 95 100 101 96 102 #define IEEE80211_VAPS_LOCK_INIT(_ic, _name) \ 97 103 spin_lock_init(&(_ic)->ic_vapslock) 98 104 #define IEEE80211_VAPS_LOCK_DESTROY(_ic) … … 108 114 } while (0) 109 115 #define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags) 110 116 111 112 /* NB: beware, spin_is_locked() is unusable for !SMP */ 113 #if defined(CONFIG_SMP) 117 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 114 118 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) \ 115 KASSERT(spin_is_locked(&(_ic)->ic_vapslock),("ieee80211com_vaps not locked!")) 119 KASSERT(spin_is_locked(&(_ic)->ic_vapslock), \ 120 ("ieee80211com_vaps not locked!")) 116 121 #else 117 122 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) 118 123 #endif … … 121 126 /* 122 127 * Node locking definitions. 123 128 */ 129 #if 0 130 124 131 typedef spinlock_t ieee80211_node_lock_t; 125 #define IEEE80211_NODE_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_nodelock) 126 #define IEEE80211_NODE_LOCK_DESTROY(_nt) 127 #define IEEE80211_NODE_LOCK(_nt) spin_lock(&(_nt)->nt_nodelock) 128 #define IEEE80211_NODE_UNLOCK(_nt) spin_unlock(&(_nt)->nt_nodelock) 129 #define IEEE80211_NODE_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_nodelock) 130 #define IEEE80211_NODE_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_nodelock) 131 #define IEEE80211_NODE_LOCK_IRQ(_nt) do { \ 132 #define IEEE80211_NODE_LOCK_INIT(_ni, _name) spin_lock_init(&(_ni)->ni_nodelock) 133 #define IEEE80211_NODE_LOCK_DESTROY(_ni) 134 #if 0 /* We should always be contesting in the same contexts */ 135 #define IEEE80211_NODE_LOCK(_ni) spin_lock(&(_ni)->ni_nodelock) 136 #define IEEE80211_NODE_UNLOCK(_ni) spin_unlock(&(_ni)->ni_nodelock) 137 #define IEEE80211_NODE_LOCK_BH(_ni) spin_lock_bh(&(_ni)->ni_nodelock) 138 #define IEEE80211_NODE_UNLOCK_BH(_ni) spin_unlock_bh(&(_ni)->ni_nodelock) 139 #endif 140 #define IEEE80211_NODE_LOCK_IRQ(_ni) do { \ 141 unsigned long __node_lockflags; \ 142 spin_lock_irqsave(&(_ni)->ni_nodelock, __node_lockflags); 143 #define IEEE80211_NODE_UNLOCK_IRQ(_ni) \ 144 spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags); \ 145 } while(0) 146 #define IEEE80211_NODE_UNLOCK_IRQ_EARLY(_ni) \ 147 spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags); 148 149 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 150 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \ 151 KASSERT(spin_is_locked(&(_ni)->ni_nodelock), \ 152 ("802.11 node not locked!")) 153 #else 154 #define IEEE80211_NODE_LOCK_ASSERT(_ni) 155 #endif 156 157 #endif /* node lock */ 158 159 /* 160 * Node table locking definitions. 161 */ 162 typedef spinlock_t ieee80211_node_table_lock_t; 163 #define IEEE80211_NODE_TABLE_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_nodelock) 164 #define IEEE80211_NODE_TABLE_LOCK_DESTROY(_nt) 165 #if 0 /* We should always be contesting in the same contexts */ 166 #define IEEE80211_NODE_TABLE_LOCK(_nt) spin_lock(&(_nt)->nt_nodelock) 167 #define IEEE80211_NODE_TABLE_UNLOCK(_nt) spin_unlock(&(_nt)->nt_nodelock) 168 #define IEEE80211_NODE_TABLE_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_nodelock) 169 #define IEEE80211_NODE_TABLE_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_nodelock) 170 #endif 171 #define IEEE80211_NODE_TABLE_LOCK_IRQ(_nt) do { \ 132 172 unsigned long __node_lockflags; \ 133 173 spin_lock_irqsave(&(_nt)->nt_nodelock, __node_lockflags); 134 #define IEEE80211_NODE_ UNLOCK_IRQ(_nt) \174 #define IEEE80211_NODE_TABLE_UNLOCK_IRQ(_nt) \ 135 175 spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); \ 136 176 } while(0) 137 #define IEEE80211_NODE_ UNLOCK_IRQ_EARLY(_nt) \177 #define IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(_nt) \ 138 178 spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); 139 179 140 /* NB: beware, *_is_locked() are bogusly defined for UP+!PREEMPT */ 141 #if (defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)) && defined(spinlock_is_locked) 142 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \ 143 KASSERT(spinlock_is_locked(&(_nt)->nt_nodelock), \ 180 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 181 #define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) \ 182 KASSERT(spin_is_locked(&(_nt)->nt_nodelock), \ 144 183 ("802.11 node table not locked!")) 145 184 #else 146 #define IEEE80211_NODE_ LOCK_ASSERT(_nt)185 #define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) 147 186 #endif 148 187 149 188 /* … … 163 202 #define IEEE80211_SCAN_UNLOCK_IRQ_EARLY(_nt) \ 164 203 spin_unlock_irqrestore(&(_nt)->nt_scanlock, __scan_lockflags); 165 204 166 /* NB: beware, spin_is_locked() is unusable for !SMP */ 167 #if defined(CONFIG_SMP) 205 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 168 206 #define IEEE80211_SCAN_LOCK_ASSERT(_nt) \ 169 207 KASSERT(spin_is_locked(&(_nt)->nt_scanlock), ("scangen not locked!")) 170 208 #else … … 182 220 #define ACL_LOCK_BH(_as) spin_lock_bh(&(_as)->as_lock) 183 221 #define ACL_UNLOCK_BH(_as) spin_unlock_bh(&(_as)->as_lock) 184 222 185 /* NB: beware, spin_is_locked() is unusable for !SMP */ 186 #if defined(CONFIG_SMP) 223 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 187 224 #define ACL_LOCK_ASSERT(_as) \ 188 225 KASSERT(spin_is_locked(&(_as)->as_lock), ("ACL not locked!")) 189 226 #else … … 299 336 * is the last reference, otherwise 0 300 337 * ieee80211_node_refcnt reference count for printing (only) 301 338 */ 339 typedef atomic_t ieee80211_node_ref_count_t; 302 340 #define ieee80211_node_initref(_ni) atomic_set(&(_ni)->ni_refcnt, 1) 303 341 #define ieee80211_node_incref(_ni) atomic_inc(&(_ni)->ni_refcnt) 304 342 #define ieee80211_node_decref(_ni) atomic_dec(&(_ni)->ni_refcnt) … … 379 417 /* msecs_to_jiffies appeared in 2.6.7 and 2.4.29 */ 380 418 #include <linux/delay.h> 381 419 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \ 382 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || \383 LINUX_VERSION_CODE < KERNEL_VERSION(2,4,29)420 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || \ 421 LINUX_VERSION_CODE < KERNEL_VERSION(2,4,29) 384 422 385 423 /* The following definitions and inline functions are 386 424 * copied from the kernel src, include/linux/jiffies.h */ -
svn.madwifi.org-trunk-2115/net80211/ieee80211_node.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_node.c 20 83 2007-02-06 15:33:38Z mentor $32 * $Id: ieee80211_node.c 2099 2007-02-09 01:16:01Z mentor $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB … … 65 65 #define IEEE80211_AID_ISSET(_vap, _b) \ 66 66 ((_vap)->iv_aid_bitmap[IEEE80211_AID(_b) / 32] & (1 << (IEEE80211_AID(_b) % 32))) 67 67 68 static struct ieee80211_node *ieee80211_alloc_node(struct ieee80211vap *, const u_int8_t *); 69 68 70 static int ieee80211_sta_join1(struct ieee80211_node *); 69 71 70 static struct ieee80211_node *node_alloc(struct ieee80211_node_table *, 71 struct ieee80211vap *); 72 static struct ieee80211_node *node_alloc(struct ieee80211vap *); 72 73 static void node_cleanup(struct ieee80211_node *); 73 74 static void node_free(struct ieee80211_node *); 74 75 static u_int8_t node_getrssi(const struct ieee80211_node *); 75 76 76 static void _ ieee80211_free_node(struct ieee80211_node *);77 static void node_reclaim(struct ieee80211_node_table *, struct ieee80211_node*);77 static void _node_table_leave(struct ieee80211_node_table *, struct ieee80211_node *); 78 static void _node_table_join(struct ieee80211_node_table *, struct ieee80211_node *); 78 79 79 80 static void ieee80211_node_timeout(unsigned long); 80 81 … … 194 195 195 196 ieee80211_node_table_reset(&ic->ic_sta, vap); 196 197 if (vap->iv_bss != NULL) { 197 ieee80211_free_node(vap->iv_bss); 198 vap->iv_bss = NULL; 198 ieee80211_unref_node(&vap->iv_bss); 199 199 } 200 200 if (vap->iv_aid_bitmap != NULL) { 201 201 FREE(vap->iv_aid_bitmap, M_DEVBUF); … … 203 203 } 204 204 } 205 205 206 int ieee80211_msg_is_reported(struct ieee80211vap *vap, unsigned m) 207 { 208 return !!(vap->iv_debug & m); 209 } 210 EXPORT_SYMBOL(ieee80211_msg_is_reported); 211 206 212 /* 207 213 * Port authorize/unauthorize interfaces for use by an authenticator. 208 214 */ … … 263 269 "%s: creating ibss on channel %u\n", __func__, 264 270 ieee80211_chan2ieee(ic, chan)); 265 271 266 /* Check to see if we already have a node for this mac */ 272 /* Check to see if we already have a node for this mac 273 * NB: we gain a node reference here 274 */ 267 275 ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr); 268 276 if (ni == NULL) { 269 ni = ieee80211_alloc_node (&ic->ic_sta,vap, vap->iv_myaddr);277 ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 270 278 if (ni == NULL) { 271 279 /* XXX recovery? */ 272 280 return; 273 281 } 274 282 } 275 else276 ieee80211_free_node(ni);277 283 278 284 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: %p<%s> refcnt %d\n", 279 285 __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), … … 345 351 else if (IEEE80211_IS_CHAN_QUARTER(chan)) 346 352 ni->ni_rates = ic->ic_sup_quarter_rates; 347 353 348 (void) ieee80211_sta_join1( ieee80211_ref_node(ni));354 (void) ieee80211_sta_join1(PASS_NODE(ni)); 349 355 } 350 356 EXPORT_SYMBOL(ieee80211_create_ibss); 351 357 … … 369 375 /* XXX multi-bss wrong */ 370 376 ieee80211_reset_erp(ic, ic->ic_curmode); 371 377 372 ni = ieee80211_alloc_node (&ic->ic_sta,vap, vap->iv_myaddr);378 ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 373 379 KASSERT(ni != NULL, ("unable to setup inital BSS node")); 374 380 obss = vap->iv_bss; 381 // Caller's reference 375 382 vap->iv_bss = ieee80211_ref_node(ni); 376 383 377 384 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: new bss %p<%s> refcnt %d\n", … … 381 388 if (obss != NULL) { 382 389 copy_bss(ni, obss); 383 390 ni->ni_intval = ic->ic_lintval; 384 ieee80211_free_node(obss); 391 // Caller's reference 392 ieee80211_unref_node(&obss); 385 393 } 386 394 } 387 395 … … 587 595 vap->iv_state == IEEE80211_S_RUN && ssid_equal(obss, selbs)); 588 596 vap->iv_bss = selbs; 589 597 if (obss != NULL) 590 ieee80211_ free_node(obss);598 ieee80211_unref_node(&obss); 591 599 ic->ic_bsschan = selbs->ni_chan; 592 600 ic->ic_curchan = ic->ic_bsschan; 593 601 ic->ic_curmode = ieee80211_chan2mode(ic->ic_curchan); … … 644 652 645 653 ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr); 646 654 if (ni == NULL) { 647 ni = ieee80211_alloc_node (&ic->ic_sta,vap, se->se_macaddr);655 ni = ieee80211_alloc_node_table(vap, se->se_macaddr); 648 656 if (ni == NULL) { 649 657 /* XXX msg */ 650 658 return 0; 651 659 } 652 } else 653 ieee80211_free_node(ni); 660 } 654 661 655 662 /* 656 663 * Expand scan state into node's format. 657 664 * XXX may not need all this stuff 658 665 */ 659 ni->ni_authmode = vap->iv_bss->ni_authmode; /* inherit authmode from iv_bss */666 ni->ni_authmode = vap->iv_bss->ni_authmode; /* inherit authmode from iv_bss */ 660 667 /* inherit the WPA setup as well (structure copy!) */ 661 668 ni->ni_rsn = vap->iv_bss->ni_rsn; 662 669 IEEE80211_ADDR_COPY(ni->ni_bssid, se->se_bssid); … … 690 697 691 698 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 692 699 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), 693 ieee80211_node_refcnt(ni) +1);700 ieee80211_node_refcnt(ni)); 694 701 695 return ieee80211_sta_join1( ieee80211_ref_node(ni));702 return ieee80211_sta_join1(PASS_NODE(ni)); 696 703 } 697 704 EXPORT_SYMBOL(ieee80211_sta_join); 698 705 … … 704 711 ieee80211_sta_leave(struct ieee80211_node *ni) 705 712 { 706 713 struct ieee80211vap *vap = ni->ni_vap; 707 struct ieee80211com *ic = vap->iv_ic;708 714 709 715 /* WDS/Repeater: Stop software beacon timer for STA */ 710 716 if (vap->iv_opmode == IEEE80211_M_STA && 711 717 vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) { 712 718 del_timer(&vap->iv_swbmiss); 713 719 } 714 715 ic->ic_node_cleanup(ni); 720 716 721 ieee80211_notify_node_leave(ni); 717 722 } 718 723 … … 721 726 */ 722 727 723 728 static void 724 ieee80211_node_table_init(struct ieee80211com *ic, 725 struct ieee80211_node_table *nt,const char *name, int inact)729 ieee80211_node_table_init(struct ieee80211com *ic, struct ieee80211_node_table *nt, 730 const char *name, int inact) 726 731 { 727 732 nt->nt_ic = ic; 728 IEEE80211_NODE_ LOCK_INIT(nt, ic->ic_dev->name);733 IEEE80211_NODE_TABLE_LOCK_INIT(nt, ic->ic_dev->name); 729 734 IEEE80211_SCAN_LOCK_INIT(nt, ic->ic_dev->name); 730 735 TAILQ_INIT(&nt->nt_node); 731 736 nt->nt_name = name; … … 737 742 mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 738 743 } 739 744 745 static __inline void _node_table_join(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 746 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 747 748 ni->ni_table = nt; 749 TAILQ_INSERT_TAIL(&nt->nt_node, ieee80211_ref_node(ni), ni_list); 750 LIST_INSERT_HEAD(&nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni, ni_hash); 751 } 752 753 static __inline void _node_table_leave(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 754 struct ieee80211_node *hni; 755 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 756 757 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 758 LIST_FOREACH(hni, &nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni_hash) { 759 LIST_REMOVE(ni, ni_hash); 760 } 761 ni->ni_table = NULL; 762 _ieee80211_unref_node(ni); 763 } 764 765 /* This is overridden by ath_node_alloc in ath/if_ath.c, and so 766 * should never get called. 767 */ 740 768 static struct ieee80211_node * 741 node_alloc(struct ieee80211 _node_table *nt, struct ieee80211vap *vap)769 node_alloc(struct ieee80211vap *vap) 742 770 { 743 771 struct ieee80211_node *ni; 744 772 … … 777 805 IEEE80211_UNLOCK_IRQ(ni->ni_ic); 778 806 } 779 807 } 780 /*781 * Clear AREF flag that marks the authorization refcnt bump782 * has happened. This is probably not needed as the node783 * should always be removed from the table so not found but784 * do it just in case.785 */786 ni->ni_flags &= ~IEEE80211_NODE_AREF;787 808 788 809 /* 789 810 * Drain power save queue and, if needed, clear TIM. … … 792 813 vap->iv_set_tim(ni, 0); 793 814 794 815 ni->ni_associd = 0; 795 if (ni->ni_challenge != NULL) { 796 FREE(ni->ni_challenge, M_DEVBUF); 797 ni->ni_challenge = NULL; 798 } 816 799 817 /* 800 818 * Preserve SSID, WPA, and WME ie's so the bss node is 801 819 * reusable during a re-auth/re-assoc state transition. … … 820 838 static void 821 839 node_free(struct ieee80211_node *ni) 822 840 { 841 #if 0 842 // We should 'cleanup' and then free'ing should be done automatically on decref 823 843 struct ieee80211com *ic = ni->ni_ic; 824 844 825 845 ic->ic_node_cleanup(ni); 846 #endif 847 KASSERT(ieee80211_node_refcnt(ni) == 0, ("node being free whilst still referenced")); 848 849 if (ni->ni_challenge != NULL) 850 FREE(ni->ni_challenge, M_DEVBUF); 826 851 if (ni->ni_wpa_ie != NULL) 827 852 FREE(ni->ni_wpa_ie, M_DEVBUF); 828 853 if (ni->ni_rsn_ie != NULL) … … 832 857 if (ni->ni_ath_ie != NULL) 833 858 FREE(ni->ni_ath_ie, M_DEVBUF); 834 859 IEEE80211_NODE_SAVEQ_DESTROY(ni); 860 835 861 FREE(ni, M_80211_NODE); 836 862 } 837 863 … … 848 874 * This interface is not intended for general use, it is 849 875 * used by the routines below to create entries with a 850 876 * specific purpose. 877 * Dont assume a BSS? 851 878 */ 852 879 struct ieee80211_node * 853 ieee80211_alloc_node (struct ieee80211_node_table *nt,854 struct ieee80211vap *vap,const u_int8_t *macaddr)880 ieee80211_alloc_node_table(struct ieee80211vap *vap, 881 const u_int8_t *macaddr) 855 882 { 856 struct ieee80211com *ic = nt->nt_ic; 883 struct ieee80211com *ic = vap->iv_ic; 884 struct ieee80211_node_table *nt = &ic->ic_sta; 857 885 struct ieee80211_node *ni; 858 int hash;859 886 860 ni = ic->ic_node_alloc(nt, vap); 861 if (ni == NULL) { 862 /* XXX msg */ 863 vap->iv_stats.is_rx_nodealloc++; 864 return NULL; 865 } 887 ni = ieee80211_alloc_node(vap, macaddr); 888 if (ni != NULL) { 889 ni->ni_inact = ni->ni_inact_reload = nt->nt_inact_init; 866 890 867 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 868 "%s: %p<%s> in %s table, refcnt %d\n", __func__, ni, 869 ether_sprintf(macaddr), nt->nt_name, 870 ieee80211_node_refcnt(ni)+1); 891 WME_UAPSD_NODE_TRIGSEQINIT(ni); 892 IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 871 893 872 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 873 hash = IEEE80211_NODE_HASH(macaddr); 874 ieee80211_node_initref(ni); /* mark referenced */ 875 ni->ni_chan = IEEE80211_CHAN_ANYC; 876 ni->ni_authmode = IEEE80211_AUTH_OPEN; 877 ni->ni_txpower = ic->ic_txpowlimit; /* max power */ 878 ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, IEEE80211_KEYIX_NONE); 879 ni->ni_inact_reload = nt->nt_inact_init; 880 ni->ni_inact = ni->ni_inact_reload; 881 ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 882 ni->ni_rxkeyoff = 0; 883 IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 894 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 895 _node_table_join(nt, ni); 896 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 897 } 884 898 885 IEEE80211_NODE_LOCK_IRQ(nt); 886 ni->ni_vap = vap; 887 ni->ni_ic = ic; 888 ni->ni_table = nt; 889 TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 890 LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 891 ni->ni_rxfrag = NULL; 892 ni->ni_challenge = NULL; 893 IEEE80211_NODE_UNLOCK_IRQ(nt); 899 return ni; 900 } 901 EXPORT_SYMBOL(ieee80211_alloc_node_table); 902 903 /* Allocate a node structure and initialise specialised structures 904 * This function does not add the node to the node table, thus this 905 * node will not be found using ieee80211_find_*node. 906 * This is useful when sending one off errors or request denials. 907 */ 908 static struct ieee80211_node * 909 ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) 910 { 911 struct ieee80211com *ic = vap->iv_ic; 912 struct ieee80211_node *ni; 913 914 /* This always allocates zeroed memoery */ 915 ni = ic->ic_node_alloc(vap); 916 if (ni != NULL) { 917 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 918 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr), 919 ieee80211_node_refcnt(ni)+1); 894 920 895 WME_UAPSD_NODE_TRIGSEQINIT(ni); 921 ieee80211_node_initref(ni); /* mark referenced */ 922 923 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 924 925 ni->ni_chan = IEEE80211_CHAN_ANYC; 926 ni->ni_authmode = IEEE80211_AUTH_OPEN; 927 ni->ni_txpower = ic->ic_txpowlimit; 928 929 ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, 930 IEEE80211_KEYIX_NONE); 931 ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 896 932 933 ni->ni_vap = vap; 934 ni->ni_ic = ic; 935 } else { 936 /* XXX msg */ 937 vap->iv_stats.is_rx_nodealloc++; 938 } 897 939 return ni; 898 940 } 899 EXPORT_SYMBOL(ieee80211_alloc_node);900 941 901 942 /* Add wds address to the node table */ 902 943 int … … 918 959 wds->wds_agingcount = WDS_AGING_COUNT; 919 960 hash = IEEE80211_NODE_HASH(macaddr); 920 961 IEEE80211_ADDR_COPY(wds->wds_macaddr, macaddr); 921 ieee80211_ref_node(ni); /* Reference node */922 wds->wds_ni = ni;923 IEEE80211_NODE_LOCK_IRQ(nt);962 963 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 964 wds->wds_ni = ieee80211_ref_node(ni); 924 965 LIST_INSERT_HEAD(&nt->nt_wds_hash[hash], wds, wds_hash); 925 IEEE80211_NODE_ UNLOCK_IRQ(nt);966 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 926 967 return 0; 927 968 } 928 969 EXPORT_SYMBOL(ieee80211_add_wds_addr); … … 935 976 struct ieee80211_wds_addr *wds; 936 977 937 978 hash = IEEE80211_NODE_HASH(macaddr); 938 IEEE80211_NODE_ LOCK_IRQ(nt);979 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 939 980 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 940 981 if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 941 if (ieee80211_node_dectestref(wds->wds_ni)) { 942 _ieee80211_free_node(wds->wds_ni); 943 LIST_REMOVE(wds, wds_hash); 944 FREE(wds, M_80211_WDS); 945 break; 946 } 982 LIST_REMOVE(wds, wds_hash); 983 ieee80211_unref_node(&wds->wds_ni); 984 FREE(wds, M_80211_WDS); 985 break; 947 986 } 948 987 } 949 IEEE80211_NODE_ UNLOCK_IRQ(nt);988 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 950 989 } 951 990 EXPORT_SYMBOL(ieee80211_remove_wds_addr); 952 991 … … 958 997 int hash; 959 998 struct ieee80211_wds_addr *wds; 960 999 961 IEEE80211_NODE_ LOCK_IRQ(nt);1000 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 962 1001 for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 963 1002 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 964 1003 if (wds->wds_ni == ni) { 965 if (ieee80211_node_dectestref(ni)) { 966 _ieee80211_free_node(ni); 967 LIST_REMOVE(wds, wds_hash); 968 FREE(wds, M_80211_WDS); 969 } 1004 LIST_REMOVE(wds, wds_hash); 1005 ieee80211_unref_node(&wds->wds_ni); 1006 FREE(wds, M_80211_WDS); 970 1007 } 971 1008 } 972 1009 } 973 IEEE80211_NODE_ UNLOCK_IRQ(nt);1010 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 974 1011 } 975 1012 EXPORT_SYMBOL(ieee80211_del_wds_node); 976 1013 … … 981 1018 int hash; 982 1019 struct ieee80211_wds_addr *wds; 983 1020 984 IEEE80211_NODE_ LOCK_IRQ(nt);1021 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 985 1022 for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 986 1023 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 987 1024 if (wds->wds_agingcount != WDS_AGING_STATIC) { 988 1025 if (!wds->wds_agingcount) { 989 if (ieee80211_node_dectestref(wds->wds_ni)) { 990 _ieee80211_free_node(wds->wds_ni); 991 LIST_REMOVE(wds, wds_hash); 992 FREE(wds, M_80211_WDS); 993 } 1026 LIST_REMOVE(wds, wds_hash); 1027 ieee80211_unref_node(&wds->wds_ni); 1028 FREE(wds, M_80211_WDS); 994 1029 } else 995 1030 wds->wds_agingcount--; 996 1031 } 997 1032 } 998 1033 } 999 IEEE80211_NODE_ UNLOCK_IRQ(nt);1034 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1000 1035 mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 1001 1036 } 1002 1037 1003 1038 1004 1039 /* 1005 * Craft a temporary node suitable for sending a management frame1006 * to the specified station. We craft only as much state as we1007 * need to do the work since the node will be immediately reclaimed1008 * once the send completes.1009 */1010 struct ieee80211_node *1011 ieee80211_tmp_node(struct ieee80211vap *vap, const u_int8_t *macaddr)1012 {1013 struct ieee80211com *ic = vap->iv_ic;1014 struct ieee80211_node *ni;1015 1016 ni = ic->ic_node_alloc(&ic->ic_sta,vap);1017 if (ni != NULL) {1018 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,1019 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr),1020 ieee80211_node_refcnt(ni)+1);1021 1022 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);1023 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid);1024 ieee80211_node_initref(ni); /* mark referenced */1025 ni->ni_txpower = vap->iv_bss->ni_txpower;1026 ni->ni_vap = vap;1027 /* NB: required by ieee80211_fix_rate */1028 ieee80211_node_set_chan(ic, ni);1029 ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey,1030 IEEE80211_KEYIX_NONE);1031 /* XXX optimize away */1032 IEEE80211_NODE_SAVEQ_INIT(ni, "unknown");1033 1034 ni->ni_table = NULL; /* NB: pedantic */1035 ni->ni_ic = ic;1036 ni->ni_rxfrag = NULL;1037 ni->ni_challenge = NULL;1038 } else {1039 /* XXX msg */1040 vap->iv_stats.is_rx_nodealloc++;1041 }1042 return ni;1043 }1044 1045 /*1046 1040 * Add the specified station to the station table. 1047 1041 */ 1048 1042 struct ieee80211_node * 1049 ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr) 1043 ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr, 1044 unsigned char tmp) 1050 1045 { 1051 struct ieee80211com *ic = vap->iv_ic;1052 1046 struct ieee80211_node *ni; 1047 1048 // HACK 1049 if (tmp) 1050 ni = ieee80211_alloc_node(vap, macaddr); 1051 else 1052 ni = ieee80211_alloc_node_table(vap, macaddr); 1053 1053 1054 ni = ieee80211_alloc_node(&ic->ic_sta, vap, macaddr);1055 1054 if (ni != NULL) { 1056 /* 1057 * Inherit from iv_bss. 1058 */ 1059 ni->ni_authmode = vap->iv_bss->ni_authmode; 1060 ni->ni_txpower = vap->iv_bss->ni_txpower; 1061 ni->ni_vlan = vap->iv_bss->ni_vlan; /* XXX?? */ 1055 copy_bss(ni, vap->iv_bss); 1062 1056 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 1063 ieee80211_node_set_chan(ic, ni); 1064 ni->ni_rsn = vap->iv_bss->ni_rsn; 1065 ni->ni_rxfrag = NULL; 1057 /* Do this only for nodes that already have a BSS. Otherwise 1058 * ic_bsschan is not set and we get a KASSERT failure. 1059 * Required by ieee80211_fix_rate */ 1060 ieee80211_node_set_chan(vap->iv_ic, ni); 1066 1061 } 1067 1062 return ni; 1068 1063 } … … 1070 1065 static struct ieee80211_node * 1071 1066 _ieee80211_find_wds_node(struct ieee80211_node_table *nt, const u_int8_t *macaddr) 1072 1067 { 1073 struct ieee80211_node *ni;1074 1068 struct ieee80211_wds_addr *wds; 1075 1069 int hash; 1076 IEEE80211_NODE_ LOCK_ASSERT(nt);1070 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 1077 1071 1078 1072 hash = IEEE80211_NODE_HASH(macaddr); 1079 1073 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 1080 1074 if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 1081 ni = wds->wds_ni;1082 1075 if (wds->wds_agingcount != WDS_AGING_STATIC) 1083 1076 wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ 1084 ieee80211_ref_node(ni); 1085 return ni; 1077 return ieee80211_ref_node(wds->wds_ni); 1086 1078 } 1087 1079 } 1088 1080 return NULL; … … 1100 1092 int hash; 1101 1093 struct ieee80211_wds_addr *wds; 1102 1094 1103 IEEE80211_NODE_ LOCK_ASSERT(nt);1095 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 1104 1096 1105 1097 hash = IEEE80211_NODE_HASH(macaddr); 1106 1098 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) { … … 1121 1113 nodes. */ 1122 1114 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 1123 1115 if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 1124 ni = wds->wds_ni; 1125 ieee80211_ref_node(ni); 1126 return ni; 1116 return ieee80211_ref_node(wds->wds_ni); 1127 1117 } 1128 1118 } 1129 1119 return NULL; … … 1138 1128 { 1139 1129 struct ieee80211_node *ni; 1140 1130 1141 IEEE80211_NODE_ LOCK_IRQ(nt);1131 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1142 1132 ni = _ieee80211_find_wds_node(nt, macaddr); 1143 IEEE80211_NODE_ UNLOCK_IRQ(nt);1133 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1144 1134 return ni; 1145 1135 } 1146 1136 EXPORT_SYMBOL(ieee80211_find_wds_node); … … 1155 1145 { 1156 1146 struct ieee80211_node *ni; 1157 1147 1158 IEEE80211_NODE_ LOCK_IRQ(nt);1148 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1159 1149 ni = _ieee80211_find_node(nt, macaddr); 1160 IEEE80211_NODE_ UNLOCK_IRQ(nt);1150 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1161 1151 return ni; 1162 1152 } 1163 1153 #ifdef IEEE80211_DEBUG_REFCNT … … 1180 1170 { 1181 1171 struct ieee80211_node *ni; 1182 1172 1183 ni = ieee80211_dup_bss(vap, macaddr );1173 ni = ieee80211_dup_bss(vap, macaddr, 0); 1184 1174 if (ni != NULL) { 1185 1175 /* XXX no rate negotiation; just dup */ 1186 1176 ni->ni_rates = vap->iv_bss->ni_rates; … … 1203 1193 * driver has an opportunity to setup it's private state. 1204 1194 */ 1205 1195 struct ieee80211_node * 1206 ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh,1196 ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh, 1207 1197 const struct ieee80211_scanparams *sp) 1208 1198 { 1209 1199 struct ieee80211com *ic = vap->iv_ic; 1210 1200 struct ieee80211_node *ni; 1211 1201 1212 ni = ieee80211_dup_bss(vap, wh->i_addr2); /* XXX alloc_node? */ 1213 /* TODO: not really putting itself in a table */ 1202 ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 1214 1203 if (ni != NULL) { 1215 1204 ni->ni_esslen = sp->ssid[1]; 1216 1205 memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]); … … 1285 1274 /* XXX check ic_bss first in station mode */ 1286 1275 /* XXX 4-address frames? */ 1287 1276 nt = &ic->ic_sta; 1288 IEEE80211_NODE_ LOCK_IRQ(nt);1277 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1289 1278 if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/) 1290 1279 ni = _ieee80211_find_node(nt, wh->i_addr1); 1291 1280 else 1292 1281 ni = _ieee80211_find_node(nt, wh->i_addr2); 1293 IEEE80211_NODE_ UNLOCK_IRQ(nt);1282 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1294 1283 1295 1284 return ni; 1296 1285 #undef IS_PSPOLL … … 1327 1316 1328 1317 /* XXX can't hold lock across dup_bss due to recursive locking */ 1329 1318 nt = &vap->iv_ic->ic_sta; 1330 IEEE80211_NODE_ LOCK_IRQ(nt);1319 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1331 1320 ni = _ieee80211_find_node(nt, mac); 1332 IEEE80211_NODE_ UNLOCK_IRQ(nt);1321 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1333 1322 1334 1323 if (ni == NULL) { 1335 1324 if (vap->iv_opmode == IEEE80211_M_IBSS || … … 1356 1345 EXPORT_SYMBOL(ieee80211_find_txnode); 1357 1346 #endif 1358 1347 1359 /* Caller must lock the IEEE80211_NODE_LOCK 1360 * 1361 * Context: hwIRQ, softIRQ and process context 1348 /* Context: hwIRQ, softIRQ and process context 1362 1349 */ 1363 staticvoid1350 void 1364 1351 _ieee80211_free_node(struct ieee80211_node *ni) 1365 1352 { 1366 1353 struct ieee80211vap *vap = ni->ni_vap; … … 1374 1361 1375 1362 if (vap->iv_aid_bitmap != NULL) 1376 1363 IEEE80211_AID_CLR(vap, ni->ni_associd); 1377 if (nt != NULL) {1378 TAILQ_REMOVE(&nt->nt_node, ni, ni_list);1379 LIST_REMOVE(ni, ni_hash);1380 }1381 vap->iv_ic->ic_node_free(ni);1382 }1383 1364 1384 void 1385 #ifdef IEEE80211_DEBUG_REFCNT 1386 ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line) 1387 #else 1388 ieee80211_free_node(struct ieee80211_node *ni) 1389 #endif 1390 { 1391 struct ieee80211_node_table *nt = ni->ni_table; 1392 struct ieee80211com *ic = ni->ni_ic; 1393 1394 #ifdef IEEE80211_DEBUG_REFCNT 1395 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 1396 "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni, 1397 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni) - 1); 1398 #endif 1399 /* 1400 * XXX: may need to lock out the following race. we dectestref 1401 * and determine it's time to free the node. between the if() 1402 * and lock, we take an rx intr to receive a frame from this 1403 * node. the rx path (tasklet or intr) bumps this node's 1404 * refcnt and xmits a response frame. eventually that response 1405 * will get reaped, and the reaping code will attempt to use 1406 * the node. the code below will delete the node prior 1407 * to the reap and we could get a crash. 1408 * 1409 * as a stopgap before delving deeper, lock intrs to 1410 * prevent this case. 1411 */ 1412 IEEE80211_LOCK_IRQ(ic); 1413 if (ieee80211_node_dectestref(ni)) { 1414 /* 1415 * Beware; if the node is marked gone then it's already 1416 * been removed from the table and we cannot assume the 1417 * table still exists. Regardless, there's no need to lock 1418 * the table. 1419 */ 1420 if (ni->ni_table != NULL) { 1421 IEEE80211_NODE_LOCK(nt); 1422 _ieee80211_free_node(ni); 1423 IEEE80211_NODE_UNLOCK(nt); 1424 } else 1425 _ieee80211_free_node(ni); 1426 } 1427 IEEE80211_UNLOCK_IRQ(ic); 1428 } 1429 #ifdef IEEE80211_DEBUG_REFCNT 1430 EXPORT_SYMBOL(ieee80211_free_node_debug); 1431 #else 1432 EXPORT_SYMBOL(ieee80211_free_node); 1433 #endif 1434 1435 /* 1436 * Reclaim a node. If this is the last reference count then 1437 * do the normal free work. Otherwise remove it from the node 1438 * table and mark it gone by clearing the back-reference. 1439 */ 1440 static void 1441 node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni) 1442 { 1443 1444 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 1445 "%s: remove %p<%s> from %s table, refcnt %d\n", 1446 __func__, ni, ether_sprintf(ni->ni_macaddr), 1447 nt->nt_name, ieee80211_node_refcnt(ni)-1); 1448 if (!ieee80211_node_dectestref(ni)) { 1449 /* 1450 * Other references are present, just remove the 1451 * node from the table so it cannot be found. When 1452 * the references are dropped storage will be 1453 * reclaimed. This normally only happens for ic_bss. 1454 */ 1455 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 1456 LIST_REMOVE(ni, ni_hash); 1457 ni->ni_table = NULL; /* clear reference */ 1458 } else 1459 _ieee80211_free_node(ni); 1365 vap->iv_ic->ic_node_free(ni); 1460 1366 } 1367 EXPORT_SYMBOL(_ieee80211_free_node); 1461 1368 1462 1369 static void 1463 1370 ieee80211_node_table_reset(struct ieee80211_node_table *nt, … … 1465 1372 { 1466 1373 struct ieee80211_node *ni, *next; 1467 1374 1468 IEEE80211_NODE_ LOCK_IRQ(nt);1375 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1469 1376 TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { 1470 1377 if (match != NULL && ni->ni_vap != match) 1471 1378 continue; … … 1477 1384 if (vap->iv_aid_bitmap != NULL) 1478 1385 IEEE80211_AID_CLR(vap, ni->ni_associd); 1479 1386 } 1480 node_reclaim(nt,ni);1387 ieee80211_node_leave(ni); 1481 1388 } 1482 IEEE80211_NODE_ UNLOCK_IRQ(nt);1389 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1483 1390 } 1484 1391 1485 1392 static void 1486 1393 ieee80211_node_table_cleanup(struct ieee80211_node_table *nt) 1487 1394 { 1395 struct ieee80211com *ic = nt->nt_ic; 1488 1396 struct ieee80211_node *ni, *next; 1489 1397 1490 1398 TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { … … 1496 1404 if (vap->iv_aid_bitmap != NULL) 1497 1405 IEEE80211_AID_CLR(vap, ni->ni_associd); 1498 1406 } 1499 node_reclaim(nt,ni);1407 ic->ic_node_cleanup(ni); 1500 1408 } 1501 1409 del_timer(&nt->nt_wds_aging_timer); 1502 1410 IEEE80211_SCAN_LOCK_DESTROY(nt); 1503 IEEE80211_NODE_ LOCK_DESTROY(nt);1411 IEEE80211_NODE_TABLE_LOCK_DESTROY(nt); 1504 1412 } 1505 1413 1506 1414 /* … … 1528 1436 IEEE80211_SCAN_LOCK_IRQ(nt); 1529 1437 gen = ++nt->nt_scangen; 1530 1438 restart: 1531 IEEE80211_NODE_ LOCK_IRQ(nt);1439 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1532 1440 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 1533 1441 if (ni->ni_scangen == gen) /* previously handled */ 1534 1442 continue; 1443 /* Temporary entries should no longer be in the node table */ 1535 1444 /* 1536 1445 * Ignore entries for which have yet to receive an 1537 1446 * authentication frame. These are transient and 1538 1447 * will be reclaimed when the last reference to them 1539 1448 * goes away (when frame xmits complete). 1540 1449 */ 1541 if (ic->ic_opmode == IEEE80211_M_HOSTAP && 1542 (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 1543 continue; 1450 /* 1451 *if (ic->ic_opmode == IEEE80211_M_HOSTAP && 1452 * (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 1453 * continue; 1454 */ 1544 1455 ni->ni_scangen = gen; 1545 1456 /* 1546 1457 * Free fragment if not needed anymore … … 1592 1503 * ref for us as needed. 1593 1504 */ 1594 1505 ieee80211_ref_node(ni); 1595 IEEE80211_NODE_ UNLOCK_IRQ_EARLY(nt);1506 IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 1596 1507 ieee80211_send_nulldata(ni); 1597 1508 /* XXX stat? */ 1598 1509 goto restart; … … 1615 1526 */ 1616 1527 ni->ni_vap->iv_stats.is_node_timeout++; 1617 1528 ieee80211_ref_node(ni); 1618 IEEE80211_NODE_ UNLOCK_IRQ_EARLY(nt);1529 IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 1619 1530 if (ni->ni_associd != 0) { 1620 1531 IEEE80211_SEND_MGMT(ni, 1621 1532 IEEE80211_FC0_SUBTYPE_DEAUTH, 1622 1533 IEEE80211_REASON_AUTH_EXPIRE); 1623 1534 } 1624 1535 ieee80211_node_leave(ni); 1625 ieee80211_ free_node(ni);1536 ieee80211_unref_node(&ni); 1626 1537 goto restart; 1627 1538 } 1628 1539 } 1629 IEEE80211_NODE_ UNLOCK_IRQ(nt);1540 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1630 1541 1631 1542 IEEE80211_SCAN_UNLOCK_IRQ(nt); 1632 1543 } … … 1661 1572 1662 1573 IEEE80211_SCAN_LOCK_IRQ(nt); 1663 1574 gen = ++nt->nt_scangen; 1575 1664 1576 restart: 1665 IEEE80211_NODE_ LOCK(nt);1577 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1666 1578 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 1667 1579 if (dev != NULL && ni->ni_vap->iv_dev != dev) 1668 1580 continue; /* skip node not for this vap */ 1669 1581 if (ni->ni_scangen != gen) { 1670 1582 ni->ni_scangen = gen; 1671 1583 (void) ieee80211_ref_node(ni); 1672 IEEE80211_NODE_ UNLOCK(nt);1584 IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 1673 1585 (*f)(arg, ni); 1674 ieee80211_free_node(ni); 1586 1587 ieee80211_unref_node(&ni); 1675 1588 goto restart; 1676 1589 } 1677 1590 } 1678 IEEE80211_NODE_ UNLOCK(nt);1591 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1679 1592 1680 1593 IEEE80211_SCAN_UNLOCK_IRQ(nt); 1681 1594 } … … 1949 1862 "station with aid %d leaves (refcnt %u)", 1950 1863 IEEE80211_NODE_AID(ni), ieee80211_node_refcnt(ni)); 1951 1864 1865 /* From this point onwards we can no longer find the node, 1866 * so no more references are generated 1867 */ 1868 ieee80211_remove_wds_addr(nt, ni->ni_macaddr); 1869 ieee80211_del_wds_node(nt, ni); 1870 IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 1871 _node_table_leave(nt, ni); 1872 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 1873 1952 1874 /* 1953 1875 * If node wasn't previously associated all 1954 1876 * we need to do is reclaim the reference. 1877 * This also goes for nodes that are auth'ed but 1878 * not associated. 1955 1879 */ 1956 1880 /* XXX ibss mode bypasses 11g and notification */ 1957 1881 if (ni->ni_associd == 0) … … 1969 1893 IEEE80211_LOCK_IRQ(ic); 1970 1894 if (vap->iv_aid_bitmap != NULL) 1971 1895 IEEE80211_AID_CLR(vap, ni->ni_associd); 1896 1972 1897 ni->ni_associd = 0; 1973 1898 vap->iv_sta_assoc--; 1974 1899 ic->ic_sta_assoc--; 1900 1975 1901 #ifdef ATH_SUPERG_XR 1976 1902 if (ni->ni_vap->iv_flags & IEEE80211_F_XR) 1977 1903 ic->ic_xr_sta_assoc--; … … 1982 1908 if (IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) 1983 1909 ieee80211_node_leave_11g(ni); 1984 1910 IEEE80211_UNLOCK_IRQ(ic); 1911 1985 1912 /* 1986 1913 * Cleanup station state. In particular clear various 1987 1914 * state that might otherwise be reused if the node … … 1991 1918 ieee80211_sta_leave(ni); 1992 1919 done: 1993 1920 /* 1994 * Remove the node from any table it's recorded in and 1995 * drop the caller's reference. Removal from the table 1996 * is important to ensure the node is not reprocessed 1997 * for inactivity. 1998 */ 1999 if (nt != NULL) { 2000 IEEE80211_NODE_LOCK_IRQ(nt); 2001 node_reclaim(nt, ni); 2002 IEEE80211_NODE_UNLOCK_IRQ(nt); 2003 ieee80211_remove_wds_addr(nt,ni->ni_macaddr); 2004 ieee80211_del_wds_node(nt,ni); 2005 } else 2006 ieee80211_free_node(ni); 1921 * Run a cleanup and then drop the caller's reference 1922 */ 1923 ic->ic_node_cleanup(ni); 1924 ieee80211_unref_node(&ni); 2007 1925 } 2008 1926 EXPORT_SYMBOL(ieee80211_node_leave); 2009 1927 … … 2063 1981 void 2064 1982 ieee80211_node_reset(struct ieee80211_node *ni, struct ieee80211vap *vap) 2065 1983 { 2066 if (ni != NULL) { 2067 struct ieee80211_node_table *nt = ni->ni_table; 2068 if (!nt) 2069 nt = &vap->iv_ic->ic_sta; 2070 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 2071 ni->ni_prev_vap = ni->ni_vap; 2072 ni->ni_vap = vap; 2073 ni->ni_ic = vap->iv_ic; 2074 /* 2075 * if node not found in the node table 2076 * add it to the node table . 2077 */ 2078 if(nt && ieee80211_find_node(nt, ni->ni_macaddr) != ni) { 2079 int hash = IEEE80211_NODE_HASH(ni->ni_macaddr); 2080 IEEE80211_NODE_LOCK_IRQ(nt); 2081 TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 2082 LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 2083 ni->ni_table = nt; 2084 IEEE80211_NODE_UNLOCK_IRQ(nt); 2085 } 2086 } 1984 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 1985 ni->ni_prev_vap = ni->ni_vap; 1986 ni->ni_vap = vap; 1987 ni->ni_ic = vap->iv_ic; 2087 1988 } -
svn.madwifi.org-trunk-2115/net80211/ieee80211_node.h
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_node.h 20 83 2007-02-06 15:33:38Z mentor $32 * $Id: ieee80211_node.h 2093 2007-02-07 21:06:25Z mentor $ 33 33 */ 34 34 #ifndef _NET80211_IEEE80211_NODE_H_ 35 35 #define _NET80211_IEEE80211_NODE_H_ … … 52 52 * authorized. The latter timeout is shorter to more aggressively 53 53 * reclaim nodes that leave part way through the 802.1x exchange. 54 54 */ 55 #define IEEE80211_INACT_WAIT 15 /* inactivity interval (secs) */55 #define IEEE80211_INACT_WAIT 15 /* inactivity interval (secs) */ 56 56 #define IEEE80211_INACT_INIT (30/IEEE80211_INACT_WAIT) /* initial */ 57 57 #define IEEE80211_INACT_AUTH (180/IEEE80211_INACT_WAIT) /* associated but not authorized */ 58 58 #define IEEE80211_INACT_RUN (300/IEEE80211_INACT_WAIT) /* authorized */ 59 59 #define IEEE80211_INACT_PROBE (30/IEEE80211_INACT_WAIT) /* probe */ 60 60 #define IEEE80211_INACT_SCAN (300/IEEE80211_INACT_WAIT) /* scanned */ 61 61 62 #define IEEE80211_TRANS_WAIT 5 /* mgt frame tx timer (secs) */62 #define IEEE80211_TRANS_WAIT 5 /* mgt frame tx timer (secs) */ 63 63 64 64 #define IEEE80211_NODE_HASHSIZE 32 65 65 /* simple hash is enough for variation of macaddr */ … … 94 94 struct ieee80211_node_table *ni_table; 95 95 TAILQ_ENTRY(ieee80211_node) ni_list; 96 96 LIST_ENTRY(ieee80211_node) ni_hash; 97 atomic_t ni_refcnt; 97 // ieee80211_node_lock_t ni_nodelock; /* on node - notably for ref counting */ 98 ieee80211_node_ref_count_t ni_refcnt; 98 99 u_int ni_scangen; /* gen# for timeout scan */ 99 100 u_int8_t ni_authmode; /* authentication algorithm */ 100 101 u_int16_t ni_flags; /* special-purpose state */ … … 121 122 u_int16_t ni_associd; /* assoc response */ 122 123 u_int16_t ni_txpower; /* current transmit power (in 0.5 dBm) */ 123 124 u_int16_t ni_vlan; /* vlan tag */ 124 u_int32_t *ni_challenge; /* shared-key challenge */125 u_int32_t *ni_challenge; /* shared-key challenge */ 125 126 u_int8_t *ni_wpa_ie; /* captured WPA ie */ 126 127 u_int8_t *ni_rsn_ie; /* captured RSN ie */ 127 128 u_int8_t *ni_wme_ie; /* captured WME ie */ 128 129 u_int8_t *ni_ath_ie; /* captured Atheros ie */ 129 u_int16_t ni_txseqs[17]; /* tx seq per-tid */130 u_int16_t ni_rxseqs[17]; /* rx seq previous per-tid*/130 u_int16_t ni_txseqs[17]; /* tx seq per-tid */ 131 u_int16_t ni_rxseqs[17]; /* rx seq previous per-tid*/ 131 132 u_int32_t ni_rxfragstamp; /* time stamp of last rx frag */ 132 133 struct sk_buff *ni_rxfrag; /* rx frag reassembly */ 133 134 struct ieee80211_rsnparms ni_rsn; /* RSN/WPA parameters */ … … 156 157 struct ieee80211_channel *ni_chan; 157 158 u_int16_t ni_fhdwell; /* FH only */ 158 159 u_int8_t ni_fhindex; /* FH only */ 159 u_int8_t ni_erp; /* ERP from beacon/probe resp */160 u_int8_t ni_erp; /* ERP from beacon/probe resp */ 160 161 u_int16_t ni_timoff; /* byte offset to TIM ie */ 161 162 162 163 /* others */ … … 168 169 struct ieee80211vap *ni_prev_vap; /* previously associated vap */ 169 170 u_int8_t ni_uapsd; /* U-APSD per-node flags matching WMM STA Qos Info field */ 170 171 u_int8_t ni_uapsd_maxsp; /* maxsp from flags above */ 171 u_int16_t ni_uapsd_trigseq[WME_NUM_AC]; /* trigger suppression on retry */172 u_int16_t ni_uapsd_trigseq[WME_NUM_AC]; /* trigger suppression on retry */ 172 173 __le16 ni_pschangeseq; 173 174 }; 174 175 MALLOC_DECLARE(M_80211_NODE); … … 186 187 #define WME_UAPSD_NODE_INVALIDSEQ 0xffff 187 188 #define WME_UAPSD_NODE_TRIGSEQINIT(_ni) (memset(&(_ni)->ni_uapsd_trigseq[0], 0xff, sizeof((_ni)->ni_uapsd_trigseq))) 188 189 189 static __inline struct ieee80211_node *190 ieee80211_ref_node(struct ieee80211_node *ni)191 {192 ieee80211_node_incref(ni);193 return ni;194 }195 196 static __inline void197 ieee80211_unref_node(struct ieee80211_node **ni)198 {199 ieee80211_node_decref(*ni);200 *ni = NULL; /* guard against use */201 }202 203 190 void ieee80211_node_attach(struct ieee80211com *); 204 191 void ieee80211_node_detach(struct ieee80211com *); 205 192 void ieee80211_node_vattach(struct ieee80211vap *); … … 242 229 * is a second table for associated stations or neighbors. 243 230 */ 244 231 struct ieee80211_node_table { 232 const char *nt_name; /* for debugging */ 245 233 struct ieee80211com *nt_ic; /* back reference */ 246 ieee80211_node_ lock_t nt_nodelock; /* on node table */234 ieee80211_node_table_lock_t nt_nodelock; /* on node table */ 247 235 TAILQ_HEAD(, ieee80211_node) nt_node; /* information of all nodes */ 248 236 ATH_LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE]; 249 237 ATH_LIST_HEAD(, ieee80211_wds_addr) nt_wds_hash[IEEE80211_NODE_HASHSIZE]; 250 const char *nt_name; /* for debugging */251 238 ieee80211_scan_lock_t nt_scanlock; /* on nt_scangen */ 252 239 u_int nt_scangen; /* gen# for timeout scan */ 253 240 int nt_inact_init; /* initial node inact setting */ 254 241 struct timer_list nt_wds_aging_timer; /* timer to age out wds entries */ 255 242 }; 256 243 257 struct ieee80211_node *ieee80211_alloc_node(struct ieee80211_node_table *, 258 struct ieee80211vap *, const u_int8_t *); 259 struct ieee80211_node *ieee80211_tmp_node(struct ieee80211vap *, 260 const u_int8_t *); 261 struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *, 244 struct ieee80211_node *ieee80211_alloc_node_table(struct ieee80211vap *, 262 245 const u_int8_t *); 246 struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *, 247 const u_int8_t *, unsigned char); 263 248 void ieee80211_node_reset(struct ieee80211_node *, struct ieee80211vap *); 264 249 #ifdef IEEE80211_DEBUG_REFCNT 265 void ieee80211_free_node_debug(struct ieee80211_node *, const char *, int);266 250 struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *, 267 251 const u_int8_t *, const char *, int); 268 252 struct ieee80211_node *ieee80211_find_rxnode_debug(struct ieee80211com *, 269 253 const struct ieee80211_frame_min *, const char *, int); 270 254 struct ieee80211_node *ieee80211_find_txnode_debug(struct ieee80211vap *, 271 255 const u_int8_t *, const char *, int); 272 #define ieee80211_ free_node(ni) \273 ieee80211_ free_node_debug(ni, __func__, __LINE__)274 #define ieee80211_find_node( nt,mac) \275 ieee80211_find_node_debug( nt,mac, __func__, __LINE__)276 #define ieee80211_find_rxnode( nt,wh) \277 ieee80211_find_rxnode_debug( nt,wh, __func__, __LINE__)278 #define ieee80211_find_txnode( nt,mac) \279 ieee80211_find_txnode_debug( nt,mac, __func__, __LINE__)256 #define ieee80211_unref_node(_ni) \ 257 ieee80211_unref_node_debug(_ni, __func__, __LINE__) 258 #define ieee80211_find_node(_nt, _mac) \ 259 ieee80211_find_node_debug(_nt, _mac, __func__, __LINE__) 260 #define ieee80211_find_rxnode(_nt, _wh) \ 261 ieee80211_find_rxnode_debug(_nt, _wh, __func__, __LINE__) 262 #define ieee80211_find_txnode(_nt, _mac) \ 263 ieee80211_find_txnode_debug(_nt, _mac, __func__, __LINE__) 280 264 #else 281 void ieee80211_free_node(struct ieee80211_node *);282 265 283 266 struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *, 284 267 const u_int8_t *); … … 287 270 struct ieee80211_node *ieee80211_find_txnode(struct ieee80211vap *, 288 271 const u_int8_t *); 289 272 #endif 273 274 void _ieee80211_free_node(struct ieee80211_node *); 275 276 static __inline struct ieee80211_node * 277 ieee80211_ref_node(struct ieee80211_node *ni) 278 { 279 ieee80211_node_incref(ni); 280 return ni; 281 } 282 283 static __inline struct ieee80211_node * 284 _ieee80211_pass_node(struct ieee80211_node **pni) { 285 struct ieee80211_node *tmp = *pni; 286 *pni = NULL; 287 return (tmp); 288 } 289 290 #define PASS_NODE(_ni) \ 291 _ieee80211_pass_node(&_ni) 292 293 static __inline int 294 _ieee80211_unref_node(struct ieee80211_node *ni) { 295 if (ieee80211_node_dectestref(ni)) { 296 _ieee80211_free_node(ni); 297 return 1; 298 } else { 299 return 0; 300 } 301 } 302 303 static __inline void 304 #ifdef IEEE80211_DEBUG_REFCNT 305 ieee80211_unref_node_debug(struct ieee80211_node **pni, const char *func, int line) 306 #else 307 ieee80211_unref_node(struct ieee80211_node **pni) 308 #endif 309 { 310 struct ieee80211_node *ni = *pni; 311 #ifdef IEEE80211_DEBUG_REFCNT 312 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 313 "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni, 314 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni) - 1); 315 #endif 316 _ieee80211_unref_node(ni); 317 *pni = NULL; /* guard against use */ 318 } 319 290 320 int ieee80211_add_wds_addr(struct ieee80211_node_table *, struct ieee80211_node *, 291 321 const u_int8_t *, u_int8_t); 292 322 void ieee80211_remove_wds_addr(struct ieee80211_node_table *, const u_int8_t *); -
svn.madwifi.org-trunk-2115/net80211/ieee80211_output.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_output.c 20 76 2007-02-06 12:53:09Z kelmo$32 * $Id: ieee80211_output.c 2093 2007-02-07 21:06:25Z mentor $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB … … 254 254 goto bad; 255 255 } 256 256 257 cb->ni = ni;257 cb->ni = ieee80211_ref_node(ni); 258 258 259 259 /* power-save checks */ 260 260 if (WME_UAPSD_AC_CAN_TRIGGER(skb->priority, ni)) { … … 293 293 } 294 294 #endif 295 295 ieee80211_parent_queue_xmit(skb); 296 ieee80211_unref_node(&ni); 296 297 return 0; 297 298 298 299 bad: 299 300 if (skb != NULL) 300 301 dev_kfree_skb(skb); 301 302 if (ni != NULL) 302 ieee80211_ free_node(ni);303 ieee80211_unref_node(&ni); 303 304 return 0; 304 305 } 305 306 … … 453 454 if (skb == NULL) { 454 455 /* XXX debug msg */ 455 456 vap->iv_stats.is_tx_nobuf++; 456 ieee80211_ free_node(ni);457 ieee80211_unref_node(&ni); 457 458 return -ENOMEM; 458 459 } 459 460 cb = (struct ieee80211_cb *)skb->cb; … … 507 508 u_int8_t *frm; 508 509 int tid; 509 510 510 ieee80211_ref_node(ni);511 511 skb = ieee80211_getmgtframe(&frm, 2); 512 512 if (skb == NULL) { 513 513 /* XXX debug msg */ 514 514 vap->iv_stats.is_tx_nobuf++; 515 ieee80211_free_node(ni);516 515 return -ENOMEM; 517 516 } 518 517 cb = (struct ieee80211_cb *)skb->cb; 519 cb->ni = ni;518 cb->ni = ieee80211_ref_node(ni); 520 519 521 520 skb->priority = ac; 522 521 qwh = (struct ieee80211_qosframe *)skb_push(skb, sizeof(struct ieee80211_qosframe)); … … 865 864 nt = &ic->ic_sta; 866 865 ni_wds = ieee80211_find_wds_node(nt, eh.ether_shost); 867 866 if (ni_wds) 868 ieee80211_ free_node(ni_wds); /* Decr ref count */867 ieee80211_unref_node(&ni_wds); /* Decr ref count */ 869 868 else 870 869 ieee80211_add_wds_addr(nt, ni, eh.ether_shost, 0); 871 870 } … … 1719 1718 __func__, __LINE__, 1720 1719 ni, ether_sprintf(ni->ni_macaddr), 1721 1720 ieee80211_node_refcnt(ni) + 1); 1722 ieee80211_ref_node(ni);1723 1721 1724 1722 /* 1725 1723 * prreq frame format … … 1735 1733 vap->app_ie[IEEE80211_APPIE_FRAME_PROBE_REQ].length); 1736 1734 if (skb == NULL) { 1737 1735 vap->iv_stats.is_tx_nobuf++; 1738 ieee80211_free_node(ni);1739 1736 return -ENOMEM; 1740 1737 } 1741 1738 … … 1758 1755 skb_trim(skb, frm - skb->data); 1759 1756 1760 1757 cb = (struct ieee80211_cb *)skb->cb; 1761 cb->ni = ni;1758 cb->ni = ieee80211_ref_node(ni); 1762 1759 1763 1760 wh = (struct ieee80211_frame *) 1764 1761 skb_push(skb, sizeof(struct ieee80211_frame)); … … 2233 2230 mod_timer(&vap->iv_mgtsend, jiffies + timer * HZ); 2234 2231 return 0; 2235 2232 bad: 2236 ieee80211_ free_node(ni);2233 ieee80211_unref_node(&ni); 2237 2234 return ret; 2238 2235 #undef senderr 2239 2236 } -
svn.madwifi.org-trunk-2115/net80211/ieee80211_power.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_power.c 1721 2006-09-20 08:45:13Z mentor $32 * $Id: ieee80211_power.c 2064 2007-02-01 20:49:37Z mentor $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB … … 109 109 int 110 110 ieee80211_node_saveq_drain(struct ieee80211_node *ni) 111 111 { 112 struct ieee80211_cb *cb = NULL; 112 113 struct sk_buff *skb; 113 114 int qlen; 114 115 115 116 IEEE80211_NODE_SAVEQ_LOCK(ni); 116 117 qlen = skb_queue_len(&ni->ni_savedq); 117 118 while ((skb = __skb_dequeue(&ni->ni_savedq)) != NULL) { 118 ieee80211_free_node(ni); 119 cb = (struct ieee80211_cb *) skb->cb; 120 ieee80211_unref_node(&cb->ni); 119 121 dev_kfree_skb_any(skb); 120 122 } 121 123 IEEE80211_NODE_SAVEQ_UNLOCK(ni); -
svn.madwifi.org-trunk-2115/net80211/ieee80211_proto.c
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_proto.c 1849 2006-12-08 17:20:08Z proski$32 * $Id: ieee80211_proto.c 2064 2007-02-01 20:49:37Z mentor $ 33 33 */ 34 34 #ifndef EXPORT_SYMTAB 35 35 #define EXPORT_SYMTAB … … 1456 1456 */ 1457 1457 if (vap->iv_opmode == IEEE80211_M_WDS) { 1458 1458 struct ieee80211_node *wds_ni; 1459 wds_ni = ieee80211_alloc_node (&ic->ic_sta,vap, vap->wds_mac);1459 wds_ni = ieee80211_alloc_node_table(vap, vap->wds_mac); 1460 1460 if (wds_ni != NULL) { 1461 1461 if (ieee80211_add_wds_addr(&ic->ic_sta, wds_ni, vap->wds_mac, 1) == 0) { 1462 1462 ieee80211_node_authorize(wds_ni); -
svn.madwifi.org-trunk-2115/net80211/ieee80211_scan_sta.c
old new 28 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 30 * 31 * $Id: ieee80211_scan_sta.c 1721 2006-09-20 08:45:13Z mentor $31 * $Id: ieee80211_scan_sta.c 2064 2007-02-01 20:49:37Z mentor $ 32 32 */ 33 33 #ifndef EXPORT_SYMTAB 34 34 #define EXPORT_SYMTAB … … 762 762 if (se->se_rssi < STA_RSSI_MIN) 763 763 fail |= 0x100; 764 764 #ifdef IEEE80211_DEBUG 765 if (ieee80211_msg (vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM)) {765 if (ieee80211_msg_is_reported(vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM)) { 766 766 printf(" %03x", fail); 767 767 printf(" %c %s", 768 768 fail & 0x40 ? '=' : fail & 0x80 ? '^' : fail ? '-' : '+', -
svn.madwifi.org-trunk-2115/net80211/ieee80211_var.h
old new 29 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 * 32 * $Id: ieee80211_var.h 1988 2007-01-22 03:07:30Z proski$32 * $Id: ieee80211_var.h 2092 2007-02-07 20:45:27Z mentor $ 33 33 */ 34 34 #ifndef _NET80211_IEEE80211_VAR_H_ 35 35 #define _NET80211_IEEE80211_VAR_H_ … … 37 37 /* 38 38 * Definitions for IEEE 802.11 drivers. 39 39 */ 40 #define IEEE80211_DEBUG 41 #undef IEEE80211_DEBUG_REFCNT /* node refcnt stuff */ 40 #include <net80211/ieee80211_debug.h> 42 41 43 42 #include <net80211/ieee80211_linux.h> 44 43 … … 230 229 /* new station association callback/notification */ 231 230 void (*ic_newassoc)(struct ieee80211_node *, int); 232 231 /* node state management */ 233 struct ieee80211_node *(*ic_node_alloc)(struct ieee80211_node_table *, 234 struct ieee80211vap *); 232 struct ieee80211_node *(*ic_node_alloc)(struct ieee80211vap *); 235 233 void (*ic_node_free)(struct ieee80211_node *); 236 234 void (*ic_node_cleanup)(struct ieee80211_node *); 237 235 u_int8_t (*ic_node_getrssi)(const struct ieee80211_node *); … … 406 404 u_int32_t app_filter; /* filters which management frames are forwarded to app */ 407 405 408 406 }; 407 409 408 MALLOC_DECLARE(M_80211_VAP); 410 409 411 410 #define IEEE80211_ADDR_NULL(a1) (memcmp(a1, "\x00\x00\x00\x00\x00\x00", \ … … 613 612 size = roundup(size, sizeof(u_int32_t)); 614 613 return size; 615 614 } 616 617 #define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */618 #define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalent */619 #define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */620 #define IEEE80211_MSG_INPUT 0x08000000 /* input handling */621 #define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */622 #define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */623 #define IEEE80211_MSG_NODE 0x01000000 /* node handling */624 #define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */625 #define IEEE80211_MSG_AUTH 0x00400000 /* authentication handling */626 #define IEEE80211_MSG_SCAN 0x00200000 /* scanning */627 #define IEEE80211_MSG_OUTPUT 0x00100000 /* output handling */628 #define IEEE80211_MSG_STATE 0x00080000 /* state machine */629 #define IEEE80211_MSG_POWER 0x00040000 /* power save handling */630 #define IEEE80211_MSG_DOT1X 0x00020000 /* 802.1x authenticator */631 #define IEEE80211_MSG_DOT1XSM 0x00010000 /* 802.1x state machine */632 #define IEEE80211_MSG_RADIUS 0x00008000 /* 802.1x radius client */633 #define IEEE80211_MSG_RADDUMP 0x00004000 /* dump 802.1x radius packets */634 #define IEEE80211_MSG_RADKEYS 0x00002000 /* dump 802.1x keys */635 #define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */636 #define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */637 #define IEEE80211_MSG_WME 0x00000400 /* WME protocol */638 #define IEEE80211_MSG_SUPG 0x00000200 /* SUPERG */639 #define IEEE80211_MSG_DOTH 0x00000100 /* 11.h */640 #define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */641 #define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */642 643 #define IEEE80211_MSG_ANY 0xffffffff /* anything */644 645 #ifdef IEEE80211_DEBUG646 #define ieee80211_msg(_vap, _m) ((_vap)->iv_debug & (_m))647 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) do { \648 if (ieee80211_msg(_vap, _m)) \649 ieee80211_note(_vap, _fmt, __VA_ARGS__); \650 } while (0)651 #define IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) do { \652 if (ieee80211_msg(_vap, _m)) \653 ieee80211_note_mac(_vap, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\654 } while (0)655 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) do { \656 if (ieee80211_msg(_vap, _m)) \657 ieee80211_note_mac(_vap, _mac, _fmt, __VA_ARGS__); \658 } while (0)659 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) do { \660 if (ieee80211_msg(_vap, _m)) \661 ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__); \662 } while (0)663 void ieee80211_note(struct ieee80211vap *, const char *, ...);664 void ieee80211_note_mac(struct ieee80211vap *,665 const u_int8_t mac[IEEE80211_ADDR_LEN], const char *, ...);666 void ieee80211_note_frame(struct ieee80211vap *,667 const struct ieee80211_frame *, const char *, ...);668 #define ieee80211_msg_debug(_vap) \669 ieee80211_msg(_vap, IEEE80211_MSG_DEBUG)670 #define ieee80211_msg_dumppkts(_vap) \671 ieee80211_msg(_vap, IEEE80211_MSG_DUMPPKTS)672 #define ieee80211_msg_input(_vap) \673 ieee80211_msg(_vap, IEEE80211_MSG_INPUT)674 #define ieee80211_msg_radius(_vap) \675 ieee80211_msg(_vap, IEEE80211_MSG_RADIUS)676 #define ieee80211_msg_dumpradius(_vap) \677 ieee80211_msg(_vap, IEEE80211_MSG_RADDUMP)678 #define ieee80211_msg_dumpradkeys(_vap) \679 ieee80211_msg(_vap, IEEE80211_MSG_RADKEYS)680 #define ieee80211_msg_scan(_vap) \681 ieee80211_msg(_vap, IEEE80211_MSG_SCAN)682 #define ieee80211_msg_assoc(_vap) \683 ieee80211_msg(_vap, IEEE80211_MSG_ASSOC)684 #else /* IEEE80211_DEBUG */685 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...)686 #define IEEE80211_NOTE(_vap, _m, _wh, _fmt, ...)687 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...)688 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...)689 #endif /* IEEE80211_DEBUG */690 691 615 #endif /* _NET80211_IEEE80211_VAR_H_ */ -
svn.madwifi.org-trunk-2115/net80211/ieee80211_wireless.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: ieee80211_wireless.c 2 103 2007-02-12 05:25:25Z proski$36 * $Id: ieee80211_wireless.c 2098 2007-02-09 00:04:06Z mentor $ 37 37 */ 38 38 39 39 /* … … 3181 3181 error = -ENXIO; 3182 3182 ieee80211_key_update_end(vap); 3183 3183 if (ni != NULL) 3184 ieee80211_ free_node(ni);3184 ieee80211_unref_node(&ni); 3185 3185 #ifdef ATH_SUPERG_XR 3186 3186 /* set the same params on the xr vap device if exists */ 3187 3187 if (vap->iv_xrvap && !(vap->iv_flags & IEEE80211_F_XR)) … … 3241 3241 memset(ik.ik_keydata, 0, sizeof(ik.ik_keydata)); 3242 3242 } 3243 3243 if (ni != NULL) 3244 ieee80211_ free_node(ni);3244 ieee80211_unref_node(&ni); 3245 3245 return (copy_to_user(iwr->u.data.pointer, &ik, sizeof(ik)) ? -EFAULT : 0); 3246 3246 } 3247 3247 … … 3264 3264 return -EINVAL; /* XXX */ 3265 3265 /* XXX error return */ 3266 3266 ieee80211_crypto_delkey(vap, &ni->ni_ucastkey, ni); 3267 ieee80211_ free_node(ni);3267 ieee80211_unref_node(&ni); 3268 3268 } else { 3269 3269 if (kid >= IEEE80211_WEP_NKID) 3270 3270 return -EINVAL; … … 3367 3367 return -EINVAL; 3368 3368 if (dev == ni->ni_vap->iv_dev) 3369 3369 domlme(mlme, ni); 3370 ieee80211_ free_node(ni);3370 ieee80211_unref_node(&ni); 3371 3371 } else 3372 3372 ieee80211_iterate_dev_nodes(dev, &ic->ic_sta, domlme, mlme); 3373 3373 break; … … 3386 3386 ieee80211_node_authorize(ni); 3387 3387 else 3388 3388 ieee80211_node_unauthorize(ni); 3389 ieee80211_ free_node(ni);3389 ieee80211_unref_node(&ni); 3390 3390 break; 3391 3391 case IEEE80211_MLME_CLEAR_STATS: 3392 3392 if (vap->iv_opmode != IEEE80211_M_HOSTAP) … … 3397 3397 3398 3398 /* clear statistics */ 3399 3399 memset(&ni->ni_stats, 0, sizeof(struct ieee80211_nodestats)); 3400 ieee80211_ free_node(ni);3400 ieee80211_unref_node(&ni); 3401 3401 break; 3402 3402 default: 3403 3403 return -EINVAL; … … 3767 3767 ielen = sizeof(wpaie.rsn_ie); 3768 3768 memcpy(wpaie.rsn_ie, ni->ni_rsn_ie, ielen); 3769 3769 } 3770 ieee80211_ free_node(ni);3770 ieee80211_unref_node(&ni); 3771 3771 return (copy_to_user(iwr->u.data.pointer, &wpaie, sizeof(wpaie)) ? 3772 3772 -EFAULT : 0); 3773 3773 } … … 3794 3794 /* NB: copy out only the statistics */ 3795 3795 error = copy_to_user(iwr->u.data.pointer + off, &ni->ni_stats, 3796 3796 iwr->u.data.length - off); 3797 ieee80211_ free_node(ni);3797 ieee80211_unref_node(&ni); 3798 3798 return (error ? -EFAULT : 0); 3799 3799 } 3800 3800 -
svn.madwifi.org-trunk-2115/tools/80211stats.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: 80211stats.c 20 88 2007-02-07 03:18:49Z proski$36 * $Id: 80211stats.c 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 39 39 /* -
svn.madwifi.org-trunk-2115/tools/athchans.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: athchans.c 20 88 2007-02-07 03:18:49Z proski$36 * $Id: athchans.c 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 39 39 /* -
svn.madwifi.org-trunk-2115/tools/athkey.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: athkey.c 20 88 2007-02-07 03:18:49Z proski$36 * $Id: athkey.c 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 39 39 /* -
svn.madwifi.org-trunk-2115/tools/wlanconfig.c
old new 33 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 35 * 36 * $Id: wlanconfig.c 20 88 2007-02-07 03:18:49Z proski$36 * $Id: wlanconfig.c 2093 2007-02-07 21:06:25Z mentor $ 37 37 */ 38 38 39 39 /*
