From 632c0f1e91cd1884c6c9c7b51f7189a1e9c6ea17 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Mon, 5 Mar 2012 14:44:21 -0800 Subject: [PATCH] Revert accidental merge of unfinished DLZ work --- bin/named/query.c | 8 +- bin/named/server.c | 50 +++---- bin/named/unix/dlz_dlopen_driver.c | 6 +- bin/named/xfrout.c | 3 +- bin/named/zoneconf.c | 27 +--- bin/tests/system/checkconf/dlz-bad.conf | 15 --- bin/tests/system/checkconf/tests.sh | 6 - bin/tests/system/dlzexternal/clean.sh | 1 - bin/tests/system/dlzexternal/driver.c | 4 +- bin/tests/system/dlzexternal/tests.sh | 17 --- contrib/dlz/example/dlz_example.c | 3 +- lib/bind9/check.c | 18 +-- lib/dns/dlz.c | 170 +++++++++--------------- lib/dns/include/dns/dlz.h | 12 +- lib/dns/include/dns/dlz_dlopen.h | 1 - lib/dns/include/dns/sdlz.h | 5 +- lib/dns/include/dns/types.h | 1 - lib/dns/include/dns/view.h | 3 +- lib/dns/sdlz.c | 6 +- lib/dns/view.c | 20 +-- lib/dns/zone.c | 41 ------ lib/isccfg/namedconf.c | 5 +- 22 files changed, 109 insertions(+), 313 deletions(-) delete mode 100644 bin/tests/system/checkconf/dlz-bad.conf diff --git a/bin/named/query.c b/bin/named/query.c index 2c3838eb59..6bae511641 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -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, &zone); - if (result == DNS_R_PARTIALMATCH) partial = ISC_TRUE; 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. */ if (result == ISC_R_SUCCESS && zone != NULL) zonelabels = dns_name_countlabels(dns_zone_getorigin(zone)); - /* * 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 && - !ISC_LIST_EMPTY(client->view->dlz_searched)) - { + if (zonelabels < namelabels && client->view->dlzdatabase != NULL) { tresult = dns_dlzfindzone(client->view, name, zonelabels, &tdbp); /* If we successful, we found a better match. */ diff --git a/bin/named/server.c b/bin/named/server.c index 84262121b5..6921feb5c9 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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 */ 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_rdataclass_t zclass = view->rdclass; isc_result_t result; @@ -1357,7 +1357,8 @@ dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) { return (result); 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 @@ -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 *alternates; const cfg_obj_t *zonelist; - const cfg_obj_t *dlzlist; const cfg_obj_t *dlz; unsigned int dlzargc; 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. */ - dlzlist = NULL; + dlz = NULL; if (voptions != NULL) - (void)cfg_map_get(voptions, "dlz", &dlzlist); + (void)cfg_map_get(voptions, "dlz", &dlz); else - (void)cfg_map_get(config, "dlz", &dlzlist); + (void)cfg_map_get(config, "dlz", &dlz); - for (element = cfg_list_first(dlzlist); - element != NULL; - element = cfg_list_next(element)) - { - 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); + obj = NULL; + if (dlz != NULL) { + (void)cfg_map_get(cfg_tuple_get(dlz, "options"), + "database", &obj); 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)); - if (s == NULL) { result = ISC_R_NOMEMORY; goto cleanup; @@ -1791,10 +1782,10 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, goto cleanup; } - name = cfg_tuple_get(dlz, "name"); - result = dns_dlzcreate(mctx, cfg_obj_asstring(name), + obj = cfg_tuple_get(dlz, "name"); + result = dns_dlzcreate(mctx, cfg_obj_asstring(obj), dlzargv[0], dlzargc, dlzargv, - &dlzdb); + &view->dlzdatabase); isc_mem_free(mctx, s); isc_mem_put(mctx, dlzargv, dlzargc * sizeof(*dlzargv)); 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, * then call its configure method now. */ - result = dns_dlzconfigure(view, dlzdb, - dlzconfigure_callback); + result = dns_dlzconfigure(view, dlzconfigure_callback); if (result != ISC_R_SUCCESS) 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; if ((strcasecmp(ztypestr, "master") == 0 || strcasecmp(ztypestr, "slave") == 0) && - cfg_map_get(zoptions, "inline-signing", &signing) - == ISC_R_SUCCESS && + cfg_map_get(zoptions, "inline-signing", &signing) == ISC_R_SUCCESS && cfg_obj_asboolean(signing)) { dns_zone_getraw(zone, &raw); diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c index eb2e689501..626efc1822 100644 --- a/bin/named/unix/dlz_dlopen_driver.c +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -449,9 +449,7 @@ dlopen_dlz_closeversion(const char *zone, isc_boolean_t commit, * Called on startup to configure any writeable zones */ static isc_result_t -dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, - void *driverarg, void *dbdata) -{ +dlopen_dlz_configure(dns_view_t *view, void *driverarg, void *dbdata) { dlopen_data_t *cd = (dlopen_data_t *) dbdata; isc_result_t result; @@ -462,7 +460,7 @@ dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, MAYBE_LOCK(cd); 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; MAYBE_UNLOCK(cd); diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index 13a1befc12..70b7830541 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -807,8 +807,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) { * Normal zone table does not have a match. * Try the DLZ database */ - // Temporary: only searching the first DLZ database - if (! ISC_LIST_EMPTY(client->view->dlz_searched)) { + if (client->view->dlzdatabase != NULL) { result = dns_dlzallowzonexfr(client->view, question_name, &client->peeraddr, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 2f0f6f28e4..748d114229 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -801,11 +801,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, isc_sockaddr_t *addrs; dns_name_t **keynames; isc_uint32_t count; + char *cpval; unsigned int dbargc; char **dbargv; static char default_dbtype[] = "rbt"; - static char dlz_dbtype[] = "dlz"; - char *cpval = default_dbtype; isc_mem_t *mctx = dns_zone_getmctx(zone); dns_dialuptype_t dialup = dns_dialuptype_no; 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); if (result == ISC_R_SUCCESS) cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj)); + else + cpval = default_dbtype; + if (cpval == NULL) 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); if (result != ISC_R_SUCCESS && cpval != default_dbtype) { 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); isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv)); - if (cpval != default_dbtype && cpval != dlz_dbtype) + if (cpval != default_dbtype) isc_mem_free(mctx, cpval); if (result != ISC_R_SUCCESS) return (result); diff --git a/bin/tests/system/checkconf/dlz-bad.conf b/bin/tests/system/checkconf/dlz-bad.conf deleted file mode 100644 index ed5c6b2c90..0000000000 --- a/bin/tests/system/checkconf/dlz-bad.conf +++ /dev/null @@ -1,15 +0,0 @@ - -dlz one { - database "one"; -}; - -dlz two { - database "two"; - search no; -}; - -zone master { - type master; - database "none"; - dlz two; -}; diff --git a/bin/tests/system/checkconf/tests.sh b/bin/tests/system/checkconf/tests.sh index 39a65e6984..85c7cb8d5e 100644 --- a/bin/tests/system/checkconf/tests.sh +++ b/bin/tests/system/checkconf/tests.sh @@ -51,11 +51,5 @@ $CHECKCONF dnssec.3 2>&1 | grep '.*' && ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi 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" exit $status diff --git a/bin/tests/system/dlzexternal/clean.sh b/bin/tests/system/dlzexternal/clean.sh index f5fb8e4024..648dbcd739 100644 --- a/bin/tests/system/dlzexternal/clean.sh +++ b/bin/tests/system/dlzexternal/clean.sh @@ -7,4 +7,3 @@ rm -f ns1/update.txt rm -f */named.memstats rm -f ns1/ddns.key rm -f random.data -rm -f dig.out* diff --git a/bin/tests/system/dlzexternal/driver.c b/bin/tests/system/dlzexternal/driver.c index 19cba5bcc4..bbc9b5fe21 100644 --- a/bin/tests/system/dlzexternal/driver.c +++ b/bin/tests/system/dlzexternal/driver.c @@ -463,7 +463,7 @@ dlz_closeversion(const char *zone, isc_boolean_t commit, * Configure a writeable zone */ 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; isc_result_t result; @@ -475,7 +475,7 @@ dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) { 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) { state->log(ISC_LOG_ERROR, "dlz_example: failed to configure zone %s", diff --git a/bin/tests/system/dlzexternal/tests.sh b/bin/tests/system/dlzexternal/tests.sh index 5f88d6410b..062a49e1c0 100644 --- a/bin/tests/system/dlzexternal/tests.sh +++ b/bin/tests/system/dlzexternal/tests.sh @@ -70,21 +70,4 @@ done [ "$ret" -eq 0 ] || echo "I:failed" 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 diff --git a/contrib/dlz/example/dlz_example.c b/contrib/dlz/example/dlz_example.c index 97b0f3bf2f..0c44e64af4 100644 --- a/contrib/dlz/example/dlz_example.c +++ b/contrib/dlz/example/dlz_example.c @@ -466,8 +466,7 @@ dlz_configure(dns_view_t *view, void *dbdata) { return (ISC_R_FAILURE); } - result = state->writeable_zone(view, view->dlzdatabase, - state->zone_name); + result = state->writeable_zone(view, state->zone_name); if (result != ISC_R_SUCCESS) { state->log(ISC_LOG_ERROR, "dlz_example: failed to configure zone %s", diff --git a/lib/bind9/check.c b/lib/bind9/check.c index ee7c7c1e49..b2ec4499c0 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -1280,7 +1280,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, isc_buffer_t b; isc_boolean_t root = ISC_FALSE; const cfg_listelt_t *element; - isc_boolean_t dlz; static optionstable options[] = { { "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. */ 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); - if (dlz && tresult == ISC_R_SUCCESS) { - 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 || + if (tresult == ISC_R_NOTFOUND || (tresult == ISC_R_SUCCESS && (strcmp("rbt", cfg_obj_asstring(obj)) == 0 || - strcmp("rbt64", cfg_obj_asstring(obj)) == 0)))) - { + strcmp("rbt64", cfg_obj_asstring(obj)) == 0))) { obj = NULL; tresult = cfg_map_get(zoptions, "file", &obj); if (tresult != ISC_R_SUCCESS && diff --git a/lib/dns/dlz.c b/lib/dns/dlz.c index b4879769da..ba7d4230e3 100644 --- a/lib/dns/dlz.c +++ b/lib/dns/dlz.c @@ -60,11 +60,10 @@ #include -#include -#include #include #include #include +#include #include #include @@ -114,41 +113,26 @@ isc_result_t dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name, isc_sockaddr_t *clientaddr, dns_db_t **dbp) { - isc_result_t result = ISC_R_NOTFOUND; + isc_result_t result; 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. */ + REQUIRE(DNS_DLZ_VALID(view->dlzdatabase)); REQUIRE(name != NULL); REQUIRE(dbp != NULL && *dbp == NULL); - /* - * Find a driver in which the zone exists and transfer is supported - */ - for (dlzdb = ISC_LIST_HEAD(view->dlz_searched); - dlzdb != NULL; - dlzdb = ISC_LIST_NEXT(dlzdb, link)) - { - 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); - } + /* ask driver if the zone is supported */ + dlzdatabase = view->dlzdatabase; + allowzonexfr = dlzdatabase->implementation->methods->allowzonexfr; + result = (*allowzonexfr)(dlzdatabase->implementation->driverarg, + dlzdatabase->dbdata, dlzdatabase->mctx, + view->rdclass, name, clientaddr, dbp); if (result == ISC_R_NOTIMPLEMENTED) - result = ISC_R_NOTFOUND; - + return (ISC_R_NOTFOUND); return (result); } @@ -207,9 +191,6 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername, (*dbp)->implementation = impinfo; - if (dlzname != NULL) - (*dbp)->dlzname = isc_mem_strdup(mctx, dlzname); - /* Create a new database using implementation 'drivername'. */ result = ((impinfo->methods->create)(mctx, dlzname, argc, argv, impinfo->driverarg, @@ -257,12 +238,9 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) { } #endif - /* call the drivers destroy method */ if ((*dbp) != NULL) { mctx = (*dbp)->mctx; - if ((*dbp)->dlzname != NULL) - isc_mem_free(mctx, (*dbp)->dlzname); destroy = (*dbp)->implementation->methods->destroy; (*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata); /* return memory */ @@ -275,8 +253,8 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) { isc_result_t -dns_dlzfindzone(dns_view_t *view, dns_name_t *name, - unsigned int minlabels, dns_db_t **dbp) +dns_dlzfindzone(dns_view_t *view, dns_name_t *name, unsigned int minlabels, + dns_db_t **dbp) { dns_fixedname_t fname; dns_name_t *zonename; @@ -284,13 +262,12 @@ dns_dlzfindzone(dns_view_t *view, dns_name_t *name, unsigned int i; isc_result_t result; dns_dlzfindzone_t findzone; - dns_dlzdb_t *dlzdb; - dns_db_t *db, *best = NULL; + dns_dlzdb_t *dlzdatabase; /* * 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(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 */ namelabels = dns_name_countlabels(name); - for (dlzdb = ISC_LIST_HEAD(view->dlz_searched); - dlzdb != NULL; - dlzdb = ISC_LIST_NEXT(dlzdb, link)) - { - REQUIRE(DNS_DLZ_VALID(dlzdb)); + /* + * loop through starting with the longest domain name and + * trying shorter names portions of the name until we find a + * match, have an error, or are below the 'minlabels' + * 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); - /* - * loop through starting with the longest domain name and - * trying shorter names portions of the name until we find a - * match, have an error, or are below the 'minlabels' - * threshold. minlabels is 0, if neither the standard - * database nor any previous DLZ database had a zone name - * match. Otherwise minlabels is the number of labels - * in that name. We need to beat that for a "better" - * 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); - } + /* ask SDLZ driver if the zone is supported */ + dlzdatabase = view->dlzdatabase; + findzone = dlzdatabase->implementation->methods->findzone; + result = (*findzone)(dlzdatabase->implementation->driverarg, + dlzdatabase->dbdata, dlzdatabase->mctx, + view->rdclass, zonename, dbp); + if (result != ISC_R_NOTFOUND) + return (result); } - - if (best != NULL) { - dns_db_attach(best, dbp); - dns_db_detach(&best); - return (ISC_R_SUCCESS); - } - return (ISC_R_NOTFOUND); } @@ -571,19 +528,20 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp) { * specific functionality on the zone */ isc_result_t -dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb, - const char *zone_name) -{ +dns_dlz_writeablezone(dns_view_t *view, const char *zone_name) { dns_zone_t *zone = NULL; dns_zone_t *dupzone = NULL; isc_result_t result; isc_buffer_t buffer; dns_fixedname_t fixorigin; 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_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); - if (dlzdb->ssutable == NULL) { - result = dns_ssutable_createdlz(dlzdb->mctx, - &dlzdb->ssutable, dlzdb); + if (dlzdatabase->ssutable == NULL) { + result = dns_ssutable_createdlz(dlzdatabase->mctx, + &dlzdatabase->ssutable, + view->dlzdatabase); if (result != ISC_R_SUCCESS) 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) 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. */ isc_result_t -dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb, - dlzconfigure_callback_t callback) +dns_dlzconfigure(dns_view_t *view, isc_result_t (*callback)(dns_view_t *, + dns_zone_t *)) { dns_dlzimplementation_t *impl; + dns_dlzdb_t *dlzdatabase; isc_result_t result; - REQUIRE(DNS_DLZ_VALID(dlzdb)); - REQUIRE(dlzdb->implementation != NULL); + REQUIRE(view != 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) return (ISC_R_SUCCESS); - dlzdb->configure_callback = callback; + dlzdatabase->configure_callback = callback; - result = impl->methods->configure(impl->driverarg, dlzdb->dbdata, - view, dlzdb); + result = impl->methods->configure(impl->driverarg, + dlzdatabase->dbdata, view); return (result); } isc_boolean_t -dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase, dns_name_t *signer, - dns_name_t *name, isc_netaddr_t *tcpaddr, - dns_rdatatype_t type, const dst_key_t *key) +dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase, + dns_name_t *signer, dns_name_t *name, isc_netaddr_t *tcpaddr, + dns_rdatatype_t type, const dst_key_t *key) { dns_dlzimplementation_t *impl; isc_boolean_t r; diff --git a/lib/dns/include/dns/dlz.h b/lib/dns/include/dns/dlz.h index 08afe220f4..43de0740d3 100644 --- a/lib/dns/include/dns/dlz.h +++ b/lib/dns/include/dns/dlz.h @@ -169,8 +169,7 @@ typedef isc_result_t typedef isc_result_t -(*dns_dlzconfigure_t)(void *driverarg, void *dbdata, - dns_view_t *view, dns_dlzdb_t *dlzdb); +(*dns_dlzconfigure_t)(void *driverarg, void *dbdata, dns_view_t *view); /*%< * Method prototype. Drivers implementing the DLZ interface may * optionally supply a configure method. If supplied, this will be @@ -210,8 +209,7 @@ struct dns_dlzimplementation { ISC_LINK(dns_dlzimplementation_t) link; }; -typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_dlzdb_t *, - dns_zone_t *); +typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_zone_t *); /*% An instance of a DLZ driver */ struct dns_dlzdb { @@ -220,8 +218,6 @@ struct dns_dlzdb { dns_dlzimplementation_t *implementation; void *dbdata; dlzconfigure_callback_t configure_callback; - char *dlzname; - ISC_LINK(dns_dlzdb_t) link; #ifdef BIND9 dns_ssutable_t *ssutable; #endif @@ -323,7 +319,6 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp); typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view, - dns_dlzdb_t *dlzdb, const char *zone_name); dns_dlz_writeablezone_t dns_dlz_writeablezone; /*%< @@ -333,8 +328,7 @@ dns_dlz_writeablezone_t dns_dlz_writeablezone; isc_result_t -dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb, - dlzconfigure_callback_t callback); +dns_dlzconfigure(dns_view_t *view, dlzconfigure_callback_t callback); /*%< * call a DLZ drivers configure method, if supplied */ diff --git a/lib/dns/include/dns/dlz_dlopen.h b/lib/dns/include/dns/dlz_dlopen.h index 0d866936ec..c101a56919 100644 --- a/lib/dns/include/dns/dlz_dlopen.h +++ b/lib/dns/include/dns/dlz_dlopen.h @@ -115,7 +115,6 @@ typedef void dlz_dlopen_closeversion_t (const char *zone, * want to support dynamic updates */ typedef isc_result_t dlz_dlopen_configure_t (dns_view_t *view, - dns_dlzdb_t *dlzdb, void *dbdata); /* diff --git a/lib/dns/include/dns/sdlz.h b/lib/dns/include/dns/sdlz.h index f69809ae99..1e2baaed4c 100644 --- a/lib/dns/include/dns/sdlz.h +++ b/lib/dns/include/dns/sdlz.h @@ -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 */ -typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view, - dns_dlzdb_t *dlzdb, - void *driverarg, void *dbdata); +typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view, void *driverarg, + void *dbdata); /*%< * Method prototype. Drivers implementing the SDLZ interface may * supply a configure method. When supplied, it will be called diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index e674e5124e..caa334757d 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -60,7 +60,6 @@ typedef struct dns_dbtable dns_dbtable_t; typedef void dns_dbversion_t; typedef struct dns_dlzimplementation dns_dlzimplementation_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_decompress dns_decompress_t; typedef struct dns_dispatch dns_dispatch_t; diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index c84b64ef8c..51099d891d 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -87,6 +87,7 @@ struct dns_view { dns_rdataclass_t rdclass; char * name; dns_zt_t * zonetable; + dns_dlzdb_t * dlzdatabase; dns_resolver_t * resolver; dns_adb_t * adb; dns_requestmgr_t * requestmgr; @@ -161,8 +162,6 @@ struct dns_view { dns_dns64list_t dns64; unsigned int dns64cnt; ISC_LIST(dns_rpz_zone_t) rpz_zones; - dns_dlzdblist_t dlz_searched; - dns_dlzdblist_t dlz_unsearched; /* * Configurable data for server use only, diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 38b7eb4fe0..12b734ef1f 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -1672,8 +1672,7 @@ dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx, static isc_result_t -dns_sdlzconfigure(void *driverarg, void *dbdata, - dns_view_t *view, dns_dlzdb_t *dlzdb) +dns_sdlzconfigure(void *driverarg, void *dbdata, dns_view_t *view) { isc_result_t result; dns_sdlzimplementation_t *imp; @@ -1685,8 +1684,7 @@ dns_sdlzconfigure(void *driverarg, void *dbdata, /* Call SDLZ driver's configure method */ if (imp->methods->configure != NULL) { MAYBE_LOCK(imp); - result = imp->methods->configure(view, dlzdb, - imp->driverarg, dbdata); + result = imp->methods->configure(view, imp->driverarg, dbdata); MAYBE_UNLOCK(imp); } else { result = ISC_R_SUCCESS; diff --git a/lib/dns/view.c b/lib/dns/view.c index 0291c4428f..0c6c615189 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -120,8 +120,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, view->acache = NULL; view->cache = NULL; view->cachedb = NULL; - ISC_LIST_INIT(view->dlz_searched); - ISC_LIST_INIT(view->dlz_unsearched); + view->dlzdatabase = NULL; view->hints = NULL; view->resolver = NULL; view->adb = NULL; @@ -268,7 +267,6 @@ static inline void destroy(dns_view_t *view) { #ifdef BIND9 dns_dns64_t *dns64; - dns_dlzdb_t *dlzdb; #endif REQUIRE(!ISC_LINK_LINKED(view, link)); @@ -330,23 +328,9 @@ destroy(dns_view_t *view) { dns_acache_detach(&view->acache); } 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 INSIST(view->acache == NULL); INSIST(ISC_LIST_EMPTY(view->rpz_zones)); - INSIST(ISC_LIST_EMPTY(view->dlz_searched)); - INSIST(ISC_LIST_EMPTY(view->dlz_unsearched)); #endif if (view->requestmgr != NULL) dns_requestmgr_detach(&view->requestmgr); @@ -354,6 +338,8 @@ destroy(dns_view_t *view) { isc_task_detach(&view->task); if (view->hints != NULL) dns_db_detach(&view->hints); + if (view->dlzdatabase != NULL) + dns_dlzdestroy(&view->dlzdatabase); if (view->cachedb != NULL) dns_db_detach(&view->cachedb); if (view->cache != NULL) diff --git a/lib/dns/zone.c b/lib/dns/zone.c index de483511ad..efa188af4f 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -1617,46 +1616,6 @@ zone_load(dns_zone_t *zone, unsigned int flags) { 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 || (zone->type == dns_zone_redirect && zone->masters != NULL)) && rbt) { diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 34b0338326..90f87a4ebc 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -130,7 +130,6 @@ static cfg_type_t cfg_type_v4_aaaa; static cfg_clausedef_t dynamically_loadable_zones_clauses[] = { { "database", &cfg_type_astring, 0 }, - { "search", &cfg_type_boolean, 0 }, { NULL, NULL, 0 } }; @@ -870,7 +869,8 @@ static cfg_clausedef_t namedconf_or_view_clauses[] = { { "key", &cfg_type_key, 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 }, { "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI }, { "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI }, @@ -1430,7 +1430,6 @@ zone_only_clauses[] = { CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE }, { "update-policy", &cfg_type_updatepolicy, 0 }, { "database", &cfg_type_astring, 0 }, - { "dlz", &cfg_type_astring, 0 }, { "delegation-only", &cfg_type_boolean, 0 }, /* * Note that the format of the check-names option is different between