From: Roy Marples Date: Mon, 16 Dec 2019 16:56:17 +0000 (+0000) Subject: DHCP6: Fix deprecating a delegated prefix X-Git-Tag: v7.2.4~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3cc4caf362f7b4d00a0795ce492888528085656;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 204edbe2..b3f16b91 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -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); diff --git a/src/ipv6.c b/src/ipv6.c index de8570f0..d3dfe064 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -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