Fix assignment of static DHCPv6 leases which was broken
by commit 6c3bc0141dacc88992583d6f2cdc8a360df7422d.
At the same time fix lifetime check of existing assignments
having a finite lifetime

Fixes FS#309

Signed-off-by: Hans Dedecker <dedec...@gmail.com>
---
 src/dhcpv6-ia.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 8db53b9..f4bf044 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -114,6 +114,8 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool 
enable)
                        odhcpd_urandom(a->key, sizeof(a->key));
                        memcpy(a->clid_data, lease->duid, lease->duid_len);
                        memcpy(a->mac, lease->mac.ether_addr_octet, 
sizeof(a->mac));
+                       /* Infinite valid */
+                       a->valid_until = 0;
 
                        // Assign to all interfaces
                        struct dhcpv6_assignment *c;
@@ -1035,7 +1037,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, 
struct interface *iface,
                        if (((c->clid_len == clid_len && !memcmp(c->clid_data, 
clid_data, clid_len)) ||
                                        (c->clid_len >= clid_len && 
!c->clid_data[0] && !c->clid_data[1]
                                                && !memcmp(c->mac, mac, 
sizeof(mac)))) &&
-                                       (c->iaid == ia->iaid || 
(!INFINITE_VALID(c->valid_until) && c->valid_until < now)) &&
+                                       (c->iaid == ia->iaid || 
INFINITE_VALID(c->valid_until) || now < c->valid_until) &&
                                        ((is_pd && c->length <= 64) || (is_na 
&& c->length == 128))) {
                                a = c;
 
-- 
1.9.1


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to