PERFORCE change 153247 for review

Sam Leffler sam at FreeBSD.org
Wed Nov 19 14:19:33 PST 2008


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

Change 153247 by sam at sam_ebb on 2008/11/19 22:19:05

	Cleanup definition and use of IEEE80211_CHAN_MAX:
	o make IEEE80211_CHAN_MAX be the max # of channels supported
	  by eliminating it's use as the max IEEE channel #; this
	  unfortunately is user-visible as it is used to size the
	  data block passed in to get the device capabilites
	o remove the code that tests if the channel # in the DSPARMS
	  ie is valid (testing against IEEE80211_CHAN_MAX); it was not
	  useful and was compiled out by default
	o fixup the set channel list ioctl to use channel array in
	  validating the passed in list instead of iterating over all
	  possible channels (eliminates a use of IEEE80211_CHAN_MAX)
	o fix scan code to not use IEEE80211_CHAN_MAX in sizing it's
	  rssi cache used to do ACS; this array is indexed by the IEEE
	  channel #
	o add asserts to the scan code to catch the unlikely event that
	  someone changes the definition of bchan s.t. it might cause
	  a bogus array index
	
	Note: this change requires ifconfig be recompiled

Affected files ...

.. //depot/projects/vap/sys/net80211/_ieee80211.h#13 edit
.. //depot/projects/vap/sys/net80211/ieee80211.c#54 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ddb.c#30 edit
.. //depot/projects/vap/sys/net80211/ieee80211_dfs.h#4 edit
.. //depot/projects/vap/sys/net80211/ieee80211_input.c#35 edit
.. //depot/projects/vap/sys/net80211/ieee80211_ioctl.c#69 edit
.. //depot/projects/vap/sys/net80211/ieee80211_regdomain.c#16 edit
.. //depot/projects/vap/sys/net80211/ieee80211_scan_sta.c#30 edit
.. //depot/projects/vap/sys/net80211/ieee80211_var.h#55 edit

Differences ...

==== //depot/projects/vap/sys/net80211/_ieee80211.h#13 (text+ko) ====

@@ -137,7 +137,7 @@
 	uint8_t		ic_extieee;	/* HT40 extension channel number */
 };
 
-#define	IEEE80211_CHAN_MAX	255
+#define	IEEE80211_CHAN_MAX	256
 #define	IEEE80211_CHAN_BYTES	32	/* howmany(IEEE80211_CHAN_MAX, NBBY) */
 #define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
 #define	IEEE80211_CHAN_ANYC \

==== //depot/projects/vap/sys/net80211/ieee80211.c#54 (text+ko) ====

@@ -118,7 +118,7 @@
 	struct ieee80211_channel *c;
 	int i;
 
-	KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX,
+	KASSERT(0 < ic->ic_nchans && ic->ic_nchans <= IEEE80211_CHAN_MAX,
 		("invalid number of channels specified: %u", ic->ic_nchans));
 	memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));
 	memset(ic->ic_modecaps, 0, sizeof(ic->ic_modecaps));
@@ -126,8 +126,6 @@
 	for (i = 0; i < ic->ic_nchans; i++) {
 		c = &ic->ic_channels[i];
 		KASSERT(c->ic_flags != 0, ("channel with no flags"));
-		KASSERT(c->ic_ieee < IEEE80211_CHAN_MAX,
-			("channel with bogus ieee number %u", c->ic_ieee));
 		setbit(ic->ic_chan_avail, c->ic_ieee);
 		/*
 		 * Identify mode capabilities.

==== //depot/projects/vap/sys/net80211/ieee80211_ddb.c#30 (text+ko) ====

@@ -540,7 +540,7 @@
 	 */
 	db_printf("\tnchans %d", ic->ic_nchans);
 #if 0
-	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1];
+	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX];
 	uint8_t			ic_chan_avail[IEEE80211_CHAN_BYTES];
 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
 	uint8_t			ic_chan_scan[IEEE80211_CHAN_BYTES];

==== //depot/projects/vap/sys/net80211/ieee80211_dfs.h#4 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 struct ieee80211_dfs_state {
-	int		nol_event[IEEE80211_CHAN_MAX+1];
+	int		nol_event[IEEE80211_CHAN_MAX];
 	struct callout	nol_timer;		/* NOL list processing */
 	struct callout	cac_timer;		/* CAC timer */
 	struct timeval	lastevent;		/* time of last radar event */

==== //depot/projects/vap/sys/net80211/ieee80211_input.c#35 (text+ko) ====

@@ -673,14 +673,6 @@
 	}
 	IEEE80211_VERIFY_ELEMENT(scan->ssid, IEEE80211_NWID_LEN,
 	    scan->status |= IEEE80211_BPARSE_SSID_INVALID);
