2020-11-21 12:53:33

by Finn Behrens

[permalink] [raw]
Subject: [PATCH] nl80211: reset regdom when reloading regdb

reset the regdom when NL80211_CMD_RELOAD_REGDB is send

Signed-off-by: Finn Behrens <[email protected]>
---
include/net/regulatory.h | 1 +
net/wireless/reg.c | 31 +++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 47f06f6f5a67..0cf9335431e0 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -83,6 +83,7 @@ struct regulatory_request {
enum nl80211_dfs_regions dfs_region;
bool intersect;
bool processed;
+ bool reload;
enum environment_cap country_ie_env;
struct list_head list;
};
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index a04fdfb35f07..50314916b020 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -199,6 +199,7 @@ static struct regulatory_request *get_last_request(void)
/* Used to queue up regulatory hints */
static LIST_HEAD(reg_requests_list);
static spinlock_t reg_requests_lock;
+static void queue_regulatory_request(struct regulatory_request *request);
/* Used to queue up beacon hints for review */
static LIST_HEAD(reg_pending_beacons);
@@ -1081,10 +1082,13 @@ int reg_reload_regdb(void)
int err;
err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
- if (err)
+ if (err) {
+ pr_info("failed to load regulatory.db\n");
return err;
+ }
if (!valid_regdb(fw->data, fw->size)) {
+ pr_info("loaded regulatory.db is malformed or signature is
missing/invalid\n");
err = -ENODATA;
goto out;
}
@@ -1101,6 +1105,28 @@ int reg_reload_regdb(void)
regdb = db;
rtnl_unlock();
+ // reset regulatory
+ const struct ieee80211_regdomain *current_regdomain = NULL;
+
+ current_regdomain = get_cfg80211_regdom();
+
+ struct regulatory_request *request = NULL;
+
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
+ if (!request) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ request->wiphy_idx = WIPHY_IDX_INVALID;
+ request->alpha2[0] = current_regdomain->alpha2[0];
+ request->alpha2[1] = current_regdomain->alpha2[1];
+ request->initiator = NL80211_USER_REG_HINT_USER;
+ request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
+ request->reload = true;
+
+ queue_regulatory_request(request);
+
out:
release_firmware(fw);
return err;
@@ -2657,7 +2683,8 @@ reg_process_hint_user(struct regulatory_request
*user_request)
treatment = __reg_process_hint_user(user_request);
if (treatment == REG_REQ_IGNORE ||
- treatment == REG_REQ_ALREADY_SET)
+ treatment == REG_REQ_ALREADY_SET &&
+ !user_request->reload)
return REG_REQ_IGNORE;
user_request->intersect = treatment == REG_REQ_INTERSECT;

--
2.29.2



2020-11-26 11:55:07

by Finn Behrens

[permalink] [raw]
Subject: [PATCH v2] nl80211: reset regdom when reloading regdb

reset the regdom when NL80211_CMD_RELOAD_REGDB is send

Signed-off-by: Finn Behrens <[email protected]>
---
resend, as patchwork showed it malformed.

include/net/regulatory.h | 1 +
net/wireless/reg.c | 31 +++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 47f06f6f5a67..0cf9335431e0 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -83,6 +83,7 @@ struct regulatory_request {
enum nl80211_dfs_regions dfs_region;
bool intersect;
bool processed;
+ bool reload;
enum environment_cap country_ie_env;
struct list_head list;
};
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index a04fdfb35f07..50314916b020 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -199,6 +199,7 @@ static struct regulatory_request *get_last_request(void)
/* Used to queue up regulatory hints */
static LIST_HEAD(reg_requests_list);
static spinlock_t reg_requests_lock;
+static void queue_regulatory_request(struct regulatory_request *request);

/* Used to queue up beacon hints for review */
static LIST_HEAD(reg_pending_beacons);
@@ -1081,10 +1082,13 @@ int reg_reload_regdb(void)
int err;

err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
- if (err)
+ if (err) {
+ pr_info("failed to load regulatory.db\n");
return err;
+ }

if (!valid_regdb(fw->data, fw->size)) {
+ pr_info("loaded regulatory.db is malformed or signature is missing/invalid\n");
err = -ENODATA;
goto out;
}
@@ -1101,6 +1105,28 @@ int reg_reload_regdb(void)
regdb = db;
rtnl_unlock();

