iface->state = IFS_DOWN;
switch (state) {
case IFS_UP:
+ case IFS_TEARDOWN:
interface_event(iface, IFEV_DOWN);
break;
case IFS_SETUP:
case IFS_UP:
case IFS_SETUP:
if (!iface->enabled || !link_state) {
- interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
+ iface->state = IFS_TEARDOWN;
if (iface->dynamic)
__set_config_state(iface, IFC_REMOVE);
- mark_interface_down(iface);
+ interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
}
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));
}
iface->assignment_hint = -1;
- if ((cur = tb[IFACE_ATTR_IP6HINT]))
- iface->assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) &
- ~((1 << (64 - iface->assignment_length)) - 1);
+ if ((cur = tb[IFACE_ATTR_IP6HINT])) {
+ int32_t assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16);
+
+ iface->assignment_hint = assignment_hint & ~((1 << (64 - iface->assignment_length)) - 1);
+
+ if (iface->assignment_hint != assignment_hint)
+ netifd_log_message(L_WARNING, "Using truncated assignment hint %d (0x%x) for interface '%s'\n",
+ iface->assignment_hint, iface->assignment_hint, iface->name);
+ }
if ((cur = tb[IFACE_ATTR_IP6CLASS]))
interface_add_assignment_classes(iface, cur);
{
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;
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);