[LEDE-DEV] [PATCH v5] netifd: track when wdev setup fails

Eduardo Abinader eduardoabinader at gmail.com
Thu Aug 11 23:51:58 PDT 2016


From: Eduardo Abinader <eduardo.abinader at riverbed.com>

When netifd failed to load a valid configuration, after an invalid one,
it was not possible to setup the wireless device. This patch
aims to track this situation and behave acordingly, by keeping
track of failed setup without affecting autostart behavior. Also
block the restart of the wdev, when not applied.

Signed-off-by: Eduardo Abinader <eduardoabinader at gmail.com>
---
 wireless.c | 17 ++++++++++++-----
 wireless.h |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/wireless.c b/wireless.c
index 34dd328..e30adb3 100644
--- a/wireless.c
+++ b/wireless.c
@@ -287,6 +287,12 @@ __wireless_device_set_up(struct wireless_device *wdev)
 	if (wdev->disabled)
 		return;
 
+	if (wdev->retry_setup_failed)
+		return;
+
+	if (!wdev->autostart)
+		return;
+
 	if (wdev->state != IFS_DOWN || config_init)
 		return;
 
@@ -314,9 +320,9 @@ wdev_handle_config_change(struct wireless_device *wdev)
 	switch(state) {
 	case IFC_NORMAL:
 	case IFC_RELOAD:
+		__wireless_device_set_up(wdev);
+
 		wdev->config_state = IFC_NORMAL;
-		if (wdev->autostart)
-			__wireless_device_set_up(wdev);
 		break;
 	case IFC_REMOVE:
 		wireless_device_free(wdev);
@@ -399,7 +405,7 @@ wireless_device_retry_setup(struct wireless_device *wdev)
 		return;
 
 	if (--wdev->retry < 0)
-		wdev->autostart = false;
+		wdev->retry_setup_failed = true;
 
 	__wireless_device_set_down(wdev);
 }
@@ -467,6 +473,7 @@ wdev_change_config(struct wireless_device *wdev, struct wireless_device *wd_new)
 	free(wdev->config);
 	wdev->config = blob_memdup(new_config);
 	wdev->disabled = disabled;
+	wdev->retry_setup_failed = false;
 	wdev_set_config_state(wdev, IFC_RELOAD);
 }
 
@@ -681,6 +688,7 @@ wireless_device_create(struct wireless_driver *drv, const char *name, struct blo
 	wdev->config_state = IFC_NORMAL;
 	wdev->name = strcpy(name_buf, name);
 	wdev->config = data;
+	wdev->retry_setup_failed = false;
 	wdev->config_autostart = true;
 	wdev->autostart = wdev->config_autostart;
 	INIT_LIST_HEAD(&wdev->script_proc);
@@ -991,6 +999,5 @@ wireless_start_pending(void)
 	struct wireless_device *wdev;
 
 	vlist_for_each_element(&wireless_devices, wdev, node)
-		if (wdev->autostart)
-			__wireless_device_set_up(wdev);
+		__wireless_device_set_up(wdev);
 }
diff --git a/wireless.h b/wireless.h
index 665cdb7..403cc86 100644
--- a/wireless.h
+++ b/wireless.h
@@ -56,6 +56,7 @@ struct wireless_device {
 	bool config_autostart;
 	bool autostart;
 	bool disabled;
+	bool retry_setup_failed;
 
 	enum interface_state state;
 	enum interface_config_state config_state;
-- 
2.5.0




More information about the Lede-dev mailing list