diff mbox series

[RESEND,03/10] mesh: Allow DFS channels to be selected if dfs is enabled

Message ID 20200626142822.272002-4-markus.theil@tu-ilmenau.de
State New
Headers show
Series mesh: support for DFS | expand

Commit Message

Markus Theil June 26, 2020, 2:28 p.m. UTC
From: Peter Oh <peter.oh@bowerswilkins.com>

Note: DFS is assumed to be usable if a country code has been set

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
---
 wpa_supplicant/wpa_supplicant.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 4c1daf1fa..fcd8462ab 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2356,6 +2356,8 @@  void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s,
 	int chwidth, seg0, seg1;
 	u32 vht_caps = 0;
 	int is_24ghz;
+	int dfs_enabled = wpa_s->conf->country[0] &&
+			 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
 
 	freq->freq = ssid->frequency;
 
@@ -2443,8 +2445,11 @@  void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s,
 		return;
 
 	/* Check primary channel flags */
-	if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
+	if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
 		return;
+	if (pri_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
+		if (!dfs_enabled)
+			return;
 
 	freq->channel = pri_chan->chan;
 
@@ -2477,8 +2482,11 @@  void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s,
 		return;
 
 	/* Check secondary channel flags */
-	if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
+	if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
 		return;
+	if (sec_chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
+		if (!dfs_enabled)
+			return;
 
 	if (ht40 == -1) {
 		if (!(pri_chan->flag & HOSTAPD_CHAN_HT40MINUS))
@@ -2571,8 +2579,11 @@  skip_ht40:
 			return;
 
 		/* Back to HT configuration if channel not usable */
-		if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR))
+		if (chan->flag & HOSTAPD_CHAN_DISABLED)
 			return;
+		if (chan->flag & (HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR))
+			if (!dfs_enabled)
+				return;
 	}
 
 	chwidth = CHANWIDTH_80MHZ;
@@ -2592,10 +2603,12 @@  skip_ht40:
 				if (!chan)
 					continue;
 
-				if (chan->flag & (HOSTAPD_CHAN_DISABLED |
-						  HOSTAPD_CHAN_NO_IR |
-						  HOSTAPD_CHAN_RADAR))
+				if (chan->flag & HOSTAPD_CHAN_DISABLED)
 					continue;
+				if (chan->flag & (HOSTAPD_CHAN_RADAR |
+						  HOSTAPD_CHAN_NO_IR))
+					if (!dfs_enabled)
+						continue;
 
 				/* Found a suitable second segment for 80+80 */
 				chwidth = CHANWIDTH_80P80MHZ;