apply basic device settings for hotplug devices, e.g. mtu and txqueuelen
[project/netifd.git] / ubus.c
diff --git a/ubus.c b/ubus.c
index 2f0019c..0d23b77 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -496,7 +496,8 @@ netifd_handle_status(struct ubus_context *ctx, struct ubus_object *obj,
                blobmsg_add_string(&b, "proto", iface->proto_handler->name);
 
        dev = iface->main_dev.dev;
-       if (dev && !(iface->proto_handler->flags & PROTO_FLAG_NODEV))
+       if (dev && !dev->hidden &&
+           !(iface->proto_handler->flags & PROTO_FLAG_NODEV))
                blobmsg_add_string(&b, "device", dev->ifname);
 
        if (iface->state == IFS_UP) {
@@ -561,10 +562,16 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj,
        if (add && !dev)
                return UBUS_STATUS_NOT_FOUND;
 
-       if (add)
-               return interface_add_link(iface, dev);
-       else
-               return interface_remove_link(iface, dev);
+       if (add) {
+               device_set_present(dev, true);
+               if (iface->device_config)
+                       device_set_config(dev, &simple_device_type, iface->config);
+
+               system_if_apply_settings(dev, &dev->settings);
+               ret = interface_add_link(iface, dev);
+       } else {
+               ret = interface_remove_link(iface, dev);
+       }
 
        device_unlock();