2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

remove qp-zonedb.c and associated code

now that "qpzone" databases are available for use in zones, we no
longer need to retain the zone semantics in the "qp" database.

all zone-specific code has been removed from QPDB, and "configure
--with-zonedb" once again takes two values, rbt and qp.

some database API methods that are never used with a cache have
been removed from qpdb.c and qp-cachedb.c; these include newversion,
closeversion, subtractrdataset, and nodefullname.
This commit is contained in:
Evan Hunt
2024-03-06 15:04:20 -08:00
parent ac2c454f4f
commit ab084d8c4f
8 changed files with 138 additions and 4532 deletions

View File

@@ -621,8 +621,8 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
/* Translate instance name to instance pointer. */
sampledb->inst = driverarg;
/* Create internal instance of RBT DB implementation from BIND. */
CHECK(dns_db_create(mctx, "qp", origin, dns_dbtype_zone,
/* Create internal instance of DB implementation from BIND. */
CHECK(dns_db_create(mctx, ZONEDB_DEFAULT, origin, dns_dbtype_zone,
dns_rdataclass_in, 0, NULL, &sampledb->rbtdb));
/* Create fake SOA, NS, and A records to make database loadable. */

View File

@@ -1570,9 +1570,8 @@ AS_IF([test -z "$DTRACE"],
AC_SUBST([DTRACE])
#
# Which should be the default zone database, RBTDB, QPDB (based on dns_qp),
# or QPZONE (based on dns_qpmulti)?
# [pairwise: --with-zonedb=qp, --with-zonedb=qpzone, --with-zonedb=rbt]
# Which should be the default zone database, RBTDB or QPZONE?
# [pairwise: --with-zonedb=qp, --with-zonedb=rbt]
#
AC_ARG_WITH([zonedb],
[AS_HELP_STRING([--with-zonedb=detect],[specify default zone database type (default is "qpzone")])],
@@ -1580,8 +1579,7 @@ AC_ARG_WITH([zonedb],
zonedb="qpzone"
AS_CASE([$with_zonedb],
[RBT*|rbt*],[zonedb="rbt"],
[QP|qp],[zonedb="qp"],
[QPZ*|qpz*],[],
[QP|qp],[],
[AC_MSG_ERROR([Unknown zone database type])]
)
AC_DEFINE_UNQUOTED([ZONEDB_DEFAULT], ["$zonedb"], [Default zone database type])

View File

@@ -224,7 +224,6 @@ libdns_la_SOURCES = \
rbtdb.c \
rbtdb_p.h \
qp-cachedb.c \
qp-zonedb.c \
qpdb_p.h \
qpdb.c \
rcode.c \

View File

@@ -1521,10 +1521,6 @@ expiredata(dns_db_t *db, dns_dbnode_t *node, void *data) {
dns_dbmethods_t dns__qpdb_cachemethods = {
.destroy = dns__qpdb_destroy,
.currentversion = dns__qpdb_currentversion,
.newversion = dns__qpdb_newversion,
.attachversion = dns__qpdb_attachversion,
.closeversion = dns__qpdb_closeversion,
.findnode = dns__qpdb_findnode,
.find = cache_find,
.findzonecut = cache_findzonecut,
@@ -1534,7 +1530,6 @@ dns_dbmethods_t dns__qpdb_cachemethods = {
.findrdataset = cache_findrdataset,
.allrdatasets = dns__qpdb_allrdatasets,
.addrdataset = dns__qpdb_addrdataset,
.subtractrdataset = dns__qpdb_subtractrdataset,
.deleterdataset = dns__qpdb_deleterdataset,
.nodecount = dns__qpdb_nodecount,
.setloop = dns__qpdb_setloop,
@@ -1549,7 +1544,6 @@ dns_dbmethods_t dns__qpdb_cachemethods = {
.unlocknode = dns__qpdb_unlocknode,
.expiredata = expiredata,
.deletedata = dns__qpdb_deletedata,
.nodefullname = dns__qpdb_nodefullname,
};
/*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -74,14 +74,8 @@ struct dns_qpdata {
* after acquiring the tree lock.
*/
unsigned int : 0; /* start of bitfields c/o tree lock */
unsigned int is_root : 1; /*%< range is 0..1 */
unsigned int color : 1; /*%< range is 0..1 */
unsigned int find_callback : 1; /*%< range is 0..1 */
bool absolute : 1; /*%< node with absolute DNS name */
unsigned int nsec : 2; /*%< range is 0..3 */
unsigned int namelen : 8; /*%< range is 1..255 */
unsigned int offsetlen : 8; /*%< range is 1..128 */
unsigned int oldnamelen : 8; /*%< range is 1..255 */
unsigned int : 0; /* end of bitfields c/o tree lock */
/*@}*/
@@ -103,7 +97,7 @@ struct dns_qpdata {
/*@{*/
/*!
* These values are used in the RBT DB implementation. The appropriate
* These values are used in the QPDB implementation. The appropriate
* node lock must be held before accessing them.
*
* Note: The two "unsigned int :0;" unnamed bitfields on either
@@ -122,7 +116,6 @@ struct dns_qpdata {
void *data;
uint8_t : 0; /* start of bitfields c/o node lock */
uint8_t dirty : 1;
uint8_t wild : 1;
uint8_t : 0; /* end of bitfields c/o node lock */
uint16_t locknum; /* note that this is not in the bitfield */
isc_refcount_t references;
@@ -138,43 +131,6 @@ typedef struct qpdb_changed {
typedef ISC_LIST(qpdb_changed_t) qpdb_changedlist_t;
struct dns_qpdb_version {
/* Not locked */
uint32_t serial;
dns_qpdb_t *qpdb;
/*
* Protected in the refcount routines.
* XXXJT: should we change the lock policy based on the refcount
* performance?
*/
isc_refcount_t references;
/* Locked by database lock. */
bool writer;
bool commit_ok;
qpdb_changedlist_t changed_list;
dns_slabheaderlist_t resigned_list;
ISC_LINK(dns_qpdb_version_t) link;
bool secure;
bool havensec3;
/* NSEC3 parameters */
dns_hash_t hash;
uint8_t flags;
uint16_t iterations;
uint8_t salt_length;
unsigned char salt[DNS_NSEC3_SALTSIZE];
/*
* records and xfrsize are covered by rwlock.
*/
isc_rwlock_t rwlock;
uint64_t records;
uint64_t xfrsize;
struct cds_wfs_stack glue_stack;
};
typedef ISC_LIST(dns_qpdb_version_t) qpdb_versionlist_t;
struct dns_qpdb {
/* Unlocked. */
dns_db_t common;
@@ -196,9 +152,6 @@ struct dns_qpdb {
uint32_t current_serial;
uint32_t least_serial;
uint32_t next_serial;
dns_qpdb_version_t *current_version;
dns_qpdb_version_t *future_version;
qpdb_versionlist_t open_versions;
isc_loop_t *loop;
dns_dbnode_t *soanode;
dns_dbnode_t *nsnode;
@@ -242,7 +195,6 @@ struct dns_qpdb {
*/
isc_mem_t *hmctx;
isc_heap_t **heaps;
isc_heapcompare_t sooner;
/* Locked by tree_lock. */
dns_qp_t *tree;
@@ -258,7 +210,6 @@ struct dns_qpdb {
*/
typedef struct {
dns_qpdb_t *qpdb;
dns_qpdb_version_t *rbtversion;
uint32_t serial;
unsigned int options;
dns_qpchain_t chain;
@@ -448,9 +399,6 @@ dns__qpdb_bindrdataset(dns_qpdb_t *qpdb, dns_qpdata_t *node,
isc_result_t
dns__qpdb_nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name);
void
dns__qpdb_freeglue(dns_glue_t *glue_list);
void
dns__qpdb_newref(dns_qpdb_t *qpdb, dns_qpdata_t *node,
isc_rwlocktype_t locktype DNS__DB_FLARG);
@@ -477,23 +425,14 @@ dns__qpdb_decref(dns_qpdb_t *qpdb, dns_qpdata_t *node, uint32_t least_serial,
isc_result_t
dns__qpdb_add(dns_qpdb_t *qpdb, dns_qpdata_t *qpnode,
const dns_name_t *nodename, dns_qpdb_version_t *rbtversion,
dns_slabheader_t *newheader, unsigned int options, bool loading,
dns_rdataset_t *addedrdataset, isc_stdtime_t now DNS__DB_FLARG);
const dns_name_t *nodename, dns_slabheader_t *newheader,
unsigned int options, bool loading, dns_rdataset_t *addedrdataset,
isc_stdtime_t now DNS__DB_FLARG);
/*%<
* Add a slab header 'newheader' to a node in an RBT database.
* The caller must have the node write-locked.
*/
void
dns__qpdb_setsecure(dns_db_t *db, dns_qpdb_version_t *version,
dns_dbnode_t *origin);
/*%<
* Update the secure status for an RBT database version 'version'.
* The version will be marked secure if it is fully signed and
* and contains a complete NSEC/NSEC3 chain.
*/
void
dns__qpdb_mark(dns_slabheader_t *header, uint_least16_t flag);
/*%<
@@ -509,43 +448,6 @@ dns__qpdb_setttl(dns_slabheader_t *header, dns_ttl_t newttl);
* also update the TTL heap accordingly.
*/
/*
* Functions specific to zone databases that are also called from qpdb.c.
*/
void
dns__qpzone_resigninsert(dns_qpdb_t *qpdb, int idx,
dns_slabheader_t *newheader);
void
dns__qpzone_resigndelete(dns_qpdb_t *qpdb, dns_qpdb_version_t *version,
dns_slabheader_t *header DNS__DB_FLARG);
/*%<
* Insert/delete a node from the zone database's resigning heap.
*/
isc_result_t
dns__qpzone_wildcardmagic(dns_qpdb_t *qpdb, const dns_name_t *name, bool lock);
/*%<
* Add the necessary magic for the wildcard name 'name'
* to be found in 'qpdb'.
*
* In order for wildcard matching to work correctly in
* zone_find(), we must ensure that a node for the wildcarding
* level exists in the database, and has its 'find_callback'
* and 'wild' bits set.
*
* E.g. if the wildcard name is "*.sub.example." then we
* must ensure that "sub.example." exists and is marked as
* a wildcard level.
*
* The tree must be write-locked.
*/
isc_result_t
dns__qpzone_addwildcards(dns_qpdb_t *qpdb, const dns_name_t *name, bool lock);
/*%<
* If 'name' is or contains a wildcard name, create a node for it in the
* database. The tree must be write-locked.
*/
/*
* Cache-specific functions that are called from qpdb.c
*/

View File

@@ -42,179 +42,6 @@
#undef CHECK
#include <tests/dns.h>
const char *ownercase_vectors[12][2] = {
{
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz",
},
{
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz",
"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ",
},
{
"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ",
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz",
},
{
"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ",
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz",
},
{
"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVxXyYzZ",
"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvxxyyzz",
},
{
"WwW.ExAmPlE.OrG",
"wWw.eXaMpLe.oRg",
},
{
"_SIP.tcp.example.org",
"_sip.TCP.example.org",
},
{
"bind-USERS.lists.example.org",
"bind-users.lists.example.org",
},
{
"a0123456789.example.org",
"A0123456789.example.org",
},
{
"\\000.example.org",
"\\000.example.org",
},
{
"wWw.\\000.isc.org",
"www.\\000.isc.org",
},
{
"\255.example.org",
"\255.example.ORG",
}
};
static bool
ownercase_test_one(const char *str1, const char *str2) {
isc_result_t result;
db_nodelock_t node_locks[1];
dns_qpdb_t qpdb = {
.common.methods = &dns__qpdb_zonemethods,
.common.mctx = mctx,
.node_locks = node_locks,
};
dns_qpdata_t rbtnode = { .locknum = 0 };
dns_slabheader_t header = {
.node = &rbtnode,
.db = (dns_db_t *)&qpdb,
};
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
.magic = DNS_RDATASET_MAGIC,
.slab = { .db = (dns_db_t *)&qpdb,
.node = &rbtnode,
.raw = raw },
.methods = &dns_rdataslab_rdatasetmethods,
};
isc_buffer_t b;
dns_fixedname_t fname1, fname2;
dns_name_t *name1 = dns_fixedname_initname(&fname1);
dns_name_t *name2 = dns_fixedname_initname(&fname2);
memset(node_locks, 0, sizeof(node_locks));
/* Minimal initialization of the mock objects */
NODE_INITLOCK(&qpdb.node_locks[0].lock);
isc_buffer_constinit(&b, str1, strlen(str1));
isc_buffer_add(&b, strlen(str1));
result = dns_name_fromtext(name1, &b, dns_rootname, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
isc_buffer_constinit(&b, str2, strlen(str2));
isc_buffer_add(&b, strlen(str2));
result = dns_name_fromtext(name2, &b, dns_rootname, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
/* Store the case from name1 */
dns_rdataset_setownercase(&rdataset, name1);
assert_true(CASESET(&header));
/* Retrieve the case to name2 */
dns_rdataset_getownercase(&rdataset, name2);
NODE_DESTROYLOCK(&qpdb.node_locks[0].lock);
return (dns_name_caseequal(name1, name2));
}
ISC_RUN_TEST_IMPL(ownercase) {
UNUSED(state);
for (size_t n = 0; n < ARRAY_SIZE(ownercase_vectors); n++) {
assert_true(ownercase_test_one(ownercase_vectors[n][0],
ownercase_vectors[n][1]));
}
assert_false(ownercase_test_one("W.example.org", "\\000.example.org"));
/* Ö and ö in ISO Latin 1 */
assert_false(ownercase_test_one("\\216", "\\246"));
}
ISC_RUN_TEST_IMPL(setownercase) {
isc_result_t result;
db_nodelock_t node_locks[1];
dns_qpdb_t qpdb = {
.common.methods = &dns__qpdb_zonemethods,
.common.mctx = mctx,
.node_locks = node_locks,
};
dns_qpdata_t rbtnode = { .locknum = 0 };
dns_slabheader_t header = {
.node = &rbtnode,
.db = (dns_db_t *)&qpdb,
};
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
.magic = DNS_RDATASET_MAGIC,
.slab = { .db = (dns_db_t *)&qpdb,
.node = &rbtnode,
.raw = raw },
.methods = &dns_rdataslab_rdatasetmethods,
};
const char *str1 =
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
isc_buffer_t b;
dns_fixedname_t fname1, fname2;
dns_name_t *name1 = dns_fixedname_initname(&fname1);
dns_name_t *name2 = dns_fixedname_initname(&fname2);
UNUSED(state);
/* Minimal initialization of the mock objects */
memset(node_locks, 0, sizeof(node_locks));
NODE_INITLOCK(&qpdb.node_locks[0].lock);
isc_buffer_constinit(&b, str1, strlen(str1));
isc_buffer_add(&b, strlen(str1));
result = dns_name_fromtext(name1, &b, dns_rootname, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
isc_buffer_constinit(&b, str1, strlen(str1));
isc_buffer_add(&b, strlen(str1));
result = dns_name_fromtext(name2, &b, dns_rootname, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
assert_false(CASESET(&header));
/* Retrieve the case to name2 */
dns_rdataset_getownercase(&rdataset, name2);
NODE_DESTROYLOCK(&qpdb.node_locks[0].lock);
assert_true(dns_name_caseequal(name1, name2));
}
/*
* Add to a cache DB 'db' an rdataset of type 'rtype' at a name
* <idx>.example.com. The rdataset would contain one data, and rdata_len is
@@ -372,8 +199,6 @@ ISC_RUN_TEST_IMPL(overmempurge_longname) {
}
ISC_TEST_LIST_START
ISC_TEST_ENTRY(ownercase)
ISC_TEST_ENTRY(setownercase)
ISC_TEST_ENTRY(overmempurge_bigrdata)
ISC_TEST_ENTRY(overmempurge_longname)
ISC_TEST_LIST_END