]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP6: Fix deprecating a delegated prefix
authorRoy Marples <roy@marples.name>
Mon, 16 Dec 2019 16:56:17 +0000 (16:56 +0000)
committerRoy Marples <roy@marples.name>
Mon, 16 Dec 2019 16:58:45 +0000 (16:58 +0000)
Be sure to remove the address using the right TAILQ member.
While here, simplify the initialisation of pd_pfxs.

src/dhcp6.c
src/ipv6.c

index 6bda48457f2a1e8bc5d69811e30d367a96a6c2fa..fadf7144911ac98d759d80197b510c6575183f7e 100644 (file)
@@ -2132,13 +2132,10 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                        a->dadcallback = dhcp6_dadcallback;
                        a->ia_type = D6_OPTION_IA_PD;
                        memcpy(a->iaid, iaid, sizeof(a->iaid));
-                       TAILQ_INIT(&a->pd_pfxs);
                        TAILQ_INSERT_TAIL(&state->addrs, a, next);
                } else {
-                       if (!(a->flags & IPV6_AF_DELEGATEDPFX)) {
+                       if (!(a->flags & IPV6_AF_DELEGATEDPFX))
                                a->flags |= IPV6_AF_NEW | IPV6_AF_DELEGATEDPFX;
-                               TAILQ_INIT(&a->pd_pfxs);
-                       }
                        a->flags &= ~(IPV6_AF_STALE |
                                      IPV6_AF_EXTENDED |
                                      IPV6_AF_REQUEST);
index 8a77a40127d02884dae69f5cceaf4ae1b81a13a6..a83a1818708c342ecc958a997a3380de28af39dd 100644 (file)
@@ -943,8 +943,17 @@ ipv6_addaddrs(struct ipv6_addrhead *addrs)
                        if (ap->flags & IPV6_AF_REQUEST) {
                                ap->flags &= ~IPV6_AF_ADDED;
                        } else {
-                               TAILQ_REMOVE(addrs, ap, next);
-                               ipv6_freeaddr(ap);
+#ifndef SMALL
+                               if (ap->delegating_prefix != NULL &&
+                                   addrs == &ap->delegating_prefix->pd_pfxs) {
+                                       TAILQ_REMOVE(addrs, ap, pd_next);
+                                       ap->delegating_prefix = NULL;
+                               } else
+#endif
+                               {
+                                       TAILQ_REMOVE(addrs, ap, next);
+                                       ipv6_freeaddr(ap);
+                               }
                        }
                } else if (!(ap->flags & IPV6_AF_STALE) &&
                    !IN6_IS_ADDR_UNSPECIFIED(&ap->addr))
@@ -1544,6 +1553,10 @@ ipv6_newaddr(struct interface *ifp, const struct in6_addr *addr,
        ia->prefix_len = prefix_len;
        ia->dhcp6_fd = -1;
 
+#ifndef SMALL
+       TAILQ_INIT(&ia->pd_pfxs);
+#endif
+
 #ifdef IPV6_AF_TEMPORARY
        tempaddr = ia->flags & IPV6_AF_TEMPORARY;
 #else