X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=ubus.c;h=d6d41889ef2a501715d506aea19281f7c49d44b7;hb=d46bc6515c3362538e298b8b038ae04adcb7db65;hp=422caca15787b9cb130574220a6a9355b8dcf6a7;hpb=01a947355e7e063ef89ce4f037d0584b686999f0;p=project%2Fnetifd.git diff --git a/ubus.c b/ubus.c index 422caca..d6d4188 100644 --- a/ubus.c +++ b/ubus.c @@ -25,7 +25,6 @@ static struct ubus_context *ctx = NULL; static struct blob_buf b; -static struct netifd_fd ubus_fd; static const char *ubus_path; /* global object */ @@ -258,8 +257,7 @@ static void netifd_ubus_add_fd(void) { ubus_add_uloop(ctx); - ubus_fd.fd = ctx->sock.fd; - netifd_fd_add(&ubus_fd); + system_fd_set_cloexec(ctx->sock.fd); } static void @@ -283,7 +281,6 @@ netifd_ubus_reconnect_timer(struct uloop_timeout *timeout) static void netifd_ubus_connection_lost(struct ubus_context *ctx) { - netifd_fd_delete(&ubus_fd); netifd_ubus_reconnect_timer(NULL); } @@ -445,8 +442,6 @@ interface_ip_dump_route_list(struct interface_ip_settings *ip, bool enabled) if (route->flags & DEVROUTE_METRIC) blobmsg_add_u32(&b, "metric", route->metric); - blobmsg_add_u8(&b, "enabled", route->enabled); - blobmsg_close_table(&b, r); } } @@ -597,8 +592,10 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj, device_lock(); dev = device_get(blobmsg_data(tb[DEV_NAME]), add ? 2 : 0); - if (add && !dev) - return UBUS_STATUS_NOT_FOUND; + if (add && !dev) { + ret = UBUS_STATUS_NOT_FOUND; + goto out; + } if (add) { device_set_present(dev, true); @@ -611,6 +608,7 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj, ret = interface_remove_link(iface, dev); } +out: device_unlock(); return ret; @@ -729,8 +727,7 @@ netifd_ubus_add_interface(struct interface *iface) struct ubus_object *obj = &iface->ubus; char *name = NULL; - asprintf(&name, "%s.interface.%s", main_object.name, iface->name); - if (!name) + if (asprintf(&name, "%s.interface.%s", main_object.name, iface->name) == -1) return; obj->name = name;