diff options
| author | roy@uberlaptop.marples.name <roy@uberlaptop.marples.name> | 2012-02-04 15:15:25 +0000 |
|---|---|---|
| committer | roy@uberlaptop.marples.name <roy@uberlaptop.marples.name> | 2012-02-04 15:15:25 +0000 |
| commit | 441b06bc38676163fff3b6f6e97a59906759b662 (patch) | |
| tree | b112b53d3bf4e35dde550e37f045c6f33d71b783 | |
| parent | 7e82ec4449b3d213b9c3838ff6f285b92d8d03fd (diff) | |
| download | dhcpcd-441b06bc38676163fff3b6f6e97a59906759b662.tar.xz | |
If the kernel is not configured to accept IPv6 or RA's then don't
needless attempt to solicit an IPv6 RA.
| -rw-r--r-- | dhcpcd.c | 3 | ||||
| -rw-r--r-- | ipv6rs.c | 2 | ||||
| -rw-r--r-- | platform-bsd.c | 37 | ||||
| -rw-r--r-- | platform-linux.c | 10 | ||||
| -rw-r--r-- | platform.h | 3 |
5 files changed, 51 insertions, 4 deletions
@@ -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) { @@ -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 diff --git a/platform-bsd.c b/platform-bsd.c index dd5791ca..ff7379a2 100644 --- a/platform-bsd.c +++ b/platform-bsd.c @@ -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 @@ -26,8 +26,12 @@ */ #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; +} diff --git a/platform-linux.c b/platform-linux.c index 79562c84..923c9746 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -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; +} @@ -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 |
