From 92b305be4bab3ebde0e7b4a93e1b0b057abe198d Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 5 Mar 2024 16:17:33 -0800 Subject: [PATCH] add a compile-time option to select default zone and cache DB by default, QPDB is the database used by named and all tools and unit tests. the old default of RBTDB can now be restored by using "configure --with-zonedb=rbt --with-cachedb=rbt". some tests have been fixed so they will work correctly with either database. CHANGES and release notes have been updated to reflect this change. --- CHANGES | 12 ++++++++--- bin/check/check-tool.c | 2 +- bin/check/named-checkconf.c | 4 +++- bin/dnssec/dnssec-cds.c | 8 ++++---- bin/dnssec/dnssec-dsfromkey.c | 4 ++-- bin/dnssec/dnssec-importkey.c | 4 ++-- bin/dnssec/dnssec-signzone.c | 12 +++++------ bin/dnssec/dnssec-verify.c | 4 ++-- bin/named/server.c | 14 ++++++------- bin/named/zoneconf.c | 2 +- bin/tests/system/makejournal.c | 2 +- configure.ac | 35 ++++++++++++++++++++++++++++++++ doc/notes/notes-current.rst | 9 +++++++-- fuzz/dns_master_load.c | 5 +++-- lib/dns/cache.c | 2 +- lib/dns/client.c | 5 +++-- lib/dns/rootns.c | 4 ++-- lib/dns/xfrin.c | 7 ++----- lib/dns/zone.c | 6 +++--- lib/isccfg/check.c | 7 ++++--- tests/dns/db_test.c | 37 ++++++++++++++++++---------------- tests/dns/dbversion_test.c | 4 ++-- tests/dns/master_test.c | 5 +++-- tests/dns/qpdb_test.c | 10 +++++---- tests/libtest/dns.c | 6 ++++-- tests/libtest/ns.c | 6 ++++-- 26 files changed, 137 insertions(+), 79 deletions(-) diff --git a/CHANGES b/CHANGES index 5160fd086e..bb07962707 100644 --- a/CHANGES +++ b/CHANGES @@ -2,8 +2,8 @@ RBTDB has been replaced with QP-tries. This is expected to improve scalability and reduce CPU consumption under load. It is currently known to - have higher memory consumption than RBTDB; this - will be addressed in future releases. + have higher memory consumption than the traditional + RBTDB; this will be addressed in future releases. Nodes in a QP-trie contain the full domain name, while nodes in a red-black tree only contain names @@ -18,7 +18,13 @@ single-thread "dns_qp" interface with locks for synchronization. A future version will use the multithreaded "dns_qpmulti" interface instead, - and will be renamed to QPDB. [GL #4411] + and will be renamed to QPDB. + + The RBT-based version of RBTDB is still in place + for now, and can be used by specifying "database rbt" + in a "zone" statement, or by compiling with + "configure --with-zonedb=rbt --with-cachedb=rbt". + [GL #4411] 6354. [bug] Change 6035 introduced a regression when chasing DS records resulting in an assertion failure. [GL #4612] diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 26983b75b6..352d83acbf 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -73,7 +73,7 @@ #define ERR_IS_MXCNAME 6 #define ERR_IS_SRVCNAME 7 -static const char *dbtype[] = { "qp" }; +static const char *dbtype[] = { ZONEDB_DEFAULT }; int debug = 0; const char *journal = NULL; diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 8e9991f265..f4ed602c49 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -242,7 +242,9 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, * Skip checks when using an alternate data source. */ cfg_map_get(zoptions, "database", &dbobj); - if (dbobj != NULL && strcmp("qp", cfg_obj_asstring(dbobj)) != 0) { + if (dbobj != NULL && + strcmp(ZONEDB_DEFAULT, cfg_obj_asstring(dbobj)) != 0) + { return (ISC_R_SUCCESS); } diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 3c0f557d02..ebd619aaa3 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -247,8 +247,8 @@ static void load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep) { isc_result_t result; - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, dbp); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, dbp); check_result(result, "dns_db_create()"); result = dns_db_load(*dbp, filename, dns_masterformat_text, @@ -979,8 +979,8 @@ update_diff(const char *cmd, uint32_t ttl, dns_rdataset_t *addset, dns_rdataset_t diffset; uint32_t save; - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, &update_db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, &update_db); check_result(result, "dns_db_create()"); result = dns_db_newversion(update_db, &update_version); diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index c9820344b0..863573ddba 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -100,8 +100,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { dns_name_format(name, setname, sizeof(setname)); - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, &db); if (result != ISC_R_SUCCESS) { fatal("can't create database"); } diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 0dfcd632c8..c93a0158eb 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -103,8 +103,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { dns_name_format(name, setname, sizeof(setname)); - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, &db); if (result != ISC_R_SUCCESS) { fatal("can't create database"); } diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 0eefe27df9..afe2eff19b 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -998,8 +998,8 @@ opendb(const char *prefix, dns_name_t *name, dns_rdataclass_t rdclass, } isc_buffer_putuint8(&b, 0); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - rdclass, 0, NULL, dbp); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, rdclass, 0, NULL, dbp); check_result(result, "dns_db_create()"); result = dns_db_load(*dbp, filename, inputformat, DNS_MASTER_HINT); @@ -2572,8 +2572,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) { isc_result_totext(result)); } - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, db); check_result(result, "dns_db_create()"); result = dns_db_load(*db, file, inputformat, 0); @@ -3162,8 +3162,8 @@ writeset(const char *prefix, dns_rdatatype_t type) { dns_diff_append(&diff, &tuple); } - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - gclass, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, gclass, 0, NULL, &db); check_result(result, "dns_db_create"); result = dns_db_newversion(db, &dbversion); diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index d91fe6abe9..c4ce4eadf7 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -109,8 +109,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) { isc_result_totext(result)); } - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, rdclass, 0, - NULL, db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + rdclass, 0, NULL, db); check_result(result, "dns_db_create()"); result = dns_db_load(*db, file, inputformat, 0); diff --git a/bin/named/server.c b/bin/named/server.c index 6c221eb3f3..116ccbbd8f 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -3377,7 +3377,7 @@ create_empty_zone(dns_zone_t *pzone, dns_name_t *name, dns_view_t *view, const cfg_obj_t *obj; const cfg_obj_t *zconfig; const cfg_obj_t *zoptions; - const char *rbt_dbtype[4] = { "qp" }; + const char *default_dbtype[4] = { ZONEDB_DEFAULT }; const char *sep = ": view "; const char *str; const char *viewname = view->name; @@ -3390,7 +3390,7 @@ create_empty_zone(dns_zone_t *pzone, dns_name_t *name, dns_view_t *view, dns_name_t *ns; dns_name_t *zname; dns_zone_t *zone = NULL; - int rbt_dbtypec = 1; + int default_dbtypec = 1; isc_result_t result; dns_namereln_t namereln; int order; @@ -3432,7 +3432,7 @@ create_empty_zone(dns_zone_t *pzone, dns_name_t *name, dns_view_t *view, } } if (db == NULL) { - CHECK(dns_db_create(view->mctx, "qp", name, + CHECK(dns_db_create(view->mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, view->rdclass, 0, NULL, &db)); CHECK(dns_db_newversion(db, &version)); @@ -3452,15 +3452,15 @@ create_empty_zone(dns_zone_t *pzone, dns_name_t *name, dns_view_t *view, } /* - * Is the existing zone the ok to use? + * Is the existing zone ok to use? */ if (pzone != NULL) { unsigned int typec; - const char **dbargv; + const char **dbargv = NULL; if (db != NULL) { - typec = rbt_dbtypec; - dbargv = rbt_dbtype; + typec = default_dbtypec; + dbargv = default_dbtype; } else { typec = empty_dbtypec; dbargv = empty_dbtype; diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 3827d8bdf5..c45051b42a 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -885,7 +885,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, uint32_t count; unsigned int dbargc; char **dbargv; - static char default_dbtype[] = "qp"; + static char default_dbtype[] = ZONEDB_DEFAULT; static char dlz_dbtype[] = "dlz"; char *cpval = default_dbtype; isc_mem_t *mctx = dns_zone_getmctx(zone); diff --git a/bin/tests/system/makejournal.c b/bin/tests/system/makejournal.c index a7c9e4710a..b9e766cf68 100644 --- a/bin/tests/system/makejournal.c +++ b/bin/tests/system/makejournal.c @@ -67,7 +67,7 @@ loadzone(dns_db_t **db, const char *origin, const char *filename) { return (result); } - result = dns_db_create(mctx, "qp", name, dns_dbtype_zone, + result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, db); if (result != ISC_R_SUCCESS) { return (result); diff --git a/configure.ac b/configure.ac index de7c9dab64..2df3d19a3b 100644 --- a/configure.ac +++ b/configure.ac @@ -1569,6 +1569,35 @@ AS_IF([test -z "$DTRACE"], AC_SUBST([DTRACE]) +# +# Which should be the default zone database, RBTDB or QPDB? +# [pairwise: --with-zonedb=qp, --with-zonedb=rbt] +# +AC_ARG_WITH([zonedb], + [AS_HELP_STRING([--with-zonedb=detect],[specify default zone database type (default is "qp")])], + [],[with_zonedb=qp]) +zonedb="qp" +AS_CASE([$with_zonedb], + [RBT*|rbt*],[zonedb="rbt"], + [QP*|qp*],[], + [AC_MSG_ERROR([Unknown zone database type])] + ) +AC_DEFINE_UNQUOTED([ZONEDB_DEFAULT], ["$zonedb"], [Default zone database type]) + +# +# Which should be the default cache database, RBTDB or QPDB? +# [pairwise: --with-cachedb=qp, --with-cachedb=rbt] +# +AC_ARG_WITH([cachedb], + [AS_HELP_STRING([--with-cachedb=detect],[specify default cache database type (default is "qp")])], + [],[with_cachedb=qp]) +cachedb="qp" +AS_CASE([$with_cachedb], + [RBT*|rbt*],[cachedb="rbt"], + [QP*|qp*],[], + [AC_MSG_ERROR([Unknown cache database type])] + ) +AC_DEFINE_UNQUOTED([CACHEDB_DEFAULT], ["$cachedb"], [Default cache database type]) # # Files to configure. These are listed here because we used to @@ -1668,6 +1697,12 @@ report() { if test "yes" = "$with_jemalloc"; then echo " Memory allocator: jemalloc" fi + if test "yes" = "$enable_full_report" -o "rbt" = "$zonedb"; then + echo " Default zone database type: $zonedb" + fi + if test "yes" = "$enable_full_report" -o "rbt" = "$zonedb"; then + echo " Default cache database type: $cachedb" + fi if test "yes" = "$enable_full_report" -o "standard" = "$with_locktype"; then echo " Mutex lock type: $with_locktype" fi diff --git a/doc/notes/notes-current.rst b/doc/notes/notes-current.rst index 892ef552b3..89764cb996 100644 --- a/doc/notes/notes-current.rst +++ b/doc/notes/notes-current.rst @@ -62,8 +62,13 @@ Feature Changes A side effect of this change is that zone files that are created with :any:`masterfile-style` ``relative`` - for example, the output of :any:`dnssec-signzone` - will no longer have multiple different - `$ORIGIN` statements. There should be no other behavior changes to - server behavior. :gl:`#4411`. + `$ORIGIN` statements. There should be no other changes to server + behavior. + + The old RBT-based database still exists for now, and can be used by + specifying ``database rbt`` in a ``zone`` statement in ``named.conf``, + or by compiling with ``configure --with-zonedb=rbt --with-cachedb=rbt``. + :gl:`#4411`. Bug Fixes ~~~~~~~~~ diff --git a/fuzz/dns_master_load.c b/fuzz/dns_master_load.c index 701ed07584..29e83dfc1e 100644 --- a/fuzz/dns_master_load.c +++ b/fuzz/dns_master_load.c @@ -49,8 +49,9 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { dns_db_t *db = NULL; isc_mem_create(&mctx); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, dns_rdataclass_in, 0, NULL, + &db); if (result != ISC_R_SUCCESS) { return 0; } diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 8fc219cc2d..4abd771ec1 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -95,7 +95,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **db) { * dns_db_create() via argv[0]. */ argv[0] = (char *)cache->hmctx; - result = dns_db_create(cache->mctx, "qp", dns_rootname, + result = dns_db_create(cache->mctx, CACHEDB_DEFAULT, dns_rootname, dns_dbtype_cache, cache->rdclass, 1, argv, db); if (result == ISC_R_SUCCESS) { dns_db_setservestalettl(*db, cache->serve_stale_ttl); diff --git a/lib/dns/client.c b/lib/dns/client.c index b1ad22db20..c01558f80a 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -216,8 +216,9 @@ createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_loopmgr_t *loopmgr, CHECK(dns_view_createresolver(view, loopmgr, nm, 0, tlsctx_client_cache, dispatchv4, dispatchv6)); - CHECK(dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_cache, rdclass, - 0, NULL, &view->cachedb)); + CHECK(dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, rdclass, 0, NULL, + &view->cachedb)); *viewp = view; return (ISC_R_SUCCESS); diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index 84237ed621..f5ebb368c0 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -238,8 +238,8 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, REQUIRE(target != NULL && *target == NULL); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - rdclass, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, rdclass, 0, NULL, &db); if (result != ISC_R_SUCCESS) { goto failure; } diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index bf732bde43..2c6e7b0f2c 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -297,11 +297,8 @@ static isc_result_t axfr_makedb(dns_xfrin_t *xfr, dns_db_t **dbp) { isc_result_t result; - result = dns_db_create(xfr->mctx, /* XXX */ - "qp", /* XXX guess */ - &xfr->name, dns_dbtype_zone, xfr->rdclass, 0, - NULL, /* XXX guess */ - dbp); + result = dns_db_create(xfr->mctx, ZONEDB_DEFAULT, &xfr->name, + dns_dbtype_zone, xfr->rdclass, 0, NULL, dbp); if (result == ISC_R_SUCCESS) { dns_zone_rpz_enable_db(xfr->zone, *dbp); dns_zone_catz_enable_db(xfr->zone, *dbp); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 905a63943c..16a467e292 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1006,7 +1006,7 @@ zmgr_tlsctx_attach(dns_zonemgr_t *zmgr, isc_tlsctx_cache_t **ptlsctx_cache); #define ENTER zone_debuglog(zone, __func__, 1, "enter") static const unsigned int dbargc_default = 1; -static const char *dbargv_default[] = { "qp" }; +static const char *dbargv_default[] = { ZONEDB_DEFAULT }; #define DNS_ZONE_JITTER_ADD(a, b, c) \ do { \ @@ -2118,7 +2118,7 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) { INSIST(zone->db_argc >= 1); - rbt = strcmp(zone->db_argv[0], "qp") == 0; + rbt = strcmp(zone->db_argv[0], ZONEDB_DEFAULT) == 0; if (zone->db != NULL && zone->masterfile == NULL && rbt) { /* @@ -11324,7 +11324,7 @@ zone_expire(dns_zone_t *zone) { isc_result_t result; dns_rpz_zone_t *rpz = zone->rpzs->zones[zone->rpz_num]; - CHECK(dns_db_create(zone->mctx, "qp", &zone->origin, + CHECK(dns_db_create(zone->mctx, ZONEDB_DEFAULT, &zone->origin, dns_dbtype_zone, zone->rdclass, 0, NULL, &db)); CHECK(dns_rpz_dbupdate_callback(db, rpz)); diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index d8ef60cee9..32a3e4fa00 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -3986,9 +3986,10 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, "and 'database'", znamestr); result = ISC_R_FAILURE; - } else if (!dlz && (tresult == ISC_R_NOTFOUND || - (tresult == ISC_R_SUCCESS && - strcmp("qp", cfg_obj_asstring(obj)) == 0))) + } else if (!dlz && + (tresult == ISC_R_NOTFOUND || + (tresult == ISC_R_SUCCESS && + strcmp(ZONEDB_DEFAULT, cfg_obj_asstring(obj)) == 0))) { isc_result_t res1; const cfg_obj_t *fileobj = NULL; diff --git a/tests/dns/db_test.c b/tests/dns/db_test.c index f41e5931a1..615cb5ca6b 100644 --- a/tests/dns/db_test.c +++ b/tests/dns/db_test.c @@ -46,8 +46,9 @@ ISC_RUN_TEST_IMPL(getoriginnode) { UNUSED(state); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); result = dns_db_getoriginnode(db, &node); @@ -69,8 +70,9 @@ ISC_RUN_TEST_IMPL(getsetservestalettl) { UNUSED(state); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_cache, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); ttl = 5000; @@ -107,8 +109,9 @@ ISC_RUN_TEST_IMPL(dns_dbfind_staleok) { UNUSED(state); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_cache, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); example = dns_fixedname_initname(&example_fixed); @@ -249,8 +252,9 @@ ISC_RUN_TEST_IMPL(class) { UNUSED(state); - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", @@ -270,8 +274,9 @@ ISC_RUN_TEST_IMPL(dbtype) { UNUSED(state); /* DB has zone semantics */ - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, + dns_dbtype_zone, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", dns_masterformat_text, 0); @@ -281,14 +286,12 @@ ISC_RUN_TEST_IMPL(dbtype) { dns_db_detach(&db); /* DB has cache semantics */ - result = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", - dns_masterformat_text, 0); - assert_int_equal(result, ISC_R_SUCCESS); - assert_false(dns_db_iscache(db)); - assert_true(dns_db_iszone(db)); + assert_true(dns_db_iscache(db)); + assert_false(dns_db_iszone(db)); dns_db_detach(&db); } diff --git a/tests/dns/dbversion_test.c b/tests/dns/dbversion_test.c index 66186797e9..8b7a8a4ab4 100644 --- a/tests/dns/dbversion_test.c +++ b/tests/dns/dbversion_test.c @@ -78,13 +78,13 @@ setup_test(void **state) { isc_assertion_setcallback(local_callback); - res = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, + res = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db1); assert_int_equal(res, ISC_R_SUCCESS); dns_db_newversion(db1, &v1); assert_non_null(v1); - res = dns_db_create(mctx, "qp", dns_rootname, dns_dbtype_zone, + res = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db2); assert_int_equal(res, ISC_R_SUCCESS); dns_db_newversion(db2, &v2); diff --git a/tests/dns/master_test.c b/tests/dns/master_test.c index 143224661e..fed3c903c2 100644 --- a/tests/dns/master_test.c +++ b/tests/dns/master_test.c @@ -472,8 +472,9 @@ ISC_RUN_TEST_IMPL(dumpraw) { &target); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_create(mctx, "qp", &dnsorigin, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx, ZONEDB_DEFAULT, &dnsorigin, + dns_dbtype_zone, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); result = isc_dir_chdir(SRCDIR); diff --git a/tests/dns/qpdb_test.c b/tests/dns/qpdb_test.c index d02c3d0c96..9002f95a1c 100644 --- a/tests/dns/qpdb_test.c +++ b/tests/dns/qpdb_test.c @@ -293,8 +293,9 @@ ISC_RUN_TEST_IMPL(overmempurge_bigrdata) { isc_mem_create(&mctx2); - result = dns_db_create(mctx2, "qp", dns_rootname, dns_dbtype_cache, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); isc_mem_setwater(mctx2, hiwater, lowater); @@ -337,8 +338,9 @@ ISC_RUN_TEST_IMPL(overmempurge_longname) { isc_mem_create(&mctx2); - result = dns_db_create(mctx2, "qp", dns_rootname, dns_dbtype_cache, - dns_rdataclass_in, 0, NULL, &db); + result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname, + dns_dbtype_cache, dns_rdataclass_in, 0, NULL, + &db); assert_int_equal(result, ISC_R_SUCCESS); isc_mem_setwater(mctx2, hiwater, lowater); diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index 349d03a628..d3d57a3df5 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -213,7 +213,9 @@ dns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, const char *testfile) { isc_result_t result; dns_fixedname_t fixed; - dns_name_t *name; + dns_name_t *name = NULL; + const char *dbimp = (dbtype == dns_dbtype_zone) ? ZONEDB_DEFAULT + : CACHEDB_DEFAULT; name = dns_fixedname_initname(&fixed); @@ -222,7 +224,7 @@ dns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, return (result); } - result = dns_db_create(mctx, "qp", name, dbtype, dns_rdataclass_in, 0, + result = dns_db_create(mctx, dbimp, name, dbtype, dns_rdataclass_in, 0, NULL, db); if (result != ISC_R_SUCCESS) { return (result); diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 0908374940..91799a774c 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -530,7 +530,9 @@ ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, const char *testfile) { isc_result_t result; dns_fixedname_t fixed; - dns_name_t *name; + dns_name_t *name = NULL; + const char *dbimp = (dbtype == dns_dbtype_zone) ? ZONEDB_DEFAULT + : CACHEDB_DEFAULT; name = dns_fixedname_initname(&fixed); @@ -539,7 +541,7 @@ ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, return (result); } - result = dns_db_create(mctx, "qp", name, dbtype, dns_rdataclass_in, 0, + result = dns_db_create(mctx, dbimp, name, dbtype, dns_rdataclass_in, 0, NULL, db); if (result != ISC_R_SUCCESS) { return (result);