From c1183528816f5d9d61a12c05ceeda5975f422b32 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Mon, 7 Sep 2020 10:20:02 +0100
Subject: [PATCH] Make sure valid and preferred lifetimes always get set

In 4d85e409cd2f4b0935d6ac5e8c72f6a151735d52 we skipped setting the floor
time if we were using the default RA interval. The commit was a bit too
broad; it also caused the valid and preferred lifetimes to be skipped
too, meaning that they were set to infinite.

Adjust the check, so that we only apply the "are we using the default?"
check when calculating the floor; but still set up the `time` variable
because that is used later on as a ceiling for valid_lft and
preferred_lft.
---
 src/radv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/radv.c b/src/radv.c
index 41df852..78edaab 100644
--- a/src/radv.c
+++ b/src/radv.c
@@ -629,11 +629,11 @@ static int add_prefixes(struct in6_addr *local,  int prefix,
 		/* find floor time, don't reduce below 3 * RA interval.
 		   If the lease time has been left as default, don't
 		   use that as a floor. */
-		if ((context->flags & CONTEXT_SETLEASE) &&
-		    time > context->lease_time)
+		if (time > context->lease_time)
 		  {
 		    time = context->lease_time;
-		    if (time < ((unsigned int)(3 * param->adv_interval)))
+		    if ((context->flags & CONTEXT_SETLEASE) &&
+		        time < ((unsigned int)(2 * param->adv_interval)))
 		      time = 3 * param->adv_interval;
 		  }
 
-- 
2.27.0

