Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: net/dns/host_resolver_impl.cc

Issue 14234006: [net/dns] When testing for IPv6, discard link local and Teredo addresses (measurement) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to IsGloballyReachable, use DCHECK Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index d6adbb8f9d1be1f925d3f1f9e556f2dedac0e4d2..7ca99ef4e9a7c71af3f4192004b1e33b3cfc58de 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -170,14 +170,32 @@ bool ResemblesMulticastDNSName(const std::string& hostname) {
}
// Attempts to connect a UDP socket to |dest|:80.
-int AttemptRoute(const IPAddressNumber& dest) {
+bool IsGloballyReachable(const IPAddressNumber& dest) {
scoped_ptr<DatagramClientSocket> socket(
ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket(
DatagramSocket::DEFAULT_BIND,
RandIntCallback(),
NULL,
NetLog::Source()));
- return socket->Connect(IPEndPoint(dest, 80));
+ int rv = socket->Connect(IPEndPoint(dest, 80));
+ if (rv != OK)
+ return false;
+ IPEndPoint endpoint;
+ rv = socket->GetLocalAddress(&endpoint);
+ if (rv != OK)
+ return false;
+ DCHECK(endpoint.GetFamily() == ADDRESS_FAMILY_IPV6);
+ const IPAddressNumber& address = endpoint.address();
+ bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80);
+ if (is_link_local)
+ return false;
+ const uint8 kTeredoPrefix[] = { 0x20, 0x01, 0, 0 };
+ bool is_teredo = std::equal(kTeredoPrefix,
+ kTeredoPrefix + arraysize(kTeredoPrefix),
+ address.begin());
+ if (is_teredo)
+ return false;
+ return true;
}
// Provide a common macro to simplify code and readability. We must use a
@@ -2033,12 +2051,12 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
const uint8 kIPv6Address[] =
{ 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 };
- int rv6 = AttemptRoute(
+ bool rv6 = IsGloballyReachable(
IPAddressNumber(kIPv6Address, kIPv6Address + arraysize(kIPv6Address)));
UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration",
base::TimeTicks::Now() - start_time);
- if (rv6 == OK) {
+ if (rv6) {
UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch",
default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698