]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Respect an accept_ra setting of 2, fixes #240.
authorRoy Marples <roy@marples.name>
Mon, 5 Mar 2012 10:04:26 +0000 (10:04 +0000)
committerRoy Marples <roy@marples.name>
Mon, 5 Mar 2012 10:04:26 +0000 (10:04 +0000)
Detect IPv6 settings per interface if the platform allows, fixed #241.

dhcpcd.c
platform-bsd.c
platform-linux.c
platform.h

index 6b8382bc17fe23185a1bff397321298dc3d2f2d7..0f71e4a67bd29a8e51d0290f084951460c969330 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1162,8 +1162,12 @@ start_interface(void *arg)
        free(iface->state->offer);
        iface->state->offer = NULL;
 
-       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS)
-               ipv6rs_start(iface);
+       if (options & DHCPCD_IPV6RS && ifo->options & DHCPCD_IPV6RS) {
+               if (check_ipv6(iface->name) == 1)
+                       ipv6rs_start(iface);
+               else
+                       ifo->options &= ~DHCPCD_IPV6RS;
+       }
 
        if (iface->state->arping_index < ifo->arping_len) {
                start_arping(iface);
@@ -1993,7 +1997,7 @@ main(int argc, char **argv)
        }
 #endif
 
-       if (options & DHCPCD_IPV6RS && !check_ipv6())
+       if (options & DHCPCD_IPV6RS && !check_ipv6(NULL))
                options &= ~DHCPCD_IPV6RS;
        if (options & DHCPCD_IPV6RS) {
                ipv6rsfd = ipv6rs_open();
index 6fb1896cb99303f0ebb9a208d0840154b66cb0b5..afa43845f65e824988633ccc2bc42982e8089824 100644 (file)
@@ -68,9 +68,13 @@ inet6_sysctl(int code)
 }
 
 int
-check_ipv6(void)
+check_ipv6(const char *ifname)
 {
 
+       /* BSD doesn't support these values per iface, so just reutrn 1 */
+       if (ifname)
+               return 1;
+
        if (inet6_sysctl(IPV6CTL_ACCEPT_RTADV) != 1) {
                syslog(LOG_WARNING,
                    "Kernel is not configured to accept IPv6 RAs");
index e2d2844b8c722a7af20ed64cf16ac22b229b0ac8..119ec5012975fa85aa3eaf29f175bf32e8aa314b 100644 (file)
@@ -121,19 +121,33 @@ check_proc_int(const char *path)
        return atoi(buf);
 }
 
+static const char *prefix = "/proc/sys/net/ipv6/conf";
+
 int
-check_ipv6(void)
+check_ipv6(const char *ifname)
 {
+       int r;
+       char path[256];
+
+       if (ifname == NULL)
+               ifname = "all";
 
-       if (check_proc_int("/proc/sys/net/ipv6/conf/all/accept_ra") != 1) {
+       snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ifname);
+       r = check_proc_int(path);
+       if (r != 1 && r != 2) {
                syslog(LOG_WARNING,
-                   "Kernel is not configured to accept IPv6 RAs");
+                   "%s: not configured to accept IPv6 RAs", ifname);
                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;
+
+       if (r != 2) {
+               snprintf(path, sizeof(path), "%s/%s/forwarding",
+                   prefix, ifname);
+               if (check_proc_int(path) != 0) {
+                       syslog(LOG_WARNING,
+                           "%s: configured as a router, not a host", ifname);
+                       return 0;
+               }
        }
        return 1;
 }
index 1286fe624d2bdde4066c98303890f3708b0a8b3d..08ec368aa1cedda1cc5cf9432a51e14c9bc16b02 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef PLATFORM_H
 #define PLATFORM_H
 
-char * hardware_platform(void);
-int check_ipv6(void);
+char *hardware_platform(void);
+int check_ipv6(const char *);
 
 #endif