+ // reset regulatory
+ const struct ieee80211_regdomain *current_regdomain = NULL;
+
+ current_regdomain = get_cfg80211_regdom();
+
+ struct regulatory_request *request = NULL;
+
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
+ if (!request) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ request->wiphy_idx = WIPHY_IDX_INVALID;
+ request->alpha2[0] = current_regdomain->alpha2[0];
+ request->alpha2[1] = current_regdomain->alpha2[1];
+ request->initiator = NL80211_USER_REG_HINT_USER;
+ request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
+ request->reload = true;
+
+ queue_regulatory_request(request);
+
out:
release_firmware(fw);
return err;
@@ -2657,7 +2683,8 @@ reg_process_hint_user(struct regulatory_request *user_request)

treatment = __reg_process_hint_user(user_request);
if (treatment == REG_REQ_IGNORE ||
- treatment == REG_REQ_ALREADY_SET)
+ treatment == REG_REQ_ALREADY_SET &&
+ !user_request->reload)
return REG_REQ_IGNORE;

user_request->intersect = treatment == REG_REQ_INTERSECT;
--
2.29.2

2020-11-26 13:01:32

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] nl80211: reset regdom when reloading regdb

Hi Finn,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on mac80211/master linus/master v5.10-rc5 next-20201126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Finn-Behrens/nl80211-reset-regdom-when-reloading-regdb/20201126-184229
base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/60f644b62d0171339bf90cbb65245a171d2edc2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Finn-Behrens/nl80211-reset-regdom-when-reloading-regdb/20201126-184229
git checkout 60f644b62d0171339bf90cbb65245a171d2edc2a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from include/linux/kernel.h:11,
from net/wireless/reg.c:50:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:169:49: warning: ordered comparison of pointer with null pointer [-Wextra]
169 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
net/wireless/reg.c: In function 'reg_reload_regdb':
>> net/wireless/reg.c:1109:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
1109 | const struct ieee80211_regdomain *current_regdomain = NULL;
| ^~~~~
net/wireless/reg.c:1113:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
1113 | struct regulatory_request *request = NULL;
| ^~~~~~
net/wireless/reg.c: In function 'reg_process_hint_user':
>> net/wireless/reg.c:2686:39: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
2686 | treatment == REG_REQ_ALREADY_SET &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
2687 | !user_request->reload)
| ~~~~~~~~~~~~~~~~~~~~~

vim +1109 net/wireless/reg.c

1077
1078 int reg_reload_regdb(void)
1079 {
1080 const struct firmware *fw;
1081 void *db;
1082 int err;
1083
1084 err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
1085 if (err) {
1086 pr_info("failed to load regulatory.db\n");
1087 return err;
1088 }
1089
1090 if (!valid_regdb(fw->data, fw->size)) {
1091 pr_info("loaded regulatory.db is malformed or signature is missing/invalid\n");
1092 err = -ENODATA;
1093 goto out;
1094 }
1095
1096 db = kmemdup(fw->data, fw->size, GFP_KERNEL);
1097 if (!db) {
1098 err = -ENOMEM;
1099 goto out;
1100 }
1101
1102 rtnl_lock();
1103 if (!IS_ERR_OR_NULL(regdb))
1104 kfree(regdb);
1105 regdb = db;
1106 rtnl_unlock();
1107
1108 // reset regulatory
> 1109 const struct ieee80211_regdomain *current_regdomain = NULL;
1110
1111 current_regdomain = get_cfg80211_regdom();
1112
1113 struct regulatory_request *request = NULL;
1114
1115 request = kzalloc(sizeof(*request), GFP_KERNEL);
1116 if (!request) {
1117 err = -ENOMEM;
1118 goto out;
1119 }
1120
1121 request->wiphy_idx = WIPHY_IDX_INVALID;
1122 request->alpha2[0] = current_regdomain->alpha2[0];
1123 request->alpha2[1] = current_regdomain->alpha2[1];
1124 request->initiator = NL80211_USER_REG_HINT_USER;
1125 request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
1126 request->reload = true;
1127
1128 queue_regulatory_request(request);
1129
1130 out:
1131 release_firmware(fw);
1132 return err;
1133 }
1134

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (4.96 kB)
.config.gz (57.52 kB)
Download all attachments

2020-12-04 11:44:19

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v2] nl80211: reset regdom when reloading regdb

On Thu, 2020-11-26 at 11:39 +0100, Finn Behrens wrote:
> reset the regdom when NL80211_CMD_RELOAD_REGDB is send

Please add a bit more commit message, saying why this is needed.

> err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
> - if (err)
> + if (err) {
> + pr_info("failed to load regulatory.db\n");
> return err;
> + }
>
> if (!valid_regdb(fw->data, fw->size)) {
> + pr_info("loaded regulatory.db is malformed or signature is missing/invalid\n");
> err = -ENODATA;
> goto out;
> }

