shill: resolver: Use (even) smaller DNS timeout
Use the new glibc facility for sub-second timeouts, and choose
300 milliseconds for the timeout. However, only do this by
default for Ethernet and WiFi networks, since VPN networks
in particular have trouble with this configuration (due to many
name servers and search domains, as well as the additional
latency inherent to such networks). Also, increase the number
of attempts, so we still spend a reasonable amount of time
overall waiting for a DNS response.
Provide a means to change which technologies are setup in this
manner.
BUG=chromium-os:29124
TEST=Manual: Install connection manager, verify via strace that
gethostbyname now waits 300 ms, and retries 15 times per trial (*).
Ensure Chromium continues to work correctly under light loads.
Also, connect via Verizon and VPN and ensure DNS parameters
are back to the long timeout.
List manager properties and ensure it says "ethernet,wifi" for
ShortDNSTimeoutTechnologies and that this is saved out to the
profile.
New unit tests.
CQ-DEPENDS=Ib9ffc59bbfcd5bf3f57d146965c5a43a936348f8
*: Each trial consists of a nameserver / IP address pair, so
for example, if we have IPv6 connectivity and have two "server"
entries in resolv.conf, we first do 30 tries of IPv6 requests,
alternating between the two servers, then another 30 alternating
IPv4 requests between them. This was tested by intentionally
making the DNS server unreachable and instrumenting the gethostbyname
request via strace.
Change-Id: Idd331b4a9fcf96d457ab9959537aefcb86328e12
Reviewed-on: https://gerrit.chromium.org/gerrit/26493
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/default_profile_unittest.cc b/default_profile_unittest.cc
index adbe161..4271401 100644
--- a/default_profile_unittest.cc
+++ b/default_profile_unittest.cc
@@ -22,6 +22,7 @@
#include "shill/mock_store.h"
#include "shill/portal_detector.h"
#include "shill/property_store_unittest.h"
+#include "shill/resolver.h"
using std::map;
using std::string;
@@ -131,6 +132,11 @@
DefaultProfile::kStoragePortalCheckInterval,
"0"))
.WillOnce(Return(true));
+ EXPECT_CALL(*storage.get(),
+ SetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageShortDNSTimeoutTechnologies,
+ ""))
+ .WillOnce(Return(true));
EXPECT_CALL(*storage.get(), Flush()).WillOnce(Return(true));
EXPECT_CALL(*device_.get(), Save(storage.get())).Times(0);
@@ -169,6 +175,11 @@
DefaultProfile::kStoragePortalCheckInterval,
_))
.WillOnce(Return(false));
+ EXPECT_CALL(*storage.get(),
+ GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageShortDNSTimeoutTechnologies,
+ _))
+ .WillOnce(Return(false));
profile_->set_storage(storage.release());
ASSERT_TRUE(profile_->LoadManagerProperties(&manager_props));
@@ -180,6 +191,8 @@
EXPECT_EQ(PortalDetector::kDefaultURL, manager_props.portal_url);
EXPECT_EQ(PortalDetector::kDefaultCheckIntervalSeconds,
manager_props.portal_check_interval_seconds);
+ EXPECT_EQ(Resolver::kDefaultShortTimeoutTechnologies,
+ manager_props.short_dns_timeout_technologies);
}
TEST_F(DefaultProfileTest, LoadManagerProperties) {
@@ -215,6 +228,13 @@
_))
.WillOnce(DoAll(SetArgumentPointee<2>(portal_check_interval_string),
Return(true)));
+ const string short_dns_timeout_technologies("wimax,cellular");
+ EXPECT_CALL(*storage.get(),
+ GetString(DefaultProfile::kStorageId,
+ DefaultProfile::kStorageShortDNSTimeoutTechnologies,
+ _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(short_dns_timeout_technologies),
+ Return(true)));
profile_->set_storage(storage.release());
Manager::Properties manager_props;
@@ -226,6 +246,8 @@
EXPECT_EQ(portal_url, manager_props.portal_url);
EXPECT_EQ(portal_check_interval_int,
manager_props.portal_check_interval_seconds);
+ EXPECT_EQ(short_dns_timeout_technologies,
+ manager_props.short_dns_timeout_technologies);
}
TEST_F(DefaultProfileTest, GetStoragePath) {