From: Roy Marples Date: Fri, 17 Jan 2020 16:21:37 +0000 (+0000) Subject: inet6: Temporary addresses only work if prefix + ifidlen == 128 X-Git-Tag: v8.1.6~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3eff5b959fff26e27deb140f79dd534e96fc3322;p=thirdparty%2Fdhcpcd.git inet6: Temporary addresses only work if prefix + ifidlen == 128 Cater for various prefix lengths when using temporay addresses. --- diff --git a/src/if-linux.c b/src/if-linux.c index 6719e487..aad2142b 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1713,7 +1713,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 diff --git a/src/ipv6.h b/src/ipv6.h index a7dc50a9..047e4bef 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -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 && \ diff --git a/src/ipv6nd.c b/src/ipv6nd.c index 798f23b7..55f8c993 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -1262,7 +1262,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)