From 4cccd67caa83be5e7ef77f439d29141234317cbb Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 19 Dec 2025 14:11:20 +0000 Subject: [PATCH] ifconfig: Fix the -L flag when using netlink By default, when ifconfig shows a v6 address derived from a router-advertised prefix, it shows the initial preferred and valid lifetimes. When -L is specified, it is supposed to show the remaining lifetimes, but this was broken in the conversion to netlink. Fix that, and add a regression test which validates ifconfig output before and after a short-lived address expires. Reported by: Franco Fichtner Reviewed by: melifaro, allanjude, Seyed Pouria Mousavizadeh Tehrani Fixes: 4c91a5dfe483 ("ifconfig: make interface and address listing use Netlink as transport") MFC after: 2 weeks Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54294 (cherry picked from commit df6861d755c8f72380ae7fb8df535b27eba8c0be) --- sbin/ifconfig/af_inet6.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index 7aed391c7bf..511b25580f0 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -375,8 +375,10 @@ show_lifetime(struct ifa_cacheinfo *ci) vl = (ci->ifa_valid == ND6_INFINITE_LIFETIME) ? 0 : ci->ifa_valid; clock_gettime(CLOCK_MONOTONIC_FAST, &now); - print_lifetime("pltime", pl + now.tv_sec, &now); - print_lifetime("vltime", vl + now.tv_sec, &now); + print_lifetime("pltime", + pl + (ip6lifetime ? ci->tstamp / 1000 : now.tv_sec), &now); + print_lifetime("vltime", + vl + (ip6lifetime ? ci->tstamp / 1000 : now.tv_sec), &now); } static void