linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <lrodriguez@atheros.com>
To: <linville@tuxdriver.com>, <johannes@sipsolutions.net>
Cc: <easwar.krishnan@atheros.com>, <linux-wireless@vger.kernel.org>,
	"Luis R. Rodriguez" <lrodriguez@atheros.com>,
	David Quan <david.quan@atheros.com>,
	Jouni Malinen <jouni.malinen@atheros.com>, <stable@kernel.org>
Subject: [PATCH 3/7] cfg80211: fix disabling channels based on hints
Date: Wed, 20 Oct 2010 10:18:55 -0700	[thread overview]
Message-ID: <1287595139-10761-4-git-send-email-lrodriguez@atheros.com> (raw)
In-Reply-To: <1287595139-10761-1-git-send-email-lrodriguez@atheros.com>

After a module loads you will have loaded the world roaming regulatory
domain or a custom regulatory domain. Further regulatory hints are
welcomed and should be respected unless the regulatory hint is coming
from a country IE as the IEEE spec allows for a country IE to be a subset
of what is allowed by the local regulatory agencies.

So disable all channels that do not fit a regulatory domain sent
from a unless the hint is from a country IE and the country IE had
no information about the band we are currently processing.

This fixes a few regulatory issues, for example for drivers that depend
on CRDA and had no 5 GHz freqencies allowed were not properly disabling
5 GHz at all, furthermore it also allows users to restrict devices
further as was intended.

If you recieve a country IE upon association we will also disable the
channels that are not allowed if the country IE had at least one
channel on the respective band we are procesing.

This was the original intention behind this design but it was
completely overlooked...

Cc: David Quan <david.quan@atheros.com>
Cc: Jouni Malinen <jouni.malinen@atheros.com>
cc: Easwar Krishnan <easwar.krishnan@atheros.com>
Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
 include/linux/nl80211.h |    6 +++++-
 net/wireless/reg.c      |   20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 0edb256..fb877b5 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1307,7 +1307,11 @@ enum nl80211_bitrate_attr {
  * 	wireless core it thinks its knows the regulatory domain we should be in.
  * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
  * 	802.11 country information element with regulatory information it
- * 	thinks we should consider.
+ * 	thinks we should consider. cfg80211 only processes the country
+ *	code from the IE, and relies on the regulatory domain information
+ *	structure pased by userspace (CRDA) from our wireless-regdb.
+ *	If a channel is enabled but the country code indicates it should
+ *	be disabled we disable the channel and re-enable it upon disassociation.
  */
 enum nl80211_reg_initiator {
 	NL80211_REGDOM_SET_BY_CORE,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 1bc8131..8ab65f2 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -750,8 +750,26 @@ static void handle_channel(struct wiphy *wiphy,
 			  desired_bw_khz,
 			  &reg_rule);
 
-	if (r)
+	if (r) {
+		/*
+		 * We will disable all channels that do not match our
+		 * recieved regulatory rule unless the hint is coming
+		 * from a Country IE and the Country IE had no information
+		 * about a band. The IEEE 802.11 spec allows for an AP
+		 * to send only a subset of the regulatory rules allowed,
+		 * so an AP in the US that only supports 2.4 GHz may only send
+		 * a country IE with information for the 2.4 GHz band
+		 * while 5 GHz is still supported.
+		 */
+		if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
+		    r == -ERANGE)
+			return;
+
+		REG_DBG_PRINT("cfg80211: Disabling freq %d MHz\n",
+			      chan->center_freq);
+		chan->flags = IEEE80211_CHAN_DISABLED;
 		return;
+	}
 
 	power_rule = &reg_rule->power_rule;
 	freq_range = &reg_rule->freq_range;
-- 
1.7.0.4


  parent reply	other threads:[~2010-10-20 17:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20 17:18 [PATCH 0/7] cfg80211: few regulatory fixes and debugging enhancements Luis R. Rodriguez
2010-10-20 17:18 ` [PATCH 1/7] cfg80211: pass the reg hint initiator to helpers Luis R. Rodriguez
2010-10-20 17:18 ` [PATCH 2/7] cfg80211: fix allowing country IEs for WIPHY_FLAG_STRICT_REGULATORY Luis R. Rodriguez
2010-10-20 21:24   ` Gábor Stefanik
2010-10-20 17:18 ` Luis R. Rodriguez [this message]
2010-10-20 17:18 ` [PATCH 4/7] cfg80211: add debug prints for when we ignore regulatory hints Luis R. Rodriguez
2010-10-20 17:18 ` [PATCH 5/7] cfg80211: add debug print when disabling a channel on a custom regd Luis R. Rodriguez
2010-10-20 17:18 ` [PATCH 6/7] cfg80211: add debug print when processing a channel Luis R. Rodriguez
2010-10-21  8:18   ` Senthil Balasubramanian
2010-10-21  9:02     ` Luis R. Rodriguez
2010-10-21  9:04       ` Luis R. Rodriguez
2010-10-20 17:18 ` [PATCH 7/7] cfg80211: prefix REG_DBG_PRINT() with cfg80211 Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287595139-10761-4-git-send-email-lrodriguez@atheros.com \
    --to=lrodriguez@atheros.com \
    --cc=david.quan@atheros.com \
    --cc=easwar.krishnan@atheros.com \
    --cc=johannes@sipsolutions.net \
    --cc=jouni.malinen@atheros.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).