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)
committerMichael Biebl <biebl@debian.org>
Thu, 29 Aug 2019 14:18:18 +0000 (15:18 +0100)
(cherry picked from commit 54a1a535bd60f13964bbddd8f381601e33e8e56f)

Gbp-Pq: Name network-ignore-requested-ipv6-addresses-when-ipv6-is-disa.patch

src/network/networkd-address.c
src/network/networkd-link.c
src/network/networkd-ndisc.c

index 42d61cc0e50569eb5afcf93a18b9137ee914584f..bf8f6ab554930934ce5df0d16ff7981eab8d5e0d 100644 (file)
@@ -566,6 +566,11 @@ int address_configure(
         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)
@@ -665,7 +670,7 @@ int address_configure(
                 return log_link_error_errno(link, r, "Could not add address: %m");
         }
 
-        return 0;
+        return 1;
 }
 
 int config_parse_broadcast(
index 3e334c8d29cccce8cbe558e47292acaeec8e22c1..d3752b2d3e1b29634c72ac28804b29c4163e0325 100644 (file)
@@ -1249,8 +1249,8 @@ static int link_request_set_addresses(Link *link) {
                         link_enter_failed(link);
                         return r;
                 }
-
-                link->address_messages++;
+                if (r > 0)
+                        link->address_messages++;
         }
 
         LIST_FOREACH(labels, label, link->network->address_labels) {
index eb470a4d481509b3ccfc2aea3f535c067717bd00..05911bda4380fe7da4a1d902a373d75c34d9e656 100644 (file)
@@ -205,8 +205,8 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
                 link_enter_failed(link);
                 return r;
         }
-
-        link->ndisc_messages++;
+        if (r > 0)
+                link->ndisc_messages++;
 
         return 0;
 }