From: Hans Dedecker Date: Thu, 2 Apr 2020 19:26:57 +0000 (+0200) Subject: dhcpv6-ia: fix preferred and valid lifetimes in ubus ipv6leases X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f61964c66be050716089d31f13688c1ab382f0b7;p=project%2Fodhcpd.git 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 --- 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;