dhcpv6-ia: cleanup prefix delegation routes
authorHans Dedecker <dedeckeh@gmail.com>
Tue, 31 Dec 2019 15:30:34 +0000 (16:30 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 31 Dec 2019 15:34:14 +0000 (16:34 +0100)
Remove prefix delegation routes as well in free_dhcpv6_assignment when
cleaning up the assignment resources

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/dhcpv6-ia.c

index e48123f2c4b3a6999147b16ecc7ff22eb269b1bb..3838d54359b75bcf3011357cbc9766fd910ec8db 100644 (file)
@@ -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;