};
static void
-set_config_state(struct interface *iface, enum interface_config_state s);
+interface_set_main_dev(struct interface *iface, struct device *dev);
static void
interface_event(struct interface *iface, enum interface_event ev);
iface->state = IFS_DOWN;
switch (state) {
case IFS_UP:
+ case IFS_TEARDOWN:
interface_event(iface, IFEV_DOWN);
break;
case IFS_SETUP:
system_flush_routes();
}
+static inline void
+__set_config_state(struct interface *iface, enum interface_config_state s)
+{
+ iface->config_state = s;
+}
+
static void
__interface_set_down(struct interface *iface, bool force)
{
case IFS_UP:
case IFS_SETUP:
iface->state = IFS_TEARDOWN;
+ if (iface->dynamic)
+ __set_config_state(iface, IFC_REMOVE);
+
if (state == IFS_UP)
interface_event(iface, IFEV_DOWN);
case IFS_UP:
case IFS_SETUP:
if (!iface->enabled || !link_state) {
+ iface->state = IFS_TEARDOWN;
+ if (iface->dynamic)
+ __set_config_state(iface, IFC_REMOVE);
+
interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
- mark_interface_down(iface);
}
break;
case IFS_DOWN:
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
continue;
- if (!blobmsg_check_attr(cur, NULL))
+ if (!blobmsg_check_attr(cur, false))
continue;
struct interface_assignment_class *c = malloc(sizeof(*c) + blobmsg_data_len(cur));
struct interface_assignment_class *c;
list_for_each_entry(c, &new->assignment_classes, head) {
- // Compare list entries one-by-one to see if there was a change
- if (list_empty(&old->assignment_classes)) // The new list is longer
+ /* Compare list entries one-by-one to see if there was a change */
+ if (list_empty(&old->assignment_classes)) /* The new list is longer */
changed = true;
if (changed)
struct interface_assignment_class *c_old = list_first_entry(&old->assignment_classes,
struct interface_assignment_class, head);
- if (strcmp(c_old->name, c->name)) // An entry didn't match
+ if (strcmp(c_old->name, c->name)) /* An entry didn't match */
break;
list_del(&c_old->head);
free(c_old);
}
- // The old list was longer than the new one or the last entry didn't match
+ /* The old list was longer than the new one or the last entry didn't match */
if (!list_empty(&old->assignment_classes)) {
interface_clear_assignment_classes(old);
changed = true;
}
if (iface->autostart)
interface_set_up(iface);
- else if (iface->dynamic)
- set_config_state(iface, IFC_REMOVE);
}
static void
{
struct blob_attr *tb[IFACE_ATTR_MAX];
struct blob_attr *cur;
- char *name = iface->dynamic ? strdup(iface->name) : NULL;
+ char *name = NULL;
blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
blob_data(config), blob_len(config));
iface->ifname = blobmsg_data(cur);
}
+ if (iface->dynamic) {
+ name = strdup(iface->name);
+
+ if (!name)
+ return false;
+ }
+
iface->config = config;
vlist_add(&interfaces, &iface->node, iface->name);
iface = vlist_find(&interfaces, name, iface, node);
free(name);
- if (!iface)
- return false;
-
/* Don't delete dynamic interface on reload */
- iface->node.version = -1;
+ if (iface)
+ iface->node.version = -1;
}
return true;
}
}
-void
+static void
interface_set_main_dev(struct interface *iface, struct device *dev)
{
bool claimed = iface->l3_dev.claimed;
interface_set_l3_dev(iface, dev);
}
-int
+static int
interface_remove_link(struct interface *iface, struct device *dev)
{
struct device *mdev = iface->main_dev.dev;
static void
set_config_state(struct interface *iface, enum interface_config_state s)
{
- iface->config_state = s;
+ __set_config_state(iface, s);
if (iface->state == IFS_DOWN)
interface_handle_config_change(iface);
else
interface_change_config(struct interface *if_old, struct interface *if_new)
{
struct blob_attr *old_config = if_old->config;
- bool reload = false, reload_ip = false;
+ bool reload = false, reload_ip = false, update_prefix_delegation = false;
#define FIELD_CHANGED_STR(field) \
((!!if_old->field != !!if_new->field) || \
if_old->force_link = if_new->force_link;
if_old->dns_metric = if_new->dns_metric;
+ if (if_old->proto_ip.no_delegation != if_new->proto_ip.no_delegation) {
+ if_old->proto_ip.no_delegation = if_new->proto_ip.no_delegation;
+ update_prefix_delegation = true;
+ }
+
if_old->proto_ip.no_dns = if_new->proto_ip.no_dns;
interface_replace_dns(&if_old->config_ip, &if_new->config_ip);
interface_ip_set_enabled(&if_old->config_ip, config_ip_enabled);
}
+ if (update_prefix_delegation)
+ interface_update_prefix_delegation(&if_old->proto_ip);
+
interface_write_resolv_conf();
if (if_old->main_dev.dev)
interface_check_state(if_old);