changeset 1865:efadc01f51dd draft

Move IPv6 RA checking and disabling kernel RA higher up the chain.
author Roy Marples <roy@marples.name>
date Tue, 19 Feb 2013 16:05:12 +0000
parents 49e324e42081
children 6aa0c2598a20
files dhcpcd.c platform-bsd.c platform-linux.c
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Tue Feb 19 15:43:29 2013 +0000
+++ b/dhcpcd.c	Tue Feb 19 16:05:12 2013 +0000
@@ -307,8 +307,8 @@
 		ifp->metric = ifo->metric;
 
 	/* We want to disable kernel interface RA as early as possible. */
-	if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS) {
-		if (check_ipv6(ifp->name) != 1)
+	if (ifo->options & DHCPCD_IPV6RS) {
+		if (check_ipv6(NULL) != 1 || check_ipv6(ifp->name) != 1)
 			ifo->options &= ~DHCPCD_IPV6RS;
 	}
 
@@ -475,9 +475,6 @@
 		syslog(LOG_ERR, "ipv4_init: %m");
 		ifo->options &= ~DHCPCD_IPV4;
 	}
-
-	if (ifo->options & DHCPCD_IPV6RS && !check_ipv6(NULL))
-		ifo->options &= ~DHCPCD_IPV6RS;
 	if (ifo->options & DHCPCD_IPV6RS && ipv6_init() == -1) {
 		syslog(LOG_ERR, "ipv6_init: %m");
 		ifo->options &= ~DHCPCD_IPV6RS;
--- a/platform-bsd.c	Tue Feb 19 15:43:29 2013 +0000
+++ b/platform-bsd.c	Tue Feb 19 16:05:12 2013 +0000
@@ -92,12 +92,17 @@
 int
 check_ipv6(const char *ifname)
 {
+	static int ipv6_checked = 0;
 	int r;
 
 	/* BSD doesn't support these values per iface, so just return 1 */
 	if (ifname)
 		return 1;
 
+	if (ipv6_checked)
+		return 1;
+	ipv6_checked = 1;
+
 	r = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV);
 	if (r == -1)
 		/* The sysctl probably doesn't exist, but this isn't an
--- a/platform-linux.c	Tue Feb 19 15:43:29 2013 +0000
+++ b/platform-linux.c	Tue Feb 19 16:05:12 2013 +0000
@@ -175,10 +175,14 @@
 int
 check_ipv6(const char *ifname)
 {
+	static int ipv6_checked = 0;
 	int r, ex, i;
 	char path[256], *p, **nrest;
 
 	if (ifname == NULL) {
+		if (ipv6_checked)
+			return 1;
+		ipv6_checked = 1;
 		ifname = "all";
 		ex = 1;
 	} else