Skip to contentSkip to conversation

cfg80211: Add API to change the indoor regulatory setting

PATCH Superseded Ilan Peer 2 participants 4 messages Jan 4, 2015 – Jan 6, 2015 802.11 (including cfg80211/NL80211)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Ilan Peer

author
#0 lore raw

PATCH 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
index b37bd5a..8690a45 100644
@@ -1688,6 +1688,9 @@ enum nl80211_commands {
  *
  * @NL80211_ATTR_MAC_MASK: MAC address mask
  *
+ * @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
@@ -2045,6 +2048,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_MAC_MASK,
 
+	NL80211_ATTR_REG_INDOOR,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +9 -1
index 7ca4b51..09b089b 100644
@@ -396,6 +396,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_ADMITTED_TIME] = { .type = NLA_U16 },
 	[NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
 	[NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
+	[NL80211_ATTR_REG_INDOOR] = { .type = NLA_FLAG },
 };
 
 /* policy for the key attributes */
@@ -4918,6 +4919,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;
 
 	/*
@@ -4944,7 +4946,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;
 	}
@@ -12506,6 +12509,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
index 5e48031..77cd8c0 100644
@@ -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
author
#1 lore raw

PATCH 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
index fa93fd2..9684a8d 100644
@@ -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,
+			   &reg_timeout, msecs_to_jiffies(3142));
 	return REG_REQ_OK;
 }
 
@@ -1766,8 +1769,7 @@ static void reg_set_request_processed(void)
 		need_more_processing = true;
 	spin_unlock(&reg_requests_lock);
 
-	if (lr->initiator == NL80211_REGDOM_SET_BY_USER)
-		cancel_delayed_work(&reg_timeout);
+	cancel_delayed_work(&reg_timeout);
 
 	if (need_more_processing)
 		schedule_work(&reg_work);
@@ -2046,8 +2048,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,
-				   &reg_timeout, msecs_to_jiffies(3142));
 		return;
 	case NL80211_REGDOM_SET_BY_DRIVER:
 		if (!wiphy)
@@ -2406,7 +2406,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;
 
@@ -2422,11 +2421,7 @@ static void restore_regulatory_settings(bool reset_user)
 	 * settings.
 	 */
 	spin_lock(&reg_requests_lock);
-	list_for_each_entry_safe(reg_request, tmp, &reg_requests_list, list) {
-		if (reg_request->initiator != NL80211_REGDOM_SET_BY_USER)
-			continue;
-		list_move_tail(&reg_request->list, &tmp_reg_req_list);
-	}
+	list_splice_tail_init(&reg_requests_list, &tmp_reg_req_list);
 	spin_unlock(&reg_requests_lock);
 
 	/* Clear beacon hints */
Signature · 1 line
1.8.3.2
maintainer
#2 lore raw
In reply to Ilan Peer
Quoted 13 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.
3. Do not reset the indoor setting when restoring the regulatory settings as it has nothing to do with CRDA or interface disconnection.

Quoted 2 lines

This doesn't apply on mac80211-next. Also, you should sign off after Arik (and how did he manage to get that X there?)

johannes

author
#3 lore raw

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogSm9oYW5uZXMgQmVyZyBb bWFpbHRvOmpvaGFubmVzQHNpcHNvbHV0aW9ucy5uZXRdDQo+IFNlbnQ6IFR1ZXNkYXksIEphbnVh cnkgMDYsIDIwMTUgMTI6MTENCj4gVG86IFBlZXIsIElsYW4NCj4gQ2M6IGxpbnV4LXdpcmVsZXNz QHZnZXIua2VybmVsLm9yZzsgbWNncm9mQHN1c2UuY29tOyBBcmlrWCBOZW10c292DQo+IFN1Ympl Y3Q6IFJlOiBbUEFUQ0ggMS8yXSBjZmc4MDIxMTogQWRkIEFQSSB0byBjaGFuZ2UgdGhlIGluZG9v ciByZWd1bGF0b3J5DQo+IHNldHRpbmcNCj4gDQo+IE9uIFNhdCwgMjAxNS0wMS0wMyBhdCAyMToy OSAtMDUwMCwgSWxhbiBQZWVyIHdyb3RlOg0KPiA+IEFzIHRoZSBvcGVyYXRpbmcgZW52aXJvbm1l bnQgb2YgYSBkZXZpY2UgY2FuIGNoYW5nZSwgYWRkIEFQSSBmb3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