]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix rtt assignement for low values of infra-cache-max-rtt (#1070)
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Thu, 16 May 2024 11:42:32 +0000 (13:42 +0200)
committerGitHub <noreply@github.com>
Thu, 16 May 2024 11:42:32 +0000 (13:42 +0200)
* Fix rtt assignement for still useful servers when a low value for
  infra-cache-max-rtt is configured.

iterator/iter_utils.c
services/cache/infra.c

index f291178d231957fe7e76ccf40e5851bcccbd9e8d..1b4f5f6ebb4f87708cd1bdba907dc64599647c6f 100644 (file)
@@ -279,9 +279,10 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
                name, namelen, qtype, &lame, &dnsseclame, &reclame,
                &rtt, now)) {
                log_addr(VERB_ALGO, "servselect", &a->addr, a->addrlen);
-               verbose(VERB_ALGO, "   rtt=%d%s%s%s%s", rtt,
+               verbose(VERB_ALGO, "   rtt=%d%s%s%s%s%s", rtt,
                        lame?" LAME":"",
                        dnsseclame?" DNSSEC_LAME":"",
+                       a->dnsseclame?" ADDR_DNSSEC_LAME":"",
                        reclame?" REC_LAME":"",
                        a->lame?" ADDR_LAME":"");
                if(lame)
index 457685ab59853688e27c0d843f4ea4e3d9ded1c3..1afa57e97f425a3bd0519bc85964512b39061d68 100644 (file)
  * can do this number of packets (until those all timeout too) */
 #define TIMEOUT_COUNT_MAX 3
 
+/** Minus 1000 because that is outside of the RTTBAND, so
+ * blacklisted servers stay blacklisted if this is chosen.
+ * If USEFUL_SERVER_TOP_TIMEOUT is below 1000 (configured via RTT_MAX_TIMEOUT,
+ * infra-cache-max-rtt) change it to just above the RTT_BAND. */
+#define STILL_USEFUL_TIMEOUT (                         \
+       USEFUL_SERVER_TOP_TIMEOUT < 1000 ||             \
+       USEFUL_SERVER_TOP_TIMEOUT - 1000 <= RTT_BAND    \
+               ?RTT_BAND + 1                           \
+               :USEFUL_SERVER_TOP_TIMEOUT - 1000)
+
 /** ratelimit value for delegation point */
 int infra_dp_ratelimit = 0;
 
@@ -656,7 +666,7 @@ infra_update_tcp_works(struct infra_cache* infra,
        if(data->rtt.rto >= RTT_MAX_TIMEOUT)
                /* do not disqualify this server altogether, it is better
                 * than nothing */
-               data->rtt.rto = RTT_MAX_TIMEOUT-1000;
+               data->rtt.rto = STILL_USEFUL_TIMEOUT;
        lock_rw_unlock(&e->lock);
 }
 
@@ -796,7 +806,7 @@ infra_get_lame_rtt(struct infra_cache* infra,
                && infra->infra_keep_probing) {
                /* single probe, keep probing */
                if(*rtt >= USEFUL_SERVER_TOP_TIMEOUT)
-                       *rtt = USEFUL_SERVER_TOP_TIMEOUT-1000;
+                       *rtt = STILL_USEFUL_TIMEOUT;
        } else if(host->rtt.rto >= PROBE_MAXRTO && timenow < host->probedelay
                && rtt_notimeout(&host->rtt)*4 <= host->rtt.rto) {
                /* single probe for this domain, and we are not probing */
@@ -804,26 +814,23 @@ infra_get_lame_rtt(struct infra_cache* infra,
                if(qtype == LDNS_RR_TYPE_A) {
                        if(host->timeout_A >= TIMEOUT_COUNT_MAX)
                                *rtt = USEFUL_SERVER_TOP_TIMEOUT;
-                       else    *rtt = USEFUL_SERVER_TOP_TIMEOUT-1000;
+                       else    *rtt = STILL_USEFUL_TIMEOUT;
                } else if(qtype == LDNS_RR_TYPE_AAAA) {
                        if(host->timeout_AAAA >= TIMEOUT_COUNT_MAX)
                                *rtt = USEFUL_SERVER_TOP_TIMEOUT;
-                       else    *rtt = USEFUL_SERVER_TOP_TIMEOUT-1000;
+                       else    *rtt = STILL_USEFUL_TIMEOUT;
                } else {
                        if(host->timeout_other >= TIMEOUT_COUNT_MAX)
                                *rtt = USEFUL_SERVER_TOP_TIMEOUT;
-                       else    *rtt = USEFUL_SERVER_TOP_TIMEOUT-1000;
+                       else    *rtt = STILL_USEFUL_TIMEOUT;
                }
        }
        /* expired entry */
        if(timenow > host->ttl) {
-
                /* see if this can be a re-probe of an unresponsive server */
-               /* minus 1000 because that is outside of the RTTBAND, so
-                * blacklisted servers stay blacklisted if this is chosen */
                if(host->rtt.rto >= USEFUL_SERVER_TOP_TIMEOUT) {
                        lock_rw_unlock(&e->lock);
-                       *rtt = USEFUL_SERVER_TOP_TIMEOUT-1000;
+                       *rtt = STILL_USEFUL_TIMEOUT;
                        *lame = 0;
                        *dnsseclame = 0;
                        *reclame = 0;