From: Roy Marples Date: Fri, 7 Dec 2012 09:43:56 +0000 (+0000) Subject: If no IPv6 proc or sysctl entries exist for RA or forward, assume it's OK. X-Git-Tag: v5.99.3~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dcec32683d843779af52e0649852a7e02eb145c2;p=thirdparty%2Fdhcpcd.git If no IPv6 proc or sysctl entries exist for RA or forward, assume it's OK. --- diff --git a/dhcpcd.c b/dhcpcd.c index 23849193..2c8ffd10 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -2105,7 +2105,8 @@ main(int argc, char **argv) ipv6rsfd = ipv6rs_open(); if (ipv6rsfd == -1) { syslog(LOG_ERR, "ipv6rs: %m"); - options &= ~DHCPCD_IPV6RS; + options &= ~(DHCPCD_IPV6RS | + DHCPCD_IPV6RA_OWN | DHCPCD_IPV6RA_OWN_DEFAULT); } else { eloop_event_add(ipv6rsfd, ipv6rs_handledata, NULL); // atexit(restore_rtadv); diff --git a/platform-bsd.c b/platform-bsd.c index 9eaaf524..0a23acb3 100644 --- a/platform-bsd.c +++ b/platform-bsd.c @@ -90,14 +90,19 @@ restore_kernel_ra(void) int check_ipv6(const char *ifname) { - int val; + int r; /* BSD doesn't support these values per iface, so just return 1 */ if (ifname) return 1; - val = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV); - if (val == 0) + r = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV); + if (r == -1) + /* The sysctl probably doesn't exist, but this isn't an + * error as such so just log it and continue */ + syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, + "IPV6CTL_ACCEPT_RTADV: %m"); + else if (r == 0) options |= DHCPCD_IPV6RA_OWN; else if (options & DHCPCD_IPV6RA_OWN) { syslog(LOG_INFO, "disabling Kernel IPv6 RA support"); @@ -107,8 +112,14 @@ check_ipv6(const char *ifname) } atexit(restore_kernel_ra); } -return 1; - if (get_inet6_sysctl(IPV6CTL_FORWARDING) != 0) { + + r = get_inet6_sysctl(IPV6CTL_FORWARDING); + if (r == -1) + /* The sysctl probably doesn't exist, but this isn't an + * error as such so just log it and continue */ + syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, + "IPV6CTL_FORWARDING: %m"); + else if (r != 0) { syslog(LOG_WARNING, "Kernel is configured as a router, not a host"); return 0; diff --git a/platform-linux.c b/platform-linux.c index 3ac2db9e..e42f8dd8 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -185,7 +185,12 @@ check_ipv6(const char *ifname) snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ifname); r = check_proc_int(path); - if (r == 0) + if (r == -1) + /* The sysctl probably doesn't exist, but this isn't an + * error as such so just log it and continue */ + syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, + "%s: %m", path); + else if (r == 0) options |= DHCPCD_IPV6RA_OWN; else if (options & DHCPCD_IPV6RA_OWN) { syslog(LOG_INFO, "%s: disabling Kernel IPv6 RA support", @@ -213,7 +218,13 @@ check_ipv6(const char *ifname) if (r != 2) { snprintf(path, sizeof(path), "%s/%s/forwarding", prefix, ifname); - if (check_proc_int(path) != 0) { + r = check_proc_int(path); + if (r == -1) { + /* The sysctl probably doesn't exist, but this isn't an + * error as such so just log it and continue */ + syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, + "%s: %m", path); + } else if (r != 0) { syslog(LOG_WARNING, "%s: configured as a router, not a host", ifname); return 0;