changeset 2963:cc55b7be4b6a draft

Only warn about adding a host route to the router the once.
author Roy Marples <roy@marples.name>
date Fri, 27 Feb 2015 14:58:13 +0000
parents bfa69b762904
children 80eb30f91444
files dhcp.c if-options.h ipv4.c
diffstat 3 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp.c	Fri Feb 27 14:33:09 2015 +0000
+++ b/dhcp.c	Fri Feb 27 14:58:13 2015 +0000
@@ -1813,7 +1813,8 @@
 	state->state = DHS_REBIND;
 	eloop_timeout_delete(ifp->ctx->eloop, send_renew, ifp);
 	state->lease.server.s_addr = 0;
-	ifp->options->options &= ~ DHCPCD_CSR_WARNED;
+	ifp->options->options &= ~(DHCPCD_CSR_WARNED |
+	    DHCPCD_ROUTER_HOST_ROUTE_WARNED);
 	send_rebind(ifp);
 }
 
@@ -2192,7 +2193,8 @@
 	free(state->old);
 	state->old = NULL;
 	state->lease.addr.s_addr = 0;
-	ifp->options->options &= ~ DHCPCD_CSR_WARNED;
+	ifp->options->options &= ~(DHCPCD_CSR_WARNED |
+	    DHCPCD_ROUTER_HOST_ROUTE_WARNED);
 }
 
 static void
--- a/if-options.h	Fri Feb 27 14:33:09 2015 +0000
+++ b/if-options.h	Fri Feb 27 14:58:13 2015 +0000
@@ -107,6 +107,7 @@
 #define DHCPCD_PFXDLGONLY		(1ULL << 52)
 #define DHCPCD_PFXDLGMIX		(1ULL << 53)
 #define DHCPCD_IPV6RA_AUTOCONF		(1ULL << 54)
+#define DHCPCD_ROUTER_HOST_ROUTE_WARNED	(1ULL << 55)
 
 extern const struct option cf_options[];
 
--- a/ipv4.c	Fri Feb 27 14:33:09 2015 +0000
+++ b/ipv4.c	Fri Feb 27 14:58:13 2015 +0000
@@ -599,6 +599,7 @@
 {
 	struct rt *rtp, *rtn;
 	const char *cp, *cp2, *cp3, *cplim;
+	struct if_options *ifo;
 
 	if (rt == NULL) /* earlier malloc failed */
 		return NULL;
@@ -627,15 +628,23 @@
 		}
 		if (rtn != rtp)
 			continue;
+		ifo = ifp->options;
 		if (ifp->flags & IFF_NOARP) {
-			syslog(LOG_WARNING,
-			    "%s: forcing router %s through interface",
-			    ifp->name, inet_ntoa(rtp->gate));
+			if (!(ifo->options & DHCPCD_ROUTER_HOST_ROUTE_WARNED)) {
+				ifo->options |= DHCPCD_ROUTER_HOST_ROUTE_WARNED;
+				syslog(LOG_WARNING,
+				    "%s: forcing router %s through interface",
+				    ifp->name, inet_ntoa(rtp->gate));
+			}
 			rtp->gate.s_addr = 0;
 			continue;
 		}
-		syslog(LOG_WARNING, "%s: router %s requires a host route",
-		    ifp->name, inet_ntoa(rtp->gate));
+		if (!(ifo->options & DHCPCD_ROUTER_HOST_ROUTE_WARNED)) {
+			ifo->options |= DHCPCD_ROUTER_HOST_ROUTE_WARNED;
+			syslog(LOG_WARNING,
+			    "%s: router %s requires a host route",
+			    ifp->name, inet_ntoa(rtp->gate));
+		}
 		rtn = malloc(sizeof(*rtn));
 		if (rtn == NULL) {
 			syslog(LOG_ERR, "%s: %m", __func__);