Deleted Added
full compact
ieee80211_node.c (179640) ieee80211_node.c (179641)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2008 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-2008 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 179640 2008-06-07 17:43:41Z sam $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 179641 2008-06-07 17:50:24Z 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>

--- 1440 unchanged lines hidden (view full) ---

1477 }
1478 }
1479 return ni;
1480}
1481
1482static void
1483_ieee80211_free_node(struct ieee80211_node *ni)
1484{
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>

--- 1440 unchanged lines hidden (view full) ---

1477 }
1478 }
1479 return ni;
1480}
1481
1482static void
1483_ieee80211_free_node(struct ieee80211_node *ni)
1484{
1485 struct ieee80211vap *vap = ni->ni_vap;
1486 struct ieee80211_node_table *nt = ni->ni_table;
1487
1485 struct ieee80211_node_table *nt = ni->ni_table;
1486
1487 /*
1488 * NB: careful about referencing the vap as it may be
1489 * gone if the last reference was held by a driver.
1490 * We know the com will always be present so it's safe
1491 * to use ni_ic below to reclaim resources.
1492 */
1493#if 0
1488 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
1489 "%s %p<%s> in %s table\n", __func__, ni,
1490 ether_sprintf(ni->ni_macaddr),
1491 nt != NULL ? nt->nt_name : "<gone>");
1494 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
1495 "%s %p<%s> in %s table\n", __func__, ni,
1496 ether_sprintf(ni->ni_macaddr),
1497 nt != NULL ? nt->nt_name : "<gone>");
1492
1493 if (vap->iv_aid_bitmap != NULL)
1494 IEEE80211_AID_CLR(vap, ni->ni_associd);
1498#endif
1499 if (ni->ni_associd != 0) {
1500 struct ieee80211vap *vap = ni->ni_vap;
1501 if (vap->iv_aid_bitmap != NULL)
1502 IEEE80211_AID_CLR(vap, ni->ni_associd);
1503 }
1495 if (nt != NULL) {
1496 TAILQ_REMOVE(&nt->nt_node, ni, ni_list);
1497 LIST_REMOVE(ni, ni_hash);
1498 }
1504 if (nt != NULL) {
1505 TAILQ_REMOVE(&nt->nt_node, ni, ni_list);
1506 LIST_REMOVE(ni, ni_hash);
1507 }
1499 vap->iv_ic->ic_node_free(ni);
1508 ni->ni_ic->ic_node_free(ni);
1500}
1501
1502void
1503#ifdef IEEE80211_DEBUG_REFCNT
1504ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line)
1505#else
1506ieee80211_free_node(struct ieee80211_node *ni)
1507#endif

--- 38 unchanged lines hidden (view full) ---

1546}
1547
1548/*
1549 * Reclaim a unicast key and clear any key cache state.
1550 */
1551int
1552ieee80211_node_delucastkey(struct ieee80211_node *ni)
1553{
1509}
1510
1511void
1512#ifdef IEEE80211_DEBUG_REFCNT
1513ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line)
1514#else
1515ieee80211_free_node(struct ieee80211_node *ni)
1516#endif

--- 38 unchanged lines hidden (view full) ---

1555}
1556
1557/*
1558 * Reclaim a unicast key and clear any key cache state.
1559 */
1560int
1561ieee80211_node_delucastkey(struct ieee80211_node *ni)
1562{
1554 struct ieee80211vap *vap = ni->ni_vap;
1555 /* XXX is ni_table safe? */
1556 struct ieee80211_node_table *nt = &ni->ni_ic->ic_sta;
1563 struct ieee80211com *ic = ni->ni_ic;
1564 struct ieee80211_node_table *nt = &ic->ic_sta;
1557 struct ieee80211_node *nikey;
1558 ieee80211_keyix keyix;
1559 int isowned, status;
1560
1561 /*
1562 * NB: We must beware of LOR here; deleting the key
1563 * can cause the crypto layer to block traffic updates
1564 * which can generate a LOR against the node table lock;
1565 * grab it here and stash the key index for our use below.
1566 *
1567 * Must also beware of recursion on the node table lock.
1568 * When called from node_cleanup we may already have
1569 * the node table lock held. Unfortunately there's no
1570 * way to separate out this path so we must do this
1571 * conditionally.
1572 */
1573 isowned = IEEE80211_NODE_IS_LOCKED(nt);
1574 if (!isowned)
1575 IEEE80211_NODE_LOCK(nt);
1565 struct ieee80211_node *nikey;
1566 ieee80211_keyix keyix;
1567 int isowned, status;
1568
1569 /*
1570 * NB: We must beware of LOR here; deleting the key
1571 * can cause the crypto layer to block traffic updates
1572 * which can generate a LOR against the node table lock;
1573 * grab it here and stash the key index for our use below.
1574 *
1575 * Must also beware of recursion on the node table lock.
1576 * When called from node_cleanup we may already have
1577 * the node table lock held. Unfortunately there's no
1578 * way to separate out this path so we must do this
1579 * conditionally.
1580 */
1581 isowned = IEEE80211_NODE_IS_LOCKED(nt);
1582 if (!isowned)
1583 IEEE80211_NODE_LOCK(nt);
1576 keyix = ni->ni_ucastkey.wk_rxkeyix;
1577 status = ieee80211_crypto_delkey(vap, &ni->ni_ucastkey);
1578 if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax) {
1579 nikey = nt->nt_keyixmap[keyix];
1580 nt->nt_keyixmap[keyix] = NULL;;
1581 } else
1582 nikey = NULL;
1584 nikey = NULL;
1585 status = 1; /* NB: success */
1586 if (!IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) {
1587 keyix = ni->ni_ucastkey.wk_rxkeyix;
1588 status = ieee80211_crypto_delkey(ni->ni_vap, &ni->ni_ucastkey);
1589 if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax) {
1590 nikey = nt->nt_keyixmap[keyix];
1591 nt->nt_keyixmap[keyix] = NULL;;
1592 }
1593 }
1583 if (!isowned)
1584 IEEE80211_NODE_UNLOCK(nt);
1585
1586 if (nikey != NULL) {
1587 KASSERT(nikey == ni,
1588 ("key map out of sync, ni %p nikey %p", ni, nikey));
1594 if (!isowned)
1595 IEEE80211_NODE_UNLOCK(nt);
1596
1597 if (nikey != NULL) {
1598 KASSERT(nikey == ni,
1599 ("key map out of sync, ni %p nikey %p", ni, nikey));
1589 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
1600 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
1590 "%s: delete key map entry %p<%s> refcnt %d\n",
1591 __func__, ni, ether_sprintf(ni->ni_macaddr),
1592 ieee80211_node_refcnt(ni)-1);
1593 ieee80211_free_node(ni);
1594 }
1595 return status;
1596}
1597

--- 885 unchanged lines hidden ---
1601 "%s: delete key map entry %p<%s> refcnt %d\n",
1602 __func__, ni, ether_sprintf(ni->ni_macaddr),
1603 ieee80211_node_refcnt(ni)-1);
1604 ieee80211_free_node(ni);
1605 }
1606 return status;
1607}
1608

--- 885 unchanged lines hidden ---