changeset 4182:4d1dbe479752 draft

IPv6ND: Fix lifetime overflow on carrier up Set the acquired time of the address to now as we're forcing short vltime and pltime.
author Roy Marples <roy@marples.name>
date Tue, 14 Nov 2017 15:37:23 +0000
parents 4224319f0887
children 115cbfa711e2
files src/ipv6nd.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ipv6nd.c	Tue Nov 14 12:16:26 2017 +0000
+++ b/src/ipv6nd.c	Tue Nov 14 15:37:23 2017 +0000
@@ -336,6 +336,8 @@
 {
 	struct ra *rap;
 	struct timespec now;
+	uint32_t vltime = seconds;
+	uint32_t pltime = seconds / 2;
 
 	if (ifp->ctx->ra_routers == NULL)
 		return;
@@ -347,13 +349,18 @@
 			rap->acquired = now;
 			rap->expired = seconds ? 0 : 1;
 			if (seconds) {
-				struct ipv6_addr *ap;
+				struct ipv6_addr *ia;
 
 				rap->lifetime = seconds;
-				TAILQ_FOREACH(ap, &rap->addrs, next) {
-					if (ap->prefix_vltime) {
-						ap->prefix_vltime = seconds;
-						ap->prefix_pltime = seconds / 2;
+				TAILQ_FOREACH(ia, &rap->addrs, next) {
+					if (ia->prefix_pltime > pltime ||
+					    ia->prefix_vltime > vltime)
+					{
+						ia->acquired = now;
+						if (ia->prefix_pltime != 0)
+							ia->prefix_pltime =
+							    pltime;
+						ia->prefix_vltime = vltime;
 					}
 				}
 				ipv6_addaddrs(&rap->addrs);