diff mbox

[2/4] hostapd: Propagate ACS errors to iface setup

Message ID 1381839010-30681-2-git-send-email-helmut.schaa@googlemail.com
State Accepted
Commit 3645fd5aae94fad408390246b5a249982d10ef41
Headers show

Commit Message

Helmut Schaa Oct. 15, 2013, 12:10 p.m. UTC
Otherwise hostapd might hang doing nothing anymore. Propagate ACS
errors so we can fail gracefully.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
---
 src/ap/acs.c         |   17 +++++++----------
 src/ap/acs.h         |    2 +-
 src/ap/hw_features.c |    5 ++++-
 3 files changed, 12 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/src/ap/acs.c b/src/ap/acs.c
index d5e3f59..82f5dbf 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -655,6 +655,7 @@  static void acs_study(struct hostapd_iface *iface)
 	ideal_chan = acs_find_ideal_chan(iface);
 	if (!ideal_chan) {
 		wpa_printf(MSG_ERROR, "ACS: Failed to compute ideal channel");
+		err = -1;
 		goto fail;
 	}
 
@@ -663,24 +664,20 @@  static void acs_study(struct hostapd_iface *iface)
 	if (iface->conf->ieee80211ac)
 		acs_adjust_vht_center_freq(iface);
 
+	err = 0;
+fail:
 	/*
 	 * hostapd_setup_interface_complete() will return -1 on failure,
 	 * 0 on success and 0 is HOSTAPD_CHAN_VALID :)
 	 */
-	switch (hostapd_acs_completed(iface)) {
-	case HOSTAPD_CHAN_VALID:
+	if (hostapd_acs_completed(iface, err) == HOSTAPD_CHAN_VALID) {
 		acs_cleanup(iface);
 		return;
-	case HOSTAPD_CHAN_INVALID:
-	case HOSTAPD_CHAN_ACS:
-	default:
-		/* This can possibly happen if channel parameters (secondary
-		 * channel, center frequencies) are misconfigured */
-		wpa_printf(MSG_ERROR, "ACS: Possibly channel configuration is invalid, please report this along with your config file.");
-		goto fail;
 	}
 
-fail:
+	/* This can possibly happen if channel parameters (secondary
+	 * channel, center frequencies) are misconfigured */
+	wpa_printf(MSG_ERROR, "ACS: Possibly channel configuration is invalid, please report this along with your config file.");
 	acs_fail(iface);
 }
 
diff --git a/src/ap/acs.h b/src/ap/acs.h
index 0d1d0f1..a41f17f 100644
--- a/src/ap/acs.h
+++ b/src/ap/acs.h
@@ -13,7 +13,7 @@ 
 #ifdef CONFIG_ACS
 
 enum hostapd_chan_status acs_init(struct hostapd_iface *iface);
-int hostapd_acs_completed(struct hostapd_iface *iface);
+int hostapd_acs_completed(struct hostapd_iface *iface, int err);
 
 #else /* CONFIG_ACS */
 
diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c
index b74032e..ff7374f 100644
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
@@ -718,10 +718,13 @@  static void hostapd_notify_bad_chans(struct hostapd_iface *iface)
 }
 
 
-int hostapd_acs_completed(struct hostapd_iface *iface)
+int hostapd_acs_completed(struct hostapd_iface *iface, int err)
 {
 	int ret = -1;
 
+	if (err)
+		goto out;
+
 	switch (hostapd_check_chans(iface)) {
 	case HOSTAPD_CHAN_VALID:
 		break;