]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Solaris: Avoid re-adding IPv6 addresses to preserve the prefix route
authorRoy Marples <roy@marples.name>
Sun, 28 Jul 2019 16:10:36 +0000 (16:10 +0000)
committerRoy Marples <roy@marples.name>
Sun, 28 Jul 2019 16:10:36 +0000 (16:10 +0000)
Really, kernels should just stop doing this, it's pointless.

src/ipv6.c

index f9eecf532a15f91e5bb9d3665b01fc67618aff0c..31a0cae085661fd9454e8f2d53bb6f1698834cf5 100644 (file)
@@ -634,6 +634,15 @@ ipv6_addaddr1(struct ipv6_addr *ia, const struct timespec *now)
 #ifdef __sun
        struct ipv6_state *state;
        struct ipv6_addr *ia2;
+
+       /* If we re-add then address on Solaris then the prefix
+        * route will be scrubbed and re-added. Something might
+        * be using it, so let's avoid it. */
+       if (ia->flags & IPV6_AF_DADCOMPLETED) {
+               logdebugx("%s: IP address %s already exists",
+                   ia->iface->name, ia->saddr);
+               return 0;
+       }
 #endif
 
        /* Remember the interface of the address. */
@@ -1187,6 +1196,8 @@ out:
        /* Done with the ia now, so free it. */
        if (cmd == RTM_DELADDR)
                ipv6_freeaddr(ia);
+       else if (!(ia->addr_flags & IN6_IFF_NOTUSEABLE))
+               ia->flags |= IPV6_AF_DADCOMPLETED;
 }
 
 int
@@ -1465,8 +1476,10 @@ ipv6_newaddr(struct interface *ifp, const struct in6_addr *addr,
                goto err;
 
        ia->iface = ifp;
-       ia->flags = IPV6_AF_NEW | flags;
        ia->addr_flags = addr_flags;
+       ia->flags = IPV6_AF_NEW | flags;
+       if (!(ia->addr_flags & IN6_IFF_NOTUSEABLE))
+               ia->flags |= IPV6_AF_DADCOMPLETED;
        ia->prefix_len = prefix_len;
        ia->dhcp6_fd = -1;