]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If the kernel is not configured to accept IPv6 or RA's then don't
authorroy@uberlaptop.marples.name <roy@uberlaptop.marples.name>
Sat, 4 Feb 2012 15:15:25 +0000 (15:15 +0000)
committerroy@uberlaptop.marples.name <roy@uberlaptop.marples.name>
Sat, 4 Feb 2012 15:15:25 +0000 (15:15 +0000)
needless attempt to solicit an IPv6 RA.

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

index 621b83ac8b024f6e9a0590cb20611631754a5933..bc2b485450f2abaa17da52c61532937918c38ad6 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -69,6 +69,7 @@ const char copyright[] = "Copyright (c) 2006-2012 Roy Marples";
 #include "ipv4ll.h"
 #include "ipv6rs.h"
 #include "net.h"
+#include "platform.h"
 #include "signals.h"
 
 /* We should define a maximum for the NAK exponential backoff */ 
@@ -1991,6 +1992,8 @@ main(int argc, char **argv)
        }
 #endif
 
+       if (options & DHCPCD_IPV6RS && !check_ipv6())
+               options &= ~DHCPCD_IPV6RS;
        if (options & DHCPCD_IPV6RS) {
                ipv6rsfd = ipv6rs_open();
                if (ipv6rsfd == -1) {
index b9e7c9d6aa3a691ee3ad92642bab8b24f50656d9..69838e9da4532813a7e7aa25b3ea8e5c8e0f30a8 100644 (file)
--- a/ipv6rs.c
+++ b/ipv6rs.c
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
index dd5791ca8df34e4768f7df61c69e8e72b0fc680f..ff7379a2a090bd90f9624b6a44dea49b34d0c807 100644 (file)
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
  */
 
 #include <sys/param.h>
+#include <sys/socket.h>
 #include <sys/sysctl.h>
 #include <sys/utsname.h>
+#include <netinet/in.h>
+
+#include <syslog.h>
 
 #include "platform.h"
 
@@ -48,3 +52,34 @@ hardware_platform(void)
                return NULL;
        return march;
 }
+
+static int
+inet6_sysctl(int code)
+{
+       int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
+       int val;
+       size_t size;
+
+       mib[3] = code;
+       size = sizeof(val);
+       if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &val, &size, NULL, 0) == -1)
+               return -1;
+       return val;
+}
+
+int
+check_ipv6(void)
+{
+
+       if (!inet6_sysctl(IPV6CTL_ACCEPT_RTADV)) {
+               syslog(LOG_WARNING,
+                   "Kernel is not configured to accept IPv6 RAs");
+               return 0;
+       }
+       if (inet6_sysctl(IPV6CTL_FORWARDING)) {
+               syslog(LOG_WARNING,
+                   "Kernel is configured as a router, not a host");
+               return 0;
+       }
+       return 1;
+}
index 79562c8445554f239dbe5a84f5a91a64f1a1e286..923c9746dc46a766a8da2655c66461fb1ab429b6 100644 (file)
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -102,3 +102,11 @@ hardware_platform(void)
                errno = ESRCH;
        return p;
 }
+
+int
+check_ipv6(void)
+{
+    
+    // FIXME: Add IPv6 detection here
+    return 1;
+}
index 24731ace5427375cb4269c5d7c193822a7418385..1286fe624d2bdde4066c98303890f3708b0a8b3d 100644 (file)
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -29,5 +29,6 @@
 #define PLATFORM_H
 
 char * hardware_platform(void);
+int check_ipv6(void);
 
 #endif