]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
selection: force resolution of new NS name after lame delegation
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Wed, 20 Jan 2021 15:19:18 +0000 (16:19 +0100)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Mon, 25 Jan 2021 14:42:55 +0000 (15:42 +0100)
Lame delegations are weird, they breed more lame delegations on broken
zones since trying another server from the same set usualy doesn't help.
We force resolution of another NS name in hope of getting somewhere.

lib/selection.c
lib/selection.h
lib/selection_iter.c

index 239015897b905c0f6b7acb2ef04add2d9368a623..e0266404a71cdc5019111ed83a3a6844fb209d8f 100644 (file)
@@ -549,10 +549,20 @@ void error(struct kr_query *qry, struct address_state *addr_state,
                        qry->flags.NO_MINIMIZE = true;
                }
                break;
+       case KR_SELECTION_LAME_DELEGATION:
+               if (qry->flags.NO_MINIMIZE) {
+                       /* Lame delegations are weird, they breed more lame delegations on broken
+                       * zones since trying another server from the same set usualy doesn't help.
+                       * We force resolution of another NS name in hope of getting somewhere. */
+                       qry->server_selection.local_state->force_resolve = true;
+                       addr_state->broken = true;
+               } else {
+                       qry->flags.NO_MINIMIZE = true;
+               }
+               break;
        case KR_SELECTION_NOTIMPL:
        case KR_SELECTION_OTHER_RCODE:
        case KR_SELECTION_DNSSEC_ERROR:
-       case KR_SELECTION_LAME_DELEGATION:
        case KR_SELECTION_BAD_CNAME:
        case KR_SELECTION_MALFORMED:
                /* These errors are fatal, no point in trying this server again. */
index c4268b0f3d9a31e7e5e7a1b9702133885b8ad487..46fad61d96b42f149c5b0075165ddef8cccb432b 100644 (file)
@@ -77,6 +77,9 @@ struct kr_transport {
 struct local_state {
        int timeouts; /**< Number of timeouts that occured resolving this query.*/
        bool truncated; /**< Query was truncated, switch to TCP. */
+       /** Force resolution of a new NS name (if possible)
+        * Done by selection.c:error in some cases. */
+       bool force_resolve;
        void *private; /**< Inner state of the implementation.*/
 };
 
index f7727c62082ce6879d274f47ea227f801fd12057..7596711cd7b99fbd7833e02cdb8f331150cd4002 100644 (file)
@@ -249,6 +249,11 @@ void iter_choose_transport(struct kr_query *qry, struct kr_transport **transport
        int choices_len = get_valid_addresses(local_state, choices);
        int resolvable_len = get_resolvable_names(local_state, resolvable, qry);
 
+       if (qry->server_selection.local_state->force_resolve && resolvable_len) {
+               choices_len = 0;
+               qry->server_selection.local_state->force_resolve = false;
+       }
+
        bool tcp = qry->flags.TCP || qry->server_selection.local_state->truncated;
        *transport = select_transport(choices, choices_len, resolvable, resolvable_len,
                                      qry->server_selection.local_state->timeouts,