From: Roy Marples Date: Fri, 17 Jan 2020 21:09:04 +0000 (+0000) Subject: inet6: Check if we can try a new address on DAD failure. X-Git-Tag: v9.0.0~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=524217dbe3418791f229ad08dce282fcacc624fe;p=thirdparty%2Fdhcpcd.git inet6: Check if we can try a new address on DAD failure. Not all prefixes are autoconfable. --- diff --git a/src/if-linux.c b/src/if-linux.c index ec7b81e1..2c260d32 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1802,8 +1802,7 @@ if_address6(unsigned char cmd, const struct ipv6_addr *ia) #endif } #elif IFA_F_MANAGETEMPADDR - if (ia->flags & IPV6_AF_AUTOCONF && - ipv6_ifidlen(ia->iface) + ia->prefix_len == 128) + if (ia->flags & IPV6_AF_AUTOCONF && IA6_CANAUTOCONF(ia)) flags |= IFA_F_MANAGETEMPADDR; #endif #ifdef IFA_F_NOPREFIXROUTE diff --git a/src/ipv6.h b/src/ipv6.h index 95f9022b..8ffc0896 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -69,6 +69,8 @@ /* Interface identifier length. Prefix + this == 128 for autoconf */ #define ipv6_ifidlen(ifp) 64 +#define IA6_CANAUTOCONF(ia) \ + ((ia)->prefix_len + ipv6_ifidlen((ia)->iface) == 128) #ifndef IN6_ARE_MASKED_ADDR_EQUAL #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ diff --git a/src/ipv6nd.c b/src/ipv6nd.c index e755244c..82c7be84 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -905,7 +905,9 @@ ipv6nd_dadcallback(void *arg) * Because ap->dadcounter is always increamented, * a different address is generated. */ /* XXX Cache DAD counter per prefix/id/ssid? */ - if (ifp->options->options & DHCPCD_SLAACPRIVATE) { + if (ifp->options->options & DHCPCD_SLAACPRIVATE && + IA6_CANAUTOCONF(ia)) + { unsigned int delay; if (ia->dadcounter >= IDGEN_RETRIES) { @@ -1281,7 +1283,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, /* RFC4941 Section 3.3.3 */ if (ap->flags & IPV6_AF_AUTOCONF && ip6_use_tempaddr(ap->iface->name) && - ipv6_ifidlen(ap->iface) + ap->prefix_len == 128) + IA6_CANAUTOCONF(ap)) { if (!new_ap) { if (ipv6_settemptime(ap, 1) == NULL)