From: Roy Marples Date: Tue, 19 Feb 2013 16:05:12 +0000 (+0000) Subject: Move IPv6 RA checking and disabling kernel RA higher up the chain. X-Git-Tag: v5.99.6~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92398db794471871590073dad3639e4c4ddc504d;p=thirdparty%2Fdhcpcd.git Move IPv6 RA checking and disabling kernel RA higher up the chain. --- diff --git a/dhcpcd.c b/dhcpcd.c index fd685122..b4724c20 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -307,8 +307,8 @@ configure_interface1(struct interface *ifp) 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 @@ init_state(struct interface *ifp, int argc, char **argv) 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; diff --git a/platform-bsd.c b/platform-bsd.c index 192e888b..76d83fe8 100644 --- a/platform-bsd.c +++ b/platform-bsd.c @@ -92,12 +92,17 @@ restore_kernel_ra(void) 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 diff --git a/platform-linux.c b/platform-linux.c index ece22c4f..f074cfc6 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -175,10 +175,14 @@ restore_kernel_ra(void) 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