PERFORCE change 134240 for review

Sam Leffler sam at FreeBSD.org
Sun Jan 27 13:00:42 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=134240

Change 134240 by sam at sam_ebb on 2008/01/27 21:00:39

	Add ieee80211_find_vap_node to lookup a station by (address+vap)
	and use it anywhere that a sta vap might be involved.  This is
	needed to support multiple sta vaps associated to the same ap.
	
	While here use the new function to replace equivalent inline code.

Affected files ...

.. //depot/projects/vap/sys/net80211/ieee80211_hostap.c#9 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#25 edit
.. //depot/projects/vap/sys/net80211/ieee80211_node.c#24 edit
.. //depot/projects/vap/sys/net80211/ieee80211_node.h#16 edit

Differences ...

==== //depot/projects/vap/sys/net80211/ieee80211_hostap.c#9 (text+ko) ====

@@ -332,11 +332,10 @@
 			 * sending it will not work; just let it be delivered
 			 * normally.
 			 */
-			struct ieee80211_node *sta = ieee80211_find_node(
-			     &vap->iv_ic->ic_sta, eh->ether_dhost);
+			struct ieee80211_node *sta = ieee80211_find_vap_node(
+			     &vap->iv_ic->ic_sta, vap, eh->ether_dhost);
 			if (sta != NULL) {
-				if (sta->ni_vap == vap &&
-				    ieee80211_node_is_authorized(sta)) {
+				if (ieee80211_node_is_authorized(sta)) {
 					/*
 					 * Beware of sending to ourself; this
 					 * needs to happen via the normal

==== //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#25 (text+ko) ====

@@ -88,7 +88,7 @@
 		return error;
 	kid = ik.ik_keyix;
 	if (kid == IEEE80211_KEYIX_NONE) {
-		ni = ieee80211_find_node(&ic->ic_sta, ik.ik_macaddr);
+		ni = ieee80211_find_vap_node(&ic->ic_sta, vap, ik.ik_macaddr);
 		if (ni == NULL)
 			return ENOENT;
 		wk = &ni->ni_ucastkey;
@@ -163,7 +163,7 @@
 	error = copyin(ireq->i_data, wpaie.wpa_macaddr, IEEE80211_ADDR_LEN);
 	if (error != 0)
 		return error;
-	ni = ieee80211_find_node(&vap->iv_ic->ic_sta, wpaie.wpa_macaddr);
+	ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, wpaie.wpa_macaddr);
 	if (ni == NULL)
 		return ENOENT;
 	memset(wpaie.wpa_ie, 0, sizeof(wpaie.wpa_ie));
@@ -212,7 +212,7 @@
 	error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
 	if (error != 0)
 		return error;
-	ni = ieee80211_find_node(&vap->iv_ic->ic_sta, macaddr);
+	ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr);
 	if (ni == NULL)
 		return ENOENT;
 	if (ireq->i_len > sizeof(struct ieee80211req_sta_stats))
@@ -487,7 +487,7 @@
 	if (IEEE80211_ADDR_EQ(macaddr, vap->iv_ifp->if_broadcastaddr)) {
 		ni = NULL;
 	} else {
-		ni = ieee80211_find_node(&vap->iv_ic->ic_sta, macaddr);
+		ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr);
 		if (ni == NULL)
 			return ENOENT;
 	}
@@ -506,7 +506,7 @@
 	error = copyin(ireq->i_data, &txpow, sizeof(txpow));
 	if (error != 0)
 		return error;
-	ni = ieee80211_find_node(&vap->iv_ic->ic_sta, txpow.it_macaddr);
+	ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, txpow.it_macaddr);
 	if (ni == NULL)
 		return ENOENT;
 	txpow.it_txpow = ni->ni_txpower;
@@ -1068,7 +1068,7 @@
 				return EADDRNOTAVAIL;
 			}
 		} else {
-			ni = ieee80211_find_node(&vap->iv_ic->ic_sta,
+			ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap,
 				ik.ik_macaddr);
 			if (ni == NULL)
 				return ENOENT;
@@ -1134,7 +1134,7 @@
 				return EADDRNOTAVAIL;
 			}
 		} else {
-			ni = ieee80211_find_node(&vap->iv_ic->ic_sta,
+			ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap,
 				dk.idk_macaddr);
 			if (ni == NULL)
 				return ENOENT;
@@ -1254,7 +1254,7 @@
 			break;
 		}
 		IEEE80211_NODE_LOCK(&ic->ic_sta);
-		ni = ieee80211_find_node(&ic->ic_sta, mac);
+		ni = ieee80211_find_vap_node(&ic->ic_sta, vap, mac);
 		if (ni != NULL) {
 			IEEE80211_NOTE(vap,
 			    IEEE80211_MSG_IOCTL | IEEE80211_MSG_AUTH,
@@ -1275,7 +1275,7 @@
 			break;
 		}
 		IEEE80211_NODE_LOCK(&ic->ic_sta);
-		ni = ieee80211_find_node(&ic->ic_sta, mac);
+		ni = ieee80211_find_vap_node(&ic->ic_sta, vap, mac);
 		if (ni != NULL) {
 			if (reason == IEEE80211_STATUS_SUCCESS) {
 				IEEE80211_SEND_MGMT(ni,
@@ -1506,7 +1506,7 @@
 	error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
 	if (error != 0)
 		return error;
-	ni = ieee80211_find_node(&vap->iv_ic->ic_sta, macaddr);
+	ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, macaddr);
 	if (ni == NULL)
 		return ENOENT;
 	/* XXX require ni_vap == vap? */
@@ -1527,7 +1527,7 @@
 	error = copyin(ireq->i_data, &txpow, sizeof(txpow));
 	if (error != 0)
 		return error;
-	ni = ieee80211_find_node(&vap->iv_ic->ic_sta, txpow.it_macaddr);
+	ni = ieee80211_find_vap_node(&vap->iv_ic->ic_sta, vap, txpow.it_macaddr);
 	if (ni == NULL)
 		return ENOENT;
 	ni->ni_txpower = txpow.it_txpow;

==== //depot/projects/vap/sys/net80211/ieee80211_node.c#24 (text+ko) ====

@@ -200,6 +200,7 @@
 /*
  * Set/change the channel.  The rate set is also updated as
  * to insure a consistent view by drivers.
+ * XXX should be private but hostap needs it to deal with CSA
  */
 void
 ieee80211_node_set_chan(struct ieee80211_node *ni,
@@ -1122,6 +1123,59 @@
 	return ni;
 }
 
+struct ieee80211_node *
+#ifdef IEEE80211_DEBUG_REFCNT
+ieee80211_find_vap_node_locked_debug(struct ieee80211_node_table *nt,
+	const struct ieee80211vap *vap,
+	const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
+#else
+ieee80211_find_vap_node_locked(struct ieee80211_node_table *nt,
+	const struct ieee80211vap *vap,
+	const uint8_t macaddr[IEEE80211_ADDR_LEN])
+#endif
+{
+	struct ieee80211_node *ni;
+	int hash;
+
+	IEEE80211_NODE_LOCK_ASSERT(nt);
+
+	hash = IEEE80211_NODE_HASH(macaddr);
+	LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
+		if (ni->ni_vap == vap &&
+		    IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
+			ieee80211_ref_node(ni);	/* mark referenced */
+#ifdef IEEE80211_DEBUG_REFCNT
+			IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
+			    "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
+			    func, line,
+			    ni, ether_sprintf(ni->ni_macaddr),
+			    ieee80211_node_refcnt(ni));
+#endif
+			return ni;
+		}
+	}
+	return NULL;
+}
+
+struct ieee80211_node *
+#ifdef IEEE80211_DEBUG_REFCNT
+ieee80211_find_vap_node_debug(struct ieee80211_node_table *nt,
+	const struct ieee80211vap *vap,
+	const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
+#else
+ieee80211_find_vap_node(struct ieee80211_node_table *nt,
+	const struct ieee80211vap *vap,
+	const uint8_t macaddr[IEEE80211_ADDR_LEN])
+#endif
+{
+	struct ieee80211_node *ni;
+
+	IEEE80211_NODE_LOCK(nt);
+	ni = ieee80211_find_vap_node_locked(nt, vap, macaddr);
+	IEEE80211_NODE_UNLOCK(nt);
+	return ni;
+}
+
 /*
  * Fake up a node; this handles node discovery in adhoc mode.
  * Note that for the driver's benefit we we treat this like

==== //depot/projects/vap/sys/net80211/ieee80211_node.h#16 (text+ko) ====

@@ -326,6 +326,16 @@
 struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *,
 		const uint8_t macaddr[IEEE80211_ADDR_LEN],
 		const char *func, int line);
+struct ieee80211_node *ieee80211_find_vap_node_locked_debug(
+		struct ieee80211_node_table *,
+		const struct ieee80211vap *vap,
+		const uint8_t macaddr[IEEE80211_ADDR_LEN],
+		const char *func, int line);
+struct ieee80211_node *ieee80211_find_vap_node_debug(
+		struct ieee80211_node_table *,
+		const struct ieee80211vap *vap,
+		const uint8_t macaddr[IEEE80211_ADDR_LEN],
+		const char *func, int line);
 struct ieee80211_node * ieee80211_find_rxnode_debug(struct ieee80211com *,
 		const struct ieee80211_frame_min *,
 		const char *func, int line);
@@ -342,6 +352,10 @@
 	ieee80211_find_node_locked_debug(nt, mac, __func__, __LINE__)
 #define	ieee80211_find_node(nt, mac) \
 	ieee80211_find_node_debug(nt, mac, __func__, __LINE__)
+#define	ieee80211_find_vap_node_locked(nt, vap, mac) \
+	ieee80211_find_vap_node_locked_debug(nt, vap, mac, __func__, __LINE__)
+#define	ieee80211_find_vap_node(nt, vap, mac) \
+	ieee80211_find_vap_node_debug(nt, vap, mac, __func__, __LINE__)
 #define	ieee80211_find_rxnode(ic, wh) \
 	ieee80211_find_rxnode_debug(ic, wh, __func__, __LINE__)
 #define	ieee80211_find_rxnode_withkey(ic, wh, keyix) \
@@ -354,6 +368,12 @@
 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
 struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *,
 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
+struct ieee80211_node *ieee80211_find_vap_node_locked(
+		struct ieee80211_node_table *, const struct ieee80211vap *,
+		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
+struct ieee80211_node *ieee80211_find_vap_node(
+		struct ieee80211_node_table *, const struct ieee80211vap *,
+		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
 struct ieee80211_node * ieee80211_find_rxnode(struct ieee80211com *,
 		const struct ieee80211_frame_min *);
 struct ieee80211_node * ieee80211_find_rxnode_withkey(struct ieee80211com *,


More information about the p4-projects mailing list