changeset 4164:834aba640014 draft

Don't attempt to flush IPv6 routers or prefixes if the kernel does not support setting them.
author Roy Marples <roy@marples.name>
date Tue, 10 Oct 2017 21:04:27 +0100
parents 799ea031e1ec
children 278ef87ffd94
files src/if-bsd.c
diffstat 1 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/if-bsd.c	Mon Oct 09 20:21:05 2017 +0100
+++ b/src/if-bsd.c	Tue Oct 10 21:04:27 2017 +0100
@@ -1346,18 +1346,6 @@
 }
 #endif
 
-static int
-if_raflush(int s)
-{
-	char dummy[IFNAMSIZ + 8];
-
-	strlcpy(dummy, "lo0", sizeof(dummy));
-	if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&dummy) == -1 ||
-	    ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&dummy) == -1)
-		return -1;
-	return 0;
-}
-
 #ifdef SIOCIFAFATTACH
 static int
 af_attach(int s, const struct interface *ifp, int af)
@@ -1533,11 +1521,18 @@
 	ra = 0;
 	if (!(ctx->options & DHCPCD_TEST)) {
 #endif
+#if defined(IPV6CTL_ACCEPT_RTADV) || defined(ND6_IFF_ACCEPT_RTADV)
 		/* Flush the kernel knowledge of advertised routers
 		 * and prefixes so the kernel does not expire prefixes
 		 * and default routes we are trying to own. */
-		if (if_raflush(s) == -1)
-			logwarn("if_raflush");
+		char dummy[IFNAMSIZ + 8];
+
+		strlcpy(dummy, "lo0", sizeof(dummy));
+		if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&dummy) == -1)
+			logwarn("SIOCSRTRFLUSH_IN6");
+		if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&dummy) == -1)
+			logwarn("SIOCSPFXFLUSH_IN6");
+#endif
 	}
 
 	ctx->ra_global = ra;