summaryrefslogtreecommitdiffstats
path: root/src/resolve
diff options
context:
space:
mode:
authorKai Krakow <kai@kaishome.de>2017-05-13 12:30:56 +0200
committerLennart Poettering <lennart@poettering.net>2017-06-27 22:04:16 +0200
commit496ae8c84b2d3622bc767a727e3582e2b6bcffcd (patch)
tree83e00059ea9ff8034625f5c565a5d8b36f4d1e36 /src/resolve
parentMerge pull request #5976 from fbuihuu/swap-fix (diff)
downloadsystemd-496ae8c84b2d3622bc767a727e3582e2b6bcffcd.tar.xz
systemd-496ae8c84b2d3622bc767a727e3582e2b6bcffcd.zip
resolved: Recover from slow DNS responses
When DNS is unreliable temporarily, the current implementation will never improve resend behavior again and switch DNS servers only late (current maximum timeout is 5 seconds). We can improve this by biasing the resend_timeout back to the current RTT when a successful response was received. Next time, a timeout is hit on this server, it will switch to the next server faster. Fixes: #5953
Diffstat (limited to '')
-rw-r--r--src/resolve/resolved-dns-server.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 63cb6a5bda..9c3ee0136c 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -304,7 +304,10 @@ void dns_server_packet_received(DnsServer *s, int protocol, DnsServerFeatureLeve
if (s->max_rtt < rtt) {
s->max_rtt = rtt;
s->resend_timeout = CLAMP(s->max_rtt * 2, DNS_TIMEOUT_MIN_USEC, DNS_TIMEOUT_MAX_USEC);
- }
+ } else if (s->resend_timeout > rtt)
+ /* If we received the packet faster than the resend_timeout, bias
+ * the resend_timeout back to the rtt. */
+ s->resend_timeout = CLAMP((2 * s->resend_timeout + rtt) / 3, DNS_TIMEOUT_MIN_USEC, DNS_TIMEOUT_MAX_USEC);
}
void dns_server_packet_lost(DnsServer *s, int protocol, DnsServerFeatureLevel level, usec_t usec) {