[v3] nl80211: Don't force VHT channel definition with HE
diff mbox series

Message ID 20190701133408.28722-1-sven@narfation.org
State Accepted
Headers show
Series
  • [v3] nl80211: Don't force VHT channel definition with HE
Related show

Commit Message

Sven Eckelmann July 1, 2019, 1:34 p.m. UTC
From: Sven Eckelmann <seckelmann@datto.com>

HE (802.11ax) is also supported on 2.4GHz. And the 2.4GHz band isn't
supposed to use VHT opers. Some codepaths in wpa_supplicant will therefore
not initialize the freq->bandwidth or the freq->center_freq1/2 members. As
a result, the nl80211_put_freq_params will directly return an error (-1) or
the kernel will return an error due to the invalid channel definition.

Instead, the channel definitions should be created based on the actual
HT/VHT/none information on 2.4GHz.

Fixes: ad9a1bfe788e ("nl80211: Share VHT channel configuration for HE")
Signed-off-by: Sven Eckelmann <seckelmann@datto.com>
---
v3:
* differentiate between 2.4GHz and 5GHz HE implementation as requested by
  John Crispin
v2:
* Fix Signed-off-by

 src/drivers/driver_nl80211.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Aug. 11, 2019, 3:25 p.m. UTC | #1
On Mon, Jul 01, 2019 at 03:34:08PM +0200, Sven Eckelmann wrote:
> HE (802.11ax) is also supported on 2.4GHz. And the 2.4GHz band isn't
> supposed to use VHT opers. Some codepaths in wpa_supplicant will therefore
> not initialize the freq->bandwidth or the freq->center_freq1/2 members. As
> a result, the nl80211_put_freq_params will directly return an error (-1) or
> the kernel will return an error due to the invalid channel definition.
> 
> Instead, the channel definitions should be created based on the actual
> HT/VHT/none information on 2.4GHz.

Thanks, applied.

Patch
diff mbox series

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 45835a21b..3b59c836b 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4344,6 +4344,10 @@  fail:
 static int nl80211_put_freq_params(struct nl_msg *msg,
 				   const struct hostapd_freq_params *freq)
 {
+	enum hostapd_hw_mode hw_mode;
+	int is_24ghz;
+	u8 channel;
+
 	wpa_printf(MSG_DEBUG, "  * freq=%d", freq->freq);
 	if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq))
 		return -ENOBUFS;
@@ -4352,7 +4356,14 @@  static int nl80211_put_freq_params(struct nl_msg *msg,
 	wpa_printf(MSG_DEBUG, "  * vht_enabled=%d", freq->vht_enabled);
 	wpa_printf(MSG_DEBUG, "  * ht_enabled=%d", freq->ht_enabled);
 
-	if (freq->vht_enabled || freq->he_enabled) {
+	hw_mode = ieee80211_freq_to_chan(freq->freq, &channel);
+	if (hw_mode == HOSTAPD_MODE_IEEE80211B ||
+	    hw_mode == HOSTAPD_MODE_IEEE80211G)
+		is_24ghz = 1;
+	else
+		is_24ghz = 0;
+
+	if (freq->vht_enabled || (freq->he_enabled && !is_24ghz)) {
 		enum nl80211_chan_width cw;
 
 		wpa_printf(MSG_DEBUG, "  * bandwidth=%d", freq->bandwidth);