]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
make getoriginnode implementation optional
authorEvan Hunt <each@isc.org>
Mon, 11 Aug 2025 19:13:53 +0000 (12:13 -0700)
committerEvan Hunt <each@isc.org>
Mon, 15 Sep 2025 16:11:50 +0000 (16:11 +0000)
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.

bin/named/builtin.c
lib/dns/db.c
lib/dns/sdlz.c

index a9049b536f2150120f52d3b75d72b43c295acb49..c24fbe164e5f89c11efc4b6c95842b37161092a0 100644 (file)
@@ -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,
 };
index c75c250b214226ab63b90b113cbcb1c663012a52..08805b053599dd6f002af3984ec10729683ff035 100644 (file)
@@ -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;
index 8ba7cc3dd8ca4c7766c1984e30e56a9a253c6be7..3852b06b1ea1415a180cecfc74d88653eb59dd0e 100644 (file)
@@ -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,
 };
 
 /*