summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-11-23 21:05:16 +0000
committerRoy Marples <roy@marples.name>2016-11-23 21:05:16 +0000
commit962f18248e835ab6a9f90c282ff7ff74faa4a87b (patch)
treef5789d0cc2bc561ef5ed364e9cb312e6eb48225f
parentcba913417b2e6951862137a91adec5321551bccc (diff)
downloaddhcpcd-962f18248e835ab6a9f90c282ff7ff74faa4a87b.tar.xz
Fix IPv6 DAD on OpenBSD.
-rw-r--r--if-bsd.c25
-rw-r--r--ipv6.c2
-rw-r--r--ipv6.h10
3 files changed, 22 insertions, 15 deletions
diff --git a/if-bsd.c b/if-bsd.c
index 0e033d17..d9910a56 100644
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -1345,23 +1345,24 @@ inet6_sysctl(int code, int val, int action)
#endif
#ifdef IPV6_MANAGETEMPADDR
-#ifndef IPV6CTL_TEMPVLTIME
-#define get_inet6_sysctlbyname(code) inet6_sysctlbyname(code, 0, 0)
-#define set_inet6_sysctlbyname(code, val) inet6_sysctlbyname(code, val, 1)
+#if !defined(IPV6CTL_TEMPVLTIME)
static int
-inet6_sysctlbyname(const char *name, int val, int action)
+get_sysctlbyname(const char *name)
{
+#ifdef __OpenBSD__
+ /* OpenBSD seems to have it enabled by default .... */
+
+ UNUSED(name);
+ return -1;
+#else
+ int val;
size_t size;
size = sizeof(val);
- if (action) {
- if (sysctlbyname(name, NULL, 0, &val, size) == -1)
- return -1;
- return 0;
- }
if (sysctlbyname(name, &val, &size, NULL, 0) == -1)
return -1;
return val;
+#endif
}
#endif
@@ -1373,7 +1374,7 @@ ip6_use_tempaddr(__unused const char *ifname)
#ifdef IPV6CTL_USETEMPADDR
val = get_inet6_sysctl(IPV6CTL_USETEMPADDR);
#else
- val = get_inet6_sysctlbyname("net.inet6.ip6.use_tempaddr");
+ val = get_sysctlbyname("net.inet6.ip6.use_tempaddr");
#endif
return val == -1 ? 0 : val;
}
@@ -1386,7 +1387,7 @@ ip6_temp_preferred_lifetime(__unused const char *ifname)
#ifdef IPV6CTL_TEMPPLTIME
val = get_inet6_sysctl(IPV6CTL_TEMPPLTIME);
#else
- val = get_inet6_sysctlbyname("net.inet6.ip6.temppltime");
+ val = get_sysctlbyname("net.inet6.ip6.temppltime");
#endif
return val < 0 ? TEMP_PREFERRED_LIFETIME : val;
}
@@ -1399,7 +1400,7 @@ ip6_temp_valid_lifetime(__unused const char *ifname)
#ifdef IPV6CTL_TEMPVLTIME
val = get_inet6_sysctl(IPV6CTL_TEMPVLTIME);
#else
- val = get_inet6_sysctlbyname("net.inet6.ip6.tempvltime");
+ val = get_sysctlbyname("net.inet6.ip6.tempvltime");
#endif
return val < 0 ? TEMP_VALID_LIFETIME : val;
}
diff --git a/ipv6.c b/ipv6.c
index c51a1efb..95665f4e 100644
--- a/ipv6.c
+++ b/ipv6.c
@@ -566,7 +566,7 @@ ipv6_checkaddrflags(void *arg)
return;
}
- if (!(ia->addr_flags & IN6_IFF_TENTATIVE)) {
+ if (!(flags & IN6_IFF_TENTATIVE)) {
/* Simulate the kernel announcing the new address. */
ipv6_handleifa(ia->iface->ctx, RTM_NEWADDR,
ia->iface->ctx->ifaces, ia->iface->name,
diff --git a/ipv6.h b/ipv6.h
index 11a38968..9efd019f 100644
--- a/ipv6.h
+++ b/ipv6.h
@@ -104,8 +104,14 @@
* Some BSDs do not allow userland to set temporary addresses.
* Linux-3.18 allows the marking of addresses from which to manage temp addrs.
*/
-#if defined(BSD) && defined(IN6_IFF_TEMPORARY)
-#define IPV6_MANAGETEMPADDR
+#if defined(BSD)
+# if !defined(IN6_IFF_TEMPORARY) && defined(IN6_IFF_PRIVACY)
+ /* OpenBSD just has to be different... */
+# define IN6_IFF_TEMPORARY IN6_IFF_PRIVACY
+# endif
+# if defined(IN6_IFF_TEMPORARY)
+# define IPV6_MANAGETEMPADDR
+# endif
#endif
/*