2015-01-01 11:42:48

by Arik Nemtsov

[permalink] [raw]
Subject: [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed

A self-managed device will sometimes need to set its regdomain synchronously.
Notably it should be set before usermode has a chance to query it. Expose
a new API to accomplish this which requires the RTNL.

Signed-off-by: Arik Nemtsov <[email protected]>
Reviewed-by: Ilan Peer <[email protected]>
Reviewed-by: Emmanuel Grumbach <[email protected]>
---
include/net/cfg80211.h | 14 ++++++++++++++
net/wireless/reg.c | 17 +++++++++++++++++
2 files changed, 31 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bd672ea..cb0bba2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3827,6 +3827,20 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
struct ieee80211_regdomain *rd);

/**
+ * regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
+ * @wiphy: the wireless device we want to process the regulatory domain on
+ * @rd: the regulatory domain information to use for this wiphy
+ *
+ * This functions requires the RTNL to be held and applies the new regdomain
+ * synchronously to this wiphy. For more details see
+ * regulatory_set_wiphy_regd().
+ *
+ * Return: 0 on success. -EINVAL, -EPERM
+ */
+int regulatory_set_wiphy_regd_sync_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/net/wireless/reg.c b/net/wireless/reg.c
index 9a5411c..9b5662f 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2928,6 +2928,23 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
}
EXPORT_SYMBOL(regulatory_set_wiphy_regd);

+int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
+ struct ieee80211_regdomain *rd)
+{
+ int ret;
+
+ ASSERT_RTNL();
+
+ ret = regulatory_set_wiphy_regd(wiphy, rd);
+ if (ret)
+ return ret;
+
+ /* process the request immediately */
+ reg_process_self_managed_hints();
+ return 0;
+}
+EXPORT_SYMBOL(regulatory_set_wiphy_regd_sync_rtnl);
+
void wiphy_regulatory_register(struct wiphy *wiphy)
{
struct regulatory_request *lr;
--
2.1.0



2015-01-01 11:42:49

by Arik Nemtsov

[permalink] [raw]
Subject: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

When a system contains only self-managed regulatory devices all hints
from the regulatory core are ignored. Stop hint processing early in this
case. These systems usually don't have CRDA deployed, which results in
endless (irrelevent) logs of the form:
cfg80211: Calling CRDA to update world regulatory domain

Signed-off-by: Arik Nemtsov <[email protected]>
---
net/wireless/reg.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 9b5662f..21b2095 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2102,6 +2102,22 @@ out_free:
reg_free_request(reg_request);
}