These changes seem unrelated.

> @@ -1101,6 +1105,28 @@ int reg_reload_regdb(void)
> regdb = db;
> rtnl_unlock();
>
> + // reset regulatory

For whatever reason, the kernel doesn't use C99 comments.

> + const struct ieee80211_regdomain *current_regdomain = NULL;

This should've given you a compiler warning that you shouldn't declare
variables in the middle of the code.

> + current_regdomain = get_cfg80211_regdom();
> +
> + struct regulatory_request *request = NULL;
> +
> + request = kzalloc(sizeof(*request), GFP_KERNEL);
> + if (!request) {
> + err = -ENOMEM;
> + goto out;
> + }
> +
> + request->wiphy_idx = WIPHY_IDX_INVALID;
> + request->alpha2[0] = current_regdomain->alpha2[0];
> + request->alpha2[1] = current_regdomain->alpha2[1];
> + request->initiator = NL80211_USER_REG_HINT_USER;
> + request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
> + request->reload = true;
> +
> + queue_regulatory_request(request);
>
Why does it even need to be queued - we're in a process context where we
can sleep?

johannes

2021-11-13 11:04:06

by Finn Behrens

[permalink] [raw]
Subject: [PATCH v4] nl80211: reset regdom when reloading regdb

this reloads the regdom when the regulatory db is reloaded.
Without this patch the user had to change the regulatoy domain to a
different, and then reset it to the one the user is in, to have the new
regulatory db take effect

Signed-off-by: Finn Behrens <[email protected]>
---
Sorry for taking so long for a new version. The mail provider my company
is using had some major problems connecting to the LKML.
This is why I now are using my personal mail server.

include/net/regulatory.h | 1 +
net/wireless/reg.c | 26 +++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 47f06f6f5a67..0cf9335431e0 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -83,6 +83,7 @@ struct regulatory_request {
enum nl80211_dfs_regions dfs_region;
bool intersect;
bool processed;
+ bool reload;
enum environment_cap country_ie_env;
struct list_head list;
};
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 0406ce7334fa..3460c0e75c6d 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -133,6 +133,7 @@ static u32 reg_is_indoor_portid;

static void restore_regulatory_settings(bool reset_user, bool cached);
static void print_regdomain(const struct ieee80211_regdomain *rd);
+static void reg_process_hint(struct regulatory_request *reg_request);

static const struct ieee80211_regdomain *get_cfg80211_regdom(void)
{
@@ -1091,6 +1092,8 @@ int reg_reload_regdb(void)
const struct firmware *fw;
void *db;
int err;
+ const struct ieee80211_regdomain *current_regdomain;
+ struct regulatory_request *request;

err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
if (err)
@@ -1113,6 +1116,26 @@ int reg_reload_regdb(void)
regdb = db;
rtnl_unlock();

+ /* reset regulatory domain */
+ current_regdomain = get_cfg80211_regdom();
+
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
+ if (!request) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ request->wiphy_idx = WIPHY_IDX_INVALID;
+ request->alpha2[0] = current_regdomain->alpha2[0];
+ request->alpha2[1] = current_regdomain->alpha2[1];
+ request->initiator = NL80211_USER_REG_HINT_USER;
+ request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
+ request->reload = true;
+
+ rtnl_lock();
+ reg_process_hint(request);
+ rtnl_unlock();
+
out:
release_firmware(fw);
return err;
@@ -2683,7 +2706,8 @@ reg_process_hint_user(struct regulatory_request *user_request)

treatment = __reg_process_hint_user(user_request);
if (treatment == REG_REQ_IGNORE ||
- treatment == REG_REQ_ALREADY_SET)
+ (treatment == REG_REQ_ALREADY_SET &&
+ !user_request->reload))
return REG_REQ_IGNORE;

user_request->intersect = treatment == REG_REQ_INTERSECT;
--
2.31.1


2021-11-26 12:52:15

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v4] nl80211: reset regdom when reloading regdb

Hi,

> Sorry for taking so long for a new version. The mail provider my company
> is using had some major problems connecting to the LKML.
> This is why I now are using my personal mail server.


Did you resend this? Did I lose it before? Or maybe the list lost it and
I had a copy? Confusing ...

But anyway:

> @@ -1113,6 +1116,26 @@ int reg_reload_regdb(void)
> regdb = db;
> rtnl_unlock();
>
> + /* reset regulatory domain */
> + current_regdomain = get_cfg80211_regdom();


