From patchwork Wed Feb 15 17:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 1742979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=y3FkaJu2; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PH4LV1TN9z23r4 for ; Thu, 16 Feb 2023 04:09:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EqkSzLE4fBJCjt1H0dSXTCxLaOwYBIc0/ktEIJqy9Bk=; b=y3FkaJu2bFQWvN eAdzoIGeGEnbn7QYek/RhrOIIL0SlGuizn/5FCZtrxZeHquSgtHhBlhXRR5I0hjPTHV0bz1DktKmn wu8ak9aFysSYH8MKFao1EoDOz4hcDvkRgdsjz/+raCvpT7PGX3mTn3bp0nMCd4oz3BHl6tfbZCesa QVgHqVyHiaK1h0xK39jjsisyxATowsh4+XDV64X8AqCquYJ1dQrroZL11ziRe9lJL78CBHub1AyiK n6Uj4mTv5+tuyidhw1D6BsCVqrSalyzOYqm6JRngsWoMBPIGVoiiBWT5TRMJ76k82vfcZcFWdcnyT ZdRu8YMdfbb95gqul0Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGp-006chd-2W; Wed, 15 Feb 2023 17:08:39 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGR-006cYK-KV for hostap@lists.infradead.org; Wed, 15 Feb 2023 17:08:17 +0000 Received: from evilbit.green-communications.fr ([92.154.77.116]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.103]) with ESMTPSA (Nemesis) id 1MEVBa-1pMJuR3WBe-00G1JX; Wed, 15 Feb 2023 18:07:57 +0100 From: Nicolas Cavallari To: hostap@lists.infradead.org Subject: [PATCH 1/4] wpasupplicant: Split ibss_mesh_setup_freq() into multiple functions Date: Wed, 15 Feb 2023 18:02:50 +0100 Message-Id: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:LeX/Wd/+hbwXh+L+hy3N7nYDROz/J9iw3JRVLtAmWRBkerQPV1V FiCcYkD1dxnMYFCMYDX2+eyWvN8y/BJYDRPYqBHfSTpGVvcVTw0I7J9yxW/Zut4+MqgrfjR WEJLAZaT86iOreRXhamAGjRWcvunGVjSlinSanDxZgng3bvZQZSmhYl68fFl3Gu8E+Pfw+G xp1s6JXusmwm4ht5z91Ow== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:2oQzjv2bejE=;rVTozX5HuPYUx4ZHR30maD3VVRm TJRXXeAoszvMS1lJdbuNAKupeVnq0yzf/lrWmi5r462v46DfbgGaUj/EH7hQbPLFrEfvrfedk w70gDu7RaOwtTQUSWyq2JHO0d+kAk8w66Wj7MvmoqX7xS+EC6MTliIygPlYFEdgVl5IlN7EN0 HOT4KxC6AQO8u40ybWZ4PVJi3768hYyz3/6kxvbHhjI09Yj7ZNmCq44M4jS37S1YCdC3zrtOZ OPjA0dQAw3BUul8Aha4QdxWLWZnbnaMXzAZe7OMCX8lwmrxXOXd7b6pglnTuxCCb1Qh2U/3ku Xj7186MUh4LpNgqGMUCABenXTo0COY7rLuyvEB42z6FY8lmVyjwvzC144Q3IrrJGzyQ06Y7w6 yHOM/h/mi5lc/hkwh0E3gUboAixRgZNzDNYdC9oCxM9WZsbMGV6bdCD/xiIfHMA9+fByzH2cn jGVuQQolxyc+c/FnVoAyjxqf+eY05sG5B6kMnz+16Aa020aB+Jri9St9QrhfWYIhDHCd7OOTs Z/tGfyZs3DqZUU+kI7xcncPiW3GzC/VKKBzdmA9s3bU/K27w/ga6BJbzmZt1ACSBM7OJZSENJ fIQQYk9E1EzfhOa1nqiCTl2Dxz9ncLFZESgJTEwjcxytpGUTjONv9/q0Uj5U38XBxDq+lYpJD SlCJ2A09UDY6ysGnSVsTgOKAMGB6lqvOmk4SrBncyQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_090816_004687_DD2338D7 X-CRM114-Status: GOOD ( 22.71 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: ibss_mesh_setup_freq() has become a 342 line function with 23 local variables, 1 or 2 goto labels depending on ifdefs and its logic is quite unpredictable. Split it into multiple functions. No functional change intended, it should be bug-compatible with the original code, except for some log messages that are skipped more often. Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.187 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.187 listed in wl.mailspike.net] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org ibss_mesh_setup_freq() has become a 342 line function with 23 local variables, 1 or 2 goto labels depending on ifdefs and its logic is quite unpredictable. Split it into multiple functions. No functional change intended, it should be bug-compatible with the original code, except for some log messages that are skipped more often. Signed-off-by: Nicolas Cavallari --- wpa_supplicant/wpa_supplicant.c | 283 ++++++++++++++++++-------------- 1 file changed, 163 insertions(+), 120 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 3766e8b7c..597288ef1 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2637,116 +2637,116 @@ static bool ibss_mesh_is_80mhz_avail(int channel, struct hostapd_hw_modes *mode) } -void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, - const struct wpa_ssid *ssid, - struct hostapd_freq_params *freq) +static struct wpa_bss* ibss_find_existing_bss(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid) { - int ieee80211_mode = wpas_mode_to_ieee80211_mode(ssid->mode); - enum hostapd_hw_mode hw_mode; - struct hostapd_hw_modes *mode = NULL; - int ht40plus[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, - 184, 192 }; - int bw80[] = { 5180, 5260, 5500, 5580, 5660, 5745, 5955, - 6035, 6115, 6195, 6275, 6355, 6435, 6515, - 6595, 6675, 6755, 6835, 6915, 6995 }; - int bw160[] = { 5955, 6115, 6275, 6435, 6595, 6755, 6915 }; - struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL; - u8 channel; - int i, chan_idx, ht40 = -1, res, obss_scan = 1; - unsigned int j, k; - struct hostapd_freq_params vht_freq; - int chwidth, seg0, seg1; - u32 vht_caps = 0; - bool is_24ghz, is_6ghz; - - freq->freq = ssid->frequency; - + unsigned int j; for (j = 0; j < wpa_s->last_scan_res_used; j++) { struct wpa_bss *bss = wpa_s->last_scan_res[j]; - if (ssid->mode != WPAS_MODE_IBSS) - break; - - /* Don't adjust control freq in case of fixed_freq */ - if (ssid->fixed_freq) - break; - if (!bss_is_ibss(bss)) continue; if (ssid->ssid_len == bss->ssid_len && - os_memcmp(ssid->ssid, bss->ssid, bss->ssid_len) == 0) { - wpa_printf(MSG_DEBUG, - "IBSS already found in scan results, adjust control freq: %d", - bss->freq); - freq->freq = bss->freq; - obss_scan = 0; - break; - } + os_memcmp(ssid->ssid, bss->ssid, bss->ssid_len) == 0) + return bss; } + return NULL; +} + +static bool ibss_mesh_can_use_ht(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_hw_modes *mode) { /* For IBSS check HT_IBSS flag */ if (ssid->mode == WPAS_MODE_IBSS && !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_HT_IBSS)) - return; + return false; if (wpa_s->group_cipher == WPA_CIPHER_WEP40 || wpa_s->group_cipher == WPA_CIPHER_WEP104 || wpa_s->pairwise_cipher == WPA_CIPHER_TKIP) { wpa_printf(MSG_DEBUG, "IBSS: WEP/TKIP detected, do not try to enable HT"); - return; + return false; } - hw_mode = ieee80211_freq_to_chan(freq->freq, &channel); - for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) { - if (wpa_s->hw.modes[i].mode == hw_mode) { - mode = &wpa_s->hw.modes[i]; - break; - } - } + if (!ht_supported(mode)) + return false; - if (!mode) - return; +#ifdef CONFIG_HT_OVERRIDES + if (ssid->disable_ht) + return false; +#endif /* CONFIG_HT_OVERRIDES */ - freq->channel = channel; + return true; +} - is_24ghz = hw_mode == HOSTAPD_MODE_IEEE80211G || - hw_mode == HOSTAPD_MODE_IEEE80211B; - /* HT/VHT and corresponding overrides are not applicable to 6 GHz. - * However, HE is mandatory for 6 GHz. - */ - is_6ghz = is_6ghz_freq(freq->freq); - if (is_6ghz) - goto skip_to_6ghz; +static bool ibss_mesh_can_use_vht(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_hw_modes *mode) { + if (mode->mode != HOSTAPD_MODE_IEEE80211A) + return false; -#ifdef CONFIG_HT_OVERRIDES - if (ssid->disable_ht) { - freq->ht_enabled = 0; - return; - } -#endif /* CONFIG_HT_OVERRIDES */ + if (!drv_supports_vht(wpa_s, ssid)) + return false; + + /* For IBSS check VHT_IBSS flag */ + if (ssid->mode == WPAS_MODE_IBSS && + !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_VHT_IBSS)) + return false; + + if (!vht_supported(mode)) + return false; + +#ifdef CONFIG_VHT_OVERRIDES + if (ssid->disable_vht) + return false; +#endif /* CONFIG_VHT_OVERRIDES */ + + return true; +} - freq->ht_enabled = ht_supported(mode); - if (!freq->ht_enabled) - return; - /* Allow HE on 2.4 GHz without VHT: see nl80211_put_freq_params() */ - if (is_24ghz) - freq->he_enabled = mode->he_capab[ieee80211_mode].he_supported; +static bool ibss_mesh_can_use_he(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_hw_modes* mode, + int ieee80211_mode) { #ifdef CONFIG_HE_OVERRIDES - if (is_24ghz && ssid->disable_he) - freq->he_enabled = 0; + if (ssid->disable_he) + return false; #endif /* CONFIG_HE_OVERRIDES */ - /* Setup higher BW only for 5 GHz */ - if (mode->mode != HOSTAPD_MODE_IEEE80211A) + switch (mode->mode) { + case HOSTAPD_MODE_IEEE80211G: + case HOSTAPD_MODE_IEEE80211B: + case HOSTAPD_MODE_IEEE80211A: + return mode->he_capab[ieee80211_mode].he_supported; + default: + return false; + } +} + + +static void ibss_mesh_select_40mhz(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_hw_modes *mode, + struct hostapd_freq_params *freq, + int obss_scan) { + int chan_idx; + struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL; + int i, j, res; + int ht40plus[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, + 184, 192 }; + int ht40 = -1; + + if (!freq->ht_enabled) return; for (chan_idx = 0; chan_idx < mode->num_channels; chan_idx++) { pri_chan = &mode->channels[chan_idx]; - if (pri_chan->chan == channel) + if (pri_chan->chan == freq->channel) break; pri_chan = NULL; } @@ -2757,21 +2757,14 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR)) return; - freq->channel = pri_chan->chan; - #ifdef CONFIG_HT_OVERRIDES - if (ssid->disable_ht40) { -#ifdef CONFIG_VHT_OVERRIDES - if (ssid->disable_vht) - return; -#endif /* CONFIG_VHT_OVERRIDES */ - goto skip_ht40; - } -#endif /* CONFIG_HT_OVERRIDES */ + if (ssid->disable_ht40) + return; +#endif /* Check/setup HT40+/HT40- */ for (j = 0; j < ARRAY_SIZE(ht40plus); j++) { - if (ht40plus[j] == channel) { + if (ht40plus[j] == freq->channel) { ht40 = 1; break; } @@ -2780,7 +2773,7 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, /* Find secondary channel */ for (i = 0; i < mode->num_channels; i++) { sec_chan = &mode->channels[i]; - if (sec_chan->chan == channel + ht40 * 4) + if (sec_chan->chan == freq->channel + ht40 * 4) break; sec_chan = NULL; } @@ -2833,38 +2826,34 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, wpa_scan_results_free(scan_res); } -#ifdef CONFIG_HT_OVERRIDES -skip_ht40: -#endif /* CONFIG_HT_OVERRIDES */ wpa_printf(MSG_DEBUG, "IBSS/mesh: setup freq channel %d, sec_channel_offset %d", freq->channel, freq->sec_channel_offset); +} - if (!drv_supports_vht(wpa_s, ssid)) - return; - - /* For IBSS check VHT_IBSS flag */ - if (ssid->mode == WPAS_MODE_IBSS && - !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_VHT_IBSS)) - return; -#ifdef CONFIG_VHT_OVERRIDES - if (ssid->disable_vht) { - freq->vht_enabled = 0; - return; - } -#endif /* CONFIG_VHT_OVERRIDES */ +static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_hw_modes *mode, + struct hostapd_freq_params *freq, + int ieee80211_mode, bool is_6ghz) { + int bw80[] = { 5180, 5260, 5500, 5580, 5660, 5745, 5955, + 6035, 6115, 6195, 6275, 6355, 6435, 6515, + 6595, 6675, 6755, 6835, 6915, 6995 }; + int bw160[] = { 5955, 6115, 6275, 6435, 6595, 6755, 6915 }; + struct hostapd_freq_params vht_freq; + int i, j, k; + int chwidth, seg0, seg1; + u32 vht_caps = 0; + u8 channel = freq->channel; -skip_to_6ghz: vht_freq = *freq; /* 6 GHz does not have VHT enabled, so allow that exception here. */ - vht_freq.vht_enabled = vht_supported(mode); + if (!freq->he_enabled && is_6ghz) + return false; if (!vht_freq.vht_enabled && !is_6ghz) - return; - - /* Enable HE with VHT for 5 GHz */ - freq->he_enabled = mode->he_capab[ieee80211_mode].he_supported; + return false; /* setup center_freq1, bandwidth */ for (j = 0; j < ARRAY_SIZE(bw80); j++) { @@ -2875,11 +2864,11 @@ skip_to_6ghz: if (j == ARRAY_SIZE(bw80) || ieee80211_freq_to_chan(bw80[j], &channel) == NUM_HOSTAPD_MODES) - return; + return false; /* Back to HT configuration if channel not usable */ if (!ibss_mesh_is_80mhz_avail(channel, mode)) - return; + return false; chwidth = CONF_OPER_CHWIDTH_80MHZ; seg0 = channel + 6; @@ -2893,7 +2882,7 @@ skip_to_6ghz: * of 160 MHz bandwidth. */ if (!ibss_mesh_is_80mhz_avail(channel + 16, mode)) - return; + return false; for (j = 0; j < ARRAY_SIZE(bw160); j++) { if (freq->freq == bw160[j]) { @@ -2913,7 +2902,7 @@ skip_to_6ghz: if (ieee80211_freq_to_chan(bw80[k], &channel) == NUM_HOSTAPD_MODES) - return; + return false; for (i = channel; i < channel + 16; i += 4) { struct hostapd_channel_data *chan; @@ -2957,12 +2946,6 @@ skip_to_6ghz: #endif /* CONFIG_HT_OVERRIDES */ } -#ifdef CONFIG_HE_OVERRIDES - if (ssid->disable_he) { - vht_freq.he_enabled = 0; - freq->he_enabled = 0; - } -#endif /* CONFIG_HE_OVERRIDES */ if (hostapd_set_freq_params(&vht_freq, mode->mode, freq->freq, freq->channel, ssid->enable_edmg, ssid->edmg_channel, freq->ht_enabled, @@ -2972,12 +2955,72 @@ skip_to_6ghz: chwidth, seg0, seg1, vht_caps, &mode->he_capab[ieee80211_mode], NULL) != 0) - return; + return false; *freq = vht_freq; wpa_printf(MSG_DEBUG, "IBSS: VHT setup freq cf1 %d, cf2 %d, bw %d", freq->center_freq1, freq->center_freq2, freq->bandwidth); + return true; +} + + +void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + const struct wpa_ssid *ssid, + struct hostapd_freq_params *freq) +{ + int ieee80211_mode = wpas_mode_to_ieee80211_mode(ssid->mode); + enum hostapd_hw_mode hw_mode; + struct hostapd_hw_modes *mode = NULL; + int i, obss_scan = 1; + u8 channel; + bool is_6ghz; + + freq->freq = ssid->frequency; + + if (ssid->mode == WPAS_MODE_IBSS && !ssid->fixed_freq) { + struct wpa_bss *bss = ibss_find_existing_bss(wpa_s, ssid); + if (bss) { + wpa_printf(MSG_DEBUG, + "IBSS already found in scan results, adjust control freq: %d", + bss->freq); + freq->freq = bss->freq; + obss_scan = 0; + } + } + + hw_mode = ieee80211_freq_to_chan(freq->freq, &channel); + for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) { + if (wpa_s->hw.modes[i].mode == hw_mode) { + mode = &wpa_s->hw.modes[i]; + break; + } + } + + if (!mode) + return; + + is_6ghz = is_6ghz_freq(freq->freq); + + freq->ht_enabled = 0; + freq->vht_enabled = 0; + freq->he_enabled = 0; + + if (!is_6ghz) + freq->ht_enabled = ibss_mesh_can_use_ht(wpa_s, ssid, mode); + if (freq->ht_enabled) + freq->vht_enabled = ibss_mesh_can_use_vht(wpa_s, ssid, mode); + if (freq->vht_enabled || is_6ghz) + freq->he_enabled = ibss_mesh_can_use_he(wpa_s, ssid, mode, + ieee80211_mode); + freq->channel = channel; + /* Setup higher BW only for 5 GHz */ + if (mode->mode == HOSTAPD_MODE_IEEE80211A) { + ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan); + if (!ibss_mesh_select_80_160mhz(wpa_s, ssid, mode, freq, + ieee80211_mode, is_6ghz)) + freq->vht_enabled = false; + } } From patchwork Wed Feb 15 17:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 1742977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=lwIgFFUf; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PH4LL4q70z240B for ; Thu, 16 Feb 2023 04:09:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L+PiYm2AJg8uEhdk522XLwR5ZONsOAA9EMsYlWoy3PQ=; b=lwIgFFUfwbJyQp Vv8AVn6J+Px0nRbB8RfDTpK2fyNjFnj6R94/1lYJ/pXWoidKBs7cFdnwOzRXZiBtwtqOdymeh0mzN 9XSiH5SRU3uEU1H24hbftCcAfK/vB6ZBKcc4kJcqX4SFunlrUMjwNeCpquRLbWIYzCPNVMpPQLpvl IcF9J34jYY5d5r07KUkrAjlH/ZhKpbBY4R6XTKtz4dwuNJNbbu9mv2zghHT8GbejKaax5K4D2bcOR FoTjIgnJp4UMyCRSrCSAiXoiifjb+tLNBnoiar9F243rrfIPXXJEwUNlAYfg3JqV6/+wBR3vSTpFC TOg4Tvuz2fiLxfH7xzlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGh-006cfX-55; Wed, 15 Feb 2023 17:08:31 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGR-006cYY-KY for hostap@lists.infradead.org; Wed, 15 Feb 2023 17:08:17 +0000 Received: from evilbit.green-communications.fr ([92.154.77.116]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.103]) with ESMTPSA (Nemesis) id 1MJV9M-1p8cWG0Peq-00Jqnt; Wed, 15 Feb 2023 18:08:00 +0100 From: Nicolas Cavallari To: hostap@lists.infradead.org Subject: [PATCH 2/4] wpa_supplicant: Make arrays static const in ibss_mesh_select_* Date: Wed, 15 Feb 2023 18:02:51 +0100 Message-Id: <20230215170253.13949-2-nicolas.cavallari@green-communications.fr> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> References: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> MIME-Version: 1.0 X-Provags-ID: V03:K1:8QymPBAXvE6EHmyIqVVbxQxxlTu7LCAM5Nl7phpmn8UM7w9T6/U 1HxCp4gRLg0+I4JhUkyRytB18fRt3vepyWwzZgBw/RhkrGze1+dSjMbVcoCC/oUWXVFt8Pi iHMS7efmKIb4vH5Yvh4IXSZC+lIIX7h5k1AHvZ+Ts9DbyW3WJ2goMtqEeMUlK/LTwQQjcsp RmO6YizdQzOruJzYQW1QQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:n4WC0TlRe9I=;SplpawDh1eXblQed/ArDaWmFDR2 qMTlohM4dz5IOW3S5sjqR3HaAoTJ9JQpOygED13HOV41ax7hrskwSP9z8nqA6Ak6bp61DOncl jDKGzCtoIQhe0XvG+6YgYse7KqlsE3t8TrBEv3ekK8mbdgq6GsMKSCUYyIpdm2Qa2TswFlCgh 3BwviMRn1e5fqkruUyMyzWdssHJCFP5Z92R+wrHSH0FbG+F+e5EUrtanzcR01T8tw9di5pit/ HUUqIjzBFhLXmgrCxcoBdT55SrfOiCEQR5Tprako9hJzqMGbYGSw2tY2lN08wTKneZYF/eKiy xDr58upaPtyY/MlMluOfaYXyaF0rQOO7xa/0BAy8x7X0BbBgV52eM4ZvcSUX1YQXLuQSZePsP mpny6P/OkjIE3sP6Srr7l1afLeSr1YQcVpTMNK7M1Q5K1AIsmhuGOq0a06PqbAxlqnyRHMIUz w6UV6+0Fz/LUpI5IkUwOZxcGfw2fgcQETWDJnaVwpid4sYVIhN8UKbcUFV15ZXbO6a0fVhkt0 d8DrtuqiFQr42ItCT/DlyWLhRdJg9Mj6WVuXXxm9fhSEE+aO1H7Exm32gnALKaI7SE7hRW3Ap a9ISJMKtaY544RBcwyE3RrgUjw+S4590QxnoKy8Brec2rKJUBPg/fIic2v7TCNm3OlL6D02lR PC7LyvshQTDCmgjOXgKjEZFvGDrW6epGjCz3xk7Mgw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_090816_140131_36E1D347 X-CRM114-Status: GOOD ( 10.06 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Nicolas Cavallari --- wpa_supplicant/wpa_supplicant.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 597288ef1..6dc581ad8 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2737,8 [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.131 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.131 listed in wl.mailspike.net] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Nicolas Cavallari --- wpa_supplicant/wpa_supplicant.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 597288ef1..6dc581ad8 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2737,8 +2737,9 @@ static void ibss_mesh_select_40mhz(struct wpa_supplicant *wpa_s, int chan_idx; struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL; int i, j, res; - int ht40plus[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, - 184, 192 }; + static const int ht40plus[] = { + 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 184, 192 + }; int ht40 = -1; if (!freq->ht_enabled) @@ -2837,10 +2838,14 @@ static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, struct hostapd_hw_modes *mode, struct hostapd_freq_params *freq, int ieee80211_mode, bool is_6ghz) { - int bw80[] = { 5180, 5260, 5500, 5580, 5660, 5745, 5955, - 6035, 6115, 6195, 6275, 6355, 6435, 6515, - 6595, 6675, 6755, 6835, 6915, 6995 }; - int bw160[] = { 5955, 6115, 6275, 6435, 6595, 6755, 6915 }; + static const int bw80[] = { + 5180, 5260, 5500, 5580, 5660, 5745, 5955, + 6035, 6115, 6195, 6275, 6355, 6435, 6515, + 6595, 6675, 6755, 6835, 6915, 6995 + }; + static const int bw160[] = { + 5955, 6115, 6275, 6435, 6595, 6755, 6915 + }; struct hostapd_freq_params vht_freq; int i, j, k; int chwidth, seg0, seg1; From patchwork Wed Feb 15 17:02:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 1742978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=4DOl2jnN; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PH4LN6fw5z23r4 for ; Thu, 16 Feb 2023 04:09:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yvcRiyltOSspF17ncocdEZmJOL5oibY50XJFT1WZl+c=; b=4DOl2jnN9hVuma 3CMCHzXkWXzlexKenP3Y88OCUeEykkHsoUR7iVfwVWnUbYteTYJvzYvh85x/yg2s98dLJG4p1lKVZ jmcKraZGuZvYhkJ7RJ+kohTvfzWprp+iGuyes16PmtX9rU88ebpn8IJDuTWyNuA9lsw2As+PyYb5B TloaJ7/0u1NzVEoJGCA1/dLDFUVJO7lWZW02/jarbQ11K/5dLTD0ckBa/PG2iyT8tMEwxvGrpJhPx W0LYR2c9YLYgWxzQBBL4bnYWH3RalRHi/4gL8BdwVIwSc4msvnr6wDA94L4sBg7En5bW47yF6LtOQ FbkHEaaod6i+7HtsHMlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGY-006cdA-TH; Wed, 15 Feb 2023 17:08:22 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGP-006cYX-Px for hostap@lists.infradead.org; Wed, 15 Feb 2023 17:08:15 +0000 Received: from evilbit.green-communications.fr ([92.154.77.116]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.103]) with ESMTPSA (Nemesis) id 1N6bsM-1oUdOI0yGk-017zTf; Wed, 15 Feb 2023 18:08:00 +0100 From: Nicolas Cavallari To: hostap@lists.infradead.org Subject: [PATCH 3/4] wpa_supplicant: Fix creating 6GHz ibss/mesh on 5/6 GHz-capable phys Date: Wed, 15 Feb 2023 18:02:52 +0100 Message-Id: <20230215170253.13949-3-nicolas.cavallari@green-communications.fr> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> References: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> MIME-Version: 1.0 X-Provags-ID: V03:K1:tEtUKJqWIQGQel89juHHkeu3odE8fCuutigOW7VwdMwvykmz+uG sUN0Fv/fYHUThNTsx97T3uLj9iSdZc871SrLQ8JduwuRE4/BhnUU9zgQc9XqAbsyTJfnjmQ La/2LtUfRNnbyUrZuHR8AKJUdGW5ofiTZMEisZLPIOlFwSy46CjyE15+WXh5GFaX8Udgv9G HoIx+FgdXvJ1B3309TzZg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:KFT6rXvuzVU=;Y+OmaskbqAOYk4scJBQNNtc7CAA g6sdcfg4Kgkm/jcfOhQSIBx68QkUpv4t2Zg2/G4Ln5XTHrdwYTAAIjpiZZDWqgi4qfdG7Q6/W GF4sPLV8Y6ickB2RLBbMNfTIR1CEKdb/ivdgVP7MmzFWKEzdIxj0LHLenDFtnKu1zjQ6L5QEc g6y/wgCntOvmwJzuWw1ysz25zh/KOzO48RP1Kxv1CufVmggvdWN2SED1NKW6Y99fnaiwEi+iC TE7rmTGWcsjvLkA1VChGa7CwJKiCuszBpuIfmSw86CjbkYIFM77drJYP4Bi7YpRgrSfQKfKWD tnB06JsOUOIqVLnUJb3v1t6Rc3LKUKWvraTraNtAj/k+XiNq4nQoeVLeRg4sqqpOFI4i1HY9u 8xRuWY9CsiUwvdskfwXZNReu9WyfRWHKnzPnmZsJstPvVB6L05XFYqTzr2KyJwAOzR7xSCL+D PnDYvb/5h18qRoRJQNK7Sx6n0xO2WaF81djubCHJSbgXumEYEBdLNj4zzGfmQi72mTJahI2+E 9yD5hhBZGIcGKzz3uy2IsYE/SiRiZ1kdOx+uyPYZvMBRKfuf3AuN47d+jy4Fu4bJW9lQy6QHe 1f6RQo/IJLk8lv6rqzqEe/7iYvW8+5XXZXCj56kFCVzSSlWPcBI2CDQnp0S5KNdPc11o9DK7Y 2YVFgtFJSSI+OPSuUbx28TTNF1MdMZ75ZpfzcuFslw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_090814_146719_8E890F55 X-CRM114-Status: GOOD ( 12.54 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: If the phy supports both 5 GHz and 6 GHz bands, then there will be two different struct hostapd_hw_modes with mode HOSTAPD_MODE_IEEE80211A, one for each band, with potentially different capabilities. Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.134 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.134 listed in wl.mailspike.net] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If the phy supports both 5 GHz and 6 GHz bands, then there will be two different struct hostapd_hw_modes with mode HOSTAPD_MODE_IEEE80211A, one for each band, with potentially different capabilities. Check that the struct hostapd_hw_modes actually contains the frequency before selecting it. Signed-off-by: Nicolas Cavallari --- wpa_supplicant/wpa_supplicant.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 6dc581ad8..9ed79abab 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2996,7 +2996,9 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, hw_mode = ieee80211_freq_to_chan(freq->freq, &channel); for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) { - if (wpa_s->hw.modes[i].mode == hw_mode) { + if (wpa_s->hw.modes[i].mode == hw_mode && + hw_mode_get_channel(&wpa_s->hw.modes[i], freq->freq, + NULL) != NULL) { mode = &wpa_s->hw.modes[i]; break; } From patchwork Wed Feb 15 17:02:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 1742976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=VLmQOv7h; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PH4LK3Crmz23r4 for ; Thu, 16 Feb 2023 04:09:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ypQtAMDQdIhtd62woGtdCWrbG++DgdtXR80HqcCeKuo=; b=VLmQOv7hdG19i9 Zh7knb+WbH8xZNXlU71Kfbgv8JWZ+nJ5kfy70XolTkP32ucyEabHEtdncWVaGiHMcb/JjaW0HN/uK VWfAOiiBryISHhIdzvLRaybDqTN85qJ475dWjBd24hs+yPTWTInOKUPD8cntDHc4y5LntI22oYFaT ZJY7QyL1ix4WC9ZobvfiyQ0ht4+K9iYSizteRw6yOVhY06OyPrmlL16V2TGwZZ8Em3OmEmksUmWjj IKjkZPHRyZKV8E0nwZODmtDsXOfK5mqW0ukKA+bNQtlNMxiUC0iT1d6U2WMwOKM/HArD4xSjzD3bE 5oksyY/XBVyO9LnKT7lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGQ-006caL-R0; Wed, 15 Feb 2023 17:08:14 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSLGM-006cYr-9v for hostap@lists.infradead.org; Wed, 15 Feb 2023 17:08:12 +0000 Received: from evilbit.green-communications.fr ([92.154.77.116]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.103]) with ESMTPSA (Nemesis) id 1Mi2BV-1oxO9h1Xnt-00e7a0; Wed, 15 Feb 2023 18:08:00 +0100 From: Nicolas Cavallari To: hostap@lists.infradead.org Subject: [PATCH 4/4] wpa_supplicant: Rework ibss/mesh 80 MHz channel selection. Date: Wed, 15 Feb 2023 18:02:53 +0100 Message-Id: <20230215170253.13949-4-nicolas.cavallari@green-communications.fr> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> References: <20230215170253.13949-1-nicolas.cavallari@green-communications.fr> MIME-Version: 1.0 X-Provags-ID: V03:K1:3d50ypbxDUubq8ahNEaKoX3h8Dum3RqcBr66I5bCT7lyAuhepkR ZArP7PpAfqpqF8dHEoFKkD4ygrxivEcf3T0cHnuFlbNqm2NmO+GwH7ptYnsKoXmq1sGM7yq 6xTzfA80iG4RsHnzUtjZBVU6P2LAZqxp088NvSdueIyiGbUf6HRDKQQccPZw1mCV2rYTIbh Bzwka+XD+Ru3rbUnozUHg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:0Wtu2S2gRkU=;HTtU+lKNI9lAAX47D8C7FK8G+qx JcTs9HOzbtF2Hkc8dpoUhA9bDW8Mn6JTTgCRmCnUGQ35REpVsUvNdC5+2/FcrlS6k6IPn52Nb x50r74cMn9CQDKcfcPx9BzX1SyYQyNSnAOfRdTSdt4c9h+RksDG4HK6x7d0mHPNZaGEyvHsCs FWSCVUBXEjA91721alScQCya+NjMqefAeb5sSoHdSnPNbJrkGo63YNC70rJbDoZ6dYoKpDS9C tupOcN4GNIj95V1EDaL87jcBi7fTsSmFxfFS1gH5NyK3zC3G0nWjNDYnmi9toBv2ctnSy/vb8 shNXEx/8G+h5f17BpLKko7WThXLsY9efiaD6dgWQB81xaaeZm0EpsAHOqu6jAw+v9Gq/UpAKf 06J3OKQPm7aTxbYxJmtp6Hg0ZQVm1XM9poRiu4TcqF1OhLKqRvqRiIMOcoVQAB15qL0vx9fXf d1Mp8QeGRscxO3ZRxvMWFMWL18MWHwF759jjcR4ZlNnadeNaXpvoMhSthPBm/uJ8ny+PdUFG2 P5gbSIEt3OhWsCPGLagMK0jhqA0oiI6A+XQx1VwX+wRoEbgxjC+4xbGYJISctk9KpsGgYSaTb 4XIh0EUHC9oNHkp4QE/4whbzjXrRV5833fM4mQSuoJXxq2HNRLI62KEfRlzWBM7RRom5fQuHc eoXfY4TA6/C/Nx6HIyD0DkP2DdBuO4Q0d/pXDM1/mg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_090810_671367_D44E1419 X-CRM114-Status: GOOD ( 17.70 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: - Do not try to enable 80 MHz if 40 MHz is disabled or not selected (due to e.g. obss_scan). - If it is not possible to use 80 HMz or even 40 MHz, then still attempt to configure HE40/VHT40/HE20/VHT20 [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [212.227.126.133 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.133 listed in wl.mailspike.net] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org - Do not try to enable 80 MHz if 40 MHz is disabled or not selected (due to e.g. obss_scan). - If it is not possible to use 80 HMz or even 40 MHz, then still attempt to configure HE40/VHT40/HE20/VHT20 instead of bailing out. - When bailing out, also disable HE. Signed-off-by: Nicolas Cavallari --- wpa_supplicant/wpa_supplicant.c | 53 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 9ed79abab..66a27468f 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2852,13 +2852,22 @@ static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, u32 vht_caps = 0; u8 channel = freq->channel; + if (!freq->vht_enabled && !freq->he_enabled) + return true; + vht_freq = *freq; - /* 6 GHz does not have VHT enabled, so allow that exception here. */ - if (!freq->he_enabled && is_6ghz) - return false; - if (!vht_freq.vht_enabled && !is_6ghz) - return false; + chwidth = CONF_OPER_CHWIDTH_USE_HT; + seg0 = freq->channel + 2 * freq->sec_channel_offset; + seg1 = 0; + if (freq->sec_channel_offset == 0) { + seg0 = 0; + /* Don't try 80 MHz if 40 MHz failed, except in 6 GHz */ + if (freq->ht_enabled && !is_6ghz) + goto skip_80mhz; + } + if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_USE_HT) + goto skip_80mhz; /* setup center_freq1, bandwidth */ for (j = 0; j < ARRAY_SIZE(bw80); j++) { @@ -2869,26 +2878,24 @@ static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, if (j == ARRAY_SIZE(bw80) || ieee80211_freq_to_chan(bw80[j], &channel) == NUM_HOSTAPD_MODES) - return false; + goto skip_80mhz; - /* Back to HT configuration if channel not usable */ + /* Use 40 MHz if channel not usable */ if (!ibss_mesh_is_80mhz_avail(channel, mode)) - return false; + goto skip_80mhz; chwidth = CONF_OPER_CHWIDTH_80MHZ; seg0 = channel + 6; seg1 = 0; + /* In 160 MHz, the initial four 20 MHz channels were validated + * above. If 160 MHz is supported, check the remaining four 20 MHz + * channels for the total of 160 MHz bandwidth for 6 GHz. + */ if ((mode->he_capab[ieee80211_mode].phy_cap[ HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] & - HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G) && is_6ghz) { - /* In 160 MHz, the initial four 20 MHz channels were validated - * above; check the remaining four 20 MHz channels for the total - * of 160 MHz bandwidth. - */ - if (!ibss_mesh_is_80mhz_avail(channel + 16, mode)) - return false; - + HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G) && is_6ghz && + ibss_mesh_is_80mhz_avail(channel + 16, mode)) { for (j = 0; j < ARRAY_SIZE(bw160); j++) { if (freq->freq == bw160[j]) { chwidth = CONF_OPER_CHWIDTH_160MHZ; @@ -2907,7 +2914,7 @@ static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, if (ieee80211_freq_to_chan(bw80[k], &channel) == NUM_HOSTAPD_MODES) - return false; + break; for (i = channel; i < channel + 16; i += 4) { struct hostapd_channel_data *chan; @@ -2942,19 +2949,13 @@ static bool ibss_mesh_select_80_160mhz(struct wpa_supplicant *wpa_s, vht_caps |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; seg0 = 114; } - } else if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_USE_HT) { - chwidth = CONF_OPER_CHWIDTH_USE_HT; - seg0 = channel + 2; -#ifdef CONFIG_HT_OVERRIDES - if (ssid->disable_ht40) - seg0 = 0; -#endif /* CONFIG_HT_OVERRIDES */ } +skip_80mhz: if (hostapd_set_freq_params(&vht_freq, mode->mode, freq->freq, freq->channel, ssid->enable_edmg, ssid->edmg_channel, freq->ht_enabled, - vht_freq.vht_enabled, freq->he_enabled, + freq->vht_enabled, freq->he_enabled, false, freq->sec_channel_offset, chwidth, seg0, seg1, vht_caps, @@ -3026,7 +3027,7 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan); if (!ibss_mesh_select_80_160mhz(wpa_s, ssid, mode, freq, ieee80211_mode, is_6ghz)) - freq->vht_enabled = false; + freq->he_enabled = freq->vht_enabled = false; } }