From patchwork Wed Nov 6 16:54:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 3148361 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 08F829F407 for ; Wed, 6 Nov 2013 16:53:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B551204EA for ; Wed, 6 Nov 2013 16:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C103204DF for ; Wed, 6 Nov 2013 16:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754235Ab3KFQxj (ORCPT ); Wed, 6 Nov 2013 11:53:39 -0500 Received: from mail-ea0-f175.google.com ([209.85.215.175]:57797 "EHLO mail-ea0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716Ab3KFQxj (ORCPT ); Wed, 6 Nov 2013 11:53:39 -0500 Received: by mail-ea0-f175.google.com with SMTP id l15so4135775eak.6 for ; Wed, 06 Nov 2013 08:53:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=5eh4qJFxEG4Z0eIDIfPNG9TWM70oC1E4bV85cIqKIRo=; b=G5i0h9ahblBfxZFLxxD+JTqvceVXbARfW0cHuhMIluhVFNweZt8DtRTJ67JoufsLHO dmSZNNVuabysHJWdOZ2GtA4duASyl69aY+4pZn5oFk4HpwG5fHCFSkChm+hfkOCWsLi0 1QbcAiXCv558DKPoy0u3b9bh5rZaLnaOPW3XrYbP2myLGwFfBb3bzJ5ycs1DuUbb6A7K J+RKFEUZdvZeABYMLs6TDwdMlYpKAxrLbk7v29iQT3xJKGUuzmVpSmraHmViehdOLE0Z oH4iLTPd76sh91wg2tRt1CGvUtl7Z8Wk8y+CUtHjmxtH2bsCYEtON5+gjQEr7wcLncxL wkjQ== X-Received: by 10.14.3.9 with SMTP id 9mr4615568eeg.72.1383756817663; Wed, 06 Nov 2013 08:53:37 -0800 (PST) Received: from mcgrof@gmail.com (blfd-4d083e1b.pool.mediaWays.net. [77.8.62.27]) by mx.google.com with ESMTPSA id b42sm75874067eem.9.2013.11.06.08.53.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 06 Nov 2013 08:53:37 -0800 (PST) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 06 Nov 2013 17:54:44 +0100 From: "Luis R. Rodriguez" To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v2 1/19] cfg80211: enforce disabling channels by custom or strict settings Date: Wed, 6 Nov 2013 17:54:44 +0100 Message-Id: <1383756884-8556-1-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.8.4.rc3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- This v2 splits up the flag assignements into two lines to make things clear: we extend the _orig flags with the disable flag, and then just copy it over to the regular channel flags. net/wireless/reg.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index dccdfe3..b4b1687 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -846,8 +846,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->orig_flags |= IEEE80211_CHAN_DISABLED; + chan->flags = chan->orig_flags; + } else { + REG_DBG_PRINT("Disabling freq %d MHz\n", + chan->center_freq); + chan->flags |= IEEE80211_CHAN_DISABLED; + } return; } @@ -1250,7 +1260,8 @@ 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->orig_flags |= IEEE80211_CHAN_DISABLED; + chan->flags = chan->orig_flags; return; }