This really is just

rcu_dereference_rtnl(cfg80211_regdomain);

so it cannot be right that you just unlocked the RTNL and are not under
RCU protection here?

I guess we can just keep the RTNL, since ...


> + request = kzalloc(sizeof(*request), GFP_KERNEL);
> + if (!request) {
> + err = -ENOMEM;
> + goto out;
> + }
> +
> + request->wiphy_idx = WIPHY_IDX_INVALID;
> + request->alpha2[0] = current_regdomain->alpha2[0];
> + request->alpha2[1] = current_regdomain->alpha2[1];
> + request->initiator = NL80211_USER_REG_HINT_USER;
> + request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
> + request->reload = true;
> +
> + rtnl_lock();

we acquire it again here anyway? Just need a new

> + reg_process_hint(request);

out_unlock:
> + rtnl_unlock();

label there.

>
> @@ -2683,7 +2706,8 @@ reg_process_hint_user(struct regulatory_request *user_request)
>
> treatment = __reg_process_hint_user(user_request);
> if (treatment == REG_REQ_IGNORE ||
> - treatment == REG_REQ_ALREADY_SET)
> + (treatment == REG_REQ_ALREADY_SET &&
> + !user_request->reload))
> return REG_REQ_IGNORE;

That could use some nicer indentation :)

johannes

2021-11-27 10:30:58

by Finn Behrens

[permalink] [raw]
Subject: [PATCH v5] nl80211: reset regdom when reloading regdb

this reloads the regdom when the regulatory db is reloaded.
Without this patch the user had to change the regulatoy domain to a
different, and then reset it to the one the user is in, to have the new
regulatory db take effect

Signed-off-by: Finn Behrens <[email protected]>
---
Hi,
I moved the rtnl_unlock into a label, and requested the current domain from inside the lock.
Finn

include/net/regulatory.h | 1 +
net/wireless/reg.c | 27 +++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 47f06f6f5a67..0cf9335431e0 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -83,6 +83,7 @@ struct regulatory_request {
enum nl80211_dfs_regions dfs_region;
bool intersect;
bool processed;
+ bool reload;
enum environment_cap country_ie_env;
struct list_head list;
};
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index df87c7f3a049..61f1bf1bc4a7 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -133,6 +133,7 @@ static u32 reg_is_indoor_portid;

static void restore_regulatory_settings(bool reset_user, bool cached);
static void print_regdomain(const struct ieee80211_regdomain *rd);
+static void reg_process_hint(struct regulatory_request *reg_request);

static const struct ieee80211_regdomain *get_cfg80211_regdom(void)
{
@@ -1098,6 +1099,8 @@ int reg_reload_regdb(void)
const struct firmware *fw;
void *db;
int err;
+ const struct ieee80211_regdomain *current_regdomain;
+ struct regulatory_request *request;

err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev);
if (err)
@@ -1118,8 +1121,27 @@ int reg_reload_regdb(void)
if (!IS_ERR_OR_NULL(regdb))
kfree(regdb);
regdb = db;
- rtnl_unlock();

+ /* reset regulatory domain */
+ current_regdomain = get_cfg80211_regdom();
+
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
+ if (!request) {
+ err = -ENOMEM;
+ goto out_unlock;
+ }
+
+ request->wiphy_idx = WIPHY_IDX_INVALID;
+ request->alpha2[0] = current_regdomain->alpha2[0];
+ request->alpha2[1] = current_regdomain->alpha2[1];
+ request->initiator = NL80211_USER_REG_HINT_USER;
+ request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
+ request->reload = true;
+
+ reg_process_hint(request);
+
+out_unlock:
+ rtnl_unlock();
out:
release_firmware(fw);
return err;
@@ -2690,7 +2712,8 @@ reg_process_hint_user(struct regulatory_request *user_request)

treatment = __reg_process_hint_user(user_request);
if (treatment == REG_REQ_IGNORE ||
- treatment == REG_REQ_ALREADY_SET)
+ (treatment == REG_REQ_ALREADY_SET &&
+ !user_request->reload))
return REG_REQ_IGNORE;

user_request->intersect = treatment == REG_REQ_INTERSECT;
--
2.31.1


2021-11-30 16:02:33

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v5] nl80211: reset regdom when reloading regdb

Hi Finn,

On Sat, Nov 27, 2021 at 11:28:53AM +0100, Finn Behrens wrote:
> this reloads the regdom when the regulatory db is reloaded.
> Without this patch the user had to change the regulatoy domain to a
> different, and then reset it to the one the user is in, to have the new
> regulatory db take effect
>
> Signed-off-by: Finn Behrens <[email protected]>

