mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-14 01:39:59 -04:00
Merge branch 'each-separate-generic-DB-helpers' into 'main'
separate generic DB helpers into db_p.h See merge request isc-projects/bind9!8713
This commit is contained in:
commit
808281cf43
14 changed files with 434 additions and 424 deletions
7
cocci/DNS_TYPEPAIR_VALUE.spatch
Normal file
7
cocci/DNS_TYPEPAIR_VALUE.spatch
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
@@
|
||||
identifier RRSIG = dns_rdatatype_rrsig;
|
||||
expression T;
|
||||
@@
|
||||
|
||||
- DNS_TYPEPAIR_VALUE(RRSIG, T)
|
||||
+ DNS_SIGTYPE(T)
|
||||
|
|
@ -165,6 +165,7 @@ libdns_la_SOURCES = \
|
|||
clientinfo.c \
|
||||
compress.c \
|
||||
db.c \
|
||||
db_p.h \
|
||||
dbiterator.c \
|
||||
diff.c \
|
||||
dispatch.c \
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ struct dns_dbimplementation {
|
|||
* Built in database implementations are registered here.
|
||||
*/
|
||||
|
||||
#include "db_p.h"
|
||||
#include "rbtdb_p.h"
|
||||
|
||||
unsigned int dns_pps = 0U;
|
||||
|
|
|
|||
156
lib/dns/db_p.h
Normal file
156
lib/dns/db_p.h
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <isc/heap.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/urcu.h>
|
||||
|
||||
#include <dns/nsec3.h>
|
||||
#include <dns/rbt.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#define RDATATYPE_NCACHEANY DNS_TYPEPAIR_VALUE(0, dns_rdatatype_any)
|
||||
|
||||
#ifdef STRONG_RWLOCK_CHECK
|
||||
#define STRONG_RWLOCK_CHECK(cond) REQUIRE(cond)
|
||||
#else
|
||||
#define STRONG_RWLOCK_CHECK(cond)
|
||||
#endif
|
||||
|
||||
#define NODE_INITLOCK(l) isc_rwlock_init((l))
|
||||
#define NODE_DESTROYLOCK(l) isc_rwlock_destroy(l)
|
||||
#define NODE_LOCK(l, t, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
RWLOCK((l), (t)); \
|
||||
*tp = t; \
|
||||
}
|
||||
#define NODE_UNLOCK(l, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
|
||||
RWUNLOCK(l, *tp); \
|
||||
*tp = isc_rwlocktype_none; \
|
||||
}
|
||||
#define NODE_RDLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_read, tp);
|
||||
#define NODE_WRLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_write, tp);
|
||||
#define NODE_TRYLOCK(l, t, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
isc_result_t _result = isc_rwlock_trylock(l, t); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = t; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define NODE_TRYRDLOCK(l, tp) NODE_TRYLOCK(l, isc_rwlocktype_read, tp)
|
||||
#define NODE_TRYWRLOCK(l, tp) NODE_TRYLOCK(l, isc_rwlocktype_write, tp)
|
||||
#define NODE_TRYUPGRADE(l, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
|
||||
isc_result_t _result = isc_rwlock_tryupgrade(l); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = isc_rwlocktype_write; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define NODE_FORCEUPGRADE(l, tp) \
|
||||
if (NODE_TRYUPGRADE(l, tp) != ISC_R_SUCCESS) { \
|
||||
NODE_UNLOCK(l, tp); \
|
||||
NODE_WRLOCK(l, tp); \
|
||||
}
|
||||
|
||||
#define TREE_INITLOCK(l) isc_rwlock_init(l)
|
||||
#define TREE_DESTROYLOCK(l) isc_rwlock_destroy(l)
|
||||
#define TREE_LOCK(l, t, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
RWLOCK(l, t); \
|
||||
*tp = t; \
|
||||
}
|
||||
#define TREE_UNLOCK(l, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
|
||||
RWUNLOCK(l, *tp); \
|
||||
*tp = isc_rwlocktype_none; \
|
||||
}
|
||||
#define TREE_RDLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_read, tp);
|
||||
#define TREE_WRLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_write, tp);
|
||||
#define TREE_TRYLOCK(l, t, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
isc_result_t _result = isc_rwlock_trylock(l, t); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = t; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define TREE_TRYRDLOCK(l, tp) TREE_TRYLOCK(l, isc_rwlocktype_read, tp)
|
||||
#define TREE_TRYWRLOCK(l, tp) TREE_TRYLOCK(l, isc_rwlocktype_write, tp)
|
||||
#define TREE_TRYUPGRADE(l, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
|
||||
isc_result_t _result = isc_rwlock_tryupgrade(l); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = isc_rwlocktype_write; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define TREE_FORCEUPGRADE(l, tp) \
|
||||
if (TREE_TRYUPGRADE(l, tp) != ISC_R_SUCCESS) { \
|
||||
TREE_UNLOCK(l, tp); \
|
||||
TREE_WRLOCK(l, tp); \
|
||||
}
|
||||
|
||||
#define IS_STUB(db) (((db)->common.attributes & DNS_DBATTR_STUB) != 0)
|
||||
#define IS_CACHE(db) (((db)->common.attributes & DNS_DBATTR_CACHE) != 0)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
struct dns_glue {
|
||||
struct dns_glue *next;
|
||||
dns_fixedname_t fixedname;
|
||||
dns_rdataset_t rdataset_a;
|
||||
dns_rdataset_t sigrdataset_a;
|
||||
dns_rdataset_t rdataset_aaaa;
|
||||
dns_rdataset_t sigrdataset_aaaa;
|
||||
|
||||
isc_mem_t *mctx;
|
||||
struct rcu_head rcu_head;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
dns_glue_t *glue_list;
|
||||
dns_db_t *db;
|
||||
dns_dbversion_t *version;
|
||||
dns_name_t *nodename;
|
||||
} dns_glue_additionaldata_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
isc_rwlock_t lock;
|
||||
/* Protected in the refcount routines. */
|
||||
isc_refcount_t references;
|
||||
/* Locked by lock. */
|
||||
bool exiting;
|
||||
} db_nodelock_t;
|
||||
|
||||
/*%
|
||||
* Prune context
|
||||
*/
|
||||
typedef struct {
|
||||
dns_db_t *db;
|
||||
dns_dbnode_t *node;
|
||||
} db_prune_t;
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
@ -184,12 +184,12 @@ struct dns_rdataset {
|
|||
* comments in rbtdb.c for details.)
|
||||
*/
|
||||
struct {
|
||||
struct dns_db *db;
|
||||
dns_dbnode_t *node;
|
||||
unsigned char *raw;
|
||||
unsigned char *iter_pos;
|
||||
unsigned int iter_count;
|
||||
dns_proof_t *noqname, *closest;
|
||||
struct dns_db *db;
|
||||
dns_dbnode_t *node;
|
||||
unsigned char *raw;
|
||||
unsigned char *iter_pos;
|
||||
unsigned int iter_count;
|
||||
dns_slabheader_proof_t *noqname, *closest;
|
||||
} slab;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ ISC_LANG_BEGINDECLS
|
|||
|
||||
#define DNS_RDATASLAB_OFFLINE 0x01 /* RRSIG is for offline DNSKEY */
|
||||
|
||||
struct dns_proof {
|
||||
struct dns_slabheader_proof {
|
||||
dns_name_t name;
|
||||
void *neg;
|
||||
void *negsig;
|
||||
|
|
@ -94,8 +94,8 @@ struct dns_slabheader {
|
|||
|
||||
atomic_uint_fast32_t last_refresh_fail_ts;
|
||||
|
||||
dns_proof_t *noqname;
|
||||
dns_proof_t *closest;
|
||||
dns_slabheader_proof_t *noqname;
|
||||
dns_slabheader_proof_t *closest;
|
||||
/*%<
|
||||
* We don't use the LIST macros, because the LIST structure has
|
||||
* both head and tail pointers, and is doubly linked.
|
||||
|
|
@ -313,4 +313,10 @@ dns_slabheader_destroy(dns_slabheader_t **headerp);
|
|||
/*%<
|
||||
* Free all memory associated with '*headerp'.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_slabheader_freeproof(isc_mem_t *mctx, dns_slabheader_proof_t **proof);
|
||||
/*%<
|
||||
* Free all memory associated with a nonexistence proof.
|
||||
*/
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@
|
|||
#define DNS_TYPEPAIR_COVERS(type) ((dns_rdatatype_t)((type) >> 16))
|
||||
#define DNS_TYPEPAIR_VALUE(base, ext) \
|
||||
((dns_typepair_t)(((uint32_t)ext) << 16) | (((uint32_t)base) & 0xffff))
|
||||
#define DNS_SIGTYPE(type) \
|
||||
((dns_typepair_t)(((uint32_t)type) << 16) | \
|
||||
(((uint32_t)dns_rdatatype_rrsig) & 0xffff))
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -120,17 +120,17 @@ typedef isc_region_t dns_label_t;
|
|||
typedef struct dns_name dns_name_t;
|
||||
typedef struct dns_nametree dns_nametree_t;
|
||||
typedef ISC_LIST(dns_name_t) dns_namelist_t;
|
||||
typedef struct dns_ntatable dns_ntatable_t;
|
||||
typedef struct dns_ntnode dns_ntnode_t;
|
||||
typedef uint16_t dns_opcode_t;
|
||||
typedef struct dns_order dns_order_t;
|
||||
typedef struct dns_peer dns_peer_t;
|
||||
typedef struct dns_peerlist dns_peerlist_t;
|
||||
typedef struct dns_proof dns_proof_t;
|
||||
typedef struct dns_rbt dns_rbt_t;
|
||||
typedef struct dns_rbtdb dns_rbtdb_t;
|
||||
typedef struct dns_rbtdb_version dns_rbtdb_version_t;
|
||||
typedef struct dns_rbtnode dns_rbtnode_t;
|
||||
typedef struct dns_ntatable dns_ntatable_t;
|
||||
typedef struct dns_ntnode dns_ntnode_t;
|
||||
typedef uint16_t dns_opcode_t;
|
||||
typedef struct dns_order dns_order_t;
|
||||
typedef struct dns_peer dns_peer_t;
|
||||
typedef struct dns_peerlist dns_peerlist_t;
|
||||
typedef struct dns_slabheader_proof dns_slabheader_proof_t;
|
||||
typedef struct dns_rbt dns_rbt_t;
|
||||
typedef struct dns_rbtdb dns_rbtdb_t;
|
||||
typedef struct dns_rbtdb_version dns_rbtdb_version_t;
|
||||
typedef struct dns_rbtnode dns_rbtnode_t;
|
||||
typedef ISC_LIST(dns_rbtnode_t) dns_rbtnodelist_t;
|
||||
typedef uint16_t dns_rcode_t;
|
||||
typedef struct dns_rdata dns_rdata_t;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
#include <dns/zone.h>
|
||||
#include <dns/zonekey.h>
|
||||
|
||||
#include "db_p.h"
|
||||
#include "rbtdb_p.h"
|
||||
|
||||
#define CHECK(op) \
|
||||
|
|
@ -186,9 +187,10 @@ update_header(dns_rbtdb_t *rbtdb, dns_slabheader_t *header, isc_stdtime_t now) {
|
|||
/* To be checked: can we really assume this? XXXMLG */
|
||||
INSIST(ISC_LINK_LINKED(header, link));
|
||||
|
||||
ISC_LIST_UNLINK(rbtdb->lru[HEADER_NODE(header)->locknum], header, link);
|
||||
ISC_LIST_UNLINK(rbtdb->lru[RBTDB_HEADERNODE(header)->locknum], header,
|
||||
link);
|
||||
header->last_used = now;
|
||||
ISC_LIST_PREPEND(rbtdb->lru[HEADER_NODE(header)->locknum], header,
|
||||
ISC_LIST_PREPEND(rbtdb->lru[RBTDB_HEADERNODE(header)->locknum], header,
|
||||
link);
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +419,7 @@ check_stale_header(dns_rbtnode_t *node, dns_slabheader_t *header,
|
|||
} else {
|
||||
dns__rbtdb_mark(header,
|
||||
DNS_SLABHEADERATTR_ANCIENT);
|
||||
HEADER_NODE(header)->dirty = 1;
|
||||
RBTDB_HEADERNODE(header)->dirty = 1;
|
||||
*header_prev = header;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -463,7 +465,7 @@ cache_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name,
|
|||
{
|
||||
dname_header = header;
|
||||
header_prev = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_SIGDNAME &&
|
||||
} else if (header->type == DNS_SIGTYPE(dns_rdatatype_dname) &&
|
||||
EXISTS(header) && !ANCIENT(header))
|
||||
{
|
||||
sigdname_header = header;
|
||||
|
|
@ -545,7 +547,7 @@ find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node,
|
|||
break;
|
||||
}
|
||||
} else if (header->type ==
|
||||
RBTDB_RDATATYPE_SIGNS)
|
||||
DNS_SIGTYPE(dns_rdatatype_ns))
|
||||
{
|
||||
foundsig = header;
|
||||
if (found != NULL) {
|
||||
|
|
@ -680,8 +682,7 @@ find_coveringnsec(rbtdb_search_t *search, const dns_name_t *name,
|
|||
fname = dns_fixedname_initname(&fixed);
|
||||
|
||||
matchtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_nsec, 0);
|
||||
sigmatchtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig,
|
||||
dns_rdatatype_nsec);
|
||||
sigmatchtype = DNS_SIGTYPE(dns_rdatatype_nsec);
|
||||
|
||||
/*
|
||||
* Extract predecessor from chain.
|
||||
|
|
@ -865,7 +866,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
|||
*/
|
||||
found = NULL;
|
||||
foundsig = NULL;
|
||||
sigtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, type);
|
||||
sigtype = DNS_SIGTYPE(type);
|
||||
negtype = DNS_TYPEPAIR_VALUE(0, type);
|
||||
nsheader = NULL;
|
||||
nsecheader = NULL;
|
||||
|
|
@ -918,8 +919,8 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
|||
if (cnamesig != NULL) {
|
||||
foundsig = cnamesig;
|
||||
} else {
|
||||
sigtype =
|
||||
RBTDB_RDATATYPE_SIGCNAME;
|
||||
sigtype = DNS_SIGTYPE(
|
||||
dns_rdatatype_cname);
|
||||
}
|
||||
}
|
||||
} else if (header->type == sigtype) {
|
||||
|
|
@ -928,7 +929,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
|||
* target type. Remember it.
|
||||
*/
|
||||
foundsig = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_NCACHEANY ||
|
||||
} else if (header->type == RDATATYPE_NCACHEANY ||
|
||||
header->type == negtype)
|
||||
{
|
||||
/*
|
||||
|
|
@ -942,7 +943,9 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
|||
* we might need it later.
|
||||
*/
|
||||
nsheader = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_SIGNS) {
|
||||
} else if (header->type ==
|
||||
DNS_SIGTYPE(dns_rdatatype_ns))
|
||||
{
|
||||
/*
|
||||
* If we need the NS rdataset, we'll also
|
||||
* need its signature.
|
||||
|
|
@ -950,10 +953,11 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
|||
nssig = header;
|
||||
} else if (header->type == dns_rdatatype_nsec) {
|
||||
nsecheader = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_SIGNSEC) {
|
||||
} else if (header->type ==
|
||||
DNS_SIGTYPE(dns_rdatatype_nsec))
|
||||
{
|
||||
nsecsig = header;
|
||||
} else if (cname_ok &&
|
||||
header->type == RBTDB_RDATATYPE_SIGCNAME)
|
||||
} else if (cname_ok && DNS_SIGTYPE(dns_rdatatype_cname))
|
||||
{
|
||||
/*
|
||||
* If we get a CNAME match, we'll also need
|
||||
|
|
@ -1272,7 +1276,9 @@ cache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
|
|||
* we might need it later.
|
||||
*/
|
||||
found = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_SIGNS) {
|
||||
} else if (header->type ==
|
||||
DNS_SIGTYPE(dns_rdatatype_ns))
|
||||
{
|
||||
/*
|
||||
* If we need the NS rdataset, we'll also
|
||||
* need its signature.
|
||||
|
|
@ -1373,7 +1379,7 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
matchtype = DNS_TYPEPAIR_VALUE(type, covers);
|
||||
negtype = DNS_TYPEPAIR_VALUE(0, type);
|
||||
if (covers == 0) {
|
||||
sigmatchtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, type);
|
||||
sigmatchtype = DNS_SIGTYPE(type);
|
||||
} else {
|
||||
sigmatchtype = 0;
|
||||
}
|
||||
|
|
@ -1399,12 +1405,12 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
*/
|
||||
dns__rbtdb_mark(header,
|
||||
DNS_SLABHEADERATTR_ANCIENT);
|
||||
HEADER_NODE(header)->dirty = 1;
|
||||
RBTDB_HEADERNODE(header)->dirty = 1;
|
||||
}
|
||||
} else if (EXISTS(header) && !ANCIENT(header)) {
|
||||
if (header->type == matchtype) {
|
||||
found = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_NCACHEANY ||
|
||||
} else if (header->type == RDATATYPE_NCACHEANY ||
|
||||
header->type == negtype)
|
||||
{
|
||||
found = header;
|
||||
|
|
@ -1447,12 +1453,10 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
|
||||
static size_t
|
||||
hashsize(dns_db_t *db) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
size_t size;
|
||||
isc_rwlocktype_t tlocktype = isc_rwlocktype_none;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
TREE_RDLOCK(&rbtdb->tree_lock, &tlocktype);
|
||||
|
|
@ -1539,8 +1543,8 @@ expiredata(dns_db_t *db, dns_dbnode_t *node, void *data) {
|
|||
isc_rwlocktype_t tlocktype = isc_rwlocktype_none;
|
||||
|
||||
NODE_WRLOCK(&rbtdb->node_locks[rbtnode->locknum].lock, &nlocktype);
|
||||
dns__cachedb_expireheader(header, &tlocktype,
|
||||
dns_expire_flush DNS__DB_FLARG_PASS);
|
||||
dns__cacherbt_expireheader(header, &tlocktype,
|
||||
dns_expire_flush DNS__DB_FLARG_PASS);
|
||||
NODE_UNLOCK(&rbtdb->node_locks[rbtnode->locknum].lock, &nlocktype);
|
||||
INSIST(tlocktype == isc_rwlocktype_none);
|
||||
}
|
||||
|
|
@ -1582,14 +1586,14 @@ dns_dbmethods_t dns__rbtdb_cachemethods = {
|
|||
* Caller must hold the node (write) lock.
|
||||
*/
|
||||
void
|
||||
dns__cachedb_expireheader(dns_slabheader_t *header,
|
||||
isc_rwlocktype_t *tlocktypep,
|
||||
dns_expire_t reason DNS__DB_FLARG) {
|
||||
dns__cacherbt_expireheader(dns_slabheader_t *header,
|
||||
isc_rwlocktype_t *tlocktypep,
|
||||
dns_expire_t reason DNS__DB_FLARG) {
|
||||
dns__rbtdb_setttl(header, 0);
|
||||
dns__rbtdb_mark(header, DNS_SLABHEADERATTR_ANCIENT);
|
||||
HEADER_NODE(header)->dirty = 1;
|
||||
RBTDB_HEADERNODE(header)->dirty = 1;
|
||||
|
||||
if (isc_refcount_current(&HEADER_NODE(header)->references) == 0) {
|
||||
if (isc_refcount_current(&RBTDB_HEADERNODE(header)->references) == 0) {
|
||||
isc_rwlocktype_t nlocktype = isc_rwlocktype_write;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)header->db;
|
||||
|
||||
|
|
@ -1598,10 +1602,11 @@ dns__cachedb_expireheader(dns_slabheader_t *header,
|
|||
* We first need to gain a new reference to the node to meet a
|
||||
* requirement of dns__rbtdb_decref().
|
||||
*/
|
||||
dns__rbtdb_newref(rbtdb, HEADER_NODE(header),
|
||||
dns__rbtdb_newref(rbtdb, RBTDB_HEADERNODE(header),
|
||||
nlocktype DNS__DB_FLARG_PASS);
|
||||
dns__rbtdb_decref(rbtdb, HEADER_NODE(header), 0, &nlocktype,
|
||||
tlocktypep, true, false DNS__DB_FLARG_PASS);
|
||||
dns__rbtdb_decref(rbtdb, RBTDB_HEADERNODE(header), 0,
|
||||
&nlocktype, tlocktypep, true,
|
||||
false DNS__DB_FLARG_PASS);
|
||||
|
||||
if (rbtdb->cachestats == NULL) {
|
||||
return;
|
||||
|
|
@ -1655,8 +1660,8 @@ expire_lru_headers(dns_rbtdb_t *rbtdb, unsigned int locknum,
|
|||
* TTL was reset to 0.
|
||||
*/
|
||||
ISC_LIST_UNLINK(rbtdb->lru[locknum], header, link);
|
||||
dns__cachedb_expireheader(header, tlocktypep,
|
||||
dns_expire_lru DNS__DB_FLARG_PASS);
|
||||
dns__cacherbt_expireheader(header, tlocktypep,
|
||||
dns_expire_lru DNS__DB_FLARG_PASS);
|
||||
purged += header_size;
|
||||
}
|
||||
|
||||
|
|
@ -1674,13 +1679,14 @@ expire_lru_headers(dns_rbtdb_t *rbtdb, unsigned int locknum,
|
|||
* A write lock on the tree must be held.
|
||||
*/
|
||||
void
|
||||
dns__cachedb_overmem(dns_rbtdb_t *rbtdb, dns_slabheader_t *newheader,
|
||||
isc_rwlocktype_t *tlocktypep DNS__DB_FLARG) {
|
||||
dns__cacherbt_overmem(dns_rbtdb_t *rbtdb, dns_slabheader_t *newheader,
|
||||
isc_rwlocktype_t *tlocktypep DNS__DB_FLARG) {
|
||||
uint32_t locknum_start = rbtdb->lru_sweep++ % rbtdb->node_lock_count;
|
||||
uint32_t locknum = locknum_start;
|
||||
/* Size of added data, possible node and possible ENT node. */
|
||||
size_t purgesize = rdataset_size(newheader) +
|
||||
2 * dns__rbtnode_getsize(HEADER_NODE(newheader));
|
||||
size_t purgesize =
|
||||
rdataset_size(newheader) +
|
||||
2 * dns__rbtnode_getsize(RBTDB_HEADERNODE(newheader));
|
||||
size_t purged = 0;
|
||||
isc_stdtime_t min_last_used = 0;
|
||||
size_t max_passes = 8;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
#include <dns/zone.h>
|
||||
#include <dns/zonekey.h>
|
||||
|
||||
#include "db_p.h"
|
||||
#include "rbtdb_p.h"
|
||||
|
||||
#define CHECK(op) \
|
||||
|
|
@ -133,7 +134,7 @@ zone_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name,
|
|||
header_next = header->next;
|
||||
if (header->type == dns_rdatatype_ns ||
|
||||
header->type == dns_rdatatype_dname ||
|
||||
header->type == RBTDB_RDATATYPE_SIGDNAME)
|
||||
header->type == DNS_SIGTYPE(dns_rdatatype_dname))
|
||||
{
|
||||
do {
|
||||
if (header->serial <= search->serial &&
|
||||
|
|
@ -155,7 +156,7 @@ zone_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name,
|
|||
if (header->type == dns_rdatatype_dname) {
|
||||
dname_header = header;
|
||||
} else if (header->type ==
|
||||
RBTDB_RDATATYPE_SIGDNAME)
|
||||
DNS_SIGTYPE(dns_rdatatype_dname))
|
||||
{
|
||||
sigdname_header = header;
|
||||
} else if (node != onode ||
|
||||
|
|
@ -806,11 +807,11 @@ find_closest_nsec(rbtdb_search_t *search, dns_dbnode_t **nodep,
|
|||
|
||||
if (tree == search->rbtdb->nsec3) {
|
||||
type = dns_rdatatype_nsec3;
|
||||
sigtype = RBTDB_RDATATYPE_SIGNSEC3;
|
||||
sigtype = DNS_SIGTYPE(dns_rdatatype_nsec3);
|
||||
wraps = true;
|
||||
} else {
|
||||
type = dns_rdatatype_nsec;
|
||||
sigtype = RBTDB_RDATATYPE_SIGNSEC;
|
||||
sigtype = DNS_SIGTYPE(dns_rdatatype_nsec);
|
||||
wraps = false;
|
||||
}
|
||||
|
||||
|
|
@ -1153,7 +1154,7 @@ found:
|
|||
|
||||
found = NULL;
|
||||
foundsig = NULL;
|
||||
sigtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, type);
|
||||
sigtype = DNS_SIGTYPE(type);
|
||||
nsecheader = NULL;
|
||||
nsecsig = NULL;
|
||||
cnamesig = NULL;
|
||||
|
|
@ -1260,8 +1261,8 @@ found:
|
|||
if (cnamesig != NULL) {
|
||||
foundsig = cnamesig;
|
||||
} else {
|
||||
sigtype =
|
||||
RBTDB_RDATATYPE_SIGCNAME;
|
||||
sigtype = DNS_SIGTYPE(
|
||||
dns_rdatatype_cname);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
@ -1291,7 +1292,8 @@ found:
|
|||
* we might need it later.
|
||||
*/
|
||||
nsecheader = header;
|
||||
} else if (header->type == RBTDB_RDATATYPE_SIGNSEC &&
|
||||
} else if (header->type ==
|
||||
DNS_SIGTYPE(dns_rdatatype_nsec) &&
|
||||
!search.rbtversion->havensec3)
|
||||
{
|
||||
/*
|
||||
|
|
@ -1300,7 +1302,8 @@ found:
|
|||
*/
|
||||
nsecsig = header;
|
||||
} else if (cname_ok &&
|
||||
header->type == RBTDB_RDATATYPE_SIGCNAME)
|
||||
header->type ==
|
||||
DNS_SIGTYPE(dns_rdatatype_cname))
|
||||
{
|
||||
/*
|
||||
* If we get a CNAME match, we'll also need
|
||||
|
|
@ -1524,7 +1527,7 @@ zone_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
|
||||
matchtype = DNS_TYPEPAIR_VALUE(type, covers);
|
||||
if (covers == 0) {
|
||||
sigmatchtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, type);
|
||||
sigmatchtype = DNS_SIGTYPE(type);
|
||||
} else {
|
||||
sigmatchtype = 0;
|
||||
}
|
||||
|
|
@ -1683,7 +1686,7 @@ static isc_result_t
|
|||
loading_addrdataset(void *arg, const dns_name_t *name,
|
||||
dns_rdataset_t *rdataset DNS__DB_FLARG) {
|
||||
rbtdb_load_t *loadctx = arg;
|
||||
dns_rbtdb_t *rbtdb = loadctx->rbtdb;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)loadctx->db;
|
||||
dns_rbtnode_t *node = NULL;
|
||||
isc_result_t result;
|
||||
isc_region_t region;
|
||||
|
|
@ -1704,7 +1707,7 @@ loading_addrdataset(void *arg, const dns_name_t *name,
|
|||
if (rdataset->type != dns_rdatatype_nsec3 &&
|
||||
rdataset->covers != dns_rdatatype_nsec3)
|
||||
{
|
||||
dns__zonedb_addwildcards(rbtdb, name, false);
|
||||
dns__zonerbt_addwildcards(rbtdb, name, false);
|
||||
}
|
||||
|
||||
if (dns_name_iswildcard(name)) {
|
||||
|
|
@ -1720,7 +1723,7 @@ loading_addrdataset(void *arg, const dns_name_t *name,
|
|||
if (rdataset->type == dns_rdatatype_nsec3) {
|
||||
return (DNS_R_INVALIDNSEC3);
|
||||
}
|
||||
result = dns__zonedb_wildcardmagic(rbtdb, name, false);
|
||||
result = dns__zonerbt_wildcardmagic(rbtdb, name, false);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -1791,24 +1794,23 @@ loading_addrdataset(void *arg, const dns_name_t *name,
|
|||
static isc_result_t
|
||||
beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
||||
rbtdb_load_t *loadctx = NULL;
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(DNS_CALLBACK_VALID(callbacks));
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
loadctx = isc_mem_get(rbtdb->common.mctx, sizeof(*loadctx));
|
||||
|
||||
loadctx->rbtdb = rbtdb;
|
||||
loadctx->db = db;
|
||||
loadctx->now = 0;
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
REQUIRE((rbtdb->attributes &
|
||||
(RBTDB_ATTR_LOADED | RBTDB_ATTR_LOADING)) == 0);
|
||||
rbtdb->attributes |= RBTDB_ATTR_LOADING;
|
||||
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
callbacks->add = loading_addrdataset;
|
||||
callbacks->add_private = loadctx;
|
||||
|
|
@ -1825,9 +1827,9 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
|||
REQUIRE(DNS_CALLBACK_VALID(callbacks));
|
||||
loadctx = callbacks->add_private;
|
||||
REQUIRE(loadctx != NULL);
|
||||
REQUIRE(loadctx->rbtdb == rbtdb);
|
||||
REQUIRE(loadctx->db == db);
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
REQUIRE((rbtdb->attributes & RBTDB_ATTR_LOADING) != 0);
|
||||
REQUIRE((rbtdb->attributes & RBTDB_ATTR_LOADED) == 0);
|
||||
|
|
@ -1841,10 +1843,10 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
|||
*/
|
||||
if (rbtdb->origin_node != NULL) {
|
||||
dns_dbversion_t *version = rbtdb->current_version;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
|
||||
} else {
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
}
|
||||
|
||||
callbacks->add = NULL;
|
||||
|
|
@ -1857,16 +1859,14 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
|||
|
||||
static bool
|
||||
issecure(dns_db_t *db) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
bool secure;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
secure = rbtdb->current_version->secure;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
|
||||
return (secure);
|
||||
}
|
||||
|
|
@ -1875,16 +1875,14 @@ static isc_result_t
|
|||
getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
|
||||
uint8_t *flags, uint16_t *iterations, unsigned char *salt,
|
||||
size_t *salt_length) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
isc_result_t result = ISC_R_NOTFOUND;
|
||||
dns_rbtdb_version_t *rbtversion = version;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
INSIST(rbtversion == NULL || rbtversion->rbtdb == rbtdb);
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
if (rbtversion == NULL) {
|
||||
rbtversion = rbtdb->current_version;
|
||||
}
|
||||
|
|
@ -1909,7 +1907,7 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
|
|||
}
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -1917,16 +1915,14 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
|
|||
static isc_result_t
|
||||
getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
|
||||
uint64_t *xfrsize) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_rbtdb_version_t *rbtversion = version;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
INSIST(rbtversion == NULL || rbtversion->rbtdb == rbtdb);
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
if (rbtversion == NULL) {
|
||||
rbtversion = rbtdb->current_version;
|
||||
}
|
||||
|
|
@ -1936,7 +1932,7 @@ getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
|
|||
|
||||
SET_IF_NOT_NULL(xfrsize, rbtversion->xfrsize);
|
||||
RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -1954,7 +1950,7 @@ setsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, isc_stdtime_t resign) {
|
|||
|
||||
header = dns_slabheader_fromrdataset(rdataset);
|
||||
|
||||
NODE_WRLOCK(&rbtdb->node_locks[HEADER_NODE(header)->locknum].lock,
|
||||
NODE_WRLOCK(&rbtdb->node_locks[RBTDB_HEADERNODE(header)->locknum].lock,
|
||||
&nlocktype);
|
||||
|
||||
oldheader = *header;
|
||||
|
|
@ -1973,25 +1969,25 @@ setsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, isc_stdtime_t resign) {
|
|||
INSIST(RESIGN(header));
|
||||
if (resign == 0) {
|
||||
isc_heap_delete(
|
||||
rbtdb->heaps[HEADER_NODE(header)->locknum],
|
||||
rbtdb->heaps[RBTDB_HEADERNODE(header)->locknum],
|
||||
header->heap_index);
|
||||
header->heap_index = 0;
|
||||
header->heap = NULL;
|
||||
} else if (rbtdb->sooner(header, &oldheader)) {
|
||||
isc_heap_increased(
|
||||
rbtdb->heaps[HEADER_NODE(header)->locknum],
|
||||
rbtdb->heaps[RBTDB_HEADERNODE(header)->locknum],
|
||||
header->heap_index);
|
||||
} else if (rbtdb->sooner(&oldheader, header)) {
|
||||
isc_heap_decreased(
|
||||
rbtdb->heaps[HEADER_NODE(header)->locknum],
|
||||
rbtdb->heaps[RBTDB_HEADERNODE(header)->locknum],
|
||||
header->heap_index);
|
||||
}
|
||||
} else if (resign != 0) {
|
||||
DNS_SLABHEADER_SETATTR(header, DNS_SLABHEADERATTR_RESIGN);
|
||||
dns__zonedb_resigninsert(rbtdb, HEADER_NODE(header)->locknum,
|
||||
header);
|
||||
dns__zonerbt_resigninsert(
|
||||
rbtdb, RBTDB_HEADERNODE(header)->locknum, header);
|
||||
}
|
||||
NODE_UNLOCK(&rbtdb->node_locks[HEADER_NODE(header)->locknum].lock,
|
||||
NODE_UNLOCK(&rbtdb->node_locks[RBTDB_HEADERNODE(header)->locknum].lock,
|
||||
&nlocktype);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -2059,12 +2055,12 @@ getsigningtime(dns_db_t *db, dns_rdataset_t *rdataset,
|
|||
* Found something; pass back the answer and unlock
|
||||
* the bucket.
|
||||
*/
|
||||
dns__rbtdb_bindrdataset(rbtdb, HEADER_NODE(header), header, 0,
|
||||
isc_rwlocktype_read,
|
||||
dns__rbtdb_bindrdataset(rbtdb, RBTDB_HEADERNODE(header), header,
|
||||
0, isc_rwlocktype_read,
|
||||
rdataset DNS__DB_FLARG_PASS);
|
||||
|
||||
if (foundname != NULL) {
|
||||
dns_rbt_fullnamefromnode(HEADER_NODE(header),
|
||||
dns_rbt_fullnamefromnode(RBTDB_HEADERNODE(header),
|
||||
foundname);
|
||||
}
|
||||
|
||||
|
|
@ -2134,12 +2130,12 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
|
|||
dns_rdataset_init(&rdataset_aaaa);
|
||||
dns_rdataset_init(&sigrdataset_aaaa);
|
||||
|
||||
result = zone_find((dns_db_t *)ctx->rbtdb, name, ctx->rbtversion,
|
||||
dns_rdatatype_a, DNS_DBFIND_GLUEOK, 0,
|
||||
(dns_dbnode_t **)&node_a, name_a, &rdataset_a,
|
||||
result = zone_find(ctx->db, name, ctx->version, dns_rdatatype_a,
|
||||
DNS_DBFIND_GLUEOK, 0, (dns_dbnode_t **)&node_a,
|
||||
name_a, &rdataset_a,
|
||||
&sigrdataset_a DNS__DB_FLARG_PASS);
|
||||
if (result == DNS_R_GLUE) {
|
||||
glue = new_gluelist(ctx->rbtdb->common.mctx, name_a);
|
||||
glue = new_gluelist(ctx->db->mctx, name_a);
|
||||
|
||||
dns_rdataset_init(&glue->rdataset_a);
|
||||
dns_rdataset_init(&glue->sigrdataset_a);
|
||||
|
|
@ -2153,14 +2149,13 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
|
|||
}
|
||||
}
|
||||
|
||||
result = zone_find((dns_db_t *)ctx->rbtdb, name, ctx->rbtversion,
|
||||
dns_rdatatype_aaaa, DNS_DBFIND_GLUEOK, 0,
|
||||
(dns_dbnode_t **)&node_aaaa, name_aaaa,
|
||||
&rdataset_aaaa,
|
||||
result = zone_find(ctx->db, name, ctx->version, dns_rdatatype_aaaa,
|
||||
DNS_DBFIND_GLUEOK, 0, (dns_dbnode_t **)&node_aaaa,
|
||||
name_aaaa, &rdataset_aaaa,
|
||||
&sigrdataset_aaaa DNS__DB_FLARG_PASS);
|
||||
if (result == DNS_R_GLUE) {
|
||||
if (glue == NULL) {
|
||||
glue = new_gluelist(ctx->rbtdb->common.mctx, name_aaaa);
|
||||
glue = new_gluelist(ctx->db->mctx, name_aaaa);
|
||||
|
||||
dns_rdataset_init(&glue->rdataset_a);
|
||||
dns_rdataset_init(&glue->sigrdataset_a);
|
||||
|
|
@ -2219,13 +2214,12 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype,
|
|||
}
|
||||
|
||||
if (node_a != NULL) {
|
||||
dns__db_detachnode((dns_db_t *)ctx->rbtdb,
|
||||
dns__db_detachnode(ctx->db,
|
||||
(dns_dbnode_t *)&node_a DNS__DB_FLARG_PASS);
|
||||
}
|
||||
if (node_aaaa != NULL) {
|
||||
dns__db_detachnode(
|
||||
(dns_db_t *)ctx->rbtdb,
|
||||
(dns_dbnode_t *)&node_aaaa DNS__DB_FLARG_PASS);
|
||||
ctx->db, (dns_dbnode_t *)&node_aaaa DNS__DB_FLARG_PASS);
|
||||
}
|
||||
|
||||
return (result);
|
||||
|
|
@ -2316,8 +2310,8 @@ newglue(dns_rbtdb_t *rbtdb, dns_rbtdb_version_t *rbtversion,
|
|||
dns_rbtnode_t *node, dns_rdataset_t *rdataset) {
|
||||
dns_fixedname_t nodename;
|
||||
dns_glue_additionaldata_ctx_t ctx = {
|
||||
.rbtdb = rbtdb,
|
||||
.rbtversion = rbtversion,
|
||||
.db = (dns_db_t *)rbtdb,
|
||||
.version = (dns_dbversion_t *)rbtversion,
|
||||
.nodename = dns_fixedname_initname(&nodename),
|
||||
};
|
||||
|
||||
|
|
@ -2340,11 +2334,11 @@ addglue(dns_db_t *db, dns_dbversion_t *version, dns_rdataset_t *rdataset,
|
|||
dns_message_t *msg) {
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
dns_rbtdb_version_t *rbtversion = version;
|
||||
dns_rbtnode_t *node = RDATASET_DBNODE(rdataset);
|
||||
dns_rbtnode_t *node = (dns_rbtnode_t *)rdataset->slab.node;
|
||||
dns_slabheader_t *header = dns_slabheader_fromrdataset(rdataset);
|
||||
|
||||
REQUIRE(rdataset->type == dns_rdatatype_ns);
|
||||
REQUIRE(rbtdb == RDATASET_RBTDB(rdataset));
|
||||
REQUIRE(rbtdb == (dns_rbtdb_t *)rdataset->slab.db);
|
||||
REQUIRE(rbtdb == rbtversion->rbtdb);
|
||||
REQUIRE(!IS_CACHE(rbtdb) && !IS_STUB(rbtdb));
|
||||
|
||||
|
|
@ -2426,8 +2420,8 @@ dns_dbmethods_t dns__rbtdb_zonemethods = {
|
|||
};
|
||||
|
||||
void
|
||||
dns__zonedb_resigninsert(dns_rbtdb_t *rbtdb, int idx,
|
||||
dns_slabheader_t *newheader) {
|
||||
dns__zonerbt_resigninsert(dns_rbtdb_t *rbtdb, int idx,
|
||||
dns_slabheader_t *newheader) {
|
||||
INSIST(!IS_CACHE(rbtdb));
|
||||
INSIST(newheader->heap_index == 0);
|
||||
INSIST(!ISC_LINK_LINKED(newheader, link));
|
||||
|
|
@ -2437,18 +2431,18 @@ dns__zonedb_resigninsert(dns_rbtdb_t *rbtdb, int idx,
|
|||
}
|
||||
|
||||
void
|
||||
dns__zonedb_resigndelete(dns_rbtdb_t *rbtdb, dns_rbtdb_version_t *version,
|
||||
dns_slabheader_t *header DNS__DB_FLARG) {
|
||||
dns__zonerbt_resigndelete(dns_rbtdb_t *rbtdb, dns_rbtdb_version_t *version,
|
||||
dns_slabheader_t *header DNS__DB_FLARG) {
|
||||
/*
|
||||
* Remove the old header from the heap
|
||||
*/
|
||||
if (header != NULL && header->heap_index != 0) {
|
||||
isc_heap_delete(rbtdb->heaps[HEADER_NODE(header)->locknum],
|
||||
isc_heap_delete(rbtdb->heaps[RBTDB_HEADERNODE(header)->locknum],
|
||||
header->heap_index);
|
||||
header->heap_index = 0;
|
||||
if (version != NULL) {
|
||||
dns__rbtdb_newref(
|
||||
rbtdb, HEADER_NODE(header),
|
||||
rbtdb, RBTDB_HEADERNODE(header),
|
||||
isc_rwlocktype_write DNS__DB_FLARG_PASS);
|
||||
ISC_LIST_APPEND(version->resigned_list, header, link);
|
||||
}
|
||||
|
|
@ -2456,8 +2450,8 @@ dns__zonedb_resigndelete(dns_rbtdb_t *rbtdb, dns_rbtdb_version_t *version,
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
dns__zonedb_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock) {
|
||||
dns__zonerbt_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock) {
|
||||
isc_result_t result;
|
||||
dns_name_t foundname;
|
||||
dns_offsets_t offsets;
|
||||
|
|
@ -2489,8 +2483,8 @@ dns__zonedb_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
dns__zonedb_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock) {
|
||||
dns__zonerbt_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock) {
|
||||
isc_result_t result;
|
||||
dns_name_t foundname;
|
||||
dns_offsets_t offsets;
|
||||
|
|
@ -2504,8 +2498,8 @@ dns__zonedb_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
|||
dns_rbtnode_t *node = NULL;
|
||||
dns_name_getlabelsequence(name, n - i, i, &foundname);
|
||||
if (dns_name_iswildcard(&foundname)) {
|
||||
result = dns__zonedb_wildcardmagic(rbtdb, &foundname,
|
||||
lock);
|
||||
result = dns__zonerbt_wildcardmagic(rbtdb, &foundname,
|
||||
lock);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
193
lib/dns/rbtdb.c
193
lib/dns/rbtdb.c
|
|
@ -61,6 +61,7 @@
|
|||
#include <dns/zone.h>
|
||||
#include <dns/zonekey.h>
|
||||
|
||||
#include "db_p.h"
|
||||
#include "rbtdb_p.h"
|
||||
|
||||
#define CHECK(op) \
|
||||
|
|
@ -137,7 +138,7 @@
|
|||
* The default value should work well for most environments, but this can
|
||||
* also be configurable at compilation time via the
|
||||
* DNS_RBTDB_CACHE_NODE_LOCK_COUNT variable. This value must be larger than
|
||||
* 1 due to the assumption of dns__cachedb_overmem().
|
||||
* 1 due to the assumption of dns__cacherbt_overmem().
|
||||
*/
|
||||
#ifdef DNS_RBTDB_CACHE_NODE_LOCK_COUNT
|
||||
#if DNS_RBTDB_CACHE_NODE_LOCK_COUNT <= 1
|
||||
|
|
@ -339,21 +340,21 @@ static bool
|
|||
prio_type(dns_typepair_t type) {
|
||||
switch (type) {
|
||||
case dns_rdatatype_soa:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_soa):
|
||||
case DNS_SIGTYPE(dns_rdatatype_soa):
|
||||
case dns_rdatatype_a:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_a):
|
||||
case DNS_SIGTYPE(dns_rdatatype_a):
|
||||
case dns_rdatatype_aaaa:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_aaaa):
|
||||
case DNS_SIGTYPE(dns_rdatatype_aaaa):
|
||||
case dns_rdatatype_nsec:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec):
|
||||
case DNS_SIGTYPE(dns_rdatatype_nsec):
|
||||
case dns_rdatatype_nsec3:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec3):
|
||||
case DNS_SIGTYPE(dns_rdatatype_nsec3):
|
||||
case dns_rdatatype_ns:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ns):
|
||||
case DNS_SIGTYPE(dns_rdatatype_ns):
|
||||
case dns_rdatatype_ds:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ds):
|
||||
case DNS_SIGTYPE(dns_rdatatype_ds):
|
||||
case dns_rdatatype_cname:
|
||||
case DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_cname):
|
||||
case DNS_SIGTYPE(dns_rdatatype_cname):
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -383,7 +384,7 @@ resign_sooner(void *v1, void *v2) {
|
|||
return (h1->resign < h2->resign ||
|
||||
(h1->resign == h2->resign && h1->resign_lsb < h2->resign_lsb) ||
|
||||
(h1->resign == h2->resign && h1->resign_lsb == h2->resign_lsb &&
|
||||
h2->type == RBTDB_RDATATYPE_SIGSOA));
|
||||
h2->type == DNS_SIGTYPE(dns_rdatatype_soa)));
|
||||
}
|
||||
|
||||
/*%
|
||||
|
|
@ -590,14 +591,14 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) {
|
|||
}
|
||||
|
||||
isc_mem_cput(rbtdb->common.mctx, rbtdb->node_locks,
|
||||
rbtdb->node_lock_count, sizeof(rbtdb_nodelock_t));
|
||||
rbtdb->node_lock_count, sizeof(db_nodelock_t));
|
||||
TREE_DESTROYLOCK(&rbtdb->tree_lock);
|
||||
isc_refcount_destroy(&rbtdb->common.references);
|
||||
if (rbtdb->loop != NULL) {
|
||||
isc_loop_detach(&rbtdb->loop);
|
||||
}
|
||||
|
||||
RBTDB_DESTROYLOCK(&rbtdb->lock);
|
||||
isc_rwlock_destroy(&rbtdb->lock);
|
||||
rbtdb->common.magic = 0;
|
||||
rbtdb->common.impmagic = 0;
|
||||
isc_mem_detach(&rbtdb->hmctx);
|
||||
|
|
@ -650,12 +651,12 @@ dns__rbtdb_destroy(dns_db_t *arg) {
|
|||
}
|
||||
|
||||
if (inactive != 0) {
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
rbtdb->active -= inactive;
|
||||
if (rbtdb->active == 0) {
|
||||
want_free = true;
|
||||
}
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
if (want_free) {
|
||||
char buf[DNS_NAME_FORMATSIZE];
|
||||
if (dns_name_dynamic(&rbtdb->common.origin)) {
|
||||
|
|
@ -679,10 +680,10 @@ dns__rbtdb_currentversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
|||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
version = rbtdb->current_version;
|
||||
isc_refcount_increment(&version->references);
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
|
||||
*versionp = (dns_dbversion_t *)version;
|
||||
}
|
||||
|
|
@ -715,7 +716,7 @@ dns__rbtdb_newversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
|||
REQUIRE(versionp != NULL && *versionp == NULL);
|
||||
REQUIRE(rbtdb->future_version == NULL);
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RUNTIME_CHECK(rbtdb->next_serial != 0); /* XXX Error? */
|
||||
version = allocate_version(rbtdb->common.mctx, rbtdb->next_serial, 1,
|
||||
true);
|
||||
|
|
@ -744,7 +745,7 @@ dns__rbtdb_newversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
|||
RWUNLOCK(&rbtdb->current_version->rwlock, isc_rwlocktype_read);
|
||||
rbtdb->next_serial++;
|
||||
rbtdb->future_version = version;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
*versionp = version;
|
||||
|
||||
|
|
@ -778,7 +779,7 @@ add_changed(dns_slabheader_t *header,
|
|||
|
||||
changed = isc_mem_get(rbtdb->common.mctx, sizeof(*changed));
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
REQUIRE(version->writer);
|
||||
|
||||
|
|
@ -799,7 +800,7 @@ add_changed(dns_slabheader_t *header,
|
|||
version->commit_ok = false;
|
||||
}
|
||||
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
return (changed);
|
||||
}
|
||||
|
|
@ -871,7 +872,7 @@ static void
|
|||
mark_ancient(dns_slabheader_t *header) {
|
||||
dns__rbtdb_setttl(header, 0);
|
||||
dns__rbtdb_mark(header, DNS_SLABHEADERATTR_ANCIENT);
|
||||
HEADER_NODE(header)->dirty = 1;
|
||||
RBTDB_HEADERNODE(header)->dirty = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1175,8 +1176,8 @@ is_leaf(dns_rbtnode_t *node) {
|
|||
static void
|
||||
send_to_prune_tree(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node,
|
||||
isc_rwlocktype_t locktype DNS__DB_FLARG) {
|
||||
prune_t *prune = isc_mem_get(rbtdb->common.mctx, sizeof(*prune));
|
||||
*prune = (prune_t){ .node = node };
|
||||
db_prune_t *prune = isc_mem_get(rbtdb->common.mctx, sizeof(*prune));
|
||||
*prune = (db_prune_t){ .node = node };
|
||||
|
||||
dns_db_attach((dns_db_t *)rbtdb, &prune->db);
|
||||
dns__rbtdb_newref(rbtdb, node, locktype DNS__DB_FLARG_PASS);
|
||||
|
|
@ -1311,7 +1312,7 @@ dns__rbtdb_decref(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node,
|
|||
isc_result_t result;
|
||||
bool locked = *tlocktypep != isc_rwlocktype_none;
|
||||
bool write_locked = false;
|
||||
rbtdb_nodelock_t *nodelock = NULL;
|
||||
db_nodelock_t *nodelock = NULL;
|
||||
int bucket = node->locknum;
|
||||
bool no_reference = true;
|
||||
uint_fast32_t refs;
|
||||
|
|
@ -1375,9 +1376,9 @@ dns__rbtdb_decref(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node,
|
|||
* Caller doesn't know the least serial.
|
||||
* Get it.
|
||||
*/
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
least_serial = rbtdb->least_serial;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
}
|
||||
clean_zone_node(node, least_serial);
|
||||
}
|
||||
|
|
@ -1487,7 +1488,7 @@ restore_locks:
|
|||
*/
|
||||
static void
|
||||
prune_tree(void *arg) {
|
||||
prune_t *prune = (prune_t *)arg;
|
||||
db_prune_t *prune = (db_prune_t *)arg;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)prune->db;
|
||||
dns_rbtnode_t *node = prune->node;
|
||||
dns_rbtnode_t *parent = NULL;
|
||||
|
|
@ -1780,9 +1781,9 @@ dns__rbtdb_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
|
|||
if (isc_refcount_decrement(&version->references) > 1) {
|
||||
/* typical and easy case first */
|
||||
if (commit) {
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
INSIST(!version->writer);
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -1795,7 +1796,7 @@ dns__rbtdb_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
|
|||
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
|
||||
}
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
serial = version->serial;
|
||||
if (version->writer) {
|
||||
if (commit) {
|
||||
|
|
@ -1930,7 +1931,7 @@ dns__rbtdb_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
|
|||
UNLINK(rbtdb->open_versions, version, link);
|
||||
}
|
||||
least_serial = rbtdb->least_serial;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
if (cleanup_version != NULL) {
|
||||
isc_refcount_destroy(&cleanup_version->references);
|
||||
|
|
@ -1954,13 +1955,15 @@ dns__rbtdb_closeversion(dns_db_t *db, dns_dbversion_t **versionp,
|
|||
|
||||
ISC_LIST_UNLINK(resigned_list, header, link);
|
||||
|
||||
lock = &rbtdb->node_locks[HEADER_NODE(header)->locknum].lock;
|
||||
lock = &rbtdb->node_locks[RBTDB_HEADERNODE(header)->locknum]
|
||||
.lock;
|
||||
NODE_WRLOCK(lock, &nlocktype);
|
||||
if (rollback && !IGNORE(header)) {
|
||||
dns__zonedb_resigninsert(
|
||||
rbtdb, HEADER_NODE(header)->locknum, header);
|
||||
dns__zonerbt_resigninsert(
|
||||
rbtdb, RBTDB_HEADERNODE(header)->locknum,
|
||||
header);
|
||||
}
|
||||
dns__rbtdb_decref(rbtdb, HEADER_NODE(header), least_serial,
|
||||
dns__rbtdb_decref(rbtdb, RBTDB_HEADERNODE(header), least_serial,
|
||||
&nlocktype, &tlocktype, true,
|
||||
false DNS__DB_FLARG_PASS);
|
||||
NODE_UNLOCK(lock, &nlocktype);
|
||||
|
|
@ -2063,10 +2066,10 @@ dns__rbtdb_findnodeintree(dns_rbtdb_t *rbtdb, dns_rbt_t *tree,
|
|||
dns_rbt_namefromnode(node, &nodename);
|
||||
node->locknum = node->hashval % rbtdb->node_lock_count;
|
||||
if (tree == rbtdb->tree) {
|
||||
dns__zonedb_addwildcards(rbtdb, name, true);
|
||||
dns__zonerbt_addwildcards(rbtdb, name, true);
|
||||
|
||||
if (dns_name_iswildcard(name)) {
|
||||
result = dns__zonedb_wildcardmagic(
|
||||
result = dns__zonerbt_wildcardmagic(
|
||||
rbtdb, name, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto unlock;
|
||||
|
|
@ -2246,7 +2249,7 @@ dns__rbtdb_detachnode(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG) {
|
|||
dns_rbtnode_t *node = NULL;
|
||||
bool want_free = false;
|
||||
bool inactive = false;
|
||||
rbtdb_nodelock_t *nodelock = NULL;
|
||||
db_nodelock_t *nodelock = NULL;
|
||||
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
|
||||
isc_rwlocktype_t tlocktype = isc_rwlocktype_none;
|
||||
|
||||
|
|
@ -2274,12 +2277,12 @@ dns__rbtdb_detachnode(dns_db_t *db, dns_dbnode_t **targetp DNS__DB_FLARG) {
|
|||
*targetp = NULL;
|
||||
|
||||
if (inactive) {
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
rbtdb->active--;
|
||||
if (rbtdb->active == 0) {
|
||||
want_free = true;
|
||||
}
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
if (want_free) {
|
||||
char buf[DNS_NAME_FORMATSIZE];
|
||||
if (dns_name_dynamic(&rbtdb->common.origin)) {
|
||||
|
|
@ -2552,7 +2555,7 @@ dns__rbtdb_add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode,
|
|||
if (rbtversion == NULL && !newheader_nx) {
|
||||
rdtype = DNS_TYPEPAIR_TYPE(newheader->type);
|
||||
covers = DNS_TYPEPAIR_COVERS(newheader->type);
|
||||
sigtype = DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, covers);
|
||||
sigtype = DNS_SIGTYPE(covers);
|
||||
if (NEGATIVE(newheader)) {
|
||||
/*
|
||||
* We're adding a negative cache entry.
|
||||
|
|
@ -2599,8 +2602,7 @@ dns__rbtdb_add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode,
|
|||
for (topheader = rbtnode->data; topheader != NULL;
|
||||
topheader = topheader->next)
|
||||
{
|
||||
if ((topheader->type ==
|
||||
RBTDB_RDATATYPE_NCACHEANY) ||
|
||||
if ((topheader->type == RDATATYPE_NCACHEANY) ||
|
||||
(newheader->type == sigtype &&
|
||||
topheader->type ==
|
||||
DNS_TYPEPAIR_VALUE(0, covers)))
|
||||
|
|
@ -2792,11 +2794,13 @@ find_header:
|
|||
}
|
||||
if (header->last_used != now) {
|
||||
ISC_LIST_UNLINK(
|
||||
rbtdb->lru[HEADER_NODE(header)->locknum],
|
||||
rbtdb->lru[RBTDB_HEADERNODE(header)
|
||||
->locknum],
|
||||
header, link);
|
||||
header->last_used = now;
|
||||
ISC_LIST_PREPEND(
|
||||
rbtdb->lru[HEADER_NODE(header)->locknum],
|
||||
rbtdb->lru[RBTDB_HEADERNODE(header)
|
||||
->locknum],
|
||||
header, link);
|
||||
}
|
||||
if (header->noqname == NULL &&
|
||||
|
|
@ -2839,7 +2843,7 @@ find_header:
|
|||
(header->type == dns_rdatatype_a ||
|
||||
header->type == dns_rdatatype_aaaa ||
|
||||
header->type == dns_rdatatype_ds ||
|
||||
header->type == RBTDB_RDATATYPE_SIGDS) &&
|
||||
header->type == DNS_SIGTYPE(dns_rdatatype_ds)) &&
|
||||
!header_nx && !newheader_nx &&
|
||||
header->trust >= newheader->trust &&
|
||||
dns_rdataslab_equal((unsigned char *)header,
|
||||
|
|
@ -2855,11 +2859,13 @@ find_header:
|
|||
}
|
||||
if (header->last_used != now) {
|
||||
ISC_LIST_UNLINK(
|
||||
rbtdb->lru[HEADER_NODE(header)->locknum],
|
||||
rbtdb->lru[RBTDB_HEADERNODE(header)
|
||||
->locknum],
|
||||
header, link);
|
||||
header->last_used = now;
|
||||
ISC_LIST_PREPEND(
|
||||
rbtdb->lru[HEADER_NODE(header)->locknum],
|
||||
rbtdb->lru[RBTDB_HEADERNODE(header)
|
||||
->locknum],
|
||||
header, link);
|
||||
}
|
||||
if (header->noqname == NULL &&
|
||||
|
|
@ -2887,7 +2893,7 @@ find_header:
|
|||
rbtversion->serial >= topheader->serial);
|
||||
if (loading) {
|
||||
newheader->down = NULL;
|
||||
idx = HEADER_NODE(newheader)->locknum;
|
||||
idx = RBTDB_HEADERNODE(newheader)->locknum;
|
||||
if (IS_CACHE(rbtdb)) {
|
||||
if (ZEROTTL(newheader)) {
|
||||
newheader->last_used =
|
||||
|
|
@ -2902,7 +2908,8 @@ find_header:
|
|||
isc_heap_insert(rbtdb->heaps[idx], newheader);
|
||||
newheader->heap = rbtdb->heaps[idx];
|
||||
} else if (RESIGN(newheader)) {
|
||||
dns__zonedb_resigninsert(rbtdb, idx, newheader);
|
||||
dns__zonerbt_resigninsert(rbtdb, idx,
|
||||
newheader);
|
||||
/*
|
||||
* Don't call resigndelete, we don't need
|
||||
* to reverse the delete. The free_slabheader
|
||||
|
|
@ -2929,7 +2936,7 @@ find_header:
|
|||
}
|
||||
dns_slabheader_destroy(&header);
|
||||
} else {
|
||||
idx = HEADER_NODE(newheader)->locknum;
|
||||
idx = RBTDB_HEADERNODE(newheader)->locknum;
|
||||
if (IS_CACHE(rbtdb)) {
|
||||
INSIST(rbtdb->heaps != NULL);
|
||||
isc_heap_insert(rbtdb->heaps[idx], newheader);
|
||||
|
|
@ -2944,8 +2951,9 @@ find_header:
|
|||
newheader, link);
|
||||
}
|
||||
} else if (RESIGN(newheader)) {
|
||||
dns__zonedb_resigninsert(rbtdb, idx, newheader);
|
||||
dns__zonedb_resigndelete(
|
||||
dns__zonerbt_resigninsert(rbtdb, idx,
|
||||
newheader);
|
||||
dns__zonerbt_resigndelete(
|
||||
rbtdb, rbtversion,
|
||||
header DNS__DB_FLARG_PASS);
|
||||
}
|
||||
|
|
@ -2987,7 +2995,7 @@ find_header:
|
|||
return (DNS_R_UNCHANGED);
|
||||
}
|
||||
|
||||
idx = HEADER_NODE(newheader)->locknum;
|
||||
idx = RBTDB_HEADERNODE(newheader)->locknum;
|
||||
if (IS_CACHE(rbtdb)) {
|
||||
isc_heap_insert(rbtdb->heaps[idx], newheader);
|
||||
newheader->heap = rbtdb->heaps[idx];
|
||||
|
|
@ -2999,9 +3007,9 @@ find_header:
|
|||
link);
|
||||
}
|
||||
} else if (RESIGN(newheader)) {
|
||||
dns__zonedb_resigninsert(rbtdb, idx, newheader);
|
||||
dns__zonedb_resigndelete(rbtdb, rbtversion,
|
||||
header DNS__DB_FLARG_PASS);
|
||||
dns__zonerbt_resigninsert(rbtdb, idx, newheader);
|
||||
dns__zonerbt_resigndelete(rbtdb, rbtversion,
|
||||
header DNS__DB_FLARG_PASS);
|
||||
}
|
||||
|
||||
if (topheader != NULL) {
|
||||
|
|
@ -3094,7 +3102,7 @@ static isc_result_t
|
|||
addnoqname(isc_mem_t *mctx, dns_slabheader_t *newheader,
|
||||
dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
dns_proof_t *noqname = NULL;
|
||||
dns_slabheader_proof_t *noqname = NULL;
|
||||
dns_name_t name = DNS_NAME_INITEMPTY;
|
||||
dns_rdataset_t neg = DNS_RDATASET_INIT, negsig = DNS_RDATASET_INIT;
|
||||
isc_region_t r1, r2;
|
||||
|
|
@ -3113,7 +3121,7 @@ addnoqname(isc_mem_t *mctx, dns_slabheader_t *newheader,
|
|||
}
|
||||
|
||||
noqname = isc_mem_get(mctx, sizeof(*noqname));
|
||||
*noqname = (dns_proof_t){
|
||||
*noqname = (dns_slabheader_proof_t){
|
||||
.neg = r1.base,
|
||||
.negsig = r2.base,
|
||||
.type = neg.type,
|
||||
|
|
@ -3133,7 +3141,7 @@ static isc_result_t
|
|||
addclosest(isc_mem_t *mctx, dns_slabheader_t *newheader,
|
||||
dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
dns_proof_t *closest = NULL;
|
||||
dns_slabheader_proof_t *closest = NULL;
|
||||
dns_name_t name = DNS_NAME_INITEMPTY;
|
||||
dns_rdataset_t neg = DNS_RDATASET_INIT, negsig = DNS_RDATASET_INIT;
|
||||
isc_region_t r1, r2;
|
||||
|
|
@ -3152,7 +3160,7 @@ addclosest(isc_mem_t *mctx, dns_slabheader_t *newheader,
|
|||
}
|
||||
|
||||
closest = isc_mem_get(mctx, sizeof(*closest));
|
||||
*closest = (dns_proof_t){
|
||||
*closest = (dns_slabheader_proof_t){
|
||||
.neg = r1.base,
|
||||
.negsig = r2.base,
|
||||
.name = DNS_NAME_INITEMPTY,
|
||||
|
|
@ -3330,8 +3338,8 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
|
|||
}
|
||||
|
||||
if (cache_is_overmem) {
|
||||
dns__cachedb_overmem(rbtdb, newheader,
|
||||
&tlocktype DNS__DB_FLARG_PASS);
|
||||
dns__cacherbt_overmem(rbtdb, newheader,
|
||||
&tlocktype DNS__DB_FLARG_PASS);
|
||||
}
|
||||
|
||||
NODE_WRLOCK(&rbtdb->node_locks[rbtnode->locknum].lock, &nlocktype);
|
||||
|
|
@ -3353,7 +3361,7 @@ dns__rbtdb_addrdataset(dns_db_t *db, dns_dbnode_t *node,
|
|||
if (header != NULL && header->ttl + STALE_TTL(header, rbtdb) <
|
||||
now - RBTDB_VIRTUAL)
|
||||
{
|
||||
dns__cachedb_expireheader(
|
||||
dns__cacherbt_expireheader(
|
||||
header, &tlocktype,
|
||||
dns_expire_ttl DNS__DB_FLARG_PASS);
|
||||
}
|
||||
|
|
@ -3533,7 +3541,7 @@ dns__rbtdb_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
|
|||
newheader, DNS_SLABHEADERATTR_RESIGN);
|
||||
newheader->resign = header->resign;
|
||||
newheader->resign_lsb = header->resign_lsb;
|
||||
dns__zonedb_resigninsert(
|
||||
dns__zonerbt_resigninsert(
|
||||
rbtdb, rbtnode->locknum, newheader);
|
||||
}
|
||||
/*
|
||||
|
|
@ -3584,8 +3592,8 @@ dns__rbtdb_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
|
|||
topheader->next = newheader;
|
||||
rbtnode->dirty = 1;
|
||||
changed->dirty = true;
|
||||
dns__zonedb_resigndelete(rbtdb, rbtversion,
|
||||
header DNS__DB_FLARG_PASS);
|
||||
dns__zonerbt_resigndelete(rbtdb, rbtversion,
|
||||
header DNS__DB_FLARG_PASS);
|
||||
} else {
|
||||
/*
|
||||
* The rdataset doesn't exist, so we don't need to do anything
|
||||
|
|
@ -3621,9 +3629,9 @@ unlock:
|
|||
* this is deferred until dns__rbtdb_closeversion() is called.
|
||||
*/
|
||||
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb)) {
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
version = rbtdb->current_version;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
|
||||
}
|
||||
|
||||
|
|
@ -3674,9 +3682,9 @@ dns__rbtdb_deleterdataset(dns_db_t *db, dns_dbnode_t *node,
|
|||
* this is deferred until dns__rbtdb_closeversion() is called.
|
||||
*/
|
||||
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb)) {
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
version = rbtdb->current_version;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_read);
|
||||
dns__rbtdb_setsecure(db, version, rbtdb->origin_node);
|
||||
}
|
||||
|
||||
|
|
@ -3691,7 +3699,7 @@ delete_callback(void *data, void *arg) {
|
|||
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
|
||||
|
||||
current = data;
|
||||
locknum = HEADER_NODE(current)->locknum;
|
||||
locknum = RBTDB_HEADERNODE(current)->locknum;
|
||||
NODE_WRLOCK(&rbtdb->node_locks[locknum].lock, &nlocktype);
|
||||
while (current != NULL) {
|
||||
next = current->next;
|
||||
|
|
@ -3703,12 +3711,10 @@ delete_callback(void *data, void *arg) {
|
|||
|
||||
unsigned int
|
||||
dns__rbtdb_nodecount(dns_db_t *db, dns_dbtree_t tree) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
unsigned int count;
|
||||
isc_rwlocktype_t tlocktype = isc_rwlocktype_none;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
TREE_RDLOCK(&rbtdb->tree_lock, &tlocktype);
|
||||
|
|
@ -3732,20 +3738,18 @@ dns__rbtdb_nodecount(dns_db_t *db, dns_dbtree_t tree) {
|
|||
|
||||
void
|
||||
dns__rbtdb_setloop(dns_db_t *db, isc_loop_t *loop) {
|
||||
dns_rbtdb_t *rbtdb = NULL;
|
||||
|
||||
rbtdb = (dns_rbtdb_t *)db;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
|
||||
REQUIRE(VALID_RBTDB(rbtdb));
|
||||
|
||||
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
if (rbtdb->loop != NULL) {
|
||||
isc_loop_detach(&rbtdb->loop);
|
||||
}
|
||||
if (loop != NULL) {
|
||||
isc_loop_attach(loop, &rbtdb->loop);
|
||||
}
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
RWUNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
|
@ -3844,7 +3848,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
rbtdb->common.methods = &dns__rbtdb_zonemethods;
|
||||
}
|
||||
|
||||
RBTDB_INITLOCK(&rbtdb->lock);
|
||||
isc_rwlock_init(&rbtdb->lock);
|
||||
TREE_INITLOCK(&rbtdb->tree_lock);
|
||||
|
||||
/*
|
||||
|
|
@ -3865,7 +3869,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
}
|
||||
INSIST(rbtdb->node_lock_count < (1 << DNS_RBT_LOCKLENGTH));
|
||||
rbtdb->node_locks = isc_mem_get(mctx, rbtdb->node_lock_count *
|
||||
sizeof(rbtdb_nodelock_t));
|
||||
sizeof(db_nodelock_t));
|
||||
|
||||
rbtdb->common.update_listeners = cds_lfht_new(16, 16, 0, 0, NULL);
|
||||
|
||||
|
|
@ -4024,7 +4028,7 @@ dns__rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
|
||||
cleanup_tree_lock:
|
||||
TREE_DESTROYLOCK(&rbtdb->tree_lock);
|
||||
RBTDB_DESTROYLOCK(&rbtdb->lock);
|
||||
isc_rwlock_destroy(&rbtdb->lock);
|
||||
isc_mem_put(mctx, rbtdb, sizeof(*rbtdb));
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -4749,23 +4753,6 @@ free_gluetable(dns_rbtdb_version_t *rbtversion) {
|
|||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void
|
||||
free_proof(isc_mem_t *mctx, dns_proof_t **noqname) {
|
||||
if (dns_name_dynamic(&(*noqname)->name)) {
|
||||
dns_name_free(&(*noqname)->name, mctx);
|
||||
}
|
||||
if ((*noqname)->neg != NULL) {
|
||||
isc_mem_put(mctx, (*noqname)->neg,
|
||||
dns_rdataslab_size((*noqname)->neg, 0));
|
||||
}
|
||||
if ((*noqname)->negsig != NULL) {
|
||||
isc_mem_put(mctx, (*noqname)->negsig,
|
||||
dns_rdataslab_size((*noqname)->negsig, 0));
|
||||
}
|
||||
isc_mem_put(mctx, *noqname, sizeof(**noqname));
|
||||
*noqname = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
dns__rbtdb_deletedata(dns_db_t *db ISC_ATTR_UNUSED,
|
||||
dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) {
|
||||
|
|
@ -4783,16 +4770,16 @@ dns__rbtdb_deletedata(dns_db_t *db ISC_ATTR_UNUSED,
|
|||
false);
|
||||
|
||||
if (ISC_LINK_LINKED(header, link)) {
|
||||
int idx = HEADER_NODE(header)->locknum;
|
||||
int idx = RBTDB_HEADERNODE(header)->locknum;
|
||||
INSIST(IS_CACHE(rbtdb));
|
||||
ISC_LIST_UNLINK(rbtdb->lru[idx], header, link);
|
||||
}
|
||||
|
||||
if (header->noqname != NULL) {
|
||||
free_proof(db->mctx, &header->noqname);
|
||||
dns_slabheader_freeproof(db->mctx, &header->noqname);
|
||||
}
|
||||
if (header->closest != NULL) {
|
||||
free_proof(db->mctx, &header->closest);
|
||||
dns_slabheader_freeproof(db->mctx, &header->closest);
|
||||
}
|
||||
} else {
|
||||
if (header->glue_list) {
|
||||
|
|
|
|||
|
|
@ -29,124 +29,7 @@
|
|||
#define VALID_RBTDB(rbtdb) \
|
||||
((rbtdb) != NULL && (rbtdb)->common.impmagic == RBTDB_MAGIC)
|
||||
|
||||
#define RBTDB_RDATATYPE_SIGNSEC \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec)
|
||||
#define RBTDB_RDATATYPE_SIGNSEC3 \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec3)
|
||||
#define RBTDB_RDATATYPE_SIGNS \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ns)
|
||||
#define RBTDB_RDATATYPE_SIGCNAME \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_cname)
|
||||
#define RBTDB_RDATATYPE_SIGDNAME \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_dname)
|
||||
#define RBTDB_RDATATYPE_SIGDS \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_ds)
|
||||
#define RBTDB_RDATATYPE_SIGSOA \
|
||||
DNS_TYPEPAIR_VALUE(dns_rdatatype_rrsig, dns_rdatatype_soa)
|
||||
#define RBTDB_RDATATYPE_NCACHEANY DNS_TYPEPAIR_VALUE(0, dns_rdatatype_any)
|
||||
|
||||
#define RBTDB_INITLOCK(l) isc_rwlock_init((l))
|
||||
#define RBTDB_DESTROYLOCK(l) isc_rwlock_destroy(l)
|
||||
#define RBTDB_LOCK(l, t) RWLOCK((l), (t))
|
||||
#define RBTDB_UNLOCK(l, t) RWUNLOCK((l), (t))
|
||||
|
||||
#ifdef DNS_RBTDB_STRONG_RWLOCK_CHECK
|
||||
#define STRONG_RWLOCK_CHECK(cond) REQUIRE(cond)
|
||||
#else
|
||||
#define STRONG_RWLOCK_CHECK(cond)
|
||||
#endif
|
||||
|
||||
#define NODE_INITLOCK(l) isc_rwlock_init((l))
|
||||
#define NODE_DESTROYLOCK(l) isc_rwlock_destroy(l)
|
||||
#define NODE_LOCK(l, t, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
RWLOCK((l), (t)); \
|
||||
*tp = t; \
|
||||
}
|
||||
#define NODE_UNLOCK(l, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
|
||||
RWUNLOCK(l, *tp); \
|
||||
*tp = isc_rwlocktype_none; \
|
||||
}
|
||||
#define NODE_RDLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_read, tp);
|
||||
#define NODE_WRLOCK(l, tp) NODE_LOCK(l, isc_rwlocktype_write, tp);
|
||||
#define NODE_TRYLOCK(l, t, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
isc_result_t _result = isc_rwlock_trylock(l, t); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = t; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define NODE_TRYRDLOCK(l, tp) NODE_TRYLOCK(l, isc_rwlocktype_read, tp)
|
||||
#define NODE_TRYWRLOCK(l, tp) NODE_TRYLOCK(l, isc_rwlocktype_write, tp)
|
||||
#define NODE_TRYUPGRADE(l, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
|
||||
isc_result_t _result = isc_rwlock_tryupgrade(l); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = isc_rwlocktype_write; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define NODE_FORCEUPGRADE(l, tp) \
|
||||
if (NODE_TRYUPGRADE(l, tp) != ISC_R_SUCCESS) { \
|
||||
NODE_UNLOCK(l, tp); \
|
||||
NODE_WRLOCK(l, tp); \
|
||||
}
|
||||
|
||||
#define TREE_INITLOCK(l) isc_rwlock_init(l)
|
||||
#define TREE_DESTROYLOCK(l) isc_rwlock_destroy(l)
|
||||
#define TREE_LOCK(l, t, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
RWLOCK(l, t); \
|
||||
*tp = t; \
|
||||
}
|
||||
#define TREE_UNLOCK(l, tp) \
|
||||
{ \
|
||||
STRONG_RWLOCK_CHECK(*tp != isc_rwlocktype_none); \
|
||||
RWUNLOCK(l, *tp); \
|
||||
*tp = isc_rwlocktype_none; \
|
||||
}
|
||||
#define TREE_RDLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_read, tp);
|
||||
#define TREE_WRLOCK(l, tp) TREE_LOCK(l, isc_rwlocktype_write, tp);
|
||||
#define TREE_TRYLOCK(l, t, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_none); \
|
||||
isc_result_t _result = isc_rwlock_trylock(l, t); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = t; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define TREE_TRYRDLOCK(l, tp) TREE_TRYLOCK(l, isc_rwlocktype_read, tp)
|
||||
#define TREE_TRYWRLOCK(l, tp) TREE_TRYLOCK(l, isc_rwlocktype_write, tp)
|
||||
#define TREE_TRYUPGRADE(l, tp) \
|
||||
({ \
|
||||
STRONG_RWLOCK_CHECK(*tp == isc_rwlocktype_read); \
|
||||
isc_result_t _result = isc_rwlock_tryupgrade(l); \
|
||||
if (_result == ISC_R_SUCCESS) { \
|
||||
*tp = isc_rwlocktype_write; \
|
||||
}; \
|
||||
_result; \
|
||||
})
|
||||
#define TREE_FORCEUPGRADE(l, tp) \
|
||||
if (TREE_TRYUPGRADE(l, tp) != ISC_R_SUCCESS) { \
|
||||
TREE_UNLOCK(l, tp); \
|
||||
TREE_WRLOCK(l, tp); \
|
||||
}
|
||||
|
||||
#define RDATASET_RBTDB(r) ((dns_rbtdb_t *)(r)->slab.db)
|
||||
#define RDATASET_DBNODE(r) ((dns_rbtnode_t *)(r)->slab.node)
|
||||
|
||||
#define HEADER_NODE(h) ((dns_rbtnode_t *)((h)->node))
|
||||
|
||||
#define IS_STUB(rbtdb) (((rbtdb)->common.attributes & DNS_DBATTR_STUB) != 0)
|
||||
#define IS_CACHE(rbtdb) (((rbtdb)->common.attributes & DNS_DBATTR_CACHE) != 0)
|
||||
#define RBTDB_HEADERNODE(h) ((dns_rbtnode_t *)((h)->node))
|
||||
|
||||
/*
|
||||
* Allow clients with a virtual time of up to 5 minutes in the past to see
|
||||
|
|
@ -165,14 +48,6 @@
|
|||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef struct {
|
||||
isc_rwlock_t lock;
|
||||
/* Protected in the refcount routines. */
|
||||
isc_refcount_t references;
|
||||
/* Locked by lock. */
|
||||
bool exiting;
|
||||
} rbtdb_nodelock_t;
|
||||
|
||||
typedef struct rbtdb_changed {
|
||||
dns_rbtnode_t *node;
|
||||
bool dirty;
|
||||
|
|
@ -181,25 +56,6 @@ typedef struct rbtdb_changed {
|
|||
|
||||
typedef ISC_LIST(rbtdb_changed_t) rbtdb_changedlist_t;
|
||||
|
||||
struct dns_glue {
|
||||
struct dns_glue *next;
|
||||
dns_fixedname_t fixedname;
|
||||
dns_rdataset_t rdataset_a;
|
||||
dns_rdataset_t sigrdataset_a;
|
||||
dns_rdataset_t rdataset_aaaa;
|
||||
dns_rdataset_t sigrdataset_aaaa;
|
||||
|
||||
isc_mem_t *mctx;
|
||||
struct rcu_head rcu_head;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
dns_glue_t *glue_list;
|
||||
dns_rbtdb_t *rbtdb;
|
||||
dns_rbtdb_version_t *rbtversion;
|
||||
dns_name_t *nodename;
|
||||
} dns_glue_additionaldata_ctx_t;
|
||||
|
||||
struct dns_rbtdb_version {
|
||||
/* Not locked */
|
||||
uint32_t serial;
|
||||
|
|
@ -246,7 +102,7 @@ struct dns_rbtdb {
|
|||
isc_rwlock_t tree_lock;
|
||||
/* Locks for individual tree nodes */
|
||||
unsigned int node_lock_count;
|
||||
rbtdb_nodelock_t *node_locks;
|
||||
db_nodelock_t *node_locks;
|
||||
dns_rbtnode_t *origin_node;
|
||||
dns_rbtnode_t *nsec3_origin_node;
|
||||
dns_stats_t *rrsetstats; /* cache DB only */
|
||||
|
|
@ -338,18 +194,10 @@ typedef struct {
|
|||
* Load Context
|
||||
*/
|
||||
typedef struct {
|
||||
dns_rbtdb_t *rbtdb;
|
||||
dns_db_t *db;
|
||||
isc_stdtime_t now;
|
||||
} rbtdb_load_t;
|
||||
|
||||
/*%
|
||||
* Prune context
|
||||
*/
|
||||
typedef struct {
|
||||
dns_db_t *db;
|
||||
dns_rbtnode_t *node;
|
||||
} prune_t;
|
||||
|
||||
extern dns_dbmethods_t dns__rbtdb_zonemethods;
|
||||
extern dns_dbmethods_t dns__rbtdb_cachemethods;
|
||||
|
||||
|
|
@ -575,18 +423,18 @@ dns__rbtdb_setttl(dns_slabheader_t *header, dns_ttl_t newttl);
|
|||
* Functions specific to zone databases that are also called from rbtdb.c.
|
||||
*/
|
||||
void
|
||||
dns__zonedb_resigninsert(dns_rbtdb_t *rbtdb, int idx,
|
||||
dns_slabheader_t *newheader);
|
||||
dns__zonerbt_resigninsert(dns_rbtdb_t *rbtdb, int idx,
|
||||
dns_slabheader_t *newheader);
|
||||
void
|
||||
dns__zonedb_resigndelete(dns_rbtdb_t *rbtdb, dns_rbtdb_version_t *version,
|
||||
dns_slabheader_t *header DNS__DB_FLARG);
|
||||
dns__zonerbt_resigndelete(dns_rbtdb_t *rbtdb, dns_rbtdb_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__zonedb_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock);
|
||||
dns__zonerbt_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
||||
bool lock);
|
||||
/*%<
|
||||
* Add the necessary magic for the wildcard name 'name'
|
||||
* to be found in 'rbtdb'.
|
||||
|
|
@ -603,7 +451,8 @@ dns__zonedb_wildcardmagic(dns_rbtdb_t *rbtdb, const dns_name_t *name,
|
|||
* The tree must be write-locked.
|
||||
*/
|
||||
isc_result_t
|
||||
dns__zonedb_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name, bool lock);
|
||||
dns__zonerbt_addwildcards(dns_rbtdb_t *rbtdb, 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.
|
||||
|
|
@ -613,11 +462,11 @@ dns__zonedb_addwildcards(dns_rbtdb_t *rbtdb, const dns_name_t *name, bool lock);
|
|||
* Cache-specific functions that are called from rbtdb.c
|
||||
*/
|
||||
void
|
||||
dns__cachedb_expireheader(dns_slabheader_t *header,
|
||||
isc_rwlocktype_t *tlocktypep,
|
||||
dns_expire_t reason DNS__DB_FLARG);
|
||||
dns__cacherbt_expireheader(dns_slabheader_t *header,
|
||||
isc_rwlocktype_t *tlocktypep,
|
||||
dns_expire_t reason DNS__DB_FLARG);
|
||||
void
|
||||
dns__cachedb_overmem(dns_rbtdb_t *rbtdb, dns_slabheader_t *newheader,
|
||||
isc_rwlocktype_t *tlocktypep DNS__DB_FLARG);
|
||||
dns__cacherbt_overmem(dns_rbtdb_t *rbtdb, dns_slabheader_t *newheader,
|
||||
isc_rwlocktype_t *tlocktypep DNS__DB_FLARG);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
|
|||
|
|
@ -89,23 +89,6 @@ struct xrdata {
|
|||
#endif /* if DNS_RDATASET_FIXED */
|
||||
};
|
||||
|
||||
struct dns_glue {
|
||||
struct dns_glue *next;
|
||||
dns_fixedname_t fixedname;
|
||||
dns_rdataset_t rdataset_a;
|
||||
dns_rdataset_t sigrdataset_a;
|
||||
dns_rdataset_t rdataset_aaaa;
|
||||
dns_rdataset_t sigrdataset_aaaa;
|
||||
struct cds_wfs_node wfs_node;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
dns_glue_t *glue_list;
|
||||
dns_rbtdb_t *rbtdb;
|
||||
dns_rbtdb_version_t *rbtversion;
|
||||
dns_name_t *nodename;
|
||||
} dns_glue_additionaldata_ctx_t;
|
||||
|
||||
static void
|
||||
rdataset_disassociate(dns_rdataset_t *rdataset DNS__DB_FLARG);
|
||||
static isc_result_t
|
||||
|
|
@ -1160,6 +1143,23 @@ dns_slabheader_destroy(dns_slabheader_t **headerp) {
|
|||
isc_mem_put(mctx, header, size);
|
||||
}
|
||||
|
||||
void
|
||||
dns_slabheader_freeproof(isc_mem_t *mctx, dns_slabheader_proof_t **proof) {
|
||||
if (dns_name_dynamic(&(*proof)->name)) {
|
||||
dns_name_free(&(*proof)->name, mctx);
|
||||
}
|
||||
if ((*proof)->neg != NULL) {
|
||||
isc_mem_put(mctx, (*proof)->neg,
|
||||
dns_rdataslab_size((*proof)->neg, 0));
|
||||
}
|
||||
if ((*proof)->negsig != NULL) {
|
||||
isc_mem_put(mctx, (*proof)->negsig,
|
||||
dns_rdataslab_size((*proof)->negsig, 0));
|
||||
}
|
||||
isc_mem_put(mctx, *proof, sizeof(**proof));
|
||||
*proof = NULL;
|
||||
}
|
||||
|
||||
dns_rdatasetmethods_t dns_rdataslab_rdatasetmethods = {
|
||||
.disassociate = rdataset_disassociate,
|
||||
.first = rdataset_first,
|
||||
|
|
@ -1331,7 +1331,7 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name,
|
|||
dns_rdataset_t *nsecsig DNS__DB_FLARG) {
|
||||
dns_db_t *db = rdataset->slab.db;
|
||||
dns_dbnode_t *node = rdataset->slab.node;
|
||||
const dns_proof_t *noqname = rdataset->slab.noqname;
|
||||
const dns_slabheader_proof_t *noqname = rdataset->slab.noqname;
|
||||
|
||||
/*
|
||||
* Usually, rdataset->slab.raw refers the data following a
|
||||
|
|
@ -1387,7 +1387,7 @@ rdataset_getclosest(dns_rdataset_t *rdataset, dns_name_t *name,
|
|||
dns_rdataset_t *nsecsig DNS__DB_FLARG) {
|
||||
dns_db_t *db = rdataset->slab.db;
|
||||
dns_dbnode_t *node = rdataset->slab.node;
|
||||
const dns_proof_t *closest = rdataset->slab.closest;
|
||||
const dns_slabheader_proof_t *closest = rdataset->slab.closest;
|
||||
|
||||
/*
|
||||
* As mentioned above, rdataset->slab.raw usually refers the data
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ const char *ownercase_vectors[12][2] = {
|
|||
static bool
|
||||
ownercase_test_one(const char *str1, const char *str2) {
|
||||
isc_result_t result;
|
||||
rbtdb_nodelock_t node_locks[1];
|
||||
db_nodelock_t node_locks[1];
|
||||
dns_rbtdb_t rbtdb = {
|
||||
.common.methods = &dns__rbtdb_zonemethods,
|
||||
.common.mctx = mctx,
|
||||
|
|
@ -163,7 +163,7 @@ ISC_RUN_TEST_IMPL(ownercase) {
|
|||
|
||||
ISC_RUN_TEST_IMPL(setownercase) {
|
||||
isc_result_t result;
|
||||
rbtdb_nodelock_t node_locks[1];
|
||||
db_nodelock_t node_locks[1];
|
||||
dns_rbtdb_t rbtdb = {
|
||||
.common.methods = &dns__rbtdb_zonemethods,
|
||||
.common.mctx = mctx,
|
||||
|
|
|
|||
Loading…
Reference in a new issue