From b413d8a13ad8d8bdc2e5bc700e9bae9b31232779 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Tue, 31 Dec 2019 16:30:34 +0100 Subject: [PATCH] dhcpv6-ia: cleanup prefix delegation routes Remove prefix delegation routes as well in free_dhcpv6_assignment when cleaning up the assignment resources Signed-off-by: Hans Dedecker --- src/dhcpv6-ia.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index e48123f..3838d54 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -40,6 +40,7 @@ (addrs)[(i)].prefix > 64) static void dhcpv6_netevent_cb(unsigned long event, struct netevent_handler_info *info); +static void apply_lease(struct dhcp_assignment *a, bool add); static void set_border_assignment_size(struct interface *iface, struct dhcp_assignment *b); static void handle_addrlist_change(struct netevent_handler_info *info); static void start_reconf(struct dhcp_assignment *a); @@ -206,6 +207,9 @@ static void dhcpv6_ia_free_assignment(struct dhcp_assignment *a) close(a->managed_sock.fd.fd); } + if (a->flags & OAF_BOUND && a->length < 128) + apply_lease(a, false); + if (a->reconf_cnt) stop_reconf(a); @@ -1370,13 +1374,13 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac apply_lease(a, true); } } else if (hdr->msg_type == DHCPV6_MSG_RELEASE) { - if (!(a->flags & OAF_STATIC)) - a->valid_until = now - 1; - - if (a->flags & OAF_BOUND) { + if (a->flags & OAF_STATIC) { apply_lease(a, false); a->flags &= ~OAF_BOUND; } + else + a->valid_until = now - 1; + } else if (hdr->msg_type == DHCPV6_MSG_DECLINE && a->length == 128) { a->flags &= ~OAF_BOUND; -- 2.25.1