mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 12:32:04 -04:00
findzonecut: helper function for cache lookup
Extract the cache lookup implementation from `dns_view_findzonecut()` into a separate helper function. Also, when the cache result is not ISC_R_SUCCESS (which is the only "success" value from the existing code in this case), the return value is overriden to DNS_R_NXDOMAIN. This enables the caller (in follow-up commit) to differentiate the case where a zone is found, but for whatever reason, no delegation is in there, from the case where no zone is found. Separating those cases enables the caller to know whether it needs to hit the cache/hints or not.
This commit is contained in:
parent
1b68638448
commit
1b54ff1efb
1 changed files with 29 additions and 5 deletions
|
|
@ -983,6 +983,32 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name,
|
|||
return result;
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
findzonecut_cache(dns_view_t *view, const dns_name_t *name, dns_name_t *fname,
|
||||
dns_name_t *dcname, isc_stdtime_t now, unsigned int options,
|
||||
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) {
|
||||
isc_result_t result = DNS_R_NXDOMAIN;
|
||||
|
||||
if (view->cachedb != NULL) {
|
||||
result = dns_db_findzonecut(view->cachedb, name, options, now,
|
||||
NULL, fname, dcname, rdataset,
|
||||
sigrdataset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cache miss returns ISC_R_NOTFOUND, but to not confuse it
|
||||
* with a zone found without delegation matching `name` (nor partial),
|
||||
* keep DNS_R_NXDOMAIN, so the hints can be checked.
|
||||
*/
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_rdataset_cleanup(rdataset);
|
||||
dns_rdataset_cleanup(sigrdataset);
|
||||
result = DNS_R_NXDOMAIN;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
findzonecut_hints(dns_view_t *view, dns_name_t *fname, dns_name_t *dcname,
|
||||
isc_stdtime_t now, dns_rdataset_t *rdataset) {
|
||||
|
|
@ -1114,8 +1140,8 @@ db_find:
|
|||
goto db_find;
|
||||
}
|
||||
} else {
|
||||
result = dns_db_findzonecut(db, name, options, now, NULL, fname,
|
||||
dcname, rdataset, sigrdataset);
|
||||
result = findzonecut_cache(view, name, fname, dcname, now,
|
||||
options, rdataset, sigrdataset);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (zfname != NULL &&
|
||||
(!dns_name_issubdomain(fname, zfname) ||
|
||||
|
|
@ -1128,7 +1154,7 @@ db_find:
|
|||
*/
|
||||
use_zone = true;
|
||||
}
|
||||
} else if (result == ISC_R_NOTFOUND) {
|
||||
} else if (result == DNS_R_NXDOMAIN) {
|
||||
if (zfname != NULL) {
|
||||
/*
|
||||
* We didn't find anything in the cache, but we
|
||||
|
|
@ -1142,8 +1168,6 @@ db_find:
|
|||
*/
|
||||
try_hints = true;
|
||||
result = ISC_R_SUCCESS;
|
||||
} else {
|
||||
result = DNS_R_NXDOMAIN;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue