Skip to contentSkip to conversation

cfg80211: drop wext channel list if too long

PATCH In review Johannes Berg 3 participants 5 messages Mar 12, 2009 – Mar 16, 2009 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 cfg80211: drop wext channel list if too long

wext limits the number of channels it can list to 32, we obey that limitation but show a partial list which is confusing. Thus, when going over the limit, drop the list completely to make the users aware that something is wrong and hopefully prompt them to use iw instead. We still let iwlist print out the total number of available channels.

---
 net/wireless/wext-compat.c |   49 +++++++++++++++++++++++++++++++++------------
 1 file changed, 37 insertions(+), 12 deletions(-)
net/wireless/wext-compat.c +37 -12
@@ -146,7 +146,7 @@ int cfg80211_wext_giwrange(struct net_de
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
 	struct iw_range *range = (struct iw_range *) extra;
 	enum ieee80211_band band;
-	int c = 0;
+	int nc = 0, nf = 0;
 
 	if (!wdev)
 		return -EOPNOTSUPP;
@@ -209,21 +209,46 @@ int cfg80211_wext_giwrange(struct net_de
 		if (!sband)
 			continue;
 
-		for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
+		for (i = 0; i < sband->n_channels; i++) {
 			struct ieee80211_channel *chan = &sband->channels[i];
 
-			if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
-				range->freq[c].i =
-					ieee80211_frequency_to_channel(
-						chan->center_freq);
-				range->freq[c].m = chan->center_freq;
-				range->freq[c].e = 6;
-				c++;
-			}
+			if (chan->flags & IEEE80211_CHAN_DISABLED)
+				continue;
+
+			nc++;
+
+			/*
+			 * reached wext limit for frequencies,
+			 * keep counting the channels in 'nc'.
+			 */
+			if (nf >= IW_MAX_FREQUENCIES)
+				continue;
+
+			range->freq[nf].i =
+			    ieee80211_frequency_to_channel(chan->center_freq);
+			range->freq[nf].m = chan->center_freq;
+			range->freq[nf].e = 6;
+			nf++;
 		}
 	}
-	range->num_channels = c;
-	range->num_frequency = c;
+
+	range->num_channels = nc;
+
+	/*
+	 * wext only supports a limited number of frequencies,
+	 * if that is reached then it helpfully suggests:
+	 *
+	 *	Note : if you have something like 80 frequencies,
+	 *	don't increase this constant and don't fill the
+	 *	frequency list. The user will be able to set by
+	 *	channel anyway...
+	 *
+	 * So in this case let's just leave the list empty.
+	 */
+	if (nc > nf)
+		nf = 0;
+
+	range->num_frequency = nf;
 
 	IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
 	IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
#1 lore raw
Quoted 8 lines · Johannes Berg

wext limits the number of channels it can list to 32, we obey that limitation but show a partial list which is confusing. Thus, when going over the limit, drop the list completely to make the users aware that something is wrong and hopefully prompt them to use iw instead. We still let iwlist print out the total number of available channels.

Will this make wpa_supplicant or Networkmanager barf?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#2 lore raw
Quoted 11 lines · John W. Linville
Quoted 8 lines · Johannes Berg

wext limits the number of channels it can list to 32, we obey that limitation but show a partial list which is confusing. Thus, when going over the limit, drop the list completely to make the users aware that something is wrong and hopefully prompt them to use iw instead. We still let iwlist print out the total number of available channels.

Will this make wpa_supplicant or Networkmanager barf?

It doesn't look like wpa_supplicant cares about the returned channel list from SIOCGIWRANGE.

NM, however, uses the returned channel list to figure out a free supported adhoc frequency to use when creating an adhoc network (like for connection sharing). If it can't find an intersection between an internal "safe" frequency list and what the card supports (which it wouldn't be able to with this patch), it will simply use 2462 or 5180 MHz.

Thus, I don't think you'll *break* anything specifically, but this patch would cause the default frequency for an IBSS created by NM to move from channel 1 to channel 11.

Dan

author maintainer
#3 lore raw
Quoted 10 lines · Dan Williams

It doesn't look like wpa_supplicant cares about the returned channel list from SIOCGIWRANGE.

NM, however, uses the returned channel list to figure out a free supported adhoc frequency to use when creating an adhoc network (like for connection sharing). If it can't find an intersection between an internal "safe" frequency list and what the card supports (which it wouldn't be able to with this patch), it will simply use 2462 or 5180 MHz.

Quoted 3 lines

Thus, I don't think you'll *break* anything specifically, but this patch would cause the default frequency for an IBSS created by NM to move from channel 1 to channel 11.

In that case, let's just drop the patch, I have no problem with that.

We just couldn't figure out why some channels were missing in iwlist when they were in iw, but that's due to the 32 channel limit. Since most people probably don't use this particular functionality, I guess it doesn't really matter. Eventually NM should just use nl80211, or at least try to, because there it gets more information like "cannot do IBSS on channel XY", something that wext doesn't give you, but mac80211 enforces.

johannes

#4 lore raw
Quoted 18 lines · Johannes Berg
Quoted 10 lines · Dan Williams

It doesn't look like wpa_supplicant cares about the returned channel list from SIOCGIWRANGE.

NM, however, uses the returned channel list to figure out a free supported adhoc frequency to use when creating an adhoc network (like for connection sharing). If it can't find an intersection between an internal "safe" frequency list and what the card supports (which it wouldn't be able to with this patch), it will simply use 2462 or 5180 MHz.

Quoted 3 lines

Thus, I don't think you'll *break* anything specifically, but this patch would cause the default frequency for an IBSS created by NM to move from channel 1 to channel 11.

In that case, let's just drop the patch, I have no problem with that.

Quoted 7 lines

We just couldn't figure out why some channels were missing in iwlist when they were in iw, but that's due to the 32 channel limit. Since most people probably don't use this particular functionality, I guess it doesn't really matter. Eventually NM should just use nl80211, or at least try to, because there it gets more information like "cannot do IBSS on channel XY", something that wext doesn't give you, but mac80211 enforces.

Yup; nl80211 is the way to go here. Or better yet, make wpa_supplicant card capabilities over D-Bus so NM doesn't have to touch the driver directly.

Dan