Skip to content

Commit 1eda919

Browse files
kloenkjmberg-intel
authored andcommitted
nl80211: reset regdom when reloading regdb
Reload the regdom when the regulatory db is reloaded. Otherwise, the user had to change the regulatoy domain to a different one and then reset it to the correct one to have a new regulatory db take effect after a reload. Signed-off-by: Finn Behrens <fin@nyantec.com> Link: https://lore.kernel.org/r/YaIIZfxHgqc/UTA7@gimli.kloenk.dev [edit commit message] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent af9d3a2 commit 1eda919

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

include/net/regulatory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct regulatory_request {
8383
enum nl80211_dfs_regions dfs_region;
8484
bool intersect;
8585
bool processed;
86+
bool reload;
8687
enum environment_cap country_ie_env;
8788
struct list_head list;
8889
};

net/wireless/reg.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static u32 reg_is_indoor_portid;
133133

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

137138
static const struct ieee80211_regdomain *get_cfg80211_regdom(void)
138139
{
@@ -1098,6 +1099,8 @@ int reg_reload_regdb(void)
10981099
const struct firmware *fw;
10991100
void *db;
11001101
int err;
1102+
const struct ieee80211_regdomain *current_regdomain;
1103+
struct regulatory_request *request;
11011104

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

1125+
/* reset regulatory domain */
1126+
current_regdomain = get_cfg80211_regdom();
1127+
1128+
request = kzalloc(sizeof(*request), GFP_KERNEL);
1129+
if (!request) {
1130+
err = -ENOMEM;
1131+
goto out_unlock;
1132+
}
1133+
1134+
request->wiphy_idx = WIPHY_IDX_INVALID;
1135+
request->alpha2[0] = current_regdomain->alpha2[0];
1136+
request->alpha2[1] = current_regdomain->alpha2[1];
1137+
request->initiator = NL80211_USER_REG_HINT_USER;
1138+
request->user_reg_hint_type = NL80211_USER_REG_HINT_USER;
1139+
request->reload = true;
1140+
1141+
reg_process_hint(request);
1142+
1143+
out_unlock:
1144+
rtnl_unlock();
11231145
out:
11241146
release_firmware(fw);
11251147
return err;
@@ -2690,7 +2712,8 @@ reg_process_hint_user(struct regulatory_request *user_request)
26902712

26912713
treatment = __reg_process_hint_user(user_request);
26922714
if (treatment == REG_REQ_IGNORE ||
2693-
treatment == REG_REQ_ALREADY_SET)
2715+
(treatment == REG_REQ_ALREADY_SET &&
2716+
!user_request->reload))
26942717
return REG_REQ_IGNORE;
26952718

26962719
user_request->intersect = treatment == REG_REQ_INTERSECT;

0 commit comments

Comments
 (0)