IFACE_ATTR_IFNAME,
IFACE_ATTR_PROTO,
IFACE_ATTR_AUTO,
+ IFACE_ATTR_DEFAULTROUTE,
IFACE_ATTR_MAX
};
[IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL },
+ [IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL },
};
const struct config_param_list interface_attr_list = {
static void
mark_interface_down(struct interface *iface)
{
+ if (iface->state == IFS_UP)
+ interface_event(iface, IFEV_DOWN);
interface_flush_state(iface);
iface->state = IFS_DOWN;
}
iface->state == IFS_TEARDOWN)
return;
+ if (iface->state == IFS_UP)
+ interface_event(iface, IFEV_DOWN);
iface->state = IFS_TEARDOWN;
- interface_event(iface, IFEV_DOWN);
interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
if (force)
interface_flush_state(iface);
{
struct device *dev;
- if (iface->ifname && iface->proto_handler &&
+ if (iface->ifname &&
!(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
dev = device_get(iface->ifname, true);
if (dev)
return;
netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name);
+ if (iface->state == IFS_UP)
+ interface_event(iface, IFEV_DOWN);
iface->state = IFS_SETUP;
- interface_event(iface, IFEV_DOWN);
break;
}
}
proto_attach_interface(iface, proto_name);
- if ((cur = tb[IFACE_ATTR_AUTO]))
- iface->autostart = blobmsg_get_bool(cur);
- else
- iface->autostart = true;
+ iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
+ iface->proto_ip.no_defaultroute =
+ !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
+
iface->config_autostart = iface->autostart;
}
goto reload;
}
+ if (if_old->proto_ip.no_defaultroute != if_new->proto_ip.no_defaultroute) {
+ if_old->proto_ip.no_defaultroute = if_new->proto_ip.no_defaultroute;
+ interface_ip_set_enabled(&if_old->proto_ip, if_old->proto_ip.enabled);
+ }
+
goto out;
reload: