2005-09-06 03:51:37 +00:00
|
|
|
/*
|
2018-03-15 18:32:45 -07:00
|
|
|
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2005-09-06 03:51:37 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* 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
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2005-09-06 03:51:37 +00:00
|
|
|
*/
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
|
|
|
|
*
|
|
|
|
* 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 STICHTING NLNET
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* STICHTING NLNET 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.
|
|
|
|
*
|
|
|
|
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
|
|
|
|
* conceived and contributed by Rob Butler.
|
|
|
|
*
|
|
|
|
* 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 ROB BUTLER
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* ROB BUTLER 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file */
|
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2005-09-05 00:12:29 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <isc/buffer.h>
|
|
|
|
#include <isc/lex.h>
|
|
|
|
#include <isc/log.h>
|
|
|
|
#include <isc/magic.h>
|
|
|
|
#include <isc/mem.h>
|
|
|
|
#include <isc/once.h>
|
|
|
|
#include <isc/print.h>
|
|
|
|
#include <isc/region.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <isc/rwlock.h>
|
|
|
|
#include <isc/string.h>
|
|
|
|
#include <isc/util.h>
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
#include <dns/callbacks.h>
|
|
|
|
#include <dns/db.h>
|
|
|
|
#include <dns/dbiterator.h>
|
|
|
|
#include <dns/dlz.h>
|
|
|
|
#include <dns/fixedname.h>
|
|
|
|
#include <dns/log.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <dns/master.h>
|
2005-09-05 00:12:29 +00:00
|
|
|
#include <dns/rdata.h>
|
|
|
|
#include <dns/rdatalist.h>
|
|
|
|
#include <dns/rdataset.h>
|
|
|
|
#include <dns/rdatasetiter.h>
|
|
|
|
#include <dns/rdatatype.h>
|
|
|
|
#include <dns/result.h>
|
|
|
|
#include <dns/sdlz.h>
|
|
|
|
#include <dns/types.h>
|
|
|
|
|
|
|
|
#include "rdatalist_p.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private Types
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dns_sdlzimplementation {
|
2020-02-12 13:59:18 +01:00
|
|
|
const dns_sdlzmethods_t *methods;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_mem_t *mctx;
|
|
|
|
void *driverarg;
|
|
|
|
unsigned int flags;
|
|
|
|
isc_mutex_t driverlock;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_dlzimplementation_t *dlz_imp;
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dns_sdlz_db {
|
|
|
|
/* Unlocked */
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_db_t common;
|
|
|
|
void *dbdata;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlzimplementation_t *dlzimp;
|
2019-05-20 16:54:13 +02:00
|
|
|
|
|
|
|
/* Atomic */
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_refcount_t references;
|
2019-05-20 16:54:13 +02:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
/* Locked */
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_dbversion_t *future_version;
|
2020-02-13 14:44:37 -08:00
|
|
|
int dummy_version;
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dns_sdlzlookup {
|
|
|
|
/* Unlocked */
|
2020-02-13 14:44:37 -08:00
|
|
|
unsigned int magic;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlz_db_t *sdlz;
|
|
|
|
ISC_LIST(dns_rdatalist_t) lists;
|
|
|
|
ISC_LIST(isc_buffer_t) buffers;
|
|
|
|
dns_name_t *name;
|
|
|
|
ISC_LINK(dns_sdlzlookup_t) link;
|
|
|
|
dns_rdatacallbacks_t callbacks;
|
2019-05-20 16:54:13 +02:00
|
|
|
|
|
|
|
/* Atomic */
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_refcount_t references;
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct dns_sdlzlookup dns_sdlznode_t;
|
|
|
|
|
|
|
|
struct dns_sdlzallnodes {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_dbiterator_t common;
|
|
|
|
ISC_LIST(dns_sdlznode_t) nodelist;
|
|
|
|
dns_sdlznode_t *current;
|
|
|
|
dns_sdlznode_t *origin;
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef dns_sdlzallnodes_t sdlz_dbiterator_t;
|
|
|
|
|
|
|
|
typedef struct sdlz_rdatasetiter {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdatasetiter_t common;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdatalist_t *current;
|
2005-09-05 00:12:29 +00:00
|
|
|
} sdlz_rdatasetiter_t;
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define SDLZDB_MAGIC ISC_MAGIC('D', 'L', 'Z', 'S')
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that "impmagic" is not the first four bytes of the struct, so
|
|
|
|
* ISC_MAGIC_VALID cannot be used.
|
|
|
|
*/
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define VALID_SDLZDB(sdlzdb) \
|
|
|
|
((sdlzdb) != NULL && (sdlzdb)->common.impmagic == SDLZDB_MAGIC)
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
#define SDLZLOOKUP_MAGIC ISC_MAGIC('D', 'L', 'Z', 'L')
|
2020-02-12 13:59:18 +01:00
|
|
|
#define VALID_SDLZLOOKUP(sdlzl) ISC_MAGIC_VALID(sdlzl, SDLZLOOKUP_MAGIC)
|
2020-02-13 14:44:37 -08:00
|
|
|
#define VALID_SDLZNODE(sdlzn) VALID_SDLZLOOKUP(sdlzn)
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* These values are taken from RFC 1537 */
|
2020-02-13 14:44:37 -08:00
|
|
|
#define SDLZ_DEFAULT_REFRESH 28800U /* 8 hours */
|
|
|
|
#define SDLZ_DEFAULT_RETRY 7200U /* 2 hours */
|
|
|
|
#define SDLZ_DEFAULT_EXPIRE 604800U /* 7 days */
|
|
|
|
#define SDLZ_DEFAULT_MINIMUM 86400U /* 1 day */
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* This is a reasonable value */
|
2020-02-12 13:59:18 +01:00
|
|
|
#define SDLZ_DEFAULT_TTL (60 * 60 * 24)
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2007-08-27 03:32:27 +00:00
|
|
|
#ifdef __COVERITY__
|
2020-02-13 14:44:37 -08:00
|
|
|
#define MAYBE_LOCK(imp) LOCK(&imp->driverlock)
|
2007-08-27 03:32:27 +00:00
|
|
|
#define MAYBE_UNLOCK(imp) UNLOCK(&imp->driverlock)
|
2020-02-13 21:48:23 +01:00
|
|
|
#else /* ifdef __COVERITY__ */
|
2020-02-12 13:59:18 +01:00
|
|
|
#define MAYBE_LOCK(imp) \
|
|
|
|
do { \
|
|
|
|
unsigned int flags = imp->flags; \
|
2005-09-05 00:12:29 +00:00
|
|
|
if ((flags & DNS_SDLZFLAG_THREADSAFE) == 0) \
|
2020-02-12 13:59:18 +01:00
|
|
|
LOCK(&imp->driverlock); \
|
2005-09-05 00:12:29 +00:00
|
|
|
} while (0)
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define MAYBE_UNLOCK(imp) \
|
|
|
|
do { \
|
|
|
|
unsigned int flags = imp->flags; \
|
2005-09-05 00:12:29 +00:00
|
|
|
if ((flags & DNS_SDLZFLAG_THREADSAFE) == 0) \
|
2020-02-12 13:59:18 +01:00
|
|
|
UNLOCK(&imp->driverlock); \
|
2005-09-05 00:12:29 +00:00
|
|
|
} while (0)
|
2020-02-13 21:48:23 +01:00
|
|
|
#endif /* ifdef __COVERITY__ */
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
2014-06-10 16:25:26 -07:00
|
|
|
* Forward references.
|
2005-09-05 00:12:29 +00:00
|
|
|
*/
|
2020-02-14 08:14:03 +01:00
|
|
|
static isc_result_t
|
|
|
|
getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
|
|
|
|
unsigned int options, dns_clientinfomethods_t *methods,
|
|
|
|
dns_clientinfo_t *clientinfo, dns_dbnode_t **nodep);
|
|
|
|
|
|
|
|
static void
|
|
|
|
list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node,
|
|
|
|
dns_rdataset_t *rdataset);
|
|
|
|
|
|
|
|
static void
|
|
|
|
detachnode(dns_db_t *db, dns_dbnode_t **targetp);
|
|
|
|
|
|
|
|
static void
|
|
|
|
dbiterator_destroy(dns_dbiterator_t **iteratorp);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_first(dns_dbiterator_t *iterator);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_last(dns_dbiterator_t *iterator);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_seek(dns_dbiterator_t *iterator, const dns_name_t *name);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_prev(dns_dbiterator_t *iterator);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_next(dns_dbiterator_t *iterator);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
|
|
|
|
dns_name_t *name);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_pause(dns_dbiterator_t *iterator);
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
static dns_dbiteratormethods_t dbiterator_methods = {
|
2020-02-12 13:59:18 +01:00
|
|
|
dbiterator_destroy, dbiterator_first, dbiterator_last,
|
|
|
|
dbiterator_seek, dbiterator_prev, dbiterator_next,
|
|
|
|
dbiterator_current, dbiterator_pause, dbiterator_origin
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Utility functions
|
|
|
|
*/
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
/*
|
|
|
|
* Log a message at the given level
|
|
|
|
*/
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
sdlz_log(int level, const char *fmt, ...) {
|
2010-12-18 01:56:23 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
|
|
|
|
ISC_LOG_DEBUG(level), fmt, ap);
|
2010-12-18 01:56:23 +00:00
|
|
|
va_end(ap);
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
/*% Converts the input string to lowercase, in place. */
|
2005-09-05 00:12:29 +00:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlz_tolower(char *str) {
|
2005-09-05 00:12:29 +00:00
|
|
|
unsigned int len = strlen(str);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (str[i] >= 'A' && str[i] <= 'Z') {
|
2005-09-05 00:12:29 +00:00
|
|
|
str[i] += 32;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int
|
2020-02-13 14:44:37 -08:00
|
|
|
initial_size(const char *data) {
|
2005-09-05 00:12:29 +00:00
|
|
|
unsigned int len = (strlen(data) / 64) + 1;
|
|
|
|
return (len * 64 + 64);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rdataset Iterator Methods. These methods were "borrowed" from the SDB
|
|
|
|
* driver interface. See the SDB driver interface documentation for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp) {
|
2020-02-12 13:59:18 +01:00
|
|
|
sdlz_rdatasetiter_t *sdlziterator = (sdlz_rdatasetiter_t *)(*iteratorp);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
detachnode(sdlziterator->common.db, &sdlziterator->common.node);
|
|
|
|
isc_mem_put(sdlziterator->common.db->mctx, sdlziterator,
|
|
|
|
sizeof(sdlz_rdatasetiter_t));
|
|
|
|
*iteratorp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
rdatasetiter_first(dns_rdatasetiter_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_rdatasetiter_t *sdlziterator = (sdlz_rdatasetiter_t *)iterator;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)iterator->node;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (ISC_LIST_EMPTY(sdlznode->lists)) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlziterator->current = ISC_LIST_HEAD(sdlznode->lists);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
rdatasetiter_next(dns_rdatasetiter_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_rdatasetiter_t *sdlziterator = (sdlz_rdatasetiter_t *)iterator;
|
|
|
|
|
|
|
|
sdlziterator->current = ISC_LIST_NEXT(sdlziterator->current, link);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlziterator->current == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
rdatasetiter_current(dns_rdatasetiter_t *iterator, dns_rdataset_t *rdataset) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_rdatasetiter_t *sdlziterator = (sdlz_rdatasetiter_t *)iterator;
|
|
|
|
|
|
|
|
list_tordataset(sdlziterator->current, iterator->db, iterator->node,
|
|
|
|
rdataset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static dns_rdatasetitermethods_t rdatasetiter_methods = {
|
2020-02-12 13:59:18 +01:00
|
|
|
rdatasetiter_destroy, rdatasetiter_first, rdatasetiter_next,
|
2005-09-05 00:12:29 +00:00
|
|
|
rdatasetiter_current
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DB routines. These methods were "borrowed" from the SDB driver interface.
|
|
|
|
* See the SDB driver interface documentation for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
attach(dns_db_t *source, dns_db_t **targetp) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)source;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2019-05-20 16:54:13 +02:00
|
|
|
isc_refcount_increment(&sdlz->references);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
*targetp = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
destroy(dns_sdlz_db_t *sdlz) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz->common.magic = 0;
|
|
|
|
sdlz->common.impmagic = 0;
|
|
|
|
|
2019-05-20 16:54:13 +02:00
|
|
|
dns_name_free(&sdlz->common.origin, sdlz->common.mctx);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2019-05-20 16:54:13 +02:00
|
|
|
isc_refcount_destroy(&sdlz->references);
|
|
|
|
isc_mem_putanddetach(&sdlz->common.mctx, sdlz, sizeof(dns_sdlz_db_t));
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
detach(dns_db_t **dbp) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)(*dbp);
|
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
|
|
|
*dbp = NULL;
|
2019-05-20 16:54:13 +02:00
|
|
|
|
|
|
|
if (isc_refcount_decrement(&sdlz->references) == 1) {
|
|
|
|
destroy(sdlz);
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
2012-06-20 14:13:12 -05:00
|
|
|
UNUSED(callbacks);
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
2012-06-20 14:13:12 -05:00
|
|
|
UNUSED(callbacks);
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dump(dns_db_t *db, dns_dbversion_t *version, const char *filename,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_masterformat_t masterformat) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(version);
|
|
|
|
UNUSED(filename);
|
|
|
|
UNUSED(masterformat);
|
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
currentversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
2005-09-05 00:12:29 +00:00
|
|
|
REQUIRE(versionp != NULL && *versionp == NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
*versionp = (void *)&sdlz->dummy_version;
|
2005-09-05 00:12:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
newversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2020-02-13 14:44:37 -08:00
|
|
|
char origin[DNS_NAME_MAXTEXT + 1];
|
|
|
|
isc_result_t result;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlz->dlzimp->methods->newversion == NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
dns_name_format(&sdlz->common.origin, origin, sizeof(origin));
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = sdlz->dlzimp->methods->newversion(
|
|
|
|
origin, sdlz->dlzimp->driverarg, sdlz->dbdata, versionp);
|
2010-12-18 01:56:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
sdlz_log(ISC_LOG_ERROR,
|
2020-02-12 13:59:18 +01:00
|
|
|
"sdlz newversion on origin %s failed : %s", origin,
|
|
|
|
isc_result_totext(result));
|
2010-12-18 01:56:23 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
sdlz->future_version = *versionp;
|
|
|
|
return (ISC_R_SUCCESS);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
attachversion(dns_db_t *db, dns_dbversion_t *source,
|
|
|
|
dns_dbversion_t **targetp) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
REQUIRE(source != NULL && source == (void *)&sdlz->dummy_version);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
*targetp = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
closeversion(dns_db_t *db, dns_dbversion_t **versionp, bool commit) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2020-02-13 14:44:37 -08:00
|
|
|
char origin[DNS_NAME_MAXTEXT + 1];
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
REQUIRE(versionp != NULL);
|
|
|
|
|
|
|
|
if (*versionp == (void *)&sdlz->dummy_version) {
|
|
|
|
*versionp = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
REQUIRE(*versionp == sdlz->future_version);
|
|
|
|
REQUIRE(sdlz->dlzimp->methods->closeversion != NULL);
|
|
|
|
|
|
|
|
dns_name_format(&sdlz->common.origin, origin, sizeof(origin));
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz->dlzimp->methods->closeversion(origin, commit,
|
|
|
|
sdlz->dlzimp->driverarg,
|
|
|
|
sdlz->dbdata, versionp);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (*versionp != NULL) {
|
2020-02-12 13:59:18 +01:00
|
|
|
sdlz_log(ISC_LOG_ERROR, "sdlz closeversion on origin %s failed",
|
|
|
|
origin);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
sdlz->future_version = NULL;
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
createnode(dns_sdlz_db_t *sdlz, dns_sdlznode_t **nodep) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlznode_t *node;
|
|
|
|
|
|
|
|
node = isc_mem_get(sdlz->common.mctx, sizeof(dns_sdlznode_t));
|
|
|
|
|
|
|
|
node->sdlz = NULL;
|
|
|
|
attach((dns_db_t *)sdlz, (dns_db_t **)&node->sdlz);
|
|
|
|
ISC_LIST_INIT(node->lists);
|
|
|
|
ISC_LIST_INIT(node->buffers);
|
|
|
|
ISC_LINK_INIT(node, link);
|
|
|
|
node->name = NULL;
|
|
|
|
dns_rdatacallbacks_init(&node->callbacks);
|
2019-05-20 16:54:13 +02:00
|
|
|
|
|
|
|
isc_refcount_init(&node->references, 1);
|
2005-09-05 00:12:29 +00:00
|
|
|
node->magic = SDLZLOOKUP_MAGIC;
|
|
|
|
|
|
|
|
*nodep = node;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
destroynode(dns_sdlznode_t *node) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_rdatalist_t *list;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdata_t *rdata;
|
|
|
|
isc_buffer_t *b;
|
|
|
|
dns_sdlz_db_t *sdlz;
|
|
|
|
dns_db_t *db;
|
|
|
|
isc_mem_t *mctx;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2019-07-23 08:27:30 -04:00
|
|
|
isc_refcount_destroy(&node->references);
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz = node->sdlz;
|
|
|
|
mctx = sdlz->common.mctx;
|
|
|
|
|
|
|
|
while (!ISC_LIST_EMPTY(node->lists)) {
|
|
|
|
list = ISC_LIST_HEAD(node->lists);
|
|
|
|
while (!ISC_LIST_EMPTY(list->rdata)) {
|
|
|
|
rdata = ISC_LIST_HEAD(list->rdata);
|
|
|
|
ISC_LIST_UNLINK(list->rdata, rdata, link);
|
|
|
|
isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
|
|
|
|
}
|
|
|
|
ISC_LIST_UNLINK(node->lists, list, link);
|
|
|
|
isc_mem_put(mctx, list, sizeof(dns_rdatalist_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!ISC_LIST_EMPTY(node->buffers)) {
|
|
|
|
b = ISC_LIST_HEAD(node->buffers);
|
|
|
|
ISC_LIST_UNLINK(node->buffers, b, link);
|
|
|
|
isc_buffer_free(&b);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->name != NULL) {
|
|
|
|
dns_name_free(node->name, mctx);
|
|
|
|
isc_mem_put(mctx, node->name, sizeof(dns_name_t));
|
|
|
|
}
|
2019-05-20 16:54:13 +02:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
node->magic = 0;
|
|
|
|
isc_mem_put(mctx, node, sizeof(dns_sdlznode_t));
|
|
|
|
db = &sdlz->common;
|
|
|
|
detach(&db);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2018-04-17 08:29:14 -07:00
|
|
|
getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
|
2014-06-10 16:25:26 -07:00
|
|
|
unsigned int options, dns_clientinfomethods_t *methods,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_clientinfo_t *clientinfo, dns_dbnode_t **nodep) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
|
|
|
dns_sdlznode_t *node = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t b;
|
|
|
|
char namestr[DNS_NAME_MAXTEXT + 1];
|
|
|
|
isc_buffer_t b2;
|
|
|
|
char zonestr[DNS_NAME_MAXTEXT + 1];
|
|
|
|
bool isorigin;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzauthorityfunc_t authority;
|
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
REQUIRE(nodep != NULL && *nodep == NULL);
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
if (sdlz->dlzimp->methods->newversion == NULL) {
|
2020-03-30 13:49:55 -07:00
|
|
|
REQUIRE(!create);
|
2010-12-18 01:56:23 +00:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
isc_buffer_init(&b, namestr, sizeof(namestr));
|
|
|
|
if ((sdlz->dlzimp->flags & DNS_SDLZFLAG_RELATIVEOWNER) != 0) {
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t relname;
|
2005-09-05 00:12:29 +00:00
|
|
|
unsigned int labels;
|
|
|
|
|
|
|
|
labels = dns_name_countlabels(name) -
|
2014-06-10 16:25:26 -07:00
|
|
|
dns_name_countlabels(&sdlz->common.origin);
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_name_init(&relname, NULL);
|
|
|
|
dns_name_getlabelsequence(name, 0, labels, &relname);
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(&relname, true, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(name, true, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
isc_buffer_putuint8(&b, 0);
|
|
|
|
|
|
|
|
isc_buffer_init(&b2, zonestr, sizeof(zonestr));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(&sdlz->common.origin, true, &b2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_putuint8(&b2, 0);
|
|
|
|
|
|
|
|
result = createnode(sdlz, &node);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
isorigin = dns_name_equal(name, &sdlz->common.origin);
|
|
|
|
|
|
|
|
/* make sure strings are always lowercase */
|
|
|
|
dns_sdlz_tolower(zonestr);
|
|
|
|
dns_sdlz_tolower(namestr);
|
|
|
|
|
|
|
|
MAYBE_LOCK(sdlz->dlzimp);
|
|
|
|
|
|
|
|
/* try to lookup the host (namestr) */
|
2020-02-12 13:59:18 +01:00
|
|
|
result = sdlz->dlzimp->methods->lookup(
|
|
|
|
zonestr, namestr, sdlz->dlzimp->driverarg, sdlz->dbdata, node,
|
|
|
|
methods, clientinfo);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
2014-06-10 16:25:26 -07:00
|
|
|
* If the name was not found and DNS_DBFIND_NOWILD is not
|
|
|
|
* set, then we try to find a wildcard entry.
|
|
|
|
*
|
|
|
|
* If DNS_DBFIND_NOZONECUT is set and there are multiple
|
|
|
|
* levels between the host and the zone origin, we also look
|
|
|
|
* for wildcards at each level.
|
2005-09-05 00:12:29 +00:00
|
|
|
*/
|
2014-06-10 16:25:26 -07:00
|
|
|
if (result == ISC_R_NOTFOUND && !create &&
|
2020-02-12 13:59:18 +01:00
|
|
|
(options & DNS_DBFIND_NOWILD) == 0) {
|
2014-06-10 16:25:26 -07:00
|
|
|
unsigned int i, dlabels, nlabels;
|
|
|
|
|
|
|
|
nlabels = dns_name_countlabels(name);
|
|
|
|
dlabels = nlabels - dns_name_countlabels(&sdlz->common.origin);
|
|
|
|
for (i = 0; i < dlabels; i++) {
|
2020-02-13 14:44:37 -08:00
|
|
|
char wildstr[DNS_NAME_MAXTEXT + 1];
|
|
|
|
dns_fixedname_t fixed;
|
2016-12-30 15:45:08 +11:00
|
|
|
const dns_name_t *wild;
|
2014-06-10 16:25:26 -07:00
|
|
|
|
|
|
|
dns_fixedname_init(&fixed);
|
2019-02-18 12:57:35 +11:00
|
|
|
if (i == dlabels - 1) {
|
2014-06-10 16:25:26 -07:00
|
|
|
wild = dns_wildcardname;
|
2019-02-18 12:57:35 +11:00
|
|
|
} else {
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_name_t *fname;
|
|
|
|
fname = dns_fixedname_name(&fixed);
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_name_getlabelsequence(
|
|
|
|
name, i + 1, dlabels - i - 1, fname);
|
|
|
|
result = dns_name_concatenate(
|
|
|
|
dns_wildcardname, fname, fname, NULL);
|
2019-03-13 10:51:56 +11:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
2014-06-10 16:25:26 -07:00
|
|
|
return (result);
|
2019-03-13 10:51:56 +11:00
|
|
|
}
|
2016-12-30 15:45:08 +11:00
|
|
|
wild = fname;
|
2014-06-10 16:25:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
isc_buffer_init(&b, wildstr, sizeof(wildstr));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(wild, true, &b);
|
2019-03-13 10:51:56 +11:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
2014-06-10 16:25:26 -07:00
|
|
|
return (result);
|
2019-03-13 10:51:56 +11:00
|
|
|
}
|
2014-06-10 16:25:26 -07:00
|
|
|
isc_buffer_putuint8(&b, 0);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = sdlz->dlzimp->methods->lookup(
|
|
|
|
zonestr, wildstr, sdlz->dlzimp->driverarg,
|
|
|
|
sdlz->dbdata, node, methods, clientinfo);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2014-06-10 16:25:26 -07:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-10 16:25:26 -07:00
|
|
|
}
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_NOTFOUND && (isorigin || create)) {
|
2013-03-11 15:54:03 -07:00
|
|
|
result = ISC_R_SUCCESS;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-11 15:54:03 -07:00
|
|
|
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2019-12-05 13:29:45 +11:00
|
|
|
isc_refcount_decrementz(&node->references);
|
2005-09-05 00:12:29 +00:00
|
|
|
destroynode(node);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isorigin && sdlz->dlzimp->methods->authority != NULL) {
|
|
|
|
MAYBE_LOCK(sdlz->dlzimp);
|
|
|
|
authority = sdlz->dlzimp->methods->authority;
|
|
|
|
result = (*authority)(zonestr, sdlz->dlzimp->driverarg,
|
|
|
|
sdlz->dbdata, node);
|
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
2020-02-12 13:59:18 +01:00
|
|
|
if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
|
2019-12-05 13:29:45 +11:00
|
|
|
isc_refcount_decrementz(&node->references);
|
2005-09-05 00:12:29 +00:00
|
|
|
destroynode(node);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
if (node->name == NULL) {
|
2020-02-12 13:59:18 +01:00
|
|
|
node->name = isc_mem_get(sdlz->common.mctx, sizeof(dns_name_t));
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_name_init(node->name, NULL);
|
2019-11-01 08:31:13 -05:00
|
|
|
dns_name_dup(name, sdlz->common.mctx, node->name);
|
2010-12-18 01:56:23 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
*nodep = node;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2014-06-10 16:25:26 -07:00
|
|
|
static isc_result_t
|
2018-04-17 08:29:14 -07:00
|
|
|
findnodeext(dns_db_t *db, const dns_name_t *name, bool create,
|
2014-06-10 16:25:26 -07:00
|
|
|
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_dbnode_t **nodep) {
|
2014-06-10 16:25:26 -07:00
|
|
|
return (getnodedata(db, name, create, 0, methods, clientinfo, nodep));
|
|
|
|
}
|
|
|
|
|
2011-10-11 00:09:03 +00:00
|
|
|
static isc_result_t
|
2018-04-17 08:29:14 -07:00
|
|
|
findnode(dns_db_t *db, const dns_name_t *name, bool create,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_dbnode_t **nodep) {
|
2014-06-10 16:25:26 -07:00
|
|
|
return (getnodedata(db, name, create, 0, NULL, NULL, nodep));
|
2011-10-11 00:09:03 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
static isc_result_t
|
2016-12-30 15:45:08 +11:00
|
|
|
findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_stdtime_t now, dns_dbnode_t **nodep, dns_name_t *foundname,
|
2018-06-13 09:29:40 +02:00
|
|
|
dns_name_t *dcname, dns_rdataset_t *rdataset,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *sigrdataset) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(options);
|
|
|
|
UNUSED(now);
|
|
|
|
UNUSED(nodep);
|
|
|
|
UNUSED(foundname);
|
2018-06-13 09:29:40 +02:00
|
|
|
UNUSED(dcname);
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(rdataset);
|
|
|
|
UNUSED(sigrdataset);
|
|
|
|
|
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
attachnode(dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlznode_t *node = (dns_sdlznode_t *)source;
|
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
|
|
|
UNUSED(sdlz);
|
|
|
|
|
2019-05-20 16:54:13 +02:00
|
|
|
isc_refcount_increment(&node->references);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
*targetp = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
detachnode(dns_db_t *db, dns_dbnode_t **targetp) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlznode_t *node;
|
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
REQUIRE(targetp != NULL && *targetp != NULL);
|
|
|
|
|
|
|
|
UNUSED(sdlz);
|
|
|
|
|
|
|
|
node = (dns_sdlznode_t *)(*targetp);
|
2019-05-20 16:54:13 +02:00
|
|
|
*targetp = NULL;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2019-05-20 16:54:13 +02:00
|
|
|
if (isc_refcount_decrement(&node->references) == 1) {
|
2005-09-05 00:12:29 +00:00
|
|
|
destroynode(node);
|
2019-05-20 16:54:13 +02:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(node);
|
|
|
|
UNUSED(now);
|
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
printnode(dns_db_t *db, dns_dbnode_t *node, FILE *out) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(node);
|
|
|
|
UNUSED(out);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
createiterator(dns_db_t *db, unsigned int options,
|
|
|
|
dns_dbiterator_t **iteratorp) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t b;
|
|
|
|
char zonestr[DNS_NAME_MAXTEXT + 1];
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlz->dlzimp->methods->allnodes == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
if ((options & DNS_DB_NSEC3ONLY) != 0 ||
|
2020-02-13 21:48:23 +01:00
|
|
|
(options & DNS_DB_NONSEC3) != 0) {
|
2020-02-12 13:59:18 +01:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_init(&b, zonestr, sizeof(zonestr));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(&sdlz->common.origin, true, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_putuint8(&b, 0);
|
|
|
|
|
|
|
|
sdlziter = isc_mem_get(sdlz->common.mctx, sizeof(sdlz_dbiterator_t));
|
|
|
|
|
|
|
|
sdlziter->common.methods = &dbiterator_methods;
|
|
|
|
sdlziter->common.db = NULL;
|
|
|
|
dns_db_attach(db, &sdlziter->common.db);
|
2020-02-13 14:44:37 -08:00
|
|
|
sdlziter->common.relative_names = ((options & DNS_DB_RELATIVENAMES) !=
|
|
|
|
0);
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlziter->common.magic = DNS_DBITERATOR_MAGIC;
|
|
|
|
ISC_LIST_INIT(sdlziter->nodelist);
|
|
|
|
sdlziter->current = NULL;
|
|
|
|
sdlziter->origin = NULL;
|
|
|
|
|
|
|
|
/* make sure strings are always lowercase */
|
|
|
|
dns_sdlz_tolower(zonestr);
|
|
|
|
|
|
|
|
MAYBE_LOCK(sdlz->dlzimp);
|
2020-02-12 13:59:18 +01:00
|
|
|
result = sdlz->dlzimp->methods->allnodes(
|
|
|
|
zonestr, sdlz->dlzimp->driverarg, sdlz->dbdata, sdlziter);
|
2005-09-05 00:12:29 +00:00
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
dns_dbiterator_t *iter = &sdlziter->common;
|
|
|
|
dbiterator_destroy(&iter);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sdlziter->origin != NULL) {
|
|
|
|
ISC_LIST_UNLINK(sdlziter->nodelist, sdlziter->origin, link);
|
|
|
|
ISC_LIST_PREPEND(sdlziter->nodelist, sdlziter->origin, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
*iteratorp = (dns_dbiterator_t *)sdlziter;
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdatatype_t type, dns_rdatatype_t covers, isc_stdtime_t now,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) {
|
2019-07-23 17:16:57 -04:00
|
|
|
REQUIRE(VALID_SDLZNODE(node));
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_rdatalist_t *list;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)node;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(version);
|
|
|
|
UNUSED(covers);
|
|
|
|
UNUSED(now);
|
|
|
|
UNUSED(sigrdataset);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (type == dns_rdatatype_sig || type == dns_rdatatype_rrsig) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
list = ISC_LIST_HEAD(sdlznode->lists);
|
|
|
|
while (list != NULL) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (list->type == type) {
|
2005-09-05 00:12:29 +00:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
list = ISC_LIST_NEXT(list, link);
|
|
|
|
}
|
2020-02-13 21:48:23 +01:00
|
|
|
if (list == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTFOUND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
list_tordataset(list, db, node, rdataset);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2016-12-30 15:45:08 +11:00
|
|
|
findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
2011-10-11 00:09:03 +00:00
|
|
|
dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
|
|
|
|
dns_dbnode_t **nodep, dns_name_t *foundname,
|
|
|
|
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
|
|
|
dns_dbnode_t *node = NULL;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_fixedname_t fname;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t xrdataset;
|
|
|
|
dns_name_t *xname;
|
|
|
|
unsigned int nlabels, olabels;
|
|
|
|
isc_result_t result;
|
|
|
|
unsigned int i;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
REQUIRE(nodep == NULL || *nodep == NULL);
|
2020-02-12 13:59:18 +01:00
|
|
|
REQUIRE(version == NULL || version == (void *)&sdlz->dummy_version ||
|
2014-04-25 13:06:30 -07:00
|
|
|
version == sdlz->future_version);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
UNUSED(sdlz);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (!dns_name_issubdomain(name, &db->origin)) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (DNS_R_NXDOMAIN);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
olabels = dns_name_countlabels(&db->origin);
|
|
|
|
nlabels = dns_name_countlabels(name);
|
|
|
|
|
2018-03-28 14:38:09 +02:00
|
|
|
xname = dns_fixedname_initname(&fname);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2007-02-13 23:36:06 +00:00
|
|
|
if (rdataset == NULL) {
|
|
|
|
dns_rdataset_init(&xrdataset);
|
2005-09-05 00:12:29 +00:00
|
|
|
rdataset = &xrdataset;
|
2007-02-13 23:36:06 +00:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
result = DNS_R_NXDOMAIN;
|
|
|
|
|
2014-06-10 16:25:26 -07:00
|
|
|
/*
|
|
|
|
* If we're not walking down searching for zone
|
|
|
|
* cuts, we can cut straight to the chase
|
|
|
|
*/
|
|
|
|
if ((options & DNS_DBFIND_NOZONECUT) != 0) {
|
|
|
|
i = nlabels;
|
|
|
|
goto search;
|
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
for (i = olabels; i <= nlabels; i++) {
|
2020-02-12 13:59:18 +01:00
|
|
|
search:
|
2005-09-05 00:12:29 +00:00
|
|
|
/*
|
|
|
|
* Look up the next label.
|
|
|
|
*/
|
|
|
|
dns_name_getlabelsequence(name, nlabels - i, i, xname);
|
2020-02-12 13:59:18 +01:00
|
|
|
result = getnodedata(db, xname, false, options, methods,
|
|
|
|
clientinfo, &node);
|
2013-01-22 15:13:08 -08:00
|
|
|
if (result == ISC_R_NOTFOUND) {
|
2005-09-05 00:12:29 +00:00
|
|
|
result = DNS_R_NXDOMAIN;
|
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else if (result != ISC_R_SUCCESS) {
|
2013-01-22 15:13:08 -08:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for a DNAME at the current label, unless this is
|
|
|
|
* the qname.
|
|
|
|
*/
|
|
|
|
if (i < nlabels) {
|
|
|
|
result = findrdataset(db, node, version,
|
2011-10-11 00:09:03 +00:00
|
|
|
dns_rdatatype_dname, 0, now,
|
|
|
|
rdataset, sigrdataset);
|
2005-09-05 00:12:29 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = DNS_R_DNAME;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for an NS at the current label, unless this is the
|
2014-06-10 16:25:26 -07:00
|
|
|
* origin, glue is ok, or there are known to be no zone cuts.
|
2005-09-05 00:12:29 +00:00
|
|
|
*/
|
2014-06-10 16:25:26 -07:00
|
|
|
if (i != olabels && (options & DNS_DBFIND_GLUEOK) == 0 &&
|
2020-02-13 14:44:37 -08:00
|
|
|
(options & DNS_DBFIND_NOZONECUT) == 0)
|
|
|
|
{
|
2005-09-05 00:12:29 +00:00
|
|
|
result = findrdataset(db, node, version,
|
2011-10-11 00:09:03 +00:00
|
|
|
dns_rdatatype_ns, 0, now,
|
|
|
|
rdataset, sigrdataset);
|
2014-06-10 16:25:26 -07:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
if (result == ISC_R_SUCCESS && i == nlabels &&
|
|
|
|
type == dns_rdatatype_any) {
|
2014-06-10 16:25:26 -07:00
|
|
|
result = DNS_R_ZONECUT;
|
|
|
|
dns_rdataset_disassociate(rdataset);
|
|
|
|
if (sigrdataset != NULL &&
|
2020-02-13 21:48:23 +01:00
|
|
|
dns_rdataset_isassociated(sigrdataset)) {
|
2014-06-10 16:25:26 -07:00
|
|
|
dns_rdataset_disassociate(sigrdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-10 16:25:26 -07:00
|
|
|
break;
|
|
|
|
} else if (result == ISC_R_SUCCESS) {
|
|
|
|
result = DNS_R_DELEGATION;
|
2005-09-05 00:12:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the current name is not the qname, add another label
|
|
|
|
* and try again.
|
|
|
|
*/
|
|
|
|
if (i < nlabels) {
|
2019-05-20 16:54:13 +02:00
|
|
|
detachnode(db, &node);
|
2005-09-05 00:12:29 +00:00
|
|
|
node = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're looking for ANY, we're done.
|
|
|
|
*/
|
|
|
|
if (type == dns_rdatatype_any) {
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for the qtype.
|
|
|
|
*/
|
2020-02-12 13:59:18 +01:00
|
|
|
result = findrdataset(db, node, version, type, 0, now, rdataset,
|
|
|
|
sigrdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for a CNAME
|
|
|
|
*/
|
|
|
|
if (type != dns_rdatatype_cname) {
|
|
|
|
result = findrdataset(db, node, version,
|
2011-10-11 00:09:03 +00:00
|
|
|
dns_rdatatype_cname, 0, now,
|
|
|
|
rdataset, sigrdataset);
|
2005-09-05 00:12:29 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = DNS_R_CNAME;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = DNS_R_NXRRSET;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (rdataset == &xrdataset && dns_rdataset_isassociated(rdataset)) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_rdataset_disassociate(rdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
if (foundname != NULL) {
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(xname, foundname);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (nodep != NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
*nodep = node;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else if (node != NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
detachnode(db, &node);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2011-10-11 00:09:03 +00:00
|
|
|
static isc_result_t
|
2016-12-30 15:45:08 +11:00
|
|
|
find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
|
2011-10-11 00:09:03 +00:00
|
|
|
dns_rdatatype_t type, unsigned int options, isc_stdtime_t now,
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_dbnode_t **nodep, dns_name_t *foundname, dns_rdataset_t *rdataset,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *sigrdataset) {
|
2020-02-12 13:59:18 +01:00
|
|
|
return (findext(db, name, version, type, options, now, nodep, foundname,
|
|
|
|
NULL, NULL, rdataset, sigrdataset));
|
2011-10-11 00:09:03 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
static isc_result_t
|
|
|
|
allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_stdtime_t now, dns_rdatasetiter_t **iteratorp) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_rdatasetiter_t *iterator;
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
REQUIRE(version == NULL || version == (void *)&sdlz->dummy_version ||
|
2010-12-18 01:56:23 +00:00
|
|
|
version == sdlz->future_version);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
UNUSED(version);
|
|
|
|
UNUSED(now);
|
|
|
|
|
|
|
|
iterator = isc_mem_get(db->mctx, sizeof(sdlz_rdatasetiter_t));
|
|
|
|
|
|
|
|
iterator->common.magic = DNS_RDATASETITER_MAGIC;
|
|
|
|
iterator->common.methods = &rdatasetiter_methods;
|
|
|
|
iterator->common.db = db;
|
|
|
|
iterator->common.node = NULL;
|
|
|
|
attachnode(db, node, &iterator->common.node);
|
|
|
|
iterator->common.version = version;
|
|
|
|
iterator->common.now = now;
|
|
|
|
|
|
|
|
*iteratorp = (dns_rdatasetiter_t *)iterator;
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
static isc_result_t
|
|
|
|
modrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|
|
|
dns_rdataset_t *rdataset, unsigned int options,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlzmodrdataset_t mod_function) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_master_style_t *style = NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t *buffer = NULL;
|
|
|
|
isc_mem_t *mctx;
|
|
|
|
dns_sdlznode_t *sdlznode;
|
|
|
|
char *rdatastr = NULL;
|
|
|
|
char name[DNS_NAME_MAXTEXT + 1];
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (mod_function == NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
sdlznode = (dns_sdlznode_t *)node;
|
|
|
|
|
|
|
|
UNUSED(options);
|
|
|
|
|
|
|
|
dns_name_format(sdlznode->name, name, sizeof(name));
|
|
|
|
|
|
|
|
mctx = sdlz->common.mctx;
|
|
|
|
|
2020-02-02 08:35:46 +01:00
|
|
|
isc_buffer_allocate(mctx, &buffer, 1024);
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1, 0xffffffff,
|
|
|
|
mctx);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-12-18 01:56:23 +00:00
|
|
|
goto cleanup;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = dns_master_rdatasettotext(sdlznode->name, rdataset, style,
|
|
|
|
NULL, buffer);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-12-18 01:56:23 +00:00
|
|
|
goto cleanup;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
if (isc_buffer_usedlength(buffer) < 1) {
|
|
|
|
result = ISC_R_BADADDRESSFORM;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rdatastr = isc_buffer_base(buffer);
|
|
|
|
if (rdatastr == NULL) {
|
|
|
|
result = ISC_R_NOMEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
rdatastr[isc_buffer_usedlength(buffer) - 1] = 0;
|
|
|
|
|
|
|
|
MAYBE_LOCK(sdlz->dlzimp);
|
|
|
|
result = mod_function(name, rdatastr, sdlz->dlzimp->driverarg,
|
|
|
|
sdlz->dbdata, version);
|
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
isc_buffer_free(&buffer);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (style != NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_master_styledestroy(&style, mctx);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
static isc_result_t
|
|
|
|
addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|
|
|
isc_stdtime_t now, dns_rdataset_t *rdataset, unsigned int options,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *addedrdataset) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(now);
|
|
|
|
UNUSED(addedrdataset);
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlz->dlzimp->methods->addrdataset == NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
result = modrdataset(db, node, version, rdataset, options,
|
|
|
|
sdlz->dlzimp->methods->addrdataset);
|
|
|
|
return (result);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|
|
|
dns_rdataset_t *rdataset, unsigned int options,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *newrdataset) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(newrdataset);
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
if (sdlz->dlzimp->methods->subtractrdataset == NULL) {
|
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = modrdataset(db, node, version, rdataset, options,
|
|
|
|
sdlz->dlzimp->methods->subtractrdataset);
|
|
|
|
return (result);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
deleterdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdatatype_t type, dns_rdatatype_t covers) {
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
|
|
|
char name[DNS_NAME_MAXTEXT + 1];
|
|
|
|
char b_type[DNS_RDATATYPE_FORMATSIZE];
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlznode_t *sdlznode;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(covers);
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlz->dlzimp->methods->delrdataset == NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
sdlznode = (dns_sdlznode_t *)node;
|
|
|
|
dns_name_format(sdlznode->name, name, sizeof(name));
|
|
|
|
dns_rdatatype_format(type, b_type, sizeof(b_type));
|
|
|
|
|
|
|
|
MAYBE_LOCK(sdlz->dlzimp);
|
2020-02-12 13:59:18 +01:00
|
|
|
result = sdlz->dlzimp->methods->delrdataset(
|
|
|
|
name, b_type, sdlz->dlzimp->driverarg, sdlz->dbdata, version);
|
2010-12-18 01:56:23 +00:00
|
|
|
MAYBE_UNLOCK(sdlz->dlzimp);
|
|
|
|
|
|
|
|
return (result);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
issecure(dns_db_t *db) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
2020-02-13 14:44:37 -08:00
|
|
|
nodecount(dns_db_t *db) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
ispersistent(dns_db_t *db) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
overmem(dns_db_t *db, bool over) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
2015-02-27 10:55:55 +11:00
|
|
|
UNUSED(over);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
settask(dns_db_t *db, isc_task_t *task) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(db);
|
|
|
|
UNUSED(task);
|
|
|
|
}
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
/*
|
|
|
|
* getoriginnode() is used by the update code to find the
|
|
|
|
* dns_rdatatype_dnskey record for a zone
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
getoriginnode(dns_db_t *db, dns_dbnode_t **nodep) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZDB(sdlz));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlz->dlzimp->methods->newversion == NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = getnodedata(db, &sdlz->common.origin, false, 0, NULL, NULL,
|
|
|
|
nodep);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2013-03-11 16:49:52 -07:00
|
|
|
sdlz_log(ISC_LOG_ERROR, "sdlz getoriginnode failed: %s",
|
2010-12-18 01:56:23 +00:00
|
|
|
isc_result_totext(result));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
static dns_dbmethods_t sdlzdb_methods = {
|
|
|
|
attach,
|
|
|
|
detach,
|
|
|
|
beginload,
|
|
|
|
endload,
|
2020-02-12 13:59:18 +01:00
|
|
|
NULL, /* serialize */
|
2005-09-05 00:12:29 +00:00
|
|
|
dump,
|
|
|
|
currentversion,
|
|
|
|
newversion,
|
|
|
|
attachversion,
|
|
|
|
closeversion,
|
|
|
|
findnode,
|
|
|
|
find,
|
|
|
|
findzonecut,
|
|
|
|
attachnode,
|
|
|
|
detachnode,
|
|
|
|
expirenode,
|
|
|
|
printnode,
|
|
|
|
createiterator,
|
|
|
|
findrdataset,
|
|
|
|
allrdatasets,
|
|
|
|
addrdataset,
|
|
|
|
subtractrdataset,
|
|
|
|
deleterdataset,
|
|
|
|
issecure,
|
|
|
|
nodecount,
|
|
|
|
ispersistent,
|
|
|
|
overmem,
|
|
|
|
settask,
|
2010-12-18 01:56:23 +00:00
|
|
|
getoriginnode,
|
2020-02-12 13:59:18 +01:00
|
|
|
NULL, /* transfernode */
|
|
|
|
NULL, /* getnsec3parameters */
|
|
|
|
NULL, /* findnsec3node */
|
|
|
|
NULL, /* setsigningtime */
|
|
|
|
NULL, /* getsigningtime */
|
|
|
|
NULL, /* resigned */
|
|
|
|
NULL, /* isdnssec */
|
|
|
|
NULL, /* getrrsetstats */
|
|
|
|
NULL, /* rpz_attach */
|
|
|
|
NULL, /* rpz_ready */
|
2011-10-11 00:09:03 +00:00
|
|
|
findnodeext,
|
2012-05-14 10:06:05 -07:00
|
|
|
findext,
|
2020-02-12 13:59:18 +01:00
|
|
|
NULL, /* setcachestats */
|
|
|
|
NULL, /* hashsize */
|
|
|
|
NULL, /* nodefullname */
|
|
|
|
NULL, /* getsize */
|
|
|
|
NULL, /* setservestalettl */
|
|
|
|
NULL, /* getservestalettl */
|
Add stale-refresh-time option
Before this update, BIND would attempt to do a full recursive resolution
process for each query received if the requested rrset had its ttl
expired. If the resolution fails for any reason, only then BIND would
check for stale rrset in cache (if 'stale-cache-enable' and
'stale-answer-enable' is on).
The problem with this approach is that if an authoritative server is
unreachable or is failing to respond, it is very unlikely that the
problem will be fixed in the next seconds.
A better approach to improve performance in those cases, is to mark the
moment in which a resolution failed, and if new queries arrive for that
same rrset, try to respond directly from the stale cache, and do that
for a window of time configured via 'stale-refresh-time'.
Only when this interval expires we then try to do a normal refresh of
the rrset.
The logic behind this commit is as following:
- In query.c / query_gotanswer(), if the test of 'result' variable falls
to the default case, an error is assumed to have happened, and a call
to 'query_usestale()' is made to check if serving of stale rrset is
enabled in configuration.
- If serving of stale answers is enabled, a flag will be turned on in
the query context to look for stale records:
query.c:6839
qctx->client->query.dboptions |= DNS_DBFIND_STALEOK;
- A call to query_lookup() will be made again, inside it a call to
'dns_db_findext()' is made, which in turn will invoke rbdb.c /
cache_find().
- In rbtdb.c / cache_find() the important bits of this change is the
call to 'check_stale_header()', which is a function that yields true
if we should skip the stale entry, or false if we should consider it.
- In check_stale_header() we now check if the DNS_DBFIND_STALEOK option
is set, if that is the case we know that this new search for stale
records was made due to a failure in a normal resolution, so we keep
track of the time in which the failured occured in rbtdb.c:4559:
header->last_refresh_fail_ts = search->now;
- In check_stale_header(), if DNS_DBFIND_STALEOK is not set, then we
know this is a normal lookup, if the record is stale and the query
time is between last failure time + stale-refresh-time window, then
we return false so cache_find() knows it can consider this stale
rrset entry to return as a response.
The last additions are two new methods to the database interface:
- setservestale_refresh
- getservestale_refresh
Those were added so rbtdb can be aware of the value set in configuration
option, since in that level we have no access to the view object.
2020-10-19 17:02:03 -03:00
|
|
|
NULL, /* setservestalerefresh */
|
|
|
|
NULL, /* getservestalerefresh */
|
Fix the rbt hashtable and grow it when setting max-cache-size
There were several problems with rbt hashtable implementation:
1. Our internal hashing function returns uint64_t value, but it was
silently truncated to unsigned int in dns_name_hash() and
dns_name_fullhash() functions. As the SipHash 2-4 higher bits are
more random, we need to use the upper half of the return value.
2. The hashtable implementation in rbt.c was using modulo to pick the
slot number for the hash table. This has several problems because
modulo is: a) slow, b) oblivious to patterns in the input data. This
could lead to very uneven distribution of the hashed data in the
hashtable. Combined with the single-linked lists we use, it could
really hog-down the lookup and removal of the nodes from the rbt
tree[a]. The Fibonacci Hashing is much better fit for the hashtable
function here. For longer description, read "Fibonacci Hashing: The
Optimization that the World Forgot"[b] or just look at the Linux
kernel. Also this will make Diego very happy :).
3. The hashtable would rehash every time the number of nodes in the rbt
tree would exceed 3 * (hashtable size). The overcommit will make the
uneven distribution in the hashtable even worse, but the main problem
lies in the rehashing - every time the database grows beyond the
limit, each subsequent rehashing will be much slower. The mitigation
here is letting the rbt know how big the cache can grown and
pre-allocate the hashtable to be big enough to actually never need to
rehash. This will consume more memory at the start, but since the
size of the hashtable is capped to `1 << 32` (e.g. 4 mio entries), it
will only consume maximum of 32GB of memory for hashtable in the
worst case (and max-cache-size would need to be set to more than
4TB). Calling the dns_db_adjusthashsize() will also cap the maximum
size of the hashtable to the pre-computed number of bits, so it won't
try to consume more gigabytes of memory than available for the
database.
FIXME: What is the average size of the rbt node that gets hashed? I
chose the pagesize (4k) as initial value to precompute the size of
the hashtable, but the value is based on feeling and not any real
data.
For future work, there are more places where we use result of the hash
value modulo some small number and that would benefit from Fibonacci
Hashing to get better distribution.
Notes:
a. A doubly linked list should be used here to speedup the removal of
the entries from the hashtable.
b. https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/
2020-07-16 10:29:54 +02:00
|
|
|
NULL, /* setgluecachestats */
|
|
|
|
NULL /* adjusthashsize */
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Database Iterator Methods. These methods were "borrowed" from the SDB
|
|
|
|
* driver interface. See the SDB driver interface documentation for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_destroy(dns_dbiterator_t **iteratorp) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)(*iteratorp);
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)sdlziter->common.db;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
while (!ISC_LIST_EMPTY(sdlziter->nodelist)) {
|
|
|
|
dns_sdlznode_t *node;
|
|
|
|
node = ISC_LIST_HEAD(sdlziter->nodelist);
|
|
|
|
ISC_LIST_UNLINK(sdlziter->nodelist, node, link);
|
2019-12-05 13:29:45 +11:00
|
|
|
isc_refcount_decrementz(&node->references);
|
2005-09-05 00:12:29 +00:00
|
|
|
destroynode(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_db_detach(&sdlziter->common.db);
|
|
|
|
isc_mem_put(sdlz->common.mctx, sdlziter, sizeof(sdlz_dbiterator_t));
|
|
|
|
|
|
|
|
*iteratorp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_first(dns_dbiterator_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
sdlziter->current = ISC_LIST_HEAD(sdlziter->nodelist);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlziter->current == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_last(dns_dbiterator_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
sdlziter->current = ISC_LIST_TAIL(sdlziter->nodelist);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlziter->current == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_seek(dns_dbiterator_t *iterator, const dns_name_t *name) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
sdlziter->current = ISC_LIST_HEAD(sdlziter->nodelist);
|
2009-06-26 06:21:03 +00:00
|
|
|
while (sdlziter->current != NULL) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dns_name_equal(sdlziter->current->name, name)) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2009-06-26 06:21:03 +00:00
|
|
|
sdlziter->current = ISC_LIST_NEXT(sdlziter->current, link);
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOTFOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_prev(dns_dbiterator_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
sdlziter->current = ISC_LIST_PREV(sdlziter->current, link);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlziter->current == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_next(dns_dbiterator_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
sdlziter->current = ISC_LIST_NEXT(sdlziter->current, link);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sdlziter->current == NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOMORE);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t *name) {
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlz_dbiterator_t *sdlziter = (sdlz_dbiterator_t *)iterator;
|
|
|
|
|
|
|
|
attachnode(iterator->db, sdlziter->current, nodep);
|
2019-09-10 13:16:48 +02:00
|
|
|
if (name != NULL) {
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(sdlziter->current->name, name);
|
2019-09-10 13:16:48 +02:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_pause(dns_dbiterator_t *iterator) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(iterator);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) {
|
2005-09-05 00:12:29 +00:00
|
|
|
UNUSED(iterator);
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(dns_rootname, name);
|
2019-09-10 13:16:48 +02:00
|
|
|
return (ISC_R_SUCCESS);
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rdataset Methods. These methods were "borrowed" from the SDB driver
|
|
|
|
* interface. See the SDB driver interface documentation for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
disassociate(dns_rdataset_t *rdataset) {
|
|
|
|
dns_dbnode_t *node = rdataset->private5;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)node;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_db_t *db = (dns_db_t *)sdlznode->sdlz;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
detachnode(db, &node);
|
|
|
|
isc__rdatalist_disassociate(rdataset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
|
|
|
|
dns_dbnode_t *node = source->private5;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlznode_t *sdlznode = (dns_sdlznode_t *)node;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_db_t *db = (dns_db_t *)sdlznode->sdlz;
|
|
|
|
dns_dbnode_t *tempdb = NULL;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
isc__rdatalist_clone(source, target);
|
|
|
|
attachnode(db, node, &tempdb);
|
|
|
|
source->private5 = tempdb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dns_rdatasetmethods_t rdataset_methods = {
|
|
|
|
disassociate,
|
|
|
|
isc__rdatalist_first,
|
|
|
|
isc__rdatalist_next,
|
|
|
|
isc__rdatalist_current,
|
|
|
|
rdataset_clone,
|
|
|
|
isc__rdatalist_count,
|
|
|
|
isc__rdatalist_addnoqname,
|
|
|
|
isc__rdatalist_getnoqname,
|
2017-04-22 08:25:10 +05:30
|
|
|
NULL, /* addclosest */
|
|
|
|
NULL, /* getclosest */
|
|
|
|
NULL, /* settrust */
|
|
|
|
NULL, /* expire */
|
|
|
|
NULL, /* clearprefetch */
|
|
|
|
NULL, /* setownercase */
|
|
|
|
NULL, /* getownercase */
|
|
|
|
NULL /* addglue */
|
2005-09-05 00:12:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
list_tordataset(dns_rdatalist_t *rdatalist, dns_db_t *db, dns_dbnode_t *node,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataset_t *rdataset) {
|
2005-09-05 00:12:29 +00:00
|
|
|
/*
|
|
|
|
* The sdlz rdataset is an rdatalist with some additions.
|
|
|
|
* - private1 & private2 are used by the rdatalist.
|
|
|
|
* - private3 & private 4 are unused.
|
|
|
|
* - private5 is the node.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This should never fail. */
|
|
|
|
RUNTIME_CHECK(dns_rdatalist_tordataset(rdatalist, rdataset) ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
rdataset->methods = &rdataset_methods;
|
|
|
|
dns_db_attachnode(db, node, &rdataset->private5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SDLZ core methods. This is the core of the new DLZ functionality.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Build a 'bind' database driver structure to be returned by
|
|
|
|
* either the find zone or the allow zone transfer method.
|
|
|
|
* This method is only available in this source file, it is
|
|
|
|
* not made available anywhere else.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
|
2016-12-30 15:45:08 +11:00
|
|
|
const dns_name_t *name, dns_rdataclass_t rdclass,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_db_t **dbp) {
|
|
|
|
isc_result_t result;
|
|
|
|
dns_sdlz_db_t *sdlzdb;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
/* check that things are as we expect */
|
|
|
|
REQUIRE(dbp != NULL && *dbp == NULL);
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
imp = (dns_sdlzimplementation_t *)driverarg;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* allocate and zero memory for driver structure */
|
|
|
|
sdlzdb = isc_mem_get(mctx, sizeof(dns_sdlz_db_t));
|
|
|
|
memset(sdlzdb, 0, sizeof(dns_sdlz_db_t));
|
|
|
|
|
|
|
|
/* initialize and set origin */
|
|
|
|
dns_name_init(&sdlzdb->common.origin, NULL);
|
|
|
|
result = dns_name_dupwithoffsets(name, mctx, &sdlzdb->common.origin);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
goto mem_cleanup;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* set the rest of the database structure attributes */
|
|
|
|
sdlzdb->dlzimp = imp;
|
|
|
|
sdlzdb->common.methods = &sdlzdb_methods;
|
|
|
|
sdlzdb->common.attributes = 0;
|
|
|
|
sdlzdb->common.rdclass = rdclass;
|
|
|
|
sdlzdb->common.mctx = NULL;
|
|
|
|
sdlzdb->dbdata = dbdata;
|
2019-05-20 16:54:13 +02:00
|
|
|
isc_refcount_init(&sdlzdb->references, 1);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* attach to the memory context */
|
|
|
|
isc_mem_attach(mctx, &sdlzdb->common.mctx);
|
|
|
|
|
|
|
|
/* mark structure as valid */
|
|
|
|
sdlzdb->common.magic = DNS_DB_MAGIC;
|
|
|
|
sdlzdb->common.impmagic = SDLZDB_MAGIC;
|
2020-02-12 13:59:18 +01:00
|
|
|
*dbp = (dns_db_t *)sdlzdb;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
return (result);
|
2020-02-12 13:59:18 +01:00
|
|
|
mem_cleanup:
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_mem_put(mctx, sdlzdb, sizeof(dns_sdlz_db_t));
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dns_sdlzallowzonexfr(void *driverarg, void *dbdata, isc_mem_t *mctx,
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_rdataclass_t rdclass, const dns_name_t *name,
|
2020-02-13 14:44:37 -08:00
|
|
|
const isc_sockaddr_t *clientaddr, dns_db_t **dbp) {
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_t b;
|
|
|
|
isc_buffer_t b2;
|
2020-02-13 14:44:37 -08:00
|
|
|
char namestr[DNS_NAME_MAXTEXT + 1];
|
2020-02-12 13:59:18 +01:00
|
|
|
char clientstr[(sizeof "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255."
|
|
|
|
"255") +
|
|
|
|
1];
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_netaddr_t netaddr;
|
|
|
|
isc_result_t result;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform checks to make sure data is as we expect it to be.
|
|
|
|
*/
|
|
|
|
REQUIRE(driverarg != NULL);
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
REQUIRE(clientaddr != NULL);
|
|
|
|
REQUIRE(dbp != NULL && *dbp == NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
imp = (dns_sdlzimplementation_t *)driverarg;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* Convert DNS name to ascii text */
|
|
|
|
isc_buffer_init(&b, namestr, sizeof(namestr));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(name, true, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_putuint8(&b, 0);
|
|
|
|
|
|
|
|
/* convert client address to ascii text */
|
|
|
|
isc_buffer_init(&b2, clientstr, sizeof(clientstr));
|
|
|
|
isc_netaddr_fromsockaddr(&netaddr, clientaddr);
|
|
|
|
result = isc_netaddr_totext(&netaddr, &b2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_putuint8(&b2, 0);
|
|
|
|
|
2008-04-01 23:47:10 +00:00
|
|
|
/* make sure strings are always lowercase */
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlz_tolower(namestr);
|
|
|
|
dns_sdlz_tolower(clientstr);
|
|
|
|
|
|
|
|
/* Call SDLZ driver's find zone method */
|
|
|
|
if (imp->methods->allowzonexfr != NULL) {
|
2019-01-02 17:29:59 +11:00
|
|
|
isc_result_t rresult = ISC_R_SUCCESS;
|
|
|
|
|
2005-09-05 00:12:29 +00:00
|
|
|
MAYBE_LOCK(imp);
|
|
|
|
result = imp->methods->allowzonexfr(imp->driverarg, dbdata,
|
|
|
|
namestr, clientstr);
|
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
/*
|
2019-01-02 17:29:59 +11:00
|
|
|
* if zone is supported and transfers are (or might be)
|
|
|
|
* allowed, build a 'bind' database driver
|
2005-09-05 00:12:29 +00:00
|
|
|
*/
|
2019-01-02 17:29:59 +11:00
|
|
|
if (result == ISC_R_SUCCESS || result == ISC_R_DEFAULT) {
|
|
|
|
rresult = dns_sdlzcreateDBP(mctx, driverarg, dbdata,
|
|
|
|
name, rdclass, dbp);
|
|
|
|
}
|
|
|
|
if (rresult != ISC_R_SUCCESS) {
|
|
|
|
result = rresult;
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dns_sdlzcreate(isc_mem_t *mctx, const char *dlzname, unsigned int argc,
|
2020-02-13 14:44:37 -08:00
|
|
|
char *argv[], void *driverarg, void **dbdata) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result = ISC_R_NOTFOUND;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* Write debugging message to log */
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_DEBUG(2), "Loading SDLZ driver.");
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Performs checks to make sure data is as we expect it to be.
|
|
|
|
*/
|
|
|
|
REQUIRE(driverarg != NULL);
|
|
|
|
REQUIRE(dlzname != NULL);
|
|
|
|
REQUIRE(dbdata != NULL);
|
|
|
|
UNUSED(mctx);
|
|
|
|
|
|
|
|
imp = driverarg;
|
|
|
|
|
|
|
|
/* If the create method exists, call it. */
|
|
|
|
if (imp->methods->create != NULL) {
|
|
|
|
MAYBE_LOCK(imp);
|
|
|
|
result = imp->methods->create(dlzname, argc, argv,
|
|
|
|
imp->driverarg, dbdata);
|
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write debugging message to log */
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_DEBUG(2), "SDLZ driver loaded successfully.");
|
2005-09-05 00:12:29 +00:00
|
|
|
} else {
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_ERROR, "SDLZ driver failed to load.");
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlzdestroy(void *driverdata, void **dbdata) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
/* Write debugging message to log */
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_DEBUG(2), "Unloading SDLZ driver.");
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
imp = driverdata;
|
|
|
|
|
|
|
|
/* If the destroy method exists, call it. */
|
|
|
|
if (imp->methods->destroy != NULL) {
|
|
|
|
MAYBE_LOCK(imp);
|
|
|
|
imp->methods->destroy(imp->driverarg, dbdata);
|
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx,
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_rdataclass_t rdclass, const dns_name_t *name,
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_db_t **dbp) {
|
|
|
|
isc_buffer_t b;
|
|
|
|
char namestr[DNS_NAME_MAXTEXT + 1];
|
|
|
|
isc_result_t result;
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform checks to make sure data is as we expect it to be.
|
|
|
|
*/
|
|
|
|
REQUIRE(driverarg != NULL);
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
REQUIRE(dbp != NULL && *dbp == NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
imp = (dns_sdlzimplementation_t *)driverarg;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* Convert DNS name to ascii text */
|
|
|
|
isc_buffer_init(&b, namestr, sizeof(namestr));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_name_totext(name, true, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_putuint8(&b, 0);
|
|
|
|
|
2008-04-01 23:47:10 +00:00
|
|
|
/* make sure strings are always lowercase */
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlz_tolower(namestr);
|
|
|
|
|
|
|
|
/* Call SDLZ driver's find zone method */
|
|
|
|
MAYBE_LOCK(imp);
|
2012-12-06 12:59:36 -08:00
|
|
|
result = imp->methods->findzone(imp->driverarg, dbdata, namestr,
|
|
|
|
methods, clientinfo);
|
2005-09-05 00:12:29 +00:00
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if zone is supported build a 'bind' database driver
|
|
|
|
* structure to return
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
result = dns_sdlzcreateDBP(mctx, driverarg, dbdata, name,
|
|
|
|
rdclass, dbp);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
static isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_sdlzconfigure(void *driverarg, void *dbdata, dns_view_t *view,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_dlzdb_t *dlzdb) {
|
|
|
|
isc_result_t result;
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
REQUIRE(driverarg != NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
imp = (dns_sdlzimplementation_t *)driverarg;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
/* Call SDLZ driver's configure method */
|
|
|
|
if (imp->methods->configure != NULL) {
|
|
|
|
MAYBE_LOCK(imp);
|
2020-02-12 13:59:18 +01:00
|
|
|
result = imp->methods->configure(view, dlzdb, imp->driverarg,
|
|
|
|
dbdata);
|
2010-12-18 01:56:23 +00:00
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
} else {
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_sdlzssumatch(const dns_name_t *signer, const dns_name_t *name,
|
2016-12-30 23:46:36 +00:00
|
|
|
const isc_netaddr_t *tcpaddr, dns_rdatatype_t type,
|
2020-02-13 14:44:37 -08:00
|
|
|
const dst_key_t *key, void *driverarg, void *dbdata) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
2020-02-13 14:44:37 -08:00
|
|
|
char b_signer[DNS_NAME_FORMATSIZE];
|
|
|
|
char b_name[DNS_NAME_FORMATSIZE];
|
|
|
|
char b_addr[ISC_NETADDR_FORMATSIZE];
|
|
|
|
char b_type[DNS_RDATATYPE_FORMATSIZE];
|
|
|
|
char b_key[DST_KEY_FORMATSIZE];
|
|
|
|
isc_buffer_t *tkey_token = NULL;
|
|
|
|
isc_region_t token_region = { NULL, 0 };
|
|
|
|
uint32_t token_len = 0;
|
|
|
|
bool ret;
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
REQUIRE(driverarg != NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
imp = (dns_sdlzimplementation_t *)driverarg;
|
2020-02-13 21:48:23 +01:00
|
|
|
if (imp->methods->ssumatch == NULL) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
/*
|
2010-12-18 23:47:11 +00:00
|
|
|
* Format the request elements. sdlz operates on strings, not
|
2010-12-18 01:56:23 +00:00
|
|
|
* structures
|
2010-12-18 23:47:11 +00:00
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (signer != NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dns_name_format(signer, b_signer, sizeof(b_signer));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2010-12-18 01:56:23 +00:00
|
|
|
b_signer[0] = 0;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
dns_name_format(name, b_name, sizeof(b_name));
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tcpaddr != NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
isc_netaddr_format(tcpaddr, b_addr, sizeof(b_addr));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2010-12-18 01:56:23 +00:00
|
|
|
b_addr[0] = 0;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
dns_rdatatype_format(type, b_type, sizeof(b_type));
|
|
|
|
|
2011-03-21 19:54:03 +00:00
|
|
|
if (key != NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
dst_key_format(key, b_key, sizeof(b_key));
|
2011-03-21 19:54:03 +00:00
|
|
|
tkey_token = dst_key_tkeytoken(key);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2010-12-18 23:47:11 +00:00
|
|
|
b_key[0] = 0;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
2011-03-21 19:54:03 +00:00
|
|
|
if (tkey_token != NULL) {
|
2010-12-18 01:56:23 +00:00
|
|
|
isc_buffer_region(tkey_token, &token_region);
|
|
|
|
token_len = token_region.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
MAYBE_LOCK(imp);
|
|
|
|
ret = imp->methods->ssumatch(b_signer, b_name, b_addr, b_type, b_key,
|
|
|
|
token_len,
|
2011-03-21 19:54:03 +00:00
|
|
|
token_len != 0 ? token_region.base : NULL,
|
2010-12-18 01:56:23 +00:00
|
|
|
imp->driverarg, dbdata);
|
|
|
|
MAYBE_UNLOCK(imp);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
static dns_dlzmethods_t sdlzmethods = { dns_sdlzcreate, dns_sdlzdestroy,
|
|
|
|
dns_sdlzfindzone, dns_sdlzallowzonexfr,
|
|
|
|
dns_sdlzconfigure, dns_sdlzssumatch };
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Public functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl,
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *data) {
|
|
|
|
dns_rdatalist_t *rdatalist;
|
|
|
|
dns_rdata_t *rdata;
|
|
|
|
dns_rdatatype_t typeval;
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_consttextregion_t r;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_buffer_t b;
|
|
|
|
isc_buffer_t *rdatabuf = NULL;
|
|
|
|
isc_lex_t *lex;
|
|
|
|
isc_result_t result;
|
|
|
|
unsigned int size;
|
|
|
|
isc_mem_t *mctx;
|
|
|
|
const dns_name_t *origin;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
REQUIRE(VALID_SDLZLOOKUP(lookup));
|
|
|
|
REQUIRE(type != NULL);
|
|
|
|
REQUIRE(data != NULL);
|
|
|
|
|
|
|
|
mctx = lookup->sdlz->common.mctx;
|
|
|
|
|
|
|
|
r.base = type;
|
|
|
|
r.length = strlen(type);
|
2020-02-12 13:59:18 +01:00
|
|
|
result = dns_rdatatype_fromtext(&typeval, (void *)&r);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
rdatalist = ISC_LIST_HEAD(lookup->lists);
|
|
|
|
while (rdatalist != NULL) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (rdatalist->type == typeval) {
|
2005-09-05 00:12:29 +00:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
rdatalist = ISC_LIST_NEXT(rdatalist, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rdatalist == NULL) {
|
|
|
|
rdatalist = isc_mem_get(mctx, sizeof(dns_rdatalist_t));
|
2015-03-03 16:43:42 +11:00
|
|
|
dns_rdatalist_init(rdatalist);
|
2005-09-05 00:12:29 +00:00
|
|
|
rdatalist->rdclass = lookup->sdlz->common.rdclass;
|
|
|
|
rdatalist->type = typeval;
|
|
|
|
rdatalist->ttl = ttl;
|
|
|
|
ISC_LIST_APPEND(lookup->lists, rdatalist, link);
|
2020-02-12 13:59:18 +01:00
|
|
|
} else if (rdatalist->ttl > ttl) {
|
|
|
|
/*
|
|
|
|
* BIND9 doesn't enforce all RRs in an RRset
|
|
|
|
* having the same TTL, as per RFC 2136,
|
|
|
|
* section 7.12. If a DLZ backend has
|
|
|
|
* different TTLs, then the best
|
|
|
|
* we can do is return the lowest.
|
|
|
|
*/
|
|
|
|
rdatalist->ttl = ttl;
|
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
|
|
|
|
dns_rdata_init(rdata);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((lookup->sdlz->dlzimp->flags & DNS_SDLZFLAG_RELATIVERDATA) != 0) {
|
2005-09-05 00:12:29 +00:00
|
|
|
origin = &lookup->sdlz->common.origin;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
origin = dns_rootname;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
lex = NULL;
|
|
|
|
result = isc_lex_create(mctx, 64, &lex);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
goto failure;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
size = initial_size(data);
|
|
|
|
do {
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&b, data, strlen(data));
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_add(&b, strlen(data));
|
|
|
|
|
|
|
|
result = isc_lex_openbuffer(lex, &b);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
goto failure;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
rdatabuf = NULL;
|
2020-02-02 08:35:46 +01:00
|
|
|
isc_buffer_allocate(mctx, &rdatabuf, size);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
result = dns_rdata_fromtext(rdata, rdatalist->rdclass,
|
2020-02-12 13:59:18 +01:00
|
|
|
rdatalist->type, lex, origin, false,
|
|
|
|
mctx, rdatabuf, &lookup->callbacks);
|
2018-10-08 12:47:28 +02:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_free(&rdatabuf);
|
2018-10-08 12:47:28 +02:00
|
|
|
result = DNS_R_SERVFAIL;
|
|
|
|
}
|
2020-02-13 21:48:23 +01:00
|
|
|
if (size >= 65535) {
|
2011-12-22 07:15:05 +00:00
|
|
|
break;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
size *= 2;
|
2020-02-13 21:48:23 +01:00
|
|
|
if (size >= 65535) {
|
2011-12-22 07:15:05 +00:00
|
|
|
size = 65535;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
} while (result == ISC_R_NOSPACE);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
goto failure;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
|
|
|
|
ISC_LIST_APPEND(lookup->buffers, rdatabuf, link);
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (lex != NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_lex_destroy(&lex);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
failure:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (rdatabuf != NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_free(&rdatabuf);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (lex != NULL) {
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_lex_destroy(&lex);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_sdlz_putnamedrr(dns_sdlzallnodes_t *allnodes, const char *name,
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *type, dns_ttl_t ttl, const char *data) {
|
|
|
|
dns_name_t *newname;
|
2016-12-30 15:45:08 +11:00
|
|
|
const dns_name_t *origin;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_fixedname_t fnewname;
|
|
|
|
dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)allnodes->common.db;
|
|
|
|
dns_sdlznode_t *sdlznode;
|
|
|
|
isc_mem_t *mctx = sdlz->common.mctx;
|
|
|
|
isc_buffer_t b;
|
|
|
|
isc_result_t result;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2018-03-28 14:38:09 +02:00
|
|
|
newname = dns_fixedname_initname(&fnewname);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((sdlz->dlzimp->flags & DNS_SDLZFLAG_RELATIVERDATA) != 0) {
|
2005-09-05 00:12:29 +00:00
|
|
|
origin = &sdlz->common.origin;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2005-09-05 00:12:29 +00:00
|
|
|
origin = dns_rootname;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&b, name, strlen(name));
|
2005-09-05 00:12:29 +00:00
|
|
|
isc_buffer_add(&b, strlen(name));
|
|
|
|
|
2009-09-01 00:22:28 +00:00
|
|
|
result = dns_name_fromtext(newname, &b, origin, 0, NULL);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
if (allnodes->common.relative_names) {
|
|
|
|
/* All names are relative to the root */
|
|
|
|
unsigned int nlabels = dns_name_countlabels(newname);
|
|
|
|
dns_name_getlabelsequence(newname, 0, nlabels - 1, newname);
|
|
|
|
}
|
|
|
|
|
|
|
|
sdlznode = ISC_LIST_HEAD(allnodes->nodelist);
|
|
|
|
if (sdlznode == NULL || !dns_name_equal(sdlznode->name, newname)) {
|
|
|
|
sdlznode = NULL;
|
|
|
|
result = createnode(sdlz, &sdlznode);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
sdlznode->name = isc_mem_get(mctx, sizeof(dns_name_t));
|
|
|
|
dns_name_init(sdlznode->name, NULL);
|
2019-11-01 08:31:13 -05:00
|
|
|
dns_name_dup(newname, mctx, sdlznode->name);
|
2005-09-05 00:12:29 +00:00
|
|
|
ISC_LIST_PREPEND(allnodes->nodelist, sdlznode, link);
|
|
|
|
if (allnodes->origin == NULL &&
|
2020-02-13 21:48:23 +01:00
|
|
|
dns_name_equal(newname, &sdlz->common.origin)) {
|
2005-09-05 00:12:29 +00:00
|
|
|
allnodes->origin = sdlznode;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
|
|
|
return (dns_sdlz_putrr(sdlznode, type, ttl, data));
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_sdlz_putsoa(dns_sdlzlookup_t *lookup, const char *mname, const char *rname,
|
2020-02-13 14:44:37 -08:00
|
|
|
uint32_t serial) {
|
2005-09-05 00:12:29 +00:00
|
|
|
char str[2 * DNS_NAME_MAXTEXT + 5 * (sizeof("2147483647")) + 7];
|
2020-02-13 14:44:37 -08:00
|
|
|
int n;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
REQUIRE(mname != NULL);
|
|
|
|
REQUIRE(rname != NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
n = snprintf(str, sizeof str, "%s %s %u %u %u %u %u", mname, rname,
|
|
|
|
serial, SDLZ_DEFAULT_REFRESH, SDLZ_DEFAULT_RETRY,
|
2005-09-05 00:12:29 +00:00
|
|
|
SDLZ_DEFAULT_EXPIRE, SDLZ_DEFAULT_MINIMUM);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (n >= (int)sizeof(str) || n < 0) {
|
2005-09-05 00:12:29 +00:00
|
|
|
return (ISC_R_NOSPACE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
return (dns_sdlz_putrr(lookup, "SOA", SDLZ_DEFAULT_TTL, str));
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_sdlzregister(const char *drivername, const dns_sdlzmethods_t *methods,
|
|
|
|
void *driverarg, unsigned int flags, isc_mem_t *mctx,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlzimplementation_t **sdlzimp) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Performs checks to make sure data is as we expect it to be.
|
|
|
|
*/
|
|
|
|
REQUIRE(drivername != NULL);
|
|
|
|
REQUIRE(methods != NULL);
|
|
|
|
REQUIRE(methods->findzone != NULL);
|
|
|
|
REQUIRE(methods->lookup != NULL);
|
|
|
|
REQUIRE(mctx != NULL);
|
|
|
|
REQUIRE(sdlzimp != NULL && *sdlzimp == NULL);
|
2020-02-12 13:59:18 +01:00
|
|
|
REQUIRE((flags &
|
|
|
|
~(DNS_SDLZFLAG_RELATIVEOWNER | DNS_SDLZFLAG_RELATIVERDATA |
|
|
|
|
DNS_SDLZFLAG_THREADSAFE)) == 0);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* Write debugging message to log */
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_DEBUG(2), "Registering SDLZ driver '%s'", drivername);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate memory for a sdlz_implementation object. Error if
|
|
|
|
* we cannot.
|
|
|
|
*/
|
|
|
|
imp = isc_mem_get(mctx, sizeof(dns_sdlzimplementation_t));
|
|
|
|
|
|
|
|
/* Make sure memory region is set to all 0's */
|
|
|
|
memset(imp, 0, sizeof(dns_sdlzimplementation_t));
|
|
|
|
|
|
|
|
/* Store the data passed into this method */
|
|
|
|
imp->methods = methods;
|
|
|
|
imp->driverarg = driverarg;
|
|
|
|
imp->flags = flags;
|
|
|
|
imp->mctx = NULL;
|
|
|
|
|
|
|
|
/* attach the new sdlz_implementation object to a memory context */
|
|
|
|
isc_mem_attach(mctx, &imp->mctx);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize the driver lock, error if we cannot
|
|
|
|
* (used if a driver does not support multiple threads)
|
|
|
|
*/
|
2018-11-16 15:33:22 +01:00
|
|
|
isc_mutex_init(&imp->driverlock);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
imp->dlz_imp = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* register the DLZ driver. Pass in our "extra" sdlz information as
|
|
|
|
* a driverarg. (that's why we stored the passed in driver arg in our
|
|
|
|
* sdlz_implementation structure) Also, store the dlz_implementation
|
|
|
|
* structure in our sdlz_implementation.
|
|
|
|
*/
|
|
|
|
result = dns_dlzregister(drivername, &sdlzmethods, imp, mctx,
|
|
|
|
&imp->dlz_imp);
|
|
|
|
|
|
|
|
/* if registration fails, cleanup and get outta here. */
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-09-05 00:12:29 +00:00
|
|
|
goto cleanup_mutex;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
*sdlzimp = imp;
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
cleanup_mutex:
|
2005-09-05 00:12:29 +00:00
|
|
|
/* destroy the driver lock, we don't need it anymore */
|
2018-11-19 10:31:09 +00:00
|
|
|
isc_mutex_destroy(&imp->driverlock);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* return the memory back to the available memory pool and
|
|
|
|
* remove it from the memory context.
|
|
|
|
*/
|
2019-07-23 17:16:57 -04:00
|
|
|
isc_mem_putanddetach(&imp->mctx, imp, sizeof(dns_sdlzimplementation_t));
|
2005-09-05 00:12:29 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_sdlzunregister(dns_sdlzimplementation_t **sdlzimp) {
|
2005-09-05 00:12:29 +00:00
|
|
|
dns_sdlzimplementation_t *imp;
|
|
|
|
|
|
|
|
/* Write debugging message to log */
|
2010-12-18 01:56:23 +00:00
|
|
|
sdlz_log(ISC_LOG_DEBUG(2), "Unregistering SDLZ driver.");
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Performs checks to make sure data is as we expect it to be.
|
|
|
|
*/
|
|
|
|
REQUIRE(sdlzimp != NULL && *sdlzimp != NULL);
|
|
|
|
|
|
|
|
imp = *sdlzimp;
|
2020-02-08 04:37:54 -08:00
|
|
|
*sdlzimp = NULL;
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/* Unregister the DLZ driver implementation */
|
|
|
|
dns_dlzunregister(&imp->dlz_imp);
|
|
|
|
|
|
|
|
/* destroy the driver lock, we don't need it anymore */
|
2018-11-19 10:31:09 +00:00
|
|
|
isc_mutex_destroy(&imp->driverlock);
|
2005-09-05 00:12:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* return the memory back to the available memory pool and
|
|
|
|
* remove it from the memory context.
|
|
|
|
*/
|
2019-07-23 17:16:57 -04:00
|
|
|
isc_mem_putanddetach(&imp->mctx, imp, sizeof(dns_sdlzimplementation_t));
|
2005-09-05 00:12:29 +00:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_sdlz_setdb(dns_dlzdb_t *dlzdatabase, dns_rdataclass_t rdclass,
|
2020-02-13 14:44:37 -08:00
|
|
|
const dns_name_t *name, dns_db_t **dbp) {
|
2010-12-18 01:56:23 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
result = dns_sdlzcreateDBP(dlzdatabase->mctx,
|
|
|
|
dlzdatabase->implementation->driverarg,
|
|
|
|
dlzdatabase->dbdata, name, rdclass, dbp);
|
|
|
|
return (result);
|
|
|
|
}
|