All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfg80211: drop wext channel list if too long
@ 2009-03-12 18:24 Johannes Berg
  2009-03-13 14:54 ` John W. Linville
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2009-03-12 18:24 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless

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.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/wireless/wext-compat.c |   49 +++++++++++++++++++++++++++++++++------------
 1 file changed, 37 insertions(+), 12 deletions(-)

--- wireless-testing.orig/net/wireless/wext-compat.c	2009-03-11 19:27:04.000000000 +0100
+++ wireless-testing/net/wireless/wext-compat.c	2009-03-11 20:12:31.000000000 +0100
@@ -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);



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cfg80211: drop wext channel list if too long
  2009-03-12 18:24 [PATCH] cfg80211: drop wext channel list if too long Johannes Berg
@ 2009-03-13 14:54 ` John W. Linville
  2009-03-13 17:18   ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: John W. Linville @ 2009-03-13 14:54 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Thu, Mar 12, 2009 at 07:24:04PM +0100, Johannes Berg wrote:
> 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.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

Will this make wpa_supplicant or Networkmanager barf?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cfg80211: drop wext channel list if too long
  2009-03-13 14:54 ` John W. Linville
@ 2009-03-13 17:18   ` Dan Williams
  2009-03-14  8:30     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Williams @ 2009-03-13 17:18 UTC (permalink / raw)
  To: John W. Linville; +Cc: Johannes Berg, linux-wireless

On Fri, 2009-03-13 at 10:54 -0400, John W. Linville wrote:
> On Thu, Mar 12, 2009 at 07:24:04PM +0100, Johannes Berg wrote:
> > 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.
> > 
> > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> 
> 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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cfg80211: drop wext channel list if too long
  2009-03-13 17:18   ` Dan Williams
@ 2009-03-14  8:30     ` Johannes Berg
  2009-03-16 16:56       ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2009-03-14  8:30 UTC (permalink / raw)
  To: Dan Williams; +Cc: John W. Linville, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]

On Fri, 2009-03-13 at 13:18 -0400, Dan Williams wrote:

> 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.

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cfg80211: drop wext channel list if too long
  2009-03-14  8:30     ` Johannes Berg
@ 2009-03-16 16:56       ` Dan Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2009-03-16 16:56 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John W. Linville, linux-wireless

On Sat, 2009-03-14 at 09:30 +0100, Johannes Berg wrote:
> On Fri, 2009-03-13 at 13:18 -0400, Dan Williams wrote:
> 
> > 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.
> 
> 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.

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-16 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-12 18:24 [PATCH] cfg80211: drop wext channel list if too long Johannes Berg
2009-03-13 14:54 ` John W. Linville
2009-03-13 17:18   ` Dan Williams
2009-03-14  8:30     ` Johannes Berg
2009-03-16 16:56       ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.