struct blob_attr *cur;
const char *proto_name = NULL;
char *iface_name;
+ bool force_link = false;
iface = calloc_a(sizeof(*iface), &iface_name, strlen(name) + 1);
iface->name = strcpy(iface_name, name);
proto_name = blobmsg_data(cur);
proto_attach_interface(iface, proto_name);
+ if (iface->proto_handler->flags & PROTO_FLAG_FORCE_LINK_DEFAULT)
+ force_link = true;
iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
- iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], false);
+ iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], force_link);
iface->proto_ip.no_defaultroute =
!blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
iface->proto_ip.no_dns =
return 0;
}
-int
-interface_add_link(struct interface *iface, struct device *dev)
+static int
+interface_add_link(struct interface *iface, struct device *dev, bool link_ext)
{
struct device *mdev = iface->main_dev.dev;
return UBUS_STATUS_NOT_SUPPORTED;
}
- device_add_user(&iface->ext_dev, dev);
+ if (link_ext)
+ device_add_user(&iface->ext_dev, dev);
+
interface_set_main_dev(iface, dev);
iface->main_dev.hotplug = true;
return 0;
}
int
-interface_handle_link(struct interface *iface, const char *name, bool add)
+interface_handle_link(struct interface *iface, const char *name, bool add, bool link_ext)
{
struct device *dev;
int ret;
device_lock();
- dev = device_get(name, add ? 2 : 0);
+ dev = device_get(name, add ? (link_ext ? 2 : 1) : 0);
if (!dev) {
ret = UBUS_STATUS_NOT_FOUND;
goto out;
device_set_config(dev, &simple_device_type, iface->config);
system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
- ret = interface_add_link(iface, dev);
+ ret = interface_add_link(iface, dev, link_ext);
} else {
ret = interface_remove_link(iface, dev);
}