rbtdb.c revision 6e8ec359a45b7e991d7bcc97ed8547eac725a506
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/*
* Principal Author: Bob Halley
*/
#include <config.h>
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include <isc/assertions.h>
#include <dns/fixedname.h>
#include <dns/dbiterator.h>
#include <dns/rdataslab.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#ifdef DNS_RBTDB_VERSION64
#include "rbtdb64.h"
#else
#include "rbtdb.h"
#endif
#ifdef DNS_RBTDB_VERSION64
#else
#endif
#ifdef DNS_RBTDB_VERSION64
typedef isc_uint64_t rbtdb_serial_t;
#else
typedef isc_uint32_t rbtdb_serial_t;
#endif
typedef struct rdatasetheader {
/*
* Locked by the owning node's lock.
*/
/*
* We don't use the LIST macros, because the LIST structure has
* both head and tail pointers, and is doubly linked.
*/
struct rdatasetheader *next;
struct rdatasetheader *down;
#define RDATASET_ATTR_NONEXISTENT 0x01
#define RDATASET_ATTR_STALE 0x02
#define RDATASET_ATTR_IGNORE 0x04
typedef struct {
unsigned int references;
typedef struct rbtdb_changed {
typedef struct rbtdb_version {
/* Not locked */
/* Locked by database lock. */
unsigned int references;
typedef struct {
/* Unlocked. */
unsigned int node_lock_count;
/* Locked by lock. */
unsigned int references;
unsigned int attributes;
/* Locked by tree_lock. */
} dns_rbtdb_t;
#define RBTDB_ATTR_LOADED 0x01
/*
* Search Context
*/
typedef struct {
dns_rbtdb_t * rbtdb;
unsigned int options;
/*
* Load Context
*/
typedef struct {
dns_rbtdb_t * rbtdb;
} rbtdb_load_t;
static dns_rdatasetmethods_t rdataset_methods = {
};
static dns_rdatasetitermethods_t rdatasetiter_methods = {
};
typedef struct rbtdb_rdatasetiter {
dns_name_t *name);
dns_name_t *name);
static dns_dbiteratormethods_t dbiterator_methods = {
};
typedef struct rbtdb_dbiterator {
/*
* Locking
*
* If a routine is going to lock more than one lock in this module, then
* the locking must be done in the following order:
*
* Tree Lock
*
* Node Lock (Only one from the set may be locked at one time by
* any caller)
*
* Database Lock
*
* Failure to follow this hierarchy can result in deadlock.
*/
/*
* Deleting Nodes
*
* Currently there is no deletion of nodes from the database, except when
* the database is being destroyed.
*
* If node deletion is added in the future, then for zone databases the node
* for the origin of the zone MUST NOT be deleted.
*/
/*
* DB Routines
*/
static void
rbtdb->references++;
}
static void
unsigned int i;
isc_region_t r;
sizeof (rbtdb_version_t));
for (i = 0; i < rbtdb->node_lock_count; i++)
}
static inline void
unsigned int i;
/* XXX check for open versions here */
/*
* Even though there are no external direct references, there still
* may be nodes in use.
*/
for (i = 0; i < rbtdb->node_lock_count; i++) {
}
if (want_free)
}
static void
rbtdb->references--;
if (rbtdb->references == 0)
if (maybe_free)
}
static void
if (version->references == 0)
version->references++;
}
static inline rbtdb_version_t *
{
return (NULL);
return (version);
}
static dns_result_t
ISC_TRUE);
rbtdb->next_serial++;
}
return (DNS_R_NOMEMORY);
return (DNS_R_SUCCESS);
}
static void
{
rbtversion->references++;
*targetp = rbtversion;
}
static rbtdb_changed_t *
{
/*
* Caller must be holding the node lock.
*/
node->references++;
} else
return (changed);
}
static inline void
unsigned int size;
else
sizeof *rdataset);
}
static inline void
/*
* Caller must hold the node lock.
*/
/*
* We set the IGNORE attribute on rdatasets with serial number
* 'serial'. When the reference count goes to zero, these rdatasets
* will be cleaned up; until that time, they will be ignored.
*/
}
}
}
}
if (make_dirty)
}
static inline void
/*
* Caller must be holding the node lock.
*/
do {
}
/*
* If current is nonexistent or stale, we can clean it up.
*/
if ((current->attributes &
(RDATASET_ATTR_NONEXISTENT|RDATASET_ATTR_STALE)) != 0) {
else
} else
}
}
static inline void
{
/*
* Caller must be holding the node lock.
*/
REQUIRE(least_serial != 0);
/*
* Find the first rdataset less than the least serial, if
* any. On the way down, clean up any instances of multiple
* rdatasets with the same serial number, or that have the
* IGNORE attribute.
*/
break;
} else
}
/*
* If there is a such an rdataset, delete it and any older
* versions.
*/
do {
}
/*
* We've eliminated all IGNORE datasets with the possible
* exception of current, which we now check.
*/
else
/*
* current no longer exists, so we can
* just continue with the loop.
*/
continue;
} else {
/*
* Pull up current->down, making it the new
* current.
*/
else
}
}
/*
* Note. The serial number of 'current' might be less than
* least_serial too, but we cannot delete it because it is
* the most recent version, unless it is a NONEXISTENT
* rdataset or is IGNOREd.
*/
} else {
/*
* If this is a NONEXISTENT rdataset, we can delete it.
*/
!= 0) {
else
} else
}
}
if (!still_dirty)
}
static inline void
if (node->references == 0) {
}
node->references++;
}
static void
{
/*
* Caller must be holding the node lock.
*/
else {
if (least_serial == 0) {
/*
* Caller doesn't know the least serial.
* Get it.
*/
}
}
}
}
static inline void
{
/*
* Caller must be holding the database lock.
*/
}
static inline void
/*
* If the changed record is dirty, then
* an update created multiple versions of
* a given rdataset. We keep this list
* until we're the least open version, at
* which point it's safe to get rid of any
* older versions.
*
* If the changed record isn't dirty, then
* we don't need it anymore since we're
* committing and not rolling back.
*
* The caller must be holding the database lock.
*/
changed = next_changed) {
}
}
}
static void
version->references--;
if (version->references == 0) {
if (commit) {
/*
* We're going to become the least open
* version.
*/
&cleanup_list);
} else {
/*
* Some other open version is the
* least version. We can't cleanup
* records that were changed in this
* version because the older versions
* may still be in use by an open
* version.
*
* We can, however, discard the
* changed records for things that
* we've added that didn't exist in
* prior versions.
*/
&cleanup_list);
}
/*
* If the (soon to be former) current version
* isn't being used by anyone, we can clean
* it up.
*/
/*
* Become the current version.
*/
} else {
/*
* We're rolling back this transaction.
*/
}
} else {
/*
* There are no external or internal references
* to this version and it can be cleaned up.
*/
/*
* Find the version with the least serial
* number greater than ours.
*/
if (least_greater == NULL)
/*
* Is this the least open version?
*/
/*
* Yes. Install the new least open
* version.
*/
&cleanup_list);
} else {
/*
* Add any unexecuted cleanups to
* those of the least greater version.
*/
link);
}
}
}
}
if (cleanup_version != NULL)
sizeof *cleanup_version);
if (!EMPTY(cleanup_list)) {
changed = next_changed) {
rbtnode->references--;
if (rollback)
if (rbtnode->references == 0)
sizeof *changed);
}
}
}
static dns_result_t
{
unsigned int locknum;
if (result == DNS_R_SUCCESS) {
} else {
if (!create) {
if (result == DNS_R_PARTIALMATCH)
return (result);
}
/*
* It would be nice to try to upgrade the lock instead of
* unlocking then relocking.
*/
return (result);
}
/*
* Turning off creation mode ensures that we can 'goto again'
* only once. If we didn't do this and dns_rbt_findnode()
* was always failing, then we could loop forever.
*/
goto again;
}
return (result);
}
static dns_result_t
/* XXX comment */
return (DNS_R_CONTINUE);
/*
* Look for an NS or DNAME rdataset active in our version.
*/
do {
/*
* Is this a "this rdataset doesn't
* exist" record?
*/
if ((header->attributes &
RDATASET_ATTR_NONEXISTENT) != 0)
break;
} else
/*
* If we found a DNAME, then we don't need
* to keep looking for NS records, because the
* DNAME has precedence.
*/
break;
}
}
}
/*
* We increment the reference count on node to ensure that
* search->zonecut_rdataset will still be valid later.
*/
/*
* Finding a DNAME stops all further searching.
*
* Note: We return DNS_R_PARTIALMATCH instead of
* DNS_R_DNAME here because that way zone_find()
* does fewer result code comparisions.
*/
/*
* If the caller does not want to find glue, then
* this is the best answer and the search should
* stop now.
*
* Note: We return DNS_R_PARTIALMATCH instead of
* DNS_R_DELEGATION here because that way zone_find()
* does fewer result code comparisions.
*/
} else {
/*
* The search will continue beneath the zone cut.
* This may or may not be the best match. In case it
* is, we need to remember the node name.
*/
NULL) ==
}
}
return (result);
}
static inline void
{
unsigned char *raw;
unsigned int count;
/*
* Caller must be holding the node lock.
*/
raw += 2;
if (count == 0) {
} else {
/*
* The private4 field is the number of rdata beyond
* the cursor position, so we decrement the total
* count by one before storing it.
*/
count--;
}
}
static inline dns_result_t
{
/*
* The caller MUST NOT be holding any node locks.
*/
/*
* If we have to set foundname, we do it before anything else.
* If we were to set foundname after we had set nodep or bound the
* rdataset, then we'd have to undo that work if dns_name_concatenate()
* failed. By setting foundname first, there's nothing to undo if
* we have trouble.
*/
if (result != DNS_R_SUCCESS)
return (result);
}
/*
* Note that we don't have to increment the node's reference
* count here because we're going to use the reference we
* already have in the search block.
*/
}
}
if (type == dns_rdatatype_dname)
return (DNS_R_DNAME);
return (DNS_R_DELEGATION);
}
static inline isc_boolean_t
{
unsigned char *raw;
/*
* No additional locking is required.
*/
/*
* Valid glue types are A, AAAA, A6. NS is also a valid glue type
* if it occurs at a zone cut, but is not valid below it.
*/
if (type == dns_rdatatype_ns) {
return (ISC_FALSE);
}
} else if (type != dns_rdatatype_a &&
type != dns_rdatatype_aaaa &&
type != dns_rdatatype_a6) {
return (ISC_FALSE);
}
raw += 2;
while (count > 0) {
count--;
raw += 2;
/*
* XXX Until we have rdata structures, we have no choice but
* to directly access the rdata format.
*/
break;
}
}
return (valid);
}
static dns_result_t
{
/*
* We don't care about 'now'. We set it to zero so compilers won't
* complain about it being unused.
*/
now = 0;
/*
* If the caller didn't supply a version, attach to the current
* version.
*/
}
/*
* XXXDNSSEC Set secure_zone properly when implementing DNSSEC.
*/
/*
* Search down from the root of the tree. If, while going down, we
* encounter a callback node, zone_zonecut_callback() will search the
* rdatasets at the zone cut for active DNAME or NS rdatasets.
*/
if (result == DNS_R_PARTIALMATCH) {
rdataset);
goto tree_exit;
} else {
/*
* XXX We need to add wildcard support as another
* 'else' clause.
*/
if (secure_zone)
goto tree_exit;
}
} else if (result != DNS_R_SUCCESS)
goto tree_exit;
/*
* We have found a node whose name is the desired name.
*/
/*
* If we're beneath a zone cut, we don't want to look for
* CNAMEs because they're not legitimate zone glue.
*/
} else {
/*
* The node may be a zone cut itself. If it might be one,
* make sure we check for it later.
*/
}
/*
* Certain DNSSEC types are not subject to CNAME matching
* (RFC 2535, section 2.3.5).
*
* We don't check for SIG, because we don't store SIG records
* directly.
*
* XXX This should be a general purpose subroutine in the rdata
* module.
*
* XXX This 'if' could be an 'else if' of the 'if' above.
*/
/*
* We now go looking for rdata...
*/
/*
* Look for an active, extant rdataset.
*/
do {
/*
* Is this a "this rdataset doesn't
* exist" record?
*/
if ((header->attributes &
RDATASET_ATTR_NONEXISTENT) != 0)
break;
} else
/*
* We now know that there is at least one active
* rdataset at this node.
*/
/*
* Do special zone cut handling, if requested.
*/
if (maybe_zonecut &&
/*
* We increment the reference count on node to
* ensure that search->zonecut_rdataset will
* still be valid later.
*/
&& type != dns_rdatatype_nxt
&& type != dns_rdatatype_key
&& type != dns_rdatatype_any) {
/*
* Glue is not OK, but any answer we
* could return would be glue. Return
* the delegation.
*/
break;
}
break;
}
/*
* If we found a type we were looking for, we're done.
*/
type == dns_rdatatype_any ||
(cname_ok &&
if (!maybe_zonecut)
break;
/*
* Remember a NXT rdataset even if we're
* not specifically looking for it, because
* we might need it later.
*/
}
}
}
if (empty_node) {
/*
* We have an exact match for the name, but there are no
* active rdatasets the desired version. That means that
* this node doesn't exist in the desired version, and that
* we really have a partial match.
*/
goto partial_match;
}
/*
* If we didn't find what we were looking for...
*/
if (must_succeed) {
/*
* We were looking for a type which must be in the
* database, but isn't for some reason.
*/
/*
* We were trying to find glue at a node beneath a
* zone cut, but didn't, so we return the delegation.
*/
rdataset);
goto tree_exit;
} else {
/*
* The desired type doesn't exist.
*/
/*
* The zone is secure but there's no NXT
* rdataset!
*/
}
}
goto node_exit;
}
/*
* We found what we were looking for, or we found a CNAME.
*/
type != dns_rdatatype_any &&
/*
* We weren't doing an ANY query and we found a CNAME instead
* of the type we were looking for, so we need to indicate
* that result to the caller.
*/
/*
* If we're beneath a zone cut, we must indicate that the
* result is glue, unless we're actually at the zone cut
* and the type is NXT or KEY.
*/
if (type == dns_rdatatype_nxt ||
else if (type == dns_rdatatype_any)
else
result = DNS_R_GLUE;
} else
result = DNS_R_GLUE;
/*
* We might have found data that isn't glue, but was occluded
* by a dynamic update. If the caller cares about this, they
* will have told us to validate glue.
*
* XXX We should cache the glue validity state!
*/
if (result == DNS_R_GLUE &&
rdataset);
goto tree_exit;
}
} else {
/*
* An ordinary successful query!
*/
}
if (!at_zonecut)
else
}
/*
* If we found a zonecut but aren't going to use it, we have to
* let go of it.
*/
if (search.need_cleanup) {
node->references--;
if (node->references == 0)
}
if (close_version)
return (result);
}
static dns_result_t
/* XXX comment */
/*
* Keep compiler silent.
*/
(void)name;
/*
* Look for DNAME rdataset.
*/
header_prev = NULL;
/*
* This rdataset is stale. If no one else is
* using the node, we can clean it up right
* now, otherwise we mark it as stale, and
* the node as dirty, so it will get cleaned
* up later.
*/
if (node->references == 0) {
if (header_prev != NULL)
header_prev->next =
else
header);
} else {
header->attributes |=
}
0)
break;
else
}
/*
* We increment the reference count on node to ensure that
* search->zonecut_rdataset will still be valid later.
*/
} else
return (result);
}
static inline dns_result_t
{
unsigned int i;
/*
* Caller must be holding the tree lock.
*/
while (i > 0) {
i--;
/*
* Look for NS rdataset.
*/
header_prev = NULL;
header = header_next) {
/*
* This rdataset is stale. If no one else is
* using the node, we can clean it up right
* now, otherwise we mark it as stale, and
* the node as dirty, so it will get cleaned
* up later.
*/
if (node->references == 0) {
if (header_prev != NULL)
header_prev->next =
else
header);
} else {
header->attributes |=
}
(header->attributes &
RDATASET_ATTR_NONEXISTENT) == 0)
break;
else
}
/*
* If we have to set foundname, we do it before
* anything else. If we were to set foundname after
* we had set nodep or bound the rdataset, then we'd
* have to undo that work if dns_name_concatenate()
* failed. By setting foundname first, there's
* nothing to undo if we have trouble.
*/
while (result == DNS_R_SUCCESS && i != 0) {
i--;
&name);
result =
&name,
NULL);
}
if (result != DNS_R_SUCCESS) {
goto node_exit;
}
}
}
}
break;
}
return (result);
}
static dns_result_t
{
/*
* XXXRTH Currently this code has no support for negative caching.
*/
/*
* We don't need to call UNEXPECTED_ERROR() because
* isc_stdtime_get() will already have done so.
*/
return (DNS_R_UNEXPECTED);
}
/*
* Search down from the root of the tree. If, while going down, we
* encounter a callback node, cache_zonecut_callback() will search the
* rdatasets at the zone cut for a DNAME rdataset.
*/
if (result == DNS_R_PARTIALMATCH) {
rdataset);
goto tree_exit;
} else {
goto tree_exit;
}
} else if (result != DNS_R_SUCCESS)
goto tree_exit;
/*
* Certain DNSSEC types are not subject to CNAME matching
* (RFC 2535, section 2.3.5).
*
* XXX This should be a general purpose subroutine in the rdata
* module.
*
* XXX This 'if' could be an 'else if' of the 'if' above.
*/
if (type == dns_rdatatype_key ||
type == dns_rdatatype_sig ||
/*
* We now go looking for rdata...
*/
header_prev = NULL;
/*
* This rdataset is stale. If no one else is using the
* node, we can clean it up right now, otherwise we
* mark it as stale, and the node as dirty, so it will
* get cleaned up later.
*/
if (node->references == 0) {
if (header_prev != NULL)
else
header);
} else {
}
== 0) {
/*
* We now know that there is at least one active
* non-stale rdataset at this node.
*/
/*
* If we found a type we were looking for, we're done.
*/
type == dns_rdatatype_any ||
/*
* Remember a NS rdataset even if we're
* not specifically looking for it, because
* we might need it later.
*/
/*
* Remember a NXT rdataset even if we're
* not specifically looking for it, because
* we might need it later.
*/
}
} else
}
if (empty_node) {
/*
* We have an exact match for the name, but there are no
* extant rdatasets. That means that this node doesn't
* meaningfully exist, and that we really have a partial match.
*/
goto find_ns;
}
/*
* If we didn't find what we were looking for...
*/
/*
* XXXDNSSEC If we found an NXT record for this name, we
* can tell whether the desired type exists or not. We don't
* yet try to use the NXT that way, but this is the place to
* do it.
*/
/*
* If there is an NS rdataset at this node, then this is the
* deepest zone cut.
*/
rdataset);
goto node_exit;
}
/*
* Go find the deepest zone cut.
*/
goto find_ns;
}
/*
* We found what we were looking for, or we found a CNAME.
*/
}
type != dns_rdatatype_any &&
/*
* We weren't doing an ANY query and we found a CNAME instead
* of the type we were looking for, so we need to indicate
* that result to the caller.
*/
} else {
/*
* An ordinary successful query!
*/
}
rdataset);
return (result);
}
static void
node->references++;
}
static void
node->references--;
if (node->references == 0)
}
static dns_result_t
/*
* We don't need to call UNEXPECTED_ERROR() because
* isc_stdtime_get() will already have done so.
*/
return (DNS_R_UNEXPECTED);
}
/*
* We don't check if rbtnode->references == 0 and try
* to free like we do in cache_find(), because
* rbtnode->references must be non-zero. This is so
* because 'node' is an argument to the function.
*/
}
}
return (DNS_R_SUCCESS);
}
static void
do {
if (!first)
"\tserial = %lu, ttl = %u, attributes = %u\n",
}
} else
}
static dns_result_t
{
return (DNS_R_NOMEMORY);
return (DNS_R_SUCCESS);
}
static dns_result_t
{
if (rbtversion == NULL) {
}
do {
/*
* Is this a "this rdataset doesn't
* exist" record?
*/
if ((header->attributes &
RDATASET_ATTR_NONEXISTENT) != 0)
break;
} else
break;
}
}
if (close_version)
return (DNS_R_NOTFOUND);
return (DNS_R_SUCCESS);
}
static dns_result_t
{
/*
* We don't need to call UNEXPECTED_ERROR() because
* isc_stdtime_get() will already have done so.
*/
return (DNS_R_UNEXPECTED);
}
/*
* We don't check if rbtnode->references == 0 and try
* to free like we do in cache_find(), because
* rbtnode->references must be non-zero. This is so
* because 'node' is an argument to the function.
*/
0) {
}
}
return (DNS_R_NOTFOUND);
return (DNS_R_SUCCESS);
}
static dns_result_t
{
return (DNS_R_NOMEMORY);
now = 0;
if (rbtversion == NULL)
else {
rbtversion->references++;
}
} else {
/*
* We don't need to call UNEXPECTED_ERROR() because
* isc_stdtime_get() will already have done so.
*/
sizeof *iterator);
return (DNS_R_UNEXPECTED);
}
rbtversion = NULL;
}
rbtnode->references++;
return (DNS_R_SUCCESS);
}
static dns_result_t
{
unsigned char *merged;
/*
* Add an rdatasetheader_t to a node.
*/
/*
* Caller must be holding the node lock.
*/
return (DNS_R_NOMEMORY);
}
header_prev = NULL;
break;
}
/*
* Don't merge if a nonexistent rdataset is involved.
*/
if (merge &&
/*
* If 'merge' is ISC_TRUE, we'll try to create a new rdataset
* that is the union of 'newheader' and 'header'.
*/
if (merge) {
(unsigned char *)header,
(unsigned char *)newheader,
(unsigned int)(sizeof *newheader),
&merged);
if (result == DNS_R_SUCCESS) {
/*
* If 'header' has the same serial number as
* we do, we could clean it up now if we knew
* that our caller had no references to it.
* We don't know this, however, so we leave it
* alone. It will get cleaned up when
* clean_zone_node() runs.
*/
} else {
if (result == DNS_R_UNCHANGED) {
if (addedrdataset != NULL)
return (DNS_R_SUCCESS);
}
return (result);
}
}
if (header_prev != NULL)
else
if (loading) {
/*
* There are no other references to 'header' when
* loading, so we MAY clean up 'header' now.
* Since we don't generate changed records when
* loading, we MUST clean up 'header' now.
*/
} else {
}
} else {
/*
* The rdataset type doesn't exist at this node.
*/
}
if (addedrdataset != NULL)
return (DNS_R_SUCCESS);
}
static inline isc_boolean_t
{
return (ISC_TRUE);
else if (type == dns_rdatatype_dname ||
return (ISC_TRUE);
return (ISC_FALSE);
}
static dns_result_t
{
if (rbtversion == NULL) {
return (DNS_R_UNEXPECTED);
} else
now = 0;
®ion,
sizeof (rdatasetheader_t));
if (result != DNS_R_SUCCESS)
return (result);
newheader->attributes = 0;
if (rbtversion != NULL) {
now = 0;
} else {
}
/*
* If we're adding a delegation type (e.g. NS or DNAME for a zone,
* just DNAME for the cache), then we need to set the callback bit
* on the node, and to do that we must be holding an exclusive lock
* on the tree.
*/
} else
addedrdataset, now);
if (delegating)
return (result);
}
static dns_result_t
{
if (type == dns_rdatatype_any)
return (DNS_R_NOTIMPLEMENTED);
return (DNS_R_NOMEMORY);
if (rbtversion != NULL)
else
return (result);
}
static dns_result_t
{
/*
* This routine does no node locking. See comments in
* 'load' below for more information on loading and
* locking.
*/
return (result);
if (result != DNS_R_EXISTS) {
}
®ion,
sizeof (rdatasetheader_t));
if (result != DNS_R_SUCCESS)
return (result);
newheader->attributes = 0;
if (result == DNS_R_SUCCESS &&
return (result);
}
static dns_result_t
/*
* XXXRTH This is not quite right. We should probably
* use the last file modification time or perhaps the value
* of an new master file option (e.g. $TIME) as the 'now'
* time.
*/
return (DNS_R_UNEXPECTED);
} else
/*
* We set RBTDB_ATTR_LOADED even though we don't know the
* load is going to succeed because we don't want someone to try
* again with partial prior load results if a load fails.
*/
/*
* In order to set the node callback bit correctly in zone databases,
* we need to know if the node has the origin name of the zone.
* In add_rdataset_callback(), we could simply compare the new name
* to the origin name, but this is expensive. Also, we don't know the
* node name in addrdataset(), so we need another way of knowing the
* zone's top.
*
* We now explicitly create a node for the zone's origin, and then
* we simply remember the node's address. This is safe, because
* the top-of-zone node can never be deleted, nor can its address
* change.
*/
&rbtdb->origin_node);
if (result != DNS_R_SUCCESS) {
return (result);
}
}
}
static void
}
}
static dns_dbmethods_t zone_methods = {
load,
};
static dns_dbmethods_t cache_methods = {
load,
};
#ifdef DNS_RBTDB_VERSION64
#else
#endif
{
int i;
/* Keep the compiler happy. */
(void)argc;
(void)argv;
return (DNS_R_NOMEMORY);
if (cache) {
} else
if (iresult != ISC_R_SUCCESS) {
"isc_mutex_init() failed: %s",
return (DNS_R_UNEXPECTED);
}
if (iresult != ISC_R_SUCCESS) {
"isc_rwlock_init() failed: %s",
return (DNS_R_UNEXPECTED);
}
if (rbtdb->node_lock_count == 0)
sizeof (rbtdb_nodelock_t));
for (i = 0; i < (int)(rbtdb->node_lock_count); i++) {
if (iresult != ISC_R_SUCCESS) {
i--;
while (i >= 0) {
i--;
}
sizeof (rbtdb_nodelock_t));
"isc_mutex_init() failed: %s",
return (DNS_R_UNEXPECTED);
}
}
/*
* Make a copy of the origin name.
*/
return (DNS_R_NOMEMORY);
}
/*
* Make the Red-Black Tree.
*/
if (dresult != DNS_R_SUCCESS) {
return (dresult);
}
rbtdb->attributes = 0;
/*
* Version Initialization.
*/
return (DNS_R_NOMEMORY);
}
return (ISC_R_SUCCESS);
}
/*
* Slabbed Rdataset Methods
*/
static dns_result_t
return (DNS_R_SUCCESS);
}
static dns_result_t
unsigned int count;
if (count == 0) {
return (DNS_R_NOMORE);
}
raw += 2;
/*
* The private4 field is the number of rdata beyond the cursor
* position, so we decrement the total count by one before storing
* it.
*/
count--;
return (DNS_R_SUCCESS);
}
static dns_result_t
unsigned int count;
unsigned int length;
unsigned char *raw;
if (count == 0)
return (DNS_R_NOMORE);
count--;
return (DNS_R_SUCCESS);
}
static void
isc_region_t r;
raw += 2;
}
/*
* Rdataset Iterator Methods
*/
static void
sizeof *rbtiterator);
}
static dns_result_t
now = 0;
} else {
serial = 1;
}
do {
/*
* Is this a "this rdataset doesn't
* exist" record?
*/
if ((header->attributes &
RDATASET_ATTR_NONEXISTENT) != 0 ||
break;
} else
break;
}
return (DNS_R_NOMORE);
return (DNS_R_SUCCESS);
}
static dns_result_t
return (DNS_R_NOMORE);
now = 0;
} else {
serial = 1;
}
do {
/*
* Is this a "this rdataset doesn't
* exist" record?
*/
if ((header->attributes &
RDATASET_ATTR_NONEXISTENT) != 0 ||
break;
} else
break;
}
}
return (DNS_R_NOMORE);
return (DNS_R_SUCCESS);
}
static void
rdataset);
}
/*
* Database Iterator Methods
*/
static inline void
node->references--;
if (node->references == 0)
}
}
static inline void
}
static void
if (rbtdbiter->tree_locked)
}
static dns_result_t
if (!rbtdbiter->tree_locked) {
}
origin);
if (result != DNS_R_NEWORIGIN) {
} else {
if (result == DNS_R_SUCCESS)
else {
}
}
return (result);
}
static dns_result_t
if (result == DNS_R_NEWORIGIN)
else
if (result != DNS_R_SUCCESS) {
}
} else
return (result);
}
static inline isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
}
static dns_result_t
{
if (result != DNS_R_SUCCESS)
return (result);
} else
return (result);
}
static dns_result_t
return (DNS_R_SUCCESS);
}
static dns_result_t
}