summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-02-28 20:36:08 +1300
committerFelix Fietkau <nbd@openwrt.org>2015-02-28 20:36:08 +1300
commit212288ba1518c0fd4d44f22e7c2af09022944a9f (patch)
tree8e7670f2455f1bb859f8b04fc5950c6a3243f1df
parent4d84111e1014c817653db92bcd8024ff1935b6be (diff)
wireless: fix teardown, always pass the previous config to the teardown handler instead of the new one
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r--wireless.c24
-rw-r--r--wireless.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/wireless.c b/wireless.c
index 8bdfc4b..fbd6191 100644
--- a/wireless.c
+++ b/wireless.c
@@ -240,8 +240,14 @@ wireless_device_run_handler(struct wireless_device *wdev, bool up)
int fds[2] = { -1, -1 };
D(WIRELESS, "Wireless device '%s' run %s handler\n", wdev->name, action);
- prepare_config(wdev, &b, up);
- config = blobmsg_format_json(b.head, true);
+ if (!up && wdev->prev_config) {
+ config = blobmsg_format_json(wdev->prev_config, true);
+ free(wdev->prev_config);
+ wdev->prev_config = NULL;
+ } else {
+ prepare_config(wdev, &b, up);
+ config = blobmsg_format_json(b.head, true);
+ }
argv[i++] = wdev->drv->script;
argv[i++] = wdev->drv->name;
@@ -273,6 +279,8 @@ __wireless_device_set_up(struct wireless_device *wdev)
if (wdev->state != IFS_DOWN || config_init)
return;
+ free(wdev->prev_config);
+ wdev->prev_config = NULL;
wdev->state = IFS_SETUP;
wireless_device_run_handler(wdev, true);
}
@@ -283,6 +291,7 @@ wireless_device_free(struct wireless_device *wdev)
vlist_flush_all(&wdev->interfaces);
avl_delete(&wireless_devices.avl, &wdev->node.avl);
free(wdev->config);
+ free(wdev->prev_config);
free(wdev);
}
@@ -422,6 +431,16 @@ wdev_set_config_state(struct wireless_device *wdev, enum interface_config_state
}
static void
+wdev_prepare_prev_config(struct wireless_device *wdev)
+{
+ if (wdev->prev_config)
+ return;
+
+ prepare_config(wdev, &b, false);
+ wdev->prev_config = blob_memdup(b.head);
+}
+
+static void
wdev_change_config(struct wireless_device *wdev, struct wireless_device *wd_new)
{
struct blob_attr *new_config = wd_new->config;
@@ -429,6 +448,7 @@ wdev_change_config(struct wireless_device *wdev, struct wireless_device *wd_new)
free(wd_new);
+ wdev_prepare_prev_config(wdev);
if (blob_attr_equal(wdev->config, new_config) && wdev->disabled == disabled)
return;
diff --git a/wireless.h b/wireless.h
index f2ea7c2..c5dbb88 100644
--- a/wireless.h
+++ b/wireless.h
@@ -49,6 +49,7 @@ struct wireless_device {
struct ubus_request_data *kill_request;
+ struct blob_attr *prev_config;
struct blob_attr *config;
struct blob_attr *data;