From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-bk0-f50.google.com ([209.85.214.50]:38605 "EHLO mail-bk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755203Ab3KERRO (ORCPT ); Tue, 5 Nov 2013 12:17:14 -0500 Received: by mail-bk0-f50.google.com with SMTP id v15so336298bkz.23 for ; Tue, 05 Nov 2013 09:17:13 -0800 (PST) From: "Luis R. Rodriguez" To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH 01/19] cfg80211: enforce disabling channels by custom or strict settings Date: Tue, 5 Nov 2013 09:17:59 -0800 Message-Id: <1383671897-7746-2-git-send-email-mcgrof@do-not-panic.com> (sfid-20131105_181719_963401_D9F8551F) In-Reply-To: <1383671897-7746-1-git-send-email-mcgrof@do-not-panic.com> References: <1383671897-7746-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-wireless-owner@vger.kernel.org List-ID: 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 --- net/wireless/reg.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 89b4664..999b4bb7 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -847,8 +847,18 @@ static void handle_channel(struct wiphy *wiphy, PTR_ERR(reg_rule) == -ERANGE) return; - REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq); - chan->flags |= IEEE80211_CHAN_DISABLED; + if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && + request_wiphy && request_wiphy == wiphy && + request_wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { + REG_DBG_PRINT("Disabling freq %d MHz for good\n", + chan->center_freq); + chan->flags = chan->orig_flags |= + IEEE80211_CHAN_DISABLED; + } else { + REG_DBG_PRINT("Disabling freq %d MHz\n", + chan->center_freq); + chan->flags |= IEEE80211_CHAN_DISABLED; + } return; } @@ -1251,7 +1261,7 @@ static void handle_channel_custom(struct wiphy *wiphy, if (IS_ERR(reg_rule)) { REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n", chan->center_freq); - chan->flags = IEEE80211_CHAN_DISABLED; + chan->flags = chan->orig_flags |= IEEE80211_CHAN_DISABLED; return; } -- 1.8.4.rc3