Chromium Code Reviews| 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..2abab7d52167c39a575949fd966fca27712a8a98 100644 |
| --- a/net/dns/host_resolver_impl.cc |
| +++ b/net/dns/host_resolver_impl.cc |
| @@ -181,7 +181,16 @@ enum DnsResolveStatus { |
| // possible to navigate to http://127.0.53.53/ directly. |
| // |
| // 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) { |
| + static const uint8_t kIcanNameCollisionIp[] = {127, 0, 53, 53}; |
|
mmenke
2016/12/13 19:24:15
I thought not using static was preferred, to ensur
eroman
2016/12/13 22:09:04
Done.
Not sure (I have seen both instances in our
|
| + 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", |
| @@ -739,16 +748,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 +1618,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 +1711,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); |
|
mmenke
2016/12/13 19:24:16
I know this is old behavior, but can we not pass t
eroman
2016/12/13 22:09:04
Correct, I believe that addr_list shouldn't be use
mmenke
2016/12/13 22:14:59
I'm actually not at all concerned about perf here.
eroman
2016/12/13 22:50:18
That's a fair concern.
I will address in a follow-
|
| @@ -1769,7 +1774,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", |