wireless: remove config_autostart
[project/netifd.git] / wireless.c
index 1f96089..be94c34 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);
 }
 
@@ -591,6 +599,7 @@ vif_update(struct vlist_tree *tree, struct vlist_node *node_new,
                }
 
                D(WIRELESS, "Update wireless interface %s on device %s\n", vif_new->name, wdev->name);
+               wireless_interface_handle_link(vif_old, false);
                free(vif_old->config);
                vif_old->config = blob_memdup(vif_new->config);
                vif_old->isolate = vif_new->isolate;
@@ -680,8 +689,8 @@ 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->config_autostart = true;
-       wdev->autostart = wdev->config_autostart;
+       wdev->retry_setup_failed = false;
+       wdev->autostart = true;
        INIT_LIST_HEAD(&wdev->script_proc);
        vlist_init(&wdev->interfaces, avl_strcmp, vif_update);
        wdev->interfaces.keep_old = true;
@@ -751,6 +760,7 @@ wireless_device_status(struct wireless_device *wdev, struct blob_buf *b)
        blobmsg_add_u8(b, "pending", wdev->state == IFS_SETUP || wdev->state == IFS_TEARDOWN);
        blobmsg_add_u8(b, "autostart", wdev->autostart);
        blobmsg_add_u8(b, "disabled", wdev->disabled);
+       blobmsg_add_u8(b, "retry_setup_failed", wdev->retry_setup_failed);
        put_container(b, wdev->config, "config");
 
        i = blobmsg_open_array(b, "interfaces");
@@ -990,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);
 }