]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
inet6: Temporary addresses only work if prefix + ifidlen == 128
authorRoy Marples <roy@marples.name>
Fri, 17 Jan 2020 16:21:37 +0000 (16:21 +0000)
committerRoy Marples <roy@marples.name>
Fri, 17 Jan 2020 16:21:37 +0000 (16:21 +0000)
Cater for various prefix lengths when using temporay addresses.

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

index 4765a7f74679fb34d66fe99db2cc83eeb8a0aff5..ec7b81e1c9180fe270adb878e1c5e5f2bf80e12f 100644 (file)
@@ -1802,7 +1802,8 @@ if_address6(unsigned char cmd, const struct ipv6_addr *ia)
 #endif
                }
 #elif IFA_F_MANAGETEMPADDR
-               if (ia->flags & IPV6_AF_AUTOCONF)
+               if (ia->flags & IPV6_AF_AUTOCONF &&
+                   ipv6_ifidlen(ia->iface) + ia->prefix_len == 128)
                        flags |= IFA_F_MANAGETEMPADDR;
 #endif
 #ifdef IFA_F_NOPREFIXROUTE
index e976bb781397620771075c054a0a0aa8c25bf52a..3158de34a0eea60f4ff4eaf457a61088f7c623aa 100644 (file)
@@ -67,6 +67,9 @@
 #define IDGEN_RETRIES  3
 #define IDGEN_DELAY    1 /* second */
 
+/* Interface identifier length. Prefix + this == 128 for autoconf */
+#define ipv6_ifidlen(ifp)      64
+
 #ifndef IN6_ARE_MASKED_ADDR_EQUAL
 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)     (       \
        (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
index 10b20ed415c546ba2d31cf98458a1702f7a34532..c652e9ae4cc116a240ea8d20c761760256719688 100644 (file)
@@ -1280,7 +1280,8 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
 #ifdef IPV6_MANAGETEMPADDR
                        /* RFC4941 Section 3.3.3 */
                        if (ap->flags & IPV6_AF_AUTOCONF &&
-                           ip6_use_tempaddr(ap->iface->name))
+                           ip6_use_tempaddr(ap->iface->name) &&
+                           ipv6_ifidlen(ap->iface) + ap->prefix_len == 128)
                        {
                                if (!new_ap) {
                                        if (ipv6_settemptime(ap, 1) == NULL)