summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-20 14:59:27 +0200
committerTom Gundersen <teg@jklm.no>2015-10-20 14:59:27 +0200
commit14a081a0ff1db125ade7aea3540e5544fd3e57a9 (patch)
tree62786b58f26036a946779840bcd0fce39a3145eb /src/network
parentc91960c5a04a3515c43f50a358588f056b8575a6 (diff)
parent44de7fb14f0fb5b8fe0f829f128c2c3e64114c0c (diff)
Merge pull request #1538 from ssahani/ipv62
networkd: add support to configure IPv6 DAD
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c35
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h1
4 files changed, 38 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index f6cc1f8ee2..9d97089576 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1850,6 +1850,37 @@ static int link_set_ipv6_accept_ra(Link *link) {
return 0;
}
+static int link_set_ipv6_dad_transmits(Link *link) {
+ char buf[DECIMAL_STR_MAX(unsigned) + 1];
+ const char *p = NULL;
+ int r;
+
+ /* Make this a NOP if IPv6 is not available */
+ if (!socket_ipv6_is_supported())
+ return 0;
+
+ if (link->flags & IFF_LOOPBACK)
+ return 0;
+
+ if (link->network->ipv6_dad_transmits < 0)
+ return 0;
+
+ p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/dad_transmits");
+
+ xsprintf(buf, "%u", link->network->ipv6_dad_transmits);
+
+ r = write_string_file(p, buf, 0);
+ if (r < 0) {
+ /* If the right value is set anyway, don't complain */
+ if (verify_one_line_file(p, buf) > 0)
+ return 0;
+
+ log_link_warning_errno(link, r, "Cannot set IPv6 dad transmits for interface: %m");
+ }
+
+ return 0;
+}
+
static int link_configure(Link *link) {
int r;
@@ -1877,6 +1908,10 @@ static int link_configure(Link *link) {
if (r < 0)
return r;
+ r = link_set_ipv6_dad_transmits(link);
+ if (r < 0)
+ return r;
+
if (link_ipv4ll_enabled(link)) {
r = ipv4ll_configure(link);
if (r < 0)
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index b6f70e191d..cc01dc24c9 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -51,6 +51,7 @@ Network.IPForward, config_parse_address_family_boolean_with
Network.IPMasquerade, config_parse_bool, 0, offsetof(Network, ip_masquerade)
Network.IPv6PrivacyExtensions, config_parse_ipv6_privacy_extensions, 0, offsetof(Network, ipv6_privacy_extensions)
Network.IPv6AcceptRouterAdvertisements, config_parse_tristate, 0, offsetof(Network, ipv6_accept_ra)
+Network.IPv6DuplicateAddressDetection, config_parse_int, 0, offsetof(Network, ipv6_dad_transmits)
Network.BindCarrier, config_parse_strv, 0, offsetof(Network, bind_carrier)
Address.Address, config_parse_address, 0, 0
Address.Peer, config_parse_address, 0, 0
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index bdee7f1923..5b8ca305bc 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -121,6 +121,7 @@ static int network_load_one(Manager *manager, const char *filename) {
network->ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_NO;
network->ipv6_accept_ra = -1;
+ network->ipv6_dad_transmits = -1;
r = config_parse(NULL, filename, file,
"Match\0"
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 2a43b6b347..c2872908b5 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -121,6 +121,7 @@ struct Network {
bool ip_masquerade;
int ipv6_accept_ra;
+ int ipv6_dad_transmits;
union in_addr_union ipv6_token;
IPv6PrivacyExtensions ipv6_privacy_extensions;