-#if IEEE80211_CHAN_MAX < 255
-	if (scan->chan > IEEE80211_CHAN_MAX) {
-		IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID,
-		    wh, NULL, "invalid channel %u", scan->chan);
-		vap->iv_stats.is_rx_badchan++;
-		scan->status |= IEEE80211_BPARSE_CHAN_INVALID;
-	}
-#endif
 	if (scan->chan != scan->bchan && ic->ic_phytype != IEEE80211_T_FH) {
 		/*
 		 * Frame was received on a channel different from the

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

@@ -1556,7 +1556,7 @@
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ieee80211req_chanlist list;
 	u_char chanlist[IEEE80211_CHAN_BYTES];
-	int i, j, nchan, error;
+	int i, nchan, error;
 
 	if (ireq->i_len != sizeof(list))
 		return EINVAL;
@@ -1564,22 +1564,16 @@
 	if (error)
 		return error;
 	memset(chanlist, 0, sizeof(chanlist));
-	/*
-	 * Since channel 0 is not available for DS, channel 1
-	 * is assigned to LSB on WaveLAN.
-	 */
-	if (ic->ic_phytype == IEEE80211_T_DS)
-		i = 1;
-	else
-		i = 0;
 	nchan = 0;
-	for (j = 0; i <= IEEE80211_CHAN_MAX; i++, j++) {
+	for (i = 0; i < ic->ic_nchans; i++) {
+		const struct ieee80211_channel *c = &ic->ic_channels[i];
 		/*
-		 * NB: silently discard unavailable channels so users
-		 *     can specify 1-255 to get all available channels.
+		 * Calculate the intersection of the user list and the
+		 * available channels so users can do things like specify
+		 * 1-255 to get all available channels.
 		 */
-		if (isset(list.ic_channels, j) && isset(ic->ic_chan_avail, i)) {
-			setbit(chanlist, i);
+		if (isset(list.ic_channels, c->ic_ieee)) {
+			setbit(chanlist, c->ic_ieee);
 			nchan++;
 		}
 	}
@@ -1890,8 +1884,6 @@
 	if (ireq->i_val == 0 ||
 	    ireq->i_val == (int16_t) IEEE80211_CHAN_ANY) {
 		c = IEEE80211_CHAN_ANYC;
-	} else if ((u_int) ireq->i_val > IEEE80211_CHAN_MAX) {
-		return EINVAL;
 	} else {
 		struct ieee80211_channel *c2;
 

==== //depot/projects/vap/sys/net80211/ieee80211_regdomain.c#16 (text+ko) ====

@@ -338,7 +338,7 @@
 		    reg->rd.isocc[0], reg->rd.isocc[1]);
 		return EINVAL;
 	}
-	if (reg->chaninfo.ic_nchans >= IEEE80211_CHAN_MAX) {
+	if (reg->chaninfo.ic_nchans > IEEE80211_CHAN_MAX) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_IOCTL,
 		    "%s: too many channels %u, max %u\n", __func__,
 		    reg->chaninfo.ic_nchans, IEEE80211_CHAN_MAX);

==== //depot/projects/vap/sys/net80211/ieee80211_scan_sta.c#30 (text+ko) ====

@@ -87,6 +87,9 @@
 #define	STA_HASH(addr)	\
 	(((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % STA_HASHSIZE)
 
+#define	MAX_IEEE_CHAN	256			/* max acceptable IEEE chan # */
+CTASSERT(MAX_IEEE_CHAN >= 256);
+
 struct sta_table {
 	struct mtx	st_lock;		/* on scan table */
 	TAILQ_HEAD(, sta_entry) st_entry;	/* all entries */
@@ -96,7 +99,7 @@
 	u_int		st_scangen;		/* scan generation # */
 	int		st_newscan;
 	/* ap-related state */
-	int		st_maxrssi[IEEE80211_CHAN_MAX];
+	int		st_maxrssi[MAX_IEEE_CHAN];
 };
 
 static void sta_flush_table(struct sta_table *);
@@ -343,6 +346,7 @@
 	se->se_seen = 1;
 	se->se_notseen = 0;
 
+	KASSERT(sizeof(sp->bchan) == 1, ("bchan size"));
 	if (rssi > st->st_maxrssi[sp->bchan])
 		st->st_maxrssi[sp->bchan] = rssi;
 
@@ -1604,6 +1608,7 @@
 		/* check channel attributes for band compatibility */
 		if (flags != 0 && (chan->ic_flags & flags) != flags)
 			continue;
+		KASSERT(sizeof(chan->ic_ieee) == 1, ("ic_chan size"));
 		/* XXX channel have interference */
 		if (st->st_maxrssi[chan->ic_ieee] == 0) {
 			/* XXX use other considerations */

==== //depot/projects/vap/sys/net80211/ieee80211_var.h#55 (text+ko) ====

@@ -156,7 +156,7 @@
 	 *    (e.g. for dynamic turbo)
 	 */
 	int			ic_nchans;	/* # entries in ic_channels */
-	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1];
+	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX];
 	uint8_t			ic_chan_avail[IEEE80211_CHAN_BYTES];
 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
 	uint8_t			ic_chan_scan[IEEE80211_CHAN_BYTES];


More information about the p4-projects mailing list