dhcpv6-ia: fix preferred and valid lifetimes in ubus ipv6leases
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 2 Apr 2020 19:26:57 +0000 (21:26 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 4 Apr 2020 18:53:43 +0000 (20:53 +0200)
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 <dedeckeh@gmail.com>
src/dhcpv6-ia.c

index b51649c19f153f7b62bbad7da95236e41a5fa30a..38a901bfc534f97db87972d3903087bf355917d3 100644 (file)
@@ -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;