From: Roy Marples Date: Mon, 23 Feb 2015 10:55:09 +0000 (+0000) Subject: Support BSDs where userland is not allowed to set temporary addresses. X-Git-Tag: v6.8.0~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d6f9ae6d243ebbb7e6aa33f16403b4d421326d3;p=thirdparty%2Fdhcpcd.git Support BSDs where userland is not allowed to set temporary addresses. --- diff --git a/if-bsd.c b/if-bsd.c index 8470ac88..8e7a7083 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -618,8 +618,10 @@ if_address6(const struct ipv6_addr *a, int action) if (a->autoconf) ifa.ifra_flags |= IN6_IFF_AUTOCONF; #endif +#ifdef IPV6_MANGETEMPADDR if (a->flags & IPV6_AF_TEMPORARY) ifa.ifra_flags |= IN6_IFF_TEMPORARY; +#endif #define ADDADDR(v, addr) { \ (v)->sin6_family = AF_INET6; \ @@ -1089,6 +1091,7 @@ 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) @@ -1119,7 +1122,7 @@ ip6_use_tempaddr(__unused const char *ifname) #else val = get_inet6_sysctlbyname("net.inet6.ip6.use_tempaddr"); #endif - return val == -1 ? TEMP_PREFERRED_LIFETIME : val; + return val == -1 ? 0 : val; } int @@ -1147,6 +1150,7 @@ ip6_temp_valid_lifetime(__unused const char *ifname) #endif return val < 0 ? TEMP_VALID_LIFETIME : val; } +#endif #define del_if_nd6_flag(ifname, flag) if_nd6_flag(ifname, flag, -1) #define get_if_nd6_flag(ifname, flag) if_nd6_flag(ifname, flag, 0) diff --git a/if.h b/if.h index c44aed6f..b15f77b4 100644 --- a/if.h +++ b/if.h @@ -125,9 +125,13 @@ int if_route(const struct rt *rt, int); #ifdef INET6 int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *, int); +#ifdef IPV6_MANAGETEMPADDR int ip6_use_tempaddr(const char *ifname); int ip6_temp_preferred_lifetime(const char *ifname); int ip6_temp_valid_lifetime(const char *ifname); +#else +#define ip6_use_tempaddr(a) (0) +#endif int if_address6(const struct ipv6_addr *, int); #define if_addaddress6(a) if_address6(a, 1) diff --git a/ipv6.c b/ipv6.c index abc2d859..01d1880f 100644 --- a/ipv6.c +++ b/ipv6.c @@ -984,8 +984,10 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx, ap, next); } ap->addr_flags = flags; +#ifdef IPV6_MANAGETEMPADDR if (ap->addr_flags & IN6_IFF_TEMPORARY) ap->flags |= IPV6_AF_TEMPORARY; +#endif if (IN6_IS_ADDR_LINKLOCAL(&ap->addr)) { #ifdef IPV6_POLLADDRFLAG if (ap->addr_flags & IN6_IFF_TENTATIVE) { diff --git a/ipv6.h b/ipv6.h index f0b3000a..eef65c2a 100644 --- a/ipv6.h +++ b/ipv6.h @@ -88,7 +88,12 @@ /* Linux-3.18 can manage temporary addresses even with RA * processing disabled. */ //#undef IFA_F_MANAGETEMPADDR -#ifndef IFA_F_MANAGETEMPADDR +#if defined(__linux__) && defined(IFA_F_MANAGETEMPADDR) +#define IPV6_MANAGETEMPADDR +#endif + +/* Some BSDs do not allow userlan to set temporary addresses. */ +#if defined(BSD) && defined(IN6_IFF_TEMPORARY) #define IPV6_MANAGETEMPADDR #endif @@ -130,7 +135,9 @@ TAILQ_HEAD(ipv6_addrhead, ipv6_addr); #define IPV6_AF_DELEGATEDPFX 0x0100 #define IPV6_AF_DELEGATEDZERO 0x0200 #define IPV6_AF_REQUEST 0x0400 +#ifdef IPV6_MANAGETEMPADDR #define IPV6_AF_TEMPORARY 0X0800 +#endif struct rt6 { TAILQ_ENTRY(rt6) next;