Commit a97831b2 authored by Miriam Gershenson's avatar Miriam Gershenson Committed by Commit Bot

Disable async DNS if VPN is present on L and earlier

The DnsConfigService can't get a correct DNS config for a VPN until
Android M. On earlier versions, check for a VPN and treat it as a config
read failure.

Bug: 805020
Change-Id: I696c52a2e012460ddd70381e5278c3abca9ca665
Reviewed-on: https://chromium-review.googlesource.com/894149Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Miriam Gershenson <mgersh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533287}
parent bef7bc21
......@@ -437,9 +437,14 @@ void AddressTrackerLinux::CloseSocket() {
}
bool AddressTrackerLinux::IsTunnelInterface(int interface_index) const {
// Linux kernel drivers/net/tun.c uses "tun" name prefix.
char buf[IFNAMSIZ] = {0};
return strncmp(get_interface_name_(interface_index, buf), "tun", 3) == 0;
return IsTunnelInterfaceName(get_interface_name_(interface_index, buf));
}
// static
bool AddressTrackerLinux::IsTunnelInterfaceName(const char* name) {
// Linux kernel drivers/net/tun.c uses "tun" name prefix.
return strncmp(name, "tun", 3) == 0;
}
void AddressTrackerLinux::UpdateCurrentConnectionType() {
......
......@@ -82,6 +82,9 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux :
// with exclusively talking to the kernel and not the C library.
static char* GetInterfaceName(int interface_index, char* buf);
// Does |name| refer to a tunnel interface?
static bool IsTunnelInterfaceName(const char* name);
private:
friend class AddressTrackerLinuxTest;
......
......@@ -736,6 +736,11 @@ TEST_F(AddressTrackerLinuxTest, BroadcastInit) {
runner2.VerifyCompletes();
}
TEST_F(AddressTrackerLinuxTest, TunnelInterfaceName) {
EXPECT_TRUE(AddressTrackerLinux::IsTunnelInterfaceName("tun0"));
EXPECT_FALSE(AddressTrackerLinux::IsTunnelInterfaceName("wlan0"));
}
} // namespace
} // namespace internal
......
......@@ -35,7 +35,9 @@
#include <sys/system_properties.h>
#include "base/android/build_info.h"
#include "net/android/network_library.h"
#include "net/base/address_tracker_linux.h"
#include "net/base/network_change_notifier.h"
#include "net/base/network_interfaces.h"
#endif
namespace net {
......@@ -118,6 +120,20 @@ class DnsConfigWatcher {
};
#endif // defined(OS_IOS)
#if defined(OS_ANDROID)
bool IsVpnPresent() {
NetworkInterfaceList networks;
if (!GetNetworkList(&networks, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES))
return false;
for (NetworkInterface network : networks) {
if (AddressTrackerLinux::IsTunnelInterfaceName(network.name.c_str()))
return true;
}
return false;
}
#endif // defined(OS_ANDROID)
ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) {
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
#if !defined(OS_ANDROID)
......@@ -184,6 +200,11 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) {
return CONFIG_PARSE_POSIX_OK;
}
if (IsVpnPresent()) {
dns_config->unhandled_options = true;
return CONFIG_PARSE_POSIX_UNHANDLED_OPTIONS;
}
char property_value[PROP_VALUE_MAX];
__system_property_get("net.dns1", property_value);
std::string dns1_string = property_value;
......
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