]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/selection*: try to avoid TCP in STUB mode
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 23 Mar 2021 10:11:44 +0000 (11:11 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 26 Mar 2021 14:40:35 +0000 (15:40 +0100)
The target of STUB might commonly not have good support
for "advanced" features like TCP.

NEWS
lib/selection_forward.c

diff --git a/NEWS b/NEWS
index 839084d656e2b6adeb8383ac19a888dd63e774a3..c8682aba55ccb68bbd5ae93cd9bf1d9dd06e394b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Knot Resolver 5.3.1 (2021-03-dd)
 Improvements
 ------------
 - doh2: send HTTP error status codes (#618, !1102)
+- policy.STUB: try to avoid TCP (compared to 5.3.0; !1155)
 
 Bugfixes
 --------
index 165aa53f445cfd2abd71836d256e8a590f6a04f8..6fa3d743a9bddf8ce3870370222398ad547d4d84 100644 (file)
@@ -86,6 +86,9 @@ void forward_choose_transport(struct kr_query *qry,
                 * says nothing about the network RTT of said target, since
                 * it is doing resolution upstream. */
                (*transport)->timeout = FORWARDING_TIMEOUT;
+               /* Try to avoid TCP in STUB case.  It seems better for common use cases. */
+               if (qry->flags.STUB && !tcp && (*transport)->protocol == KR_TRANSPORT_TCP)
+                       (*transport)->protocol = KR_TRANSPORT_UDP;
                /* We need to propagate this to flags since it's used in other
                 * parts of the resolver (e.g. logging and stats). */
                qry->flags.TCP = tcp;