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

Unified Diff: net/dns/host_resolver_impl.cc

Issue 2567623003: Make ERR_ICANN_NAME_COLLISION work for async DNS resolver. (Closed)
Patch Set: address Matt's comments Created 4 years 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 | « net/dns/dns_test_util.cc ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | 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 e4ee073591d764edfd0f20e786493da4eef2b7dd..161796e54223a6fe3ecb9aa7f97d0be172050c0d 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -183,6 +183,16 @@ enum DnsResolveStatus {
// For more details: https://www.icann.org/news/announcement-2-2014-08-01-en
const uint8_t kIcanNameCollisionIp[] = {127, 0, 53, 53};
+bool ContainsIcannNameCollisionIp(const AddressList& addr_list) {
+ for (const auto& endpoint : addr_list) {
+ const IPAddress& addr = endpoint.address();
+ if (addr.IsIPv4() && IPAddressStartsWith(addr, kIcanNameCollisionIp)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void UmaAsyncDnsResolveStatus(DnsResolveStatus result) {
UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ResolveStatus",
result,
@@ -739,16 +749,6 @@ class HostResolverImpl::ProcTask
&results,
&os_error);
- // Fail the resolution if the result contains 127.0.53.53. See the comment
- // block of kIcanNameCollisionIp for details on why.
- for (const auto& it : results) {
- const IPAddress& cur = it.address();
- if (cur.IsIPv4() && IPAddressStartsWith(cur, kIcanNameCollisionIp)) {
- error = ERR_ICANN_NAME_COLLISION;
- break;
- }
- }
-
network_task_runner_->PostTask(
FROM_HERE, base::Bind(&ProcTask::OnLookupComplete, this, results,
start_time, attempt_number, error, os_error));
@@ -1619,6 +1619,9 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
}
}
+ if (ContainsIcannNameCollisionIp(addr_list))
+ net_error = ERR_ICANN_NAME_COLLISION;
+
base::TimeDelta ttl =
base::TimeDelta::FromSeconds(kNegativeCacheEntryTTLSeconds);
if (net_error == OK)
@@ -1709,6 +1712,9 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
base::TimeDelta bounded_ttl =
std::max(ttl, base::TimeDelta::FromSeconds(kMinimumTTLSeconds));
+ if (ContainsIcannNameCollisionIp(addr_list))
+ net_error = ERR_ICANN_NAME_COLLISION;
+
CompleteRequests(
HostCache::Entry(net_error, MakeAddressListForRequest(addr_list), ttl),
bounded_ttl);
@@ -1769,7 +1775,7 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
DCHECK(!requests_.empty());
- if (entry.error() == OK) {
+ if (entry.error() == OK || entry.error() == ERR_ICANN_NAME_COLLISION) {
// Record this histogram here, when we know the system has a valid DNS
// configuration.
UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig",
« no previous file with comments | « net/dns/dns_test_util.cc ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698