Commit 3b9e5aca authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by Johannes Berg

cfg80211: set core regulatory updates on its own

This splits up the core regulatory update to be
set on its own helper. This should make it easier
to read exactly what type of requests should be
expected there. In this case its clear that
NL80211_REGDOM_SET_BY_CORE is only used by the
core for updating the world regulatory domain.
This is consistant with the nl80211.h documentation.
Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
[add warning to default switch case to avoid compiler warning]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent db0e066a
...@@ -2191,6 +2191,14 @@ static void print_regdomain_info(const struct ieee80211_regdomain *rd) ...@@ -2191,6 +2191,14 @@ static void print_regdomain_info(const struct ieee80211_regdomain *rd)
print_rd_rules(rd); print_rd_rules(rd);
} }
static int reg_set_rd_core(const struct ieee80211_regdomain *rd)
{
if (!is_world_regdom(rd->alpha2))
return -EINVAL;
update_world_regdomain(rd);
return 0;
}
/* Takes ownership of rd only if it doesn't fail */ /* Takes ownership of rd only if it doesn't fail */
static int __set_regdom(const struct ieee80211_regdomain *rd, static int __set_regdom(const struct ieee80211_regdomain *rd,
struct regulatory_request *lr) struct regulatory_request *lr)
...@@ -2199,18 +2207,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd, ...@@ -2199,18 +2207,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd,
const struct ieee80211_regdomain *intersected_rd = NULL; const struct ieee80211_regdomain *intersected_rd = NULL;
struct wiphy *request_wiphy; struct wiphy *request_wiphy;
/* Some basic sanity checks first */
if (!reg_is_valid_request(rd->alpha2))
return -EINVAL;
if (is_world_regdom(rd->alpha2)) {
if (lr->initiator != NL80211_REGDOM_SET_BY_CORE)
return -EINVAL;
update_world_regdomain(rd);
return 0;
}
if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) &&
!is_unknown_alpha2(rd->alpha2)) !is_unknown_alpha2(rd->alpha2))
return -EINVAL; return -EINVAL;
...@@ -2320,10 +2316,28 @@ int set_regdom(const struct ieee80211_regdomain *rd) ...@@ -2320,10 +2316,28 @@ int set_regdom(const struct ieee80211_regdomain *rd)
struct regulatory_request *lr; struct regulatory_request *lr;
int r; int r;
if (!reg_is_valid_request(rd->alpha2)) {
kfree(rd);
return -EINVAL;
}
lr = get_last_request(); lr = get_last_request();
/* Note that this doesn't update the wiphys, this is done below */ /* Note that this doesn't update the wiphys, this is done below */
switch (lr->initiator) {
case NL80211_REGDOM_SET_BY_CORE:
r = reg_set_rd_core(rd);
break;
case NL80211_REGDOM_SET_BY_USER:
case NL80211_REGDOM_SET_BY_DRIVER:
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
r = __set_regdom(rd, lr); r = __set_regdom(rd, lr);
break;
default:
WARN(1, "invalid initiator %d\n", lr->initiator);
return -EINVAL;
}
if (r) { if (r) {
if (r == -EALREADY) if (r == -EALREADY)
reg_set_request_processed(); reg_set_request_processed();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment