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: v9.0.0~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b81f23921398ca3e736fda52c9fffea92e6cdd60;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 4765a7f7..ec7b81e1 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -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 diff --git a/src/ipv6.h b/src/ipv6.h index e976bb78..3158de34 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 10b20ed4..c652e9ae 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -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)