From patchwork Mon Dec 1 15:48:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arik Nemtsov X-Patchwork-Id: 5413231 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DBA15BEEBA for ; Mon, 1 Dec 2014 15:48:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1250120211 for ; Mon, 1 Dec 2014 15:48:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28D872021A for ; Mon, 1 Dec 2014 15:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932146AbaLAPsy (ORCPT ); Mon, 1 Dec 2014 10:48:54 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:62900 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbaLAPsx (ORCPT ); Mon, 1 Dec 2014 10:48:53 -0500 Received: by mail-wg0-f51.google.com with SMTP id k14so14487167wgh.10 for ; Mon, 01 Dec 2014 07:48:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OIbSbxUfeUfj9O5BdE/mAcLB8+A/yan801B+dYKK+lQ=; b=dDzFw5YqAfcd1Uqhwo4o/dD8MHLVR+kfmIXZsdKz1lNxhDB8jsWfnOUd6uBQVuq9PL moOLUK2Cjc/dPiQ9ysv4gMGbJUigZlEgyzEsQtNFyB9dzwoMMAkwGnBlv4pzqeo/nXYK q2cAa3Fr1J1mx+Sqa5MNSwcSgBpfG4TVtVePGY3kYxLJWgkmalgzeZJOUqrQdaLt+cML 3MLCLoUD6QxXCXoBXijTfmQORkCKMAoabjlpCluvH8q+4DNE5Kb0vof6jvvQ1qr4wace Bvl/S5gtGO3LktazIh8vjSkI40kF3b1AQQZiUjrEO9eaoXxb26BYGX37CPTFEDFISuiV GrWQ== X-Gm-Message-State: ALoCoQnFmhKgoKy6lJXdPATD8rc5aiQR2UHKb60X64bmqNtwG4C5fP+e2PmtKSqomwCJNq0xkKJN X-Received: by 10.180.91.201 with SMTP id cg9mr87328478wib.63.1417448932323; Mon, 01 Dec 2014 07:48:52 -0800 (PST) Received: from athena.amr.corp.intel.com (85-250-108-142.bb.netvision.net.il. [85.250.108.142]) by mx.google.com with ESMTPSA id gf6sm15276047wjc.11.2014.12.01.07.48.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Dec 2014 07:48:51 -0800 (PST) From: Arik Nemtsov To: Cc: Johannes Berg , "Luis R. Rodriguez" , Arik Nemtsov Subject: [PATCH v6 3/4] cfg80211: return private regdom for self-managed devices Date: Mon, 1 Dec 2014 17:48:46 +0200 Message-Id: <1417448927-9337-3-git-send-email-arik@wizery.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417448927-9337-1-git-send-email-arik@wizery.com> References: <1417448927-9337-1-git-send-email-arik@wizery.com> 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 device has self-managed regulatory, insist on returning the wiphy specific regdomain if a wiphy-idx is specified. The global regdomain is meaningless for such devices. Also add an attribute for self-managed devices, so usermode can distinguish them as such. Signed-off-by: Arik Nemtsov Reviewed-by: Luis R. Rodriguez --- net/wireless/nl80211.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index de523aa..ca60c6a 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -396,6 +396,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_ADMITTED_TIME] = { .type = NLA_U16 }, [NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 }, [NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN }, + [NL80211_ATTR_WIPHY_SELF_MANAGED_REG] = { .type = NLA_FLAG }, }; /* policy for the key attributes */ @@ -5406,6 +5407,8 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info) goto put_failure; if (info->attrs[NL80211_ATTR_WIPHY]) { + bool self_managed; + rdev = cfg80211_get_dev_from_info(genl_info_net(info), info); if (IS_ERR(rdev)) { nlmsg_free(msg); @@ -5413,8 +5416,16 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info) } wiphy = &rdev->wiphy; + self_managed = wiphy->regulatory_flags & + REGULATORY_WIPHY_SELF_MANAGED; regdom = get_wiphy_regdom(wiphy); + /* a self-managed-reg device must have a private regdom */ + if (WARN_ON(!regdom && self_managed)) { + nlmsg_free(msg); + return -EINVAL; + } + if (regdom && nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy))) goto nla_put_failure; @@ -5476,6 +5487,10 @@ static int nl80211_send_regdom(struct sk_buff *msg, struct netlink_callback *cb, nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy))) goto nla_put_failure; + if (wiphy && wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && + nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG)) + goto nla_put_failure; + return genlmsg_end(msg, hdr); nla_put_failure: @@ -11081,6 +11096,11 @@ static bool nl80211_reg_change_event_fill(struct sk_buff *msg, if (wiphy && nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) goto nla_put_failure; + + if (wiphy && + wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && + nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG)) + goto nla_put_failure; } return true;