When the regulatory settings change, some channels might become invalid.
Disconnect interfaces acting on these channels, after giving userspace
code a grace period to leave them.
This mode is currently opt-in, and not all interface operating modes are
supported for regulatory-enforcement checks. A wiphy that wishes to use
the new enforcement code must specify an appropriate regulatory flag,
and all its supported interface modes must be supported by the chekcing
code.
Signed-off-by: Arik Nemtsov <[email protected]>
---
include/net/regulatory.h | 6 +++
net/wireless/core.c | 13 ++++++
net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 124 insertions(+), 1 deletion(-)
diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index dad7ab2..701177c 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -136,6 +136,11 @@ struct regulatory_request {
* otherwise initiating radiation is not allowed. This will enable the
* relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
* option
+ * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
+ * interfaces on this wiphy reside on allowed channels. Upon a regdomain
+ * change, the interfaces are given a grace period to disconnect or move
+ * to an allowed channels. Interfaces on forbidden channels are forcibly
+ * disconnected.
*/
enum ieee80211_regulatory_flags {
REGULATORY_CUSTOM_REG = BIT(0),
@@ -144,6 +149,7 @@ enum ieee80211_regulatory_flags {
REGULATORY_COUNTRY_IE_FOLLOW_POWER = BIT(3),
REGULATORY_COUNTRY_IE_IGNORE = BIT(4),
REGULATORY_ENABLE_RELAX_NO_IR = BIT(5),
+ REGULATORY_ENFORCE_CHANNELS = BIT(6),
};
struct ieee80211_freq_range {
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 4c2e501..5295456 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -546,6 +546,19 @@ int wiphy_register(struct wiphy *wiphy)
!rdev->ops->tdls_cancel_channel_switch)))
return -EINVAL;
+ /*
+ * a wiphy that wishes to enable channel enforcement must have only
+ * modes where enforcement is supported.
+ */
+ if (WARN_ON((wiphy->regulatory_flags & REGULATORY_ENFORCE_CHANNELS) &&
+ (wiphy->interface_modes & ~(BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_AP) |
+ BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_ADHOC) |
+ BIT(NL80211_IFTYPE_P2P_DEVICE) |
+ BIT(NL80211_IFTYPE_AP_VLAN) |
+ BIT(NL80211_IFTYPE_MONITOR)))))
+ return -EINVAL;
+
if (WARN_ON(wiphy->coalesce &&
(!wiphy->coalesce->n_rules ||
!wiphy->coalesce->n_patterns) &&
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 32d8310..922d00a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -56,6 +56,7 @@
#include <net/cfg80211.h>
#include "core.h"
#include "reg.h"
+#include "rdev-ops.h"
#include "regdb.h"
#include "nl80211.h"
@@ -66,6 +67,12 @@
#define REG_DBG_PRINT(args...)
#endif
+/*
+ * Grace period we give before making sure all current interfaces reside on
+ * channels allowed by the current regulatory domain.
+ */
+#define REG_ENFORCE_GRACE_MS 60000
+
/**
* enum reg_request_treatment - regulatory request treatment
*
@@ -210,6 +217,9 @@ struct reg_beacon {
struct ieee80211_channel chan;
};
+static void reg_check_chans_work(struct work_struct *work);
+static DECLARE_DELAYED_WORK(reg_check_chans, reg_check_chans_work);
+
static void reg_todo(struct work_struct *work);
static DECLARE_WORK(reg_work, reg_todo);
@@ -1518,6 +1528,95 @@ static void reg_call_notifier(struct wiphy *wiphy,
wiphy->reg_notifier(wiphy, request);
}
+static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
+{
+ struct ieee80211_channel *ch;
+ struct cfg80211_chan_def chandef;
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+ bool ret = true;
+
+ wdev_lock(wdev);
+
+ if (!wdev->netdev || !netif_running(wdev->netdev))
+ goto out;
+
+ switch (wdev->iftype) {
+ case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_P2P_GO:
+ if (!wdev->beacon_interval)
+ goto out;
+
+ ret = cfg80211_reg_can_beacon(wiphy,
+ &wdev->chandef, wdev->iftype);
+ break;
+ case NL80211_IFTYPE_STATION:
+ case NL80211_IFTYPE_P2P_CLIENT:
+ case NL80211_IFTYPE_ADHOC:
+ if (!wdev->current_bss ||
+ !wdev->current_bss->pub.channel)
+ goto out;
+
+ ch = wdev->current_bss->pub.channel;
+ if (rdev->ops->get_channel &&
+ !rdev_get_channel(rdev, wdev, &chandef))
+ ret = cfg80211_chandef_usable(wiphy, &chandef,
+ IEEE80211_CHAN_DISABLED);
+ else
+ ret = !(ch->flags & IEEE80211_CHAN_DISABLED);
+ break;
+ case NL80211_IFTYPE_MONITOR:
+ case NL80211_IFTYPE_AP_VLAN:
+ case NL80211_IFTYPE_P2P_DEVICE:
+ /* no enforcement required */
+ break;
+ default:
+ /* others not implemented for now */
+ WARN_ON(1);
+ break;
+ }
+
+out:
+ wdev_unlock(wdev);
+ return ret;
+}
+
+static void reg_leave_invalid_chans(struct wiphy *wiphy)
+{
+ struct wireless_dev *wdev;
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+
+ ASSERT_RTNL();
+
+ list_for_each_entry(wdev, &rdev->wdev_list, list)
+ if (!reg_wdev_chan_valid(wiphy, wdev))
+ cfg80211_leave(rdev, wdev);
+}
+
+static void reg_check_chans_work(struct work_struct *work)
+{
+ struct cfg80211_registered_device *rdev;
+
+ REG_DBG_PRINT("Verifying active interfaces after reg change\n");
+ rtnl_lock();
+
+ list_for_each_entry(rdev, &cfg80211_rdev_list, list)
+ if (rdev->wiphy.regulatory_flags & REGULATORY_ENFORCE_CHANNELS)
+ reg_leave_invalid_chans(&rdev->wiphy);
+
+ rtnl_unlock();
+}
+
+static void reg_check_channels(void)
+{
+ /*
+ * Give usermode a chance to do something nicer (move to another
+ * channel, orderly disconnection), before forcing a disconnection.
+ */
+ mod_delayed_work(system_power_efficient_wq,
+ ®_check_chans,
+ msecs_to_jiffies(REG_ENFORCE_GRACE_MS));
+}
+
static void wiphy_update_regulatory(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator)
{
@@ -1557,6 +1656,8 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
wiphy = &rdev->wiphy;
wiphy_update_regulatory(wiphy, initiator);
}
+
+ reg_check_channels();
}
static void handle_channel_custom(struct wiphy *wiphy,
@@ -1976,8 +2077,10 @@ static void reg_process_hint(struct regulatory_request *reg_request)
/* This is required so that the orig_* parameters are saved */
if (treatment == REG_REQ_ALREADY_SET && wiphy &&
- wiphy->regulatory_flags & REGULATORY_STRICT_REG)
+ wiphy->regulatory_flags & REGULATORY_STRICT_REG) {
wiphy_update_regulatory(wiphy, reg_request->initiator);
+ reg_check_channels();
+ }
return;
@@ -2858,6 +2961,7 @@ void regulatory_exit(void)
cancel_work_sync(®_work);
cancel_delayed_work_sync(®_timeout);
+ cancel_delayed_work_sync(®_check_chans);
/* Lock to suppress warnings */
rtnl_lock();
--
1.9.1
From: Jonathan Doron <[email protected]>
Allow usermode to query wiphy-specific regd info, for drivers that use
wiphy-specific regulatory management.
Use the existing API for sending regdomain info to usermode, but return
the wiphy-specific regd in case wiphy index is provided and the driver
employs wiphy-specific management. This implies user and kernel-mode
support for the feature and is backward compatible.
Signed-off-by: Jonathan Doron <[email protected]>
Signed-off-by: Arik Nemtsov <[email protected]>
---
include/uapi/linux/nl80211.h | 18 ++++++++++-
net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
net/wireless/reg.c | 2 +-
net/wireless/reg.h | 1 +
4 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 3771e7d..b222e5c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -252,7 +252,12 @@
* %NL80211_ATTR_IFINDEX.
*
* @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
- * regulatory domain.
+ * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
+ * self-manages its regulatory settings, its private regulatory domain
+ * will be returned.
+ * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
+ * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
+ * returned, even if it's regulatory is not self-managed.
* @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
* after being queried by the kernel. CRDA replies by sending a regulatory
* domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
@@ -1693,6 +1698,14 @@ enum nl80211_commands {
*
* @NL80211_ATTR_MAC_MASK: MAC address mask
*
+ * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
+ * regulatory information was obtained from the private regdomain
+ * of a device with self-managed regulatory.
+ * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
+ * information should be obtained from a device's private regdomain,
+ * if it exists. This will happen even if the device is not self-managing
+ * its regulatory.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2050,6 +2063,9 @@ enum nl80211_attrs {
NL80211_ATTR_MAC_MASK,
+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
+ NL80211_ATTR_WIPHY_GET_PRIV_REG,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index de3a47a..42ccca7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -396,6 +396,8 @@ 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 },
+ [NL80211_ATTR_WIPHY_GET_PRIV_REG] = { .type = NLA_FLAG },
};
/* policy for the key attributes */
@@ -5328,15 +5330,12 @@ static int nl80211_update_mesh_config(struct sk_buff *skb,
static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
{
- const struct ieee80211_regdomain *regdom;
+ const struct ieee80211_regdomain *regdom = NULL;
struct sk_buff *msg;
void *hdr = NULL;
struct nlattr *nl_reg_rules;
unsigned int i;
- if (!cfg80211_regdomain)
- return -EINVAL;
-
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOBUFS;
@@ -5346,13 +5345,54 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
if (!hdr)
goto put_failure;
- if (reg_last_request_cell_base() &&
- nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE,
- NL80211_USER_REG_HINT_CELL_BASE))
- goto nla_put_failure;
+ if (info->attrs[NL80211_ATTR_WIPHY]) {
+ u32 reg_flags;
+ struct wiphy *wiphy;
+ struct cfg80211_registered_device *rdev =
+ cfg80211_get_dev_from_info(genl_info_net(info), info);
+
+ if (IS_ERR(rdev)) {
+ nlmsg_free(msg);
+ return PTR_ERR(rdev);
+ }
+
+ wiphy = &rdev->wiphy;
+ reg_flags = wiphy->regulatory_flags;
+ if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED ||
+ info->attrs[NL80211_ATTR_WIPHY_GET_PRIV_REG]) {
+ regdom = get_wiphy_regdom(wiphy);
+ if (!regdom) {
+ nlmsg_free(msg);
+ return -EINVAL;
+ }
+
+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY,
+ rdev->wiphy_idx))
+ goto nla_put_failure;
+
+ if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED &&
+ nla_put_flag(msg,
+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
+ goto nla_put_failure;
+ }
+ }
+
+ if (!regdom) {
+ if (!cfg80211_regdomain) {
+ nlmsg_free(msg);
+ return -EINVAL;
+ }
+
+ if (reg_last_request_cell_base() &&
+ nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE,
+ NL80211_USER_REG_HINT_CELL_BASE))
+ goto nla_put_failure;
+ }
rcu_read_lock();
- regdom = rcu_dereference(cfg80211_regdomain);
+
+ if (!regdom)
+ regdom = rcu_dereference(cfg80211_regdomain);
if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, regdom->alpha2) ||
(regdom->dfs_region &&
@@ -10970,9 +11010,16 @@ static bool nl80211_reg_change_event_fill(struct sk_buff *msg,
goto nla_put_failure;
}
- if (request->wiphy_idx != WIPHY_IDX_INVALID &&
- nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx))
- goto nla_put_failure;
+ if (request->wiphy_idx != WIPHY_IDX_INVALID) {
+ struct wiphy *wiphy;
+
+ wiphy = wiphy_idx_to_wiphy(request->wiphy_idx);
+ if (wiphy &&
+ nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx) &&
+ wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED &&
+ nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
+ goto nla_put_failure;
+ }
return true;
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 18cf13b..662d947 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -142,7 +142,7 @@ static const struct ieee80211_regdomain *get_cfg80211_regdom(void)
return rtnl_dereference(cfg80211_regdomain);
}
-static const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy)
+const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy)
{
return rtnl_dereference(wiphy->regd);
}
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index 5e48031..4b45d6e 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -38,6 +38,7 @@ unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
const struct ieee80211_reg_rule *rule);
bool reg_last_request_cell_base(void);
+const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
/**
* regulatory_hint_found_beacon - hints a beacon was found on a channel
--
1.9.1
On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
> When the regulatory settings change, some channels might become invalid.
> Disconnect interfaces acting on these channels, after giving userspace
> code a grace period to leave them.
>
> This mode is currently opt-in, and not all interface operating modes are
> supported for regulatory-enforcement checks. A wiphy that wishes to use
> the new enforcement code must specify an appropriate regulatory flag,
> and all its supported interface modes must be supported by the chekcing
> code.
This is all looking beter now, since I had a few requests for the last patch
I'll ask for some other things here without asking to negage the flag purpose
as I originally wanted.
> Signed-off-by: Arik Nemtsov <[email protected]>
> ---
> include/net/regulatory.h | 6 +++
> net/wireless/core.c | 13 ++++++
> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 124 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
> index dad7ab2..701177c 100644
> --- a/include/net/regulatory.h
> +++ b/include/net/regulatory.h
> @@ -136,6 +136,11 @@ struct regulatory_request {
> * otherwise initiating radiation is not allowed. This will enable the
> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
> * option
> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
> + * change, the interfaces are given a grace period to disconnect or move
> + * to an allowed channels. Interfaces on forbidden channels are forcibly
> + * disconnected.
Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
some information about the amount current of grace period used,
and types of interfaces supported. Since this is a regulatory flag
this information will help folks decide whether to enable or not.
Also encourage its use, and mention that once all supported devices
get support for this will be enabled by default. In the meantime
I'd prefer if this feature was enabled by default if the supported
interface types of a dveice match the white list of supported
interfaces.
Luis
From: Jonathan Doron <[email protected]>
Add a new regulatory flag that allows a driver to manage regdomain
changes/updates for its own wiphy.
A self-managed wiphys only employs regulatory information obtained from
the FW and driver and does not use other cfg80211 sources like
beacon-hints, country-code IEs and hints from other devices on the same
system. Conversely, a self-managed wiphy does not share its regulatory
hints with other devices in the system. If a system contains several
devices, one or more of which are self-managed, there might be
contradictory regulatory settings between them. Usage of flag is
generally discouraged. Only use it if the FW/driver is incompatible
with non-locally originated hints.
A new API lets the driver send a complete regdomain, to be applied on
its wiphy only.
After a wiphy-specific regdomain change takes place, usermode will get
a new type of change notification. The regulatory core also takes care
enforce regulatory restrictions, in case some interfaces are on
forbidden channels.
Signed-off-by: Jonathan Doron <[email protected]>
Signed-off-by: Arik Nemtsov <[email protected]>
---
include/net/cfg80211.h | 16 +++++++++
include/net/regulatory.h | 19 +++++++++++
include/uapi/linux/nl80211.h | 5 +++
net/wireless/core.c | 8 +++++
net/wireless/nl80211.c | 80 ++++++++++++++++++++++++++++++++++----------
net/wireless/nl80211.h | 1 +
net/wireless/reg.c | 59 ++++++++++++++++++++++++++++++++
7 files changed, 170 insertions(+), 18 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bb748c4..bfe630f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3808,6 +3808,22 @@ const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type,
int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
/**
+ * regulatory_set_wiphy_regd_rtnl - set regdom info for self managed drivers
+ * @wiphy: the wireless device we want to process the regulatory domain on
+ * @rd: the regulatory domain informatoin to use for this wiphy
+ *
+ * Set the regulatory domain information for self-managed wiphys, only they
+ * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
+ * information.
+ *
+ * This function requires the caller to hold the rtnl_lock.
+ *
+ * Return: 0 on success. -EINVAL, -EPERM
+ */
+int regulatory_set_wiphy_regd_rtnl(struct wiphy *wiphy,
+ struct ieee80211_regdomain *rd);
+
+/**
* wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
* @wiphy: the wireless device we want to process the regulatory domain on
* @regd: the custom regulatory domain to use for this wiphy
diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 701177c..d69c3db 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -141,6 +141,24 @@ struct regulatory_request {
* change, the interfaces are given a grace period to disconnect or move
* to an allowed channels. Interfaces on forbidden channels are forcibly
* disconnected.
+ * @REGULATORY_WIPHY_SELF_MANAGED: for devices that employ wiphy-specific
+ * regdom management. These devices will ignore all regdom changes not
+ * originating from their own wiphy.
+ * A self-managed wiphys only employs regulatory information obtained from
+ * the FW and driver and does not use other cfg80211 sources like
+ * beacon-hints, country-code IEs and hints from other devices on the same
+ * system. Conversely, a self-managed wiphy does not share its regulatory
+ * hints with other devices in the system. If a system contains several
+ * devices, one or more of which are self-managed, there might be
+ * contradictory regulatory settings between them. Usage of flag is
+ * generally discouraged. Only use it if the FW/driver is incompatible
+ * with non-locally originated hints.
+ * This flag is incompatible with the flags: %REGULATORY_CUSTOM_REG,
+ * %REGULATORY_STRICT_REG, %REGULATORY_COUNTRY_IE_FOLLOW_POWER,
+ * %REGULATORY_COUNTRY_IE_IGNORE and %REGULATORY_DISABLE_BEACON_HINTS.
+ * Mixing any of the above flags with this flag will result in a failure
+ * to register the wiphy. This flag implies
+ * %REGULATORY_DISABLE_BEACON_HINTS.
*/
enum ieee80211_regulatory_flags {
REGULATORY_CUSTOM_REG = BIT(0),
@@ -150,6 +168,7 @@ enum ieee80211_regulatory_flags {
REGULATORY_COUNTRY_IE_IGNORE = BIT(4),
REGULATORY_ENABLE_RELAX_NO_IR = BIT(5),
REGULATORY_ENFORCE_CHANNELS = BIT(6),
+ REGULATORY_WIPHY_SELF_MANAGED = BIT(7),
};
struct ieee80211_freq_range {
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index d775245..3771e7d 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -774,6 +774,9 @@
* peer given by %NL80211_ATTR_MAC. Both peers must be on the base channel
* when this command completes.
*
+ * @NL80211_CMD_WIPHY_REG_CHANGE: Similar to %NL80211_CMD_REG_CHANGE, but used
+ * for indicating changes for devices with wiphy-specific regdom management
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -958,6 +961,8 @@ enum nl80211_commands {
NL80211_CMD_TDLS_CHANNEL_SWITCH,
NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
+ NL80211_CMD_WIPHY_REG_CHANGE,
+
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 5295456..15036a4 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -559,6 +559,14 @@ int wiphy_register(struct wiphy *wiphy)
BIT(NL80211_IFTYPE_MONITOR)))))
return -EINVAL;
+ if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) &&
+ (wiphy->regulatory_flags &
+ (REGULATORY_CUSTOM_REG | REGULATORY_STRICT_REG |
+ REGULATORY_COUNTRY_IE_FOLLOW_POWER |
+ REGULATORY_COUNTRY_IE_IGNORE |
+ REGULATORY_DISABLE_BEACON_HINTS))))
+ return -EINVAL;
+
if (WARN_ON(wiphy->coalesce &&
(!wiphy->coalesce->n_rules ||
!wiphy->coalesce->n_patterns) &&
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6e41777..de3a47a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10942,25 +10942,9 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
NL80211_MCGRP_SCAN, GFP_KERNEL);
}
-/*
- * This can happen on global regulatory changes or device specific settings
- * based on custom world regulatory domains.
- */
-void nl80211_send_reg_change_event(struct regulatory_request *request)
+static bool nl80211_reg_change_event_fill(struct sk_buff *msg,
+ struct regulatory_request *request)
{
- struct sk_buff *msg;
- void *hdr;
-
- msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (!msg)
- return;
-
- hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_CHANGE);
- if (!hdr) {
- nlmsg_free(msg);
- return;
- }
-
/* Userspace can always count this one always being set */
if (nla_put_u8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator))
goto nla_put_failure;
@@ -10990,6 +10974,66 @@ void nl80211_send_reg_change_event(struct regulatory_request *request)
nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx))
goto nla_put_failure;
+ return true;
+
+nla_put_failure:
+ return false;
+}
+
+/*
+ * This can happen on global regulatory changes or device specific settings
+ * based on custom world regulatory domains.
+ */
+void nl80211_send_reg_change_event(struct regulatory_request *request)
+{
+ struct sk_buff *msg;
+ void *hdr;
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_CHANGE);
+ if (!hdr) {
+ nlmsg_free(msg);
+ return;
+ }
+
+ if (nl80211_reg_change_event_fill(msg, request) == false)
+ goto nla_put_failure;
+
+ genlmsg_end(msg, hdr);
+
+ rcu_read_lock();
+ genlmsg_multicast_allns(&nl80211_fam, msg, 0,
+ NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
+ rcu_read_unlock();
+
+ return;
+
+nla_put_failure:
+ genlmsg_cancel(msg, hdr);
+ nlmsg_free(msg);
+}
+
+void nl80211_send_wiphy_reg_change_event(struct regulatory_request *request)
+{
+ struct sk_buff *msg;
+ void *hdr;
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_WIPHY_REG_CHANGE);
+ if (!hdr) {
+ nlmsg_free(msg);
+ return;
+ }
+
+ if (nl80211_reg_change_event_fill(msg, request) == false)
+ goto nla_put_failure;
+
genlmsg_end(msg, hdr);
rcu_read_lock();
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 7ad70d6..b91b9c5 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -18,6 +18,7 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
struct net_device *netdev);
void nl80211_send_reg_change_event(struct regulatory_request *request);
+void nl80211_send_wiphy_reg_change_event(struct regulatory_request *request);
void nl80211_send_rx_auth(struct cfg80211_registered_device *rdev,
struct net_device *netdev,
const u8 *buf, size_t len, gfp_t gfp);
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 922d00a..18cf13b 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1307,6 +1307,9 @@ static bool ignore_reg_update(struct wiphy *wiphy,
{
struct regulatory_request *lr = get_last_request();
+ if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
+ return true;
+
if (!lr) {
REG_DBG_PRINT("Ignoring regulatory request set by %s "
"since last_request is not set\n",
@@ -1370,6 +1373,9 @@ static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx,
sband = wiphy->bands[reg_beacon->chan.band];
chan = &sband->channels[chan_idx];
+ if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
+ return;
+
if (likely(chan->center_freq != reg_beacon->chan.center_freq))
return;
@@ -2431,6 +2437,9 @@ static void restore_regulatory_settings(bool reset_user)
world_alpha2[1] = cfg80211_world_regdom->alpha2[1];
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
+ if (rdev->wiphy.regulatory_flags &
+ REGULATORY_WIPHY_SELF_MANAGED)
+ continue;
if (rdev->wiphy.regulatory_flags & REGULATORY_CUSTOM_REG)
restore_custom_reg_settings(&rdev->wiphy);
}
@@ -2834,6 +2843,56 @@ int set_regdom(const struct ieee80211_regdomain *rd)
return 0;
}
+int regulatory_set_wiphy_regd_rtnl(struct wiphy *wiphy,
+ struct ieee80211_regdomain *rd)
+{
+ const struct ieee80211_regdomain *regd;
+ const struct ieee80211_regdomain *tmp;
+ enum ieee80211_band band;
+ struct regulatory_request request = {};
+
+ if (WARN_ON(!wiphy || !rd))
+ return -EINVAL;
+
+ if (WARN(!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED),
+ "wiphy should have REGULATORY_WIPHY_SELF_MANAGED\n"))
+ return -EPERM;
+
+ WARN_ON_ONCE(!lockdep_rtnl_is_held());
+
+ if (WARN(!is_valid_rd(rd), "Invalid regulatory domain detected\n")) {
+ print_regdomain_info(rd);
+ return -EINVAL;
+ }
+
+ regd = reg_copy_regd(rd);
+ if (IS_ERR(regd))
+ return PTR_ERR(regd);
+
+ tmp = get_wiphy_regdom(wiphy);
+ rcu_assign_pointer(wiphy->regd, regd);
+ rcu_free_regdom(tmp);
+
+ for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+ handle_band_custom(wiphy,
+ wiphy->bands[band],
+ regd);
+ }
+
+ reg_process_ht_flags(wiphy);
+
+ request.wiphy_idx = get_wiphy_idx(wiphy);
+ request.alpha2[0] = rd->alpha2[0];
+ request.alpha2[1] = rd->alpha2[1];
+ request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
+
+ nl80211_send_wiphy_reg_change_event(&request);
+
+ reg_check_channels();
+ return 0;
+}
+EXPORT_SYMBOL(regulatory_set_wiphy_regd_rtnl);
+
void wiphy_regulatory_register(struct wiphy *wiphy)
{
struct regulatory_request *lr;
--
1.9.1
On Tue, Nov 25, 2014 at 10:28 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
>> From: Jonathan Doron <[email protected]>
>>
>> Allow usermode to query wiphy-specific regd info, for drivers that use
>> wiphy-specific regulatory management.
>>
>> Use the existing API for sending regdomain info to usermode, but return
>> the wiphy-specific regd in case wiphy index is provided and the driver
>> employs wiphy-specific management. This implies user and kernel-mode
>> support for the feature and is backward compatible.
>>
>> Signed-off-by: Jonathan Doron <[email protected]>
>> Signed-off-by: Arik Nemtsov <[email protected]>
>> ---
>> include/uapi/linux/nl80211.h | 18 ++++++++++-
>> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
>> net/wireless/reg.c | 2 +-
>> net/wireless/reg.h | 1 +
>> 4 files changed, 78 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
>> index 3771e7d..b222e5c 100644
>> --- a/include/uapi/linux/nl80211.h
>> +++ b/include/uapi/linux/nl80211.h
>> @@ -252,7 +252,12 @@
>> * %NL80211_ATTR_IFINDEX.
>> *
>> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
>> - * regulatory domain.
>> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
>> + * self-manages its regulatory settings, its private regulatory domain
>> + * will be returned.
>> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
>> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
>> + * returned, even if it's regulatory is not self-managed.
>> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
>> * after being queried by the kernel. CRDA replies by sending a regulatory
>> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
>> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
>> *
>> * @NL80211_ATTR_MAC_MASK: MAC address mask
>> *
>> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
>> + * regulatory information was obtained from the private regdomain
>> + * of a device with self-managed regulatory.
>> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
>> + * information should be obtained from a device's private regdomain,
>> + * if it exists. This will happen even if the device is not self-managing
>> + * its regulatory.
>
> As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
> drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
> Then this can be used by cfg80211 to send to userspace regdomains for wiphys
> that have used this API. Below you enable userspace to only query for these
> explictly but we want to be able to let userspace get all information, ie
> through 'iw reg get'. This should go in as a separate patch along with
> NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
> NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
> plate code for getting that reg first, getting self managed regd's can then
> go in as a clear secondary evolutionary step.
>
> The documentation for NL80211_ATTR_WIPHY_GET_PRIV_REG can refer to the new
> %REGULATORY_WIPHY_REG_HINT flag. NL80211_ATTR_WIPHY_SELF_MANAGED_REG should
> refer to %REGULATORY_WIPHY_SELF_MANAGED
>
>> @@ -5346,13 +5345,54 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
>> if (!hdr)
>> goto put_failure;
>>
>> - if (reg_last_request_cell_base() &&
>> - nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE,
>> - NL80211_USER_REG_HINT_CELL_BASE))
>> - goto nla_put_failure;
>> + if (info->attrs[NL80211_ATTR_WIPHY]) {
>> + u32 reg_flags;
>> + struct wiphy *wiphy;
>> + struct cfg80211_registered_device *rdev =
>> + cfg80211_get_dev_from_info(genl_info_net(info), info);
>> +
>> + if (IS_ERR(rdev)) {
>> + nlmsg_free(msg);
>> + return PTR_ERR(rdev);
>> + }
>> +
>> + wiphy = &rdev->wiphy;
>> + reg_flags = wiphy->regulatory_flags;
>> + if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED ||
>> + info->attrs[NL80211_ATTR_WIPHY_GET_PRIV_REG]) {
>> + regdom = get_wiphy_regdom(wiphy);
>> + if (!regdom) {
>> + nlmsg_free(msg);
>> + return -EINVAL;
>> + }
>> +
>> + if (nla_put_u32(msg, NL80211_ATTR_WIPHY,
>> + rdev->wiphy_idx))
>> + goto nla_put_failure;
>> +
>> + if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED &&
>> + nla_put_flag(msg,
>> + NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
>> + goto nla_put_failure;
>> + }
>> + }
>
> If no NL80211_ATTR_WIPHY was requested specifically it would still
> be good to send the central regulatory domain followed by each
> wiphy's own regulatory domain whether priv or managed. Can you add
> that as well? With the split above the first patch would send
> all regds for all wiphys that used regulatory_hint(), the second
> patch would extend this to add the self managed list too.
Ok I'll make the change.
Arik
On Wed, Nov 26, 2014 at 11:16 AM, Arik Nemtsov <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 5:58 PM, Luis R. Rodriguez <[email protected]> wrote:
>> On Wed, Nov 26, 2014 at 10:39 AM, Arik Nemtsov <[email protected]> wrote:
>>> On Wed, Nov 26, 2014 at 5:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>>>> On Wed, Nov 26, 2014 at 05:06:37PM +0200, Arik Nemtsov wrote:
>>>>> On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
>>>>> > On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
>>>>> >> When the regulatory settings change, some channels might become invalid.
>>>>> >> Disconnect interfaces acting on these channels, after giving userspace
>>>>> >> code a grace period to leave them.
>>>>> >>
>>>>> >> This mode is currently opt-in, and not all interface operating modes are
>>>>> >> supported for regulatory-enforcement checks. A wiphy that wishes to use
>>>>> >> the new enforcement code must specify an appropriate regulatory flag,
>>>>> >> and all its supported interface modes must be supported by the chekcing
>>>>> >> code.
>>>>> >
>>>>> > This is all looking beter now, since I had a few requests for the last patch
>>>>> > I'll ask for some other things here without asking to negage the flag purpose
>>>>> > as I originally wanted.
>>>>> >
>>>>> >> Signed-off-by: Arik Nemtsov <[email protected]>
>>>>> >> ---
>>>>> >> include/net/regulatory.h | 6 +++
>>>>> >> net/wireless/core.c | 13 ++++++
>>>>> >> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
>>>>> >> 3 files changed, 124 insertions(+), 1 deletion(-)
>>>>> >>
>>>>> >> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
>>>>> >> index dad7ab2..701177c 100644
>>>>> >> --- a/include/net/regulatory.h
>>>>> >> +++ b/include/net/regulatory.h
>>>>> >> @@ -136,6 +136,11 @@ struct regulatory_request {
>>>>> >> * otherwise initiating radiation is not allowed. This will enable the
>>>>> >> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
>>>>> >> * option
>>>>> >> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
>>>>> >> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
>>>>> >> + * change, the interfaces are given a grace period to disconnect or move
>>>>> >> + * to an allowed channels. Interfaces on forbidden channels are forcibly
>>>>> >> + * disconnected.
>>>>> >
>>>>> > Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
>>>>> > some information about the amount current of grace period used,
>>>>> > and types of interfaces supported. Since this is a regulatory flag
>>>>> > this information will help folks decide whether to enable or not.
>>>>> > Also encourage its use, and mention that once all supported devices
>>>>> > get support for this will be enabled by default. In the meantime
>>>>> > I'd prefer if this feature was enabled by default if the supported
>>>>> > interface types of a dveice match the white list of supported
>>>>> > interfaces.
>>>>>
>>>>> btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
>>>>
>>>> Indeed, the REGULATORY_IGNORE_STALE_KICKOFF would be the inversion, which
>>>> is really a better way to deal with this but Johannes considered it more
>>>> work. I'll leave it up to you but if the supported interfaces on a driver
>>>> work with it we should enable this by default. This is why the inversion
>>>> (REGULATORY_IGNORE_STALE_KICKOFF) would work better in the end, as we want
>>>> to keep this on by default and only let folks opt out.
>>>
>>> I thought we agreed this to be opt-in,
>>
>> We agreed to not have to require this to be opt-out, that's different
>> than having it enabled by default for supported devices.
>>
>>> even if all interfaces are
>>> supported? I still think an untested driver might be hurt by this
>>> patch. For instance if it requires a different grace period, etc.
>>
>> This is a generic feature and I think its important to enable it by
>> default, if a different grace period can be used it sounds like you
>> can easily fold that in as an alternative to override the default.
>
> Let's not start adding features out of speculation. I was just proving my point.
> Everything can be easily added, but perhaps not easily predicted.
OK
> But sure, I can make this default-on if only supported interfaces are
> present. And for that case, I'll set the flag as opt-out.
Thanks for the work. Its highly appreciated.
Luis
On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
> From: Jonathan Doron <[email protected]>
>
> Allow usermode to query wiphy-specific regd info, for drivers that use
> wiphy-specific regulatory management.
>
> Use the existing API for sending regdomain info to usermode, but return
> the wiphy-specific regd in case wiphy index is provided and the driver
> employs wiphy-specific management. This implies user and kernel-mode
> support for the feature and is backward compatible.
>
> Signed-off-by: Jonathan Doron <[email protected]>
> Signed-off-by: Arik Nemtsov <[email protected]>
> ---
> include/uapi/linux/nl80211.h | 18 ++++++++++-
> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
> net/wireless/reg.c | 2 +-
> net/wireless/reg.h | 1 +
> 4 files changed, 78 insertions(+), 14 deletions(-)
>
> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> index 3771e7d..b222e5c 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -252,7 +252,12 @@
> * %NL80211_ATTR_IFINDEX.
> *
> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
> - * regulatory domain.
> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
> + * self-manages its regulatory settings, its private regulatory domain
> + * will be returned.
> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
> + * returned, even if it's regulatory is not self-managed.
> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
> * after being queried by the kernel. CRDA replies by sending a regulatory
> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
> *
> * @NL80211_ATTR_MAC_MASK: MAC address mask
> *
> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
> + * regulatory information was obtained from the private regdomain
> + * of a device with self-managed regulatory.
> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
> + * information should be obtained from a device's private regdomain,
> + * if it exists. This will happen even if the device is not self-managing
> + * its regulatory.
As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
Then this can be used by cfg80211 to send to userspace regdomains for wiphys
that have used this API. Below you enable userspace to only query for these
explictly but we want to be able to let userspace get all information, ie
through 'iw reg get'. This should go in as a separate patch along with
NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
plate code for getting that reg first, getting self managed regd's can then
go in as a clear secondary evolutionary step.
The documentation for NL80211_ATTR_WIPHY_GET_PRIV_REG can refer to the new
%REGULATORY_WIPHY_REG_HINT flag. NL80211_ATTR_WIPHY_SELF_MANAGED_REG should
refer to %REGULATORY_WIPHY_SELF_MANAGED
> @@ -5346,13 +5345,54 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
> if (!hdr)
> goto put_failure;
>
> - if (reg_last_request_cell_base() &&
> - nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE,
> - NL80211_USER_REG_HINT_CELL_BASE))
> - goto nla_put_failure;
> + if (info->attrs[NL80211_ATTR_WIPHY]) {
> + u32 reg_flags;
> + struct wiphy *wiphy;
> + struct cfg80211_registered_device *rdev =
> + cfg80211_get_dev_from_info(genl_info_net(info), info);
> +
> + if (IS_ERR(rdev)) {
> + nlmsg_free(msg);
> + return PTR_ERR(rdev);
> + }
> +
> + wiphy = &rdev->wiphy;
> + reg_flags = wiphy->regulatory_flags;
> + if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED ||
> + info->attrs[NL80211_ATTR_WIPHY_GET_PRIV_REG]) {
> + regdom = get_wiphy_regdom(wiphy);
> + if (!regdom) {
> + nlmsg_free(msg);
> + return -EINVAL;
> + }
> +
> + if (nla_put_u32(msg, NL80211_ATTR_WIPHY,
> + rdev->wiphy_idx))
> + goto nla_put_failure;
> +
> + if (reg_flags & REGULATORY_WIPHY_SELF_MANAGED &&
> + nla_put_flag(msg,
> + NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
> + goto nla_put_failure;
> + }
> + }
If no NL80211_ATTR_WIPHY was requested specifically it would still
be good to send the central regulatory domain followed by each
wiphy's own regulatory domain whether priv or managed. Can you add
that as well? With the split above the first patch would send
all regds for all wiphys that used regulatory_hint(), the second
patch would extend this to add the self managed list too.
I think we really need then only two interfaces:
iw reg get
iw reg get dev wlan0
I don't think we need to be letting userspace asking for
NL80211_ATTR_WIPHY_SELF_MANAGED_REG regds or priv ones.
Luis
On Wed, Nov 26, 2014 at 6:47 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 11:43 AM, Arik Nemtsov <[email protected]> wrote:
>> On Tue, Nov 25, 2014 at 10:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>>> On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
>>>> From: Jonathan Doron <[email protected]>
>>>>
>>>> Allow usermode to query wiphy-specific regd info, for drivers that use
>>>> wiphy-specific regulatory management.
>>>>
>>>> Use the existing API for sending regdomain info to usermode, but return
>>>> the wiphy-specific regd in case wiphy index is provided and the driver
>>>> employs wiphy-specific management. This implies user and kernel-mode
>>>> support for the feature and is backward compatible.
>>>>
>>>> Signed-off-by: Jonathan Doron <[email protected]>
>>>> Signed-off-by: Arik Nemtsov <[email protected]>
>>>> ---
>>>> include/uapi/linux/nl80211.h | 18 ++++++++++-
>>>> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
>>>> net/wireless/reg.c | 2 +-
>>>> net/wireless/reg.h | 1 +
>>>> 4 files changed, 78 insertions(+), 14 deletions(-)
>>>>
>>>> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
>>>> index 3771e7d..b222e5c 100644
>>>> --- a/include/uapi/linux/nl80211.h
>>>> +++ b/include/uapi/linux/nl80211.h
>>>> @@ -252,7 +252,12 @@
>>>> * %NL80211_ATTR_IFINDEX.
>>>> *
>>>> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
>>>> - * regulatory domain.
>>>> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
>>>> + * self-manages its regulatory settings, its private regulatory domain
>>>> + * will be returned.
>>>> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
>>>> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
>>>> + * returned, even if it's regulatory is not self-managed.
>>>> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
>>>> * after being queried by the kernel. CRDA replies by sending a regulatory
>>>> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
>>>> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
>>>> *
>>>> * @NL80211_ATTR_MAC_MASK: MAC address mask
>>>> *
>>>> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
>>>> + * regulatory information was obtained from the private regdomain
>>>> + * of a device with self-managed regulatory.
>>>> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
>>>> + * information should be obtained from a device's private regdomain,
>>>> + * if it exists. This will happen even if the device is not self-managing
>>>> + * its regulatory.
>>>
>>> As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
>>> drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
>>> Then this can be used by cfg80211 to send to userspace regdomains for wiphys
>>> that have used this API. Below you enable userspace to only query for these
>>> explictly but we want to be able to let userspace get all information, ie
>>> through 'iw reg get'. This should go in as a separate patch along with
>>> NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
>>> NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
>>> plate code for getting that reg first, getting self managed regd's can then
>>> go in as a clear secondary evolutionary step.
>>
>> Note that we don't really need the new REGULATORY_WIPHY_REG_HINT.. If
>> a wiphy is not self-managed, we can just put
>> NL80211_ATTR_WIPHY_PRIV_REG, since it's obvious the regulatory_hint
>> API was used.
>
> What if a driver sets the managed flag and then uses regulatory_hint()
> ? Either way if this is addressed and we can also infer what type of
> wiphy->regd it is well that's OK with me, the flag idea was just in
> case we needed it, so I think you might be right.
A self-managed device can't use regulatory_hint().. This is the
regular path which also updates the cfg80211 regdomain.
If a device tries to do that, the new regd from CRDA will never reach
it. So we're covered here.
Arik
On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
>> When the regulatory settings change, some channels might become invalid.
>> Disconnect interfaces acting on these channels, after giving userspace
>> code a grace period to leave them.
>>
>> This mode is currently opt-in, and not all interface operating modes are
>> supported for regulatory-enforcement checks. A wiphy that wishes to use
>> the new enforcement code must specify an appropriate regulatory flag,
>> and all its supported interface modes must be supported by the chekcing
>> code.
>
> This is all looking beter now, since I had a few requests for the last patch
> I'll ask for some other things here without asking to negage the flag purpose
> as I originally wanted.
>
>> Signed-off-by: Arik Nemtsov <[email protected]>
>> ---
>> include/net/regulatory.h | 6 +++
>> net/wireless/core.c | 13 ++++++
>> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
>> 3 files changed, 124 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
>> index dad7ab2..701177c 100644
>> --- a/include/net/regulatory.h
>> +++ b/include/net/regulatory.h
>> @@ -136,6 +136,11 @@ struct regulatory_request {
>> * otherwise initiating radiation is not allowed. This will enable the
>> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
>> * option
>> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
>> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
>> + * change, the interfaces are given a grace period to disconnect or move
>> + * to an allowed channels. Interfaces on forbidden channels are forcibly
>> + * disconnected.
>
> Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
> some information about the amount current of grace period used,
> and types of interfaces supported. Since this is a regulatory flag
> this information will help folks decide whether to enable or not.
> Also encourage its use, and mention that once all supported devices
> get support for this will be enabled by default. In the meantime
> I'd prefer if this feature was enabled by default if the supported
> interface types of a dveice match the white list of supported
> interfaces.
btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
Arik
On Wed, Nov 26, 2014 at 11:49 AM, Arik Nemtsov <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 6:47 PM, Luis R. Rodriguez <[email protected]> wrote:
>> On Wed, Nov 26, 2014 at 11:43 AM, Arik Nemtsov <[email protected]> wrote:
>>> On Tue, Nov 25, 2014 at 10:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>>>> On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
>>>>> From: Jonathan Doron <[email protected]>
>>>>>
>>>>> Allow usermode to query wiphy-specific regd info, for drivers that use
>>>>> wiphy-specific regulatory management.
>>>>>
>>>>> Use the existing API for sending regdomain info to usermode, but return
>>>>> the wiphy-specific regd in case wiphy index is provided and the driver
>>>>> employs wiphy-specific management. This implies user and kernel-mode
>>>>> support for the feature and is backward compatible.
>>>>>
>>>>> Signed-off-by: Jonathan Doron <[email protected]>
>>>>> Signed-off-by: Arik Nemtsov <[email protected]>
>>>>> ---
>>>>> include/uapi/linux/nl80211.h | 18 ++++++++++-
>>>>> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
>>>>> net/wireless/reg.c | 2 +-
>>>>> net/wireless/reg.h | 1 +
>>>>> 4 files changed, 78 insertions(+), 14 deletions(-)
>>>>>
>>>>> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
>>>>> index 3771e7d..b222e5c 100644
>>>>> --- a/include/uapi/linux/nl80211.h
>>>>> +++ b/include/uapi/linux/nl80211.h
>>>>> @@ -252,7 +252,12 @@
>>>>> * %NL80211_ATTR_IFINDEX.
>>>>> *
>>>>> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
>>>>> - * regulatory domain.
>>>>> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
>>>>> + * self-manages its regulatory settings, its private regulatory domain
>>>>> + * will be returned.
>>>>> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
>>>>> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
>>>>> + * returned, even if it's regulatory is not self-managed.
>>>>> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
>>>>> * after being queried by the kernel. CRDA replies by sending a regulatory
>>>>> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
>>>>> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
>>>>> *
>>>>> * @NL80211_ATTR_MAC_MASK: MAC address mask
>>>>> *
>>>>> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
>>>>> + * regulatory information was obtained from the private regdomain
>>>>> + * of a device with self-managed regulatory.
>>>>> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
>>>>> + * information should be obtained from a device's private regdomain,
>>>>> + * if it exists. This will happen even if the device is not self-managing
>>>>> + * its regulatory.
>>>>
>>>> As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
>>>> drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
>>>> Then this can be used by cfg80211 to send to userspace regdomains for wiphys
>>>> that have used this API. Below you enable userspace to only query for these
>>>> explictly but we want to be able to let userspace get all information, ie
>>>> through 'iw reg get'. This should go in as a separate patch along with
>>>> NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
>>>> NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
>>>> plate code for getting that reg first, getting self managed regd's can then
>>>> go in as a clear secondary evolutionary step.
>>>
>>> Note that we don't really need the new REGULATORY_WIPHY_REG_HINT.. If
>>> a wiphy is not self-managed, we can just put
>>> NL80211_ATTR_WIPHY_PRIV_REG, since it's obvious the regulatory_hint
>>> API was used.
>>
>> What if a driver sets the managed flag and then uses regulatory_hint()
>> ? Either way if this is addressed and we can also infer what type of
>> wiphy->regd it is well that's OK with me, the flag idea was just in
>> case we needed it, so I think you might be right.
>
> A self-managed device can't use regulatory_hint().. This is the
> regular path which also updates the cfg80211 regdomain.
> If a device tries to do that, the new regd from CRDA will never reach
> it. So we're covered here.
OK cool.
Luis
On Sun, Nov 23, 2014 at 5:02 PM, Arik Nemtsov <[email protected]> wrote:
> +int regulatory_set_wiphy_regd_rtnl(struct wiphy *wiphy,
> + struct ieee80211_regdomain *rd)
> +{
You gave us Reviewed-by, and it's appreciated, but unfortunately we
have to change the API a bit.
It appears we can't take the RTNL from within a driver safely - on
driver unload, we might have a work-item that needs the RTNL pending,
and the driver unload itself already acquires RTNL.
So we'll modify the code a bit to set a wiphy->requested_regd and do
the actual work inside reg_todo.
We'll resubmit shortly.
Arik
On Sun, Nov 23, 2014 at 05:02:20PM +0200, Arik Nemtsov wrote:
> From: Jonathan Doron <[email protected]>
>
> Add a new regulatory flag that allows a driver to manage regdomain
> changes/updates for its own wiphy.
> A self-managed wiphys only employs regulatory information obtained from
> the FW and driver and does not use other cfg80211 sources like
> beacon-hints, country-code IEs and hints from other devices on the same
> system. Conversely, a self-managed wiphy does not share its regulatory
> hints with other devices in the system. If a system contains several
> devices, one or more of which are self-managed, there might be
> contradictory regulatory settings between them. Usage of flag is
> generally discouraged. Only use it if the FW/driver is incompatible
> with non-locally originated hints.
>
> A new API lets the driver send a complete regdomain, to be applied on
> its wiphy only.
>
> After a wiphy-specific regdomain change takes place, usermode will get
> a new type of change notification. The regulatory core also takes care
> enforce regulatory restrictions, in case some interfaces are on
> forbidden channels.
>
> Signed-off-by: Jonathan Doron <[email protected]>
> Signed-off-by: Arik Nemtsov <[email protected]>
Reviewed-by: Luis R. Rodriguez <[email protected]>
Luis
On Wed, Nov 26, 2014 at 10:39 AM, Arik Nemtsov <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 5:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>> On Wed, Nov 26, 2014 at 05:06:37PM +0200, Arik Nemtsov wrote:
>>> On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
>>> > On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
>>> >> When the regulatory settings change, some channels might become invalid.
>>> >> Disconnect interfaces acting on these channels, after giving userspace
>>> >> code a grace period to leave them.
>>> >>
>>> >> This mode is currently opt-in, and not all interface operating modes are
>>> >> supported for regulatory-enforcement checks. A wiphy that wishes to use
>>> >> the new enforcement code must specify an appropriate regulatory flag,
>>> >> and all its supported interface modes must be supported by the chekcing
>>> >> code.
>>> >
>>> > This is all looking beter now, since I had a few requests for the last patch
>>> > I'll ask for some other things here without asking to negage the flag purpose
>>> > as I originally wanted.
>>> >
>>> >> Signed-off-by: Arik Nemtsov <[email protected]>
>>> >> ---
>>> >> include/net/regulatory.h | 6 +++
>>> >> net/wireless/core.c | 13 ++++++
>>> >> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
>>> >> 3 files changed, 124 insertions(+), 1 deletion(-)
>>> >>
>>> >> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
>>> >> index dad7ab2..701177c 100644
>>> >> --- a/include/net/regulatory.h
>>> >> +++ b/include/net/regulatory.h
>>> >> @@ -136,6 +136,11 @@ struct regulatory_request {
>>> >> * otherwise initiating radiation is not allowed. This will enable the
>>> >> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
>>> >> * option
>>> >> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
>>> >> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
>>> >> + * change, the interfaces are given a grace period to disconnect or move
>>> >> + * to an allowed channels. Interfaces on forbidden channels are forcibly
>>> >> + * disconnected.
>>> >
>>> > Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
>>> > some information about the amount current of grace period used,
>>> > and types of interfaces supported. Since this is a regulatory flag
>>> > this information will help folks decide whether to enable or not.
>>> > Also encourage its use, and mention that once all supported devices
>>> > get support for this will be enabled by default. In the meantime
>>> > I'd prefer if this feature was enabled by default if the supported
>>> > interface types of a dveice match the white list of supported
>>> > interfaces.
>>>
>>> btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
>>
>> Indeed, the REGULATORY_IGNORE_STALE_KICKOFF would be the inversion, which
>> is really a better way to deal with this but Johannes considered it more
>> work. I'll leave it up to you but if the supported interfaces on a driver
>> work with it we should enable this by default. This is why the inversion
>> (REGULATORY_IGNORE_STALE_KICKOFF) would work better in the end, as we want
>> to keep this on by default and only let folks opt out.
>
> I thought we agreed this to be opt-in,
We agreed to not have to require this to be opt-out, that's different
than having it enabled by default for supported devices.
> even if all interfaces are
> supported? I still think an untested driver might be hurt by this
> patch. For instance if it requires a different grace period, etc.
This is a generic feature and I think its important to enable it by
default, if a different grace period can be used it sounds like you
can easily fold that in as an alternative to override the default.
Luis
On Wed, Nov 26, 2014 at 11:43 AM, Arik Nemtsov <[email protected]> wrote:
> On Tue, Nov 25, 2014 at 10:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>> On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
>>> From: Jonathan Doron <[email protected]>
>>>
>>> Allow usermode to query wiphy-specific regd info, for drivers that use
>>> wiphy-specific regulatory management.
>>>
>>> Use the existing API for sending regdomain info to usermode, but return
>>> the wiphy-specific regd in case wiphy index is provided and the driver
>>> employs wiphy-specific management. This implies user and kernel-mode
>>> support for the feature and is backward compatible.
>>>
>>> Signed-off-by: Jonathan Doron <[email protected]>
>>> Signed-off-by: Arik Nemtsov <[email protected]>
>>> ---
>>> include/uapi/linux/nl80211.h | 18 ++++++++++-
>>> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
>>> net/wireless/reg.c | 2 +-
>>> net/wireless/reg.h | 1 +
>>> 4 files changed, 78 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
>>> index 3771e7d..b222e5c 100644
>>> --- a/include/uapi/linux/nl80211.h
>>> +++ b/include/uapi/linux/nl80211.h
>>> @@ -252,7 +252,12 @@
>>> * %NL80211_ATTR_IFINDEX.
>>> *
>>> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
>>> - * regulatory domain.
>>> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
>>> + * self-manages its regulatory settings, its private regulatory domain
>>> + * will be returned.
>>> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
>>> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
>>> + * returned, even if it's regulatory is not self-managed.
>>> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
>>> * after being queried by the kernel. CRDA replies by sending a regulatory
>>> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
>>> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
>>> *
>>> * @NL80211_ATTR_MAC_MASK: MAC address mask
>>> *
>>> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
>>> + * regulatory information was obtained from the private regdomain
>>> + * of a device with self-managed regulatory.
>>> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
>>> + * information should be obtained from a device's private regdomain,
>>> + * if it exists. This will happen even if the device is not self-managing
>>> + * its regulatory.
>>
>> As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
>> drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
>> Then this can be used by cfg80211 to send to userspace regdomains for wiphys
>> that have used this API. Below you enable userspace to only query for these
>> explictly but we want to be able to let userspace get all information, ie
>> through 'iw reg get'. This should go in as a separate patch along with
>> NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
>> NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
>> plate code for getting that reg first, getting self managed regd's can then
>> go in as a clear secondary evolutionary step.
>
> Note that we don't really need the new REGULATORY_WIPHY_REG_HINT.. If
> a wiphy is not self-managed, we can just put
> NL80211_ATTR_WIPHY_PRIV_REG, since it's obvious the regulatory_hint
> API was used.
What if a driver sets the managed flag and then uses regulatory_hint()
? Either way if this is addressed and we can also infer what type of
wiphy->regd it is well that's OK with me, the flag idea was just in
case we needed it, so I think you might be right.
Luis
On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
>
> Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
> some information about the amount current of grace period used,
> and types of interfaces supported. Since this is a regulatory flag
> this information will help folks decide whether to enable or not.
> Also encourage its use, and mention that once all supported devices
> get support for this will be enabled by default. In the meantime
> I'd prefer if this feature was enabled by default if the supported
> interface types of a dveice match the white list of supported
> interfaces.
Will do.
Arik
On Wed, Nov 26, 2014 at 05:06:37PM +0200, Arik Nemtsov wrote:
> On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
> > On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
> >> When the regulatory settings change, some channels might become invalid.
> >> Disconnect interfaces acting on these channels, after giving userspace
> >> code a grace period to leave them.
> >>
> >> This mode is currently opt-in, and not all interface operating modes are
> >> supported for regulatory-enforcement checks. A wiphy that wishes to use
> >> the new enforcement code must specify an appropriate regulatory flag,
> >> and all its supported interface modes must be supported by the chekcing
> >> code.
> >
> > This is all looking beter now, since I had a few requests for the last patch
> > I'll ask for some other things here without asking to negage the flag purpose
> > as I originally wanted.
> >
> >> Signed-off-by: Arik Nemtsov <[email protected]>
> >> ---
> >> include/net/regulatory.h | 6 +++
> >> net/wireless/core.c | 13 ++++++
> >> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
> >> 3 files changed, 124 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
> >> index dad7ab2..701177c 100644
> >> --- a/include/net/regulatory.h
> >> +++ b/include/net/regulatory.h
> >> @@ -136,6 +136,11 @@ struct regulatory_request {
> >> * otherwise initiating radiation is not allowed. This will enable the
> >> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
> >> * option
> >> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
> >> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
> >> + * change, the interfaces are given a grace period to disconnect or move
> >> + * to an allowed channels. Interfaces on forbidden channels are forcibly
> >> + * disconnected.
> >
> > Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
> > some information about the amount current of grace period used,
> > and types of interfaces supported. Since this is a regulatory flag
> > this information will help folks decide whether to enable or not.
> > Also encourage its use, and mention that once all supported devices
> > get support for this will be enabled by default. In the meantime
> > I'd prefer if this feature was enabled by default if the supported
> > interface types of a dveice match the white list of supported
> > interfaces.
>
> btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
Indeed, the REGULATORY_IGNORE_STALE_KICKOFF would be the inversion, which
is really a better way to deal with this but Johannes considered it more
work. I'll leave it up to you but if the supported interfaces on a driver
work with it we should enable this by default. This is why the inversion
(REGULATORY_IGNORE_STALE_KICKOFF) would work better in the end, as we want
to keep this on by default and only let folks opt out.
Luis
On Wed, Nov 26, 2014 at 5:28 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 05:06:37PM +0200, Arik Nemtsov wrote:
>> On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
>> > On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
>> >> When the regulatory settings change, some channels might become invalid.
>> >> Disconnect interfaces acting on these channels, after giving userspace
>> >> code a grace period to leave them.
>> >>
>> >> This mode is currently opt-in, and not all interface operating modes are
>> >> supported for regulatory-enforcement checks. A wiphy that wishes to use
>> >> the new enforcement code must specify an appropriate regulatory flag,
>> >> and all its supported interface modes must be supported by the chekcing
>> >> code.
>> >
>> > This is all looking beter now, since I had a few requests for the last patch
>> > I'll ask for some other things here without asking to negage the flag purpose
>> > as I originally wanted.
>> >
>> >> Signed-off-by: Arik Nemtsov <[email protected]>
>> >> ---
>> >> include/net/regulatory.h | 6 +++
>> >> net/wireless/core.c | 13 ++++++
>> >> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
>> >> 3 files changed, 124 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
>> >> index dad7ab2..701177c 100644
>> >> --- a/include/net/regulatory.h
>> >> +++ b/include/net/regulatory.h
>> >> @@ -136,6 +136,11 @@ struct regulatory_request {
>> >> * otherwise initiating radiation is not allowed. This will enable the
>> >> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
>> >> * option
>> >> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
>> >> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
>> >> + * change, the interfaces are given a grace period to disconnect or move
>> >> + * to an allowed channels. Interfaces on forbidden channels are forcibly
>> >> + * disconnected.
>> >
>> > Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
>> > some information about the amount current of grace period used,
>> > and types of interfaces supported. Since this is a regulatory flag
>> > this information will help folks decide whether to enable or not.
>> > Also encourage its use, and mention that once all supported devices
>> > get support for this will be enabled by default. In the meantime
>> > I'd prefer if this feature was enabled by default if the supported
>> > interface types of a dveice match the white list of supported
>> > interfaces.
>>
>> btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
>
> Indeed, the REGULATORY_IGNORE_STALE_KICKOFF would be the inversion, which
> is really a better way to deal with this but Johannes considered it more
> work. I'll leave it up to you but if the supported interfaces on a driver
> work with it we should enable this by default. This is why the inversion
> (REGULATORY_IGNORE_STALE_KICKOFF) would work better in the end, as we want
> to keep this on by default and only let folks opt out.
I thought we agreed this to be opt-in, even if all interfaces are
supported? I still think an untested driver might be hurt by this
patch. For instance if it requires a different grace period, etc.
Arik
On Wed, Nov 26, 2014 at 5:58 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Wed, Nov 26, 2014 at 10:39 AM, Arik Nemtsov <[email protected]> wrote:
>> On Wed, Nov 26, 2014 at 5:28 PM, Luis R. Rodriguez <[email protected]> wrote:
>>> On Wed, Nov 26, 2014 at 05:06:37PM +0200, Arik Nemtsov wrote:
>>>> On Tue, Nov 25, 2014 at 9:38 PM, Luis R. Rodriguez <[email protected]> wrote:
>>>> > On Sun, Nov 23, 2014 at 05:02:19PM +0200, Arik Nemtsov wrote:
>>>> >> When the regulatory settings change, some channels might become invalid.
>>>> >> Disconnect interfaces acting on these channels, after giving userspace
>>>> >> code a grace period to leave them.
>>>> >>
>>>> >> This mode is currently opt-in, and not all interface operating modes are
>>>> >> supported for regulatory-enforcement checks. A wiphy that wishes to use
>>>> >> the new enforcement code must specify an appropriate regulatory flag,
>>>> >> and all its supported interface modes must be supported by the chekcing
>>>> >> code.
>>>> >
>>>> > This is all looking beter now, since I had a few requests for the last patch
>>>> > I'll ask for some other things here without asking to negage the flag purpose
>>>> > as I originally wanted.
>>>> >
>>>> >> Signed-off-by: Arik Nemtsov <[email protected]>
>>>> >> ---
>>>> >> include/net/regulatory.h | 6 +++
>>>> >> net/wireless/core.c | 13 ++++++
>>>> >> net/wireless/reg.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
>>>> >> 3 files changed, 124 insertions(+), 1 deletion(-)
>>>> >>
>>>> >> diff --git a/include/net/regulatory.h b/include/net/regulatory.h
>>>> >> index dad7ab2..701177c 100644
>>>> >> --- a/include/net/regulatory.h
>>>> >> +++ b/include/net/regulatory.h
>>>> >> @@ -136,6 +136,11 @@ struct regulatory_request {
>>>> >> * otherwise initiating radiation is not allowed. This will enable the
>>>> >> * relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
>>>> >> * option
>>>> >> + * @REGULATORY_ENFORCE_CHANNELS: the regulatory core will make sure all
>>>> >> + * interfaces on this wiphy reside on allowed channels. Upon a regdomain
>>>> >> + * change, the interfaces are given a grace period to disconnect or move
>>>> >> + * to an allowed channels. Interfaces on forbidden channels are forcibly
>>>> >> + * disconnected.
>>>> >
>>>> > Please rename to REGULATORY_IGNORE_STALE_KICKOFF, also please add
>>>> > some information about the amount current of grace period used,
>>>> > and types of interfaces supported. Since this is a regulatory flag
>>>> > this information will help folks decide whether to enable or not.
>>>> > Also encourage its use, and mention that once all supported devices
>>>> > get support for this will be enabled by default. In the meantime
>>>> > I'd prefer if this feature was enabled by default if the supported
>>>> > interface types of a dveice match the white list of supported
>>>> > interfaces.
>>>>
>>>> btw, I think you meant REGULATORY_STALE_KICKOFF, since it's an opt-in flag.
>>>
>>> Indeed, the REGULATORY_IGNORE_STALE_KICKOFF would be the inversion, which
>>> is really a better way to deal with this but Johannes considered it more
>>> work. I'll leave it up to you but if the supported interfaces on a driver
>>> work with it we should enable this by default. This is why the inversion
>>> (REGULATORY_IGNORE_STALE_KICKOFF) would work better in the end, as we want
>>> to keep this on by default and only let folks opt out.
>>
>> I thought we agreed this to be opt-in,
>
> We agreed to not have to require this to be opt-out, that's different
> than having it enabled by default for supported devices.
>
>> even if all interfaces are
>> supported? I still think an untested driver might be hurt by this
>> patch. For instance if it requires a different grace period, etc.
>
> This is a generic feature and I think its important to enable it by
> default, if a different grace period can be used it sounds like you
> can easily fold that in as an alternative to override the default.
Let's not start adding features out of speculation. I was just proving my point.
Everything can be easily added, but perhaps not easily predicted.
But sure, I can make this default-on if only supported interfaces are
present. And for that case, I'll set the flag as opt-out.
Arik
On Tue, Nov 25, 2014 at 10:28 PM, Luis R. Rodriguez <[email protected]> wrote:
> On Sun, Nov 23, 2014 at 05:02:21PM +0200, Arik Nemtsov wrote:
>> From: Jonathan Doron <[email protected]>
>>
>> Allow usermode to query wiphy-specific regd info, for drivers that use
>> wiphy-specific regulatory management.
>>
>> Use the existing API for sending regdomain info to usermode, but return
>> the wiphy-specific regd in case wiphy index is provided and the driver
>> employs wiphy-specific management. This implies user and kernel-mode
>> support for the feature and is backward compatible.
>>
>> Signed-off-by: Jonathan Doron <[email protected]>
>> Signed-off-by: Arik Nemtsov <[email protected]>
>> ---
>> include/uapi/linux/nl80211.h | 18 ++++++++++-
>> net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++--------
>> net/wireless/reg.c | 2 +-
>> net/wireless/reg.h | 1 +
>> 4 files changed, 78 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
>> index 3771e7d..b222e5c 100644
>> --- a/include/uapi/linux/nl80211.h
>> +++ b/include/uapi/linux/nl80211.h
>> @@ -252,7 +252,12 @@
>> * %NL80211_ATTR_IFINDEX.
>> *
>> * @NL80211_CMD_GET_REG: ask the wireless core to send us its currently set
>> - * regulatory domain.
>> + * regulatory domain. If %NL80211_ATTR_WIPHY is specified and the device
>> + * self-manages its regulatory settings, its private regulatory domain
>> + * will be returned.
>> + * If %NL80211_ATTR_WIPHY_GET_PRIV_REG is specified in addition to
>> + * %NL80211_ATTR_WIPHY, a device's private regulatory domain will be
>> + * returned, even if it's regulatory is not self-managed.
>> * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
>> * after being queried by the kernel. CRDA replies by sending a regulatory
>> * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
>> @@ -1693,6 +1698,14 @@ enum nl80211_commands {
>> *
>> * @NL80211_ATTR_MAC_MASK: MAC address mask
>> *
>> + * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating the
>> + * regulatory information was obtained from the private regdomain
>> + * of a device with self-managed regulatory.
>> + * @NL80211_ATTR_WIPHY_GET_PRIV_REG: flag attribute indicating the regulatory
>> + * information should be obtained from a device's private regdomain,
>> + * if it exists. This will happen even if the device is not self-managing
>> + * its regulatory.
>
> As with REGULATORY_WIPHY_SELF_MANAGED we need a flag that cfg80211 sets for
> drivers that use regulatory_hint() API, perhaps REGULATORY_WIPHY_REG_HINT.
> Then this can be used by cfg80211 to send to userspace regdomains for wiphys
> that have used this API. Below you enable userspace to only query for these
> explictly but we want to be able to let userspace get all information, ie
> through 'iw reg get'. This should go in as a separate patch along with
> NL80211_ATTR_WIPHY_GET_PRIV_REG as its use predates
> NL80211_ATTR_WIPHY_SELF_MANAGED_REG, this will also let you stuff in the boiler
> plate code for getting that reg first, getting self managed regd's can then
> go in as a clear secondary evolutionary step.
Note that we don't really need the new REGULATORY_WIPHY_REG_HINT.. If
a wiphy is not self-managed, we can just put
NL80211_ATTR_WIPHY_PRIV_REG, since it's obvious the regulatory_hint
API was used.
Arik