summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2015-06-08 13:02:00 +0200
committerSteven Barth <steven@midlink.org>2015-06-08 13:02:00 +0200
commit8795f9ef89626cd658f615c78c6a17e990c0dcaa (patch)
treed28c7efea73b90a2d92a3212940e14453aed7a22
parent3653d721dad44c5a63790a3fd67e819dfb1dc428 (diff)
Fix removal of dynamic interfaces
Also remove obsolete "del_dynamic" call (use "down" instead) Signed-off-by: Steven Barth <steven@midlink.org>
-rw-r--r--interface.c8
-rw-r--r--ubus.c26
2 files changed, 5 insertions, 29 deletions
diff --git a/interface.c b/interface.c
index 5166c0c..848990e 100644
--- a/interface.c
+++ b/interface.c
@@ -74,6 +74,9 @@ const struct uci_blob_param_list interface_attr_list = {
};
static void
+set_config_state(struct interface *iface, enum interface_config_state s);
+
+static void
interface_error_flush(struct interface *iface)
{
struct interface_error *error, *tmp;
@@ -256,9 +259,6 @@ __interface_set_down(struct interface *iface, bool force)
interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
if (force)
interface_flush_state(iface);
-
- if (iface->dynamic)
- vlist_delete(&interfaces, &iface->node);
break;
case IFS_DOWN:
@@ -644,6 +644,8 @@ interface_handle_config_change(struct interface *iface)
}
if (iface->autostart && iface->available)
interface_set_up(iface);
+ else if (iface->dynamic)
+ set_config_state(iface, IFC_REMOVE);
}
static void
diff --git a/ubus.c b/ubus.c
index 422b652..56f7bdd 100644
--- a/ubus.c
+++ b/ubus.c
@@ -166,38 +166,12 @@ error:
return UBUS_STATUS_UNKNOWN_ERROR;
}
-static int
-netifd_del_dynamic(struct ubus_context *ctx, struct ubus_object *obj,
- struct ubus_request_data *req, const char *method,
- struct blob_attr *msg)
-{
- struct blob_attr *tb[__DI_MAX];
- struct interface *iface;
-
- blobmsg_parse(dynamic_policy, __DI_MAX, tb, blob_data(msg), blob_len(msg));
-
- if (!tb[DI_NAME])
- return UBUS_STATUS_INVALID_ARGUMENT;
-
- const char *name = blobmsg_get_string(tb[DI_NAME]);
- iface = vlist_find(&interfaces, name, iface, node);
-
- if (!iface)
- return UBUS_STATUS_NOT_FOUND;
- else if (!iface->dynamic)
- return UBUS_STATUS_INVALID_COMMAND;
-
- vlist_delete(&interfaces, &iface->node);
- return UBUS_STATUS_OK;
-}
-
static struct ubus_method main_object_methods[] = {
{ .name = "restart", .handler = netifd_handle_restart },
{ .name = "reload", .handler = netifd_handle_reload },
UBUS_METHOD("add_host_route", netifd_add_host_route, route_policy),
{ .name = "get_proto_handlers", .handler = netifd_get_proto_handlers },
UBUS_METHOD("add_dynamic", netifd_add_dynamic, dynamic_policy),
- UBUS_METHOD("del_dynamic", netifd_del_dynamic, dynamic_policy),
};
static struct ubus_object_type main_object_type =