summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-12-16 16:56:17 +0000
committerRoy Marples <roy@marples.name>2019-12-16 16:56:17 +0000
commitc3cc4caf362f7b4d00a0795ce492888528085656 (patch)
treef4010c153eac7feff6bed2bfc0a220e52db5717d
parentbd92b3cfca4d9035d3c8d8e7fa17224ec4fb31ce (diff)
downloaddhcpcd-c3cc4caf362f7b4d00a0795ce492888528085656.tar.xz
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.
-rw-r--r--src/dhcp6.c5
-rw-r--r--src/ipv6.c17
2 files changed, 16 insertions, 6 deletions
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