summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-03-05 10:04:26 +0000
committerRoy Marples <roy@marples.name>2012-03-05 10:04:26 +0000
commitd705c979f018e29f2ecba822ca229827efb9e95c (patch)
tree816f0afaa8880df8127eef6c04d8c8e3d64242c0
parent46caaa5ee45a851f9995a625d8ab3c01eabcc1bd (diff)
downloaddhcpcd-d705c979f018e29f2ecba822ca229827efb9e95c.tar.xz
Respect an accept_ra setting of 2, fixes #240.
Detect IPv6 settings per interface if the platform allows, fixed #241.
-rw-r--r--dhcpcd.c10
-rw-r--r--platform-bsd.c6
-rw-r--r--platform-linux.c28
-rw-r--r--platform.h4
4 files changed, 35 insertions, 13 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 6b8382bc..0f71e4a6 100644
--- 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();
diff --git a/platform-bsd.c b/platform-bsd.c
index 6fb1896c..afa43845 100644
--- a/platform-bsd.c
+++ b/platform-bsd.c
@@ -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");
diff --git a/platform-linux.c b/platform-linux.c
index e2d2844b..119ec501 100644
--- a/platform-linux.c
+++ b/platform-linux.c
@@ -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;
}
diff --git a/platform.h b/platform.h
index 1286fe62..08ec368a 100644
--- a/platform.h
+++ b/platform.h
@@ -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