Commit c9fa8f31 authored by szym@chromium.org's avatar szym@chromium.org

[net/dns] Treat Name Resolution Policy Table as unhandled option.

Also, conservatively assume that non-empty NRPT or unknown DnsConfig could mean
DirectAccess is used, and disable IPv6 probing in that case.

BUG=259792

Review URL: https://chromiumcodereview.appspot.com/23522036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223595 0039d316-1c4b-4281-b951-d872f2087c98
parent a6751cc0
......@@ -1632,14 +1632,8 @@ EVENT_TYPE(NETWORK_CHANGED)
// {
// "nameservers": <List of name server IPs>,
// "search": <List of domain suffixes>,
// "unhandled_options": <See DnsConfig>,
// "append_to_multi_label_name": <See DnsConfig>,
// "ndots": <See DnsConfig>,
// "timeout": <See DnsConfig>,
// "attempts": <See DnsConfig>,
// "rotate": <See DnsConfig>,
// "edns0": <See DnsConfig>,
// "num_hosts": <Number of entries in the HOSTS file>
// "num_hosts": <Number of entries in the HOSTS file>,
// <other>: <See DnsConfig>
// }
EVENT_TYPE(DNS_CONFIG_CHANGED)
......
......@@ -21,7 +21,8 @@ DnsConfig::DnsConfig()
timeout(base::TimeDelta::FromSeconds(kDnsTimeoutSeconds)),
attempts(2),
rotate(false),
edns0(false) {}
edns0(false),
use_local_ipv6(false) {}
DnsConfig::~DnsConfig() {}
......@@ -38,7 +39,8 @@ bool DnsConfig::EqualsIgnoreHosts(const DnsConfig& d) const {
(timeout == d.timeout) &&
(attempts == d.attempts) &&
(rotate == d.rotate) &&
(edns0 == d.edns0);
(edns0 == d.edns0) &&
(use_local_ipv6 == d.use_local_ipv6);
}
void DnsConfig::CopyIgnoreHosts(const DnsConfig& d) {
......@@ -51,6 +53,7 @@ void DnsConfig::CopyIgnoreHosts(const DnsConfig& d) {
attempts = d.attempts;
rotate = d.rotate;
edns0 = d.edns0;
use_local_ipv6 = d.use_local_ipv6;
}
base::Value* DnsConfig::ToValue() const {
......@@ -73,6 +76,7 @@ base::Value* DnsConfig::ToValue() const {
dict->SetInteger("attempts", attempts);
dict->SetBoolean("rotate", rotate);
dict->SetBoolean("edns0", edns0);
dict->SetBoolean("use_local_ipv6", use_local_ipv6);
dict->SetInteger("num_hosts", hosts.size());
return dict;
......
......@@ -83,6 +83,11 @@ struct NET_EXPORT_PRIVATE DnsConfig {
bool rotate;
// Enable EDNS0 extensions.
bool edns0;
// Indicates system configuration uses local IPv6 connectivity, e.g.,
// DirectAccess. This is exposed for HostResolver to skip IPv6 probes,
// as it may cause them to return incorrect results.
bool use_local_ipv6;
};
......
This diff is collapsed.
......@@ -34,19 +34,6 @@ namespace net {
namespace internal {
// Registry key paths.
const wchar_t* const kTcpipPath =
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
const wchar_t* const kTcpip6Path =
L"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters";
const wchar_t* const kDnscachePath =
L"SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters";
const wchar_t* const kPolicyPath =
L"SOFTWARE\\Policies\\Microsoft\\Windows NT\\DNSClient";
// Returns the path to the HOSTS file.
base::FilePath GetHostsPath();
// Parses |value| as search list (comma-delimited list of domain names) from
// a registry key and stores it in |out|. Returns true on success. Empty
// entries (e.g., "chromium.org,,org") terminate the list. Non-ascii hostnames
......@@ -98,6 +85,10 @@ struct NET_EXPORT_PRIVATE DnsSystemSettings {
// SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\AppendToMultiLabelName
RegDword append_to_multi_label_name;
// True when the Name Resolution Policy Table (NRPT) has at least one rule:
// SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\DnsPolicyConfig\Rule*
bool have_name_resolution_policy;
};
enum ConfigParseWinResult {
......@@ -113,6 +104,7 @@ enum ConfigParseWinResult {
CONFIG_PARSE_WIN_READ_PRIMARY_SUFFIX,
CONFIG_PARSE_WIN_BAD_ADDRESS,
CONFIG_PARSE_WIN_NO_NAMESERVERS,
CONFIG_PARSE_WIN_UNHANDLED_OPTIONS,
CONFIG_PARSE_WIN_MAX // Bounding values for enumeration.
};
......
......@@ -4,6 +4,7 @@
#include "net/dns/dns_config_service_win.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/win/windows_version.h"
#include "net/dns/dns_protocol.h"
......@@ -420,10 +421,46 @@ TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) {
DnsConfig config;
EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK,
internal::ConvertSettingsToDnsConfig(settings, &config));
EXPECT_EQ(config.append_to_multi_label_name, t.expected_output);
EXPECT_EQ(t.expected_output, config.append_to_multi_label_name);
}
}
// Setting have_name_resolution_policy_table should set unhandled_options.
TEST(DnsConfigServiceWinTest, HaveNRPT) {
AdapterInfo infos[2] = {
{ IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } },
{ 0 },
};
const struct TestCase {
bool have_nrpt;
bool unhandled_options;
internal::ConfigParseWinResult result;
} cases[] = {
{ false, false, internal::CONFIG_PARSE_WIN_OK },
{ true, true, internal::CONFIG_PARSE_WIN_UNHANDLED_OPTIONS },
};
for (size_t i = 0; i < arraysize(cases); ++i) {
const TestCase& t = cases[i];
internal::DnsSystemSettings settings = {
CreateAdapterAddresses(infos),
{ false }, { false }, { false }, { false },
{ { false }, { false } },
{ { false }, { false } },
{ { false }, { false } },
{ false },
t.have_nrpt,
};
DnsConfig config;
EXPECT_EQ(t.result,
internal::ConvertSettingsToDnsConfig(settings, &config));
EXPECT_EQ(t.unhandled_options, config.unhandled_options);
EXPECT_EQ(t.have_nrpt, config.use_local_ipv6);
}
}
} // namespace
} // namespace net
......
......@@ -1799,6 +1799,7 @@ HostResolverImpl::HostResolverImpl(
received_dns_config_(false),
num_dns_failures_(0),
probe_ipv6_support_(true),
use_local_ipv6_(false),
resolved_known_ipv6_hostname_(false),
additional_resolver_flags_(0),
fallback_to_proctask_(true) {
......@@ -1824,12 +1825,12 @@ HostResolverImpl::HostResolverImpl(
EnsureDnsReloaderInit();
#endif
// TODO(szym): Remove when received_dns_config_ is removed, once
// http://crbug.com/137914 is resolved.
{
DnsConfig dns_config;
NetworkChangeNotifier::GetDnsConfig(&dns_config);
received_dns_config_ = dns_config.IsValid();
// Conservatively assume local IPv6 is needed when DnsConfig is not valid.
use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6;
}
fallback_to_proctask_ = !ConfigureAsyncDnsNoFallbackFieldTrial();
......@@ -2142,7 +2143,7 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
AddressFamily effective_address_family = info.address_family();
if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) {
if (probe_ipv6_support_) {
if (probe_ipv6_support_ && !use_local_ipv6_) {
base::TimeTicks start_time = base::TimeTicks::Now();
// Google DNS address.
const uint8 kIPv6Address[] =
......@@ -2266,6 +2267,8 @@ void HostResolverImpl::OnDNSChanged() {
// TODO(szym): Remove once http://crbug.com/137914 is resolved.
received_dns_config_ = dns_config.IsValid();
// Conservatively assume local IPv6 is needed when DnsConfig is not valid.
use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6;
num_dns_failures_ = 0;
......
......@@ -279,6 +279,10 @@ class NET_EXPORT HostResolverImpl
// explicit setting in |default_address_family_| is used.
bool probe_ipv6_support_;
// True if DnsConfigService detected that system configuration depends on
// local IPv6 connectivity. Disables probing.
bool use_local_ipv6_;
// True iff ProcTask has successfully resolved a hostname known to have IPv6
// addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change.
bool resolved_known_ipv6_hostname_;
......
......@@ -18389,6 +18389,7 @@ other types of suffix sets.
<int value="9" label="READ_PRIMARY_SUFFIX"/>
<int value="10" label="BAD_ADDRESS"/>
<int value="11" label="NO_NAMESERVERS"/>
<int value="12" label="UNHANDLED_OPTIONS"/>
</enum>
<enum name="AsyncDNSHostsParseWin" type="int">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment