diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2015-05-05 17:08:45 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2015-05-05 17:08:45 +0000 |
commit | 01d964efc4ddcb5c555d2272e4063cb5a7bfcc74 (patch) | |
tree | 05274220f975eb1b2622ae1f2fb5a62052a9610b /lib | |
parent | d6194a1e5556bfad7ef6675f516375f9c5606f17 (diff) |
AI_ADDRCONFIG: skip loopback addresses, not loopback interfaces.
This is what RFC3493 suggests. Fixes AI_ADDRCONFIG on setups where
global addresses are configured only on loopback interfaces.
Discussed with and ok eric@ gilles@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/asr/getaddrinfo_async.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index 1550a8e309a..d6a8e84dd9a 100644 --- a/lib/libc/asr/getaddrinfo_async.c +++ b/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.35 2015/05/05 16:59:08 jca Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.36 2015/05/05 17:08:44 jca Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -834,6 +834,7 @@ static int addrconfig_setup(struct asr_query *as) { struct ifaddrs *ifa, *ifa0; + struct sockaddr_in *sinp; struct sockaddr_in6 *sin6p; if (getifaddrs(&ifa0) != 0) @@ -842,19 +843,24 @@ addrconfig_setup(struct asr_query *as) as->as.ai.flags |= ASYNC_NO_INET | ASYNC_NO_INET6; for (ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_flags & IFF_LOOPBACK) - continue; - if (ifa->ifa_addr == NULL) continue; switch (ifa->ifa_addr->sa_family) { case PF_INET: + sinp = (struct sockaddr_in *)ifa->ifa_addr; + + if (sinp->sin_addr.s_addr == INADDR_LOOPBACK) + continue; + as->as.ai.flags &= ~ASYNC_NO_INET; break; case PF_INET6: sin6p = (struct sockaddr_in6 *)ifa->ifa_addr; + if (IN6_IS_ADDR_LOOPBACK(&sin6p->sin6_addr)) + continue; + if (IN6_IS_ADDR_LINKLOCAL(&sin6p->sin6_addr)) continue; |