]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: ignore requested ipv6 addresses when ipv6 is disabled by sysctl
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Jun 2019 14:20:56 +0000 (23:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Jun 2019 02:02:33 +0000 (11:02 +0900)
src/network/networkd-address.c
src/network/networkd-link.c
src/network/networkd-ndisc.c

index d6c6f5f27159198ad825e621f46a342886d7a23a..7fe99bc4853216b1329db4a9f25ac01d1223d78d 100644 (file)
@@ -566,6 +566,11 @@ int address_configure(
         assert(link->manager->rtnl);
         assert(callback);
 
         assert(link->manager->rtnl);
         assert(callback);
 
+        if (address->family == AF_INET6 && manager_sysctl_ipv6_enabled(link->manager) == 0) {
+                log_link_warning(link, "An IPv6 address is requested, but IPv6 is disabled by sysctl, ignoring.");
+                return 0;
+        }
+
         /* If this is a new address, then refuse adding more than the limit */
         if (address_get(link, address->family, &address->in_addr, address->prefixlen, NULL) <= 0 &&
             set_size(link->addresses) >= ADDRESSES_PER_LINK_MAX)
         /* If this is a new address, then refuse adding more than the limit */
         if (address_get(link, address->family, &address->in_addr, address->prefixlen, NULL) <= 0 &&
             set_size(link->addresses) >= ADDRESSES_PER_LINK_MAX)
@@ -665,7 +670,7 @@ int address_configure(
                 return log_link_error_errno(link, r, "Could not add address: %m");
         }
 
                 return log_link_error_errno(link, r, "Could not add address: %m");
         }
 
-        return 0;
+        return 1;
 }
 
 int config_parse_broadcast(
 }
 
 int config_parse_broadcast(
index 7181cdd0d70dd61e8f05539fb714bcb75bd05c4a..df26199c9ef01e25b83fdc176499cf1994509539 100644 (file)
@@ -1194,8 +1194,8 @@ static int link_request_set_addresses(Link *link) {
                         link_enter_failed(link);
                         return r;
                 }
                         link_enter_failed(link);
                         return r;
                 }
-
-                link->address_messages++;
+                if (r > 0)
+                        link->address_messages++;
         }
 
         LIST_FOREACH(labels, label, link->network->address_labels) {
         }
 
         LIST_FOREACH(labels, label, link->network->address_labels) {
index 3016f3448bddc9644767010f21f0246ae62e71d4..0600edac61b10246441916bc58f7965038951e57 100644 (file)
@@ -209,8 +209,8 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
                 link_enter_failed(link);
                 return r;
         }
                 link_enter_failed(link);
                 return r;
         }
-
-        link->ndisc_messages++;
+        if (r > 0)
+                link->ndisc_messages++;
 
         return 0;
 }
 
         return 0;
 }