]> 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:56:17 +0000 (16:56 +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 204edbe267ac25a6f44461d550f9f275d8d38037..b3f16b911a6ef856756e66978f76f1634e954607 100644 (file)
@@ -2145,13 +2145,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 de8570f025c2f11ef2e497634835bcad46abdf02..d3dfe064a7335145973fc44f554de3226c2fdf66 100644 (file)
@@ -921,8 +921,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))
@@ -1459,6 +1468,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