2013-02-12 17:11:59

by Dennis H Jensen

[permalink] [raw]
Subject: [PATCH] nl80211: Don't add empty bands or disabled channels in NL80211_CMD_GET_WIPHY


This patch resolves issues where the driver reports too many channels
for them all to fit in one netlink message, as long as some are
disabled, and makes it possible to use non-standard channels and
customized regulatory databases.

Signed-off-by: Dennis H Jensen <[email protected]>

---
net/wireless/nl80211.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 807d448..8cd274d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -986,6 +986,15 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag
if (!dev->wiphy.bands[band])
continue;

+ /* don't add band info if all channels are disabled */
+ for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) {
+ chan = &dev->wiphy.bands[band]->channels[i];
+ if (!(chan->flags & IEEE80211_CHAN_DISABLED))
+ break;
+ }
+ if (i == dev->wiphy.bands[band]->n_channels)
+ continue;
+
nl_band = nla_nest_start(msg, band);
if (!nl_band)
goto nla_put_failure;
@@ -1018,12 +1027,15 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag
goto nla_put_failure;

for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) {
+ /* don't add disabled frequencies */
+ chan = &dev->wiphy.bands[band]->channels[i];
+ if (chan->flags & IEEE80211_CHAN_DISABLED)
+ continue;
+
nl_freq = nla_nest_start(msg, i);
if (!nl_freq)
goto nla_put_failure;

- chan = &dev->wiphy.bands[band]->channels[i];
-
if (nl80211_msg_put_channel(msg, chan))
goto nla_put_failure;

--
1.7.9.5



2013-02-13 14:57:16

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] nl80211: Don't add empty bands or disabled channels in NL80211_CMD_GET_WIPHY

On Tue, 2013-02-12 at 18:00 +0100, Dennis H Jensen wrote:
> This patch resolves issues where the driver reports too many channels
> for them all to fit in one netlink message, as long as some are
> disabled, and makes it possible to use non-standard channels and
> customized regulatory databases.

I don't think this is a good idea -- the state of a channel being
"disabled" can change due to regulatory database, so it's useful to know
which channels are actually registered and disabled via regulatory and
which aren't even present at all.

Since you must be hacking the drivers anyway, you could just not
register those channels you're not using, right?

Maybe there'd be a way to allocate larger messages, but I suppose the
right fix would be to split up the dump in a way that it can support
arbitrarily many channels, which will also require userspace changes
though (and has to be done in a backward compatible way.)

johannes