From 2f7ef7dc6cb542d5811f64fa7af97fb8619c9429 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Sun, 11 Nov 2018 21:15:56 +0100 Subject: interface: rework code to get rid of interface_set_dynamic Integrate dynamic interface creation code into interface_alloc and __interface_add so we can get rid of interface_set_dynamic Signed-off-by: Hans Dedecker --- ubus.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'ubus.c') diff --git a/ubus.c b/ubus.c index 9c5b8b1..f5e4997 100644 --- a/ubus.c +++ b/ubus.c @@ -137,29 +137,22 @@ netifd_add_dynamic(struct ubus_context *ctx, struct ubus_object *obj, const char *name = blobmsg_get_string(tb[DI_NAME]); - iface = interface_alloc(name, msg); + iface = interface_alloc(name, msg, true); if (!iface) return UBUS_STATUS_UNKNOWN_ERROR; config = blob_memdup(msg); if (!config) - goto error; - - interface_add(iface, config); - - // need to look up the interface name again, in case of config update - // the pointer will have changed - iface = vlist_find(&interfaces, name, iface, node); - if (!iface) - return UBUS_STATUS_UNKNOWN_ERROR; + goto error_free; - // Set interface as dynamic - interface_set_dynamic(iface); + if (!interface_add(iface, config)) + goto error; return UBUS_STATUS_OK; -error: +error_free: free(iface); +error: return UBUS_STATUS_UNKNOWN_ERROR; } -- cgit v1.2.1