From: Evan Hunt Date: Mon, 11 Aug 2025 19:13:53 +0000 (-0700) Subject: make getoriginnode implementation optional X-Git-Tag: v9.21.14~44^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17101fa4914e43a7585c6f6aa7581174cf62e264;p=thirdparty%2Fbind9.git make getoriginnode implementation optional if the dns_db_getoriginnode() call is not implemented, we can fall back to running dns_db_findnode() on the database origin. we now only implement getoriginnode directly in databases where it's clearly faster than the fallback implementation would be. --- diff --git a/bin/named/builtin.c b/bin/named/builtin.c index a9049b536f2..c24fbe164e5 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -822,41 +822,6 @@ destroynode(bdbnode_t *node) { dns_db_detach((dns_db_t **)(void *)&bdb); } -static isc_result_t -getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { - bdb_t *bdb = (bdb_t *)db; - bdbnode_t *node = NULL; - isc_result_t result; - dns_name_t relname; - dns_name_t *name = NULL; - - REQUIRE(VALID_BDB(bdb)); - REQUIRE(nodep != NULL && *nodep == NULL); - - dns_name_init(&relname); - name = &relname; - - result = createnode(bdb, &node); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = builtin_lookup(bdb, name, node); - if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) { - destroynode(node); - return result; - } - - result = builtin_authority(bdb, node); - if (result != ISC_R_SUCCESS) { - destroynode(node); - return result; - } - - *nodep = (dns_dbnode_t *)node; - return ISC_R_SUCCESS; -} - static isc_result_t findnode(dns_db_t *db, const dns_name_t *name, bool create, dns_clientinfomethods_t *methods ISC_ATTR_UNUSED, @@ -1154,7 +1119,6 @@ static dns_dbmethods_t bdb_methods = { .closeversion = closeversion, .findrdataset = findrdataset, .allrdatasets = allrdatasets, - .getoriginnode = getoriginnode, .findnode = findnode, .find = find, }; diff --git a/lib/dns/db.c b/lib/dns/db.c index c75c250b214..08805b05359 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -797,6 +797,9 @@ dns__db_getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { if (db->methods->getoriginnode != NULL) { return (db->methods->getoriginnode)(db, nodep DNS__DB_FLARG_PASS); + } else if (db->methods->findnode != NULL) { + return (db->methods->findnode)(db, &db->origin, false, NULL, + NULL, nodep DNS__DB_FLARG_PASS); } return ISC_R_NOTFOUND; diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 8ba7cc3dd8c..3852b06b1ea 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -1092,29 +1092,6 @@ deleterdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, return result; } -/* - * getoriginnode() is used by the update code to find the - * dns_rdatatype_dnskey record for a zone - */ -static isc_result_t -getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { - dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db; - isc_result_t result; - - REQUIRE(VALID_SDLZDB(sdlz)); - if (sdlz->dlzimp->methods->newversion == NULL) { - return ISC_R_NOTIMPLEMENTED; - } - - result = getnodedata(db, &sdlz->common.origin, false, 0, NULL, NULL, - nodep); - if (result != ISC_R_SUCCESS) { - sdlz_log(ISC_LOG_ERROR, "sdlz getoriginnode failed: %s", - isc_result_totext(result)); - } - return result; -} - static dns_dbmethods_t sdlzdb_methods = { .destroy = destroy, .currentversion = currentversion, @@ -1129,7 +1106,6 @@ static dns_dbmethods_t sdlzdb_methods = { .addrdataset = addrdataset, .subtractrdataset = subtractrdataset, .deleterdataset = deleterdataset, - .getoriginnode = getoriginnode, }; /*