From: Roy Marples Date: Tue, 7 Apr 2015 21:16:31 +0000 (+0000) Subject: Only take into account useable IPv6 public addresses. X-Git-Tag: v6.8.2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a258c8ddf7257976be62c20c6e3749581c037ea1;p=thirdparty%2Fdhcpcd.git Only take into account useable IPv6 public addresses. --- diff --git a/dhcp6.c b/dhcp6.c index 7b94caf7..15cdcfa4 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -496,8 +496,7 @@ dhcp6_has_public_addr(const struct interface *ifp) if (state == NULL) return 0; TAILQ_FOREACH(ia, &state->addrs, next) { - if (ia->prefix_pltime && - (ia->addr.s6_addr[0] & 0xfe) != 0xc) + if (ipv6_publicaddr(ia)) return 1; } return 0; diff --git a/ipv6.c b/ipv6.c index 7ab15d6e..66c2fca1 100644 --- a/ipv6.c +++ b/ipv6.c @@ -745,6 +745,14 @@ ipv6_addaddr(struct ipv6_addr *ap, const struct timespec *now) return 0; } +int +ipv6_publicaddr(const struct ipv6_addr *ia) +{ + return (ia->prefix_pltime && + (ia->addr.s6_addr[0] & 0xfe) != 0xc && + !(ia->addr_flags & IN6_IFF_NOTUSEABLE)); +} + struct ipv6_addr * ipv6_findaddr(struct dhcpcd_ctx *ctx, const struct in6_addr *addr, short flags) { diff --git a/ipv6.h b/ipv6.h index db2d886d..5e7f2cdf 100644 --- a/ipv6.h +++ b/ipv6.h @@ -246,6 +246,7 @@ void ipv6_handleifa(struct dhcpcd_ctx *ctx, int, struct if_head *, const char *, const struct in6_addr *, uint8_t, int); int ipv6_handleifa_addrs(int, struct ipv6_addrhead *, const struct in6_addr *, int); +int ipv6_publicaddr(const struct ipv6_addr *); const struct ipv6_addr *ipv6_iffindaddr(const struct interface *, const struct in6_addr *); struct ipv6_addr *ipv6_findaddr(struct dhcpcd_ctx *, diff --git a/ipv6nd.c b/ipv6nd.c index 5f33d9fc..4df88650 100644 --- a/ipv6nd.c +++ b/ipv6nd.c @@ -679,9 +679,8 @@ ipv6nd_ra_has_public_addr(const struct ra *rap) const struct ipv6_addr *ia; TAILQ_FOREACH(ia, &rap->addrs, next) { - if (ia->prefix_pltime && - (ia->addr.s6_addr[0] & 0xfe) != 0xfc && - ia->flags & IPV6_AF_AUTOCONF) + if (ia->flags & IPV6_AF_AUTOCONF && + ipv6_publicaddr(ia)) return 1; } return 0;