From f61964c66be050716089d31f13688c1ab382f0b7 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Thu, 2 Apr 2020 21:26:57 +0200 Subject: [PATCH] dhcpv6-ia: fix preferred and valid lifetimes in ubus ipv6leases Since commit 6db312a698e920ff61505ef1f42469880829774d the preferred and valid lifetimes of the addresses/prefixes is based on the configured leasetime; as a result the displayed preferred and valid lifetimes need to be calculated based on the assignment lifetime as this is set to the lowest valid lifetime of the addresses/prefixes. Signed-off-by: Hans Dedecker --- src/dhcpv6-ia.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index b51649c..38a901b 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -247,9 +247,15 @@ void dhcpv6_ia_enum_addrs(struct interface *iface, struct dhcp_assignment *c, addr.s6_addr32[2] = addr.s6_addr32[3] = 0; } + if (pref > (uint32_t)c->valid_until) + pref = c->valid_until; + if (pref != UINT32_MAX) pref -= now; + if (valid > (uint32_t)c->valid_until) + valid = c->valid_until; + if (valid != UINT32_MAX) valid -= now; -- 2.30.2