From: Roy Marples Date: Sat, 4 Feb 2012 15:37:42 +0000 (+0000) Subject: Add kernel IPv6 RA and forwarding detection on Linux. X-Git-Tag: v5.5.4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d77ae0270f65b957bd7678ad978530637a22a59;p=thirdparty%2Fdhcpcd.git Add kernel IPv6 RA and forwarding detection on Linux. --- diff --git a/platform-linux.c b/platform-linux.c index 923c9746..e2d2844b 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -27,7 +27,9 @@ #include #include +#include #include +#include #include "common.h" #include "platform.h" @@ -103,10 +105,35 @@ hardware_platform(void) return p; } +static int +check_proc_int(const char *path) +{ + FILE *fp; + char *buf; + + fp = fopen(path, "r"); + if (fp == NULL) + return -1; + buf = get_line(fp); + fclose(fp); + if (buf == NULL) + return -1; + return atoi(buf); +} + int check_ipv6(void) { - - // FIXME: Add IPv6 detection here - return 1; + + if (check_proc_int("/proc/sys/net/ipv6/conf/all/accept_ra") != 1) { + syslog(LOG_WARNING, + "Kernel is not configured to accept IPv6 RAs"); + return 0; + } + if (check_proc_int("/proc/sys/net/ipv6/conf/all/forwarding") != 0) { + syslog(LOG_WARNING, + "Kernel is configured as a router, not a host"); + return 0; + } + return 1; }