2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-28 21:17:54 +00:00

Revert accidental merge of unfinished DLZ work

This commit is contained in:
Evan Hunt 2012-03-05 14:44:21 -08:00
parent e214e8728a
commit 632c0f1e91
22 changed files with 109 additions and 313 deletions

View File

@ -798,7 +798,6 @@ query_getzonedb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
result = dns_zt_find(client->view->zonetable, name, ztoptions, NULL, result = dns_zt_find(client->view->zonetable, name, ztoptions, NULL,
&zone); &zone);
if (result == DNS_R_PARTIALMATCH) if (result == DNS_R_PARTIALMATCH)
partial = ISC_TRUE; partial = ISC_TRUE;
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
@ -1029,14 +1028,11 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
/* See how many labels are in the zone's name. */ /* See how many labels are in the zone's name. */
if (result == ISC_R_SUCCESS && zone != NULL) if (result == ISC_R_SUCCESS && zone != NULL)
zonelabels = dns_name_countlabels(dns_zone_getorigin(zone)); zonelabels = dns_name_countlabels(dns_zone_getorigin(zone));
/* /*
* If # zone labels < # name labels, try to find an even better match * If # zone labels < # name labels, try to find an even better match
* Only try if DLZ drivers are loaded for this view * Only try if a DLZ driver is loaded for this view
*/ */
if (zonelabels < namelabels && if (zonelabels < namelabels && client->view->dlzdatabase != NULL) {
!ISC_LIST_EMPTY(client->view->dlz_searched))
{
tresult = dns_dlzfindzone(client->view, name, tresult = dns_dlzfindzone(client->view, name,
zonelabels, &tdbp); zonelabels, &tdbp);
/* If we successful, we found a better match. */ /* If we successful, we found a better match. */

View File

@ -1347,7 +1347,7 @@ cache_sharable(dns_view_t *originview, dns_view_t *view,
* Callback from DLZ configure when the driver sets up a writeable zone * Callback from DLZ configure when the driver sets up a writeable zone
*/ */
static isc_result_t static isc_result_t
dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) { dlzconfigure_callback(dns_view_t *view, dns_zone_t *zone) {
dns_name_t *origin = dns_zone_getorigin(zone); dns_name_t *origin = dns_zone_getorigin(zone);
dns_rdataclass_t zclass = view->rdclass; dns_rdataclass_t zclass = view->rdclass;
isc_result_t result; isc_result_t result;
@ -1357,7 +1357,8 @@ dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) {
return (result); return (result);
dns_zone_setstats(zone, ns_g_server->zonestats); dns_zone_setstats(zone, ns_g_server->zonestats);
return (ns_zone_configure_writeable_dlz(dlzdb, zone, zclass, origin)); return (ns_zone_configure_writeable_dlz(view->dlzdatabase,
zone, zclass, origin));
} }
static isc_result_t static isc_result_t
@ -1568,7 +1569,6 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
const cfg_obj_t *forwarders; const cfg_obj_t *forwarders;
const cfg_obj_t *alternates; const cfg_obj_t *alternates;
const cfg_obj_t *zonelist; const cfg_obj_t *zonelist;
const cfg_obj_t *dlzlist;
const cfg_obj_t *dlz; const cfg_obj_t *dlz;
unsigned int dlzargc; unsigned int dlzargc;
char **dlzargv; char **dlzargv;
@ -1759,27 +1759,18 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
/* /*
* Create Dynamically Loadable Zone driver. * Create Dynamically Loadable Zone driver.
*/ */
dlzlist = NULL; dlz = NULL;
if (voptions != NULL) if (voptions != NULL)
(void)cfg_map_get(voptions, "dlz", &dlzlist); (void)cfg_map_get(voptions, "dlz", &dlz);
else else
(void)cfg_map_get(config, "dlz", &dlzlist); (void)cfg_map_get(config, "dlz", &dlz);
for (element = cfg_list_first(dlzlist); obj = NULL;
element != NULL; if (dlz != NULL) {
element = cfg_list_next(element)) (void)cfg_map_get(cfg_tuple_get(dlz, "options"),
{ "database", &obj);
obj = NULL;
const cfg_obj_t *dlzopts;
dlz = cfg_listelt_value(element);
dlzopts = cfg_tuple_get(dlz, "options");
(void)cfg_map_get(dlzopts, "database", &obj);
if (obj != NULL) { if (obj != NULL) {
dns_dlzdb_t *dlzdb = NULL;
const cfg_obj_t *name, *search = NULL;
char *s = isc_mem_strdup(mctx, cfg_obj_asstring(obj)); char *s = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
if (s == NULL) { if (s == NULL) {
result = ISC_R_NOMEMORY; result = ISC_R_NOMEMORY;
goto cleanup; goto cleanup;
@ -1791,10 +1782,10 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
goto cleanup; goto cleanup;
} }
name = cfg_tuple_get(dlz, "name"); obj = cfg_tuple_get(dlz, "name");
result = dns_dlzcreate(mctx, cfg_obj_asstring(name), result = dns_dlzcreate(mctx, cfg_obj_asstring(obj),
dlzargv[0], dlzargc, dlzargv, dlzargv[0], dlzargc, dlzargv,
&dlzdb); &view->dlzdatabase);
isc_mem_free(mctx, s); isc_mem_free(mctx, s);
isc_mem_put(mctx, dlzargv, dlzargc * sizeof(*dlzargv)); isc_mem_put(mctx, dlzargv, dlzargc * sizeof(*dlzargv));
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
@ -1804,19 +1795,9 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
* If the dlz backend supports configuration, * If the dlz backend supports configuration,
* then call its configure method now. * then call its configure method now.
*/ */
result = dns_dlzconfigure(view, dlzdb, result = dns_dlzconfigure(view, dlzconfigure_callback);
dlzconfigure_callback);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto cleanup; goto cleanup;
(void)cfg_map_get(dlzopts, "search", &search);
if (search == NULL || cfg_obj_asboolean(search))
ISC_LIST_APPEND(view->dlz_searched,
dlzdb, link);
else
ISC_LIST_APPEND(view->dlz_unsearched,
dlzdb, link);
} }
} }
@ -3482,8 +3463,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
signing = NULL; signing = NULL;
if ((strcasecmp(ztypestr, "master") == 0 || if ((strcasecmp(ztypestr, "master") == 0 ||
strcasecmp(ztypestr, "slave") == 0) && strcasecmp(ztypestr, "slave") == 0) &&
cfg_map_get(zoptions, "inline-signing", &signing) cfg_map_get(zoptions, "inline-signing", &signing) == ISC_R_SUCCESS &&
== ISC_R_SUCCESS &&
cfg_obj_asboolean(signing)) cfg_obj_asboolean(signing))
{ {
dns_zone_getraw(zone, &raw); dns_zone_getraw(zone, &raw);

View File

@ -449,9 +449,7 @@ dlopen_dlz_closeversion(const char *zone, isc_boolean_t commit,
* Called on startup to configure any writeable zones * Called on startup to configure any writeable zones
*/ */
static isc_result_t static isc_result_t
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, dlopen_dlz_configure(dns_view_t *view, void *driverarg, void *dbdata) {
void *driverarg, void *dbdata)
{
dlopen_data_t *cd = (dlopen_data_t *) dbdata; dlopen_data_t *cd = (dlopen_data_t *) dbdata;
isc_result_t result; isc_result_t result;
@ -462,7 +460,7 @@ dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
MAYBE_LOCK(cd); MAYBE_LOCK(cd);
cd->in_configure = ISC_TRUE; cd->in_configure = ISC_TRUE;
result = cd->dlz_configure(view, dlzdb, cd->dbdata); result = cd->dlz_configure(view, cd->dbdata);
cd->in_configure = ISC_FALSE; cd->in_configure = ISC_FALSE;
MAYBE_UNLOCK(cd); MAYBE_UNLOCK(cd);

View File

@ -807,8 +807,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
* Normal zone table does not have a match. * Normal zone table does not have a match.
* Try the DLZ database * Try the DLZ database
*/ */
// Temporary: only searching the first DLZ database if (client->view->dlzdatabase != NULL) {
if (! ISC_LIST_EMPTY(client->view->dlz_searched)) {
result = dns_dlzallowzonexfr(client->view, result = dns_dlzallowzonexfr(client->view,
question_name, question_name,
&client->peeraddr, &client->peeraddr,

View File

@ -801,11 +801,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
isc_sockaddr_t *addrs; isc_sockaddr_t *addrs;
dns_name_t **keynames; dns_name_t **keynames;
isc_uint32_t count; isc_uint32_t count;
char *cpval;
unsigned int dbargc; unsigned int dbargc;
char **dbargv; char **dbargv;
static char default_dbtype[] = "rbt"; static char default_dbtype[] = "rbt";
static char dlz_dbtype[] = "dlz";
char *cpval = default_dbtype;
isc_mem_t *mctx = dns_zone_getmctx(zone); isc_mem_t *mctx = dns_zone_getmctx(zone);
dns_dialuptype_t dialup = dns_dialuptype_no; dns_dialuptype_t dialup = dns_dialuptype_no;
dns_zonetype_t ztype; dns_zonetype_t ztype;
@ -868,28 +867,12 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
result = cfg_map_get(zoptions, "database", &obj); result = cfg_map_get(zoptions, "database", &obj);
if (result == ISC_R_SUCCESS) if (result == ISC_R_SUCCESS)
cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj)); cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
else
cpval = default_dbtype;
if (cpval == NULL) if (cpval == NULL)
return(ISC_R_NOMEMORY); return(ISC_R_NOMEMORY);
obj = NULL;
result = cfg_map_get(zoptions, "dlz", &obj);
if (result == ISC_R_SUCCESS) {
const char *dlzname = cfg_obj_asstring(obj);
size_t len;
if (cpval != default_dbtype) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
"zone '%s': both 'database' and 'dlz' "
"specified", zname);
return (ISC_R_FAILURE);
}
len = strlen(dlzname) + 5;
cpval = isc_mem_allocate(mctx, len);
snprintf(cpval, len, "dlz %s", dlzname);
}
result = strtoargv(mctx, cpval, &dbargc, &dbargv); result = strtoargv(mctx, cpval, &dbargc, &dbargv);
if (result != ISC_R_SUCCESS && cpval != default_dbtype) { if (result != ISC_R_SUCCESS && cpval != default_dbtype) {
isc_mem_free(mctx, cpval); isc_mem_free(mctx, cpval);
@ -903,7 +886,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
*/ */
result = dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv); result = dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv);
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv)); isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
if (cpval != default_dbtype && cpval != dlz_dbtype) if (cpval != default_dbtype)
isc_mem_free(mctx, cpval); isc_mem_free(mctx, cpval);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);

View File

@ -1,15 +0,0 @@
dlz one {
database "one";
};
dlz two {
database "two";
search no;
};
zone master {
type master;
database "none";
dlz two;
};

View File

@ -51,11 +51,5 @@ $CHECKCONF dnssec.3 2>&1 | grep '.*' && ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret` status=`expr $status + $ret`
echo "I: checking named-checkconf DLZ warnings"
ret=0
$CHECKCONF dlz-bad.conf 2>&1 | grep "'dlz' and 'database'" > /dev/null || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status" echo "I:exit status: $status"
exit $status exit $status

View File

@ -7,4 +7,3 @@ rm -f ns1/update.txt
rm -f */named.memstats rm -f */named.memstats
rm -f ns1/ddns.key rm -f ns1/ddns.key
rm -f random.data rm -f random.data
rm -f dig.out*

View File

@ -463,7 +463,7 @@ dlz_closeversion(const char *zone, isc_boolean_t commit,
* Configure a writeable zone * Configure a writeable zone
*/ */
isc_result_t isc_result_t
dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) { dlz_configure(dns_view_t *view, void *dbdata) {
struct dlz_example_data *state = (struct dlz_example_data *)dbdata; struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
isc_result_t result; isc_result_t result;
@ -475,7 +475,7 @@ dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) {
return (ISC_R_FAILURE); return (ISC_R_FAILURE);
} }
result = state->writeable_zone(view, dlzdb, state->zone_name); result = state->writeable_zone(view, state->zone_name);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
state->log(ISC_LOG_ERROR, state->log(ISC_LOG_ERROR,
"dlz_example: failed to configure zone %s", "dlz_example: failed to configure zone %s",

View File

@ -70,21 +70,4 @@ done
[ "$ret" -eq 0 ] || echo "I:failed" [ "$ret" -eq 0 ] || echo "I:failed"
status=`expr $status + $ret` status=`expr $status + $ret`
echo "I:testing multiple DLZ drivers"
test_update testdc1.alternate.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
status=`expr $status + $ret`
echo "I:testing AXFR from DLZ drivers"
$DIG $DIGOPTS +noall +answer axfr example.nil > dig.out.ns1.1
n=`cat dig.out.ns1.1 | wc -l`
[ "$n" -eq 7 ] || ret=1
$DIG $DIGOPTS +noall +answer axfr alternate.nil > dig.out.ns1.2
n=`cat dig.out.ns1.2 | wc -l`
[ "$n" -eq 5 ] || ret=1
status=`expr $status + $ret`
echo "I:testing unsearched DLZ driver"
$DIG $DIGOPTS +noall +answer ns other.nil > dig.out.ns1.3
cat dig.out.ns1.3
exit $status exit $status

View File

@ -466,8 +466,7 @@ dlz_configure(dns_view_t *view, void *dbdata) {
return (ISC_R_FAILURE); return (ISC_R_FAILURE);
} }
result = state->writeable_zone(view, view->dlzdatabase, result = state->writeable_zone(view, state->zone_name);
state->zone_name);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
state->log(ISC_LOG_ERROR, state->log(ISC_LOG_ERROR,
"dlz_example: failed to configure zone %s", "dlz_example: failed to configure zone %s",

View File

@ -1280,7 +1280,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
isc_buffer_t b; isc_buffer_t b;
isc_boolean_t root = ISC_FALSE; isc_boolean_t root = ISC_FALSE;
const cfg_listelt_t *element; const cfg_listelt_t *element;
isc_boolean_t dlz;
static optionstable options[] = { static optionstable options[] = {
{ "allow-query", MASTERZONE | SLAVEZONE | STUBZONE | REDIRECTZONE | { "allow-query", MASTERZONE | SLAVEZONE | STUBZONE | REDIRECTZONE |
@ -1702,24 +1701,11 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
* require file clauses. * require file clauses.
*/ */
obj = NULL; obj = NULL;
dlz = ISC_FALSE;
tresult = cfg_map_get(zoptions, "dlz", &obj);
if (tresult == ISC_R_SUCCESS)
dlz = ISC_TRUE;
obj = NULL;
tresult = cfg_map_get(zoptions, "database", &obj); tresult = cfg_map_get(zoptions, "database", &obj);
if (dlz && tresult == ISC_R_SUCCESS) { if (tresult == ISC_R_NOTFOUND ||
cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
"zone '%s': cannot specify both 'dlz' "
"and 'database'", znamestr);
result = ISC_R_FAILURE;
} else if (!dlz &&
(tresult == ISC_R_NOTFOUND ||
(tresult == ISC_R_SUCCESS && (tresult == ISC_R_SUCCESS &&
(strcmp("rbt", cfg_obj_asstring(obj)) == 0 || (strcmp("rbt", cfg_obj_asstring(obj)) == 0 ||
strcmp("rbt64", cfg_obj_asstring(obj)) == 0)))) strcmp("rbt64", cfg_obj_asstring(obj)) == 0))) {
{
obj = NULL; obj = NULL;
tresult = cfg_map_get(zoptions, "file", &obj); tresult = cfg_map_get(zoptions, "file", &obj);
if (tresult != ISC_R_SUCCESS && if (tresult != ISC_R_SUCCESS &&

View File

@ -60,11 +60,10 @@
#include <config.h> #include <config.h>
#include <dns/db.h>
#include <dns/dlz.h>
#include <dns/fixedname.h> #include <dns/fixedname.h>
#include <dns/log.h> #include <dns/log.h>
#include <dns/master.h> #include <dns/master.h>
#include <dns/dlz.h>
#include <dns/ssu.h> #include <dns/ssu.h>
#include <dns/zone.h> #include <dns/zone.h>
@ -114,41 +113,26 @@ isc_result_t
dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name, dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name,
isc_sockaddr_t *clientaddr, dns_db_t **dbp) isc_sockaddr_t *clientaddr, dns_db_t **dbp)
{ {
isc_result_t result = ISC_R_NOTFOUND; isc_result_t result;
dns_dlzallowzonexfr_t allowzonexfr; dns_dlzallowzonexfr_t allowzonexfr;
dns_dlzdb_t *dlzdb; dns_dlzdb_t *dlzdatabase;
/* /*
* Performs checks to make sure data is as we expect it to be. * Performs checks to make sure data is as we expect it to be.
*/ */
REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
REQUIRE(name != NULL); REQUIRE(name != NULL);
REQUIRE(dbp != NULL && *dbp == NULL); REQUIRE(dbp != NULL && *dbp == NULL);
/* /* ask driver if the zone is supported */
* Find a driver in which the zone exists and transfer is supported dlzdatabase = view->dlzdatabase;
*/ allowzonexfr = dlzdatabase->implementation->methods->allowzonexfr;
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched); result = (*allowzonexfr)(dlzdatabase->implementation->driverarg,
dlzdb != NULL; dlzdatabase->dbdata, dlzdatabase->mctx,
dlzdb = ISC_LIST_NEXT(dlzdb, link)) view->rdclass, name, clientaddr, dbp);
{
REQUIRE(DNS_DLZ_VALID(dlzdb));
allowzonexfr = dlzdb->implementation->methods->allowzonexfr;
result = (*allowzonexfr)(dlzdb->implementation->driverarg,
dlzdb->dbdata, dlzdb->mctx,
view->rdclass, name, clientaddr, dbp);
/*
* if ISC_R_NOPERM, we found the right database but
* the zone may not transfer.
*/
if (result == ISC_R_SUCCESS || result == ISC_R_NOPERM)
return (result);
}
if (result == ISC_R_NOTIMPLEMENTED) if (result == ISC_R_NOTIMPLEMENTED)
result = ISC_R_NOTFOUND; return (ISC_R_NOTFOUND);
return (result); return (result);
} }
@ -207,9 +191,6 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
(*dbp)->implementation = impinfo; (*dbp)->implementation = impinfo;
if (dlzname != NULL)
(*dbp)->dlzname = isc_mem_strdup(mctx, dlzname);
/* Create a new database using implementation 'drivername'. */ /* Create a new database using implementation 'drivername'. */
result = ((impinfo->methods->create)(mctx, dlzname, argc, argv, result = ((impinfo->methods->create)(mctx, dlzname, argc, argv,
impinfo->driverarg, impinfo->driverarg,
@ -257,12 +238,9 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
} }
#endif #endif
/* call the drivers destroy method */ /* call the drivers destroy method */
if ((*dbp) != NULL) { if ((*dbp) != NULL) {
mctx = (*dbp)->mctx; mctx = (*dbp)->mctx;
if ((*dbp)->dlzname != NULL)
isc_mem_free(mctx, (*dbp)->dlzname);
destroy = (*dbp)->implementation->methods->destroy; destroy = (*dbp)->implementation->methods->destroy;
(*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata); (*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata);
/* return memory */ /* return memory */
@ -275,8 +253,8 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
isc_result_t isc_result_t
dns_dlzfindzone(dns_view_t *view, dns_name_t *name, dns_dlzfindzone(dns_view_t *view, dns_name_t *name, unsigned int minlabels,
unsigned int minlabels, dns_db_t **dbp) dns_db_t **dbp)
{ {
dns_fixedname_t fname; dns_fixedname_t fname;
dns_name_t *zonename; dns_name_t *zonename;
@ -284,13 +262,12 @@ dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
unsigned int i; unsigned int i;
isc_result_t result; isc_result_t result;
dns_dlzfindzone_t findzone; dns_dlzfindzone_t findzone;
dns_dlzdb_t *dlzdb; dns_dlzdb_t *dlzdatabase;
dns_db_t *db, *best = NULL;
/* /*
* Performs checks to make sure data is as we expect it to be. * Performs checks to make sure data is as we expect it to be.
*/ */
REQUIRE(view != NULL); REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
REQUIRE(name != NULL); REQUIRE(name != NULL);
REQUIRE(dbp != NULL && *dbp == NULL); REQUIRE(dbp != NULL && *dbp == NULL);
@ -301,53 +278,33 @@ dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
/* count the number of labels in the name */ /* count the number of labels in the name */
namelabels = dns_name_countlabels(name); namelabels = dns_name_countlabels(name);
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched); /*
dlzdb != NULL; * loop through starting with the longest domain name and
dlzdb = ISC_LIST_NEXT(dlzdb, link)) * trying shorter names portions of the name until we find a
{ * match, have an error, or are below the 'minlabels'
REQUIRE(DNS_DLZ_VALID(dlzdb)); * threshold. minlabels is 0, if the standard database didn't
* have a zone name match. Otherwise minlabels is the number
* of labels in that name. We need to beat that for a
* "better" match for the DLZ database to be authoritative
* instead of the standard database.
*/
for (i = namelabels; i > minlabels && i > 1; i--) {
if (i == namelabels) {
result = dns_name_copy(name, zonename, NULL);
if (result != ISC_R_SUCCESS)
return (result);
} else
dns_name_split(name, i, NULL, zonename);
/* /* ask SDLZ driver if the zone is supported */
* loop through starting with the longest domain name and dlzdatabase = view->dlzdatabase;
* trying shorter names portions of the name until we find a findzone = dlzdatabase->implementation->methods->findzone;
* match, have an error, or are below the 'minlabels' result = (*findzone)(dlzdatabase->implementation->driverarg,
* threshold. minlabels is 0, if neither the standard dlzdatabase->dbdata, dlzdatabase->mctx,
* database nor any previous DLZ database had a zone name view->rdclass, zonename, dbp);
* match. Otherwise minlabels is the number of labels if (result != ISC_R_NOTFOUND)
* in that name. We need to beat that for a "better" return (result);
* match for this DLZ database to be authoritative.
*/
for (i = namelabels; i > minlabels && i > 1; i--) {
if (i == namelabels) {
result = dns_name_copy(name, zonename, NULL);
if (result != ISC_R_SUCCESS)
return (result);
} else
dns_name_split(name, i, NULL, zonename);
/* ask SDLZ driver if the zone is supported */
db = NULL;
findzone = dlzdb->implementation->methods->findzone;
result = (*findzone)(dlzdb->implementation->driverarg,
dlzdb->dbdata, dlzdb->mctx,
view->rdclass, zonename, &db);
if (result != ISC_R_NOTFOUND) {
if (best != NULL)
dns_db_detach(&best);
dns_db_attach(db, &best);
minlabels = i;
} else if (db != NULL)
dns_db_detach(&db);
}
} }
if (best != NULL) {
dns_db_attach(best, dbp);
dns_db_detach(&best);
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND); return (ISC_R_NOTFOUND);
} }
@ -571,19 +528,20 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp) {
* specific functionality on the zone * specific functionality on the zone
*/ */
isc_result_t isc_result_t
dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_dlz_writeablezone(dns_view_t *view, const char *zone_name) {
const char *zone_name)
{
dns_zone_t *zone = NULL; dns_zone_t *zone = NULL;
dns_zone_t *dupzone = NULL; dns_zone_t *dupzone = NULL;
isc_result_t result; isc_result_t result;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_fixedname_t fixorigin; dns_fixedname_t fixorigin;
dns_name_t *origin; dns_name_t *origin;
dns_dlzdb_t *dlzdatabase;
REQUIRE(DNS_DLZ_VALID(dlzdb)); REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
REQUIRE(dlzdb->configure_callback != NULL); dlzdatabase = view->dlzdatabase;
REQUIRE(dlzdatabase->configure_callback != NULL);
isc_buffer_init(&buffer, zone_name, strlen(zone_name)); isc_buffer_init(&buffer, zone_name, strlen(zone_name));
isc_buffer_add(&buffer, strlen(zone_name)); isc_buffer_add(&buffer, strlen(zone_name));
@ -614,15 +572,16 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
dns_zone_setadded(zone, ISC_TRUE); dns_zone_setadded(zone, ISC_TRUE);
if (dlzdb->ssutable == NULL) { if (dlzdatabase->ssutable == NULL) {
result = dns_ssutable_createdlz(dlzdb->mctx, result = dns_ssutable_createdlz(dlzdatabase->mctx,
&dlzdb->ssutable, dlzdb); &dlzdatabase->ssutable,
view->dlzdatabase);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto cleanup; goto cleanup;
} }
dns_zone_setssutable(zone, dlzdb->ssutable); dns_zone_setssutable(zone, dlzdatabase->ssutable);
result = dlzdb->configure_callback(view, dlzdb, zone); result = dlzdatabase->configure_callback(view, zone);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto cleanup; goto cleanup;
@ -644,31 +603,34 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
* the backend an opportunity to configure parameters related to DLZ. * the backend an opportunity to configure parameters related to DLZ.
*/ */
isc_result_t isc_result_t
dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_dlzconfigure(dns_view_t *view, isc_result_t (*callback)(dns_view_t *,
dlzconfigure_callback_t callback) dns_zone_t *))
{ {
dns_dlzimplementation_t *impl; dns_dlzimplementation_t *impl;
dns_dlzdb_t *dlzdatabase;
isc_result_t result; isc_result_t result;
REQUIRE(DNS_DLZ_VALID(dlzdb)); REQUIRE(view != NULL);
REQUIRE(dlzdb->implementation != NULL); REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
REQUIRE(view->dlzdatabase->implementation != NULL);
impl = dlzdb->implementation; dlzdatabase = view->dlzdatabase;
impl = dlzdatabase->implementation;
if (impl->methods->configure == NULL) if (impl->methods->configure == NULL)
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
dlzdb->configure_callback = callback; dlzdatabase->configure_callback = callback;
result = impl->methods->configure(impl->driverarg, dlzdb->dbdata, result = impl->methods->configure(impl->driverarg,
view, dlzdb); dlzdatabase->dbdata, view);
return (result); return (result);
} }
isc_boolean_t isc_boolean_t
dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase, dns_name_t *signer, dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase,
dns_name_t *name, isc_netaddr_t *tcpaddr, dns_name_t *signer, dns_name_t *name, isc_netaddr_t *tcpaddr,
dns_rdatatype_t type, const dst_key_t *key) dns_rdatatype_t type, const dst_key_t *key)
{ {
dns_dlzimplementation_t *impl; dns_dlzimplementation_t *impl;
isc_boolean_t r; isc_boolean_t r;

View File

@ -169,8 +169,7 @@ typedef isc_result_t
typedef isc_result_t typedef isc_result_t
(*dns_dlzconfigure_t)(void *driverarg, void *dbdata, (*dns_dlzconfigure_t)(void *driverarg, void *dbdata, dns_view_t *view);
dns_view_t *view, dns_dlzdb_t *dlzdb);
/*%< /*%<
* Method prototype. Drivers implementing the DLZ interface may * Method prototype. Drivers implementing the DLZ interface may
* optionally supply a configure method. If supplied, this will be * optionally supply a configure method. If supplied, this will be
@ -210,8 +209,7 @@ struct dns_dlzimplementation {
ISC_LINK(dns_dlzimplementation_t) link; ISC_LINK(dns_dlzimplementation_t) link;
}; };
typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_dlzdb_t *, typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_zone_t *);
dns_zone_t *);
/*% An instance of a DLZ driver */ /*% An instance of a DLZ driver */
struct dns_dlzdb { struct dns_dlzdb {
@ -220,8 +218,6 @@ struct dns_dlzdb {
dns_dlzimplementation_t *implementation; dns_dlzimplementation_t *implementation;
void *dbdata; void *dbdata;
dlzconfigure_callback_t configure_callback; dlzconfigure_callback_t configure_callback;
char *dlzname;
ISC_LINK(dns_dlzdb_t) link;
#ifdef BIND9 #ifdef BIND9
dns_ssutable_t *ssutable; dns_ssutable_t *ssutable;
#endif #endif
@ -323,7 +319,6 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp);
typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view, typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
dns_dlzdb_t *dlzdb,
const char *zone_name); const char *zone_name);
dns_dlz_writeablezone_t dns_dlz_writeablezone; dns_dlz_writeablezone_t dns_dlz_writeablezone;
/*%< /*%<
@ -333,8 +328,7 @@ dns_dlz_writeablezone_t dns_dlz_writeablezone;
isc_result_t isc_result_t
dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_dlzconfigure(dns_view_t *view, dlzconfigure_callback_t callback);
dlzconfigure_callback_t callback);
/*%< /*%<
* call a DLZ drivers configure method, if supplied * call a DLZ drivers configure method, if supplied
*/ */

View File

@ -115,7 +115,6 @@ typedef void dlz_dlopen_closeversion_t (const char *zone,
* want to support dynamic updates * want to support dynamic updates
*/ */
typedef isc_result_t dlz_dlopen_configure_t (dns_view_t *view, typedef isc_result_t dlz_dlopen_configure_t (dns_view_t *view,
dns_dlzdb_t *dlzdb,
void *dbdata); void *dbdata);
/* /*

View File

@ -227,9 +227,8 @@ typedef void (*dns_sdlzcloseversion_t)(const char *zone, isc_boolean_t commit,
* If the call is successful then *versionp should be set to NULL * If the call is successful then *versionp should be set to NULL
*/ */
typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view, typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view, void *driverarg,
dns_dlzdb_t *dlzdb, void *dbdata);
void *driverarg, void *dbdata);
/*%< /*%<
* Method prototype. Drivers implementing the SDLZ interface may * Method prototype. Drivers implementing the SDLZ interface may
* supply a configure method. When supplied, it will be called * supply a configure method. When supplied, it will be called

View File

@ -60,7 +60,6 @@ typedef struct dns_dbtable dns_dbtable_t;
typedef void dns_dbversion_t; typedef void dns_dbversion_t;
typedef struct dns_dlzimplementation dns_dlzimplementation_t; typedef struct dns_dlzimplementation dns_dlzimplementation_t;
typedef struct dns_dlzdb dns_dlzdb_t; typedef struct dns_dlzdb dns_dlzdb_t;
typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t;
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t; typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;
typedef struct dns_decompress dns_decompress_t; typedef struct dns_decompress dns_decompress_t;
typedef struct dns_dispatch dns_dispatch_t; typedef struct dns_dispatch dns_dispatch_t;

View File

@ -87,6 +87,7 @@ struct dns_view {
dns_rdataclass_t rdclass; dns_rdataclass_t rdclass;
char * name; char * name;
dns_zt_t * zonetable; dns_zt_t * zonetable;
dns_dlzdb_t * dlzdatabase;
dns_resolver_t * resolver; dns_resolver_t * resolver;
dns_adb_t * adb; dns_adb_t * adb;
dns_requestmgr_t * requestmgr; dns_requestmgr_t * requestmgr;
@ -161,8 +162,6 @@ struct dns_view {
dns_dns64list_t dns64; dns_dns64list_t dns64;
unsigned int dns64cnt; unsigned int dns64cnt;
ISC_LIST(dns_rpz_zone_t) rpz_zones; ISC_LIST(dns_rpz_zone_t) rpz_zones;
dns_dlzdblist_t dlz_searched;
dns_dlzdblist_t dlz_unsearched;
/* /*
* Configurable data for server use only, * Configurable data for server use only,

View File

@ -1672,8 +1672,7 @@ dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx,
static isc_result_t static isc_result_t
dns_sdlzconfigure(void *driverarg, void *dbdata, dns_sdlzconfigure(void *driverarg, void *dbdata, dns_view_t *view)
dns_view_t *view, dns_dlzdb_t *dlzdb)
{ {
isc_result_t result; isc_result_t result;
dns_sdlzimplementation_t *imp; dns_sdlzimplementation_t *imp;
@ -1685,8 +1684,7 @@ dns_sdlzconfigure(void *driverarg, void *dbdata,
/* Call SDLZ driver's configure method */ /* Call SDLZ driver's configure method */
if (imp->methods->configure != NULL) { if (imp->methods->configure != NULL) {
MAYBE_LOCK(imp); MAYBE_LOCK(imp);
result = imp->methods->configure(view, dlzdb, result = imp->methods->configure(view, imp->driverarg, dbdata);
imp->driverarg, dbdata);
MAYBE_UNLOCK(imp); MAYBE_UNLOCK(imp);
} else { } else {
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;

View File

@ -120,8 +120,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
view->acache = NULL; view->acache = NULL;
view->cache = NULL; view->cache = NULL;
view->cachedb = NULL; view->cachedb = NULL;
ISC_LIST_INIT(view->dlz_searched); view->dlzdatabase = NULL;
ISC_LIST_INIT(view->dlz_unsearched);
view->hints = NULL; view->hints = NULL;
view->resolver = NULL; view->resolver = NULL;
view->adb = NULL; view->adb = NULL;
@ -268,7 +267,6 @@ static inline void
destroy(dns_view_t *view) { destroy(dns_view_t *view) {
#ifdef BIND9 #ifdef BIND9
dns_dns64_t *dns64; dns_dns64_t *dns64;
dns_dlzdb_t *dlzdb;
#endif #endif
REQUIRE(!ISC_LINK_LINKED(view, link)); REQUIRE(!ISC_LINK_LINKED(view, link));
@ -330,23 +328,9 @@ destroy(dns_view_t *view) {
dns_acache_detach(&view->acache); dns_acache_detach(&view->acache);
} }
dns_rpz_view_destroy(view); dns_rpz_view_destroy(view);
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
dlzdb != NULL;
dlzdb = ISC_LIST_HEAD(view->dlz_searched)) {
ISC_LIST_UNLINK(view->dlz_searched, dlzdb, link);
dns_dlzdestroy(&dlzdb);
}
for (dlzdb = ISC_LIST_HEAD(view->dlz_unsearched);
dlzdb != NULL;
dlzdb = ISC_LIST_HEAD(view->dlz_unsearched)) {
ISC_LIST_UNLINK(view->dlz_unsearched, dlzdb, link);
dns_dlzdestroy(&dlzdb);
}
#else #else
INSIST(view->acache == NULL); INSIST(view->acache == NULL);
INSIST(ISC_LIST_EMPTY(view->rpz_zones)); INSIST(ISC_LIST_EMPTY(view->rpz_zones));
INSIST(ISC_LIST_EMPTY(view->dlz_searched));
INSIST(ISC_LIST_EMPTY(view->dlz_unsearched));
#endif #endif
if (view->requestmgr != NULL) if (view->requestmgr != NULL)
dns_requestmgr_detach(&view->requestmgr); dns_requestmgr_detach(&view->requestmgr);
@ -354,6 +338,8 @@ destroy(dns_view_t *view) {
isc_task_detach(&view->task); isc_task_detach(&view->task);
if (view->hints != NULL) if (view->hints != NULL)
dns_db_detach(&view->hints); dns_db_detach(&view->hints);
if (view->dlzdatabase != NULL)
dns_dlzdestroy(&view->dlzdatabase);
if (view->cachedb != NULL) if (view->cachedb != NULL)
dns_db_detach(&view->cachedb); dns_db_detach(&view->cachedb);
if (view->cache != NULL) if (view->cache != NULL)

View File

@ -45,7 +45,6 @@
#include <dns/callbacks.h> #include <dns/callbacks.h>
#include <dns/db.h> #include <dns/db.h>
#include <dns/dbiterator.h> #include <dns/dbiterator.h>
#include <dns/dlz.h>
#include <dns/dnssec.h> #include <dns/dnssec.h>
#include <dns/events.h> #include <dns/events.h>
#include <dns/journal.h> #include <dns/journal.h>
@ -1617,46 +1616,6 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
goto cleanup; goto cleanup;
} }
/*
* Zones associated with a DLZ don't need to be loaded either,
* but we need to associate the database with the zone object.
*/
if (strcmp(zone->db_argv[0], "dlz") == 0) {
dns_dlzdb_t *dlzdb;
dns_db_t *db = NULL;
dns_dlzfindzone_t findzone;
for (dlzdb = ISC_LIST_HEAD(zone->view->dlz_searched);
dlzdb != NULL;
dlzdb = ISC_LIST_NEXT(dlzdb, link))
{
INSIST(DNS_DLZ_VALID(dlzdb));
if (strcmp(zone->db_argv[1], dlzdb->dlzname) == 0)
break;
}
if (dlzdb == NULL) {
result = ISC_R_NOTFOUND;
goto cleanup;
}
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_write);
/* ask SDLZ driver if the zone is supported */
findzone = dlzdb->implementation->methods->findzone;
result = (*findzone)(dlzdb->implementation->driverarg,
dlzdb->dbdata, dlzdb->mctx,
zone->view->rdclass, &zone->origin, &db);
if (result != ISC_R_NOTFOUND) {
if (zone->db != NULL)
zone_detachdb(zone);
zone_attachdb(zone, db);
dns_db_detach(&db);
result = ISC_R_SUCCESS;
}
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_write);
goto cleanup;
}
if ((zone->type == dns_zone_slave || zone->type == dns_zone_stub || if ((zone->type == dns_zone_slave || zone->type == dns_zone_stub ||
(zone->type == dns_zone_redirect && zone->masters != NULL)) && (zone->type == dns_zone_redirect && zone->masters != NULL)) &&
rbt) { rbt) {

View File

@ -130,7 +130,6 @@ static cfg_type_t cfg_type_v4_aaaa;
static cfg_clausedef_t static cfg_clausedef_t
dynamically_loadable_zones_clauses[] = { dynamically_loadable_zones_clauses[] = {
{ "database", &cfg_type_astring, 0 }, { "database", &cfg_type_astring, 0 },
{ "search", &cfg_type_boolean, 0 },
{ NULL, NULL, 0 } { NULL, NULL, 0 }
}; };
@ -870,7 +869,8 @@ static cfg_clausedef_t
namedconf_or_view_clauses[] = { namedconf_or_view_clauses[] = {
{ "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI }, { "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },
{ "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI }, { "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI },
{ "dlz", &cfg_type_dynamically_loadable_zones, CFG_CLAUSEFLAG_MULTI }, /* only 1 DLZ per view allowed */
{ "dlz", &cfg_type_dynamically_loadable_zones, 0 },
{ "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI }, { "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI },
{ "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI }, { "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI },
{ "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI }, { "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI },
@ -1430,7 +1430,6 @@ zone_only_clauses[] = {
CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE }, CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE },
{ "update-policy", &cfg_type_updatepolicy, 0 }, { "update-policy", &cfg_type_updatepolicy, 0 },
{ "database", &cfg_type_astring, 0 }, { "database", &cfg_type_astring, 0 },
{ "dlz", &cfg_type_astring, 0 },
{ "delegation-only", &cfg_type_boolean, 0 }, { "delegation-only", &cfg_type_boolean, 0 },
/* /*
* Note that the format of the check-names option is different between * Note that the format of the check-names option is different between