+static bool reg_only_self_managed_wiphys(void)
+{
+ struct cfg80211_registered_device *rdev;
+ struct wiphy *wiphy;
+
+ ASSERT_RTNL();
+
+ list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
+ wiphy = &rdev->wiphy;
+ if (!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED))
+ return false;
+ }
+
+ return true;
+}
+
/*
* Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_*
* Regulatory hints come on a first come first serve basis and we
@@ -2133,6 +2149,11 @@ static void reg_process_pending_hints(void)

spin_unlock(&reg_requests_lock);

+ if (reg_only_self_managed_wiphys()) {
+ reg_free_request(reg_request);
+ return;
+ }
+
reg_process_hint(reg_request);
}

--
2.1.0


2015-01-06 14:05:04

by Arik Nemtsov

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <[email protected]> wrote:
> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> > When a system contains only self-managed regulatory devices all hints
>> > from the regulatory core are ignored. Stop hint processing early in this
>> > case. These systems usually don't have CRDA deployed, which results in
>> > endless (irrelevent) logs of the form:
>> > cfg80211: Calling CRDA to update world regulatory domain
>>
>> Applied.
>
> I take that back - dropped again. This was causing spurious messages in
> the hwsim test run VM, saying something like "couldn't set reg domain:
> -7". Maybe at that point not a single wiphy existed?

Interesting. I guess I should fix this to only drop the request in
case there's at least one self-managed wiphy.

Arik

2015-01-06 10:55:01

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed

On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> A self-managed device will sometimes need to set its regdomain synchronously.
> Notably it should be set before usermode has a chance to query it. Expose
> a new API to accomplish this which requires the RTNL.

> + ret = regulatory_set_wiphy_regd(wiphy, rd);
> + if (ret)
> + return ret;

It seems to me you should refactor that and avoid scheduling the work
struct when you're going to run the necessary work below by hand.

johannes


2015-01-07 13:35:43

by Arik Nemtsov

[permalink] [raw]
Subject: Re: [PATCH 1/2] cfg80211: introduce sync regdom set API for self-managed

On Tue, Jan 6, 2015 at 12:54 PM, Johannes Berg
<[email protected]> wrote:
> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> A self-managed device will sometimes need to set its regdomain synchronously.
>> Notably it should be set before usermode has a chance to query it. Expose
>> a new API to accomplish this which requires the RTNL.
>
>> + ret = regulatory_set_wiphy_regd(wiphy, rd);
>> + if (ret)
>> + return ret;
>
> It seems to me you should refactor that and avoid scheduling the work
> struct when you're going to run the necessary work below by hand.

Sounds good.

Arik

2015-01-06 10:56:09

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> When a system contains only self-managed regulatory devices all hints
> from the regulatory core are ignored. Stop hint processing early in this
> case. These systems usually don't have CRDA deployed, which results in
> endless (irrelevent) logs of the form:
> cfg80211: Calling CRDA to update world regulatory domain

Applied.

johannes


2015-01-06 13:59:08

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> > When a system contains only self-managed regulatory devices all hints
> > from the regulatory core are ignored. Stop hint processing early in this
> > case. These systems usually don't have CRDA deployed, which results in
> > endless (irrelevent) logs of the form:
> > cfg80211: Calling CRDA to update world regulatory domain
>
> Applied.

I take that back - dropped again. This was causing spurious messages in
the hwsim test run VM, saying something like "couldn't set reg domain:
-7". Maybe at that point not a single wiphy existed?

johannes


2015-01-07 13:54:04

by Arik Nemtsov

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Wed, Jan 7, 2015 at 3:42 PM, Johannes Berg <[email protected]> wrote:
> On Wed, 2015-01-07 at 15:38 +0200, Arik Nemtsov wrote:
>> On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <[email protected]> wrote:
>> > On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <[email protected]> wrote:
>> >> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>> >>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>> >>> > When a system contains only self-managed regulatory devices all hints
>> >>> > from the regulatory core are ignored. Stop hint processing early in this
>> >>> > case. These systems usually don't have CRDA deployed, which results in
>> >>> > endless (irrelevent) logs of the form:
>> >>> > cfg80211: Calling CRDA to update world regulatory domain
>> >>>
>> >>> Applied.
>> >>
>> >> I take that back - dropped again. This was causing spurious messages in
>> >> the hwsim test run VM, saying something like "couldn't set reg domain:
>> >> -7". Maybe at that point not a single wiphy existed?
>> >
>> > Interesting. I guess I should fix this to only drop the request in
>> > case there's at least one self-managed wiphy.
>>
>> Could you point me to the hwsim test that failed for you?
>
> I don't think it was a specific test case - the message seems to have
> come during boot. OTOH, I also reverted some of Eliad's patches, so
> perhaps I should retest without those?

It's a good check to add anyway (at least one self-managed device).
Since the regulatory queues us the world-update core hint right away..
Not sure why I haven't encountered it, I'll try to introduce some
sleep() calls to reproduce. It's a real bug I believe.

>
>> Also where is that message coming from? I don't see it in wpa_s or the kernel.
>
> I have no idea! I can't even explain where the -7 (-E2BIG) came from!

Yea that's what I was after as well. :)

Arik

2015-01-07 13:42:50

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Wed, 2015-01-07 at 15:38 +0200, Arik Nemtsov wrote:
> On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <[email protected]> wrote:
> > On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <[email protected]> wrote:
> >> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
> >>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
> >>> > When a system contains only self-managed regulatory devices all hints
> >>> > from the regulatory core are ignored. Stop hint processing early in this
> >>> > case. These systems usually don't have CRDA deployed, which results in
> >>> > endless (irrelevent) logs of the form:
> >>> > cfg80211: Calling CRDA to update world regulatory domain
> >>>
> >>> Applied.
> >>
> >> I take that back - dropped again. This was causing spurious messages in
> >> the hwsim test run VM, saying something like "couldn't set reg domain:
> >> -7". Maybe at that point not a single wiphy existed?
> >
> > Interesting. I guess I should fix this to only drop the request in
> > case there's at least one self-managed wiphy.
>
> Could you point me to the hwsim test that failed for you?

I don't think it was a specific test case - the message seems to have
come during boot. OTOH, I also reverted some of Eliad's patches, so
perhaps I should retest without those?

> Also where is that message coming from? I don't see it in wpa_s or the kernel.

I have no idea! I can't even explain where the -7 (-E2BIG) came from!

johannes


2015-01-07 13:45:48

by Arik Nemtsov

[permalink] [raw]
Subject: Re: [PATCH 2/2] cfg80211: avoid reg-hints in self-managed only systems

On Tue, Jan 6, 2015 at 4:04 PM, Arik Nemtsov <[email protected]> wrote:
> On Tue, Jan 6, 2015 at 3:59 PM, Johannes Berg <[email protected]> wrote:
>> On Tue, 2015-01-06 at 11:56 +0100, Johannes Berg wrote:
>>> On Thu, 2015-01-01 at 13:42 +0200, Arik Nemtsov wrote:
>>> > When a system contains only self-managed regulatory devices all hints
>>> > from the regulatory core are ignored. Stop hint processing early in this
>>> > case. These systems usually don't have CRDA deployed, which results in
>>> > endless (irrelevent) logs of the form:
>>> > cfg80211: Calling CRDA to update world regulatory domain
>>>
>>> Applied.
>>
>> I take that back - dropped again. This was causing spurious messages in
>> the hwsim test run VM, saying something like "couldn't set reg domain:
>> -7". Maybe at that point not a single wiphy existed?
>
> Interesting. I guess I should fix this to only drop the request in
> case there's at least one self-managed wiphy.

Could you point me to the hwsim test that failed for you?
Also where is that message coming from? I don't see it in wpa_s or the kernel.

Arik