summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 21:53:59 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 21:53:59 +0000
commitdec7db0c7de01a80b3daca4333e469944accb1b8 (patch)
treef74afd06444c910219898d2e9271f99655bbc38e /net/base/net_util.cc
parentdab7df7ddb57590dec29e78c0a22d33684aa16aa (diff)
downloadchromium_src-dec7db0c7de01a80b3daca4333e469944accb1b8.zip
chromium_src-dec7db0c7de01a80b3daca4333e469944accb1b8.tar.gz
chromium_src-dec7db0c7de01a80b3daca4333e469944accb1b8.tar.bz2
Treat IPv6 link local addresses as loopback addresses.
IPv6 linklocal address are effectively loopback addresses because we don't expect to send traffic over them. Linux's getaddrinfo considers them "valid" with respect to AI_ADDRCONFIG, so we can't use that flag when there are only loopback *or* link local addresses configured. BUG=55041 TEST=manually test that http://localhost/ works when link local addresses are configured. Review URL: http://codereview.chromium.org/3331024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r--net/base/net_util.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index ff812eb..0a3f9b9 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -1831,6 +1831,14 @@ bool HaveOnlyLoopbackAddresses() {
const struct sockaddr* addr = interface->ifa_addr;
if (!addr)
continue;
+ if (addr->sa_family == AF_INET6) {
+ // Safe cast since this is AF_INET6.
+ const struct sockaddr_in6* addr_in6 =
+ reinterpret_cast<const struct sockaddr_in6*>(addr);
+ const struct in6_addr* sin6_addr = &addr_in6->sin6_addr;
+ if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_LINKLOCAL(sin6_addr))
+ continue;
+ }
if (addr->sa_family != AF_INET6 && addr->sa_family != AF_INET)
continue;