netifd: track when wdev setup fails
authorEduardo Abinader <eduardo.abinader@riverbed.com>
Fri, 12 Aug 2016 06:51:58 +0000 (08:51 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 23 Aug 2016 07:54:24 +0000 (09:54 +0200)
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@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
wireless.c
wireless.h

index 34dd328e14de15242ec9241e46b72b2dac9fe57e..f5378482a5c3e24fdc990912ccdcbc2e37c9d468 100644 (file)
@@ -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);
 }
@@ -424,6 +430,7 @@ wireless_device_script_task_cb(struct netifd_process *proc, int ret)
 void
 wireless_device_set_down(struct wireless_device *wdev)
 {
+       wdev->retry_setup_failed = false;
        wdev->autostart = false;
        __wireless_device_set_down(wdev);
 }
@@ -467,6 +474,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 +689,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 +1000,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);
 }
index 665cdb7c97be984708cacccda6b3dc45ea9391f3..403cc86da9cb7ebba06ad8ebcfa781412702895c 100644 (file)
@@ -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;