interface-ip: fix delegate config update on reload (FS#2087)
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 13 Mar 2019 13:56:21 +0000 (14:56 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 13 Mar 2019 20:07:53 +0000 (21:07 +0100)
Update the no_delegation parameter on a config reload; in case prefixes
are present update the prefix assignments as well according to the
no_delegation status

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface-ip.c
interface-ip.h
interface.c

index 1a6c28d45b62d66657556423cd934f8acd8d9f92..83f1dfa69c28d0d4f9775d26f9c18a8bb305d7e9 100644 (file)
@@ -1053,6 +1053,20 @@ void interface_refresh_assignments(bool hint)
        refresh = hint;
 }
 
+void interface_update_prefix_delegation(struct interface_ip_settings *ip)
+{
+       struct device_prefix *prefix;
+
+       vlist_for_each_element(&ip->prefix, prefix, node) {
+               interface_update_prefix_assignments(prefix, !ip->no_delegation);
+
+               if (ip->no_delegation) {
+                       if (prefix->head.next)
+                               list_del(&prefix->head);
+               } else
+                       list_add(&prefix->head, &prefixes);
+       }
+}
 
 static void
 interface_update_prefix(struct vlist_tree *tree,
index ec6d7fbd0f9d559f3a414af236d7295fedd4de3d..21c6e9b24981d52ab0143401554f0f8e6e31025a 100644 (file)
@@ -172,5 +172,6 @@ struct device_prefix* interface_ip_add_device_prefix(struct interface *iface,
                struct in6_addr *excl_addr, uint8_t excl_length, const char *pclass);
 void interface_ip_set_ula_prefix(const char *prefix);
 void interface_refresh_assignments(bool hint);
+void interface_update_prefix_delegation(struct interface_ip_settings *ip);
 
 #endif
index b21d2345bfc9577884e76aaf006dcdb39e330d5b..b8c4ae23a2f1cadbc48541f929763860f7ff3d43 100644 (file)
@@ -1197,7 +1197,7 @@ static void
 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) ||                \
@@ -1247,6 +1247,11 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
        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);
 
@@ -1276,6 +1281,9 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
                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);