wireless: fix reload of active interfaces
authorFelix Fietkau <nbd@openwrt.org>
Sun, 1 Dec 2013 22:47:47 +0000 (23:47 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 1 Dec 2013 22:47:47 +0000 (23:47 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
wireless.c

index c19d12c073df92d418c379839a37bae740b8fc43..fb66e7f3b136384abb1825f5b6d58d399687f308 100644 (file)
@@ -247,6 +247,32 @@ __wireless_device_set_up(struct wireless_device *wdev)
        wireless_device_run_handler(wdev, true);
 }
 
+static void
+wireless_device_free(struct wireless_device *wdev)
+{
+    vlist_flush_all(&wdev->interfaces);
+    free(wdev->config);
+    free(wdev);
+}
+
+static void
+wdev_handle_config_change(struct wireless_device *wdev)
+{
+       enum interface_config_state state = wdev->config_state;
+
+       wdev->config_state = IFC_NORMAL;
+       switch(state) {
+       case IFC_NORMAL:
+       case IFC_RELOAD:
+               if (wdev->autostart)
+                       __wireless_device_set_up(wdev);
+               break;
+       case IFC_REMOVE:
+               wireless_device_free(wdev);
+               break;
+       }
+}
+
 static void
 wireless_device_mark_down(struct wireless_device *wdev)
 {
@@ -262,9 +288,7 @@ wireless_device_mark_down(struct wireless_device *wdev)
        wdev->cancel = false;
        wdev->state = IFS_DOWN;
        wireless_device_free_state(wdev);
-
-       if (wdev->autostart)
-               __wireless_device_set_up(wdev);
+       wdev_handle_config_change(wdev);
 }
 
 static void
@@ -344,33 +368,6 @@ wireless_device_set_down(struct wireless_device *wdev)
        __wireless_device_set_down(wdev);
 }
 
-static void
-wireless_device_free(struct wireless_device *wdev)
-{
-    vlist_flush_all(&wdev->interfaces);
-    free(wdev->config);
-    free(wdev);
-}
-
-static void
-wdev_handle_config_change(struct wireless_device *wdev)
-{
-       enum interface_config_state state = wdev->config_state;
-
-       wdev->config_state = IFC_NORMAL;
-       switch(state) {
-       case IFC_NORMAL:
-               break;
-       case IFC_RELOAD:
-               if (wdev->autostart)
-                       __wireless_device_set_up(wdev);
-               break;
-       case IFC_REMOVE:
-               wireless_device_free(wdev);
-               break;
-       }
-}
-
 static void
 wdev_set_config_state(struct wireless_device *wdev, enum interface_config_state s)
 {