ieee80211_node.c (188494) | ieee80211_node.c (188541) |
---|---|
1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2009 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: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2009 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: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 188494 2009-02-11 18:40:09Z sam $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 188541 2009-02-12 23:34:58Z sam $"); |
29 30#include "opt_wlan.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/mbuf.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 45 unchanged lines hidden (view full) --- 82 83static void _ieee80211_free_node(struct ieee80211_node *); 84 85static void ieee80211_node_table_init(struct ieee80211com *ic, 86 struct ieee80211_node_table *nt, const char *name, 87 int inact, int keymaxix); 88static void ieee80211_node_table_reset(struct ieee80211_node_table *, 89 struct ieee80211vap *); | 29 30#include "opt_wlan.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/mbuf.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 45 unchanged lines hidden (view full) --- 82 83static void _ieee80211_free_node(struct ieee80211_node *); 84 85static void ieee80211_node_table_init(struct ieee80211com *ic, 86 struct ieee80211_node_table *nt, const char *name, 87 int inact, int keymaxix); 88static void ieee80211_node_table_reset(struct ieee80211_node_table *, 89 struct ieee80211vap *); |
90static void ieee80211_node_reclaim(struct ieee80211_node *); | |
91static void ieee80211_node_table_cleanup(struct ieee80211_node_table *nt); 92static void ieee80211_erp_timeout(struct ieee80211com *); 93 94MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state"); 95MALLOC_DEFINE(M_80211_NODE_IE, "80211nodeie", "802.11 node ie"); 96 97void 98ieee80211_node_attach(struct ieee80211com *ic) --- 570 unchanged lines hidden (view full) --- 669 * case we can reassociate when operating in sta mode. 670 */ 671 canreassoc = (obss != NULL && 672 vap->iv_state == IEEE80211_S_RUN && 673 IEEE80211_ADDR_EQ(obss->ni_macaddr, selbs->ni_macaddr)); 674 vap->iv_bss = selbs; /* NB: caller assumed to bump refcnt */ 675 if (obss != NULL) { 676 copy_bss(selbs, obss); | 90static void ieee80211_node_table_cleanup(struct ieee80211_node_table *nt); 91static void ieee80211_erp_timeout(struct ieee80211com *); 92 93MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state"); 94MALLOC_DEFINE(M_80211_NODE_IE, "80211nodeie", "802.11 node ie"); 95 96void 97ieee80211_node_attach(struct ieee80211com *ic) --- 570 unchanged lines hidden (view full) --- 668 * case we can reassociate when operating in sta mode. 669 */ 670 canreassoc = (obss != NULL && 671 vap->iv_state == IEEE80211_S_RUN && 672 IEEE80211_ADDR_EQ(obss->ni_macaddr, selbs->ni_macaddr)); 673 vap->iv_bss = selbs; /* NB: caller assumed to bump refcnt */ 674 if (obss != NULL) { 675 copy_bss(selbs, obss); |
677 ieee80211_node_reclaim(obss); | 676 ieee80211_node_decref(obss); /* iv_bss reference */ 677 ieee80211_free_node(obss); /* station table reference */ |
678 obss = NULL; /* NB: guard against later use */ 679 } 680 681 /* 682 * Delete unusable rates; we've already checked 683 * that the negotiated rate set is acceptable. 684 */ 685 ieee80211_fix_rate(vap->iv_bss, &vap->iv_bss->ni_rates, --- 1048 unchanged lines hidden (view full) --- 1734 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 1735 LIST_REMOVE(ni, ni_hash); 1736 ni->ni_table = NULL; /* clear reference */ 1737 } else 1738 _ieee80211_free_node(ni); 1739} 1740 1741/* | 678 obss = NULL; /* NB: guard against later use */ 679 } 680 681 /* 682 * Delete unusable rates; we've already checked 683 * that the negotiated rate set is acceptable. 684 */ 685 ieee80211_fix_rate(vap->iv_bss, &vap->iv_bss->ni_rates, --- 1048 unchanged lines hidden (view full) --- 1734 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 1735 LIST_REMOVE(ni, ni_hash); 1736 ni->ni_table = NULL; /* clear reference */ 1737 } else 1738 _ieee80211_free_node(ni); 1739} 1740 1741/* |
1742 * Reclaim a (bss) node. Decrement the refcnt and reclaim 1743 * the node if the only other reference to it is in the sta 1744 * table. This is effectively ieee80211_free_node followed 1745 * by node_reclaim when the refcnt is 1 (after the free). 1746 */ 1747static void 1748ieee80211_node_reclaim(struct ieee80211_node *ni) 1749{ 1750 struct ieee80211_node_table *nt = ni->ni_table; 1751 1752 KASSERT(nt != NULL, ("reclaim node not in table")); 1753 1754#ifdef IEEE80211_DEBUG_REFCNT 1755 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 1756 "%s %p<%s> refcnt %d\n", __func__, ni, 1757 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)-1); 1758#endif 1759 IEEE80211_NODE_LOCK(nt); 1760 if (ieee80211_node_dectestref(ni)) { 1761 /* 1762 * Last reference, reclaim state. 1763 */ 1764 _ieee80211_free_node(ni); 1765 nt = NULL; 1766 } else if (ieee80211_node_refcnt(ni) == 1 && nt->nt_keyixmap != NULL) { 1767 ieee80211_keyix keyix; 1768 /* 1769 * Check for a last reference in the key mapping table. 1770 */ 1771 keyix = ni->ni_ucastkey.wk_rxkeyix; 1772 if (keyix < nt->nt_keyixmax && 1773 nt->nt_keyixmap[keyix] == ni) { 1774 IEEE80211_DPRINTF(ni->ni_vap, 1775 IEEE80211_MSG_NODE, 1776 "%s: %p<%s> clear key map entry %u", __func__, 1777 ni, ether_sprintf(ni->ni_macaddr), keyix); 1778 nt->nt_keyixmap[keyix] = NULL; 1779 ieee80211_node_decref(ni); /* XXX needed? */ 1780 _ieee80211_free_node(ni); 1781 nt = NULL; 1782 } 1783 } 1784 if (nt != NULL && ieee80211_node_refcnt(ni) == 1) { 1785 /* 1786 * Last reference is in the sta table; complete 1787 * the reclaim. This handles bss nodes being 1788 * recycled: the node has two references, one for 1789 * iv_bss and one for the table. After dropping 1790 * the iv_bss ref above we need to reclaim the sta 1791 * table reference. 1792 */ 1793 ieee80211_node_decref(ni); /* NB: be pendantic */ 1794 _ieee80211_free_node(ni); 1795 } 1796 IEEE80211_NODE_UNLOCK(nt); 1797} 1798 1799/* | |
1800 * Node table support. 1801 */ 1802 1803static void 1804ieee80211_node_table_init(struct ieee80211com *ic, 1805 struct ieee80211_node_table *nt, 1806 const char *name, int inact, int keyixmax) 1807{ --- 788 unchanged lines hidden --- | 1742 * Node table support. 1743 */ 1744 1745static void 1746ieee80211_node_table_init(struct ieee80211com *ic, 1747 struct ieee80211_node_table *nt, 1748 const char *name, int inact, int keyixmax) 1749{ --- 788 unchanged lines hidden --- |