From: Paul Donald Date: Tue, 9 Apr 2024 03:04:04 +0000 (+0200) Subject: router: inherit user-assigned preferred_lifetime X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3b4e06055900c7e3dc6462ad17ff897093b1fc27;p=project%2Fodhcpd.git router: inherit user-assigned preferred_lifetime Inherit preferred_lifetime value irrespective of whether ra_useleasetime is set or not. User-provided values for preferred_lifetime are now assigned, instead of ignored. Before: == ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64) Type: Prefix information (3) Length: 4 (32 bytes) Prefix Length: 64 Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A) Valid Lifetime: Infinity (4294967295) Preferred Lifetime: Infinity (4294967295) Reserved Prefix: fd51:1c2a:8909:: == After (preferred_lifetime set to 7 minutes): == ICMPv6 Option (Prefix information : fd51:1c2a:8909::/64) Type: Prefix information (3) Length: 4 (32 bytes) Prefix Length: 64 Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A) Valid Lifetime: Infinity (4294967295) Preferred Lifetime: 420 Reserved Prefix: fd51:1c2a:8909:: == Signed-off-by: Paul Donald Reviewed-by: Daniel Golle [ fix comment format and improve commit description ] Signed-off-by: Christian Marangi --- diff --git a/src/router.c b/src/router.c index 6a9e19d..6eba161 100644 --- a/src/router.c +++ b/src/router.c @@ -590,9 +590,10 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr if (addr->preferred_lt > (uint32_t)now) { preferred_lt = TIME_LEFT(addr->preferred_lt, now); - if (iface->ra_useleasetime && - preferred_lt > iface->preferred_lifetime) + if (preferred_lt > iface->preferred_lifetime) { + /* set to possibly user mandated preferred_lt */ preferred_lt = iface->preferred_lifetime; + } } if (addr->valid_lt > (uint32_t)now) {