dhcpv6-ia: remove assignment equal to 0 checks
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 24 Dec 2020 15:28:43 +0000 (16:28 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 24 Dec 2020 15:31:40 +0000 (16:31 +0100)
Remove the checks as they're leftovers of the old static lease
implementation which created assigments with assigned equal to 0
whihc is not the case anymore in the reworked static lease
implementation

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

index 42268e5b879a97e6732d9d7cbdf556cec0f54c75..d7848de4638bfb9115fa053adba676cfe836464a 100644 (file)
@@ -618,8 +618,7 @@ static bool assign_pd(struct interface *iface, struct dhcp_assignment *assign)
                                return true;
                        }
 
-                       if (c->assigned != 0)
-                               current = (c->assigned + (1 << (64 - c->length)));
+                       current = (c->assigned + (1 << (64 - c->length)));
                }
        }
 
@@ -630,6 +629,7 @@ static bool assign_pd(struct interface *iface, struct dhcp_assignment *assign)
                        continue;
 
                current = (current + asize) & (~asize);
+
                if (current + asize < c->assigned) {
                        assign->assigned = current;
                        list_add_tail(&assign->head, &c->head);
@@ -640,8 +640,7 @@ static bool assign_pd(struct interface *iface, struct dhcp_assignment *assign)
                        return true;
                }
 
-               if (c->assigned != 0)
-                       current = (c->assigned + (1 << (64 - c->length)));
+               current = (c->assigned + (1 << (64 - c->length)));
        }
 
        return false;
@@ -713,7 +712,7 @@ static void handle_addrlist_change(struct netevent_handler_info *info)
                    c->managed_size)
                        continue;
 
-               if (c->assigned == 0 || c->assigned >= border->assigned)
+               if (c->assigned >= border->assigned)
                        list_move(&c->head, &reassign);
                else if (c->flags & OAF_BOUND)
                        apply_lease(c, true);
@@ -874,8 +873,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
                                o_ia_p.addr.s6_addr32[1] |= htonl(a->assigned);
                                o_ia_p.addr.s6_addr32[2] = o_ia_p.addr.s6_addr32[3] = 0;
 
-                               if ((a->assigned == 0 && a->managed_size == 0) ||
-                                               !valid_prefix_length(a, addrs[i].prefix))
+                               if (!valid_prefix_length(a, addrs[i].prefix))
                                        continue;
 
                                if (buflen < ia_len + sizeof(o_ia_p))
@@ -896,8 +894,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
 
                                o_ia_a.addr.s6_addr32[3] = htonl(a->assigned);
 
-                               if (!ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs) ||
-                                               a->assigned == 0)
+                               if (!ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs))
                                        continue;
 
                                if (buflen < ia_len + sizeof(o_ia_a))