Ticket #907: madwifi-refcnt.9.diff

File madwifi-refcnt.9.diff, 78.0 kB (added by mentor, 5 years ago)
  • net80211/ieee80211_node.c

    old new  
    6565#define IEEE80211_AID_ISSET(_vap, _b) \ 
    6666        ((_vap)->iv_aid_bitmap[IEEE80211_AID(_b) / 32] & (1 << (IEEE80211_AID(_b) % 32))) 
    6767 
     68static struct ieee80211_node *ieee80211_alloc_node(struct ieee80211vap *, const u_int8_t *); 
     69 
    6870static int ieee80211_sta_join1(struct ieee80211_node *); 
    6971 
    70 static struct ieee80211_node *node_alloc(struct ieee80211_node_table *, 
    71         struct ieee80211vap *); 
     72static struct ieee80211_node *node_alloc(struct ieee80211vap *); 
    7273static void node_cleanup(struct ieee80211_node *); 
    7374static void node_free(struct ieee80211_node *); 
    7475static u_int8_t node_getrssi(const struct ieee80211_node *); 
    7576 
    76 static void _ieee80211_free_node(struct ieee80211_node *); 
    77 static void node_reclaim(struct ieee80211_node_table *, struct ieee80211_node*); 
     77static void _node_table_leave(struct ieee80211_node_table *, struct ieee80211_node *); 
     78static void _node_table_join(struct ieee80211_node_table *, struct ieee80211_node *); 
    7879 
    7980static void ieee80211_node_timeout(unsigned long); 
    8081 
     
    194195 
    195196        ieee80211_node_table_reset(&ic->ic_sta, vap); 
    196197        if (vap->iv_bss != NULL) { 
    197                 ieee80211_free_node(vap->iv_bss); 
    198                 vap->iv_bss = NULL; 
     198                ieee80211_unref_node(&vap->iv_bss); 
    199199        } 
    200200        if (vap->iv_aid_bitmap != NULL) { 
    201201                FREE(vap->iv_aid_bitmap, M_DEVBUF); 
     
    263263                "%s: creating ibss on channel %u\n", __func__, 
    264264                ieee80211_chan2ieee(ic, chan)); 
    265265 
    266         /* Check to see if we already have a node for this mac */ 
     266        /* Check to see if we already have a node for this mac  
     267         * NB: we gain a node reference here 
     268         */ 
    267269        ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr); 
    268270        if (ni == NULL) { 
    269                 ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); 
     271                ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 
    270272                if (ni == NULL) { 
    271273                        /* XXX recovery? */ 
    272274                        return; 
    273275                } 
    274276        } 
    275         else 
    276                 ieee80211_free_node(ni); 
    277277 
    278278        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: %p<%s> refcnt %d\n", 
    279279                __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), 
     
    345345        else if (IEEE80211_IS_CHAN_QUARTER(chan)) 
    346346                ni->ni_rates = ic->ic_sup_quarter_rates; 
    347347 
    348         (void) ieee80211_sta_join1(ieee80211_ref_node(ni)); 
     348        (void) ieee80211_sta_join1(PASS_NODE(ni)); 
    349349} 
    350350EXPORT_SYMBOL(ieee80211_create_ibss); 
    351351 
     
    369369        /* XXX multi-bss wrong */ 
    370370        ieee80211_reset_erp(ic, ic->ic_curmode); 
    371371 
    372         ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); 
     372        ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 
    373373        KASSERT(ni != NULL, ("unable to setup inital BSS node")); 
    374374        obss = vap->iv_bss; 
     375        // Caller's reference 
    375376        vap->iv_bss = ieee80211_ref_node(ni); 
    376377 
    377378        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: new bss %p<%s> refcnt %d\n", 
     
    381382        if (obss != NULL) { 
    382383                copy_bss(ni, obss); 
    383384                ni->ni_intval = ic->ic_lintval; 
    384                 ieee80211_free_node(obss); 
     385                // Caller's reference 
     386                ieee80211_unref_node(&obss); 
    385387        } 
    386388} 
    387389 
     
    587589                vap->iv_state == IEEE80211_S_RUN && ssid_equal(obss, selbs)); 
    588590        vap->iv_bss = selbs; 
    589591        if (obss != NULL) 
    590                 ieee80211_free_node(obss); 
     592                ieee80211_unref_node(&obss); 
    591593        ic->ic_bsschan = selbs->ni_chan; 
    592594        ic->ic_curchan = ic->ic_bsschan; 
    593595        ic->ic_curmode = ieee80211_chan2mode(ic->ic_curchan); 
     
    644646 
    645647        ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr); 
    646648        if (ni == NULL) { 
    647                 ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr); 
     649                ni = ieee80211_alloc_node_table(vap, se->se_macaddr); 
    648650                if (ni == NULL) { 
    649651                        /* XXX msg */ 
    650652                        return 0; 
    651653                } 
    652         } else 
    653                 ieee80211_free_node(ni); 
     654        } 
    654655 
    655656        /* 
    656657         * Expand scan state into node's format. 
    657658         * XXX may not need all this stuff 
    658659         */ 
    659         ni->ni_authmode = vap->iv_bss->ni_authmode;            /* inherit authmode from iv_bss */ 
     660        ni->ni_authmode = vap->iv_bss->ni_authmode;     /* inherit authmode from iv_bss */ 
    660661        /* inherit the WPA setup as well (structure copy!) */ 
    661662        ni->ni_rsn = vap->iv_bss->ni_rsn;  
    662663        IEEE80211_ADDR_COPY(ni->ni_bssid, se->se_bssid); 
     
    690691 
    691692        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    692693        "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    693         ieee80211_node_refcnt(ni)+1); 
     694        ieee80211_node_refcnt(ni)); 
    694695 
    695         return ieee80211_sta_join1(ieee80211_ref_node(ni)); 
     696        return ieee80211_sta_join1(PASS_NODE(ni)); 
    696697} 
    697698EXPORT_SYMBOL(ieee80211_sta_join); 
    698699 
     
    704705ieee80211_sta_leave(struct ieee80211_node *ni) 
    705706{ 
    706707        struct ieee80211vap *vap = ni->ni_vap; 
    707         struct ieee80211com *ic = vap->iv_ic; 
    708708 
    709709        /* WDS/Repeater: Stop software beacon timer for STA */ 
    710710        if (vap->iv_opmode == IEEE80211_M_STA && 
    711711            vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) { 
    712712                del_timer(&vap->iv_swbmiss); 
    713713        } 
    714  
    715         ic->ic_node_cleanup(ni); 
     714         
    716715        ieee80211_notify_node_leave(ni); 
    717716} 
    718717 
     
    721720 */ 
    722721 
    723722static void 
    724 ieee80211_node_table_init(struct ieee80211com *ic, 
    725         struct ieee80211_node_table *nt,      const char *name, int inact) 
     723ieee80211_node_table_init(struct ieee80211com *ic, struct ieee80211_node_table *nt, 
     724              const char *name, int inact) 
    726725{ 
    727726        nt->nt_ic = ic; 
    728         IEEE80211_NODE_LOCK_INIT(nt, ic->ic_dev->name); 
     727        IEEE80211_NODE_TABLE_LOCK_INIT(nt, ic->ic_dev->name); 
    729728        IEEE80211_SCAN_LOCK_INIT(nt, ic->ic_dev->name); 
    730729        TAILQ_INIT(&nt->nt_node); 
    731730        nt->nt_name = name; 
     
    737736        mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 
    738737} 
    739738 
     739static __inline void _node_table_join(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 
     740        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
     741 
     742        ni->ni_table = nt; 
     743        TAILQ_INSERT_TAIL(&nt->nt_node, ieee80211_ref_node(ni), ni_list); 
     744        LIST_INSERT_HEAD(&nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni, ni_hash); 
     745} 
     746 
     747static __inline void _node_table_leave(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 
     748        struct ieee80211_node *hni; 
     749        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
     750         
     751        TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
     752        LIST_FOREACH(hni, &nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni_hash) { 
     753                LIST_REMOVE(ni, ni_hash); 
     754        } 
     755        ni->ni_table = NULL; 
     756        _ieee80211_unref_node(ni); 
     757} 
     758 
     759/* This is overridden by ath_node_alloc in ath/if_ath.c, and so 
     760 * should never get called. 
     761 */ 
    740762static struct ieee80211_node * 
    741 node_alloc(struct ieee80211_node_table *nt, struct ieee80211vap *vap) 
     763node_alloc(struct ieee80211vap *vap) 
    742764{ 
    743765        struct ieee80211_node *ni; 
    744766 
     
    779801                        IEEE80211_UNLOCK_IRQ(ni->ni_ic); 
    780802                } 
    781803        } 
    782         /* 
    783          * Clear AREF flag that marks the authorization refcnt bump 
    784          * has happened.  This is probably not needed as the node 
    785          * should always be removed from the table so not found but 
    786          * do it just in case. 
    787          */ 
    788         ni->ni_flags &= ~IEEE80211_NODE_AREF; 
    789804 
    790805        /* 
    791806         * Drain power save queue and, if needed, clear TIM. 
     
    794809                vap->iv_set_tim(ni, 0); 
    795810 
    796811        ni->ni_associd = 0; 
    797         if (ni->ni_challenge != NULL) { 
    798                 FREE(ni->ni_challenge, M_DEVBUF); 
    799                 ni->ni_challenge = NULL; 
    800         } 
     812         
    801813        /* 
    802814         * Preserve SSID, WPA, and WME ie's so the bss node is 
    803815         * reusable during a re-auth/re-assoc state transition. 
     
    823835static void 
    824836node_free(struct ieee80211_node *ni) 
    825837{ 
     838#if 0 
     839        // We should 'cleanup' and then free'ing should be done automatically on decref 
    826840        struct ieee80211com *ic = ni->ni_ic; 
    827841 
    828842        ic->ic_node_cleanup(ni); 
     843#endif  
     844        KASSERT(ieee80211_node_refcnt(ni) == 0, ("node being free whilst still referenced")); 
     845 
     846        if (ni->ni_challenge != NULL)  
     847                FREE(ni->ni_challenge, M_DEVBUF); 
    829848        if (ni->ni_wpa_ie != NULL) 
    830849                FREE(ni->ni_wpa_ie, M_DEVBUF); 
    831850        if (ni->ni_rsn_ie != NULL) 
     
    835854        if (ni->ni_ath_ie != NULL) 
    836855                FREE(ni->ni_ath_ie, M_DEVBUF); 
    837856        IEEE80211_NODE_SAVEQ_DESTROY(ni); 
     857         
    838858        FREE(ni, M_80211_NODE); 
    839859} 
    840860 
     
    851871 * This interface is not intended for general use, it is 
    852872 * used by the routines below to create entries with a 
    853873 * specific purpose. 
     874 * Dont assume a BSS? 
    854875 */ 
    855876struct ieee80211_node * 
    856 ieee80211_alloc_node(struct ieee80211_node_table *nt, 
    857         struct ieee80211vap *vap, const u_int8_t *macaddr) 
     877ieee80211_alloc_node_table(struct ieee80211vap *vap,  
     878        const u_int8_t *macaddr) 
    858879{ 
    859         struct ieee80211com *ic = nt->nt_ic; 
     880        struct ieee80211com *ic = vap->iv_ic; 
     881        struct ieee80211_node_table *nt = &ic->ic_sta; 
    860882        struct ieee80211_node *ni; 
    861         int hash; 
    862         int i; 
    863883 
    864         ni = ic->ic_node_alloc(nt, vap); 
    865         if (ni == NULL) { 
    866                 /* XXX msg */ 
    867                 vap->iv_stats.is_rx_nodealloc++; 
    868                 return NULL; 
    869         } 
     884        ni = ieee80211_alloc_node(vap, macaddr); 
     885        if (ni != NULL) { 
     886                ni->ni_inact = ni->ni_inact_reload = nt->nt_inact_init; 
    870887 
    871         IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 
    872                 "%s: %p<%s> in %s table, refcnt %d\n", __func__, ni, 
    873                 ether_sprintf(macaddr), nt->nt_name, 
    874                 ieee80211_node_refcnt(ni)+1); 
     888                WME_UAPSD_NODE_TRIGSEQINIT(ni); 
     889                IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
    875890 
    876         IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
    877         hash = IEEE80211_NODE_HASH(macaddr); 
    878         ieee80211_node_initref(ni);             /* mark referenced */ 
    879         ni->ni_chan = IEEE80211_CHAN_ANYC; 
    880         ni->ni_authmode = IEEE80211_AUTH_OPEN; 
    881         ni->ni_txpower = ic->ic_txpowlimit;     /* max power */ 
    882         ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, IEEE80211_KEYIX_NONE); 
    883         ni->ni_inact_reload = nt->nt_inact_init; 
    884         ni->ni_inact = ni->ni_inact_reload; 
    885         ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 
    886         ni->ni_rxkeyoff = 0; 
    887         IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
     891                IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
     892                _node_table_join(nt, ni); 
     893                IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
     894        } 
    888895 
    889         IEEE80211_NODE_LOCK_IRQ(nt); 
    890         ni->ni_vap = vap; 
    891         ni->ni_ic = ic; 
    892         ni->ni_table = nt; 
    893         TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 
    894         LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 
    895 #define N(a)    (sizeof(a)/sizeof(a[0])) 
    896         for (i = 0; i < N(ni->ni_rxfrag); i++) 
    897                 ni->ni_rxfrag[i] = NULL; 
    898 #undef N 
    899         ni->ni_challenge = NULL; 
    900         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     896        return ni; 
     897
     898EXPORT_SYMBOL(ieee80211_alloc_node_table); 
    901899 
    902         WME_UAPSD_NODE_TRIGSEQINIT(ni); 
     900/* Allocate a node structure and initialise specialised structures 
     901 * This function does not add the node to the node table, thus this 
     902 * node will not be found using ieee80211_find_*node. 
     903 * This is useful when sending one off errors or request denials. 
     904 */ 
     905static struct ieee80211_node * 
     906ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) 
     907
     908        struct ieee80211com *ic = vap->iv_ic; 
     909        struct ieee80211_node *ni; 
     910         
     911        /* This always allocates zeroed memoery */ 
     912        ni = ic->ic_node_alloc(vap); 
     913        if (ni != NULL) { 
     914                IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
     915                "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr),  
     916                ieee80211_node_refcnt(ni)+1); 
    903917 
     918                ieee80211_node_initref(ni);             /* mark referenced */ 
     919                 
     920                IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
     921                 
     922                ni->ni_chan = IEEE80211_CHAN_ANYC; 
     923                ni->ni_authmode = IEEE80211_AUTH_OPEN; 
     924                ni->ni_txpower = ic->ic_txpowlimit; 
     925                 
     926                ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, 
     927                        IEEE80211_KEYIX_NONE); 
     928                ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 
     929 
     930                ni->ni_vap = vap; 
     931                ni->ni_ic = ic; 
     932        } else { 
     933                /* XXX msg */ 
     934                vap->iv_stats.is_rx_nodealloc++; 
     935        } 
    904936        return ni; 
    905937} 
    906 EXPORT_SYMBOL(ieee80211_alloc_node); 
    907938 
    908939/* Add wds address to the node table */ 
    909940int 
     
    925956                wds->wds_agingcount = WDS_AGING_COUNT; 
    926957        hash = IEEE80211_NODE_HASH(macaddr); 
    927958        IEEE80211_ADDR_COPY(wds->wds_macaddr, macaddr); 
    928         ieee80211_ref_node(ni);                /* Reference node */ 
    929         wds->wds_ni = ni
    930         IEEE80211_NODE_LOCK_IRQ(nt); 
     959         
     960        IEEE80211_NODE_TABLE_LOCK_IRQ(nt)
     961        wds->wds_ni = ieee80211_ref_node(ni); 
    931962        LIST_INSERT_HEAD(&nt->nt_wds_hash[hash], wds, wds_hash); 
    932         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     963        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    933964        return 0; 
    934965} 
    935966EXPORT_SYMBOL(ieee80211_add_wds_addr); 
     
    942973        struct ieee80211_wds_addr *wds; 
    943974 
    944975        hash = IEEE80211_NODE_HASH(macaddr); 
    945         IEEE80211_NODE_LOCK_IRQ(nt); 
     976        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    946977        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    947978                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    948                         if (ieee80211_node_dectestref(wds->wds_ni)) { 
    949                                 _ieee80211_free_node(wds->wds_ni); 
    950                                 LIST_REMOVE(wds, wds_hash); 
    951                                 FREE(wds, M_80211_WDS); 
    952                                 break; 
    953                         } 
     979                        LIST_REMOVE(wds, wds_hash); 
     980                        ieee80211_unref_node(&wds->wds_ni); 
     981                        FREE(wds, M_80211_WDS); 
     982                        break; 
    954983                } 
    955984        } 
    956         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     985        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    957986} 
    958987EXPORT_SYMBOL(ieee80211_remove_wds_addr); 
    959988 
     
    965994        int hash; 
    966995        struct ieee80211_wds_addr *wds; 
    967996 
    968         IEEE80211_NODE_LOCK_IRQ(nt); 
     997        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    969998        for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 
    970999                LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    9711000                        if (wds->wds_ni == ni) { 
    972                                 if (ieee80211_node_dectestref(ni)) { 
    973                                         _ieee80211_free_node(ni); 
    974                                         LIST_REMOVE(wds, wds_hash); 
    975                                         FREE(wds, M_80211_WDS); 
    976                                 } 
     1001                                LIST_REMOVE(wds, wds_hash); 
     1002                                ieee80211_unref_node(&wds->wds_ni); 
     1003                                FREE(wds, M_80211_WDS); 
    9771004                        } 
    9781005                } 
    9791006        } 
    980         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1007        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    9811008} 
    9821009EXPORT_SYMBOL(ieee80211_del_wds_node); 
    9831010 
     
    9881015        int hash; 
    9891016        struct ieee80211_wds_addr *wds; 
    9901017 
    991         IEEE80211_NODE_LOCK_IRQ(nt); 
     1018        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    9921019        for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 
    9931020                LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    9941021                        if (wds->wds_agingcount != WDS_AGING_STATIC) { 
    9951022                                if (!wds->wds_agingcount) { 
    996                                         if (ieee80211_node_dectestref(wds->wds_ni)) { 
    997                                                 _ieee80211_free_node(wds->wds_ni);   
    998                                                 LIST_REMOVE(wds, wds_hash); 
    999                                                 FREE(wds, M_80211_WDS); 
    1000                                         } 
     1023                                        LIST_REMOVE(wds, wds_hash); 
     1024                                        ieee80211_unref_node(&wds->wds_ni);   
     1025                                        FREE(wds, M_80211_WDS); 
    10011026                                } else 
    10021027                                        wds->wds_agingcount--; 
    10031028                        } 
    10041029                } 
    10051030        } 
    1006         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1031        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    10071032        mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 
    10081033} 
    10091034 
    10101035 
    10111036/* 
    1012  * Craft a temporary node suitable for sending a management frame 
    1013  * to the specified station.  We craft only as much state as we 
    1014  * need to do the work since the node will be immediately reclaimed 
    1015  * once the send completes. 
    1016  */ 
    1017 struct ieee80211_node * 
    1018 ieee80211_tmp_node(struct ieee80211vap *vap, const u_int8_t *macaddr) 
    1019 { 
    1020         struct ieee80211com *ic = vap->iv_ic; 
    1021         struct ieee80211_node *ni; 
    1022         int i; 
    1023  
    1024         ni = ic->ic_node_alloc(&ic->ic_sta,vap); 
    1025         if (ni != NULL) { 
    1026                 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    1027                 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr),  
    1028                 ieee80211_node_refcnt(ni)+1); 
    1029  
    1030                 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
    1031                 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    1032                 ieee80211_node_initref(ni);             /* mark referenced */ 
    1033                 ni->ni_txpower = vap->iv_bss->ni_txpower; 
    1034                 ni->ni_vap = vap; 
    1035                 /* NB: required by ieee80211_fix_rate */ 
    1036                 ieee80211_node_set_chan(ic, ni); 
    1037                 ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, 
    1038                         IEEE80211_KEYIX_NONE); 
    1039                 /* XXX optimize away */ 
    1040                 IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
    1041  
    1042                 ni->ni_table = NULL;            /* NB: pedantic */ 
    1043                 ni->ni_ic = ic; 
    1044 #define N(a)    (sizeof(a)/sizeof(a[0])) 
    1045                 for (i = 0; i < N(ni->ni_rxfrag); i++) 
    1046                         ni->ni_rxfrag[i] = NULL; 
    1047 #undef N 
    1048                 ni->ni_challenge = NULL; 
    1049         } else { 
    1050                 /* XXX msg */ 
    1051                 vap->iv_stats.is_rx_nodealloc++; 
    1052         } 
    1053         return ni; 
    1054 } 
    1055  
    1056 /* 
    10571037 * Add the specified station to the station table. 
    10581038 */ 
    10591039struct ieee80211_node * 
    1060 ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr) 
     1040ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr,  
     1041                unsigned char tmp) 
    10611042{ 
    1062         struct ieee80211com *ic = vap->iv_ic; 
    10631043        struct ieee80211_node *ni; 
    1064         int i; 
     1044         
     1045        // HACK 
     1046        if (tmp) 
     1047                ni = ieee80211_alloc_node(vap, macaddr); 
     1048        else 
     1049                ni = ieee80211_alloc_node_table(vap, macaddr); 
    10651050 
    1066         ni = ieee80211_alloc_node(&ic->ic_sta, vap, macaddr); 
    10671051        if (ni != NULL) { 
    1068                 /* 
    1069                  * Inherit from iv_bss. 
    1070                  */ 
    1071                 ni->ni_authmode = vap->iv_bss->ni_authmode; 
    1072                 ni->ni_txpower = vap->iv_bss->ni_txpower; 
    1073                 ni->ni_vlan = vap->iv_bss->ni_vlan;     /* XXX?? */ 
     1052                copy_bss(ni, vap->iv_bss); 
    10741053                IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    1075                 ieee80211_node_set_chan(ic, ni); 
    1076                 ni->ni_rsn = vap->iv_bss->ni_rsn; 
    1077 #define N(a)    (sizeof(a)/sizeof(a[0])) 
    1078                 for (i = 0; i < N(ni->ni_rxfrag); i++) 
    1079                         ni->ni_rxfrag[i] = NULL; 
    1080 #undef N 
     1054                /* Do this only for nodes that already have a BSS. Otherwise 
     1055                 * ic_bsschan is not set and we get a KASSERT failure. 
     1056                 * Required by ieee80211_fix_rate */ 
     1057                ieee80211_node_set_chan(vap->iv_ic, ni); 
    10811058        } 
    10821059        return ni; 
    10831060} 
     
    10851062static struct ieee80211_node * 
    10861063_ieee80211_find_wds_node(struct ieee80211_node_table *nt, const u_int8_t *macaddr) 
    10871064{ 
    1088         struct ieee80211_node *ni; 
    10891065        struct ieee80211_wds_addr *wds; 
    10901066        int hash; 
    1091         IEEE80211_NODE_LOCK_ASSERT(nt); 
     1067        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
    10921068 
    10931069        hash = IEEE80211_NODE_HASH(macaddr); 
    10941070        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    10951071                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    1096                         ni = wds->wds_ni; 
    10971072                        if (wds->wds_agingcount != WDS_AGING_STATIC) 
    10981073                                wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ 
    1099                         ieee80211_ref_node(ni); 
    1100                         return ni; 
     1074                        return ieee80211_ref_node(wds->wds_ni); 
    11011075                } 
    11021076        } 
    11031077        return NULL; 
     
    11151089        int hash; 
    11161090        struct ieee80211_wds_addr *wds; 
    11171091 
    1118         IEEE80211_NODE_LOCK_ASSERT(nt); 
     1092        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
    11191093 
    11201094        hash = IEEE80211_NODE_HASH(macaddr); 
    11211095        LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) { 
     
    11361110           nodes. */ 
    11371111        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    11381112                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    1139                         ni = wds->wds_ni; 
    1140                         ieee80211_ref_node(ni); 
    1141                         return ni; 
     1113                        return ieee80211_ref_node(wds->wds_ni); 
    11421114                } 
    11431115        } 
    11441116        return NULL; 
     
    11531125{ 
    11541126        struct ieee80211_node *ni; 
    11551127 
    1156         IEEE80211_NODE_LOCK_IRQ(nt); 
     1128        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    11571129        ni = _ieee80211_find_wds_node(nt, macaddr); 
    1158         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1130        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    11591131        return ni; 
    11601132} 
    11611133EXPORT_SYMBOL(ieee80211_find_wds_node); 
     
    11701142{ 
    11711143        struct ieee80211_node *ni; 
    11721144 
    1173         IEEE80211_NODE_LOCK_IRQ(nt); 
     1145        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    11741146        ni = _ieee80211_find_node(nt, macaddr); 
    1175         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1147        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    11761148        return ni; 
    11771149} 
    11781150#ifdef IEEE80211_DEBUG_REFCNT 
     
    11951167{ 
    11961168        struct ieee80211_node *ni; 
    11971169 
    1198         ni = ieee80211_dup_bss(vap, macaddr); 
     1170        ni = ieee80211_dup_bss(vap, macaddr, 0); 
    11991171        if (ni != NULL) { 
    12001172                /* XXX no rate negotiation; just dup */ 
    12011173                ni->ni_rates = vap->iv_bss->ni_rates; 
     
    12181190 * driver has an opportunity to setup it's private state. 
    12191191 */ 
    12201192struct ieee80211_node * 
    1221 ieee80211_add_neighbor(struct ieee80211vap *vap,       const struct ieee80211_frame *wh, 
     1193ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh, 
    12221194        const struct ieee80211_scanparams *sp) 
    12231195{ 
    12241196        struct ieee80211com *ic = vap->iv_ic; 
    12251197        struct ieee80211_node *ni; 
    12261198 
    1227         ni = ieee80211_dup_bss(vap, wh->i_addr2);       /* XXX alloc_node? */ 
    1228         /* TODO: not really putting itself in a table */ 
     1199        ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 
    12291200        if (ni != NULL) { 
    12301201                ni->ni_esslen = sp->ssid[1]; 
    12311202                memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]); 
     
    13001271        /* XXX check ic_bss first in station mode */ 
    13011272        /* XXX 4-address frames? */ 
    13021273        nt = &ic->ic_sta; 
    1303         IEEE80211_NODE_LOCK_IRQ(nt); 
     1274        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    13041275        if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/) 
    13051276                ni = _ieee80211_find_node(nt, wh->i_addr1); 
    13061277        else 
    13071278                ni = _ieee80211_find_node(nt, wh->i_addr2); 
    1308         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1279        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    13091280 
    13101281        return ni; 
    13111282#undef IS_PSPOLL 
     
    13421313 
    13431314        /* XXX can't hold lock across dup_bss due to recursive locking */ 
    13441315        nt = &vap->iv_ic->ic_sta; 
    1345         IEEE80211_NODE_LOCK_IRQ(nt); 
     1316        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    13461317        ni = _ieee80211_find_node(nt, mac); 
    1347         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1318        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    13481319 
    13491320        if (ni == NULL) { 
    13501321                if (vap->iv_opmode == IEEE80211_M_IBSS || 
     
    13711342EXPORT_SYMBOL(ieee80211_find_txnode); 
    13721343#endif 
    13731344 
    1374 /* Caller must lock the IEEE80211_NODE_LOCK 
    1375  * 
    1376  * Context: hwIRQ, softIRQ and process context 
     1345/* Context: hwIRQ, softIRQ and process context 
    13771346 */ 
    1378 static void 
     1347void 
    13791348_ieee80211_free_node(struct ieee80211_node *ni) 
    13801349{ 
    13811350        struct ieee80211vap *vap = ni->ni_vap; 
     
    13891358 
    13901359        if (vap->iv_aid_bitmap != NULL) 
    13911360                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    1392         if (nt != NULL) { 
    1393                 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
    1394                 LIST_REMOVE(ni, ni_hash); 
    1395         } 
     1361 
    13961362        vap->iv_ic->ic_node_free(ni); 
    13971363} 
     1364EXPORT_SYMBOL(_ieee80211_free_node); 
    13981365 
    1399 void 
    1400 #ifdef IEEE80211_DEBUG_REFCNT 
    1401 ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line) 
    1402 #else 
    1403 ieee80211_free_node(struct ieee80211_node *ni) 
    1404 #endif 
    1405 { 
    1406         struct ieee80211_node_table *nt = ni->ni_table; 
    1407         struct ieee80211com *ic = ni->ni_ic; 
    1408  
    1409 #ifdef IEEE80211_DEBUG_REFCNT 
    1410         IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 
    1411                 "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni, 
    1412                  ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni) - 1); 
    1413 #endif 
    1414         /* 
    1415          * XXX: may need to lock out the following race. we dectestref 
    1416          *      and determine it's time to free the node. between the if() 
    1417          *      and lock, we take an rx intr to receive a frame from this 
    1418          *      node. the rx path (tasklet or intr) bumps this node's 
    1419          *      refcnt and xmits a response frame. eventually that response 
    1420          *      will get reaped, and the reaping code will attempt to use 
    1421          *      the node. the code below will delete the node prior 
    1422          *      to the reap and we could get a crash. 
    1423          * 
    1424          *      as a stopgap before delving deeper, lock intrs to 
    1425          *      prevent this case. 
    1426          */ 
    1427         IEEE80211_LOCK_IRQ(ic); 
    1428         if (ieee80211_node_dectestref(ni)) { 
    1429                 /* 
    1430                  * Beware; if the node is marked gone then it's already 
    1431                  * been removed from the table and we cannot assume the 
    1432                  * table still exists.  Regardless, there's no need to lock 
    1433                  * the table. 
    1434                  */ 
    1435                 if (ni->ni_table != NULL) { 
    1436                         IEEE80211_NODE_LOCK(nt); 
    1437                         _ieee80211_free_node(ni); 
    1438                         IEEE80211_NODE_UNLOCK(nt); 
    1439                 } else 
    1440                         _ieee80211_free_node(ni); 
    1441         } 
    1442         IEEE80211_UNLOCK_IRQ(ic); 
    1443 } 
    1444 #ifdef IEEE80211_DEBUG_REFCNT 
    1445 EXPORT_SYMBOL(ieee80211_free_node_debug); 
    1446 #else 
    1447 EXPORT_SYMBOL(ieee80211_free_node); 
    1448 #endif 
    1449  
    1450 /* 
    1451  * Reclaim a node.  If this is the last reference count then 
    1452  * do the normal free work.  Otherwise remove it from the node 
    1453  * table and mark it gone by clearing the back-reference. 
    1454  */ 
    14551366static void 
    1456 node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni) 
    1457 { 
    1458  
    1459         IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 
    1460                 "%s: remove %p<%s> from %s table, refcnt %d\n", 
    1461                 __func__, ni, ether_sprintf(ni->ni_macaddr), 
    1462                 nt->nt_name, ieee80211_node_refcnt(ni)-1); 
    1463         if (!ieee80211_node_dectestref(ni)) { 
    1464                 /* 
    1465                  * Other references are present, just remove the 
    1466                  * node from the table so it cannot be found.  When 
    1467                  * the references are dropped storage will be 
    1468                  * reclaimed.  This normally only happens for ic_bss. 
    1469                  */ 
    1470                 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
    1471                 LIST_REMOVE(ni, ni_hash); 
    1472                 ni->ni_table = NULL;            /* clear reference */ 
    1473         } else 
    1474                 _ieee80211_free_node(ni); 
    1475 } 
    1476  
    1477 static void 
    14781367ieee80211_node_table_reset(struct ieee80211_node_table *nt, 
    14791368        struct ieee80211vap *match) 
    14801369{ 
    14811370        struct ieee80211_node *ni, *next; 
    14821371 
    1483         IEEE80211_NODE_LOCK_IRQ(nt); 
     1372        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    14841373        TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { 
    14851374                if (match != NULL && ni->ni_vap != match) 
    14861375                        continue; 
     
    14921381                        if (vap->iv_aid_bitmap != NULL) 
    14931382                                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    14941383                } 
    1495                 node_reclaim(nt, ni); 
     1384                ieee80211_node_leave(ni); 
    14961385        } 
    1497         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1386        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    14981387} 
    14991388 
    15001389static void 
    15011390ieee80211_node_table_cleanup(struct ieee80211_node_table *nt) 
    15021391{ 
     1392        struct ieee80211com *ic = nt->nt_ic; 
    15031393        struct ieee80211_node *ni, *next; 
    15041394 
    15051395        TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { 
     
    15111401                        if (vap->iv_aid_bitmap != NULL) 
    15121402                                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    15131403                } 
    1514                 node_reclaim(nt, ni); 
     1404                ic->ic_node_cleanup(ni); 
    15151405        } 
    15161406        del_timer(&nt->nt_wds_aging_timer); 
    15171407        IEEE80211_SCAN_LOCK_DESTROY(nt); 
    1518         IEEE80211_NODE_LOCK_DESTROY(nt); 
     1408        IEEE80211_NODE_TABLE_LOCK_DESTROY(nt); 
    15191409} 
    15201410 
    15211411/* 
     
    15431433        IEEE80211_SCAN_LOCK_IRQ(nt);  
    15441434        gen = ++nt->nt_scangen; 
    15451435restart: 
    1546         IEEE80211_NODE_LOCK_IRQ(nt); 
     1436        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    15471437        TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 
    15481438                if (ni->ni_scangen == gen)      /* previously handled */ 
    15491439                        continue; 
     1440                /* Temporary entries should no longer be in the node table */ 
    15501441                /* 
    15511442                 * Ignore entries for which have yet to receive an 
    15521443                 * authentication frame.  These are transient and 
    15531444                 * will be reclaimed when the last reference to them 
    15541445                 * goes away (when frame xmits complete). 
    15551446                 */ 
    1556                 if (ic->ic_opmode == IEEE80211_M_HOSTAP && 
    1557                     (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1558                         continue; 
     1447                /* 
     1448                 *if (ic->ic_opmode == IEEE80211_M_HOSTAP && 
     1449                 *   (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
     1450                 *      continue; 
     1451                 */ 
    15591452                ni->ni_scangen = gen; 
    15601453                /* 
    15611454                 * Free fragment if not needed anymore 
     
    16071500                                 * ref for us as needed. 
    16081501                                 */ 
    16091502                                ieee80211_ref_node(ni); 
    1610                                 IEEE80211_NODE_UNLOCK_IRQ_EARLY(nt); 
     1503                                IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
    16111504                                ieee80211_send_nulldata(ni); 
    16121505                                /* XXX stat? */ 
    16131506                                goto restart; 
     
    16301523                         */ 
    16311524                        ni->ni_vap->iv_stats.is_node_timeout++; 
    16321525                        ieee80211_ref_node(ni); 
    1633                         IEEE80211_NODE_UNLOCK_IRQ_EARLY(nt); 
     1526                        IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
    16341527                        if (ni->ni_associd != 0) { 
    16351528                                IEEE80211_SEND_MGMT(ni, 
    16361529                                        IEEE80211_FC0_SUBTYPE_DEAUTH, 
    16371530                                        IEEE80211_REASON_AUTH_EXPIRE); 
    16381531                        } 
    16391532                        ieee80211_node_leave(ni); 
    1640                         ieee80211_free_node(ni); 
     1533                        ieee80211_unref_node(&ni); 
    16411534                        goto restart; 
    16421535                } 
    16431536        } 
    1644         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1537        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    16451538 
    16461539        IEEE80211_SCAN_UNLOCK_IRQ(nt); 
    16471540} 
     
    16641557void 
    16651558ieee80211_iterate_nodes(struct ieee80211_node_table *nt, ieee80211_iter_func *f, void *arg) 
    16661559{ 
    1667         struct ieee80211_node *ni; 
     1560        struct ieee80211_node *tni, *ni; 
    16681561        u_int gen; 
    16691562 
    16701563        IEEE80211_SCAN_LOCK_IRQ(nt); 
    16711564        gen = ++nt->nt_scangen; 
     1565         
    16721566restart: 
    1673         IEEE80211_NODE_LOCK(nt); 
    1674         TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 
    1675                 if (ni->ni_scangen != gen) { 
    1676                         ni->ni_scangen = gen; 
    1677                         (void) ieee80211_ref_node(ni); 
    1678                         IEEE80211_NODE_UNLOCK(nt); 
     1567        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
     1568        TAILQ_FOREACH(tni, &nt->nt_node, ni_list) { 
     1569                if (tni->ni_scangen != gen) { 
     1570                        tni->ni_scangen = gen; 
     1571                         
     1572                        ni = ieee80211_ref_node(tni); 
     1573                        IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
     1574 
    16791575                        (*f)(arg, ni); 
    1680                         ieee80211_free_node(ni); 
     1576                         
     1577                        ieee80211_unref_node(&ni); 
    16811578                        goto restart; 
    16821579                } 
    16831580        } 
    1684         IEEE80211_NODE_UNLOCK(nt); 
     1581        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    16851582 
    16861583        IEEE80211_SCAN_UNLOCK_IRQ(nt); 
    16871584} 
     
    19551852                "station with aid %d leaves (refcnt %u)", 
    19561853                IEEE80211_NODE_AID(ni), ieee80211_node_refcnt(ni)); 
    19571854 
     1855        /* From this point onwards we can no longer find the node, 
     1856         * so no more references are generated 
     1857         */ 
     1858        ieee80211_remove_wds_addr(nt, ni->ni_macaddr); 
     1859        ieee80211_del_wds_node(nt, ni); 
     1860        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
     1861        _node_table_leave(nt, ni); 
     1862        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
     1863 
    19581864        /* 
    19591865         * If node wasn't previously associated all 
    19601866         * we need to do is reclaim the reference. 
     1867         * This also goes for nodes that are auth'ed but 
     1868         * not associated. 
    19611869         */ 
    19621870        /* XXX ibss mode bypasses 11g and notification */ 
    19631871        if (ni->ni_associd == 0) 
     
    19751883        IEEE80211_LOCK_IRQ(ic); 
    19761884        if (vap->iv_aid_bitmap != NULL) 
    19771885                IEEE80211_AID_CLR(vap, ni->ni_associd); 
     1886 
    19781887        ni->ni_associd = 0; 
    19791888        vap->iv_sta_assoc--; 
    19801889        ic->ic_sta_assoc--; 
     1890 
    19811891#ifdef ATH_SUPERG_XR 
    19821892        if (ni->ni_vap->iv_flags & IEEE80211_F_XR) 
    19831893                ic->ic_xr_sta_assoc--; 
     
    19881898        if (IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) 
    19891899                ieee80211_node_leave_11g(ni); 
    19901900        IEEE80211_UNLOCK_IRQ(ic); 
     1901 
    19911902        /* 
    19921903         * Cleanup station state.  In particular clear various 
    19931904         * state that might otherwise be reused if the node 
     
    19971908        ieee80211_sta_leave(ni); 
    19981909done: 
    19991910        /* 
    2000          * Remove the node from any table it's recorded in and 
    2001          * drop the caller's reference.  Removal from the table 
    2002          * is important to ensure the node is not reprocessed 
    2003          * for inactivity. 
     1911         * Run a cleanup and then drop the caller's reference 
    20041912         */ 
    2005         if (nt != NULL) { 
    2006                 IEEE80211_NODE_LOCK_IRQ(nt); 
    2007                 node_reclaim(nt, ni); 
    2008                 IEEE80211_NODE_UNLOCK_IRQ(nt); 
    2009                 ieee80211_remove_wds_addr(nt,ni->ni_macaddr); 
    2010                 ieee80211_del_wds_node(nt,ni); 
    2011         } else 
    2012                 ieee80211_free_node(ni); 
     1913        ic->ic_node_cleanup(ni); 
     1914        ieee80211_unref_node(&ni); 
    20131915} 
    20141916EXPORT_SYMBOL(ieee80211_node_leave); 
    20151917 
     
    20691971void 
    20701972ieee80211_node_reset(struct ieee80211_node *ni, struct ieee80211vap *vap) 
    20711973{ 
    2072         if (ni != NULL) { 
    2073                 struct ieee80211_node_table *nt = ni->ni_table; 
    2074                 if (!nt) 
    2075                         nt = &vap->iv_ic->ic_sta; 
    2076                 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    2077                 ni->ni_prev_vap = ni->ni_vap; 
    2078                 ni->ni_vap = vap; 
    2079                 ni->ni_ic = vap->iv_ic; 
    2080                 /*  
    2081                  * if node not found in the node table 
    2082                  * add it to the node table . 
    2083                  */ 
    2084                 if(nt && ieee80211_find_node(nt, ni->ni_macaddr) != ni) { 
    2085                         int hash = IEEE80211_NODE_HASH(ni->ni_macaddr); 
    2086                         IEEE80211_NODE_LOCK_IRQ(nt); 
    2087                         TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 
    2088                         LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 
    2089                         ni->ni_table = nt; 
    2090                         IEEE80211_NODE_UNLOCK_IRQ(nt); 
    2091                 } 
    2092         } 
     1974        IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
     1975        ni->ni_prev_vap = ni->ni_vap; 
     1976        ni->ni_vap = vap; 
     1977        ni->ni_ic = vap->iv_ic; 
    20931978} 
  • net80211/ieee80211_node.h

    old new  
    5252 * authorized.  The latter timeout is shorter to more aggressively 
    5353 * reclaim nodes that leave part way through the 802.1x exchange. 
    5454 */ 
    55 #define IEEE80211_INACT_WAIT    15              /* inactivity interval (secs) */ 
     55#define IEEE80211_INACT_WAIT    15                             /* inactivity interval (secs) */ 
    5656#define IEEE80211_INACT_INIT    (30/IEEE80211_INACT_WAIT)       /* initial */ 
    5757#define IEEE80211_INACT_AUTH    (180/IEEE80211_INACT_WAIT)      /* associated but not authorized */ 
    5858#define IEEE80211_INACT_RUN     (300/IEEE80211_INACT_WAIT)      /* authorized */ 
    5959#define IEEE80211_INACT_PROBE   (30/IEEE80211_INACT_WAIT)       /* probe */ 
    6060#define IEEE80211_INACT_SCAN    (300/IEEE80211_INACT_WAIT)      /* scanned */ 
    6161 
    62 #define IEEE80211_TRANS_WAIT    5               /* mgt frame tx timer (secs) */ 
     62#define IEEE80211_TRANS_WAIT    5                              /* mgt frame tx timer (secs) */ 
    6363 
    6464#define IEEE80211_NODE_HASHSIZE 32 
    6565/* simple hash is enough for variation of macaddr */ 
     
    9494        struct ieee80211_node_table *ni_table; 
    9595        TAILQ_ENTRY(ieee80211_node) ni_list; 
    9696        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; 
    9899        u_int ni_scangen;                       /* gen# for timeout scan */ 
    99100        u_int8_t ni_authmode;                   /* authentication algorithm */ 
    100101        u_int16_t ni_flags;                     /* special-purpose state */ 
     
    121122        u_int16_t ni_associd;                   /* assoc response */ 
    122123        u_int16_t ni_txpower;                   /* current transmit power (in 0.5 dBm) */ 
    123124        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 */ 
    125126        u_int8_t *ni_wpa_ie;                    /* captured WPA ie */ 
    126127        u_int8_t *ni_rsn_ie;                    /* captured RSN ie */ 
    127128        u_int8_t *ni_wme_ie;                    /* captured WME ie */ 
    128129        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*/ 
    131132        u_int32_t ni_rxfragstamp;               /* time stamp of last rx frag */ 
    132133        struct sk_buff *ni_rxfrag[3];           /* rx frag reassembly */ 
    133134        struct ieee80211_rsnparms ni_rsn;       /* RSN/WPA parameters */ 
     
    156157        struct ieee80211_channel *ni_chan; 
    157158        u_int16_t ni_fhdwell;                   /* FH only */ 
    158159        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 */ 
    160161        u_int16_t ni_timoff;                    /* byte offset to TIM ie */ 
    161162 
    162163        /* others */ 
     
    168169        struct ieee80211vap *ni_prev_vap;       /* previously associated vap */ 
    169170        u_int8_t ni_uapsd;                      /* U-APSD per-node flags matching WMM STA Qos Info field */ 
    170171        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 */ 
    172173        __le16 ni_pschangeseq; 
    173174}; 
    174175MALLOC_DECLARE(M_80211_NODE); 
     
    186187#define WME_UAPSD_NODE_INVALIDSEQ       0xffff 
    187188#define WME_UAPSD_NODE_TRIGSEQINIT(_ni) (memset(&(_ni)->ni_uapsd_trigseq[0], 0xff, sizeof((_ni)->ni_uapsd_trigseq))) 
    188189 
    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 void 
    197 ieee80211_unref_node(struct ieee80211_node **ni) 
    198 { 
    199         ieee80211_node_decref(*ni); 
    200         *ni = NULL;                     /* guard against use */ 
    201 } 
    202  
    203190void ieee80211_node_attach(struct ieee80211com *); 
    204191void ieee80211_node_detach(struct ieee80211com *); 
    205192void ieee80211_node_vattach(struct ieee80211vap *); 
     
    242229 * is a second table for associated stations or neighbors. 
    243230 */ 
    244231struct ieee80211_node_table { 
     232        const char *nt_name;                    /* for debugging */ 
    245233        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 */ 
    247235        TAILQ_HEAD(, ieee80211_node) nt_node;   /* information of all nodes */ 
    248236        ATH_LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE]; 
    249237        ATH_LIST_HEAD(, ieee80211_wds_addr) nt_wds_hash[IEEE80211_NODE_HASHSIZE]; 
    250         const char *nt_name;                    /* for debugging */ 
    251238        ieee80211_scan_lock_t nt_scanlock;      /* on nt_scangen */ 
    252239        u_int nt_scangen;                       /* gen# for timeout scan */ 
    253240        int nt_inact_init;                      /* initial node inact setting */ 
    254241        struct timer_list nt_wds_aging_timer;   /* timer to age out wds entries */ 
    255242}; 
    256243 
    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 *, 
     244struct ieee80211_node *ieee80211_alloc_node_table(struct ieee80211vap *, 
    260245        const u_int8_t *); 
    261 struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *, 
    262         const u_int8_t *); 
     246struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *,  
     247        const u_int8_t *, unsigned char); 
    263248void ieee80211_node_reset(struct ieee80211_node *, struct ieee80211vap *); 
    264249#ifdef IEEE80211_DEBUG_REFCNT 
    265 void ieee80211_free_node_debug(struct ieee80211_node *, const char *, int); 
    266250struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *, 
    267251        const u_int8_t *, const char *, int); 
    268252struct ieee80211_node *ieee80211_find_rxnode_debug(struct ieee80211com *, 
    269253        const struct ieee80211_frame_min *, const char *, int); 
    270254struct ieee80211_node *ieee80211_find_txnode_debug(struct ieee80211vap *, 
    271255        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__) 
    280264#else 
    281 void ieee80211_free_node(struct ieee80211_node *); 
    282265 
    283266struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *, 
    284267        const u_int8_t *); 
     
    287270struct ieee80211_node *ieee80211_find_txnode(struct ieee80211vap *, 
    288271        const u_int8_t *); 
    289272#endif 
     273 
     274void _ieee80211_free_node(struct ieee80211_node *); 
     275 
     276static __inline struct ieee80211_node * 
     277ieee80211_ref_node(struct ieee80211_node *ni) 
     278{ 
     279        ieee80211_node_incref(ni); 
     280        return ni; 
     281} 
     282 
     283static __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 
     293static __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 
     303static __inline void 
     304#ifdef IEEE80211_DEBUG_REFCNT 
     305ieee80211_unref_node_debug(struct ieee80211_node **pni, const char *func, int line) 
     306#else 
     307ieee80211_unref_node(struct ieee80211_node **pni) 
     308#endif 
     309{        
     310        struct ieee80211_node *ni = *pni; 
     311#ifdef IEEE80211_DEBUG_REFCNT 
     312        IEEE80211_DPRINTF(NULL, 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 
    290320int ieee80211_add_wds_addr(struct ieee80211_node_table *, struct ieee80211_node *, 
    291321        const u_int8_t *, u_int8_t); 
    292322void ieee80211_remove_wds_addr(struct ieee80211_node_table *, const u_int8_t *); 
  • 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 
     71int 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) 
     88struct ieee80211vap; 
     89struct ieee80211_frame; 
     90void ieee80211_note(struct ieee80211vap *, const char *, ...); 
     91void ieee80211_note_mac(struct ieee80211vap *, 
     92        const u_int8_t mac[IEEE80211_ADDR_LEN], const char *, ...); 
     93void 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 
  • net80211/ieee80211_scan_sta.c

    old new  
    762762        if (se->se_rssi < STA_RSSI_MIN) 
    763763                fail |= 0x100; 
    764764#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)) { 
    766766                printf(" %03x", fail); 
    767767                printf(" %c %s", 
    768768                        fail & 0x40 ? '=' : fail & 0x80 ? '^' : fail ? '-' : '+', 
  • net80211/ieee80211_wireless.c

    old new  
    31603160                error = -ENXIO; 
    31613161        ieee80211_key_update_end(vap); 
    31623162        if (ni != NULL) 
    3163                 ieee80211_free_node(ni); 
     3163                ieee80211_unref_node(&ni); 
    31643164#ifdef ATH_SUPERG_XR 
    31653165        /* set the same params on the xr vap device if exists */ 
    31663166        if (vap->iv_xrvap && !(vap->iv_flags & IEEE80211_F_XR)) 
     
    32203220                memset(ik.ik_keydata, 0, sizeof(ik.ik_keydata)); 
    32213221        } 
    32223222        if (ni != NULL) 
    3223                 ieee80211_free_node(ni); 
     3223                ieee80211_unref_node(&ni); 
    32243224        return (copy_to_user(iwr->u.data.pointer, &ik, sizeof(ik)) ? -EFAULT : 0); 
    32253225} 
    32263226 
     
    32433243                        return -EINVAL;         /* XXX */ 
    32443244                /* XXX error return */ 
    32453245                ieee80211_crypto_delkey(vap, &ni->ni_ucastkey, ni); 
    3246                 ieee80211_free_node(ni); 
     3246                ieee80211_unref_node(&ni); 
    32473247        } else { 
    32483248                if (kid >= IEEE80211_WEP_NKID) 
    32493249                        return -EINVAL; 
     
    33453345                                if (ni == NULL) 
    33463346                                        return -EINVAL; 
    33473347                                domlme(mlme, ni); 
    3348                                 ieee80211_free_node(ni); 
     3348                                ieee80211_unref_node(&ni); 
    33493349                        } else 
    33503350                                ieee80211_iterate_nodes(&ic->ic_sta, domlme, mlme); 
    33513351                        break; 
     
    33643364                        ieee80211_node_authorize(ni); 
    33653365                else 
    33663366                        ieee80211_node_unauthorize(ni); 
    3367                 ieee80211_free_node(ni); 
     3367                ieee80211_unref_node(&ni); 
    33683368                break; 
    33693369        case IEEE80211_MLME_CLEAR_STATS: 
    33703370                if (vap->iv_opmode != IEEE80211_M_HOSTAP) 
     
    33753375                 
    33763376                /* clear statistics */ 
    33773377                memset(&ni->ni_stats, 0, sizeof(struct ieee80211_nodestats)); 
    3378                 ieee80211_free_node(ni); 
     3378                ieee80211_unref_node(&ni); 
    33793379                break; 
    33803380        default: 
    33813381                return -EINVAL; 
     
    37453745                        ielen = sizeof(wpaie.rsn_ie); 
    37463746                memcpy(wpaie.rsn_ie, ni->ni_rsn_ie, ielen); 
    37473747        } 
    3748         ieee80211_free_node(ni); 
     3748        ieee80211_unref_node(&ni); 
    37493749        return (copy_to_user(iwr->u.data.pointer, &wpaie, sizeof(wpaie)) ? 
    37503750                -EFAULT : 0); 
    37513751} 
     
    37723772        /* NB: copy out only the statistics */ 
    37733773        error = copy_to_user(iwr->u.data.pointer + off, &ni->ni_stats, 
    37743774                iwr->u.data.length - off); 
    3775         ieee80211_free_node(ni); 
     3775        ieee80211_unref_node(&ni); 
    37763776        return (error ? -EFAULT : 0); 
    37773777} 
    37783778 
  • net80211/ieee80211_input.c

    old new  
    310310                                /* 
    311311                                 * Try to find sender in local node table. 
    312312                                 */ 
    313                                 ieee80211_free_node(ni); 
     313                                ieee80211_unref_node(&ni); 
    314314                                ni = ieee80211_find_node(vap->iv_bss->ni_table, wh->i_addr2); 
    315315                                if (ni == NULL) { 
    316316                                        /* 
     
    491491                                        nt = &ic->ic_sta; 
    492492                                        ni_wds = ieee80211_find_wds_node(nt, wh->i_addr3); 
    493493                                        if (ni_wds) { 
    494                                                 ieee80211_free_node(ni_wds); /* Decr ref count */ 
     494                                                ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    495495                                                IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, 
    496496                                                        wh, NULL, "%s", 
    497497                                                        "multicast echo originated from node behind me"); 
     
    571571                                if (ni_wds == NULL) 
    572572                                        ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); 
    573573                                else 
    574                                         ieee80211_free_node(ni_wds); /* Decr ref count */ 
     574                                        ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    575575                        } 
    576576                         
    577577                        /* 
     
    930930                } 
    931931                ni = ieee80211_ref_node(vap->iv_bss); 
    932932                type = ieee80211_input(ni, skb1, rssi, rstamp); 
    933                 ieee80211_free_node(ni); 
     933                ieee80211_unref_node(&ni); 
    934934        } 
    935935        if (skb != NULL)                /* no vaps, reclaim skb */ 
    936936                dev_kfree_skb(skb); 
     
    980980        } 
    981981 
    982982        /* 
    983          * Use this lock to make sure ni->ni_rxfrag[0] is 
    984          * not freed by the timer process while we use it. 
    985          * XXX bogus 
    986          */ 
    987         IEEE80211_NODE_LOCK_IRQ(ni->ni_table); 
    988  
    989         /* 
    990983         * Update the time stamp.  As a side effect, it 
    991984         * also makes sure that the timer will not change 
    992985         * ni->ni_rxfrag[0] for at least 1 second, or in 
    993986         * other words, for the remaining of this function. 
     987         * XXX HUGE HORRIFIC HACK 
    994988         */ 
    995989        ni->ni_rxfragstamp = jiffies; 
    996990 
    997         IEEE80211_NODE_UNLOCK_IRQ(ni->ni_table); 
    998  
    999991        /* 
    1000992         * Validate that fragment is in order and 
    1001993         * related to the previous ones. 
     
    11241116                                        skb = NULL; 
    11251117                                } 
    11261118                                /* XXX statistic? */ 
    1127                                 ieee80211_free_node(ni1); 
     1119                                ieee80211_unref_node(&ni1); 
    11281120                        } 
    11291121                } 
    11301122                if (skb1 != NULL) { 
     
    12481240        int rssi, u_int32_t rstamp, u_int16_t seq, u_int16_t status) 
    12491241{ 
    12501242        struct ieee80211vap *vap = ni->ni_vap; 
     1243        unsigned int tmpnode = 0; 
    12511244 
    12521245        if (ni->ni_authmode == IEEE80211_AUTH_SHARED) { 
    12531246                IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 
     
    12551248                        "bad sta auth mode %u", ni->ni_authmode); 
    12561249                vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ 
    12571250                if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 
    1258                         /* XXX hack to workaround calling convention */ 
    1259  
    1260                         /* XXX To send the frame to the requesting STA, we have to 
    1261                          * create a node for the station that we're going to reject. 
    1262                          * The node will be freed automatically */ 
    12631251                        if (ni == vap->iv_bss) { 
    1264                                 ni = ieee80211_dup_bss(vap, wh->i_addr2); 
     1252                                ieee80211_unref_node(&ni); 
     1253                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 
    12651254                                if (ni == NULL) 
    12661255                                        return; 
    12671256 
    12681257                                IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    12691258                                "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    12701259                                ieee80211_node_refcnt(ni)); 
     1260                                tmpnode = 1; 
    12711261                        } 
    12721262                        IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, 
    12731263                                (seq + 1) | (IEEE80211_STATUS_ALG<<16)); 
     1264                         
     1265                        if (tmpnode) 
     1266                                ieee80211_unref_node(&ni); 
    12741267                        return; 
    12751268                } 
    12761269        } 
     
    12981291                } 
    12991292                /* always accept open authentication requests */ 
    13001293                if (ni == vap->iv_bss) { 
    1301                         ni = ieee80211_dup_bss(vap, wh->i_addr2);  
     1294                        ieee80211_unref_node(&ni); 
     1295                        ni = ieee80211_dup_bss(vap, wh->i_addr2, 0);  
    13021296                        if (ni == NULL) 
    13031297                                return; 
    13041298 
    13051299                        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    13061300                        "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    13071301                        ieee80211_node_refcnt(ni)); 
    1308  
    1309                 } else if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1310                         (void) ieee80211_ref_node(ni); 
    1311                 /* 
    1312                  * Mark the node as referenced to reflect that it's 
    1313                  * reference count has been bumped to ensure it remains 
    1314                  * after the transaction completes. 
    1315                  */ 
    1316                 ni->ni_flags |= IEEE80211_NODE_AREF; 
    1317  
     1302                        tmpnode = 1; 
     1303                } 
     1304                 
    13181305                IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, seq + 1); 
    13191306                IEEE80211_NOTE(vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, 
    13201307                        ni, "station authenticated (%s)", "open"); 
     
    13241311                 */ 
    13251312                if (ni->ni_authmode != IEEE80211_AUTH_8021X) 
    13261313                        ieee80211_node_authorize(ni); 
     1314                if (tmpnode) 
     1315                        ieee80211_unref_node(&ni); 
    13271316                break; 
    13281317 
    13291318        case IEEE80211_M_STA: 
     
    13621351        int istmp; 
    13631352 
    13641353        if (ni == vap->iv_bss) { 
    1365                 ni = ieee80211_tmp_node(vap, mac); 
     1354                ieee80211_unref_node(&ni); 
     1355                ni = ieee80211_dup_bss(vap, mac, 1); 
    13661356                if (ni == NULL) { 
    13671357                        /* XXX msg */ 
    13681358                        return; 
     
    13721362                istmp = 0; 
    13731363        IEEE80211_SEND_MGMT(ni, subtype, arg); 
    13741364        if (istmp) 
    1375                 ieee80211_free_node(ni); 
     1365                ieee80211_unref_node(&ni); 
    13761366} 
    13771367 
    13781368static int 
     
    13981388{ 
    13991389        struct ieee80211vap *vap = ni->ni_vap; 
    14001390        u_int8_t *challenge; 
    1401         int allocbs, estatus
     1391        int allocbs = 0, estatus = 0
    14021392 
    14031393        /* 
    14041394         * NB: this can happen as we allow pre-shared key 
     
    14081398         * ordering in which case this check would just be 
    14091399         * for sanity/consistency. 
    14101400         */ 
    1411         estatus = 0;                    /* NB: silence compiler */ 
    14121401        if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { 
    14131402                IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 
    14141403                        ni->ni_macaddr, "shared key auth", 
     
    14881477                switch (seq) { 
    14891478                case IEEE80211_AUTH_SHARED_REQUEST: 
    14901479                        if (ni == vap->iv_bss) { 
    1491                                 ni = ieee80211_dup_bss(vap, wh->i_addr2); 
     1480                                ieee80211_unref_node(&ni); 
     1481                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 
    14921482                                if (ni == NULL) { 
    14931483                                        /* NB: no way to return an error */ 
    14941484                                        return; 
     
    14991489                                ieee80211_node_refcnt(ni)); 
    15001490 
    15011491                                allocbs = 1; 
    1502                         } else { 
    1503                                 if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1504                                         (void) ieee80211_ref_node(ni); 
    1505                                 allocbs = 0; 
    15061492                        } 
    1507                         /* 
    1508                          * Mark the node as referenced to reflect that it's 
    1509                          * reference count has been bumped to ensure it remains 
    1510                          * after the transaction completes. 
    1511                          */ 
    1512                         ni->ni_flags |= IEEE80211_NODE_AREF; 
     1493 
    15131494                        ni->ni_rssi = rssi; 
    15141495                        ni->ni_rstamp = rstamp; 
    15151496                        ni->ni_last_rx = jiffies; 
     
    16031584        } 
    16041585        return; 
    16051586bad: 
    1606         /* 
    1607          * Send an error response; but only when operating as an AP. 
    1608          */ 
     1587        /* Send an error response; but only when operating as an AP. */ 
    16091588        if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 
    16101589                /* XXX hack to workaround calling convention */ 
    16111590                ieee80211_send_error(ni, wh->i_addr2,  
    16121591                        IEEE80211_FC0_SUBTYPE_AUTH, 
    16131592                        (seq + 1) | (estatus<<16)); 
     1593                ieee80211_node_leave(ni); 
    16141594        } else if (vap->iv_opmode == IEEE80211_M_STA) { 
    16151595                /* 
    16161596                 * Kick the state machine.  This short-circuits 
     
    20742054        /* optional RSN capabilities */ 
    20752055        if (len > 2) 
    20762056                rsn_parm->rsn_caps = LE_READ_2(frm); 
    2077         /* XXXPMKID */ 
     2057        /* XXX PMKID */ 
    20782058 
    20792059        return 0; 
    20802060} 
     
    25682548        u_int8_t *frm, *efrm; 
    25692549        u_int8_t *ssid, *rates, *xrates, *wpa, *rsn, *wme, *ath; 
    25702550        u_int8_t rate; 
    2571         int reassoc, resp, allocbs
     2551        int reassoc, resp, allocbs = 0
    25722552        u_int8_t qosinfo; 
    25732553 
    25742554        wh = (struct ieee80211_frame *) skb->data; 
     
    28492829                } 
    28502830                if (scan.capinfo & IEEE80211_CAPINFO_IBSS) { 
    28512831                        if (!IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_macaddr)) { 
    2852                                 /* 
    2853                                  * Create a new entry in the neighbor table. 
    2854                                  */ 
    28552832                                ni = ieee80211_add_neighbor(vap, wh, &scan); 
    28562833                        } else { 
    28572834                                /* 
     
    29652942                                 */ 
    29662943                                ni = ieee80211_fakeup_adhoc_node(vap, 
    29672944                                        wh->i_addr2); 
    2968                         } else 
    2969                                 ni = ieee80211_tmp_node(vap, wh->i_addr2); 
     2945                        } else { 
     2946                                ieee80211_unref_node(&ni); 
     2947                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 
     2948                        } 
    29702949                        if (ni == NULL) 
    29712950                                return; 
    29722951                        allocbs = 1; 
    2973                 } else 
    2974                         allocbs = 0; 
     2952                } 
     2953 
    29752954                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2, 
    29762955                        "%s", "recv probe req"); 
    29772956                ni->ni_rssi = rssi; 
     
    29942973                         * Temporary node created just to send a 
    29952974                         * response, reclaim immediately 
    29962975                         */ 
    2997                         ieee80211_free_node(ni); 
     2976                        ieee80211_unref_node(&ni); 
    29982977                } else if (ath != NULL) 
    29992978                        ieee80211_saveath(ni, ath); 
    30002979                break; 
     
    30243003                                        ni = vap->iv_xrvap->iv_bss; 
    30253004                                else { 
    30263005                                        ieee80211_node_leave(ni); 
     3006                                        /* This would be a stupid place to add a node to the table 
     3007                                         * XR stuff needs work anyway 
     3008                                         */ 
    30273009                                        ieee80211_node_reset(ni, vap->iv_xrvap); 
    30283010                                } 
    30293011                                vap = vap->iv_xrvap; 
     
    30363018#endif 
    30373019                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2, 
    30383020                        "recv auth frame with algorithm %d seq %d", algo, seq); 
    3039                 /* 
    3040                  * Consult the ACL policy module if setup. 
    3041                  */ 
     3021                /* Consult the ACL policy module if setup. */ 
    30423022                if (vap->iv_acl != NULL && 
    30433023                    !vap->iv_acl->iac_check(vap, wh->i_addr2)) { 
    30443024                        IEEE80211_DISCARD(vap, IEEE80211_MSG_ACL, 
     
    30713051                                /* XXX not right */ 
    30723052                                ieee80211_send_error(ni, wh->i_addr2, 
    30733053                                        IEEE80211_FC0_SUBTYPE_AUTH, 
    3074                                         (seq+1) | (IEEE80211_STATUS_ALG << 16)); 
     3054                                        (seq + 1) | (IEEE80211_STATUS_ALG << 16)); 
    30753055                        } 
    30763056                        return; 
    30773057                }  
  • net80211/ieee80211_output.c

    old new  
    254254                goto bad; 
    255255        } 
    256256         
    257         cb->ni = ni
     257        cb->ni = ieee80211_ref_node(ni)
    258258         
    259259        /* power-save checks */ 
    260260        if (WME_UAPSD_AC_CAN_TRIGGER(skb->priority, ni)) { 
     
    293293        } 
    294294#endif 
    295295        ieee80211_parent_queue_xmit(skb); 
     296        ieee80211_unref_node(&ni); 
    296297        return 0; 
    297298 
    298299bad: 
    299300        if (skb != NULL) 
    300301                dev_kfree_skb(skb); 
    301302        if (ni != NULL) 
    302                 ieee80211_free_node(ni); 
     303                ieee80211_unref_node(&ni); 
    303304        return 0; 
    304305} 
    305306 
     
    453454        if (skb == NULL) { 
    454455                /* XXX debug msg */ 
    455456                vap->iv_stats.is_tx_nobuf++; 
    456                 ieee80211_free_node(ni); 
     457                ieee80211_unref_node(&ni); 
    457458                return -ENOMEM; 
    458459        } 
    459460        cb = (struct ieee80211_cb *)skb->cb; 
     
    507508        u_int8_t *frm; 
    508509        int tid; 
    509510 
    510         ieee80211_ref_node(ni); 
    511511        skb = ieee80211_getmgtframe(&frm, 2); 
    512512        if (skb == NULL) { 
    513513                /* XXX debug msg */ 
    514514                vap->iv_stats.is_tx_nobuf++; 
    515                 ieee80211_free_node(ni); 
    516515                return -ENOMEM; 
    517516        } 
    518517        cb = (struct ieee80211_cb *)skb->cb; 
    519         cb->ni = ni
     518        cb->ni = ieee80211_ref_node(ni)
    520519 
    521520        skb->priority = ac; 
    522521        qwh = (struct ieee80211_qosframe *)skb_push(skb, sizeof(struct ieee80211_qosframe)); 
     
    865864                                nt = &ic->ic_sta; 
    866865                                ni_wds = ieee80211_find_wds_node(nt, eh.ether_shost); 
    867866                                if (ni_wds) 
    868                                         ieee80211_free_node(ni_wds); /* Decr ref count */ 
     867                                        ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    869868                                else 
    870869                                        ieee80211_add_wds_addr(nt, ni, eh.ether_shost, 0); 
    871870                        } 
     
    17191718                __func__, __LINE__, 
    17201719                ni, ether_sprintf(ni->ni_macaddr), 
    17211720                ieee80211_node_refcnt(ni) + 1); 
    1722         ieee80211_ref_node(ni); 
    17231721 
    17241722        /* 
    17251723         * prreq frame format 
     
    17351733               vap->app_ie[IEEE80211_APPIE_FRAME_PROBE_REQ].length); 
    17361734        if (skb == NULL) { 
    17371735                vap->iv_stats.is_tx_nobuf++; 
    1738                 ieee80211_free_node(ni); 
    17391736                return -ENOMEM; 
    17401737        } 
    17411738 
     
    17581755        skb_trim(skb, frm - skb->data); 
    17591756 
    17601757        cb = (struct ieee80211_cb *)skb->cb; 
    1761         cb->ni = ni
     1758        cb->ni = ieee80211_ref_node(ni)
    17621759 
    17631760        wh = (struct ieee80211_frame *) 
    17641761                skb_push(skb, sizeof(struct ieee80211_frame)); 
     
    22332230                mod_timer(&vap->iv_mgtsend, jiffies + timer * HZ); 
    22342231        return 0; 
    22352232bad: 
    2236         ieee80211_free_node(ni); 
     2233        ieee80211_unref_node(&ni); 
    22372234        return ret; 
    22382235#undef senderr 
    22392236} 
  • net80211/ieee80211_power.c

    old new  
    109109int 
    110110ieee80211_node_saveq_drain(struct ieee80211_node *ni) 
    111111{ 
     112        struct ieee80211_cb *cb = NULL; 
    112113        struct sk_buff *skb; 
    113114        int qlen; 
    114115 
    115116        IEEE80211_NODE_SAVEQ_LOCK(ni); 
    116117        qlen = skb_queue_len(&ni->ni_savedq); 
    117118        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); 
    119121                dev_kfree_skb_any(skb); 
    120122        } 
    121123        IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
  • net80211/ieee80211_var.h

    old new  
    3737/* 
    3838 * Definitions for IEEE 802.11 drivers. 
    3939 */ 
    40 #define IEEE80211_DEBUG 
    41 #undef  IEEE80211_DEBUG_REFCNT                  /* node refcnt stuff */ 
     40#include <net80211/ieee80211_debug.h> 
    4241 
    4342#include <net80211/ieee80211_linux.h> 
    4443 
     
    230229        /* new station association callback/notification */ 
    231230        void (*ic_newassoc)(struct ieee80211_node *, int); 
    232231        /* 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 *); 
    235233        void (*ic_node_free)(struct ieee80211_node *); 
    236234        void (*ic_node_cleanup)(struct ieee80211_node *); 
    237235        u_int8_t (*ic_node_getrssi)(const struct ieee80211_node *); 
     
    406404        u_int32_t app_filter;                   /* filters which management frames are forwarded to app */ 
    407405 
    408406}; 
     407 
     408static __inline int ieee80211_is_printed(struct ieee80211vap *vap, unsigned m) 
     409{ 
     410        return !!(vap->iv_debug & m); 
     411} 
     412 
    409413MALLOC_DECLARE(M_80211_VAP); 
    410414 
    411415#define IEEE80211_ADDR_NULL(a1)         (memcmp(a1, "\x00\x00\x00\x00\x00\x00", \ 
     
    613617                size = roundup(size, sizeof(u_int32_t)); 
    614618        return size; 
    615619} 
    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_DEBUG 
    646 #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  
    691620#endif /* _NET80211_IEEE80211_VAR_H_ */ 
  • net80211/ieee80211_proto.c

    old new  
    14561456                                 */                              
    14571457                                if (vap->iv_opmode == IEEE80211_M_WDS) { 
    14581458                                        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); 
    14601460                                        if (wds_ni != NULL) { 
    14611461                                                if (ieee80211_add_wds_addr(&ic->ic_sta, wds_ni, vap->wds_mac, 1) == 0) { 
    14621462                                                        ieee80211_node_authorize(wds_ni); 
  • net80211/ieee80211_linux.h

    old new  
    6363 
    6464#define IEEE80211_RESCHEDULE    schedule 
    6565 
     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 
    6672/* 
    6773 * Beacon handler locking definitions. 
    6874 * Beacon locking  
     
    8591#define IEEE80211_LOCK(_ic)     spin_lock(&(_ic)->ic_comlock) 
    8692#define IEEE80211_UNLOCK(_ic)   spin_unlock(&(_ic)->ic_comlock) 
    8793 
    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) 
    9095#define IEEE80211_LOCK_ASSERT(_ic) \ 
    9196        KASSERT(spin_is_locked(&(_ic)->ic_comlock),("ieee80211com not locked!")) 
    9297#else 
    9398#define IEEE80211_LOCK_ASSERT(_ic) 
    9499#endif 
    95100 
     101 
    96102#define IEEE80211_VAPS_LOCK_INIT(_ic, _name)            \ 
    97103        spin_lock_init(&(_ic)->ic_vapslock) 
    98104#define IEEE80211_VAPS_LOCK_DESTROY(_ic) 
     
    108114} while (0) 
    109115#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic)    spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags) 
    110116 
    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) 
    114118#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!")) 
    116121#else 
    117122#define IEEE80211_VAPS_LOCK_ASSERT(_ic) 
    118123#endif 
     
    121126/* 
    122127 * Node locking definitions. 
    123128 */ 
     129#if 0 
     130 
    124131typedef 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 {    \ 
    132141        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 */ 
     162typedef 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 {    \ 
     172        unsigned long __node_lockflags;         \ 
    133173        spin_lock_irqsave(&(_nt)->nt_nodelock, __node_lockflags); 
    134 #define IEEE80211_NODE_UNLOCK_IRQ(_nt)                \ 
     174#define IEEE80211_NODE_TABLE_UNLOCK_IRQ(_nt)          \ 
    135175        spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); \ 
    136176} while(0) 
    137 #define IEEE80211_NODE_UNLOCK_IRQ_EARLY(_nt)          \ 
     177#define IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(_nt)            \ 
    138178        spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); 
    139179 
    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), \ 
    144183                ("802.11 node table not locked!")) 
    145184#else 
    146 #define IEEE80211_NODE_LOCK_ASSERT(_nt) 
     185#define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) 
    147186#endif 
    148187 
    149188/* 
     
    163202#define IEEE80211_SCAN_UNLOCK_IRQ_EARLY(_nt)            \ 
    164203        spin_unlock_irqrestore(&(_nt)->nt_scanlock, __scan_lockflags); 
    165204 
    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) 
    168206#define IEEE80211_SCAN_LOCK_ASSERT(_nt) \ 
    169207        KASSERT(spin_is_locked(&(_nt)->nt_scanlock), ("scangen not locked!")) 
    170208#else 
     
    182220#define ACL_LOCK_BH(_as)                spin_lock_bh(&(_as)->as_lock) 
    183221#define ACL_UNLOCK_BH(_as)              spin_unlock_bh(&(_as)->as_lock) 
    184222 
    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) 
    187224#define ACL_LOCK_ASSERT(_as) \ 
    188225        KASSERT(spin_is_locked(&(_as)->as_lock), ("ACL not locked!")) 
    189226#else 
     
    299336 *                              is the last reference, otherwise 0 
    300337 * ieee80211_node_refcnt        reference count for printing (only) 
    301338 */ 
     339typedef atomic_t ieee80211_node_ref_count_t;  
    302340#define ieee80211_node_initref(_ni)     atomic_set(&(_ni)->ni_refcnt, 1) 
    303341#define ieee80211_node_incref(_ni)      atomic_inc(&(_ni)->ni_refcnt) 
    304342#define ieee80211_node_decref(_ni)      atomic_dec(&(_ni)->ni_refcnt) 
     
    379417/* msecs_to_jiffies appeared in 2.6.7 and 2.4.29 */ 
    380418#include <linux/delay.h> 
    381419#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) 
    384422 
    385423/* The following definitions and inline functions are 
    386424 * copied from the kernel src, include/linux/jiffies.h */ 
  • ath/if_ath.c

    old new  
    159159static int ath_desc_alloc(struct ath_softc *); 
    160160static void ath_desc_free(struct ath_softc *); 
    161161static void ath_desc_swap(struct ath_desc *); 
    162 static struct ieee80211_node *ath_node_alloc(struct ieee80211_node_table *, 
    163         struct ieee80211vap *); 
     162static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *); 
    164163static void ath_node_cleanup(struct ieee80211_node *); 
    165164static void ath_node_free(struct ieee80211_node *); 
    166165static u_int8_t ath_node_getrssi(const struct ieee80211_node *); 
     
    24622461                if (ath_tx_start(sc->sc_dev, ni, bf_ff, bf_ff->bf_skb, 0) == 0) 
    24632462                        continue; 
    24642463        bad: 
    2465                 ieee80211_free_node(ni); 
     2464                ieee80211_unref_node(&ni); 
    24662465                if (bf_ff->bf_skb != NULL) { 
    24672466                        dev_kfree_skb(bf_ff->bf_skb); 
    24682467                        bf_ff->bf_skb = NULL; 
     
    26032602                        ATH_FF_MAGIC_PUT(skb); 
    26042603 
    26052604                        /* decrement extra node reference made when an_tx_ffbuf[] was set */ 
    2606                         //ieee80211_free_node(ni); /* XXX where was it set ? */ 
     2605                        //ieee80211_unref_node(&ni); /* XXX where was it set ? */ 
    26072606 
    26082607                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    26092608                                "%s: aggregating fast-frame\n", __func__); 
     
    26622661                ff_flushbad: 
    26632662                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    26642663                                "%s: ff stageq flush failure\n", __func__); 
    2665                         ieee80211_free_node(ni); 
     2664                        ieee80211_unref_node(&ni); 
    26662665                        if (bf_ff->bf_skb) { 
    26672666                                dev_kfree_skb(bf_ff->bf_skb); 
    26682667                                bf_ff->bf_skb = NULL; 
     
    27872786                        tbf->bf_node = NULL; 
    27882787                         
    27892788                        if (ni != NULL)  
    2790                                 ieee80211_free_node(ni); 
     2789                                ieee80211_unref_node(&ni); 
    27912790 
    27922791                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 
    27932792                } 
     
    28692868        /* fall thru... */ 
    28702869bad: 
    28712870        if (ni != NULL) 
    2872                 ieee80211_free_node(ni); 
     2871                ieee80211_unref_node(&ni); 
    28732872        if (bf != NULL) { 
    28742873                bf->bf_skb = NULL; 
    28752874                bf->bf_node = NULL; 
     
    32553254         */ 
    32563255        ni = sc->sc_keyixmap[keyix]; 
    32573256        if (ni != NULL) { 
    3258                 ieee80211_free_node(ni); 
     3257                ieee80211_unref_node(&ni); 
    32593258                sc->sc_keyixmap[keyix] = NULL; 
    32603259        } 
    32613260        /* 
     
    32663265                ath_hal_keyreset(ah, keyix + 32);       /* RX key */ 
    32673266                ni = sc->sc_keyixmap[keyix + 32]; 
    32683267                if (ni != NULL) {                       /* as above... */ 
    3269                         ieee80211_free_node(ni); 
     3268                        ieee80211_unref_node(&ni); 
    32703269                        sc->sc_keyixmap[keyix + 32] = NULL; 
    32713270                } 
    32723271        } 
     
    32793278                        ath_hal_keyreset(ah, keyix + rxkeyoff); 
    32803279                        ni = sc->sc_keyixmap[keyix + rxkeyoff]; 
    32813280                        if (ni != NULL) {       /* as above... */ 
    3282                                 ieee80211_free_node(ni); 
     3281                                ieee80211_unref_node(&ni); 
    32833282                                sc->sc_keyixmap[keyix + rxkeyoff] = NULL; 
    32843283                        } 
    32853284                } 
     
    38353834                dev_kfree_skb(bf->bf_skb); 
    38363835                bf->bf_skb = NULL; 
    38373836        } 
    3838         if (bf->bf_node != NULL) { 
    3839                 ieee80211_free_node(bf->bf_node); 
    3840                 bf->bf_node = NULL; 
    3841         } 
     3837        if (bf->bf_node != NULL) 
     3838                ieee80211_unref_node(&bf->bf_node); 
    38423839 
    38433840        /* 
    38443841         * NB: the beacon data buffer must be 32-bit aligned; 
     
    43824379                dev_kfree_skb(bf->bf_skb); 
    43834380                bf->bf_skb = NULL; 
    43844381        } 
    4385         if (bf->bf_node != NULL) { 
    4386                 ieee80211_free_node(bf->bf_node); 
    4387                 bf->bf_node = NULL; 
    4388         } 
     4382        if (bf->bf_node != NULL)  
     4383                ieee80211_unref_node(&bf->bf_node); 
    43894384        STAILQ_INSERT_TAIL(&sc->sc_bbuf, bf, bf_list); 
    43904385} 
    43914386 
     
    44044399                        dev_kfree_skb(bf->bf_skb); 
    44054400                        bf->bf_skb = NULL; 
    44064401                } 
    4407                 if (bf->bf_node != NULL) { 
    4408                         ieee80211_free_node(bf->bf_node); 
    4409                         bf->bf_node = NULL; 
    4410                 } 
     4402                if (bf->bf_node != NULL) 
     4403                        ieee80211_unref_node(&bf->bf_node); 
    44114404        } 
    44124405} 
    44134406 
     
    46924685                        /* 
    46934686                         * Reclaim node reference. 
    46944687                         */ 
    4695                         ieee80211_free_node(ni); 
     4688                        ieee80211_unref_node(&ni); 
    46964689                } 
    46974690        } 
    46984691 
     
    47514744} 
    47524745 
    47534746static struct ieee80211_node * 
    4754 ath_node_alloc(struct ieee80211_node_table *nt,struct ieee80211vap *vap) 
     4747ath_node_alloc(struct ieee80211vap *vap) 
    47554748{ 
    4756         struct ath_softc *sc = nt->nt_ic->ic_dev->priv; 
     4749        struct ath_softc *sc = vap->iv_ic->ic_dev->priv; 
    47574750        const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; 
    47584751        struct ath_node *an; 
    47594752 
    47604753        an = kmalloc(space, GFP_ATOMIC); 
    4761         if (an == NULL) 
     4754        if (an != NULL) { 
     4755                memset(an, 0, space); 
     4756                an->an_decomp_index = INVALID_DECOMP_INDEX; 
     4757                an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 
     4758                an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 
     4759                an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 
     4760                an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 
     4761                /* 
     4762                 * ath_rate_node_init needs a vap pointer in node 
     4763                 * to decide which mgt rate to use 
     4764                 */ 
     4765                an->an_node.ni_vap = vap; 
     4766                sc->sc_rc->ops->node_init(sc, an); 
     4767 
     4768                /* U-APSD init */ 
     4769                STAILQ_INIT(&an->an_uapsd_q); 
     4770                an->an_uapsd_qdepth = 0; 
     4771                STAILQ_INIT(&an->an_uapsd_overflowq); 
     4772                an->an_uapsd_overflowqdepth = 0; 
     4773                ATH_NODE_UAPSD_LOCK_INIT(an); 
     4774                 
     4775                DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 
     4776                return &an->an_node; 
     4777        } else { 
    47624778                return NULL; 
    4763         memset(an, 0, space); 
    4764         an->an_decomp_index = INVALID_DECOMP_INDEX; 
    4765         an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 
    4766         an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 
    4767         an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 
    4768         an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 
    4769         /* 
    4770          * ath_rate_node_init needs a VAP pointer in node 
    4771          * to decide which mgt rate to use 
    4772          */ 
    4773         an->an_node.ni_vap = vap; 
    4774         sc->sc_rc->ops->node_init(sc, an); 
    4775  
    4776         /* U-APSD init */ 
    4777         STAILQ_INIT(&an->an_uapsd_q); 
    4778         an->an_uapsd_qdepth = 0; 
    4779         STAILQ_INIT(&an->an_uapsd_overflowq); 
    4780         an->an_uapsd_overflowqdepth = 0; 
    4781         ATH_NODE_UAPSD_LOCK_INIT(an); 
    4782  
    4783         DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 
    4784         return &an->an_node; 
     4779        } 
    47854780} 
    47864781 
    47874782static void 
     
    47914786        struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 
    47924787        struct ath_node *an = ATH_NODE(ni); 
    47934788        struct ath_buf *bf; 
     4789        struct ieee80211_cb *cb = NULL; 
    47944790         
    47954791        /* 
    47964792         * U-APSD cleanup 
     
    48054801        while (an->an_uapsd_qdepth) { 
    48064802                bf = STAILQ_FIRST(&an->an_uapsd_q); 
    48074803                STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 
    4808                 bf->bf_desc->ds_link = (u_int32_t)NULL; 
    48094804 
     4805                cb = (struct ieee80211_cb *) bf->bf_skb->cb; 
     4806                ieee80211_unref_node(&cb->ni); 
    48104807                dev_kfree_skb_any(bf->bf_skb); 
     4808 
     4809                bf->bf_desc->ds_link = 0; 
    48114810                bf->bf_skb = NULL; 
    48124811                bf->bf_node = NULL; 
     4812 
    48134813                ATH_TXBUF_LOCK_IRQ(sc); 
    48144814                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    48154815                ATH_TXBUF_UNLOCK_IRQ(sc); 
    4816                 ieee80211_free_node(ni); 
    48174816 
    48184817                an->an_uapsd_qdepth--; 
    48194818        } 
     
    48214820        while (an->an_uapsd_overflowqdepth) { 
    48224821                bf = STAILQ_FIRST(&an->an_uapsd_overflowq); 
    48234822                STAILQ_REMOVE_HEAD(&an->an_uapsd_overflowq, bf_list); 
    4824                 bf->bf_desc->ds_link = (u_int32_t)NULL; 
    48254823 
     4824                cb = (struct ieee80211_cb *) bf->bf_skb->cb; 
     4825                ieee80211_unref_node(&cb->ni); 
    48264826                dev_kfree_skb_any(bf->bf_skb); 
     4827 
    48274828                bf->bf_skb = NULL; 
    48284829                bf->bf_node = NULL; 
     4830                bf->bf_desc->ds_link = 0; 
     4831                 
    48294832                ATH_TXBUF_LOCK_IRQ(sc); 
    48304833                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    48314834                ATH_TXBUF_UNLOCK_IRQ(sc); 
    4832                 ieee80211_free_node(ni); 
    48334835 
    48344836                an->an_uapsd_overflowqdepth--; 
    48354837        } 
    48364838 
     4839        // Clean up node-specific rate things - this currently appears to always be a no-op 
     4840        sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); 
     4841 
    48374842        ATH_NODE_UAPSD_LOCK_IRQ(an); 
    48384843        sc->sc_node_cleanup(ni); 
    48394844        ATH_NODE_UAPSD_UNLOCK_IRQ(an); 
     
    48444849{ 
    48454850        struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 
    48464851 
    4847         sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); 
    48484852        sc->sc_node_free(ni); 
    48494853#ifdef ATH_SUPERG_XR 
    48504854        ath_grppoll_period_update(sc); 
     
    57275731                        ATH_RSSI_LPF(an->an_avgrssi, ds->ds_rxstat.rs_rssi); 
    57285732                        type = ieee80211_input(ni, skb, 
    57295733                                ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); 
    5730                         ieee80211_free_node(ni); 
     5734                        ieee80211_unref_node(&ni); 
    57315735                } else { 
    57325736                        /* 
    57335737                         * No key index or no entry, do a lookup and 
     
    57525756                                if (keyix != IEEE80211_KEYIX_NONE && 
    57535757                                    sc->sc_keyixmap[keyix] == NULL) 
    57545758                                        sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni); 
    5755                                 ieee80211_free_node(ni);  
     5759                                ieee80211_unref_node(&ni);  
    57565760                        } else 
    57575761                                type = ieee80211_input_all(ic, skb, 
    57585762                                        ds->ds_rxstat.rs_rssi, 
     
    65526556                STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 
    65536557                dev_kfree_skb(lastbuf->bf_skb); 
    65546558                lastbuf->bf_skb = NULL; 
    6555                 ieee80211_free_node(lastbuf->bf_node); 
    6556                 lastbuf->bf_node = NULL; 
     6559                ieee80211_unref_node(&lastbuf->bf_node); 
    65576560                ATH_TXBUF_LOCK_IRQ(sc); 
    65586561                STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list); 
    65596562                ATH_TXBUF_UNLOCK_IRQ(sc); 
     
    73047307                         *     this is a DEAUTH message that was sent and the 
    73057308                         *     node was timed out due to inactivity. 
    73067309                         */ 
    7307                          ieee80211_free_node(ni);  
     7310                         ieee80211_unref_node(&ni);  
    73087311                } 
    73097312 
    73107313                bus_unmap_single(sc->sc_bdev, bf->bf_skbaddr,  
     
    75527555                } 
    75537556#endif /* ATH_SUPERG_FF */ 
    75547557                if (bf->bf_node) 
    7555                         ieee80211_free_node(bf->bf_node); 
     7558                        ieee80211_unref_node(&bf->bf_node); 
    75567559 
    75577560                bf->bf_skb = NULL; 
    75587561                bf->bf_node = NULL;