[Madwifi-cvs] revision 1526 committed by dyqith
Status: Beta
Brought to you by:
otaku
From: dyqith <svn...@ma...> - 2006-04-23 23:54:50
|
Project : madwifi Revision : 1526 Author : dyqith Date : 2006-04-24 01:54:40 +0200 (Mon, 24 Apr 2006) Log Message : Fix some duplicate node errors by always finding old nodes before allocating. Signed-off-by: Daniel Wu <dy...@gm...> Affected Files: * trunk/ath/if_ath.c updated * trunk/net80211/ieee80211_input.c updated * trunk/net80211/ieee80211_node.c updated * trunk/net80211/ieee80211_output.c updated * trunk/net80211/ieee80211_wireless.c updated Modified: trunk/ath/if_ath.c =================================================================== --- trunk/ath/if_ath.c 2006-04-23 21:05:57 UTC (rev 1525) +++ trunk/ath/if_ath.c 2006-04-23 23:54:40 UTC (rev 1526) @@ -2552,7 +2552,7 @@ ATH_FF_MAGIC_PUT(skb); /* decrement extra node reference made when an_tx_ffbuf[] was set */ - ieee80211_free_node(ni); + //ieee80211_free_node(ni); /* XXX where was it set ? */ DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, "%s: aggregating fast-frame\n", __func__); @@ -2669,7 +2669,7 @@ else break; - ieee80211_node_incref(ni); + ieee80211_ref_node(ni); } if (bfcnt != framecnt) { @@ -2728,13 +2728,15 @@ STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) { tbf->bf_skb = NULL; tbf->bf_node = NULL; + + if (ni != NULL) + ieee80211_free_node(ni); + STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); - - if (ni != NULL) - ieee80211_free_node(ni); } ATH_TXBUF_UNLOCK(sc); } + /* free sk_buffs */ while (skb) { tskb = skb->next; @@ -5580,7 +5582,7 @@ if (keyix != IEEE80211_KEYIX_NONE && sc->sc_keyixmap[keyix] == NULL) sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni); - ieee80211_free_node(ni); + ieee80211_free_node(ni); } else type = ieee80211_input_all(ic, skb, ds->ds_rxstat.rs_rssi, @@ -6989,7 +6991,13 @@ return 0; } + + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: %p<%s> refcnt %d\n", + __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), + ieee80211_node_refcnt(vap->iv_bss)); + ath_tx_txqaddbuf(sc, ni, txq, bf, ds, pktlen); return 0; #undef MIN @@ -7123,7 +7131,7 @@ * this is a DEAUTH message that was sent and the * node was timed out due to inactivity. */ - ieee80211_free_node(ni); + ieee80211_free_node(ni); } bus_unmap_single(sc->sc_bdev, bf->bf_skbaddr, Modified: trunk/net80211/ieee80211_input.c =================================================================== --- trunk/net80211/ieee80211_input.c 2006-04-23 21:05:57 UTC (rev 1525) +++ trunk/net80211/ieee80211_input.c 2006-04-23 23:54:40 UTC (rev 1526) @@ -484,7 +484,7 @@ * reference to the previous station and add * reference to the new one */ - (void) ieee80211_remove_wds_addr(nt,wh4->i_addr4); + (void) ieee80211_remove_wds_addr(nt, wh4->i_addr4); ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); } if (ni_wds == NULL) @@ -1144,6 +1144,10 @@ ni = ieee80211_dup_bss(vap, wh->i_addr2); if (ni == NULL) return; + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); } IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, (seq + 1) | (IEEE80211_STATUS_ALG<<16)); @@ -1174,9 +1178,14 @@ } /* always accept open authentication requests */ if (ni == vap->iv_bss) { - ni = ieee80211_dup_bss(vap, wh->i_addr2); + ni = ieee80211_dup_bss(vap, wh->i_addr2); if (ni == NULL) return; + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); + } else if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) (void) ieee80211_ref_node(ni); /* @@ -1364,6 +1373,11 @@ /* NB: no way to return an error */ return; } + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); + allocbs = 1; } else { if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) Modified: trunk/net80211/ieee80211_node.c =================================================================== --- trunk/net80211/ieee80211_node.c 2006-04-23 21:05:57 UTC (rev 1525) +++ trunk/net80211/ieee80211_node.c 2006-04-23 23:54:40 UTC (rev 1526) @@ -107,6 +107,7 @@ { del_timer(&ic->ic_inact); ieee80211_node_table_cleanup(&ic->ic_sta); + } void @@ -260,11 +261,22 @@ "%s: creating ibss on channel %u\n", __func__, ieee80211_chan2ieee(ic, chan)); - ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); + /* Check to see if we already have a node for this mac */ + ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr); if (ni == NULL) { - /* XXX recovery? */ - return; + ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); + if (ni == NULL) { + /* XXX recovery? */ + return; + } } + else + ieee80211_free_node(ni); + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: %p<%s> refcnt %d\n", + __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), + ieee80211_node_refcnt(ni)); + IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_myaddr); ni->ni_esslen = vap->iv_des_ssid[0].len; memcpy(ni->ni_essid, vap->iv_des_ssid[0].ssid, ni->ni_esslen); @@ -347,8 +359,9 @@ struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni, *obss; - IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: old bss %p<%s>\n", - __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr)); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: old bss %p<%s> refcnt %d\n", + __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), + ieee80211_node_refcnt(vap->iv_bss)); ieee80211_node_table_reset(&ic->ic_sta, vap); /* XXX multi-bss wrong */ @@ -358,9 +371,15 @@ KASSERT(ni != NULL, ("unable to setup inital BSS node")); obss = vap->iv_bss; vap->iv_bss = ieee80211_ref_node(ni); + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: new bss %p<%s> refcnt %d\n", + __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), + ieee80211_node_refcnt(vap->iv_bss)); + if (obss != NULL) { copy_bss(ni, obss); ni->ni_intval = ic->ic_lintval; + ieee80211_free_node(obss); } } @@ -614,11 +633,15 @@ struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni; - ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr); + ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr); if (ni == NULL) { - /* XXX msg */ - return 0; - } + ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr); + if (ni == NULL) { + /* XXX msg */ + return 0; + } + } else + ieee80211_free_node(ni); /* * Expand scan state into node's format. @@ -656,7 +679,11 @@ ieee80211_setup_rates(ni, se->se_rates, se->se_xrates, IEEE80211_F_DOSORT); - return ieee80211_sta_join1(ni); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)+1); + + return ieee80211_sta_join1(ieee80211_ref_node(ni)); } EXPORT_SYMBOL(ieee80211_sta_join); @@ -708,6 +735,7 @@ MALLOC(ni, struct ieee80211_node *, sizeof(struct ieee80211_node), M_80211_NODE, M_NOWAIT | M_ZERO); + return ni; } @@ -824,7 +852,7 @@ int hash; int i; - ni = ic->ic_node_alloc(nt,vap); + ni = ic->ic_node_alloc(nt, vap); if (ni == NULL) { /* XXX msg */ vap->iv_stats.is_rx_nodealloc++; @@ -832,8 +860,9 @@ } IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, - "%s %p<%s> in %s table\n", __func__, ni, - ether_sprintf(macaddr), nt->nt_name); + "%s: %p<%s> in %s table, refcnt %d\n", __func__, ni, + ether_sprintf(macaddr), nt->nt_name, + ieee80211_node_refcnt(ni)+1); IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); hash = IEEE80211_NODE_HASH(macaddr); @@ -985,8 +1014,9 @@ ni = ic->ic_node_alloc(&ic->ic_sta,vap); if (ni != NULL) { - IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, - "%s %p<%s>\n", __func__, ni, ether_sprintf(macaddr)); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr), + ieee80211_node_refcnt(ni)+1); IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); @@ -1007,7 +1037,6 @@ ni->ni_rxfrag[i] = NULL; #undef N ni->ni_challenge = NULL; - } else { /* XXX msg */ vap->iv_stats.is_rx_nodealloc++; @@ -1148,6 +1177,8 @@ * Note that for the driver's benefit we we treat this like * an association so the driver has an opportunity to setup * it's private state. + * + * Caller must ieee80211_ref_node() */ struct ieee80211_node * ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, @@ -1163,6 +1194,10 @@ vap->iv_ic->ic_newassoc(ni, 1); /* XXX not right for 802.1x/WPA */ ieee80211_node_authorize(ni); + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr), + ieee80211_node_refcnt(ni)); } return ni; } @@ -1181,6 +1216,7 @@ struct ieee80211_node *ni; ni = ieee80211_dup_bss(vap, wh->i_addr2); /* XXX alloc_node? */ + /* TODO: not really putting itself in a table */ if (ni != NULL) { ni->ni_esslen = sp->ssid[1]; memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]); @@ -1209,6 +1245,10 @@ ic->ic_newassoc(ni, 1); /* XXX not right for 802.1x/WPA */ ieee80211_node_authorize(ni); + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); } return ni; } @@ -1321,9 +1361,11 @@ struct ieee80211_node_table *nt = ni->ni_table; IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, - "%s %p<%s> in %s table\n", __func__, ni, + "%s: %p<%s> in %s table, refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr), - nt != NULL ? nt->nt_name : "<gone>"); + nt != NULL ? nt->nt_name : "<gone>", + ieee80211_node_refcnt(ni)); + if (vap->iv_aid_bitmap != NULL) IEEE80211_AID_CLR(vap, ni->ni_associd); if (nt != NULL) { Modified: trunk/net80211/ieee80211_output.c =================================================================== --- trunk/net80211/ieee80211_output.c 2006-04-23 21:05:57 UTC (rev 1525) +++ trunk/net80211/ieee80211_output.c 2006-04-23 23:54:40 UTC (rev 1526) @@ -467,6 +467,12 @@ ieee80211_chan2ieee(ic, ic->ic_curchan), wh->i_fc[1] & IEEE80211_FC1_PWR_MGT ? "ena" : "dis"); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n", + __func__, __LINE__, + ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); + /* XXX assign some priority; this probably is wrong */ skb->priority = WME_AC_BE; @@ -533,6 +539,12 @@ M_FLAG_SET(skb, M_UAPSD); } + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n", + __func__, __LINE__, + ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); + (void) ic->ic_mgtstart(ic, skb); /* cheat */ return 0; @@ -1765,7 +1777,7 @@ "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n", __func__, __LINE__, ni, ether_sprintf(ni->ni_macaddr), - ieee80211_node_refcnt(ni)+1); + ieee80211_node_refcnt(ni) + 1); ieee80211_ref_node(ni); timer = 0; @@ -2152,6 +2164,12 @@ IEEE80211_FC0_SUBTYPE_PS_POLL; if (IEEE80211_VAP_IS_SLEEPING(ni->ni_vap)) wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT; + + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, + "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n", + __func__, __LINE__, + ni, ether_sprintf(ni->ni_macaddr), + ieee80211_node_refcnt(ni)); (void) ic->ic_mgtstart(ic, skb); /* cheat */ } Modified: trunk/net80211/ieee80211_wireless.c =================================================================== --- trunk/net80211/ieee80211_wireless.c 2006-04-23 21:05:57 UTC (rev 1525) +++ trunk/net80211/ieee80211_wireless.c 2006-04-23 23:54:40 UTC (rev 1526) @@ -1074,6 +1074,7 @@ /* locate a node, copy its rssi value, convert to dBm */ for (i = 0; i < number; i++) { ni = ieee80211_find_node(nt, &vap->iv_spy.mac[i * IEEE80211_ADDR_LEN]); + /* TODO: free node ? */ /* check we are associated w/ this vap */ if (ni && (ni->ni_vap == vap)) set_quality(&spy_stat[i], ni->ni_rssi); |