Commit e96bf1f3 authored by Diego dos Santos Fronza's avatar Diego dos Santos Fronza
Browse files

Merge branch '2247-add-serve-stale-option-to-set-client-timeout' into 'main'

Resolve "Add serve-stale option to set client timeout"

Closes #2247

See merge request !4514
parents 91acd207 d8c6655d
Pipeline #62084 failed with stages
in 158 minutes and 7 seconds
5566. [func] Add "stale-answer-client-timeout" option, which
is the amount of time a recursive resolver waits before
attempting to answer the query using stale data from cache.
[GL #2247]
5565. [func] The SONAMEs for BIND 9 libraries now include the current
BIND 9 version number, in an effort to tightly couple
internal libraries with a specific release. [GL #2387]
......
......@@ -194,9 +194,10 @@ options {\n\
servfail-ttl 1;\n\
# sortlist <none>\n\
stale-answer-enable false;\n\
stale-refresh-time 30; /* 30 seconds */\n\
stale-answer-client-timeout 1800; /* in milliseconds */\n\
stale-answer-ttl 30; /* 30 seconds */\n\
stale-cache-enable false;\n\
stale-refresh-time 30; /* 30 seconds */\n\
synth-from-dnssec no;\n\
# topology <none>\n\
transfer-format many-answers;\n\
......
......@@ -403,6 +403,7 @@ OPTIONS
sig-validity-interval integer [ integer ];
sortlist { address_match_element; ... };
stacksize ( default | unlimited | sizeval );
stale-answer-client-timeout ( disabled | off | integer );
stale-answer-enable boolean;
stale-answer-ttl duration;
stale-cache-enable boolean;
......@@ -806,6 +807,7 @@ VIEW
sig-signing-type integer;
sig-validity-interval integer [ integer ];
sortlist { address_match_element; ... };
stale-answer-client-timeout ( disabled | off | integer );
stale-answer-enable boolean;
stale-answer-ttl duration;
stale-cache-enable boolean;
......
......@@ -4485,6 +4485,23 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
view->staleanswersok = dns_stale_answer_conf;
}
obj = NULL;
result = named_config_get(maps, "stale-answer-client-timeout", &obj);
INSIST(result == ISC_R_SUCCESS);
if (cfg_obj_isstring(obj)) {
/*
* The only string values available for this option
* are "disabled" and "off".
* We use (uint32_t) -1 to represent disabled since
* a value of zero means that stale data can be used
* to promptly answer the query, while an attempt to
* refresh the RRset will still be made in background.
*/
view->staleanswerclienttimeout = (uint32_t)-1;
} else {
view->staleanswerclienttimeout = cfg_obj_asuint32(obj);
}
obj = NULL;
result = named_config_get(maps, "stale-refresh-time", &obj);
INSIST(result == ISC_R_SUCCESS);
......@@ -4774,6 +4791,27 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
query_timeout = cfg_obj_asuint32(obj);
dns_resolver_settimeout(view->resolver, query_timeout);
/*
* Adjust stale-answer-client-timeout upper bound
* to be resolver-query-timeout - 1s.
* This assignment is safe as dns_resolver_settimeout()
* ensures that resolver->querytimeout value will be in the
* [MINIMUM_QUERY_TIMEOUT, MAXIMUM_QUERY_TIMEOUT] range and
* MINIMUM_QUERY_TIMEOUT is > 1000 (in ms).
*/
if (view->staleanswerclienttimeout != (uint32_t)-1 &&
view->staleanswerclienttimeout >
(dns_resolver_gettimeout(view->resolver) - 1000))
{
view->staleanswerclienttimeout =
dns_resolver_gettimeout(view->resolver) - 1000;
isc_log_write(
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
"stale-answer-client-timeout adjusted to %" PRIu32,
view->staleanswerclienttimeout);
}
/* Specify whether to use 0-TTL for negative response for SOA query */
dns_resolver_setzeronosoattl(view->resolver, zero_no_soattl);
......
......@@ -15,3 +15,4 @@ rm -f */named.run */named.memstats
rm -f ns*/managed-keys.bind*
rm -f ns*/named_dump*
rm -f ns*/named.stats*
rm -f ns*/named.run.prev
......@@ -30,6 +30,7 @@ options {
max-stale-ttl 3600;
stale-answer-ttl 4;
stale-answer-enable yes;
stale-answer-client-timeout disabled;
stale-cache-enable yes;
stale-refresh-time 30;
servfail-ttl 0;
......
......@@ -30,6 +30,7 @@ options {
max-stale-ttl 20;
stale-answer-ttl 3;
stale-answer-enable yes;
stale-answer-client-timeout disabled;
stale-cache-enable yes;
servfail-ttl 0;
};
......
......@@ -30,6 +30,7 @@ options {
max-stale-ttl 20;
stale-answer-ttl 3;
stale-answer-enable yes;
stale-answer-client-timeout disabled;
stale-cache-enable yes;
stale-refresh-time 0;
servfail-ttl 0;
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*
* Test default stale-answer-client-timeout value
*/
key rndc_key {
secret "1234abcd8765";
algorithm hmac-sha256;
};
controls {
inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
options {
query-source address 10.53.0.3;
notify-source 10.53.0.3;
transfer-source 10.53.0.3;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.3; };
listen-on-v6 { none; };
dnssec-validation no;
recursion yes;
stale-answer-enable yes;
stale-cache-enable yes;
stale-answer-ttl 3;
stale-refresh-time 0;
max-stale-ttl 3600;
resolver-query-timeout 10;
};
zone "." {
type secondary;
primaries { 10.53.0.1; };
file "root.bk";
};
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*
* Test disable of stale-answer-client-timeout.
*/
key rndc_key {
secret "1234abcd8765";
algorithm hmac-sha256;
};
controls {
inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
options {
query-source address 10.53.0.3;
notify-source 10.53.0.3;
transfer-source 10.53.0.3;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.3; };
listen-on-v6 { none; };
dnssec-validation no;
recursion yes;
stale-answer-enable yes;
stale-cache-enable yes;
stale-answer-ttl 3;
stale-answer-client-timeout off;
stale-refresh-time 0;
max-stale-ttl 3600;
resolver-query-timeout 10;
};
zone "." {
type hint;
file "root.db";
};
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*
* Test stale-answer-client-timeout 0.
*/
key rndc_key {
secret "1234abcd8765";
algorithm hmac-sha256;
};
controls {
inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
options {
query-source address 10.53.0.3;
notify-source 10.53.0.3;
transfer-source 10.53.0.3;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.3; };
listen-on-v6 { none; };
dnssec-validation no;
recursion yes;
stale-answer-enable yes;
stale-cache-enable yes;
stale-answer-ttl 3;
stale-answer-client-timeout 0;
stale-refresh-time 0;
resolver-query-timeout 10;
max-stale-ttl 3600;
};
zone "." {
type hint;
file "root.db";
};
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*
* Test stale-answer-client-timeout 0.
*/
key rndc_key {
secret "1234abcd8765";
algorithm hmac-sha256;
};
controls {
inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
options {
query-source address 10.53.0.3;
notify-source 10.53.0.3;
transfer-source 10.53.0.3;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.3; };
listen-on-v6 { none; };
dnssec-validation no;
recursion yes;
stale-answer-enable yes;
stale-cache-enable yes;
stale-answer-ttl 3;
stale-answer-client-timeout 0;
stale-refresh-time 4;
resolver-query-timeout 10;
max-stale-ttl 3600;
};
zone "." {
type hint;
file "root.db";
};
; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;
; See the COPYRIGHT file distributed with this work for additional
; information regarding copyright ownership.
. 300 NS ns.nil.
ns.nil. 300 A 10.53.0.1
This diff is collapsed.
......@@ -1832,6 +1832,20 @@ Boolean Options
Information about stale answers is logged under the ``serve-stale``
log category.
``stale-answer-client-timeout``
This option defines the amount of time ``named`` waits before attempting to
answer the query with a stale RRset from cache. If a stale answer is found,
``named`` continues the ongoing fetches, attempting to refresh the RRset in
cache until the ``resolver-query-timeout`` interval is reached.
The default value is ``1800`` (in milliseconds) and the maximum value is
bounded to ``resolver-query-timeout`` minus one second. A value of ``0``
immediately returns a cached RRset if available, and still attempts a refresh
of the data in cache.
The option can be disabled by setting the value to ``off`` or ``disabled``.
It also has no effect if ``stale-answer-enable`` is disabled.
``stale-cache-enable``
If ``yes``, enable the retaining of "stale" cached answers. Default ``no``.
......
......@@ -466,6 +466,7 @@ options {
sig\-validity\-interval integer [ integer ];
sortlist { address_match_element; ... };
stacksize ( default | unlimited | sizeval );
stale\-answer\-client\-timeout ( disabled | off | integer );
stale\-answer\-enable boolean;
stale\-answer\-ttl duration;
stale\-cache\-enable boolean;
......@@ -901,6 +902,7 @@ view string [ class ] {
sig\-signing\-type integer;
sig\-validity\-interval integer [ integer ];
sortlist { address_match_element; ... };
stale\-answer\-client\-timeout ( disabled | off | integer );
stale\-answer\-enable boolean;
stale\-answer\-ttl duration;
stale\-cache\-enable boolean;
......
......@@ -333,6 +333,7 @@ options {
sig-validity-interval <integer> [ <integer> ];
sortlist { <address_match_element>; ... };
stacksize ( default | unlimited | <sizeval> );
stale-answer-client-timeout ( disabled | off | <integer> );
stale-answer-enable <boolean>;
stale-answer-ttl <duration>;
stale-cache-enable <boolean>;
......@@ -696,6 +697,7 @@ view <string> [ <class> ] {
sig-signing-type <integer>;
sig-validity-interval <integer> [ <integer> ];
sortlist { <address_match_element>; ... };
stale-answer-client-timeout ( disabled | off | <integer> );
stale-answer-enable <boolean>;
stale-answer-ttl <duration>;
stale-cache-enable <boolean>;
......
......@@ -331,6 +331,7 @@ options {
sig-validity-interval <integer> [ <integer> ];
sortlist { <address_match_element>; ... };
stacksize ( default | unlimited | <sizeval> );
stale-answer-client-timeout ( disabled | off | <integer> );
stale-answer-enable <boolean>;
stale-answer-ttl <duration>;
stale-cache-enable <boolean>;
......@@ -692,6 +693,7 @@ view <string> [ <class> ] {
sig-signing-type <integer>;
sig-validity-interval <integer> [ <integer> ];
sortlist { <address_match_element>; ... };
stale-answer-client-timeout ( disabled | off | <integer> );
stale-answer-enable <boolean>;
stale-answer-ttl <duration>;
stale-cache-enable <boolean>;
......
......@@ -259,6 +259,7 @@
sig-validity-interval <integer> [ <integer> ];
sortlist { <address_match_element>; ... };
stacksize ( default | unlimited | <sizeval> );
stale-answer-client-timeout ( disabled | off | <integer> );
stale-answer-enable <boolean>;
stale-answer-ttl <duration>;
stale-cache-enable <boolean>;
......
......@@ -26,6 +26,23 @@ New Features
- None.
- A new option, ```stale-answer-client-timeout``, has been added to
improve ``named``'s behavior with respect to serving stale data. The option
defines the amount of time ``named`` waits before attempting
to answer the query with a stale RRset from cache. If a stale answer
is found, ``named`` continues the ongoing fetches, attempting to
refresh the RRset in cache until the ``resolver-query-timeout`` interval is
reached.
The default value is ``1800`` (in milliseconds) and the maximum value is
bounded to ``resolver-query-timeout`` minus one second. A value of
``0`` immediately returns a cached RRset if available, and still
attempts a refresh of the data in cache.
The option can be disabled by setting the value to ``off`` or
``disabled``. It also has no effect if ``stale-answer-enable`` is
disabled.
Removed Features
~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment