diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 22d1852f62..83632e784c 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -257,7 +257,7 @@ static void free_db(dns_db_t **dbp, dns_dbnode_t **nodep, dns_dbversion_t **versionp) { if (*dbp != NULL) { if (*nodep != NULL) { - dns_db_detachnode(*dbp, nodep); + dns_db_detachnode(nodep); } if (versionp != NULL && *versionp != NULL) { dns_db_closeversion(*dbp, versionp, false); diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 0eaf67d505..a6363a0cd9 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -132,7 +132,7 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 31f51c01ed..71befcbac3 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -135,7 +135,7 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index ff0fd055cf..6128b33a25 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -953,7 +953,7 @@ addnowildcardhash(hashlist_t *l, result = dns_db_findnode(gdb, wild, false, &node); if (result == ISC_R_SUCCESS) { - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); return; } @@ -1031,7 +1031,7 @@ loadds(dns_name_t *name, uint32_t ttl, dns_rdataset_t *dsset) { result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_ds, 0, 0, dsset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_SUCCESS) { vbprintf(2, "found DS records\n"); dsset->ttl = ttl; @@ -1058,7 +1058,7 @@ loadds(dns_name_t *name, uint32_t ttl, dns_rdataset_t *dsset) { result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_dnskey, 0, 0, &keyset, NULL); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_detach(&db); return result; } @@ -1092,7 +1092,7 @@ loadds(dns_name_t *name, uint32_t ttl, dns_rdataset_t *dsset) { check_result(result, "dns_db_findrdataset"); dns_rdataset_disassociate(&keyset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_detach(&db); return result; } @@ -1454,7 +1454,7 @@ setsoaserial(uint32_t serial, dns_updatemethod_t method) { cleanup: dns_rdataset_disassociate(&rdataset); if (node != NULL) { - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } dns_rdata_reset(&rdata); @@ -1500,7 +1500,7 @@ signapex(void) { check_dns_dbiterator_current(result); signname(node, true, name); dumpnode(name, node); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); result = dns_dbiterator_first(gdbiter); if (result == ISC_R_NOMORE) { atomic_store(&finished, true); @@ -1559,7 +1559,7 @@ assignwork(void *arg) { * The origin was handled by signapex(). */ if (dns_name_equal(name, gorigin)) { - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); goto next; } /* @@ -1603,7 +1603,7 @@ assignwork(void *arg) { if (!found) { dumpnode(name, node); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } next: @@ -1633,7 +1633,7 @@ assignwork(void *arg) { * Write a node to the output file, and restart the worker task. */ lock_and_dumpnode(dns_fixedname_name(&fname), node); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); isc_async_current(assignwork, NULL); } @@ -1800,7 +1800,7 @@ nsecify(void) { "rrsig)"); } dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiter); @@ -1823,7 +1823,7 @@ nsecify(void) { } else { check_result(result, "dns_dbiterator_next()"); } - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); continue; } @@ -1852,7 +1852,7 @@ nsecify(void) { check_dns_dbiterator_current(result); active = active_node(nextnode); if (!active) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } @@ -1863,11 +1863,11 @@ nsecify(void) { remove_sigs(nextnode, false, 0); remove_records(nextnode, dns_rdatatype_nsec, false); - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); break; } if (result == ISC_R_NOMORE) { @@ -1881,7 +1881,7 @@ nsecify(void) { result = dns_nsec_build(gdb, gversion, node, nextname, zone_soa_min_ttl); check_result(result, "dns_nsec_build()"); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiter); @@ -1939,7 +1939,7 @@ addnsec3param(const unsigned char *salt, size_t salt_len, result = ISC_R_SUCCESS; } check_result(result, "addnsec3param: dns_db_addrdataset()"); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } static void @@ -1989,7 +1989,7 @@ addnsec3(dns_name_t *name, dns_dbnode_t *node, const unsigned char *salt, result = ISC_R_SUCCESS; } check_result(result, "addnsec3: dns_db_addrdataset()"); - dns_db_detachnode(gdb, &nsec3node); + dns_db_detachnode(&nsec3node); } /*% @@ -2186,7 +2186,7 @@ cleanup_zone(void) { dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } result = dns_diff_applysilently(&del, gdb, gversion); @@ -2245,7 +2245,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, } else { check_result(result, "dns_dbiterator_next()"); } - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); continue; } @@ -2267,7 +2267,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, check_dns_dbiterator_current(result); active = active_node(nextnode); if (!active) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } @@ -2276,7 +2276,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, dns_name_issubdomain(nextname, zonecut))) { remove_sigs(nextnode, false, 0); - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } @@ -2291,14 +2291,14 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, if (OPTOUT(nsec3flags) && !secure(nextname, nextnode)) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } } else if (has_dname(gdb, gversion, nextnode)) { zonecut = savezonecut(&fzonecut, nextname); } - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); break; } if (result == ISC_R_NOMORE) { @@ -2311,7 +2311,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, dns_name_downcase(name, name); hashlist_add_dns_name(hashlist, name, hashalg, iterations, salt, salt_len, false); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); /* * Add hashes for empty nodes. Use closest encloser logic. * The closest encloser either has data or is a empty @@ -2367,7 +2367,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, check_dns_dbiterator_current(result); nsec3clean(name, node, hashalg, iterations, salt, salt_len, hashlist); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiter); @@ -2393,7 +2393,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, } else { check_result(result, "dns_dbiterator_next()"); } - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); continue; } @@ -2409,7 +2409,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, check_dns_dbiterator_current(result); active = active_node(nextnode); if (!active) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } @@ -2417,7 +2417,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, (zonecut != NULL && dns_name_issubdomain(nextname, zonecut))) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } @@ -2428,14 +2428,14 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, if (OPTOUT(nsec3flags) && !secure(nextname, nextnode)) { - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } } else if (has_dname(gdb, gversion, nextnode)) { zonecut = savezonecut(&fzonecut, nextname); } - dns_db_detachnode(gdb, &nextnode); + dns_db_detachnode(&nextnode); break; } if (result == ISC_R_NOMORE) { @@ -2451,7 +2451,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations, dns_dbiterator_pause(dbiter); addnsec3(name, node, salt, salt_len, iterations, hashlist, zone_soa_min_ttl); - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); /* * Add NSEC3's for empty nodes. Use closest encloser logic. */ @@ -2573,7 +2573,7 @@ cleanup: if (dns_rdataset_isassociated(&soasigs)) { dns_rdataset_disassociate(&soasigs); } - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); dns_db_closeversion(gdb, ¤tversion, false); } @@ -2792,7 +2792,7 @@ findkeys: isc_result_totext(result)); } - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); dns_db_closeversion(gdb, &ver, true); dns_diff_clear(&diff); @@ -2856,7 +2856,7 @@ warnifallksk(dns_db_t *db) { dns_rdata_freestruct(&dnskey); } dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_closeversion(db, ¤tversion, false); if (!have_non_ksk && !ignore_kskflag) { if (disable_zone_check) { @@ -2968,7 +2968,7 @@ cleanup: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(gdb, &node); + dns_db_detachnode(&node); } dns_db_closeversion(gdb, &ver, false); } diff --git a/bin/named/builtin.c b/bin/named/builtin.c index 9582230bf1..664e4b2bd9 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -62,12 +62,12 @@ typedef struct bdb { } bdb_t; struct bdbnode { - unsigned int magic; + DBNODE_FIELDS; + isc_refcount_t references; bdb_t *bdb; ISC_LIST(dns_rdatalist_t) lists; ISC_LIST(isc_buffer_t) buffers; - dns_name_t *name; ISC_LINK(bdbnode_t) link; dns_rdatacallbacks_t callbacks; }; @@ -83,12 +83,21 @@ findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG); +/* + * Node methods forward declarations + */ static void -attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG); +bdbnode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG); +static void +bdbnode_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG); -static void -detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG); +/* + * Node methods structure + */ +static dns_dbnode_methods_t bdbnode_methods = (dns_dbnode_methods_t){ + .attachnode = bdbnode_attachnode, + .detachnode = bdbnode_detachnode, +}; /* * Helper functions to convert text to wire forma. @@ -613,21 +622,17 @@ ipv4reverse_lookup(bdbnode_t *node) { static void disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG) { dns_dbnode_t *node = rdataset->rdlist.node; - bdbnode_t *bdbnode = (bdbnode_t *)node; - dns_db_t *db = (dns_db_t *)bdbnode->bdb; - detachnode(db, &node DNS__DB_FLARG_PASS); + bdbnode_detachnode(&node DNS__DB_FLARG_PASS); dns_rdatalist_disassociate(rdataset DNS__DB_FLARG_PASS); } static void rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target DNS__DB_FLARG) { dns_dbnode_t *node = source->rdlist.node; - bdbnode_t *bdbnode = (bdbnode_t *)node; - dns_db_t *db = (dns_db_t *)bdbnode->bdb; dns_rdatalist_clone(source, target DNS__DB_FLARG_PASS); - attachnode(db, node, &target->rdlist.node DNS__DB_FLARG_PASS); + bdbnode_attachnode(node, &target->rdlist.node DNS__DB_FLARG_PASS); } static dns_rdatasetmethods_t bdb_rdataset_methods = { @@ -642,12 +647,12 @@ static dns_rdatasetmethods_t bdb_rdataset_methods = { }; static void -new_rdataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node, - dns_rdataset_t *rdataset) { +new_rdataset(dns_rdatalist_t *rdatalist, dns_db_t *db ISC_ATTR_UNUSED, + dns_dbnode_t *node, dns_rdataset_t *rdataset) { dns_rdatalist_tordataset(rdatalist, rdataset); rdataset->methods = &bdb_rdataset_methods; - dns_db_attachnode(db, node, &rdataset->rdlist.node); + dns_db_attachnode(node, &rdataset->rdlist.node); } /* @@ -657,8 +662,7 @@ new_rdataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node, static void rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG) { bdb_rdatasetiter_t *bdbiterator = (bdb_rdatasetiter_t *)(*iteratorp); - detachnode(bdbiterator->common.db, - &bdbiterator->common.node DNS__DB_FLARG_PASS); + bdbnode_detachnode(&bdbiterator->common.node DNS__DB_FLARG_PASS); isc_mem_put(bdbiterator->common.db->mctx, bdbiterator, sizeof(bdb_rdatasetiter_t)); *iteratorp = NULL; @@ -785,6 +789,7 @@ createnode(bdb_t *bdb, bdbnode_t **nodep) { isc_refcount_init(&node->references, 1); node->magic = BDBNODE_MAGIC; + node->methods = &bdbnode_methods; *nodep = node; return ISC_R_SUCCESS; @@ -812,11 +817,6 @@ destroynode(bdbnode_t *node) { isc_buffer_free(&b); } - if (node->name != NULL) { - dns_name_free(node->name, mctx); - isc_mem_put(mctx, node->name, sizeof(dns_name_t)); - } - node->magic = 0; isc_mem_put(mctx, node, sizeof(bdbnode_t)); dns_db_detach((dns_db_t **)(void *)&bdb); @@ -1060,31 +1060,25 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, if (nodep != NULL) { *nodep = node; } else if (node != NULL) { - detachnode(db, &node DNS__DB_FLARG_PASS); + bdbnode_detachnode(&node DNS__DB_FLARG_PASS); } return result; } static void -attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { - bdb_t *bdb = (bdb_t *)db; +bdbnode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG) { bdbnode_t *node = (bdbnode_t *)source; - REQUIRE(VALID_BDB(bdb)); - isc_refcount_increment(&node->references); *targetp = source; } static void -detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { - bdb_t *bdb = (bdb_t *)db; +bdbnode_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG) { bdbnode_t *node = NULL; - REQUIRE(VALID_BDB(bdb)); REQUIRE(nodep != NULL && *nodep != NULL); node = (bdbnode_t *)(*nodep); @@ -1141,7 +1135,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, .common.magic = DNS_RDATASETITER_MAGIC, }; - attachnode(db, node, &iterator->common.node DNS__DB_FLARG_PASS); + bdbnode_attachnode(node, &iterator->common.node DNS__DB_FLARG_PASS); *iteratorp = (dns_rdatasetiter_t *)iterator; @@ -1153,8 +1147,6 @@ static dns_dbmethods_t bdb_methods = { .currentversion = currentversion, .attachversion = attachversion, .closeversion = closeversion, - .attachnode = attachnode, - .detachnode = detachnode, .findrdataset = findrdataset, .allrdatasets = allrdatasets, .getoriginnode = getoriginnode, diff --git a/bin/named/server.c b/bin/named/server.c index 771ec91cbe..6d712c94bc 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -3099,7 +3099,7 @@ add_soa(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -3139,7 +3139,7 @@ add_ns(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -6778,7 +6778,7 @@ tat_done(void *arg) { /* Free resources which are not of interest */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); @@ -14317,7 +14317,7 @@ cleanup: dns_rdataset_disassociate(&privset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 6bed6e3dcd..339479a1d4 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -661,7 +661,7 @@ cleanup: dns_rdataset_disassociate(&rdataset); } if (apexnode != NULL) { - dns_db_detachnode(db, &apexnode); + dns_db_detachnode(&apexnode); } if (dbversion != NULL) { dns_db_closeversion(db, &dbversion, false); diff --git a/bin/tests/system/dyndb/driver/db.c b/bin/tests/system/dyndb/driver/db.c index f5a3bdd219..b0bfe605fb 100644 --- a/bin/tests/system/dyndb/driver/db.c +++ b/bin/tests/system/dyndb/driver/db.c @@ -164,25 +164,6 @@ findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, sigrdataset DNS__DB_FLARG_PASS); } -static void -attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { - sampledb_t *sampledb = (sampledb_t *)db; - - REQUIRE(VALID_SAMPLEDB(sampledb)); - - dns__db_attachnode(sampledb->db, source, targetp DNS__DB_FLARG_PASS); -} - -static void -detachnode(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG) { - sampledb_t *sampledb = (sampledb_t *)db; - - REQUIRE(VALID_SAMPLEDB(sampledb)); - - dns__db_detachnode(sampledb->db, targetp DNS__DB_FLARG_PASS); -} - static isc_result_t createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) { @@ -233,8 +214,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, CHECK(dns__db_addrdataset(sampledb->db, node, version, now, rdataset, options, addedrdataset DNS__DB_FLARG_PASS)); if (dns_rdatatype_isaddr(rdataset->type)) { - CHECK(dns_db_nodefullname(sampledb->db, node, - dns_fixedname_name(&name))); + CHECK(dns_db_nodefullname(node, dns_fixedname_name(&name))); CHECK(syncptrs(sampledb->inst, dns_fixedname_name(&name), rdataset, DNS_DIFFOP_ADD)); } @@ -262,8 +242,7 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, } if (dns_rdatatype_isaddr(rdataset->type)) { - CHECK(dns_db_nodefullname(sampledb->db, node, - dns_fixedname_name(&name))); + CHECK(dns_db_nodefullname(node, dns_fixedname_name(&name))); CHECK(syncptrs(sampledb->inst, dns_fixedname_name(&name), rdataset, DNS_DIFFOP_DEL)); } @@ -410,15 +389,6 @@ setcachestats(dns_db_t *db, isc_stats_t *stats) { return dns_db_setcachestats(sampledb->db, stats); } -static isc_result_t -nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name) { - sampledb_t *sampledb = (sampledb_t *)db; - - REQUIRE(VALID_SAMPLEDB(sampledb)); - - return dns_db_nodefullname(sampledb->db, node, name); -} - /* * DB interface definition. Database driver uses this structure to * determine which implementation of dns_db_*() function to call. @@ -432,8 +402,6 @@ static dns_dbmethods_t sampledb_methods = { .findnode = findnode, .find = find, .findzonecut = findzonecut, - .attachnode = attachnode, - .detachnode = detachnode, .createiterator = createiterator, .findrdataset = findrdataset, .allrdatasets = allrdatasets, @@ -452,7 +420,6 @@ static dns_dbmethods_t sampledb_methods = { .findnodeext = findnodeext, .findext = findext, .setcachestats = setcachestats, - .nodefullname = nodefullname, }; /* Auxiliary driver functions. */ @@ -490,7 +457,7 @@ add_soa(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, CHECK(dns_db_addrdataset(db, node, version, 0, &rdataset, 0, NULL)); cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -528,7 +495,7 @@ add_ns(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, CHECK(dns_db_addrdataset(db, node, version, 0, &rdataset, 0, NULL)); cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -564,7 +531,7 @@ add_a(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, CHECK(dns_db_addrdataset(db, node, version, 0, &rdataset, 0, NULL)); cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 4366ed0f79..096dee62de 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2594,7 +2594,7 @@ fetch_callback(void *arg) { * Cleanup things we don't care about. */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 1d34595ee6..7d6b5440e6 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -439,7 +439,7 @@ cleartree(dns_db_t *db, const dns_name_t *name) { if (result != ISC_R_SUCCESS && answer == ISC_R_SUCCESS) { answer = result; } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); result = dns_dbiterator_next(iter); } @@ -451,13 +451,13 @@ cleanup: answer = result; } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (iter != NULL) { dns_dbiterator_destroy(&iter); } if (top != NULL) { - dns_db_detachnode(db, &top); + dns_db_detachnode(&top); } return answer; @@ -499,7 +499,7 @@ dns_cache_flushnode(dns_cache_t *cache, const dns_name_t *name, bool tree) { goto cleanup_db; } result = clearnode(cache->db, node); - dns_db_detachnode(cache->db, &node); + dns_db_detachnode(&node); } cleanup_db: diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 7929d1b0f4..155084b4dd 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -2363,7 +2363,7 @@ dns__catz_update_cb(void *data) { vers_node = node; } else if (node == vers_node) { /* Skip the already processed version node */ - dns_db_detachnode(updb, &node); + dns_db_detachnode(&node); result = dns_dbiterator_next(updbit); continue; } @@ -2375,7 +2375,7 @@ dns__catz_update_cb(void *data) { DNS_LOGMODULE_CATZ, ISC_LOG_ERROR, "catz: failed to fetch rrdatasets - %s", isc_result_totext(result)); - dns_db_detachnode(updb, &node); + dns_db_detachnode(&node); break; } @@ -2429,7 +2429,7 @@ dns__catz_update_cb(void *data) { dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(updb, &node); + dns_db_detachnode(&node); if (!is_vers_processed) { is_vers_processed = true; diff --git a/lib/dns/client.c b/lib/dns/client.c index cfe1e497dc..21baa0ff25 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -526,7 +526,7 @@ client_resfind(resctx_t *rctx, dns_fetchresponse_t *resp) { */ if (node != NULL) { INSIST(db != NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); @@ -774,7 +774,7 @@ client_resfind(resctx_t *rctx, dns_fetchresponse_t *resp) { } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); diff --git a/lib/dns/db.c b/lib/dns/db.c index baa186b9c5..44455bd84a 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -564,29 +564,29 @@ dns__db_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, } void -dns__db_attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { +dns__db_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG) { /* * Attach *targetp to source. */ - REQUIRE(DNS_DB_VALID(db)); REQUIRE(source != NULL); REQUIRE(targetp != NULL && *targetp == NULL); + REQUIRE(source->methods != NULL && source->methods->attachnode != NULL); - (db->methods->attachnode)(db, source, targetp DNS__DB_FLARG_PASS); + (source->methods->attachnode)(source, targetp DNS__DB_FLARG_PASS); } void -dns__db_detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { +dns__db_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG) { /* * Detach *nodep from its node. */ - REQUIRE(DNS_DB_VALID(db)); REQUIRE(nodep != NULL && *nodep != NULL); + dns_dbnode_t *node = *nodep; + REQUIRE(node->methods != NULL && node->methods->detachnode != NULL); - (db->methods->detachnode)(db, nodep DNS__DB_FLARG_PASS); + (node->methods->detachnode)(nodep DNS__DB_FLARG_PASS); ENSURE(*nodep == NULL); } @@ -786,7 +786,7 @@ freerdataset: dns_rdataset_disassociate(&rdataset); freenode: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -1118,41 +1118,44 @@ dns_db_addglue(dns_db_t *db, dns_dbversion_t *version, dns_rdataset_t *rdataset, } void -dns_db_locknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type) { - if (db->methods->locknode != NULL) { - (db->methods->locknode)(db, node, type); +dns_db_locknode(dns_dbnode_t *node, isc_rwlocktype_t type) { + REQUIRE(node != NULL && node->methods != NULL); + if (node->methods->locknode != NULL) { + (node->methods->locknode)(node, type); } } void -dns_db_unlocknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type) { - if (db->methods->unlocknode != NULL) { - (db->methods->unlocknode)(db, node, type); +dns_db_unlocknode(dns_dbnode_t *node, isc_rwlocktype_t type) { + REQUIRE(node != NULL && node->methods != NULL); + if (node->methods->unlocknode != NULL) { + (node->methods->unlocknode)(node, type); } } void -dns_db_expiredata(dns_db_t *db, dns_dbnode_t *node, void *data) { - if (db->methods->expiredata != NULL) { - (db->methods->expiredata)(db, node, data); +dns_db_expiredata(dns_dbnode_t *node, void *data) { + REQUIRE(node != NULL && node->methods != NULL); + if (node->methods->expiredata != NULL) { + (node->methods->expiredata)(node, data); } } void -dns_db_deletedata(dns_db_t *db, dns_dbnode_t *node, void *data) { - if (db->methods->deletedata != NULL) { - (db->methods->deletedata)(db, node, data); +dns_db_deletedata(dns_dbnode_t *node, void *data) { + REQUIRE(node != NULL && node->methods != NULL); + if (node->methods->deletedata != NULL) { + (node->methods->deletedata)(node, data); } } isc_result_t -dns_db_nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name) { - REQUIRE(db != NULL); - REQUIRE(node != NULL); +dns_db_nodefullname(dns_dbnode_t *node, dns_name_t *name) { + REQUIRE(node != NULL && node->methods != NULL); REQUIRE(name != NULL); - if (db->methods->nodefullname != NULL) { - return (db->methods->nodefullname)(db, node, name); + if (node->methods != NULL && node->methods->nodefullname != NULL) { + return node->methods->nodefullname(node, name); } return ISC_R_NOTIMPLEMENTED; } diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 5d0c9d63ff..2ea9876e8d 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -502,7 +502,7 @@ diff_apply(const dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, } CHECK(result); } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (dns_rdataset_isassociated(&ardataset)) { dns_rdataset_disassociate(&ardataset); } @@ -512,7 +512,7 @@ diff_apply(const dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } diff --git a/lib/dns/include/dns/db.h b/lib/dns/include/dns/db.h index f04253dff7..513fb1eafb 100644 --- a/lib/dns/include/dns/db.h +++ b/lib/dns/include/dns/db.h @@ -75,7 +75,21 @@ extern unsigned int dns_pps; ***** Types *****/ -typedef struct dns_dbmethods { +typedef struct dns_dbnode_methods { + isc_result_t (*nodefullname)(dns_dbnode_t *node, dns_name_t *name); + + void (*attachnode)(dns_dbnode_t *source, + dns_dbnode_t **targetp DNS__DB_FLARG); + void (*detachnode)(dns_dbnode_t **targetp DNS__DB_FLARG); + + void (*locknode)(dns_dbnode_t *node, isc_rwlocktype_t t); + void (*unlocknode)(dns_dbnode_t *node, isc_rwlocktype_t t); + + void (*deletedata)(dns_dbnode_t *node, void *data); + void (*expiredata)(dns_dbnode_t *node, void *data); +} dns_dbnode_methods_t; + +typedef struct dns_db_methods { void (*destroy)(dns_db_t *db); isc_result_t (*beginload)(dns_db_t *db, dns_rdatacallbacks_t *callbacks); @@ -101,9 +115,6 @@ typedef struct dns_dbmethods { dns_name_t *dcname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG); - void (*attachnode)(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG); - void (*detachnode)(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG); isc_result_t (*createiterator)(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp); isc_result_t (*findrdataset)(dns_db_t *db, dns_dbnode_t *node, @@ -171,15 +182,8 @@ typedef struct dns_dbmethods { isc_result_t (*setservestalerefresh)(dns_db_t *db, uint32_t interval); isc_result_t (*getservestalerefresh)(dns_db_t *db, uint32_t *interval); isc_result_t (*setgluecachestats)(dns_db_t *db, isc_stats_t *stats); - void (*locknode)(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t t); - void (*unlocknode)(dns_db_t *db, dns_dbnode_t *node, - isc_rwlocktype_t t); void (*addglue)(dns_db_t *db, dns_dbversion_t *version, dns_rdataset_t *rdataset, dns_message_t *msg); - void (*expiredata)(dns_db_t *db, dns_dbnode_t *node, void *data); - void (*deletedata)(dns_db_t *db, dns_dbnode_t *node, void *data); - isc_result_t (*nodefullname)(dns_db_t *db, dns_dbnode_t *node, - dns_name_t *name); void (*setmaxrrperset)(dns_db_t *db, uint32_t value); void (*setmaxtypepername)(dns_db_t *db, uint32_t value); isc_result_t (*getzoneversion)(dns_db_t *db, isc_buffer_t *b); @@ -197,6 +201,17 @@ typedef isc_result_t (*dns_dbupdate_callback_t)(dns_db_t *db, void *fn_arg); #define DNS_DB_MAGIC ISC_MAGIC('D', 'N', 'S', 'D') #define DNS_DB_VALID(db) ISC_MAGIC_VALID(db, DNS_DB_MAGIC) +#define DBNODE_FIELDS \ + unsigned int magic; \ + uint16_t locknum; \ + dns_dbnode_methods_t *methods; \ + isc_mem_t *mctx; \ + dns_name_t name; + +struct dns_dbnode { + DBNODE_FIELDS; +}; + /*% * This structure is actually just the common prefix of a DNS db * implementation's version of a dns_db_t. @@ -986,11 +1001,10 @@ dns__db_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, * errors. */ -#define dns_db_attachnode(db, source, targetp) \ - dns__db_attachnode(db, source, targetp DNS__DB_FILELINE) +#define dns_db_attachnode(source, targetp) \ + dns__db_attachnode(source, targetp DNS__DB_FILELINE) void -dns__db_attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG); +dns__db_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG); /*%< * Attach *targetp to source. * @@ -1007,10 +1021,9 @@ dns__db_attachnode(dns_db_t *db, dns_dbnode_t *source, * \li *targetp is attached to source. */ -#define dns_db_detachnode(db, nodep) \ - dns__db_detachnode(db, nodep DNS__DB_FILELINE) +#define dns_db_detachnode(nodep) dns__db_detachnode(nodep DNS__DB_FILELINE) void -dns__db_detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG); +dns__db_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG); /*%< * Detach *nodep from its node. * @@ -1734,9 +1747,9 @@ dns_db_setgluecachestats(dns_db_t *db, isc_stats_t *stats); */ void -dns_db_locknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type); +dns_db_locknode(dns_dbnode_t *node, isc_rwlocktype_t type); void -dns_db_unlocknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type); +dns_db_unlocknode(dns_dbnode_t *node, isc_rwlocktype_t type); /*%< * Lock/unlock a single node within a database so that data stored * there can be manipulated directly. @@ -1763,22 +1776,22 @@ dns_db_addglue(dns_db_t *db, dns_dbversion_t *version, dns_rdataset_t *rdataset, */ void -dns_db_expiredata(dns_db_t *db, dns_dbnode_t *node, void *data); +dns_db_expiredata(dns_dbnode_t *node, void *data); /*%< * Tell the database 'db' to mark a block of data 'data' stored at * node 'node' as expired. */ void -dns_db_deletedata(dns_db_t *db, dns_dbnode_t *node, void *data); +dns_db_deletedata(dns_dbnode_t *node, void *data); /*%< - * Tell the database 'db' to prepare to delete the block of data 'data' + * Tell the database to prepare to delete the block of data 'data' * stored at node 'node. This may include, for example, removing the * data from an LRU list or a heap. */ isc_result_t -dns_db_nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name); +dns_db_nodefullname(dns_dbnode_t *node, dns_name_t *name); /*%< * Get the name associated with a database node. * diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index 20e0ddcb1a..2460387e64 100644 --- a/lib/dns/include/dns/rdataslab.h +++ b/lib/dns/include/dns/rdataslab.h @@ -119,7 +119,6 @@ struct dns_slabheader { * this rdataset. */ - dns_db_t *db; dns_dbnode_t *node; /*%< * The database and database node objects containing diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index 73d8c40890..619f3a779a 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -57,16 +57,15 @@ typedef uint16_t dns_cert_t; typedef struct dns_compress dns_compress_t; typedef enum dns_compress_flags dns_compress_flags_t; typedef struct dns_compress_slot dns_compress_slot_t; +typedef struct dns_dbnode dns_dbnode_t; typedef struct dns_db dns_db_t; typedef struct dns_dbimplementation dns_dbimplementation_t; typedef struct dns_dbiterator dns_dbiterator_t; typedef void dns_dbload_t; -typedef struct dns_dbnode dns_dbnode_t; /* this is dummy struct for proper type - checking */ -typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t; -typedef struct dns_dbversion dns_dbversion_t; -typedef struct dns_dlzimplementation dns_dlzimplementation_t; -typedef struct dns_dlzdb dns_dlzdb_t; +typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t; +typedef struct dns_dbversion dns_dbversion_t; +typedef struct dns_dlzimplementation dns_dlzimplementation_t; +typedef struct dns_dlzdb dns_dlzdb_t; typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t; typedef struct dns_dyndbctx dns_dyndbctx_t; typedef struct dns_sdlzimplementation dns_sdlzimplementation_t; diff --git a/lib/dns/journal.c b/lib/dns/journal.c index e68fc1f4dd..30c5ddbc58 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -155,11 +155,11 @@ dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx, dns_difftuple_create(mctx, op, zonename, rdataset.ttl, &rdata, tp); dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; freenode: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); nonode: UNEXPECTED_ERROR("missing SOA"); return result; @@ -2158,7 +2158,7 @@ get_name_diff(dns_db_t *db, dns_dbversion_t *ver, isc_stdtime_t now, result = ISC_R_SUCCESS; cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 7112790f2c..ca5b031318 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1735,17 +1735,17 @@ dumptostream(dns_dumpctx_t *dctx) { result = dns_db_allrdatasets(dctx->db, node, dctx->version, options, dctx->now, &rdsiter); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(dctx->db, &node); + dns_db_detachnode(&node); goto cleanup; } result = (dctx->dumpsets)(dctx->mctx, name, rdsiter, &dctx->tctx, &buffer, dctx->f); dns_rdatasetiter_destroy(&rdsiter); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(dctx->db, &node); + dns_db_detachnode(&node); goto cleanup; } - dns_db_detachnode(dctx->db, &node); + dns_db_detachnode(&node); } if (result == ISC_R_NOMORE) { diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 8aeb1ed90e..6b8f6fffd0 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -254,7 +254,7 @@ dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version, dns_diff_t *diff, result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey, 0, 0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { *answer = false; diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index a5e411271f..7a7db5aafd 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -374,7 +374,7 @@ name_exists(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, dns_rdatasetiter_destroy(&iter); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -446,7 +446,7 @@ delnsec3(dns_db_t *db, dns_dbversion_t *version, const dns_name_t *name, failure: dns_rdataset_disassociate(&rdataset); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -640,7 +640,7 @@ dns_nsec3_addnsec3(dns_db_t *db, dns_dbversion_t *version, result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { continue; } @@ -713,7 +713,7 @@ addnsec3: CHECK(dns_nsec3_buildrdata(db, version, node, hash, flags, iterations, salt, salt_length, nexthash, next_length, nsec3buf, &rdata)); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* * Delete the old NSEC3 and record the change. @@ -727,7 +727,7 @@ addnsec3: CHECK(do_one_tuple(&tuple, db, version, diff)); INSIST(tuple == NULL); dns_rdata_reset(&rdata); - dns_db_detachnode(db, &newnode); + dns_db_detachnode(&newnode); /* * Add missing NSEC3 records for empty nodes @@ -761,7 +761,7 @@ addnsec3: result = find_nsec3(&nsec3, &rdataset, nsec3param); dns_rdataset_disassociate(&rdataset); if (result == ISC_R_SUCCESS) { - dns_db_detachnode(db, &newnode); + dns_db_detachnode(&newnode); break; } } else if (result == ISC_R_NOTFOUND) { @@ -793,7 +793,7 @@ addnsec3: result = dns_db_findrdataset( db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { continue; } @@ -854,7 +854,7 @@ addnsec3: CHECK(do_one_tuple(&tuple, db, version, diff)); INSIST(tuple == NULL); dns_rdata_reset(&rdata); - dns_db_detachnode(db, &newnode); + dns_db_detachnode(&newnode); } while (1); /* result cannot be ISC_R_NOMORE here */ @@ -868,10 +868,10 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (newnode != NULL) { - dns_db_detachnode(db, &newnode); + dns_db_detachnode(&newnode); } return result; } @@ -902,7 +902,7 @@ dns_nsec3_addnsec3s(dns_db_t *db, dns_dbversion_t *version, result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3param, 0, 0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { return ISC_R_SUCCESS; } @@ -934,7 +934,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; @@ -1019,7 +1019,7 @@ rr_exists(dns_db_t *db, dns_dbversion_t *ver, const dns_name_t *name, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -1174,7 +1174,7 @@ failure: if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -1281,7 +1281,7 @@ failure: dns_rdataset_disassociate(&prdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; @@ -1389,7 +1389,7 @@ dns_nsec3_delnsec3(dns_db_t *db, dns_dbversion_t *version, CHECK(dns_dbiterator_pause(dbit)); result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { goto cleanup_orphaned_ents; } @@ -1427,7 +1427,7 @@ dns_nsec3_delnsec3(dns_db_t *db, dns_dbversion_t *version, result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { continue; } @@ -1500,7 +1500,7 @@ cleanup_orphaned_ents: result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { goto success; } @@ -1531,7 +1531,7 @@ cleanup_orphaned_ents: result = dns_db_findrdataset( db, node, version, dns_rdatatype_nsec3, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { continue; } @@ -1582,7 +1582,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -1690,7 +1690,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; @@ -1728,7 +1728,7 @@ dns_nsec3_activex(dns_db_t *db, dns_dbversion_t *version, bool complete, } if (result != ISC_R_SUCCESS) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -1748,14 +1748,14 @@ dns_nsec3_activex(dns_db_t *db, dns_dbversion_t *version, bool complete, try_private: if (privatetype == 0 || complete) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); *answer = false; return ISC_R_SUCCESS; } result = dns_db_findrdataset(db, node, version, privatetype, 0, 0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { *answer = false; return ISC_R_SUCCESS; diff --git a/lib/dns/nta.c b/lib/dns/nta.c index 5896d410c7..fa4c7f243f 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -169,7 +169,7 @@ fetch_done(void *arg) { dns_resolver_destroyfetch(&resp->fetch); if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); diff --git a/lib/dns/private.c b/lib/dns/private.c index e16514cdeb..33d7292691 100644 --- a/lib/dns/private.c +++ b/lib/dns/private.c @@ -297,7 +297,7 @@ failure: dns_rdataset_disassociate(&privateset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 83ae15b273..0d8b9853f4 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -139,14 +139,20 @@ */ #define DNS_QPDB_EXPIRE_TTL_COUNT 10 +/*% + * Forward declarations + */ +typedef struct qpcache qpcache_t; + /*% * This is the structure that is used for each node in the qp trie of * trees. */ typedef struct qpcnode qpcnode_t; struct qpcnode { - dns_name_t name; - isc_mem_t *mctx; + DBNODE_FIELDS; + + qpcache_t *qpdb; uint8_t : 0; unsigned int delegating : 1; @@ -154,8 +160,6 @@ struct qpcnode { unsigned int havensec : 1; uint8_t : 0; - uint16_t locknum; - /* * 'erefs' counts external references held by a caller: for * example, it could be incremented by dns_db_findnode(), @@ -235,7 +239,6 @@ typedef struct qpcache_bucket { } qpcache_bucket_t; -typedef struct qpcache qpcache_t; struct qpcache { /* Unlocked. */ dns_db_t common; @@ -321,6 +324,31 @@ ISC_REFCOUNT_STATIC_TRACE_DECL(qpcnode); ISC_REFCOUNT_STATIC_DECL(qpcnode); #endif +/* + * Node methods forward declarations + */ +static void +qpcnode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG); +static void +qpcnode_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG); +static void +qpcnode_locknode(dns_dbnode_t *node, isc_rwlocktype_t type); +static void +qpcnode_unlocknode(dns_dbnode_t *node, isc_rwlocktype_t type); +static void +qpcnode_deletedata(dns_dbnode_t *node, void *data); +static void +qpcnode_expiredata(dns_dbnode_t *node, void *data); + +static dns_dbnode_methods_t qpcnode_methods = (dns_dbnode_methods_t){ + .attachnode = qpcnode_attachnode, + .detachnode = qpcnode_detachnode, + .locknode = qpcnode_locknode, + .unlocknode = qpcnode_unlocknode, + .deletedata = qpcnode_deletedata, + .expiredata = qpcnode_expiredata, +}; + /* QP methods */ static void qp_attach(void *uctx, void *pval, uint32_t ival); @@ -844,6 +872,7 @@ mark(dns_slabheader_t *header, uint_least16_t flag) { uint_least16_t newattributes = 0; dns_stats_t *stats = NULL; + qpcache_t *qpdb = HEADERNODE(header)->qpdb; /* * If we are already ancient there is nothing to do. */ @@ -859,7 +888,7 @@ mark(dns_slabheader_t *header, uint_least16_t flag) { * Decrement and increment the stats counter for the appropriate * RRtype. */ - stats = dns_db_getrrsetstats(header->db); + stats = dns_db_getrrsetstats(&qpdb->common); if (stats != NULL) { update_rrsetstats(stats, header->type, attributes, false); update_rrsetstats(stats, header->type, newattributes, true); @@ -903,7 +932,7 @@ expireheader(dns_slabheader_t *header, isc_rwlocktype_t *nlocktypep, mark_ancient(header); if (isc_refcount_current(&HEADERNODE(header)->erefs) == 0) { - qpcache_t *qpdb = (qpcache_t *)header->db; + qpcache_t *qpdb = HEADERNODE(header)->qpdb; /* * If no one else is using the node, we can clean it up now. @@ -2160,14 +2189,15 @@ getservestalerefresh(dns_db_t *db, uint32_t *interval) { } static void -expiredata(dns_db_t *db, dns_dbnode_t *node, void *data) { - qpcache_t *qpdb = (qpcache_t *)db; +qpcnode_expiredata(dns_dbnode_t *node, void *data) { qpcnode_t *qpnode = (qpcnode_t *)node; + qpcache_t *qpdb = (qpcache_t *)qpnode->qpdb; + dns_slabheader_t *header = data; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; isc_rwlocktype_t tlocktype = isc_rwlocktype_none; - isc_rwlock_t *nlock = &qpdb->buckets[qpnode->locknum].lock; + isc_rwlock_t *nlock = &qpdb->buckets[qpnode->locknum].lock; NODE_WRLOCK(nlock, &nlocktype); expireheader(header, &nlocktype, &tlocktype, dns_expire_flush DNS__DB_FILELINE); @@ -2333,6 +2363,8 @@ static qpcnode_t * new_qpcnode(qpcache_t *qpdb, const dns_name_t *name, dns_namespace_t nspace) { qpcnode_t *newdata = isc_mem_get(qpdb->common.mctx, sizeof(*newdata)); *newdata = (qpcnode_t){ + .methods = &qpcnode_methods, + .qpdb = qpdb, .name = DNS_NAME_INITEMPTY, .nspace = nspace, .references = ISC_REFCOUNT_INITIALIZER(1), @@ -2387,53 +2419,6 @@ unlock: return result; } -static void -qpcache_attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { - REQUIRE(VALID_QPDB((qpcache_t *)db)); - REQUIRE(targetp != NULL && *targetp == NULL); - - qpcache_t *qpdb = (qpcache_t *)db; - qpcnode_t *node = (qpcnode_t *)source; - - qpcnode_acquire(qpdb, node, isc_rwlocktype_none, - isc_rwlocktype_none DNS__DB_FLARG_PASS); - - *targetp = source; -} - -static void -qpcache_detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { - qpcache_t *qpdb = (qpcache_t *)db; - qpcnode_t *node = NULL; - isc_rwlocktype_t nlocktype = isc_rwlocktype_none; - isc_rwlocktype_t tlocktype = isc_rwlocktype_none; - isc_rwlock_t *nlock = NULL; - - REQUIRE(VALID_QPDB(qpdb)); - REQUIRE(nodep != NULL && *nodep != NULL); - - node = (qpcnode_t *)(*nodep); - *nodep = NULL; - nlock = &qpdb->buckets[node->locknum].lock; - - /* - * We can't destroy qpcache while holding a nodelock, so we need to - * reference it before acquiring the lock and release it afterward. - * Additionally, we must ensure that we don't destroy the database while - * the NODE_LOCK is locked. - */ - qpcache_ref(qpdb); - - rcu_read_lock(); - NODE_RDLOCK(nlock, &nlocktype); - qpcnode_release(qpdb, node, &nlocktype, &tlocktype DNS__DB_FLARG_PASS); - NODE_UNLOCK(nlock, &nlocktype); - rcu_read_unlock(); - - qpcache_detach(&qpdb); -} - static isc_result_t qpcache_createiterator(dns_db_t *db, unsigned int options ISC_ATTR_UNUSED, dns_dbiterator_t **iteratorp) { @@ -2504,6 +2489,52 @@ prio_header(dns_slabheader_t *header) { return prio_type(header->type); } +static void +qpcnode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG) { + REQUIRE(targetp != NULL && *targetp == NULL); + + qpcnode_t *node = (qpcnode_t *)source; + qpcache_t *qpdb = (qpcache_t *)node->qpdb; + + qpcnode_acquire(qpdb, node, isc_rwlocktype_none, + isc_rwlocktype_none DNS__DB_FLARG_PASS); + + *targetp = source; +} + +static void +qpcnode_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG) { + qpcnode_t *node = NULL; + isc_rwlocktype_t nlocktype = isc_rwlocktype_none; + isc_rwlocktype_t tlocktype = isc_rwlocktype_none; + isc_rwlock_t *nlock = NULL; + + REQUIRE(nodep != NULL && *nodep != NULL); + + node = (qpcnode_t *)(*nodep); + qpcache_t *qpdb = (qpcache_t *)node->qpdb; + *nodep = NULL; + nlock = &qpdb->buckets[node->locknum].lock; + + REQUIRE(VALID_QPDB(qpdb)); + + /* + * We can't destroy qpcache while holding a nodelock, so we need to + * reference it before acquiring the lock and release it afterward. + * Additionally, we must ensure that we don't destroy the database while + * the NODE_LOCK is locked. + */ + qpcache_ref(qpdb); + + rcu_read_lock(); + NODE_RDLOCK(nlock, &nlocktype); + qpcnode_release(qpdb, node, &nlocktype, &tlocktype DNS__DB_FLARG_PASS); + NODE_UNLOCK(nlock, &nlocktype); + rcu_read_unlock(); + + qpcache_detach(&qpdb); +} + static isc_result_t add(qpcache_t *qpdb, qpcnode_t *qpnode, const dns_name_t *nodename ISC_ATTR_UNUSED, dns_slabheader_t *newheader, @@ -2944,8 +2975,8 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, REQUIRE(VALID_QPDB(qpdb)); REQUIRE(version == NULL); - result = dns_rdataslab_fromrdataset(rdataset, qpdb->common.mctx, - ®ion, qpdb->maxrrperset); + result = dns_rdataslab_fromrdataset(rdataset, qpnode->mctx, ®ion, + qpdb->maxrrperset); if (result != ISC_R_SUCCESS) { if (result == DNS_R_TOOMANYRECORDS) { dns__db_logtoomanyrecords((dns_db_t *)qpdb, @@ -2987,16 +3018,16 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_OPTOUT); } if (rdataset->attributes.noqname) { - result = addnoqname(qpdb->common.mctx, newheader, - qpdb->maxrrperset, rdataset); + result = addnoqname(qpnode->mctx, newheader, qpdb->maxrrperset, + rdataset); if (result != ISC_R_SUCCESS) { dns_slabheader_destroy(&newheader); return result; } } if (rdataset->attributes.closest) { - result = addclosest(qpdb->common.mctx, newheader, - qpdb->maxrrperset, rdataset); + result = addclosest(qpnode->mctx, newheader, qpdb->maxrrperset, + rdataset); if (result != ISC_R_SUCCESS) { dns_slabheader_destroy(&newheader); return result; @@ -3139,17 +3170,17 @@ nodecount(dns_db_t *db, dns_dbtree_t tree) { } static void -locknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type) { - qpcache_t *qpdb = (qpcache_t *)db; +qpcnode_locknode(dns_dbnode_t *node, isc_rwlocktype_t type) { qpcnode_t *qpnode = (qpcnode_t *)node; + qpcache_t *qpdb = qpnode->qpdb; RWLOCK(&qpdb->buckets[qpnode->locknum].lock, type); } static void -unlocknode(dns_db_t *db, dns_dbnode_t *node, isc_rwlocktype_t type) { - qpcache_t *qpdb = (qpcache_t *)db; +qpcnode_unlocknode(dns_dbnode_t *node, isc_rwlocktype_t type) { qpcnode_t *qpnode = (qpcnode_t *)node; + qpcache_t *qpdb = qpnode->qpdb; RWUNLOCK(&qpdb->buckets[qpnode->locknum].lock, type); } @@ -3243,8 +3274,7 @@ rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG) { iterator = (qpc_rditer_t *)(*iteratorp); - dns__db_detachnode(iterator->common.db, - &iterator->common.node DNS__DB_FLARG_PASS); + dns__db_detachnode(&iterator->common.node DNS__DB_FLARG_PASS); isc_mem_put(iterator->common.db->mctx, iterator, sizeof(*iterator)); *iteratorp = NULL; @@ -3702,10 +3732,10 @@ dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) { } static void -deletedata(dns_db_t *db ISC_ATTR_UNUSED, dns_dbnode_t *node ISC_ATTR_UNUSED, - void *data) { +qpcnode_deletedata(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) { dns_slabheader_t *header = data; - qpcache_t *qpdb = (qpcache_t *)header->db; + qpcache_t *qpdb = HEADERNODE(header)->qpdb; + int idx = HEADERNODE(header)->locknum; if (header->heap != NULL && header->heap_index != 0) { @@ -3720,10 +3750,10 @@ deletedata(dns_db_t *db ISC_ATTR_UNUSED, dns_dbnode_t *node ISC_ATTR_UNUSED, } if (header->noqname != NULL) { - dns_slabheader_freeproof(db->mctx, &header->noqname); + dns_slabheader_freeproof(qpdb->common.mctx, &header->noqname); } if (header->closest != NULL) { - dns_slabheader_freeproof(db->mctx, &header->closest); + dns_slabheader_freeproof(qpdb->common.mctx, &header->closest); } } @@ -3784,8 +3814,6 @@ static dns_dbmethods_t qpdb_cachemethods = { .findnode = qpcache_findnode, .find = qpcache_find, .findzonecut = qpcache_findzonecut, - .attachnode = qpcache_attachnode, - .detachnode = qpcache_detachnode, .createiterator = qpcache_createiterator, .findrdataset = qpcache_findrdataset, .allrdatasets = qpcache_allrdatasets, @@ -3798,10 +3826,6 @@ static dns_dbmethods_t qpdb_cachemethods = { .getservestalettl = getservestalettl, .setservestalerefresh = setservestalerefresh, .getservestalerefresh = getservestalerefresh, - .locknode = locknode, - .unlocknode = unlocknode, - .expiredata = expiredata, - .deletedata = deletedata, .setmaxrrperset = setmaxrrperset, .setmaxtypepername = setmaxtypepername, }; diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 51c96a8c90..15163d85f9 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -172,11 +172,10 @@ typedef struct qpz_heap { ISC_REFCOUNT_STATIC_DECL(qpz_heap); struct qpznode { - dns_name_t name; - isc_mem_t *mctx; + DBNODE_FIELDS; qpz_heap_t *heap; - + qpzonedb_t *qpdb; /* * 'erefs' counts external references held by a caller: for * example, it could be incremented by dns_db_findnode(), @@ -202,7 +201,6 @@ struct qpznode { isc_refcount_t references; isc_refcount_t erefs; - uint16_t locknum; _Atomic(dns_namespace_t) nspace; atomic_bool havensec; atomic_bool wild; @@ -297,6 +295,7 @@ typedef struct { } qpz_load_t; static dns_dbmethods_t qpdb_zonemethods; +static dns_dbnode_methods_t qpznode_methods; #if DNS_DB_NODETRACE #define qpznode_ref(ptr) qpznode__ref(ptr, __func__, __FILE__, __LINE__) @@ -665,10 +664,12 @@ static qpznode_t * new_qpznode(qpzonedb_t *qpdb, const dns_name_t *name, dns_namespace_t nspace) { qpznode_t *newdata = isc_mem_get(qpdb->common.mctx, sizeof(*newdata)); *newdata = (qpznode_t){ + .methods = &qpznode_methods, .name = DNS_NAME_INITEMPTY, .nspace = nspace, .heap = qpdb->heap, .references = ISC_REFCOUNT_INITIALIZER(1), + .qpdb = qpdb, .locknum = qpzone_get_locknum(), }; @@ -1329,7 +1330,7 @@ resigninsert(dns_slabheader_t *newheader) { } static void -resigndelete(qpzonedb_t *qpdb, qpz_version_t *version, +resigndelete(qpzonedb_t *qpdb ISC_ATTR_UNUSED, qpz_version_t *version, dns_slabheader_t *header DNS__DB_FLARG) { if (header == NULL || header->heap_index == 0) { return; @@ -1832,8 +1833,8 @@ cname_and_other(qpznode_t *node, uint32_t serial) { static qpz_changed_t * add_changed(dns_slabheader_t *header, qpz_version_t *version DNS__DB_FLARG) { qpz_changed_t *changed = NULL; - qpzonedb_t *qpdb = (qpzonedb_t *)header->db; - qpznode_t *node = (qpznode_t *)header->node; + qpznode_t *node = HEADERNODE(header); + qpzonedb_t *qpdb = node->qpdb; changed = isc_mem_get(qpdb->common.mctx, sizeof(*changed)); @@ -2214,8 +2215,8 @@ loading_addrdataset(void *arg, const dns_name_t *name, } loading_addnode(loadctx, name, rdataset->type, rdataset->covers, &node); - result = dns_rdataslab_fromrdataset(rdataset, qpdb->common.mctx, - ®ion, qpdb->maxrrperset); + result = dns_rdataslab_fromrdataset(rdataset, node->mctx, ®ion, + qpdb->maxrrperset); if (result != ISC_R_SUCCESS) { if (result == DNS_R_TOOMANYRECORDS) { dns__db_logtoomanyrecords((dns_db_t *)qpdb, name, @@ -3968,10 +3969,9 @@ qpzone_allrdatasets(dns_db_t *db, dns_dbnode_t *dbnode, } static void -qpzone_attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { - qpzonedb_t *qpdb = (qpzonedb_t *)db; +qpzone_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG) { qpznode_t *node = (qpznode_t *)source; + qpzonedb_t *qpdb = node->qpdb; REQUIRE(VALID_QPZONE(qpdb)); REQUIRE(targetp != NULL && *targetp == NULL); @@ -3982,16 +3982,18 @@ qpzone_attachnode(dns_db_t *db, dns_dbnode_t *source, } static void -qpzone_detachnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { - qpzonedb_t *qpdb = (qpzonedb_t *)db; +qpzone_detachnode(dns_dbnode_t **nodep DNS__DB_FLARG) { qpznode_t *node = NULL; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; isc_rwlock_t *nlock = NULL; + qpzonedb_t *qpdb; - REQUIRE(VALID_QPZONE(qpdb)); REQUIRE(nodep != NULL && *nodep != NULL); node = (qpznode_t *)(*nodep); + qpdb = node->qpdb; + + REQUIRE(VALID_QPZONE(qpdb)); *nodep = NULL; nlock = qpzone_get_lock(node); @@ -4061,24 +4063,21 @@ getoriginnode(dns_db_t *db, dns_dbnode_t **nodep DNS__DB_FLARG) { } static void -locknode(dns_db_t *db ISC_ATTR_UNUSED, dns_dbnode_t *dbnode, - isc_rwlocktype_t type) { +locknode(dns_dbnode_t *dbnode, isc_rwlocktype_t type) { qpznode_t *node = (qpznode_t *)dbnode; RWLOCK(qpzone_get_lock(node), type); } static void -unlocknode(dns_db_t *db ISC_ATTR_UNUSED, dns_dbnode_t *dbnode, - isc_rwlocktype_t type) { +unlocknode(dns_dbnode_t *dbnode, isc_rwlocktype_t type) { qpznode_t *node = (qpznode_t *)dbnode; RWUNLOCK(qpzone_get_lock(node), type); } static void -deletedata(dns_db_t *db ISC_ATTR_UNUSED, dns_dbnode_t *node ISC_ATTR_UNUSED, - void *data) { +deletedata(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) { dns_slabheader_t *header = data; if (header->heap_index != 0) { @@ -4104,8 +4103,7 @@ rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG) { closeversion(qrditer->common.db, &qrditer->common.version, false DNS__DB_FLARG_PASS); } - dns__db_detachnode(qrditer->common.db, - &qrditer->common.node DNS__DB_FLARG_PASS); + dns__db_detachnode(&qrditer->common.node DNS__DB_FLARG_PASS); isc_mem_put(qrditer->common.db->mctx, qrditer, sizeof(*qrditer)); *iteratorp = NULL; @@ -4829,8 +4827,8 @@ qpzone_addrdataset(dns_db_t *db, dns_dbnode_t *dbnode, rdataset->type != dns_rdatatype_nsec3 && rdataset->covers != dns_rdatatype_nsec3)); - result = dns_rdataslab_fromrdataset(rdataset, qpdb->common.mctx, - ®ion, qpdb->maxrrperset); + result = dns_rdataslab_fromrdataset(rdataset, node->mctx, ®ion, + qpdb->maxrrperset); if (result != ISC_R_SUCCESS) { if (result == DNS_R_TOOMANYRECORDS) { dns__db_logtoomanyrecords((dns_db_t *)qpdb, &node->name, @@ -4951,8 +4949,7 @@ qpzone_subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, rdataset->covers != dns_rdatatype_nsec3)); dns_name_copy(&node->name, nodename); - result = dns_rdataslab_fromrdataset(rdataset, qpdb->common.mctx, - ®ion, 0); + result = dns_rdataslab_fromrdataset(rdataset, node->mctx, ®ion, 0); if (result != ISC_R_SUCCESS) { return result; } @@ -5143,13 +5140,11 @@ qpzone_deleterdataset(dns_db_t *db, dns_dbnode_t *dbnode, } static isc_result_t -nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name) { - qpzonedb_t *qpdb = (qpzonedb_t *)db; +nodefullname(dns_dbnode_t *node, dns_name_t *name) { qpznode_t *qpnode = (qpznode_t *)node; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; isc_rwlock_t *nlock = NULL; - REQUIRE(VALID_QPZONE(qpdb)); REQUIRE(node != NULL); REQUIRE(name != NULL); @@ -5305,12 +5300,10 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype, } if (node_a != NULL) { - dns__db_detachnode(ctx->db, - (dns_dbnode_t **)&node_a DNS__DB_FLARG_PASS); + dns__db_detachnode((dns_dbnode_t **)&node_a DNS__DB_FLARG_PASS); } if (node_aaaa != NULL) { dns__db_detachnode( - ctx->db, (dns_dbnode_t **)&node_aaaa DNS__DB_FLARG_PASS); } @@ -5511,8 +5504,6 @@ static dns_dbmethods_t qpdb_zonemethods = { .closeversion = closeversion, .findnode = qpzone_findnode, .find = qpzone_find, - .attachnode = qpzone_attachnode, - .detachnode = qpzone_detachnode, .createiterator = qpzone_createiterator, .findrdataset = qpzone_findrdataset, .allrdatasets = qpzone_allrdatasets, @@ -5529,15 +5520,20 @@ static dns_dbmethods_t qpdb_zonemethods = { .getsigningtime = getsigningtime, .getsize = getsize, .setgluecachestats = setgluecachestats, - .locknode = locknode, - .unlocknode = unlocknode, .addglue = addglue, - .deletedata = deletedata, - .nodefullname = nodefullname, .setmaxrrperset = setmaxrrperset, .setmaxtypepername = setmaxtypepername, }; +static dns_dbnode_methods_t qpznode_methods = (dns_dbnode_methods_t){ + .nodefullname = nodefullname, + .attachnode = qpzone_attachnode, + .detachnode = qpzone_detachnode, + .locknode = locknode, + .unlocknode = unlocknode, + .deletedata = deletedata, +}; + static void destroy_qpznode(qpznode_t *node) { dns_slabheader_t *current = NULL, *next = NULL; diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 8f796e4608..2af3f3ba50 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -863,7 +863,6 @@ dns_slabheader_reset(dns_slabheader_t *h, dns_db_t *db, dns_dbnode_t *node) { ISC_LINK_INIT(h, link); h->heap_index = 0; h->heap = NULL; - h->db = db; h->node = node; h->visited = false; @@ -894,9 +893,8 @@ dns_slabheader_destroy(dns_slabheader_t **headerp) { *headerp = NULL; - isc_mem_t *mctx = header->db->mctx; - - dns_db_deletedata(header->db, header->node, header); + isc_mem_t *mctx = header->node->mctx; + dns_db_deletedata(header->node, header); if (NONEXISTENT(header)) { size = sizeof(*header); @@ -967,10 +965,9 @@ dns_slabheader_top(dns_slabheader_t *header) { static void rdataset_disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG) { - dns_db_t *db = rdataset->slab.db; dns_dbnode_t *node = rdataset->slab.node; - dns__db_detachnode(db, &node DNS__DB_FLARG_PASS); + dns__db_detachnode(&node DNS__DB_FLARG_PASS); } static isc_result_t @@ -1049,11 +1046,10 @@ rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) { static void rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target DNS__DB_FLARG) { - dns_db_t *db = source->slab.db; dns_dbnode_t *node = source->slab.node; dns_dbnode_t *cloned_node = NULL; - dns__db_attachnode(db, node, &cloned_node DNS__DB_FLARG_PASS); + dns__db_attachnode(node, &cloned_node DNS__DB_FLARG_PASS); INSIST(!ISC_LINK_LINKED(target, link)); *target = *source; ISC_LINK_INIT(target, link); @@ -1086,8 +1082,7 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, * getownercase methods from affecting the case of NSEC/NSEC3 * owner names. */ - dns__db_attachnode(db, node, - &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); + dns__db_attachnode(node, &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); *nsec = (dns_rdataset_t){ .methods = &dns_rdataslab_rdatasetmethods, .rdclass = db->rdclass, @@ -1104,8 +1099,7 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, }; nsec->attributes.keepcase = true; - dns__db_attachnode(db, node, - &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); + dns__db_attachnode(node, &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); *nsecsig = (dns_rdataset_t){ .methods = &dns_rdataslab_rdatasetmethods, .rdclass = db->rdclass, @@ -1141,8 +1135,7 @@ rdataset_getclosest(dns_rdataset_t *rdataset, dns_name_t *name, * following an dns_slabheader, but in this case it points to a bare * rdataslab belonging to the dns_slabheader's `closest` field. */ - dns__db_attachnode(db, node, - &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); + dns__db_attachnode(node, &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); *nsec = (dns_rdataset_t){ .methods = &dns_rdataslab_rdatasetmethods, .rdclass = db->rdclass, @@ -1159,8 +1152,7 @@ rdataset_getclosest(dns_rdataset_t *rdataset, dns_name_t *name, }; nsec->attributes.keepcase = true; - dns__db_attachnode(db, node, - &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); + dns__db_attachnode(node, &(dns_dbnode_t *){ NULL } DNS__DB_FLARG_PASS); *nsecsig = (dns_rdataset_t){ .methods = &dns_rdataslab_rdatasetmethods, .rdclass = db->rdclass, @@ -1187,25 +1179,25 @@ static void rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) { dns_slabheader_t *header = dns_rdataset_getheader(rdataset); - dns_db_locknode(header->db, header->node, isc_rwlocktype_write); + dns_db_locknode(header->node, isc_rwlocktype_write); header->trust = rdataset->trust = trust; - dns_db_unlocknode(header->db, header->node, isc_rwlocktype_write); + dns_db_unlocknode(header->node, isc_rwlocktype_write); } static void rdataset_expire(dns_rdataset_t *rdataset DNS__DB_FLARG) { dns_slabheader_t *header = dns_rdataset_getheader(rdataset); - dns_db_expiredata(header->db, header->node, header); + dns_db_expiredata(header->node, header); } static void rdataset_clearprefetch(dns_rdataset_t *rdataset) { dns_slabheader_t *header = dns_rdataset_getheader(rdataset); - dns_db_locknode(header->db, header->node, isc_rwlocktype_write); + dns_db_locknode(header->node, isc_rwlocktype_write); DNS_SLABHEADER_CLRATTR(header, DNS_SLABHEADERATTR_PREFETCH); - dns_db_unlocknode(header->db, header->node, isc_rwlocktype_write); + dns_db_unlocknode(header->node, isc_rwlocktype_write); } static void @@ -1214,9 +1206,9 @@ rdataset_setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) { DNS_SLABHEADER_CLRATTR(header, DNS_SLABHEADERATTR_CASEFULLYLOWER); - dns_db_locknode(header->db, header->node, isc_rwlocktype_write); + dns_db_locknode(header->node, isc_rwlocktype_write); dns_slabheader_setownercase(header, name); - dns_db_unlocknode(header->db, header->node, isc_rwlocktype_write); + dns_db_unlocknode(header->node, isc_rwlocktype_write); } static void @@ -1230,7 +1222,7 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) { return; } - dns_db_locknode(header->db, header->node, isc_rwlocktype_read); + dns_db_locknode(header->node, isc_rwlocktype_read); if (CASESET(header)) { uint8_t *nd = name->ndata; for (size_t i = 0; i < name->length; i++) { @@ -1244,7 +1236,7 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) { : isc_ascii_tolower(nd[i]); } } - dns_db_unlocknode(header->db, header->node, isc_rwlocktype_read); + dns_db_unlocknode(header->node, isc_rwlocktype_read); } static dns_slabheader_t * diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 2d40ed2d96..3d1fb3e147 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4113,8 +4113,8 @@ resume_qmin(void *arg) { dns_rdataset_init(&sigrdataset); if (resp->node != NULL) { - dns_db_attachnode(resp->db, resp->node, &node); - dns_db_detachnode(resp->db, &resp->node); + dns_db_attachnode(resp->node, &node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_attach(resp->db, &db); @@ -4183,8 +4183,7 @@ resume_qmin(void *arg) { dns_db_attach(db, &resp->db); } if (node != NULL) { - dns_db_attachnode(db, node, - &resp->node); + dns_db_attachnode(node, &resp->node); } dns_name_copy(fname, resp->foundname); clone_results(fctx); @@ -4251,8 +4250,7 @@ resume_qmin(void *arg) { dns_db_attach(db, &resp->db); } if (node != NULL) { - dns_db_attachnode(db, node, - &resp->node); + dns_db_attachnode(node, &resp->node); } dns_name_copy(fname, resp->foundname); if (result == DNS_R_CNAME && @@ -4347,7 +4345,7 @@ resume_qmin(void *arg) { cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); @@ -5039,7 +5037,7 @@ clone_results(fetchctx_t *fctx) { resp->result = hresp->result; dns_name_copy(hresp->foundname, resp->foundname); dns_db_attach(hresp->db, &resp->db); - dns_db_attachnode(hresp->db, hresp->node, &resp->node); + dns_db_attachnode(hresp->node, &resp->node); INSIST(hresp->rdataset != NULL && resp->rdataset != NULL); if (dns_rdataset_isassociated(hresp->rdataset)) { @@ -5258,7 +5256,7 @@ cache_rrset(fetchctx_t *fctx, isc_stdtime_t now, dns_name_t *name, * detach it before returning. */ if (nodep != NULL && *nodep != NULL) { - dns_db_attachnode(fctx->cache, *nodep, &node); + dns_db_attachnode(*nodep, &node); } else { result = dns_db_findnode(fctx->cache, name, true, &node); } @@ -5284,7 +5282,7 @@ cache_rrset(fetchctx_t *fctx, isc_stdtime_t now, dns_name_t *name, if (nodep != NULL && *nodep == NULL) { *nodep = node; } else if (node != NULL) { - dns_db_detachnode(fctx->cache, &node); + dns_db_detachnode(&node); } return result; @@ -5306,7 +5304,7 @@ delete_rrset(fetchctx_t *fctx, dns_name_t *name, dns_rdatatype_t type, } if (node != NULL) { - dns_db_detachnode(fctx->cache, &node); + dns_db_detachnode(&node); } } @@ -5583,7 +5581,7 @@ cleanup: cleanup_unlocked: if (node != NULL) { - dns_db_detachnode(fctx->cache, &node); + dns_db_detachnode(&node); } if (nextval != NULL) { @@ -6069,7 +6067,7 @@ rctx_cachename(respctx_t *rctx, dns_message_t *message, dns_name_t *name) { cleanup: if (node != NULL) { - dns_db_detachnode(fctx->cache, &node); + dns_db_detachnode(&node); } return result; @@ -6269,7 +6267,7 @@ unlock: UNLOCK(&fctx->lock); if (node != NULL) { - dns_db_detachnode(fctx->cache, &node); + dns_db_detachnode(&node); } done: @@ -6731,7 +6729,7 @@ resume_dslookup(void *arg) { FCTXTRACE("resume_dslookup"); if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); @@ -9666,7 +9664,7 @@ prime_done(void *arg) { } if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index 295f30cd80..21183550c9 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -182,7 +182,7 @@ check_hints(dns_db_t *db) { goto cleanup; } dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } cleanup: @@ -193,7 +193,7 @@ cleanup: dns_rdatasetiter_destroy(&rdsiter); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (dbiter != NULL) { dns_dbiterator_destroy(&dbiter); diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 759cf4f4b3..88ca72de29 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1775,14 +1775,14 @@ update_nodes(dns_rpz_zone_t *rpz, isc_ht_t *newnodes) { "rpz: %s: failed to fetch " "rrdatasets - %s", domain, isc_result_totext(result)); - dns_db_detachnode(rpz->updb, &node); + dns_db_detachnode(&node); goto cleanup; } result = dns_rdatasetiter_first(rdsiter); dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(rpz->updb, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { /* skip empty non-terminal */ if (result != ISC_R_NOMORE) { diff --git a/lib/dns/rriterator.c b/lib/dns/rriterator.c index 6d4ea151b2..2adf531cb3 100644 --- a/lib/dns/rriterator.c +++ b/lib/dns/rriterator.c @@ -68,7 +68,7 @@ dns_rriterator_first(dns_rriterator_t *it) { dns_rdatasetiter_destroy(&it->rdatasetit); } if (it->node != NULL) { - dns_db_detachnode(it->db, &it->node); + dns_db_detachnode(&it->node); } it->result = dns_dbiterator_first(it->dbit); @@ -96,7 +96,7 @@ dns_rriterator_first(dns_rriterator_t *it) { * This node is empty. Try next node. */ dns_rdatasetiter_destroy(&it->rdatasetit); - dns_db_detachnode(it->db, &it->node); + dns_db_detachnode(&it->node); it->result = dns_dbiterator_next(it->dbit); continue; } @@ -122,7 +122,7 @@ dns_rriterator_nextrrset(dns_rriterator_t *it) { */ while (it->result == ISC_R_NOMORE) { dns_rdatasetiter_destroy(&it->rdatasetit); - dns_db_detachnode(it->db, &it->node); + dns_db_detachnode(&it->node); it->result = dns_dbiterator_next(it->dbit); if (it->result == ISC_R_NOMORE) { /* We are at the end of the entire database. */ @@ -188,7 +188,7 @@ dns_rriterator_destroy(dns_rriterator_t *it) { dns_rdatasetiter_destroy(&it->rdatasetit); } if (it->node != NULL) { - dns_db_detachnode(it->db, &it->node); + dns_db_detachnode(&it->node); } dns_dbiterator_destroy(&it->dbit); } diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 2a8b0b20c2..7e2064dc98 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -105,11 +105,11 @@ struct dns_sdlz_db { struct dns_sdlzlookup { /* Unlocked */ - unsigned int magic; + DBNODE_FIELDS; + dns_sdlz_db_t *sdlz; ISC_LIST(dns_rdatalist_t) lists; ISC_LIST(isc_buffer_t) buffers; - dns_name_t name; ISC_LINK(dns_sdlzlookup_t) link; dns_rdatacallbacks_t callbacks; @@ -187,8 +187,18 @@ static void list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node, dns_rdataset_t *rdataset); +/* + * Node methods forward declarations + */ static void -detachnode(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG); +sdlznode_attachnode(dns_dbnode_t *source, dns_dbnode_t **targetp DNS__DB_FLARG); +static void +sdlznode_detachnode(dns_dbnode_t **targetp DNS__DB_FLARG); + +static dns_dbnode_methods_t sdlznode_methods = (dns_dbnode_methods_t){ + .attachnode = sdlznode_attachnode, + .detachnode = sdlznode_detachnode, +}; static void dbiterator_destroy(dns_dbiterator_t **iteratorp DNS__DB_FLARG); @@ -248,8 +258,7 @@ static void rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp DNS__DB_FLARG) { sdlz_rdatasetiter_t *sdlziterator = (sdlz_rdatasetiter_t *)(*iteratorp); - detachnode(sdlziterator->common.db, - &sdlziterator->common.node DNS__DB_FLARG_PASS); + sdlznode_detachnode(&sdlziterator->common.node DNS__DB_FLARG_PASS); isc_mem_put(sdlziterator->common.db->mctx, sdlziterator, sizeof(sdlz_rdatasetiter_t)); *iteratorp = NULL; @@ -396,6 +405,7 @@ createnode(dns_sdlz_db_t *sdlz, dns_sdlznode_t **nodep) { node = isc_mem_get(sdlz->common.mctx, sizeof(dns_sdlznode_t)); + node->methods = &sdlznode_methods; node->sdlz = NULL; dns_db_attach((dns_db_t *)sdlz, (dns_db_t **)&node->sdlz); ISC_LIST_INIT(node->lists); @@ -622,16 +632,11 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create, } static void -attachnode(dns_db_t *db, dns_dbnode_t *source, - dns_dbnode_t **targetp DNS__DB_FLARG) { - dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db; +sdlznode_attachnode(dns_dbnode_t *source, + dns_dbnode_t **targetp DNS__DB_FLARG) { dns_sdlznode_t *node = (dns_sdlznode_t *)source; uint_fast32_t refs; - REQUIRE(VALID_SDLZDB(sdlz)); - - UNUSED(sdlz); - refs = isc_refcount_increment(&node->references); #if DNS_DB_NODETRACE fprintf(stderr, "incr:node:%s:%s:%u:%p->references = %" PRIuFAST32 "\n", @@ -644,16 +649,12 @@ attachnode(dns_db_t *db, dns_dbnode_t *source, } static void -detachnode(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG) { - dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db; +sdlznode_detachnode(dns_dbnode_t **targetp DNS__DB_FLARG) { dns_sdlznode_t *node; uint_fast32_t refs; - REQUIRE(VALID_SDLZDB(sdlz)); REQUIRE(targetp != NULL && *targetp != NULL); - UNUSED(sdlz); - node = (dns_sdlznode_t *)(*targetp); *targetp = NULL; @@ -878,7 +879,7 @@ findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, * and try again. */ if (i < nlabels) { - detachnode(db, &node DNS__DB_FLARG_PASS); + sdlznode_detachnode(&node DNS__DB_FLARG_PASS); node = NULL; continue; } @@ -928,7 +929,7 @@ findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, if (nodep != NULL) { *nodep = node; } else if (node != NULL) { - detachnode(db, &node DNS__DB_FLARG_PASS); + sdlznode_detachnode(&node DNS__DB_FLARG_PASS); } return result; @@ -964,7 +965,8 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, iterator->common.methods = &rdatasetiter_methods; iterator->common.db = db; iterator->common.node = NULL; - attachnode(db, node, &iterator->common.node DNS__DB_FLARG_PASS); + sdlznode_attachnode((dns_dbnode_t *)node, + &iterator->common.node DNS__DB_FLARG_PASS); iterator->common.version = version; iterator->common.options = options; iterator->common.now = now; @@ -1157,8 +1159,6 @@ static dns_dbmethods_t sdlzdb_methods = { .closeversion = closeversion, .findnode = findnode, .find = find, - .attachnode = attachnode, - .detachnode = detachnode, .createiterator = createiterator, .findrdataset = findrdataset, .allrdatasets = allrdatasets, @@ -1265,8 +1265,8 @@ dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep, dns_name_t *name DNS__DB_FLARG) { sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator; - attachnode(iterator->db, (dns_dbnode_t *)sdlziter->current, - nodep DNS__DB_FLARG_PASS); + sdlznode_attachnode((dns_dbnode_t *)sdlziter->current, + nodep DNS__DB_FLARG_PASS); if (name != NULL) { dns_name_copy(&sdlziter->current->name, name); return ISC_R_SUCCESS; @@ -1295,21 +1295,16 @@ dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) { static void disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG) { dns_dbnode_t *node = rdataset->rdlist.node; - dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)node; - dns_db_t *db = (dns_db_t *)sdlznode->sdlz; - - detachnode(db, &node DNS__DB_FLARG_PASS); + sdlznode_detachnode(&node DNS__DB_FLARG_PASS); dns_rdatalist_disassociate(rdataset DNS__DB_FLARG_PASS); } static void rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target DNS__DB_FLARG) { dns_dbnode_t *node = source->rdlist.node; - dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)node; - dns_db_t *db = (dns_db_t *)sdlznode->sdlz; dns_rdatalist_clone(source, target DNS__DB_FLARG_PASS); - attachnode(db, node, &target->rdlist.node DNS__DB_FLARG_PASS); + sdlznode_attachnode(node, &target->rdlist.node DNS__DB_FLARG_PASS); } static dns_rdatasetmethods_t rdataset_methods = { @@ -1324,8 +1319,8 @@ static dns_rdatasetmethods_t rdataset_methods = { }; static void -list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node, - dns_rdataset_t *rdataset) { +list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db ISC_ATTR_UNUSED, + dns_dbnode_t *node, dns_rdataset_t *rdataset) { /* * The sdlz rdataset is an rdatalist, but additionally holds * a database node reference. @@ -1333,7 +1328,7 @@ list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node, dns_rdatalist_tordataset(rdatalist, rdataset); rdataset->methods = &rdataset_methods; - dns_db_attachnode(db, node, &rdataset->rdlist.node); + dns_db_attachnode(node, &rdataset->rdlist.node); } /* diff --git a/lib/dns/update.c b/lib/dns/update.c index 0cd35bd6dd..b0781de441 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -372,7 +372,7 @@ foreach_rrset(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_rdatasetiter_destroy(&iter); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -457,7 +457,7 @@ foreach_rr(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, cleanup_rdataset: dns_rdataset_disassociate(&rdataset); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -728,7 +728,7 @@ namelist_append_subdomain(dns_db_t *db, dns_name_t *name, { dns_dbnode_t *node = NULL; CHECK(dns_dbiterator_current(dbit, &node, child)); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (!dns_name_issubdomain(child, name)) { break; } @@ -905,7 +905,7 @@ next_active(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, } } CHECK(dns_dbiterator_current(dbit, &node, newname)); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* * The iterator may hold the tree lock, and @@ -974,7 +974,7 @@ add_nsec(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, CHECK(dns_db_findnode(db, name, false, &node)); dns_rdata_init(&rdata); CHECK(dns_nsec_buildrdata(db, ver, node, target, buffer, &rdata)); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* * Delete the old NSEC and record the change. @@ -991,7 +991,7 @@ add_nsec(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -1110,7 +1110,7 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, } CHECK(dns_db_findrdataset(db, node, ver, type, 0, (isc_stdtime_t)0, &rdataset, NULL)); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); #define REVOKE(x) ((dst_key_flags(x) & DNS_KEYFLAG_REVOKE) != 0) #define KSK(x) ((dst_key_flags(x) & DNS_KEYFLAG_KSK) != 0) @@ -1258,7 +1258,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -1289,7 +1289,7 @@ del_keysigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, result = dns_db_findrdataset(db, node, ver, dns_rdatatype_rrsig, dns_rdatatype_dnskey, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { return ISC_R_SUCCESS; @@ -1339,7 +1339,7 @@ del_keysigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -1405,7 +1405,7 @@ add_exposed_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, dns_rdatasetiter_destroy(&iter); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -1556,7 +1556,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, CHECK(dns_rdata_tostruct(&rdata, &soa, NULL)); state->nsecttl = ISC_MIN(rdataset.ttl, soa.minimum); dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* * Find all RRsets directly affected by the update, and @@ -2125,7 +2125,7 @@ next_state: failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_diff_clear(&state->sig_diff); diff --git a/lib/dns/validator.c b/lib/dns/validator.c index c3247cc2d8..bf176aa509 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -408,7 +408,7 @@ fetch_callback_dnskey(void *arg) { /* Free resources which are not of interest. */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); @@ -504,7 +504,7 @@ fetch_callback_ds(void *arg) { /* Free resources which are not of interest. */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); diff --git a/lib/dns/view.c b/lib/dns/view.c index 662eecf3e1..e8a711f434 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -844,7 +844,7 @@ db_find: dns_rdataset_disassociate(sigrdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (!is_cache) { dns_db_detach(&db); @@ -878,7 +878,7 @@ db_find: dns_db_detach(&db); } dns_db_attach(zdb, &db); - dns_db_attachnode(db, znode, &node); + dns_db_attachnode(znode, &node); goto cleanup; } } @@ -906,7 +906,7 @@ db_find: } if (db != NULL) { if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); } @@ -937,7 +937,7 @@ db_find: * Cleanup if non-standard hints are used. */ if (db == NULL && node != NULL) { - dns_db_detachnode(view->hints, &node); + dns_db_detachnode(&node); } } @@ -951,7 +951,7 @@ cleanup: if (zdb != NULL) { if (znode != NULL) { - dns_db_detachnode(zdb, &znode); + dns_db_detachnode(&znode); } dns_db_detach(&zdb); } @@ -961,7 +961,7 @@ cleanup: if (nodep != NULL) { *nodep = node; } else { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } } if (dbp != NULL) { diff --git a/lib/dns/zone.c b/lib/dns/zone.c index f015a2c01e..beb7f1b900 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -3314,11 +3314,11 @@ zone_check_dup(dns_zone_t *zone, dns_db_t *db) { dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&rdsit); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiterator); @@ -3723,7 +3723,7 @@ integrity_checks(dns_zone_t *zone, dns_db_t *db) { } next: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (has_a) { @@ -3792,7 +3792,7 @@ integrity_checks(dns_zone_t *zone, dns_db_t *db) { cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiterator); @@ -3902,7 +3902,7 @@ zone_check_dnskeys(dns_zone_t *zone, dns_db_t *db) { cleanup: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); @@ -3974,7 +3974,7 @@ resume_signingwithkey(dns_zone_t *zone) { cleanup: if (db != NULL) { if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); @@ -4261,7 +4261,7 @@ resume_addnsec3chain(dns_zone_t *zone) { cleanup: if (db != NULL) { if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); @@ -4419,7 +4419,7 @@ cleanup: dns_rdataset_disassociate(&rdataset); } dns_db_closeversion(db, &version, false); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -5188,7 +5188,7 @@ check_reportchannel(dns_zone_t *zone, dns_db_t *db) { result = dns_db_findrdataset(db, node, version, dns_rdatatype_txt, dns_rdatatype_none, 0, &rdataset, NULL); dns_db_closeversion(db, &version, false); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_SUCCESS) { dns_rdataset_disassociate(&rdataset); } @@ -6060,7 +6060,7 @@ zone_get_from_db(dns_zone_t *zone, dns_db_t *db, unsigned int *nscount, } } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); closeversion: dns_db_closeversion(db, &version, false); @@ -6814,7 +6814,7 @@ dns_zone_findkeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -6897,7 +6897,7 @@ failure: dns_rdataset_disassociate(&keyset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } ISC_LIST_FOREACH (dnskeys, key, link) { ISC_LIST_UNLINK(dnskeys, key, link); @@ -7091,7 +7091,7 @@ del_sigs(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, } result = dns_db_findrdataset(db, node, ver, dns_rdatatype_rrsig, type, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { INSIST(!dns_rdataset_isassociated(&rdataset)); @@ -7249,7 +7249,7 @@ del_sigs(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, } failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -7291,7 +7291,7 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone, } result = dns_db_findrdataset(db, node, ver, type, 0, (isc_stdtime_t)0, &rdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result == ISC_R_NOTFOUND) { INSIST(!dns_rdataset_isassociated(&rdataset)); return ISC_R_SUCCESS; @@ -7456,7 +7456,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -7741,7 +7741,7 @@ next_active(dns_db_t *db, dns_dbversion_t *version, dns_name_t *oldname, if (bottom && dns_name_issubdomain(newname, oldname) && !dns_name_equal(newname, oldname)) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); continue; } /* @@ -7749,7 +7749,7 @@ next_active(dns_db_t *db, dns_dbversion_t *version, dns_name_t *oldname, */ CHECK(dns_db_allrdatasets(db, node, version, 0, 0, &rdsit)); result = dns_rdatasetiter_first(rdsit); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_rdatasetiter_destroy(&rdsit); if (result != ISC_R_NOMORE) { break; @@ -7757,7 +7757,7 @@ next_active(dns_db_t *db, dns_dbversion_t *version, dns_name_t *oldname, } while (1); failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (dbit != NULL) { dns_dbiterator_destroy(&dbit); @@ -8097,7 +8097,7 @@ success: result = ISC_R_SUCCESS; failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -8225,7 +8225,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(signing->db, &node); + dns_db_detachnode(&node); } return result; } @@ -8427,7 +8427,7 @@ add: CHECK(update_one_rr(db, ver, diff, DNS_DIFFOP_ADD, name, ttl, &rdata)); failure: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); } @@ -8522,11 +8522,11 @@ need_nsec_chain(dns_db_t *db, dns_dbversion_t *ver, &rdataset, NULL); if (result == ISC_R_SUCCESS) { dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } if (result != ISC_R_NOTFOUND) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -8534,11 +8534,11 @@ need_nsec_chain(dns_db_t *db, dns_dbversion_t *ver, 0, &rdataset, NULL); if (result == ISC_R_NOTFOUND) { *answer = true; - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return ISC_R_SUCCESS; } if (result != ISC_R_SUCCESS) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -8578,7 +8578,7 @@ failure: if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -8941,7 +8941,7 @@ zone_nsec3chain(dns_zone_t *zone) { */ next_addnode: first = false; - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); do { result = dns_dbiterator_next(nsec3chain->dbiterator); @@ -8984,7 +8984,7 @@ zone_nsec3chain(dns_zone_t *zone) { } else if (delegation) { dns_dbiterator_current(nsec3chain->dbiterator, &node, nextname); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (!dns_name_issubdomain(nextname, name)) { break; } @@ -9184,7 +9184,7 @@ zone_nsec3chain(dns_zone_t *zone) { next_removenode: first = false; - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); do { result = dns_dbiterator_next(nsec3chain->dbiterator); if (result == ISC_R_NOMORE && buildnsecchain) { @@ -9222,7 +9222,7 @@ zone_nsec3chain(dns_zone_t *zone) { } else if (delegation) { dns_dbiterator_current(nsec3chain->dbiterator, &node, nextname); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (!dns_name_issubdomain(nextname, name)) { break; } @@ -9271,7 +9271,7 @@ skip_removals: dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&iterator); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (rebuild_nsec) { if (nsec3chain != NULL) { @@ -9498,7 +9498,7 @@ failure: } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); @@ -10051,7 +10051,7 @@ zone_sign(dns_zone_t *zone) { */ next_node: first = false; - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); do { result = dns_dbiterator_next(signing->dbiterator); if (result == ISC_R_NOMORE) { @@ -10099,7 +10099,7 @@ zone_sign(dns_zone_t *zone) { } else if (is_bottom_of_zone) { dns_dbiterator_current(signing->dbiterator, &node, nextname); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (!dns_name_issubdomain(nextname, name)) { break; } @@ -10242,7 +10242,7 @@ cleanup: } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { @@ -10588,7 +10588,7 @@ keyfetch_done(void *arg) { /* Free resources which are not of interest */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); @@ -13325,7 +13325,7 @@ cleanup3: dns_name_free(&primary, zone->mctx); } cleanup2: - dns_db_detachnode(zonedb, &node); + dns_db_detachnode(&node); cleanup1: dns_db_closeversion(zonedb, &version, false); dns_db_detach(&zonedb); @@ -13621,7 +13621,7 @@ stub_glue_response(void *arg) { "dns_db_addrdataset() failed: %s", isc_result_totext(result)); } - dns_db_detachnode(stub->db, &node); + dns_db_detachnode(&node); cleanup: if (msg != NULL) { @@ -13754,7 +13754,7 @@ save_nsrrset(dns_message_t *message, dns_name_t *name, goto done; } result = dns_db_addrdataset(db, node, version, 0, nsrdataset, 0, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { goto done; } @@ -13783,7 +13783,7 @@ save_nsrrset(dns_message_t *message, dns_name_t *name, } result = dns_db_addrdataset(db, node, version, 0, rdataset, 0, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { goto done; } @@ -13801,7 +13801,7 @@ save_nsrrset(dns_message_t *message, dns_name_t *name, } result = dns_db_addrdataset(db, node, version, 0, rdataset, 0, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { goto done; } @@ -15017,7 +15017,7 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) { result = dns_db_addrdataset(stub->db, node, stub->version, 0, soardataset, 0, NULL); - dns_db_detachnode(stub->db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { dns_zone_log(zone, ISC_LOG_INFO, "refreshing stub: " @@ -15643,7 +15643,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags, soa_cleanup: if (node != NULL) { - dns_db_detachnode(zonedb, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(zonedb, &version, false); @@ -16970,7 +16970,7 @@ sync_secure_db(dns_zone_t *seczone, dns_zone_t *raw, dns_db_t *secdb, if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); } - dns_db_detachnode(secdb, &node); + dns_db_detachnode(&node); } ISC_LIST_FOREACH (diff->tuples, tuple, link) { @@ -17559,7 +17559,7 @@ done: failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); @@ -17675,10 +17675,10 @@ cleanup: dns_rdatasetiter_destroy(&rdsit); } if (rawnode) { - dns_db_detachnode(rawdb, &rawnode); + dns_db_detachnode(&rawnode); } if (node) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -20511,7 +20511,7 @@ rr_exists(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -20799,7 +20799,7 @@ clean_nsec3param(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -21758,7 +21758,7 @@ nsfetch_done(void *arg) { /* Free resources which are not of interest */ if (resp->node != NULL) { - dns_db_detachnode(resp->db, &resp->node); + dns_db_detachnode(&resp->node); } if (resp->db != NULL) { dns_db_detach(&resp->db); @@ -22964,7 +22964,7 @@ failure: dns_rdataset_disassociate(&cdnskeyset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); @@ -23006,7 +23006,7 @@ dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version, return result; } result = zone_count_ns_rr(zone, db, node, version, NULL, errors, false); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -23255,7 +23255,7 @@ failure: if (dns_rdataset_isassociated(&cdnskey)) { dns_rdataset_disassociate(&cdnskey); } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -23609,7 +23609,7 @@ failure: } if (db != NULL) { if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (oldver != NULL) { dns_db_closeversion(db, &oldver, false); @@ -23963,7 +23963,7 @@ failure: dns_rdataset_disassociate(&nrdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (oldver != NULL) { dns_db_closeversion(db, &oldver, false); @@ -24129,7 +24129,7 @@ failure: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (version != NULL) { dns_db_closeversion(db, &version, false); diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index 9acab371e7..181e31cff8 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -665,7 +665,7 @@ done: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); } return result; @@ -763,7 +763,7 @@ done: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); } return result; @@ -1408,7 +1408,7 @@ check_apex_rrsets(vctx_t *vctx) { result = ISC_R_SUCCESS; done: - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); return result; } @@ -1734,10 +1734,10 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { if (!dns_name_issubdomain(name, vctx->origin)) { result = check_no_nsec(vctx, name, node); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); result = dns_dbiterator_next(dbiter); if (result == ISC_R_NOMORE) { done = true; @@ -1770,7 +1770,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { "dns_dbiterator_current():" " %s", isc_result_totext(result)); - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } if (!dns_name_issubdomain(nextname, vctx->origin) || @@ -1780,16 +1780,16 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { result = check_no_nsec(vctx, nextname, nextnode); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(vctx->db, &node); - dns_db_detachnode(vctx->db, &nextnode); + dns_db_detachnode(&node); + dns_db_detachnode(&nextnode); goto done; } - dns_db_detachnode(vctx->db, &nextnode); + dns_db_detachnode(&nextnode); result = dns_dbiterator_next(dbiter); continue; } result = is_empty(vctx, nextnode); - dns_db_detachnode(vctx->db, &nextnode); + dns_db_detachnode(&nextnode); switch (result) { case ISC_R_SUCCESS: break; @@ -1797,7 +1797,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { result = dns_dbiterator_next(dbiter); continue; default: - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); } break; } @@ -1809,14 +1809,14 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { "iterating through the database " "failed: %s", isc_result_totext(result)); - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } result = verifynode(vctx, name, node, isdelegation, dstkeys, nkeys, &vctx->nsecset, &vctx->nsec3paramset, nextname, &tvresult); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } if (*vresult == ISC_R_UNSET) { @@ -1830,7 +1830,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { vctx, name, prevname, isdelegation, &vctx->nsec3paramset, &tvresult); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } } else { @@ -1840,7 +1840,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { if (*vresult == ISC_R_SUCCESS) { *vresult = tvresult; } - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); } dns_dbiterator_destroy(&dbiter); @@ -1865,11 +1865,11 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { if (result != ISC_R_SUCCESS) { zoneverify_log_error(vctx, "verifynode: %s", isc_result_totext(result)); - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); goto done; } result = record_found(vctx, name, node, &vctx->nsec3paramset); - dns_db_detachnode(vctx->db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { goto done; } diff --git a/lib/ns/query.c b/lib/ns/query.c index c698a93d6e..810e9f1eaf 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -806,8 +806,7 @@ query_reset(ns_client_t *client, bool everything) { ns_client_putrdataset(client, &client->query.redirect.sigrdataset); if (client->query.redirect.db != NULL) { if (client->query.redirect.node != NULL) { - dns_db_detachnode(client->query.redirect.db, - &client->query.redirect.node); + dns_db_detachnode(&client->query.redirect.node); } dns_db_detach(&client->query.redirect.db); } @@ -1614,7 +1613,7 @@ query_additionalauthfind(dns_db_t *db, dns_dbversion_t *version, } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; @@ -1845,7 +1844,7 @@ query_additional_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype, dns_rdataset_disassociate(sigrdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); @@ -2142,7 +2141,7 @@ cleanup: ns_client_releasename(client, &fname); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); @@ -2350,7 +2349,7 @@ mark_secure(ns_client_t *client, dns_db_t *db, dns_name_t *name, NULL); (void)dns_db_addrdataset(db, node, NULL, client->inner.now, sigrdataset, 0, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } /* @@ -2382,7 +2381,7 @@ get_key(ns_client_t *client, dns_db_t *db, dns_rdata_rrsig_t *rrsig, result = dns_db_findrdataset( db, node, NULL, dns_rdatatype_dnskey, 0, client->inner.now, keyrdataset, NULL); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); if (result != ISC_R_SUCCESS) { return false; } @@ -2545,7 +2544,7 @@ free_fresp(ns_client_t *client, dns_fetchresponse_t **frespp) { dns_resolver_destroyfetch(&fresp->fetch); } if (fresp->node != NULL) { - dns_db_detachnode(fresp->db, &fresp->node); + dns_db_detachnode(&fresp->node); } if (fresp->db != NULL) { dns_db_detach(&fresp->db); @@ -2685,7 +2684,7 @@ stale_refresh_aftermath(ns_client_t *client, isc_result_t result) { qctx.fname, &cm, &ci, qctx.rdataset, qctx.sigrdataset); if (qctx.node != NULL) { - dns_db_detachnode(db, &qctx.node); + dns_db_detachnode(&qctx.node); } dns_db_detach(&db); @@ -2890,7 +2889,7 @@ rpz_clean(dns_zone_t **zonep, dns_db_t **dbp, dns_dbnode_t **nodep, dns_rdataset_t **rdatasetp) { if (nodep != NULL && *nodep != NULL) { REQUIRE(dbp != NULL && *dbp != NULL); - dns_db_detachnode(*dbp, nodep); + dns_db_detachnode(nodep); } if (dbp != NULL && *dbp != NULL) { dns_db_detach(dbp); @@ -3326,7 +3325,7 @@ rpz_find_p(ns_client_t *client, dns_name_t *self_name, dns_rdatatype_t qtype, if (dns_rdataset_isassociated(*rdatasetp)) { dns_rdataset_disassociate(*rdatasetp); } - dns_db_detachnode(*dbp, nodep); + dns_db_detachnode(nodep); if (dns_rdatatype_issig(qtype)) { result = DNS_R_NXRRSET; @@ -4627,7 +4626,7 @@ cleanup: dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return ttl; } @@ -4790,7 +4789,7 @@ redirect(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, dns_rdataset_disassociate(&trdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); return ISC_R_NOTFOUND; @@ -4807,12 +4806,12 @@ redirect(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, } nxrrset: if (*nodep != NULL) { - dns_db_detachnode(*dbp, nodep); + dns_db_detachnode(nodep); } dns_db_detach(dbp); - dns_db_attachnode(db, node, nodep); + dns_db_attachnode(node, nodep); dns_db_attach(db, dbp); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_detach(&db); *versionp = dbversion->version; @@ -4937,7 +4936,7 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, dns_rdataset_disassociate(&trdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); /* @@ -4960,7 +4959,7 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, dns_rdataset_disassociate(&trdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); return ISC_R_NOTFOUND; @@ -4989,12 +4988,12 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, } nxrrset: if (*nodep != NULL) { - dns_db_detachnode(*dbp, nodep); + dns_db_detachnode(nodep); } dns_db_detach(dbp); - dns_db_attachnode(db, node, nodep); + dns_db_attachnode(node, nodep); dns_db_attach(db, dbp); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_detach(&db); *is_zonep = is_zone; *versionp = version; @@ -5063,7 +5062,7 @@ qctx_clean(query_ctx_t *qctx) { dns_rdataset_disassociate(qctx->sigrdataset); } if (qctx->db != NULL && qctx->node != NULL) { - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); } if (qctx->client != NULL && qctx->client->query.gluedb != NULL) { dns_db_detach(&qctx->client->query.gluedb); @@ -5100,7 +5099,7 @@ qctx_freedata(query_ctx_t *qctx) { ns_client_putrdataset(qctx->client, &qctx->zsigrdataset); ns_client_putrdataset(qctx->client, &qctx->zrdataset); ns_client_releasename(qctx->client, &qctx->zfname); - dns_db_detachnode(qctx->zdb, &qctx->znode); + dns_db_detachnode(&qctx->znode); dns_db_detach(&qctx->zdb); qctx->zversion = NULL; } @@ -6373,7 +6372,7 @@ query_resume(query_ctx_t *qctx) { qctx->qtype = qctx->rpz_st->q.qtype; if (qctx->fresp->node != NULL) { - dns_db_detachnode(qctx->fresp->db, &qctx->fresp->node); + dns_db_detachnode(&qctx->fresp->node); } SAVE(qctx->rpz_st->r.db, qctx->fresp->db); qctx->rpz_st->r.r_type = qctx->fresp->qtype; @@ -6411,7 +6410,7 @@ query_resume(query_ctx_t *qctx) { ns_client_putrdataset(qctx->client, &qctx->fresp->rdataset); ns_client_putrdataset(qctx->client, &qctx->fresp->sigrdataset); if (qctx->fresp->node != NULL) { - dns_db_detachnode(qctx->fresp->db, &qctx->fresp->node); + dns_db_detachnode(&qctx->fresp->node); } if (qctx->fresp->db != NULL) { dns_db_detach(&qctx->fresp->db); @@ -8003,7 +8002,7 @@ query_respond(query_ctx_t *qctx) { SAVE(qctx->client->query.dns64_aaaa, qctx->rdataset); SAVE(qctx->client->query.dns64_sigaaaa, qctx->sigrdataset); ns_client_releasename(qctx->client, &qctx->fname); - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); qctx->type = qctx->qtype = dns_rdatatype_a; qctx->dns64_exclude = qctx->dns64 = true; @@ -8491,7 +8490,7 @@ query_zone_delegation(query_ctx_t *qctx) { &qctx->fname); } if (qctx->node != NULL) { - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); } if (qctx->db != NULL) { dns_db_detach(&qctx->db); @@ -8615,7 +8614,7 @@ query_delegation(query_ctx_t *qctx) { } qctx->version = NULL; - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); dns_db_detach(&qctx->db); RESTORE(qctx->db, qctx->zdb); RESTORE(qctx->node, qctx->znode); @@ -8924,7 +8923,7 @@ query_nodata(query_ctx_t *qctx, isc_result_t res) { SAVE(qctx->client->query.dns64_aaaa, qctx->rdataset); SAVE(qctx->client->query.dns64_sigaaaa, qctx->sigrdataset); ns_client_releasename(qctx->client, &qctx->fname); - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); qctx->type = qctx->qtype = dns_rdatatype_a; qctx->dns64 = true; return query_lookup(qctx); @@ -9890,7 +9889,7 @@ query_coveringnsec(query_ctx_t *qctx) { } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } soardataset = ns_client_newrdataset(qctx->client); @@ -9926,7 +9925,7 @@ cleanup: } if (db != NULL) { if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); } @@ -9944,7 +9943,7 @@ cleanup: ns_client_releasename(qctx->client, &qctx->fname); } if (qctx->node != NULL) { - dns_db_detachnode(qctx->db, &qctx->node); + dns_db_detachnode(&qctx->node); } ns_client_putrdataset(qctx->client, &qctx->rdataset); if (qctx->sigrdataset != NULL) { @@ -10508,7 +10507,7 @@ query_addsoa(query_ctx_t *qctx, unsigned int override_ttl, ns_client_releasename(client, &name); } if (node != NULL) { - dns_db_detachnode(qctx->db, &node); + dns_db_detachnode(&node); } return eresult; @@ -10592,7 +10591,7 @@ query_addns(query_ctx_t *qctx) { ns_client_releasename(client, &name); } if (node != NULL) { - dns_db_detachnode(qctx->db, &node); + dns_db_detachnode(&node); } CTRACE(ISC_LOG_DEBUG(3), "query_addns: done"); @@ -10692,7 +10691,7 @@ db_find: } if (USECACHE(client)) { ns_client_keepname(client, fname, dbuf); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); SAVE(zdb, db); SAVE(zfname, fname); SAVE(zrdataset, rdataset); @@ -10743,7 +10742,7 @@ db_find: } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_detach(&db); @@ -10805,7 +10804,7 @@ cleanup: ns_client_releasename(client, &fname); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (db != NULL) { dns_db_detach(&db); @@ -10922,7 +10921,7 @@ again: dns_rdatatype_nsec, options, 0, &node, fname, &cm, &ci, rdataset, sigrdataset); if (node != NULL) { - dns_db_detachnode(qctx->db, &node); + dns_db_detachnode(&node); } if (!dns_rdataset_isassociated(rdataset)) { diff --git a/lib/ns/update.c b/lib/ns/update.c index 24847c381b..29cb145dd0 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -622,7 +622,7 @@ foreach_rrset(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_rdatasetiter_destroy(&iter); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -728,7 +728,7 @@ foreach_rr(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, cleanup_rdataset: dns_rdataset_disassociate(&rdataset); cleanup_node: - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } @@ -1143,7 +1143,7 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db, if (dns_rdatatype_issig(type)) { covers = dns_rdata_covers(&t->rdata); } else if (type == dns_rdatatype_any) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_diff_clear(&trash); return DNS_R_NXRRSET; } else { @@ -1159,7 +1159,7 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db, covers, (isc_stdtime_t)0, &rdataset, NULL); if (result != ISC_R_SUCCESS) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_diff_clear(&trash); return DNS_R_NXRRSET; } @@ -1215,11 +1215,11 @@ temp_check(isc_mem_t *mctx, dns_diff_t *temp, dns_db_t *db, dns_diff_clear(&u_rrs); dns_diff_clear(&trash); dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); return result; } - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_diff_clear(&trash); @@ -2189,7 +2189,7 @@ rr_exists(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } return result; } @@ -2272,7 +2272,7 @@ success: failure: if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); diff --git a/tests/dns/db_test.c b/tests/dns/db_test.c index 9052ad5a1b..d1faaf555c 100644 --- a/tests/dns/db_test.c +++ b/tests/dns/db_test.c @@ -54,11 +54,11 @@ ISC_LOOP_TEST_IMPL(getoriginnode) { result = dns_db_getoriginnode(db, &node); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); result = dns_db_getoriginnode(db, &node); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_detach(&db); isc_loopmgr_shutdown(); @@ -165,7 +165,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) { NULL); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_rdataset_disassociate(&rdataset); result = dns_db_find(db, example, NULL, dns_rdatatype_a, 0, 0, @@ -181,7 +181,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) { assert_in_range(count, 1, 21); /* loop sanity */ assert_int_equal(rdataset.attributes.stale, false); assert_true(rdataset.ttl > 0); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_rdataset_disassociate(&rdataset); usleep(100000); /* 100 ms */ @@ -215,7 +215,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) { assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(rdataset.attributes.stale, true); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_rdataset_disassociate(&rdataset); usleep(100000); /* 100 ms */ @@ -314,7 +314,7 @@ ISC_LOOP_TEST_IMPL(version) { foundname, &rdataset, NULL); assert_int_equal(result, ISC_R_SUCCESS); dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); dns_db_closeversion(db, &ver, false); /* Open new version for writing */ @@ -335,7 +335,7 @@ ISC_LOOP_TEST_IMPL(version) { assert_int_equal(result, ISC_R_SUCCESS); dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* This should fail now */ result = dns_db_find(db, name, new, dns_rdatatype_a, 0, 0, &node, @@ -348,7 +348,7 @@ ISC_LOOP_TEST_IMPL(version) { result = dns_db_find(db, name, ver, dns_rdatatype_a, 0, 0, &node, foundname, &rdataset, NULL); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); /* Now we create a node with an empty parent */ result = dns_db_newversion(db, &new); @@ -362,7 +362,7 @@ ISC_LOOP_TEST_IMPL(version) { /* look up the ENT; it should be empty */ dns_test_namefromstring("ent.name.test.test.", &fname); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); result = dns_db_find(db, name, new, dns_rdatatype_a, 0, 0, &node, foundname, &rdataset, NULL); assert_int_equal(result, DNS_R_EMPTYNAME); @@ -380,7 +380,7 @@ ISC_LOOP_TEST_IMPL(version) { dns_rdataset_disassociate(&rdataset); } if (node != NULL) { - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } dns_db_closeversion(db, &ver, false); diff --git a/tests/dns/dbiterator_test.c b/tests/dns/dbiterator_test.c index d5eabfb280..4e7cfc5fb8 100644 --- a/tests/dns/dbiterator_test.c +++ b/tests/dns/dbiterator_test.c @@ -96,7 +96,7 @@ test_walk(const char *filename, int flags, int nodes) { DNS_DBITERATOR_FOREACH (iter) { result = dns_dbiterator_current(iter, &node, name); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); i++; } @@ -150,7 +150,7 @@ test_reverse(const char *filename, int flags, int nodes) { { result = dns_dbiterator_current(iter, &node, name); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); i++; } @@ -214,7 +214,7 @@ test_seek_node(const char *filename, int flags, int nodes) { while (result == ISC_R_SUCCESS) { result = dns_dbiterator_current(iter, &node, name); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); result = dns_dbiterator_next(iter); i++; } @@ -236,7 +236,7 @@ test_seek_node(const char *filename, int flags, int nodes) { while (result == ISC_R_SUCCESS) { result = dns_dbiterator_current(iter, &node, name); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); result = dns_dbiterator_prev(iter); i++; } diff --git a/tests/dns/dbversion_test.c b/tests/dns/dbversion_test.c index 9a5ccf7ce9..4b011d1258 100644 --- a/tests/dns/dbversion_test.c +++ b/tests/dns/dbversion_test.c @@ -213,7 +213,7 @@ ISC_RUN_TEST_IMPL(allrdatasets) { dns_rdatasetiter_destroy(&iterator); assert_null(iterator); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); } @@ -244,7 +244,7 @@ ISC_RUN_TEST_IMPL(findrdataset) { check_assertion(dns_db_findrdataset(db1, node, v2, dns_rdatatype_soa, 0, 0, &rdataset, NULL)); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); } @@ -266,7 +266,7 @@ ISC_RUN_TEST_IMPL(deleterdataset) { check_assertion( dns_db_deleterdataset(db1, node, v2, dns_rdatatype_soa, 0)); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); } @@ -305,7 +305,7 @@ ISC_RUN_TEST_IMPL(subtract) { check_assertion( dns_db_subtractrdataset(db1, node, v2, &rdataset, 0, NULL)); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); } @@ -337,7 +337,7 @@ ISC_RUN_TEST_IMPL(addrdataset) { check_assertion( dns_db_addrdataset(db1, node, v2, 0, &rdataset, 0, NULL)); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); } @@ -415,7 +415,7 @@ ISC_RUN_TEST_IMPL(rollback) { assert_int_equal(res, ISC_R_SUCCESS); dns_db_closeversion(db1, &v1, true); /* commit */ assert_null(v1); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); /* db2: Insert the first version ("text 1"), and commit */ @@ -425,7 +425,7 @@ ISC_RUN_TEST_IMPL(rollback) { assert_int_equal(res, ISC_R_SUCCESS); dns_db_closeversion(db2, &v2, true); /* commit */ assert_null(v2); - dns_db_detachnode(db2, &node); + dns_db_detachnode(&node); assert_null(node); /* Reopen the versions */ @@ -441,7 +441,7 @@ ISC_RUN_TEST_IMPL(rollback) { assert_int_equal(res, ISC_R_SUCCESS); dns_db_closeversion(db1, &v1, false); /* rollback */ assert_null(v1); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); /* db2: Insert the second version ("text 2"), and commit */ @@ -451,7 +451,7 @@ ISC_RUN_TEST_IMPL(rollback) { assert_int_equal(res, ISC_R_SUCCESS); dns_db_closeversion(db2, &v2, true); /* commit */ assert_null(v2); - dns_db_detachnode(db2, &node); + dns_db_detachnode(&node); assert_null(node); /* db1: Look it up and check that the first version is found */ @@ -479,7 +479,7 @@ ISC_RUN_TEST_IMPL(rollback) { dns_db_closeversion(db1, &v1, true); assert_null(v1); - dns_db_detachnode(db1, &node); + dns_db_detachnode(&node); assert_null(node); /* db2: Look it up and check that the second version is found */ @@ -507,7 +507,7 @@ ISC_RUN_TEST_IMPL(rollback) { dns_db_closeversion(db2, &v2, true); assert_null(v2); - dns_db_detachnode(db2, &node); + dns_db_detachnode(&node); assert_null(node); } diff --git a/tests/dns/qpdb_test.c b/tests/dns/qpdb_test.c index 1c840e2901..e7e16042c2 100644 --- a/tests/dns/qpdb_test.c +++ b/tests/dns/qpdb_test.c @@ -109,7 +109,7 @@ overmempurge_addrdataset(dns_db_t *db, isc_stdtime_t now, int idx, result = dns_db_addrdataset(db, node, NULL, now, &rdataset, 0, NULL); assert_int_equal(result, ISC_R_SUCCESS); - dns_db_detachnode(db, &node); + dns_db_detachnode(&node); } static void diff --git a/tests/dns/qpzone_test.c b/tests/dns/qpzone_test.c index 48a42c71f2..73cd7514a1 100644 --- a/tests/dns/qpzone_test.c +++ b/tests/dns/qpzone_test.c @@ -109,10 +109,9 @@ ownercase_test_one(const char *str1, const char *str2) { .common.methods = &qpdb_zonemethods, .common.mctx = isc_g_mctx, }; - qpznode_t node = { .locknum = 0 }; + qpznode_t node = { .methods = &qpznode_methods, .locknum = 0 }; dns_slabheader_t header = { .node = (dns_dbnode_t *)&node, - .db = (dns_db_t *)qpdb, }; unsigned char *raw = (unsigned char *)(&header) + sizeof(header); dns_rdataset_t rdataset = { @@ -172,10 +171,9 @@ ISC_RUN_TEST_IMPL(setownercase) { .common.methods = &qpdb_zonemethods, .common.mctx = isc_g_mctx, }; - qpznode_t node = { .locknum = 0 }; + qpznode_t node = { .methods = &qpznode_methods, .locknum = 0 }; dns_slabheader_t header = { .node = (dns_dbnode_t *)&node, - .db = (dns_db_t *)qpdb, }; unsigned char *raw = (unsigned char *)(&header) + sizeof(header); dns_rdataset_t rdataset = {