iface->link_up_event = false;
iface->state = IFS_DOWN;
- if (state == IFS_UP)
+ switch (state) {
+ case IFS_UP:
interface_event(iface, IFEV_DOWN);
- else
+ break;
+ case IFS_SETUP:
interface_event(iface, IFEV_UP_FAILED);
+ break;
+ default:
+ break;
+ }
interface_ip_set_enabled(&iface->config_ip, false);
interface_ip_set_enabled(&iface->proto_ip, false);
interface_ip_flush(&iface->proto_ip);
interface_main_dev_cb(struct device_user *dep, enum device_event ev)
{
struct interface *iface;
- bool new_state = false;
iface = container_of(dep, struct interface, main_dev);
switch (ev) {
case DEV_EVENT_ADD:
- new_state = true;
+ interface_set_available(iface, true);
+ break;
case DEV_EVENT_REMOVE:
- interface_set_available(iface, new_state);
- if (!new_state && dep->dev && dep->dev->external)
+ interface_set_available(iface, false);
+ if (dep->dev && dep->dev->external)
interface_set_main_dev(iface, NULL);
break;
case DEV_EVENT_UP:
- new_state = true;
+ interface_set_enabled(iface, true);
+ break;
case DEV_EVENT_DOWN:
- interface_set_enabled(iface, new_state);
+ interface_set_enabled(iface, false);
break;
case DEV_EVENT_LINK_UP:
- new_state = true;
+ interface_set_link_state(iface, true);
+ break;
case DEV_EVENT_LINK_DOWN:
- interface_set_link_state(iface, new_state);
+ interface_set_link_state(iface, false);
break;
case DEV_EVENT_TOPO_CHANGE:
interface_proto_event(iface->proto, PROTO_CMD_RENEW, false);
interface_do_free(iface);
return;
}
- if (iface->autostart && iface->available)
+ if (iface->autostart)
interface_set_up(iface);
else if (iface->dynamic)
set_config_state(iface, IFC_REMOVE);
struct interface *iface;
vlist_for_each_element(&interfaces, iface, node) {
- if (iface->available && iface->autostart)
+ if (iface->autostart)
interface_set_up(iface);
}
}
set_config_state(if_old, IFC_REMOVE);
} else if (node_new) {
D(INTERFACE, "Create interface '%s'\n", if_new->name);
+ interface_event(if_new, IFEV_CREATE);
proto_init_interface(if_new, if_new->config);
interface_claim_device(if_new);
netifd_ubus_add_interface(if_new);