[RFC] hostapd: DFS - handle running out of DFS channels

Zefir Kurtisi zefir.kurtisi
Fri Oct 9 05:58:34 PDT 2015


In scenarios where only DFS channels are available (e.g. outdoor,
special countrycodes), hostapd must be able to handle situations
where all are unavailable.

The two possibilities to get there are
1) while operating on the last available DFS channel a radar is
   detected
2) hostapd is started while all channels are unavailable

In both cases, hostapd instead of terminating should better
wait for the NOPs to pass and re-try operation after the CAC.

This patch attempts to provide this feature with minimal modifi-
cation of the existing DFS framework. It uses the condition
(iface->state == HAPD_IFACE_DFS && !iface->cac_started)
as NOP mode signature to retry operation from within
hostapd_dfs_nop_finished().

Signed-off-by: Zefir Kurtisi <zefir.kurtisi at neratec.com>
---
 src/ap/dfs.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 7273caa..7e9acfd 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -660,13 +660,14 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
 	}
 
 	iface->cac_started = 0;
+	hostapd_set_state(iface, HAPD_IFACE_DFS);
 
 	do {
 		/* Get start (first) channel for current configuration */
 		start_chan_idx = dfs_get_start_chan_idx(iface,
 							&start_chan_idx1);
 		if (start_chan_idx == -1)
-			return -1;
+			return 0;
 
 		/* Get number of used channels, depend on width */
 		n_chans = dfs_get_used_n_chans(iface, &n_chans1);
@@ -704,7 +705,7 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
 							skip_radar);
 			if (!channel) {
 				wpa_printf(MSG_ERROR, "could not get valid channel");
-				return -1;
+				return 0;
 			}
 
 			iface->freq = channel->freq;
@@ -716,7 +717,6 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
 	} while (res);
 
 	/* Finally start CAC */
-	hostapd_set_state(iface, HAPD_IFACE_DFS);
 	wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz", iface->freq);
 	wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
 		"freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds",
@@ -793,7 +793,6 @@ static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface)
 
 	if (!channel) {
 		wpa_printf(MSG_ERROR, "No valid channel available");
-		hostapd_setup_interface_complete(iface, err);
 		return err;
 	}
 
@@ -858,8 +857,8 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
 						&vht_oper_centr_freq_seg1_idx,
 						skip_radar);
 		if (!channel) {
-			/* FIXME: Wait for channel(s) to become available */
-			hostapd_disable_iface(iface);
+			wpa_printf(MSG_INFO, "%s: no DFS channels left, "
+				   "waiting for NOP to finish", __func__);
 			return err;
 		}
 
@@ -982,6 +981,9 @@ int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq,
 	/* TODO add correct implementation here */
 	set_dfs_state(iface, freq, ht_enabled, chan_offset, chan_width,
 		      cf1, cf2, HOSTAPD_CHAN_DFS_USABLE);
+
+	if (iface->state == HAPD_IFACE_DFS && !iface->cac_started)
+		hostapd_handle_dfs(iface);
 	return 0;
 }
 
-- 
2.5.0




More information about the Hostap mailing list