]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
inet6: Check if we can try a new address on DAD failure.
authorRoy Marples <roy@marples.name>
Fri, 17 Jan 2020 21:09:04 +0000 (21:09 +0000)
committerRoy Marples <roy@marples.name>
Fri, 17 Jan 2020 21:09:04 +0000 (21:09 +0000)
Not all prefixes are autoconfable.

src/if-linux.c
src/ipv6.h
src/ipv6nd.c

index ec7b81e1c9180fe270adb878e1c5e5f2bf80e12f..2c260d327ba8d5260442e412ca1d5e6fa9c8ad8b 100644 (file)
@@ -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
index 95f9022b1f5f83cd8989817bc1618465368decfd..8ffc0896760281dccc057b40eb529b0ffe057070 100644 (file)
@@ -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)     (       \
index e755244cac4f58594af732ccb9dad1b654077159..82c7be8473eba5d1a25b06e67b574847148ce1d1 100644 (file)
@@ -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)