Mercurial > hg > dhcpcd
changeset 4979:326cb725999e draft
OpenBSD: Support privacy extensions
If course, OpenBSD is really different from other BSD's.
IN6_IFF_PRIVACY is their IN6_IFF_TEMPORARY.
Temporary addresses are on by default, you need to turn them
off on OpenBSD via ifconfig.
Temporary addresss timings are not configurable and the address
itself is always preferred over non temporary addresses within the
same scope.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 17 Jan 2020 17:18:45 +0000 |
| parents | ab1d8e03721c |
| children | b01fcca467a5 |
| files | src/if-bsd.c src/ipv6.h |
| diffstat | 2 files changed, 41 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if-bsd.c Fri Jan 17 16:21:37 2020 +0000 +++ b/src/if-bsd.c Fri Jan 17 17:18:45 2020 +0000 @@ -1634,7 +1634,7 @@ } #ifdef IPV6_MANAGETEMPADDR -#ifndef IPV6CTL_TEMPVLTIME +#if defined(IPV6CTL_TEMPVLTIME) && !defined(__OpenBSD__) #define get_inet6_sysctlbyname(code) inet6_sysctlbyname(code, 0, 0) #define set_inet6_sysctlbyname(code, val) inet6_sysctlbyname(code, val, 1) static int @@ -1654,6 +1654,40 @@ } #endif +#ifdef __OpenBSD__ +int +ip6_use_tempaddr(const char *ifname) +{ + int s, r; + struct ifreq ifr; + + s = socket(PF_INET6, SOCK_DGRAM, 0); /* XXX Not efficient */ + if (s == -1) + return -1; + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + r = ioctl(s, SIOCGIFXFLAGS, &ifr); + close(s); + if (r == -1) + return -1; + return ifr.ifr_flags & IFXF_INET6_NOPRIVACY ? 0 : 1; +} + +int +ip6_temp_preferred_lifetime(__unused const char *ifname) +{ + + return ND6_PRIV_PREFERRED_LIFETIME; +} + +int +ip6_temp_valid_lifetime(__unused const char *ifname) +{ + + return ND6_PRIV_VALID_LIFETIME; +} + +#else /* __OpenBSD__ */ + int ip6_use_tempaddr(__unused const char *ifname) { @@ -1692,6 +1726,7 @@ #endif return val < 0 ? TEMP_VALID_LIFETIME : val; } +#endif /* !__OpenBSD__ */ #endif int
--- a/src/ipv6.h Fri Jan 17 16:21:37 2020 +0000 +++ b/src/ipv6.h Fri Jan 17 17:18:45 2020 +0000 @@ -108,6 +108,11 @@ # undef IPV6_POLLADDRFLAG #endif +/* Of course OpenBSD has their own special name. */ +#if !defined(IN6_IFF_TEMPORARY) && defined(IN6_IFF_PRIVACY) +#define IN6_IFF_TEMPORARY IN6_IFF_PRIVACY +#endif + #ifdef __sun /* Solaris lacks these defines. * While it supports DaD, to seems to only expose IFF_DUPLICATE
