mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Consider non-stale data when in serve-stale mode
With 'stale-answer-enable yes;' and 'stale-answer-client-timeout off;', consider the following situation: A CNAME record and its target record are in the cache, then the CNAME record expires, but the target record is still valid. When a new query for the CNAME record arrives, and the query fails, the stale record is used, and then the query "restarts" to follow the CNAME target. The problem is that the query's multiple stale options (like DNS_DBFIND_STALEOK) are not reset, so 'query_lookup()' treats the restarted query as a lookup following a failed lookup, and returns a SERVFAIL answer when there is no stale data found in the cache, even if there is valid non-stale data there available. With this change, query_lookup() now considers non-stale data in the cache in the first place, and returns it if it is available.
This commit is contained in:
@@ -156,6 +156,11 @@ struct dns_rdataset {
|
|||||||
*
|
*
|
||||||
* \def DNS_RDATASETATTR_LOADORDER
|
* \def DNS_RDATASETATTR_LOADORDER
|
||||||
* Output the RRset in load order.
|
* Output the RRset in load order.
|
||||||
|
*
|
||||||
|
* \def DNS_RDATASETATTR_STALE_ADDED
|
||||||
|
* Set on rdatasets that were added during a stale-answer-client-timeout
|
||||||
|
* lookup. In other words, the RRset was added during a lookup of stale
|
||||||
|
* data and does not necessarily mean that the rdataset itself is stale.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DNS_RDATASETATTR_NONE 0x00000000 /*%< No ordering. */
|
#define DNS_RDATASETATTR_NONE 0x00000000 /*%< No ordering. */
|
||||||
|
@@ -5883,6 +5883,7 @@ query_lookup(query_ctx_t *qctx) {
|
|||||||
dns_ttl_t stale_refresh = 0;
|
dns_ttl_t stale_refresh = 0;
|
||||||
bool dbfind_stale = false;
|
bool dbfind_stale = false;
|
||||||
bool stale_timeout = false;
|
bool stale_timeout = false;
|
||||||
|
bool answer_found = false;
|
||||||
bool stale_found = false;
|
bool stale_found = false;
|
||||||
bool stale_refresh_window = false;
|
bool stale_refresh_window = false;
|
||||||
uint16_t ede = 0;
|
uint16_t ede = 0;
|
||||||
@@ -5990,6 +5991,14 @@ query_lookup(query_ctx_t *qctx) {
|
|||||||
*/
|
*/
|
||||||
stale_timeout = ((dboptions & DNS_DBFIND_STALETIMEOUT) != 0);
|
stale_timeout = ((dboptions & DNS_DBFIND_STALETIMEOUT) != 0);
|
||||||
|
|
||||||
|
if (dns_rdataset_isassociated(qctx->rdataset) &&
|
||||||
|
dns_rdataset_count(qctx->rdataset) > 0 && !STALE(qctx->rdataset))
|
||||||
|
{
|
||||||
|
/* Found non-stale usable rdataset. */
|
||||||
|
answer_found = true;
|
||||||
|
goto gotanswer;
|
||||||
|
}
|
||||||
|
|
||||||
if (dbfind_stale || stale_refresh_window || stale_timeout) {
|
if (dbfind_stale || stale_refresh_window || stale_timeout) {
|
||||||
dns_name_format(qctx->client->query.qname, namebuf,
|
dns_name_format(qctx->client->query.qname, namebuf,
|
||||||
sizeof(namebuf));
|
sizeof(namebuf));
|
||||||
@@ -6121,7 +6130,8 @@ query_lookup(query_ctx_t *qctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stale_timeout && stale_found) {
|
gotanswer:
|
||||||
|
if (stale_timeout && (answer_found || stale_found)) {
|
||||||
/*
|
/*
|
||||||
* Mark RRsets that we are adding to the client message on a
|
* Mark RRsets that we are adding to the client message on a
|
||||||
* lookup during 'stale-answer-client-timeout', so we can
|
* lookup during 'stale-answer-client-timeout', so we can
|
||||||
|
Reference in New Issue
Block a user