]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Only take into account useable IPv6 public addresses.
authorRoy Marples <roy@marples.name>
Tue, 7 Apr 2015 21:16:31 +0000 (21:16 +0000)
committerRoy Marples <roy@marples.name>
Tue, 7 Apr 2015 21:16:31 +0000 (21:16 +0000)
dhcp6.c
ipv6.c
ipv6.h
ipv6nd.c

diff --git a/dhcp6.c b/dhcp6.c
index 7b94caf7cf2851771e0add6076b5d06c9986c543..15cdcfa4cefabb1a23b540aa3131c25cfb870c44 100644 (file)
--- 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 7ab15d6eafdbf5ffe91ef7745254393b87515059..66c2fca17fcf3d93cbb2c816ffe0d833baf22459 100644 (file)
--- 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 db2d886dfb31c179e9225e6f9f422c0e4860a27f..5e7f2cdfb901e818242332db7aaee78f22d9dbfb 100644 (file)
--- 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 *,
index 5f33d9fc39d5afe79d40dbf89bd023823f8dd5d2..4df88650745c21b7fce1f055a434fa9aefea542d 100644 (file)
--- 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;