aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/reg.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-11-06 11:54:44 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-11-25 14:51:00 -0500
commitcc493e4f5296f4da111f25ea4a216bb77270ccc6 (patch)
treefba9e744b1695d836fe20b9adbaed49ef7c5a636 /net/wireless/reg.c
parentae689390b09d1f5b274c83dbbd3836fedb692e31 (diff)
cfg80211: enforce disabling channels by custom or strict settings
If a custom regulatory domain is passed and if a rule for a channel indicates it should be disabled that channel should always remain disabled as per its documentation and design. Likewise if WIPHY_FLAG_STRICT_REGULATORY flag is set and a regulatory_hint() is issued if a channel is disabled that channel should remain disabled. Without this change only drivers that set the _orig flags appropriately on their own would ensure disallowed channels remaind disabled. This helps drivers save code by relying on the APIS provided to entrust channels that should not be enabled be respected by only having to use wiphy_apply_custom_regulatory() or regulatory_hint() with the WIPHY_FLAG_STRICT_REGULATORY set. If wiphy_apply_custom_regulatory() is used together with WIPHY_FLAG_STRICT_REGULATORY and a regulatory_hint() issued later, the incoming regulatory domain can override previously set _orig parameters from the initial custom regulatory setting. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r--net/wireless/reg.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index dccdfe36a310..b4b16871a56e 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -846,8 +846,18 @@ static void handle_channel(struct wiphy *wiphy,
846 PTR_ERR(reg_rule) == -ERANGE) 846 PTR_ERR(reg_rule) == -ERANGE)
847 return; 847 return;
848 848
849 REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq); 849 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
850 chan->flags |= IEEE80211_CHAN_DISABLED; 850 request_wiphy && request_wiphy == wiphy &&
851 request_wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) {
852 REG_DBG_PRINT("Disabling freq %d MHz for good\n",
853 chan->center_freq);
854 chan->orig_flags |= IEEE80211_CHAN_DISABLED;
855 chan->flags = chan->orig_flags;
856 } else {
857 REG_DBG_PRINT("Disabling freq %d MHz\n",
858 chan->center_freq);
859 chan->flags |= IEEE80211_CHAN_DISABLED;
860 }
851 return; 861 return;
852 } 862 }
853 863
@@ -1250,7 +1260,8 @@ static void handle_channel_custom(struct wiphy *wiphy,
1250 if (IS_ERR(reg_rule)) { 1260 if (IS_ERR(reg_rule)) {
1251 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n", 1261 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n",
1252 chan->center_freq); 1262 chan->center_freq);
1253 chan->flags = IEEE80211_CHAN_DISABLED; 1263 chan->orig_flags |= IEEE80211_CHAN_DISABLED;
1264 chan->flags = chan->orig_flags;
1254 return; 1265 return;
1255 } 1266 }
1256 1267