This patch as commit 1eda919126b4 ("nl80211: reset regdom when reloading
regdb") in -next causes the following clang warning/error:

net/wireless/reg.c:1137:23: error: implicit conversion from enumeration type 'enum nl80211_user_reg_hint_type' to different enumeration type 'enum nl80211_reg_initiator' [-Werror,-Wenum-conversion]
request->initiator = NL80211_USER_REG_HINT_USER;
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Should that be NL80211_REGDOM_SET_BY_CORE (same value, 0) or something
different?

Cheers,
Nathan

2021-11-30 16:51:05

by Finn Behrens

[permalink] [raw]
Subject: Re: [PATCH v5] nl80211: reset regdom when reloading regdb


> On 30. Nov 2021, at 17:02, Nathan Chancellor <[email protected]> wrote:
>
> Hi Finn,
>
> On Sat, Nov 27, 2021 at 11:28:53AM +0100, Finn Behrens wrote:
>> this reloads the regdom when the regulatory db is reloaded.
>> Without this patch the user had to change the regulatoy domain to a
>> different, and then reset it to the one the user is in, to have the new
>> regulatory db take effect
>>
>> Signed-off-by: Finn Behrens <[email protected]>
>
> This patch as commit 1eda919126b4 ("nl80211: reset regdom when reloading
> regdb") in -next causes the following clang warning/error:
>
> net/wireless/reg.c:1137:23: error: implicit conversion from enumeration type 'enum nl80211_user_reg_hint_type' to different enumeration type 'enum nl80211_reg_initiator' [-Werror,-Wenum-conversion]
> request->initiator = NL80211_USER_REG_HINT_USER;
> ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> Should that be NL80211_REGDOM_SET_BY_CORE (same value, 0) or something
> different?
>
> Cheers,
> Nathan

Hi Nathan,

I think It should have been NL80211_REGDOM_SET_BY_USER, as the reload flag check is currently implemented in the user hint function. But If I see it correctly right now. We could remove the reload flag,
and NL80211_REGDOM_SET_BY_CORE should work as well. As the reg_query_database function is called unconditionally there.

I will prepare a patch that reverts the reload flag, and changes to NL80211_REGDOM_SET_BY_CORE as this already works. Or should it be NL80211_REGDOM_SET_BY_USER, as it’s results from an user
called function?

Cheers,
Finn

2021-11-30 18:32:21

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v5] nl80211: reset regdom when reloading regdb

On Tue, Nov 30, 2021 at 05:50:58PM +0100, Finn Behrens wrote:
> > On 30. Nov 2021, at 17:02, Nathan Chancellor <[email protected]> wrote:
> > On Sat, Nov 27, 2021 at 11:28:53AM +0100, Finn Behrens wrote:
> >> this reloads the regdom when the regulatory db is reloaded.
> >> Without this patch the user had to change the regulatoy domain to a
> >> different, and then reset it to the one the user is in, to have the new
> >> regulatory db take effect
> >>
> >> Signed-off-by: Finn Behrens <[email protected]>
> >
> > This patch as commit 1eda919126b4 ("nl80211: reset regdom when reloading
> > regdb") in -next causes the following clang warning/error:
> >
> > net/wireless/reg.c:1137:23: error: implicit conversion from enumeration type 'enum nl80211_user_reg_hint_type' to different enumeration type 'enum nl80211_reg_initiator' [-Werror,-Wenum-conversion]
> > request->initiator = NL80211_USER_REG_HINT_USER;
> > ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1 error generated.
> >
> > Should that be NL80211_REGDOM_SET_BY_CORE (same value, 0) or something
> > different?
>
> I think It should have been NL80211_REGDOM_SET_BY_USER, as the reload
> flag check is currently implemented in the user hint function. But If
> I see it correctly right now. We could remove the reload flag, and
> NL80211_REGDOM_SET_BY_CORE should work as well. As the
> reg_query_database function is called unconditionally there.

If you tested the current version of your patch and it worked fine, then
it seems like you should just revert the addition of the reload flag and
change

request->initiator = NL80211_USER_REG_HINT_USER;

to

request->initiator = NL80211_REGDOM_SET_BY_CORE;

given that is what is happening right now. The warning is basically
pointing out that reg_process_hint() is calling reg_process_hint_core()
instead of reg_process_hint_user() because NL80211_USER_REG_HINT_USER =
NL80211_REGDOM_SET_BY_CORE = 0. Hopefully that makes sense.

Cheers,
Nathan