]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
wip: don't resolve a new NS name when the resolution seems in trouble
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Wed, 17 Feb 2021 13:15:39 +0000 (14:15 +0100)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Wed, 17 Feb 2021 13:15:39 +0000 (14:15 +0100)
lib/selection.c
lib/selection.h
lib/selection_iter.c

index 1f47e159b602e06b0a1e5bae3848ae60c3e48d0d..ee85efff66968f4f2bcce2812505380e849299dd 100644 (file)
@@ -230,7 +230,7 @@ static void check_tls_capable(struct address_state *address_state,
 /* TODO: uncomment these once we actually use the information it collects. */
 /**
  * Check if there is a existing TCP connection to this address.
- * 
+ *
  * @p req has to have the selection_context properly initiazed.
  */
 void check_tcp_connections(struct address_state *address_state, struct kr_request *req, struct sockaddr *address) {
@@ -534,6 +534,7 @@ void error(struct kr_query *qry, struct address_state *addr_state,
                } else {
                        qry->flags.TCP = true;
                        qry->flags.NO_0X20 = true;
+                       qry->server_selection.local_state->dont_resolve = true;
                }
                break;
        case KR_SELECTION_TRUNCATED:
@@ -587,7 +588,7 @@ void error(struct kr_query *qry, struct address_state *addr_state,
 
        addr_state->error_count++;
        addr_state->errors[sel_error]++;
-       
+
        WITH_VERBOSE(qry)
        {
        KR_DNAME_GET_STR(ns_name, transport->ns_name);
index 59e478bca7c814206a2f5edaf8222300b91ddd0a..7d9208e3f273a8414943ac4510a5eea052efb84d 100644 (file)
@@ -81,6 +81,8 @@ struct local_state {
        /** Force resolution of a new NS name (if possible)
         * Done by selection.c:error in some cases. */
        bool force_resolve;
+       /** Disable resolution of new NS name for the next attempt. */
+       bool dont_resolve;
        void *private; /**< Inner state of the implementation.*/
 };
 
index 61e1080df451042d555e8285e81485c9a532320f..e2a17f90e9117abd146f0a40c3236fc580dc4e32 100644 (file)
@@ -99,7 +99,7 @@ static void unpack_state_from_zonecut(struct iter_local_state *local_state,
                        name_state->a_state = RECORD_UNKNOWN;
                        name_state->aaaa_state = RECORD_UNKNOWN;
                }
-               
+
                /* Iterate over all addresses of this NS (if any). */
                for (uint8_t *obj = pack_head(*addresses); obj != pack_tail(*addresses);
                     obj = pack_obj_next(obj)) {
@@ -254,6 +254,11 @@ void iter_choose_transport(struct kr_query *qry, struct kr_transport **transport
                qry->server_selection.local_state->force_resolve = false;
        }
 
+       if (qry->server_selection.local_state->dont_resolve && choices_len) {
+               resolvable_len = 0;
+               qry->server_selection.local_state->dont_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,