All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected
@ 2020-01-15 15:02 Orr Mazor
  2020-01-15 16:04 ` Tom Psyborg
  0 siblings, 1 reply; 4+ messages in thread
From: Orr Mazor @ 2020-01-15 15:02 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Orr Mazor

In case no one is occupying a wiphy, all past regulatory data will be lost
as a result of reset to world reg domain.

This includes any channel that is currently in NOP time as well as
in AVAILABLE state.

This means that after detecting a radar on a channel the user might be
able to simply reset hostapd and get back to that channel,
this is a major issue.

To solve this I have added a check before doing any resets.

If the user (for example: hostapd) asks for a regdomain and we are
already in that regdomain, than we shouldn't reset that regdomain in case
of wiphy disconnection (for example: hostapd reset or killed).

That way the regulatory data will be saved as long as we are
in the same regdomain.

Since in that case we will anyway get back to the same regdomain
the only difference is we will now save the regulatory data,
won't lose it, and as a result won't get back to a channel that a radar
was detected on until NOP will be finished, as should be.

Signed-off-by: Orr Mazor <Orr.Mazor@tandemg.com>
---
 net/wireless/reg.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index d18cc05061a0..5049c487950b 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool reset_user, bool cached)
 	}
 	spin_unlock(&reg_indoor_lock);
 
+	/* If the user asks for a regdomain and we are
+	 * already in that regdomain, than we shouldn't reset
+	 * the regdomain in the case of wiphy disconnection.
+	 */
+	if (cached && !reset_user &&
+	    (!IS_ERR_OR_NULL(cfg80211_user_regdom)) &&
+	    (!regdom_changes(cfg80211_user_regdom->alpha2))) {
+		return;
+	}
+
 	reset_regdomains(true, &world_regdom);
 	restore_alpha2(alpha2, reset_user);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected
  2020-01-15 15:02 [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected Orr Mazor
@ 2020-01-15 16:04 ` Tom Psyborg
  2020-01-16 12:23   ` Orr Mazor
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Psyborg @ 2020-01-15 16:04 UTC (permalink / raw)
  To: Orr Mazor; +Cc: Johannes Berg, linux-wireless

On 15/01/2020, Orr Mazor <orr.mazor@tandemg.com> wrote:
> In case no one is occupying a wiphy, all past regulatory data will be lost
> as a result of reset to world reg domain.
>
> This includes any channel that is currently in NOP time as well as
> in AVAILABLE state.
>
> This means that after detecting a radar on a channel the user might be
> able to simply reset hostapd and get back to that channel,
> this is a major issue.
>
> To solve this I have added a check before doing any resets.
>
> If the user (for example: hostapd) asks for a regdomain and we are
> already in that regdomain, than we shouldn't reset that regdomain in case
> of wiphy disconnection (for example: hostapd reset or killed).
>
> That way the regulatory data will be saved as long as we are
> in the same regdomain.
>
> Since in that case we will anyway get back to the same regdomain
> the only difference is we will now save the regulatory data,
> won't lose it, and as a result won't get back to a channel that a radar
> was detected on until NOP will be finished, as should be.
>
> Signed-off-by: Orr Mazor <Orr.Mazor@tandemg.com>
> ---
>  net/wireless/reg.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index d18cc05061a0..5049c487950b 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool
> reset_user, bool cached)
>  	}
>  	spin_unlock(&reg_indoor_lock);
>
> +	/* If the user asks for a regdomain and we are
> +	 * already in that regdomain, than we shouldn't reset
> +	 * the regdomain in the case of wiphy disconnection.
> +	 */
> +	if (cached && !reset_user &&
> +	    (!IS_ERR_OR_NULL(cfg80211_user_regdom)) &&
> +	    (!regdom_changes(cfg80211_user_regdom->alpha2))) {
> +		return;
> +	}
> +
>  	reset_regdomains(true, &world_regdom);
>  	restore_alpha2(alpha2, reset_user);
>
> --
> 2.17.1
>
>

Which device have you tested this on?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected
  2020-01-15 16:04 ` Tom Psyborg
@ 2020-01-16 12:23   ` Orr Mazor
  2020-02-07 10:43     ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Orr Mazor @ 2020-01-16 12:23 UTC (permalink / raw)
  To: Tom Psyborg; +Cc: Johannes Berg, linux-wireless

>On 15/01/2020, Orr Mazor <orr.mazor@tandemg.com> wrote:
>> In case no one is occupying a wiphy, all past regulatory data will be
>> lost as a result of reset to world reg domain.
>>
>> This includes any channel that is currently in NOP time as well as in
>> AVAILABLE state.
>>
>> This means that after detecting a radar on a channel the user might be
>> able to simply reset hostapd and get back to that channel, this is a
>> major issue.
>>
>> To solve this I have added a check before doing any resets.
>>
>> If the user (for example: hostapd) asks for a regdomain and we are
>> already in that regdomain, than we shouldn't reset that regdomain in
>> case of wiphy disconnection (for example: hostapd reset or killed).
>>
>> That way the regulatory data will be saved as long as we are in the
>> same regdomain.
>>
>> Since in that case we will anyway get back to the same regdomain the
>> only difference is we will now save the regulatory data, won't lose
>> it, and as a result won't get back to a channel that a radar was
>> detected on until NOP will be finished, as should be.
>>
>> Signed-off-by: Orr Mazor <Orr.Mazor@tandemg.com>
>> ---
>>  net/wireless/reg.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/net/wireless/reg.c b/net/wireless/reg.c index
>> d18cc05061a0..5049c487950b 100644
>> --- a/net/wireless/reg.c
>> +++ b/net/wireless/reg.c
>> @@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool
>> reset_user, bool cached)
>>  	}
>>  	spin_unlock(&reg_indoor_lock);
>>
>> +	/* If the user asks for a regdomain and we are
>> +	 * already in that regdomain, than we shouldn't reset
>> +	 * the regdomain in the case of wiphy disconnection.
>> +	 */
>> +	if (cached && !reset_user &&
>> +	    (!IS_ERR_OR_NULL(cfg80211_user_regdom)) &&
>> +	    (!regdom_changes(cfg80211_user_regdom->alpha2))) {
>> +		return;
>> +	}
>> +
>>  	reset_regdomains(true, &world_regdom);
>>  	restore_alpha2(alpha2, reset_user);
>>
>> --
>> 2.17.1
>>
>>
>
>Which device have you tested this on?

Hi Tom,

I have tested this on mac80211_hwsim and on a intel proprietary device.
The issue (before the patch) is seen in both, and the patch solves it in both.

BR,
Orr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected
  2020-01-16 12:23   ` Orr Mazor
@ 2020-02-07 10:43     ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2020-02-07 10:43 UTC (permalink / raw)
  To: Orr Mazor, Tom Psyborg; +Cc: linux-wireless

On Thu, 2020-01-16 at 12:23 +0000, Orr Mazor wrote:
> > 
> I have tested this on mac80211_hwsim and on a intel proprietary device.
> The issue (before the patch) is seen in both, and the patch solves it in both.

However, it breaks hwsim tests, e.g. this one:

START he160b 1/1
wlan0: Country code not reset back to 00: is 98
Country code remains set - expect following test cases to fail
FAIL he160b 68.974926 2020-02-07 10:49:51.312663
failed tests: he160b

So maybe it wasn't quite right somehow?

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-07 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 15:02 [PATCH] cfg80211: Fix regulatory data is reset in case all phys have disconnected Orr Mazor
2020-01-15 16:04 ` Tom Psyborg
2020-01-16 12:23   ` Orr Mazor
2020-02-07 10:43     ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.