From: Matthijs Mekking Date: Wed, 9 Jul 2025 12:21:44 +0000 (+0200) Subject: Special case refresh stale ncache data X-Git-Tag: v9.21.11~32^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7774f16ed5b1675d3bafc479c59ff7fbf1491084;p=thirdparty%2Fbind9.git Special case refresh stale ncache data When refreshing stale ncache data, the qctx->rdataset is NULL and requires special processing. --- diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index 2632d3a643f..7bf61705867 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -119,32 +119,32 @@ struct dns_rdataset { struct { bool question : 1; - bool rendered : 1; /*%< message.c: was rendered */ - bool answered : 1; /*%< server. */ - bool cache : 1; /*%< resolver. */ - bool answer : 1; /*%< resolver. */ - bool answersig : 1; /*%< resolver. */ - bool external : 1; /*%< resolver. */ - bool ncache : 1; /*%< resolver. */ - bool chaining : 1; /*%< resolver. */ - bool ttladjusted : 1; /*%< message.c: data had differing TTL - values, and the rdataset->ttl holds the smallest */ - bool chase : 1; /*%< Used by resolver. */ - bool nxdomain : 1; - bool noqname : 1; - bool checknames : 1; /*%< Used by resolver. */ - bool required : 1; - bool resign : 1; - bool closest : 1; - bool optout : 1; /*%< OPTOUT proof */ - bool negative : 1; - bool prefetch : 1; - bool stale : 1; - bool ancient : 1; - bool stale_window : 1; - bool keepcase : 1; - bool staticstub : 1; - dns_orderopt_t order : 2; + bool rendered : 1; /*%< message.c: was rendered */ + bool answered : 1; /*%< server. */ + bool cache : 1; /*%< resolver. */ + bool answer : 1; /*%< resolver. */ + bool answersig : 1; /*%< resolver. */ + bool external : 1; /*%< resolver. */ + bool ncache : 1; /*%< resolver. */ + bool chaining : 1; /*%< resolver. */ + bool ttladjusted : 1; /*%< message.c: data had differing TTL + values, and the rdataset->ttl holds the smallest */ + bool chase : 1; /*%< Used by resolver. */ + bool nxdomain : 1; + bool noqname : 1; + bool checknames : 1; /*%< Used by resolver. */ + bool required : 1; + bool resign : 1; + bool closest : 1; + bool optout : 1; /*%< OPTOUT proof */ + bool negative : 1; + bool prefetch : 1; + bool stale : 1; + bool ancient : 1; + bool stale_window : 1; + bool keepcase : 1; + bool staticstub : 1; + dns_orderopt_t order : 2; } attributes; /*% diff --git a/lib/ns/query.c b/lib/ns/query.c index 9bca2446a41..e751dca81a7 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2813,12 +2813,19 @@ query_stale_refresh(ns_client_t *client, dns_name_t *qname, dns_rdataset_t *rdataset) { CTRACE(ISC_LOG_DEBUG(3), "query_stale_refresh"); - bool stale_refresh_window = - (STALE_WINDOW(rdataset) && - (client->query.dboptions & DNS_DBFIND_STALEENABLED) != 0); + bool stale_refresh_window = false; + bool stale_rrset = true; + + if (rdataset != NULL) { + stale_refresh_window = (STALE_WINDOW(rdataset) && + (client->query.dboptions & + DNS_DBFIND_STALEENABLED) != 0); + stale_rrset = STALE(rdataset); + } + if (FETCH_RECTYPE_STALE_REFRESH(client) != NULL || (client->query.dboptions & DNS_DBFIND_STALETIMEOUT) == 0 || - !STALE(rdataset) || stale_refresh_window) + !stale_rrset || stale_refresh_window) { return; } @@ -2842,6 +2849,18 @@ query_stale_refresh(ns_client_t *client, dns_name_t *qname, RECTYPE_STALE_REFRESH); } +static void +query_stale_refresh_ncache(ns_client_t *client) { + dns_name_t *qname; + + if (client->query.origqname != NULL) { + qname = client->query.origqname; + } else { + qname = client->query.qname; + } + query_stale_refresh(client, qname, NULL); +} + static void query_prefetch(ns_client_t *client, dns_name_t *qname, dns_rdataset_t *rdataset) { @@ -9965,7 +9984,7 @@ query_ncache(query_ctx_t *qctx, isc_result_t result) { } if (!qctx->is_zone && RECURSIONOK(qctx->client)) { - query_stale_refresh(qctx->client, qctx->fname, qctx->rdataset); + query_stale_refresh_ncache(qctx->client); } return query_nodata(qctx, result);