changeset 4268:bd01addbb40f draft

ipv6nd: warn if router lifetime is set to zero
author Roy Marples <roy@marples.name>
date Wed, 02 May 2018 22:01:18 +0100
parents b5284aa7f420
children 3050be161143
files src/ipv6nd.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ipv6nd.c	Tue May 01 19:55:02 2018 +0100
+++ b/src/ipv6nd.c	Wed May 02 22:01:18 2018 +0100
@@ -750,6 +750,7 @@
 	struct ipv6_addr *ap;
 	struct dhcp_opt *dho;
 	uint8_t new_rap, new_data;
+	uint32_t old_lifetime;
 	__printflike(1, 2) void (*logfunc)(const char *, ...);
 #ifdef IPV6_MANAGETEMPADDR
 	uint8_t new_ap;
@@ -858,7 +859,11 @@
 
 	clock_gettime(CLOCK_MONOTONIC, &rap->acquired);
 	rap->flags = nd_ra->nd_ra_flags_reserved;
+	old_lifetime = rap->lifetime;
 	rap->lifetime = ntohs(nd_ra->nd_ra_router_lifetime);
+	if (!new_rap && rap->lifetime == 0 && old_lifetime != 0)
+		logwarnx("%s: %s: no longer a default router",
+		    ifp->name, rap->sfrom);
 	if (nd_ra->nd_ra_reachable) {
 		rap->reachable = ntohl(nd_ra->nd_ra_reachable);
 		if (rap->reachable > MAX_REACHABLE_TIME)