From: Roy Marples Date: Mon, 16 Dec 2019 16:56:17 +0000 (+0000) Subject: DHCP6: Fix deprecating a delegated prefix X-Git-Tag: v8.1.3~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd70db72f05447d17188c8885a7f6743888c04b0;p=thirdparty%2Fdhcpcd.git DHCP6: Fix deprecating a delegated prefix Be sure to remove the address using the right TAILQ member. While here, simplify the initialisation of pd_pfxs. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 6bda4845..fadf7144 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -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); diff --git a/src/ipv6.c b/src/ipv6.c index 8a77a401..a83a1818 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -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