From bbf1046532eaaab4e1da292253782bf4338d7afd Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 17 Jan 2020 16:21:37 +0000 Subject: [PATCH] inet6: Temporary addresses only work if prefix + ifidlen == 128 Cater for various prefix lengths when using temporay addresses. --- src/if-linux.c | 3 ++- src/ipv6.h | 3 +++ src/ipv6nd.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) 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) -- 2.47.3