[LEDE-DEV] [PATCH odhcpd 1/2] dhcpv6-ia: Fix assignment of static DHCPv6 leases

Hans Dedecker dedeckeh at gmail.com
Thu Dec 1 05:24:23 PST 2016


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 <dedeckeh at 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




More information about the Lede-dev mailing list