summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-08 02:46:59 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-11 19:40:00 +0100
commit571370c1555d2aa697733479a50957aff024bbcb (patch)
tree07ed30f3c1ac6e956448e32f9aa770d757583e13
parent7e1851e3c62147794b4b0104ba776453d8945a39 (diff)
resolved: when we get a packet failure from a server, don't downgrade UDP to TCP or vice versa
Under the assumption that packet failures (i.e. FORMERR, SERVFAIL, NOTIMP) are caused by packet contents, not used transport, we shouldn't switch between UDP and TCP when we get them, but only downgrade the higher levels down to UDP.
-rw-r--r--src/resolve/resolved-dns-server.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 0de6c8cec0..1600e7c292 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -277,6 +277,14 @@ void dns_server_packet_failed(DnsServer *s, DnsServerFeatureLevel level) {
if (s->possible_feature_level != level)
return;
+ /* Invoked whenever we get a FORMERR, SERVFAIL or NOTIMP rcode from a server. This is an immediate trigger for
+ * us to go one feature level down. Except when we are already at TCP or UDP level, in which case there's no
+ * point in changing, under the assumption that packet failures are caused by packet contents, not by used
+ * transport. */
+
+ if (s->possible_feature_level <= DNS_SERVER_FEATURE_LEVEL_UDP)
+ return;
+
s->n_failed_attempts = (unsigned) -1;
}