libdns refactoring: get rid of multiple versions of dns_view_find, dns_view_findzonecut and dns_view_flushcache

This commit is contained in:
Witold Kręcicki 2018-04-04 09:51:42 +02:00
parent 702c022016
commit d54d482af0
9 changed files with 40 additions and 79 deletions

View file

@ -10877,7 +10877,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
{
if (ptr != NULL && strcasecmp(ptr, view->name) != 0)
continue;
CHECK(dns_view_flushcache(view));
CHECK(dns_view_flushcache(view, ISC_FALSE));
if (set) {
view->enablevalidation = enable;
@ -10968,7 +10968,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
if (ptr != NULL && !nsc->needflush)
continue;
nsc->needflush = ISC_TRUE;
result = dns_view_flushcache2(nsc->primaryview, ISC_FALSE);
result = dns_view_flushcache(nsc->primaryview, ISC_FALSE);
if (result != ISC_R_SUCCESS) {
flushed = ISC_FALSE;
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@ -10999,7 +10999,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
nsc = ISC_LIST_NEXT(nsc, link)) {
if (!nsc->needflush || nsc->cache != view->cache)
continue;
result = dns_view_flushcache2(view, ISC_TRUE);
result = dns_view_flushcache(view, ISC_TRUE);
if (result != ISC_R_SUCCESS) {
flushed = ISC_FALSE;
isc_log_write(named_g_lctx,

View file

@ -3700,12 +3700,12 @@ dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype)
* matching static-stub zone without looking into the cache to honor
* the configuration on which server we should send queries to.
*/
result = dns_view_find2(adb->view, &adbname->name, rdtype, now,
NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0,
ISC_TF(NAME_HINTOK(adbname)),
(adbname->flags & NAME_STARTATZONE) != 0 ?
ISC_TRUE : ISC_FALSE,
NULL, NULL, fname, &rdataset, NULL);
result = dns_view_find(adb->view, &adbname->name, rdtype, now,
NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0,
ISC_TF(NAME_HINTOK(adbname)),
(adbname->flags & NAME_STARTATZONE) != 0 ?
ISC_TRUE : ISC_FALSE,
NULL, NULL, fname, &rdataset, NULL);
/* XXXVIX this switch statement is too sparse to gen a jump table. */
switch (result) {
@ -4027,9 +4027,9 @@ fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone,
adbname);
dns_fixedname_init(&fixed);
name = dns_fixedname_name(&fixed);
result = dns_view_findzonecut2(adb->view, &adbname->name, name,
0, 0, ISC_TRUE, ISC_FALSE,
&rdataset, NULL);
result = dns_view_findzonecut(adb->view, &adbname->name, name,
0, 0, ISC_TRUE, ISC_FALSE,
&rdataset, NULL);
if (result != ISC_R_SUCCESS && result != DNS_R_HINT)
goto cleanup;
nameservers = &rdataset;

View file

@ -797,7 +797,8 @@ view_find(resctx_t *rctx, dns_db_t **dbp, dns_dbnode_t **nodep,
type = rctx->type;
result = dns_view_find(rctx->view, name, type, 0, 0, ISC_FALSE,
dbp, nodep, foundname, rctx->rdataset,
ISC_FALSE, dbp, nodep, foundname,
rctx->rdataset,
rctx->sigrdataset);
return (result);

View file

@ -546,17 +546,13 @@ dns_view_thaw(dns_view_t *view);
*
*\li 'view' is no longer frozen.
*/
isc_result_t
dns_view_find(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type,
isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
isc_stdtime_t now, unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_static_stub,
dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
isc_result_t
dns_view_find2(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type,
isc_stdtime_t now, unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_static_stub,
dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
/*%<
* Find an rdataset whose owner name is 'name', and whose type is
* 'type'.
@ -703,19 +699,12 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name,
* or an error occurred.
*/
/*% See dns_view_findzonecut2() */
isc_result_t
dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
dns_name_t *fname, isc_stdtime_t now,
unsigned int options, isc_boolean_t use_hints,
unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_cache,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
isc_result_t
dns_view_findzonecut2(dns_view_t *view, const dns_name_t *name,
dns_name_t *fname, isc_stdtime_t now,
unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_cache,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
/*%<
* Find the best known zonecut containing 'name'.
*
@ -907,9 +896,7 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp);
*/
isc_result_t
dns_view_flushcache(dns_view_t *view);
isc_result_t
dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly);
dns_view_flushcache(dns_view_t *view, isc_boolean_t fixuponly);
/*%<
* Flush the view's cache (and ADB). If 'fixuponly' is true, it only updates
* the internal reference to the cache DB with omitting actual flush operation.

View file

@ -166,9 +166,9 @@ view_find(dns_lookup_t *lookup, dns_name_t *foundname) {
type = lookup->type;
result = dns_view_find(lookup->view, name, type, 0, 0, ISC_FALSE,
&lookup->event->db, &lookup->event->node,
foundname, &lookup->rdataset,
&lookup->sigrdataset);
ISC_FALSE, &lookup->event->db,
&lookup->event->node, foundname,
&lookup->rdataset, &lookup->sigrdataset);
return (result);
}

View file

@ -4617,6 +4617,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
findoptions |= DNS_DBFIND_NOEXACT;
result = dns_view_findzonecut(res->view, name, fname,
0, findoptions, ISC_TRUE,
ISC_TRUE,
&fctx->nameservers,
NULL);
if (result != ISC_R_SUCCESS)
@ -8999,7 +9000,7 @@ rctx_nextserver(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo,
result = dns_view_findzonecut(fctx->res->view,
name, fname,
rctx->now, findoptions,
ISC_TRUE,
ISC_TRUE, ISC_TRUE,
&fctx->nameservers,
NULL);
if (result != ISC_R_SUCCESS) {

View file

@ -997,7 +997,7 @@ view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) {
dns_fixedname_init(&fixedname);
foundname = dns_fixedname_name(&fixedname);
result = dns_view_find(val->view, name, type, 0, options,
ISC_FALSE, NULL, NULL, foundname,
ISC_FALSE, ISC_FALSE, NULL, NULL, foundname,
&val->frdataset, &val->fsigrdataset);
if (result == DNS_R_NXDOMAIN) {
@ -3409,9 +3409,9 @@ proveunsecure(dns_validator_t *val, isc_boolean_t have_ds, isc_boolean_t resume)
*/
if (result == DNS_R_NXRRSET &&
!dns_rdataset_isassociated(&val->frdataset) &&
dns_view_findzonecut2(val->view, tname, found,
0, 0, ISC_FALSE, ISC_FALSE,
NULL, NULL) == ISC_R_SUCCESS &&
dns_view_findzonecut(val->view, tname, found,
0, 0, ISC_FALSE, ISC_FALSE,
NULL, NULL) == ISC_R_SUCCESS &&
dns_name_equal(tname, found)) {
if (val->mustbesecure) {
validator_log(val, ISC_LOG_WARNING,

View file

@ -991,20 +991,10 @@ dns_view_findzone(dns_view_t *view, const dns_name_t *name,
isc_result_t
dns_view_find(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type,
isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
isc_stdtime_t now, unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_static_stub,
dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) {
return (dns_view_find2(view, name, type, now, options, use_hints,
ISC_FALSE, dbp, nodep, foundname, rdataset,
sigrdataset));
}
isc_result_t
dns_view_find2(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type,
isc_stdtime_t now, unsigned int options,
isc_boolean_t use_hints, isc_boolean_t use_static_stub,
dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
{
isc_result_t result;
dns_db_t *db, *zdb;
@ -1223,8 +1213,9 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name,
dns_fixedname_init(&foundname);
result = dns_view_find(view, name, type, now, options, use_hints,
NULL, NULL, dns_fixedname_name(&foundname),
rdataset, sigrdataset);
ISC_FALSE, NULL, NULL,
dns_fixedname_name(&foundname), rdataset,
sigrdataset);
if (result == DNS_R_NXDOMAIN) {
/*
* The rdataset and sigrdataset of the relevant NSEC record
@ -1258,21 +1249,10 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name,
isc_result_t
dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
dns_name_t *fname, isc_stdtime_t now, unsigned int options,
isc_boolean_t use_hints,
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
{
return(dns_view_findzonecut2(view, name, fname, now, options,
use_hints, ISC_TRUE,
rdataset, sigrdataset));
}
isc_result_t
dns_view_findzonecut2(dns_view_t *view, const dns_name_t *name,
dns_name_t *fname, isc_stdtime_t now,
unsigned int options, isc_boolean_t use_hints,
isc_boolean_t use_cache, dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset)
dns_name_t *fname, isc_stdtime_t now,
unsigned int options, isc_boolean_t use_hints,
isc_boolean_t use_cache, dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset)
{
isc_result_t result;
dns_db_t *db;
@ -1621,12 +1601,7 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp) {
}
isc_result_t
dns_view_flushcache(dns_view_t *view) {
return (dns_view_flushcache2(view, ISC_FALSE));
}
isc_result_t
dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly) {
dns_view_flushcache(dns_view_t *view, isc_boolean_t fixuponly) {
isc_result_t result;
REQUIRE(DNS_VIEW_VALID(view));

View file

@ -1051,13 +1051,10 @@ dns_view_dialup
dns_view_dumpdbtostream
dns_view_excludedelegationonly
dns_view_find
dns_view_find2
dns_view_findzone
dns_view_findzonecut
dns_view_findzonecut2
dns_view_flushanddetach
dns_view_flushcache
dns_view_flushcache2
dns_view_flushname
dns_view_flushnode
dns_view_freeze