cfg80211: Add API to change the indoor regulatory setting
PATCH v2 1/2 cfg80211: Add API to change the indoor regulatory setting
As the operating environment of a device can change, add API for user space to indicate a change of indoor settings. In addition modify the handling of the indoor processing as follows:
1. Directly update the indoor setting without wrapping it as a regulatory request.
2. Track the socket on which the indoor hint is issued, and reset indoor setting if the socket was released.
3. Do not reset the indoor setting when restoring the regulatory settings as it has nothing to do with CRDA or interface disconnection.
--- include/uapi/linux/nl80211.h | 5 +++ net/wireless/nl80211.c | 10 +++++- net/wireless/reg.c | 80 +++++++++++++++++++++++++------------------- net/wireless/reg.h | 15 ++++++++- 4 files changed, 73 insertions(+), 37 deletions(-)
include/uapi/linux/nl80211.h +5 -0
@@ -1713,6 +1713,9 @@ enum nl80211_commands {* obtained from it is coming from the device's wiphy and not the global * cfg80211 regdomain. * +* @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device +* is operating in an indoor environment. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2072,6 +2075,8 @@ enum nl80211_attrs {NL80211_ATTR_WIPHY_SELF_MANAGED_REG , +NL80211_ATTR_REG_INDOOR , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +9 -1
@@ -397,6 +397,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [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_REG_INDOOR] = { .type = NLA_FLAG }, };/* policy for the key attributes */
@@ -4923,6 +4924,7 @@ static int parse_reg_rule(struct nlattr *tb[],static int nl80211_req_set_reg (struct sk_buff *skb,struct genl_info *info) {char *data =NULL ; +bool is_indoor;enum nl80211_user_reg_hint_type user_reg_hint_type;/*
@@ -4949,7 +4951,8 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) data =nla_data (info->attrs[NL80211_ATTR_REG_ALPHA2 ]);return regulatory_hint_user (data, user_reg_hint_type);case NL80211_USER_REG_HINT_INDOOR : -return regulatory_hint_indoor_user (); + is_indoor = !!info->attrs[NL80211_ATTR_REG_INDOOR ]; +return regulatory_hint_indoor (is_indoor, info->snd_portid);default :return -EINVAL ; }
@@ -12669,6 +12672,11 @@ static int nl80211_netlink_notify(struct notifier_block * nb,rcu_read_unlock (); +/* +* It is possible that the user space process that is controlling the +* indoor setting disappeared, so notify the regulatory core. +*/ +regulatory_netlink_notify (notify->portid);return NOTIFY_OK ; }
net/wireless/reg.c +45 -35
161 lines not on this page · raw message
net/wireless/reg.h +14 -1
@@ -25,7 +25,20 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy);int regulatory_hint_user (const char *alpha2,enum nl80211_user_reg_hint_type user_reg_hint_type); -int regulatory_hint_indoor_user (void ); + +/** +* regulatory_hint_indoor - hint operation in indoor env. or not +* @is_indoor: if true indicates that user space thinks that the +* device is operating in an indoor environment. +* @portid: the netlink port ID on which the hint was given. +*/ +int regulatory_hint_indoor (bool is_indoor,u32 portid); + +/** +* regulatory_netlink_notify - notify on released netlink socket +* @portid: the netlink socket port ID +*/ +void regulatory_netlink_notify (u32 portid);void wiphy_regulatory_register (struct wiphy *wiphy);void wiphy_regulatory_deregister (struct wiphy *wiphy);
Signature · 1 line
1.8.3.2
PATCH v2 2/2 cfg80211: Schedule timeout for all CRDA calls
Timeout was scheduled only in case CRDA was called due to user hints, but was not scheduled for other cases. This can result in regulatory hint processing getting stuck in case that there is no CRDA configured.
Change this by scheduling a timeout every time CRDA is called. In addition, in restore_regulatory_settings() all pending requests are restored (and not only the user ones).
--- net/wireless/reg.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
net/wireless/reg.c +5 -10
@@ -552,6 +552,9 @@ reg_call_crda(struct regulatory_request *request) {if (call_crda (request->alpha2))return REG_REQ_IGNORE ; + +queue_delayed_work (system_power_efficient_wq, + ®_timeout,msecs_to_jiffies (3142 ));return REG_REQ_OK ; }
@@ -1773,8 +1776,7 @@ static void reg_set_request_processed(void) need_more_processing = true;spin_unlock (®_requests_lock); -if (lr->initiator ==NL80211_REGDOM_SET_BY_USER ) -cancel_delayed_work (®_timeout); +cancel_delayed_work (®_timeout);if (need_more_processing)schedule_work (®_work);
@@ -2053,8 +2055,6 @@ static void reg_process_hint(struct regulatory_request *reg_request)if (treatment ==REG_REQ_IGNORE || treatment ==REG_REQ_ALREADY_SET )return ; -queue_delayed_work (system_power_efficient_wq, - ®_timeout,msecs_to_jiffies (3142 ));return ;case NL80211_REGDOM_SET_BY_DRIVER :if (!wiphy)
@@ -2454,7 +2454,6 @@ static void restore_regulatory_settings(bool reset_user)char alpha2[2 ];char world_alpha2[2 ];struct reg_beacon *reg_beacon, *btmp; -struct regulatory_request *reg_request, *tmp;LIST_HEAD (tmp_reg_req_list);struct cfg80211_registered_device *rdev;
@@ -2470,11 +2469,7 @@ static void restore_regulatory_settings(bool reset_user)* settings. */ spin_lock (®_requests_lock); -list_for_each_entry_safe (reg_request, tmp, ®_requests_list, list) { -if (reg_request->initiator !=NL80211_REGDOM_SET_BY_USER ) -continue ; -list_move_tail (®_request->list, &tmp_reg_req_list); - } +list_splice_tail_init (®_requests_list, &tmp_reg_req_list);spin_unlock (®_requests_lock);/* Clear beacon hints */
Signature · 1 line
1.8.3.2
Johannes Berg
maintainerRe: [PATCH v2 2/2] cfg80211: Schedule timeout for all CRDA calls
Quoted 3 lines · Ilan Peer
Timeout was scheduled only in case CRDA was called due to user hints, but was not scheduled for other cases. This can result in regulatory hint processing getting stuck in case that there is no CRDA configured.
I can understand this part.
Quoted 3 lines
Change this by scheduling a timeout every time CRDA is called. In addition, in
restore_regulatory_settings()all pending requests are restored (and not only the user ones).
Care to explain why, and why this should be in the same patch?
johannes
RE: [PATCH v2 2/2] cfg80211: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HVzZXIgb25lcykuDQo+IA0KPiBD YXJlIHRvIGV4cGxhaW4gd2h5LCBhbmQgd2h5IHRoaXMgc2hvdWxkIGJlIGluIHRoZSBzYW1lIHBh dGNoPw0KDQpQcmV2aW91c2x5IG9ubHkgdGhlIHBlbmRpbmcgdXNlciBoaW50cyB3ZXJlIHJlc3Rv cmVkIChub3Qgc3VyZSB3aHksIGJ1dCBtYXliZSB0aGVyZSB3YXMgYW4gYXNzdW1wdGlvbiB0aGF0 IHRoZSB0aW1lb3V0IHdhcyBvbmx5IHNjaGVkdWxlZCBmb3IgdXNlciBoaW50cz8pLiBXYXMgbm90 IHN1cmUgd2h5IGFsbCBvdGhlciBoaW50IHR5cGVzIHdlcmUgbm90IHJlc3RvcmVkLiBJIGNhbiBt b3ZlIHRoaXMgdG8gYW5vdGhlciBwYXRjaCBpdCB0aGlzIGlzIHN0aWxsIHJlYXNvbmFibGUuDQoN CklsYW4uDQo=
Johannes Berg
maintainerQuoted 9 lines · Ilan Peer
As the operating environment of a device can change, add API for user space to indicate a change of indoor settings. In addition modify the handling of the indoor processing as follows:
1. Directly update the indoor setting without wrapping it as a regulatory request.
2. Track the socket on which the indoor hint is issued, and reset indoor setting if the socket was released.
This probably needs to be wrapped with a request flag from userspace to have the new behaviour - but if not then at least explain why not?
johannes
PATCH v3 1/2 cfg80211: Add API to change the indoor regulatory setting
In reply to Ilan PeerAs the operating environment of a device can change, add API for user space to indicate a change of indoor settings. In addition modify the handling of the indoor processing as follows:
1. Directly update the indoor setting without wrapping it as a regulatory request.
2. Track the socket on which the indoor hint is issued, and reset indoor setting if the socket was released. The motivation here is to force a user space process that sets the indoor setting to constantly monitor this setting, and be responsible to correctly toggling it, so indoor operation will not be enabled uncontrolled.
3. Do not reset the indoor setting when restoring the regulatory settings as it has nothing to do with CRDA or interface disconnection.
--- include/uapi/linux/nl80211.h | 5 +++ net/wireless/nl80211.c | 10 +++++- net/wireless/reg.c | 80 +++++++++++++++++++++++++------------------- net/wireless/reg.h | 15 ++++++++- 4 files changed, 73 insertions(+), 37 deletions(-)
include/uapi/linux/nl80211.h +5 -0
@@ -1713,6 +1713,9 @@ enum nl80211_commands {* obtained from it is coming from the device's wiphy and not the global * cfg80211 regdomain. * +* @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device +* is operating in an indoor environment. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2072,6 +2075,8 @@ enum nl80211_attrs {NL80211_ATTR_WIPHY_SELF_MANAGED_REG , +NL80211_ATTR_REG_INDOOR , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +9 -1
@@ -397,6 +397,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [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_REG_INDOOR] = { .type = NLA_FLAG }, };/* policy for the key attributes */
@@ -4923,6 +4924,7 @@ static int parse_reg_rule(struct nlattr *tb[],static int nl80211_req_set_reg (struct sk_buff *skb,struct genl_info *info) {char *data =NULL ; +bool is_indoor;enum nl80211_user_reg_hint_type user_reg_hint_type;/*
@@ -4949,7 +4951,8 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) data =nla_data (info->attrs[NL80211_ATTR_REG_ALPHA2 ]);return regulatory_hint_user (data, user_reg_hint_type);case NL80211_USER_REG_HINT_INDOOR : -return regulatory_hint_indoor_user (); + is_indoor = !!info->attrs[NL80211_ATTR_REG_INDOOR ]; +return regulatory_hint_indoor (is_indoor, info->snd_portid);default :return -EINVAL ; }
@@ -12669,6 +12672,11 @@ static int nl80211_netlink_notify(struct notifier_block * nb,rcu_read_unlock (); +/* +* It is possible that the user space process that is controlling the +* indoor setting disappeared, so notify the regulatory core. +*/ +regulatory_netlink_notify (notify->portid);return NOTIFY_OK ; }
net/wireless/reg.c +45 -35
161 lines not on this page · raw message
net/wireless/reg.h +14 -1
@@ -25,7 +25,20 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy);int regulatory_hint_user (const char *alpha2,enum nl80211_user_reg_hint_type user_reg_hint_type); -int regulatory_hint_indoor_user (void ); + +/** +* regulatory_hint_indoor - hint operation in indoor env. or not +* @is_indoor: if true indicates that user space thinks that the +* device is operating in an indoor environment. +* @portid: the netlink port ID on which the hint was given. +*/ +int regulatory_hint_indoor (bool is_indoor,u32 portid); + +/** +* regulatory_netlink_notify - notify on released netlink socket +* @portid: the netlink socket port ID +*/ +void regulatory_netlink_notify (u32 portid);void wiphy_regulatory_register (struct wiphy *wiphy);void wiphy_regulatory_deregister (struct wiphy *wiphy);
Signature · 1 line
1.8.3.2