From patchwork Thu Apr 26 17:13:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 10366539 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17081601BE for ; Thu, 26 Apr 2018 17:14:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0932B2847D for ; Thu, 26 Apr 2018 17:14:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1B4F28488; Thu, 26 Apr 2018 17:14:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BA30291F9 for ; Thu, 26 Apr 2018 17:14:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756715AbeDZROJ (ORCPT ); Thu, 26 Apr 2018 13:14:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44236 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756589AbeDZROI (ORCPT ); Thu, 26 Apr 2018 13:14:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id ED3FF605FF; Thu, 26 Apr 2018 17:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524762847; bh=f7hDYpfAeXfppVjSrwJsbD4oaSSbFflnDFBc1eqpVnI=; h=From:To:Cc:Subject:Date:From; b=H4xQh8Nx17gxySH482//ORqWDSLJ3b2UlUbrRO5oQuE0DGDu9KRBzyTJ0FNh/D8mA jnPZcnqF5yIkuUeXoiic95/bPCuhlED5edQdK/Nmyu7FhY+Tsi/eL9Wn7a8MwvdZgf HQOVMmbvhQjSrsLPavzL8o7oF+E20ILjjsBmsgaw= Received: from jouni.codeaurora.org (176-93-247-36.bb.dnainternet.fi [176.93.247.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jouni@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8386760264; Thu, 26 Apr 2018 17:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524762845; bh=f7hDYpfAeXfppVjSrwJsbD4oaSSbFflnDFBc1eqpVnI=; h=From:To:Cc:Subject:Date:From; b=c7KX+oX0/fBfVZ0EECtNQxYYpNBG8kFZEuVREB/w7u5imNHYDqczpZpdwkA47WsWT CvJ7K9YZtnRfMbwVKy5QU5EOLmkvg0gimkIZ4JNI4PBzr4vMF8gxkXftciKPxAawlx V79uY0iOh6tITkC5wWsFLSeDv2Z+ouHembfS38xs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8386760264 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jouni@codeaurora.org From: Jouni Malinen To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Amar Singhal , Jouni Malinen Subject: [PATCHv2] cfg80211: Call reg_notifier for self managed hints conditionally Date: Thu, 26 Apr 2018 20:13:07 +0300 Message-Id: <1524762787-7703-1-git-send-email-jouni@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Amar Singhal Currently the regulatory core does not call the regulatory callback reg_notifier for self managed wiphys, but regulatory_hint_user() call is independent of wiphy and is meant for all wiphys in the system. Even a self managed wiphy may be interested in regulatory_hint_user() to know the country code from a trusted regulatory domain change like a cellular base station. Therefore, for the regulatory source NL80211_REGDOM_SET_BY_USER and the user hint type NL80211_USER_REG_HINT_CELL_BASE, call the regulatory notifier. No current wlan driver uses the REGULATORY_WIPHY_SELF_MANAGED flag while also registering the reg_notifier regulatory callback, therefore there will be no impact on existing drivers without them being explicitly modified to take advantage of this new possibility. Signed-off-by: Amar Singhal Signed-off-by: Jouni Malinen --- net/wireless/reg.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) v2 - merge the two patches into a single one - instead of modifying reg_only_self_managed_wiphys() use a new helper function notify_self_managed_wiphys() to clean up the implementation - update commit message and comments to describe the desired use case more clearly and note that this does not change behavior with existing drivers without an explicit driver change diff --git a/net/wireless/reg.c b/net/wireless/reg.c index ecfee5f..25bce79 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -2768,6 +2768,21 @@ static void reg_process_hint(struct regulatory_request *reg_request) reg_free_request(reg_request); } +static void notify_self_managed_wiphys(struct regulatory_request *request) +{ + struct cfg80211_registered_device *rdev; + struct wiphy *wiphy; + + list_for_each_entry(rdev, &cfg80211_rdev_list, list) { + wiphy = &rdev->wiphy; + if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && + request->initiator == NL80211_REGDOM_SET_BY_USER && + request->user_reg_hint_type == + NL80211_USER_REG_HINT_CELL_BASE) + reg_call_notifier(wiphy, request); + } +} + static bool reg_only_self_managed_wiphys(void) { struct cfg80211_registered_device *rdev; @@ -2819,6 +2834,7 @@ static void reg_process_pending_hints(void) spin_unlock(®_requests_lock); + notify_self_managed_wiphys(reg_request); if (reg_only_self_managed_wiphys()) { reg_free_request(reg_request); return; @@ -3698,17 +3714,26 @@ EXPORT_SYMBOL(regulatory_set_wiphy_regd_sync_rtnl); void wiphy_regulatory_register(struct wiphy *wiphy) { - struct regulatory_request *lr; + struct regulatory_request *lr = get_last_request(); - /* self-managed devices ignore external hints */ - if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) + /* self-managed devices ignore beacon hints and country IE */ + if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS | REGULATORY_COUNTRY_IE_IGNORE; + /* + * The last request may have been received before this + * registration call. Call the driver notifier if + * initiator is USER and user type is CELL_BASE. + */ + if (lr->initiator == NL80211_REGDOM_SET_BY_USER && + lr->user_reg_hint_type == NL80211_USER_REG_HINT_CELL_BASE) + reg_call_notifier(wiphy, lr); + } + if (!reg_dev_ignore_cell_hint(wiphy)) reg_num_devs_support_basehint++; - lr = get_last_request(); wiphy_update_regulatory(wiphy, lr->initiator); wiphy_all_share_dfs_chan_state(wiphy); }