cfg80211: Fix regulatory data is reset in case all phys have disconnected
PATCH 1/1 cfg80211: Fix regulatory data is reset in case all phys have disconnected
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.
--- net/wireless/reg.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/wireless/reg.c +10 -0
@@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool reset_user, bool cached) }spin_unlock (®_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);
Signature · 1 line
2.17.1
Quoted 52 lines · 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 <[email protected]>--- net/wireless/reg.c | 10 ++++++++++ 1 file changed, 10 insertions(+)net/wireless/reg.c +10
-1@@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool reset_user, bool cached) }spin_unlock (®_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); --
Quoted 3 lines
2.17.1
Which device have you tested this on?
Quoted 52 lines · Orr Mazor
Quoted 51 lines
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 <[email protected]>--- net/wireless/reg.c | 10 ++++++++++ 1 file changed, 10 insertions(+)net/wireless/reg.c index renamed from net/wireless/reg.c +0
-0
d18cc05061a0..5049c487950b100644net/wireless/reg.c +10
-0@@ -3180,6 +3180,16 @@ static void restore_regulatory_settings(bool reset_user, bool cached) }spin_unlock (®_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);
Quoted 6 lines
Quoted 4 lines
--
2.17.1Which 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
Johannes Berg
maintainerQuoted 3 lines · Orr Mazor
Quoted 1 line
I have tested this on
mac80211_hwsimand 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