]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
wireless: fix enabling channel 12 for custom regulatory domain
authorGanapathi Bhat <ganapathi.bhat@nxp.com>
Fri, 20 Dec 2019 10:14:32 +0000 (10:14 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:13:20 +0000 (02:13 -0500)
BugLink: https://bugs.launchpad.net/bugs/1864904
[ Upstream commit c4b9d655e445a8be0bff624aedea190606b5ebbc ]

Commit e33e2241e272 ("Revert "cfg80211: Use 5MHz bandwidth by
default when checking usable channels"") fixed a broken
regulatory (leaving channel 12 open for AP where not permitted).
Apply a similar fix to custom regulatory domain processing.

Signed-off-by: Cathy Luo <xiaohua.luo@nxp.com>
Signed-off-by: Ganapathi Bhat <ganapathi.bhat@nxp.com>
Link: https://lore.kernel.org/r/1576836859-8945-1-git-send-email-ganapathi.bhat@nxp.com
[reword commit message, fix coding style, add a comment]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/wireless/reg.c

index 13a8e0e70f4d226c428742bf6ed413213c69afc1..ee6d6abdb588febc68c66e16502798de7c357a48 100644 (file)
@@ -2080,14 +2080,15 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
 
 static void handle_channel_custom(struct wiphy *wiphy,
                                  struct ieee80211_channel *chan,
-                                 const struct ieee80211_regdomain *regd)
+                                 const struct ieee80211_regdomain *regd,
+                                 u32 min_bw)
 {
        u32 bw_flags = 0;
        const struct ieee80211_reg_rule *reg_rule = NULL;
        const struct ieee80211_power_rule *power_rule = NULL;
        u32 bw;
 
-       for (bw = MHZ_TO_KHZ(20); bw >= MHZ_TO_KHZ(5); bw = bw / 2) {
+       for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) {
                reg_rule = freq_reg_info_regd(MHZ_TO_KHZ(chan->center_freq),
                                              regd, bw);
                if (!IS_ERR(reg_rule))
@@ -2143,8 +2144,14 @@ static void handle_band_custom(struct wiphy *wiphy,
        if (!sband)
                return;
 
+       /*
+        * We currently assume that you always want at least 20 MHz,
+        * otherwise channel 12 might get enabled if this rule is
+        * compatible to US, which permits 2402 - 2472 MHz.
+        */
        for (i = 0; i < sband->n_channels; i++)
-               handle_channel_custom(wiphy, &sband->channels[i], regd);
+               handle_channel_custom(wiphy, &sband->channels[i], regd,
+                                     MHZ_TO_KHZ(20));
 }
 
 /* Used by drivers prior to wiphy registration */