mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Added option for disabling stale-answer-client-timeout
This commit allows to specify "disabled" or "off" in stale-answer-client-timeout statement. The logic to support this behavior will be added in the subsequent commits. This commit also ensures an upper bound to stale-answer-client-timeout which equals to one second less than 'resolver-query-timeout'.
This commit is contained in:
@@ -4488,7 +4488,19 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
||||
obj = NULL;
|
||||
result = named_config_get(maps, "stale-answer-client-timeout", &obj);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
view->staleanswerclienttimeout = cfg_obj_asuint32(obj);
|
||||
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);
|
||||
@@ -4779,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);
|
||||
|
||||
|
@@ -1899,6 +1899,28 @@ static cfg_type_t cfg_type_dns64 = { "dns64", cfg_parse_netprefix_map,
|
||||
cfg_print_map, cfg_doc_map,
|
||||
&cfg_rep_map, dns64_clausesets };
|
||||
|
||||
static const char *staleanswerclienttimeout_enums[] = { "disabled", "off",
|
||||
NULL };
|
||||
static isc_result_t
|
||||
parse_staleanswerclienttimeout(cfg_parser_t *pctx, const cfg_type_t *type,
|
||||
cfg_obj_t **ret) {
|
||||
return (cfg_parse_enum_or_other(pctx, type, &cfg_type_uint32, ret));
|
||||
}
|
||||
|
||||
static void
|
||||
doc_staleanswerclienttimeout(cfg_printer_t *pctx, const cfg_type_t *type) {
|
||||
cfg_doc_enum_or_other(pctx, type, &cfg_type_uint32);
|
||||
}
|
||||
|
||||
static cfg_type_t cfg_type_staleanswerclienttimeout = {
|
||||
"staleanswerclienttimeout",
|
||||
parse_staleanswerclienttimeout,
|
||||
cfg_print_ustring,
|
||||
doc_staleanswerclienttimeout,
|
||||
&cfg_rep_string,
|
||||
staleanswerclienttimeout_enums
|
||||
};
|
||||
|
||||
/*%
|
||||
* Clauses that can be found within the 'view' statement,
|
||||
* with defaults in the 'options' statement.
|
||||
@@ -2027,7 +2049,8 @@ static cfg_clausedef_t view_clauses[] = {
|
||||
{ "servfail-ttl", &cfg_type_duration, 0 },
|
||||
{ "sortlist", &cfg_type_bracketed_aml, 0 },
|
||||
{ "stale-answer-enable", &cfg_type_boolean, 0 },
|
||||
{ "stale-answer-client-timeout", &cfg_type_uint32, 0 },
|
||||
{ "stale-answer-client-timeout", &cfg_type_staleanswerclienttimeout,
|
||||
0 },
|
||||
{ "stale-answer-ttl", &cfg_type_duration, 0 },
|
||||
{ "stale-cache-enable", &cfg_type_boolean, 0 },
|
||||
{ "stale-refresh-time", &cfg_type_duration, 0 },
|
||||
|
Reference in New Issue
Block a user