iface->state = IFS_DOWN;
}
-static int
-__interface_set_up(struct interface *iface)
-{
- int ret;
-
- if (iface->state != IFS_DOWN)
- return 0;
-
- if (iface->main_dev.dev) {
- ret = device_claim(&iface->main_dev);
- if (ret)
- return ret;
- }
-
- iface->state = IFS_SETUP;
- ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
- if (ret) {
- mark_interface_down(iface);
- return ret;
- }
-
- return 0;
-}
-
void
__interface_set_down(struct interface *iface, bool force)
{
if (dev)
device_add_user(&iface->main_dev, dev);
}
+ if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE)
+ interface_set_available(iface, true);
}
interface_do_reload(struct interface *iface)
{
interface_cleanup(iface);
-
- interface_claim_device(iface);
proto_init_interface(iface, iface->config);
+ interface_claim_device(iface);
}
static void
int
interface_set_up(struct interface *iface)
{
+ int ret;
+
iface->autostart = true;
if (iface->state != IFS_DOWN)
return -1;
}
- return __interface_set_up(iface);
+ if (iface->main_dev.dev) {
+ ret = device_claim(&iface->main_dev);
+ if (ret)
+ return ret;
+ }
+
+ iface->state = IFS_SETUP;
+ ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
+ if (ret) {
+ mark_interface_down(iface);
+ return ret;
+ }
+
+ return 0;
}
int
if_old->ifname = if_new->ifname;
if_old->proto_handler = if_new->proto_handler;
- if (strcmp(old_ifname, if_new->ifname) != 0 ||
- proto != if_new->proto_handler) {
+ if ((!!old_ifname != !!if_new->ifname) ||
+ (old_ifname && strcmp(old_ifname, if_new->ifname) != 0) ||
+ proto != if_new->proto_handler) {
D(INTERFACE, "Reload interface '%s' because of ifname/proto change\n",
if_old->name);
goto reload;
set_config_state(if_old, IFC_REMOVE);
} else if (node_new) {
D(INTERFACE, "Create interface '%s'\n", if_new->name);
- interface_claim_device(if_new);
proto_init_interface(if_new, if_new->config);
+ interface_claim_device(if_new);
netifd_ubus_add_interface(if_new);
}
}