diff --git a/Makefile.in b/Makefile.in index 8193b8c8e..4dbda6796 100644 --- a/Makefile.in +++ b/Makefile.in @@ -79,14 +79,14 @@ EDIT = $(SED) \ TARGETS=nsd nsd-checkconf nsd-checkzone nsd-control nsd.conf.sample nsd-control-setup.sh MANUALS=nsd.8 nsd-checkconf.8 nsd-checkzone.8 nsd-control.8 nsd.conf.5 -COMMON_OBJ=answer.o axfr.o ixfr.o ixfrcreate.o buffer.o configlexer.o configparser.o dname.o dns.o edns.o iterated_hash.o lookup3.o namedb.o nsec3.o options.o packet.o query.o rbtree.o radtree.o rdata.o region-allocator.o rrl.o siphash.o tsig.o tsig-openssl.o udb.o udbradtree.o udbzone.o util.o bitset.o popen3.o proxy_protocol.o +COMMON_OBJ=answer.o axfr.o ixfr.o ixfrcreate.o buffer.o configlexer.o configparser.o dname.o dns.o edns.o iterated_hash.o lookup3.o namedb.o nsec3.o options.o packet.o query.o rbtree.o radtree.o rdata.o region-allocator.o rrl.o siphash.o tsig.o tsig-openssl.o udb.o util.o bitset.o popen3.o proxy_protocol.o XFRD_OBJ=xfrd-disk.o xfrd-notify.o xfrd-tcp.o xfrd.o remote.o $(DNSTAP_OBJ) NSD_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) difffile.o ipc.o mini_event.o netio.o nsd.o server.o dbaccess.o dbcreate.o zlexer.o zonec.o zparser.o verify.o ALL_OBJ=$(NSD_OBJ) nsd-checkconf.o nsd-checkzone.o nsd-control.o nsd-mem.o xfr-inspect.o NSD_CHECKCONF_OBJ=$(COMMON_OBJ) nsd-checkconf.o NSD_CHECKZONE_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) dbaccess.o dbcreate.o difffile.o ipc.o mini_event.o netio.o server.o zonec.o zparser.o zlexer.o nsd-checkzone.o verify.o NSD_CONTROL_OBJ=$(COMMON_OBJ) nsd-control.o -CUTEST_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) dbaccess.o dbcreate.o difffile.o ipc.o mini_event.o netio.o server.o verify.o zonec.o zparser.o zlexer.o cutest_dname.o cutest_dns.o cutest_iterated_hash.o cutest_run.o cutest_radtree.o cutest_rbtree.o cutest_namedb.o cutest_options.o cutest_region.o cutest_rrl.o cutest_udb.o cutest_udbrad.o cutest_util.o cutest_bitset.o cutest_popen3.o cutest_iter.o cutest_event.o cutest.o qtest.o +CUTEST_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) dbaccess.o dbcreate.o difffile.o ipc.o mini_event.o netio.o server.o verify.o zonec.o zparser.o zlexer.o cutest_dname.o cutest_dns.o cutest_iterated_hash.o cutest_run.o cutest_radtree.o cutest_rbtree.o cutest_namedb.o cutest_options.o cutest_region.o cutest_rrl.o cutest_udb.o cutest_util.o cutest_bitset.o cutest_popen3.o cutest_iter.o cutest_event.o cutest.o qtest.o NSD_MEM_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) dbaccess.o dbcreate.o difffile.o ipc.o mini_event.o netio.o verify.o server.o zonec.o zparser.o zlexer.o nsd-mem.o all: $(TARGETS) $(MANUALS) @@ -172,9 +172,6 @@ nsd-mem: $(NSD_MEM_OBJ) $(LIBOBJS) cutest: $(CUTEST_OBJ) $(LIBOBJS) popen3_echo $(LINK) -o $@ $(CUTEST_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS) -udb-inspect: udb-inspect.o $(COMMON_OBJ) zonec.o zparser.o zlexer.o $(LIBOBJS) - $(LINK) -o $@ udb-inspect.o $(COMMON_OBJ) zonec.o zparser.o zlexer.o $(LIBOBJS) $(LIBS) - xfr-inspect: xfr-inspect.o $(COMMON_OBJ) zonec.o zparser.o zlexer.o $(LIBOBJS) $(LINK) -o $@ xfr-inspect.o $(COMMON_OBJ) zonec.o zparser.o zlexer.o $(LIBOBJS) $(LIBS) @@ -193,7 +190,7 @@ audit: nsd nsd-checkconf nsd-checkzone nsd-control nsd-mem checksec ./checksec --file=nsd-mem clean: - rm -f *.o $(TARGETS) $(MANUALS) cutest popen3_echo udb-inspect xfr-inspect nsd-mem + rm -f *.o $(TARGETS) $(MANUALS) cutest popen3_echo xfr-inspect nsd-mem distclean: clean rm -f Makefile config.h config.log config.status dnstap/dnstap_config.h @@ -331,9 +328,6 @@ cutest.o: $(srcdir)/tpkg/cutest/cutest.c qtest.o: $(srcdir)/tpkg/cutest/qtest.c $(COMPILE) -c $(srcdir)/tpkg/cutest/qtest.c -udb-inspect.o: $(srcdir)/tpkg/cutest/udb-inspect.c - $(COMPILE) -c $(srcdir)/tpkg/cutest/udb-inspect.c - zlexer.c: $(srcdir)/zlexer.lex if test "$(LEX)" != ":"; then rm -f $@ ;\ echo '#include "config.h"' > $@ ;\ @@ -439,14 +433,14 @@ configparser.o: configparser.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/opti $(srcdir)/namedb.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/packet.h configparser.h dbaccess.o: $(srcdir)/dbaccess.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dns.h $(srcdir)/namedb.h $(srcdir)/dname.h \ $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/options.h $(srcdir)/rdata.h \ - $(srcdir)/udb.h $(srcdir)/udbradtree.h $(srcdir)/udbzone.h $(srcdir)/zonec.h $(srcdir)/nsec3.h $(srcdir)/difffile.h $(srcdir)/nsd.h $(srcdir)/edns.h \ + $(srcdir)/udb.h $(srcdir)/zonec.h $(srcdir)/nsec3.h $(srcdir)/difffile.h $(srcdir)/nsd.h $(srcdir)/edns.h \ $(srcdir)/bitset.h $(srcdir)/ixfr.h $(srcdir)/query.h $(srcdir)/packet.h $(srcdir)/tsig.h $(srcdir)/ixfrcreate.h dbcreate.o: $(srcdir)/dbcreate.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h \ - $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/udb.h $(srcdir)/udbradtree.h \ - $(srcdir)/udbzone.h $(srcdir)/options.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/ixfr.h $(srcdir)/query.h $(srcdir)/packet.h $(srcdir)/tsig.h + $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/udb.h \ + $(srcdir)/options.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/ixfr.h $(srcdir)/query.h $(srcdir)/packet.h $(srcdir)/tsig.h difffile.o: $(srcdir)/difffile.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/difffile.h $(srcdir)/rbtree.h \ $(srcdir)/region-allocator.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h \ - $(srcdir)/options.h $(srcdir)/udb.h $(srcdir)/xfrd-disk.h $(srcdir)/packet.h $(srcdir)/rdata.h $(srcdir)/udbzone.h $(srcdir)/udbradtree.h \ + $(srcdir)/options.h $(srcdir)/udb.h $(srcdir)/xfrd-disk.h $(srcdir)/packet.h $(srcdir)/rdata.h \ $(srcdir)/nsec3.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/rrl.h $(srcdir)/query.h $(srcdir)/tsig.h $(srcdir)/ixfr.h $(srcdir)/zonec.h dname.o: $(srcdir)/dname.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dns.h $(srcdir)/dname.h $(srcdir)/buffer.h \ $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/query.h $(srcdir)/namedb.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/nsd.h \ @@ -490,11 +484,11 @@ nsd-control.o: $(srcdir)/nsd-control.c config.h $(srcdir)/compat/cpuset.h $(srcd $(srcdir)/dns.h $(srcdir)/radtree.h nsd-mem.o: $(srcdir)/nsd-mem.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/nsd.h $(srcdir)/dns.h $(srcdir)/edns.h $(srcdir)/buffer.h \ $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/bitset.h $(srcdir)/tsig.h $(srcdir)/dname.h $(srcdir)/options.h $(srcdir)/rbtree.h \ - $(srcdir)/namedb.h $(srcdir)/radtree.h $(srcdir)/udb.h $(srcdir)/udbzone.h $(srcdir)/udbradtree.h + $(srcdir)/namedb.h $(srcdir)/radtree.h nsec3.o: $(srcdir)/nsec3.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/nsec3.h $(srcdir)/iterated_hash.h \ $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h \ $(srcdir)/rbtree.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/answer.h $(srcdir)/packet.h $(srcdir)/query.h $(srcdir)/tsig.h \ - $(srcdir)/udbzone.h $(srcdir)/udb.h $(srcdir)/udbradtree.h $(srcdir)/options.h + $(srcdir)/udb.h $(srcdir)/options.h options.o: $(srcdir)/options.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/options.h \ $(srcdir)/region-allocator.h $(srcdir)/rbtree.h $(srcdir)/query.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/util.h \ $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/packet.h $(srcdir)/tsig.h $(srcdir)/ixfr.h $(srcdir)/difffile.h \ @@ -532,12 +526,8 @@ tsig.o: $(srcdir)/tsig.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/tsig.h $(s $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/query.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h tsig-openssl.o: $(srcdir)/tsig-openssl.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/tsig-openssl.h \ $(srcdir)/region-allocator.h $(srcdir)/tsig.h $(srcdir)/buffer.h $(srcdir)/util.h $(srcdir)/dname.h -udb.o: $(srcdir)/udb.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udb.h $(srcdir)/lookup3.h $(srcdir)/util.h -udbradtree.o: $(srcdir)/udbradtree.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udbradtree.h $(srcdir)/udb.h \ +udb.o: $(srcdir)/udb.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udb.h $(srcdir)/lookup3.h $(srcdir)/util.h \ $(srcdir)/radtree.h -udbzone.o: $(srcdir)/udbzone.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udbzone.h $(srcdir)/udb.h $(srcdir)/dns.h \ - $(srcdir)/udbradtree.h $(srcdir)/util.h $(srcdir)/iterated_hash.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/region-allocator.h \ - $(srcdir)/difffile.h $(srcdir)/rbtree.h $(srcdir)/namedb.h $(srcdir)/radtree.h $(srcdir)/options.h util.o: $(srcdir)/util.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/util.h $(srcdir)/region-allocator.h $(srcdir)/dname.h \ $(srcdir)/buffer.h $(srcdir)/namedb.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/rdata.h $(srcdir)/zonec.h $(srcdir)/nsd.h $(srcdir)/edns.h \ $(srcdir)/bitset.h @@ -558,8 +548,8 @@ xfrd-notify.o: $(srcdir)/xfrd-notify.c config.h $(srcdir)/compat/cpuset.h $(srcd xfrd-tcp.o: $(srcdir)/xfrd-tcp.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/nsd.h $(srcdir)/dns.h $(srcdir)/edns.h \ $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/bitset.h $(srcdir)/xfrd-tcp.h $(srcdir)/xfrd.h $(srcdir)/rbtree.h \ $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/radtree.h $(srcdir)/options.h $(srcdir)/tsig.h $(srcdir)/packet.h $(srcdir)/xfrd-disk.h -xfr-inspect.o: $(srcdir)/xfr-inspect.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udbzone.h $(srcdir)/udb.h \ - $(srcdir)/dns.h $(srcdir)/udbradtree.h $(srcdir)/util.h $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/packet.h $(srcdir)/namedb.h \ +xfr-inspect.o: $(srcdir)/xfr-inspect.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udb.h \ + $(srcdir)/dns.h $(srcdir)/util.h $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/packet.h $(srcdir)/namedb.h \ $(srcdir)/dname.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/rdata.h $(srcdir)/difffile.h $(srcdir)/options.h zlexer.o: zlexer.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/zonec.h $(srcdir)/namedb.h $(srcdir)/dname.h \ $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h zparser.h @@ -609,7 +599,7 @@ cutest_iter.o: $(srcdir)/tpkg/cutest/cutest_iter.c config.h $(srcdir)/compat/cpu cutest_namedb.o: $(srcdir)/tpkg/cutest/cutest_namedb.c config.h $(srcdir)/compat/cpuset.h \ $(srcdir)/tpkg/cutest/cutest.h $(srcdir)/region-allocator.h $(srcdir)/options.h $(srcdir)/region-allocator.h \ $(srcdir)/rbtree.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/util.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/nsec3.h $(srcdir)/udb.h \ - $(srcdir)/udbzone.h $(srcdir)/udb.h $(srcdir)/udbradtree.h $(srcdir)/difffile.h $(srcdir)/namedb.h $(srcdir)/options.h $(srcdir)/zonec.h $(srcdir)/nsd.h \ + $(srcdir)/udb.h $(srcdir)/difffile.h $(srcdir)/namedb.h $(srcdir)/options.h $(srcdir)/zonec.h $(srcdir)/nsd.h \ $(srcdir)/edns.h $(srcdir)/bitset.h cutest_options.o: $(srcdir)/tpkg/cutest/cutest_options.c config.h $(srcdir)/compat/cpuset.h \ $(srcdir)/tpkg/cutest/cutest.h $(srcdir)/region-allocator.h $(srcdir)/options.h $(srcdir)/region-allocator.h \ @@ -632,8 +622,6 @@ cutest_run.o: $(srcdir)/tpkg/cutest/cutest_run.c config.h $(srcdir)/compat/cpuse $(srcdir)/util.h $(srcdir)/nsd.h $(srcdir)/dns.h $(srcdir)/edns.h $(srcdir)/buffer.h $(srcdir)/bitset.h cutest_udb.o: $(srcdir)/tpkg/cutest/cutest_udb.c config.h $(srcdir)/compat/cpuset.h \ $(srcdir)/tpkg/cutest/cutest.h $(srcdir)/udb.h -cutest_udbrad.o: $(srcdir)/tpkg/cutest/cutest_udbrad.c config.h $(srcdir)/compat/cpuset.h \ - $(srcdir)/tpkg/cutest/cutest.h $(srcdir)/udbradtree.h $(srcdir)/udb.h cutest_util.o: $(srcdir)/tpkg/cutest/cutest_util.c config.h $(srcdir)/compat/cpuset.h \ $(srcdir)/tpkg/cutest/cutest.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/xfrd-tcp.h $(srcdir)/xfrd.h \ $(srcdir)/rbtree.h $(srcdir)/region-allocator.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/util.h $(srcdir)/dns.h \ @@ -643,7 +631,3 @@ qtest.o: $(srcdir)/tpkg/cutest/qtest.c config.h $(srcdir)/compat/cpuset.h $(srcd $(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/query.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h \ $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/nsd.h $(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/packet.h $(srcdir)/tsig.h $(srcdir)/namedb.h \ $(srcdir)/util.h $(srcdir)/nsec3.h $(srcdir)/options.h $(srcdir)/packet.h $(srcdir)/dname.h $(srcdir)/rdata.h -udb-inspect.o: $(srcdir)/tpkg/cutest/udb-inspect.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/udb.h \ - $(srcdir)/udbradtree.h $(srcdir)/udb.h $(srcdir)/udbzone.h $(srcdir)/dns.h $(srcdir)/udbradtree.h $(srcdir)/util.h $(srcdir)/buffer.h \ - $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/packet.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/buffer.h $(srcdir)/radtree.h \ - $(srcdir)/rbtree.h $(srcdir)/rdata.h $(srcdir)/namedb.h $(srcdir)/difffile.h $(srcdir)/options.h diff --git a/configparser.y b/configparser.y index 8fcac17a6..5cf8dd546 100644 --- a/configparser.y +++ b/configparser.y @@ -281,7 +281,7 @@ server_option: | VAR_DEBUG_MODE boolean { cfg_parser->opt->debug_mode = $2; } | VAR_USE_SYSTEMD boolean - { /* ignored, deprecated */ } + { /* ignored, obsolete */ } | VAR_HIDE_VERSION boolean { cfg_parser->opt->hide_version = $2; } | VAR_HIDE_IDENTITY boolean @@ -297,14 +297,7 @@ server_option: | VAR_DO_IP6 boolean { cfg_parser->opt->do_ip6 = $2; } | VAR_DATABASE STRING - { - cfg_parser->opt->database = region_strdup(cfg_parser->opt->region, $2); - if(cfg_parser->opt->database[0] == 0 && - cfg_parser->opt->zonefiles_write == 0) - { - cfg_parser->opt->zonefiles_write = ZONEFILES_WRITE_INTERVAL; - } - } + { /* ignored, obsolete */ } | VAR_IDENTITY STRING { cfg_parser->opt->identity = region_strdup(cfg_parser->opt->region, $2); } | VAR_VERSION STRING @@ -387,7 +380,7 @@ server_option: | VAR_ZONELISTFILE STRING { cfg_parser->opt->zonelistfile = region_strdup(cfg_parser->opt->region, $2); } | VAR_DIFFFILE STRING - { /* ignored, deprecated */ } + { /* ignored, obsolete */ } | VAR_XFRDFILE STRING { cfg_parser->opt->xfrdfile = region_strdup(cfg_parser->opt->region, $2); } | VAR_XFRDIR STRING diff --git a/configure.ac b/configure.ac index a638c2c5e..6fe7682cf 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl sinclude(acx_nlnetlabs.m4) sinclude(dnstap/dnstap.m4) -AC_INIT([NSD],[4.7.1],[https://github.com/NLnetLabs/nsd/issues or nsd-bugs@nlnetlabs.nl]) +AC_INIT([NSD],[4.8.0],[https://github.com/NLnetLabs/nsd/issues or nsd-bugs@nlnetlabs.nl]) AC_CONFIG_HEADERS([config.h]) # @@ -96,20 +96,8 @@ AC_ARG_WITH([pidfile], AC_SUBST(pidfile) AC_DEFINE_UNQUOTED(PIDFILE, ["`eval echo $pidfile`"], [Pathname to the NSD pidfile]) -# -# Determine location of nsd.db -# -dbfile=${dbdir}/nsd.db AC_ARG_WITH([dbfile], - AS_HELP_STRING([--with-dbfile=path],[Pathname to the NSD database]), - [dbfile=$withval]) -AC_SUBST(dbfile) -AC_DEFINE_UNQUOTED(DBFILE, ["`eval echo $dbfile`"], [Pathname to the NSD database]) - -if test -n "$dbfile"; then - dbdir=`dirname $dbfile` -fi -AC_SUBST(dbdir) + AS_HELP_STRING([--with-dbfile=path],[Pathname to the NSD database (obsolete)]),[]) piddir=`dirname $pidfile` AC_SUBST(piddir) diff --git a/dbaccess.c b/dbaccess.c index da5d94003..5d979979c 100644 --- a/dbaccess.c +++ b/dbaccess.c @@ -24,8 +24,6 @@ #include "options.h" #include "rdata.h" #include "udb.h" -#include "udbradtree.h" -#include "udbzone.h" #include "zonec.h" #include "nsec3.h" #include "difffile.h" @@ -33,36 +31,15 @@ #include "ixfr.h" #include "ixfrcreate.h" -static time_t udb_time = 0; -static unsigned long udb_rrsets = 0; -static unsigned long udb_rrset_count = 0; - void namedb_close(struct namedb* db) { if(db) { - if(db->udb) { - udb_base_close(db->udb); - udb_base_free(db->udb); - db->udb = NULL; - } zonec_desetup_parser(); region_destroy(db->region); } } -void -namedb_close_udb(struct namedb* db) -{ - if(db) { - /* we cannot actually munmap the data, because other - * processes still need to access the udb, so cleanup the - * udb */ - udb_base_free_keep_mmap(db->udb); - db->udb = NULL; - } -} - void namedb_free_ixfr(struct namedb* db) { @@ -72,148 +49,6 @@ namedb_free_ixfr(struct namedb* db) } } -/** read rr */ -static void -read_rr(namedb_type* db, rr_type* rr, udb_ptr* urr, domain_type* domain) -{ - buffer_type buffer; - ssize_t c; - assert(udb_ptr_get_type(urr) == udb_chunk_type_rr); - rr->owner = domain; - rr->type = RR(urr)->type; - rr->klass = RR(urr)->klass; - rr->ttl = RR(urr)->ttl; - - buffer_create_from(&buffer, RR(urr)->wire, RR(urr)->len); - c = rdata_wireformat_to_rdata_atoms(db->region, db->domains, - rr->type, RR(urr)->len, &buffer, &rr->rdatas); - if(c == -1) { - /* safe on error */ - rr->rdata_count = 0; - rr->rdatas = NULL; - return; - } - rr->rdata_count = c; -} - -/** calculate rr count */ -static uint16_t -calculate_rr_count(udb_base* udb, udb_ptr* rrset) -{ - udb_ptr rr; - uint16_t num = 0; - udb_ptr_new(&rr, udb, &RRSET(rrset)->rrs); - while(rr.data) { - num++; - udb_ptr_set_rptr(&rr, udb, &RR(&rr)->next); - } - udb_ptr_unlink(&rr, udb); - return num; -} - -/** read rrset */ -static void -read_rrset(udb_base* udb, namedb_type* db, zone_type* zone, - domain_type* domain, udb_ptr* urrset) -{ - rrset_type* rrset; - udb_ptr urr; - unsigned i; - assert(udb_ptr_get_type(urrset) == udb_chunk_type_rrset); - /* if no RRs, do not create anything (robust) */ - if(RRSET(urrset)->rrs.data == 0) - return; - rrset = (rrset_type *) region_alloc(db->region, sizeof(rrset_type)); - rrset->zone = zone; - rrset->rr_count = calculate_rr_count(udb, urrset); - rrset->rrs = (rr_type *) region_alloc_array( - db->region, rrset->rr_count, sizeof(rr_type)); - /* add the RRs */ - udb_ptr_new(&urr, udb, &RRSET(urrset)->rrs); - for(i=0; irr_count; i++) { - read_rr(db, &rrset->rrs[i], &urr, domain); - udb_ptr_set_rptr(&urr, udb, &RR(&urr)->next); - } - udb_ptr_unlink(&urr, udb); - domain_add_rrset(domain, rrset); - if(domain == zone->apex) - apex_rrset_checks(db, rrset, domain); -} - -/** read one elem from db, of type domain_d */ -static void read_node_elem(udb_base* udb, namedb_type* db, - region_type* dname_region, zone_type* zone, struct domain_d* d) -{ - const dname_type* dname; - domain_type* domain; - udb_ptr urrset; - - dname = dname_make(dname_region, d->name, 0); - if(!dname) return; - domain = domain_table_insert(db->domains, dname); - assert(domain); /* domain_table_insert should always return non-NULL */ - - /* add rrsets */ - udb_ptr_init(&urrset, udb); - udb_ptr_set_rptr(&urrset, udb, &d->rrsets); - while(urrset.data) { - read_rrset(udb, db, zone, domain, &urrset); - udb_ptr_set_rptr(&urrset, udb, &RRSET(&urrset)->next); - - if(++udb_rrsets % ZONEC_PCT_COUNT == 0 && time(NULL) > udb_time + ZONEC_PCT_TIME) { - udb_time = time(NULL); - VERBOSITY(1, (LOG_INFO, "read %s %d %%", - zone->opts->name, - (int)(udb_rrsets*((unsigned long)100)/udb_rrset_count))); - } - } - region_free_all(dname_region); - udb_ptr_unlink(&urrset, udb); -} - -/** recurse read radix from disk. This radix tree is by domain name, so max of - * 256 depth, and thus the stack usage is small. */ -static void read_zone_recurse(udb_base* udb, namedb_type* db, - region_type* dname_region, zone_type* zone, struct udb_radnode_d* node) -{ - if(node->elem.data) { - /* pre-order process of node->elem, for radix tree this is - * also in-order processing (identical to order tree_next()) */ - read_node_elem(udb, db, dname_region, zone, (struct domain_d*) - ((char*)udb->base + node->elem.data)); - } - if(node->lookup.data) { - uint16_t i; - struct udb_radarray_d* a = (struct udb_radarray_d*) - ((char*)udb->base + node->lookup.data); - /* we do not care for what the exact radix key is, we want - * to add all of them and the read routine does not need - * the radix-key, it has it stored */ - for(i=0; ilen; i++) { - if(a->array[i].node.data) { - read_zone_recurse(udb, db, dname_region, zone, - (struct udb_radnode_d*)((char*)udb->base + - a->array[i].node.data)); - } - } - } -} - -/** read zone data */ -static void -read_zone_data(udb_base* udb, namedb_type* db, region_type* dname_region, - udb_ptr* z, zone_type* zone) -{ - udb_ptr dtree; - /* recursively read domains, we only read so ptrs stay valid */ - udb_ptr_new(&dtree, udb, &ZONE(z)->domains); - if(RADTREE(&dtree)->root.data) - read_zone_recurse(udb, db, dname_region, zone, - (struct udb_radnode_d*) - ((char*)udb->base + RADTREE(&dtree)->root.data)); - udb_ptr_unlink(&dtree, udb); -} - /** create a zone */ zone_type* namedb_zone_create(namedb_type* db, const dname_type* dname, @@ -294,103 +129,8 @@ namedb_zone_delete(namedb_type* db, zone_type* zone) region_recycle(db->region, zone, sizeof(zone_type)); } -#ifdef HAVE_MMAP -/** read a zone */ -static void -read_zone(udb_base* udb, namedb_type* db, struct nsd_options* opt, - region_type* dname_region, udb_ptr* z) -{ - /* construct dname */ - const dname_type* dname = dname_make(dname_region, ZONE(z)->name, 0); - struct zone_options* zo = dname?zone_options_find(opt, dname):NULL; - zone_type* zone; - if(!dname) return; - if(!zo) { - /* deleted from the options, remove it from the nsd.db too */ - VERBOSITY(2, (LOG_WARNING, "zone %s is deleted", - dname_to_string(dname, NULL))); - udb_zone_delete(udb, z); - region_free_all(dname_region); - return; - } - assert(udb_ptr_get_type(z) == udb_chunk_type_zone); - udb_rrsets = 0; - udb_rrset_count = ZONE(z)->rrset_count; - zone = namedb_zone_create(db, dname, zo); - region_free_all(dname_region); - read_zone_data(udb, db, dname_region, z, zone); - zone->is_changed = (ZONE(z)->is_changed != 0); -#ifdef NSEC3 - prehash_zone_complete(db, zone); -#endif -} -#endif /* HAVE_MMAP */ - -#ifdef HAVE_MMAP -/** read zones from nsd.db */ -static void -read_zones(udb_base* udb, namedb_type* db, struct nsd_options* opt, - region_type* dname_region) -{ - udb_ptr ztree, n, z; - udb_ptr_init(&z, udb); - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - udb_radix_first(udb,&ztree,&n); - udb_time = time(NULL); - while(n.data) { - udb_ptr_set_rptr(&z, udb, &RADNODE(&n)->elem); - udb_radix_next(udb, &n); /* store in case n is deleted */ - read_zone(udb, db, opt, dname_region, &z); - udb_ptr_zero(&z, udb); - if(nsd.signal_hint_shutdown) break; - } - udb_ptr_unlink(&ztree, udb); - udb_ptr_unlink(&n, udb); - udb_ptr_unlink(&z, udb); -} -#endif /* HAVE_MMAP */ - -#ifdef HAVE_MMAP -/** try to read the udb file or fail */ -static int -try_read_udb(namedb_type* db, int fd, const char* filename, - struct nsd_options* opt) -{ - /* - * Temporary region used while loading domain names from the - * database. The region is freed after each time a dname is - * read from the database. - */ - region_type* dname_region; - - assert(fd != -1); - if(!(db->udb=udb_base_create_fd(filename, fd, &namedb_walkfunc, - NULL))) { - /* fd is closed by failed udb create call */ - VERBOSITY(1, (LOG_ERR, "can not use %s, " - "will create anew", filename)); - return 0; - } - /* sanity check if can be opened */ - if(udb_base_get_userflags(db->udb) != 0) { - log_msg(LOG_ERR, "%s was not closed properly, it might " - "be corrupted, will create anew", filename); - udb_base_free(db->udb); - db->udb = NULL; - return 0; - } - /* read if it can be opened */ - dname_region = region_create(xalloc, free); - /* this operation does not fail, we end up with - * something, even if that is an empty namedb */ - read_zones(db->udb, db, opt, dname_region); - region_destroy(dname_region); - return 1; -} -#endif /* HAVE_MMAP */ - struct namedb * -namedb_open (const char* filename, struct nsd_options* opt) +namedb_open (struct nsd_options* opt) { namedb_type* db; @@ -399,7 +139,8 @@ namedb_open (const char* filename, struct nsd_options* opt) * freed in namedb_close. */ region_type* db_region; - int fd; + + (void)opt; #ifdef USE_MMAP_ALLOC db_region = region_create_custom(mmap_alloc, mmap_free, MMAP_ALLOC_CHUNK_SIZE, @@ -417,54 +158,12 @@ namedb_open (const char* filename, struct nsd_options* opt) zonec_setup_parser(db); if (gettimeofday(&(db->diff_timestamp), NULL) != 0) { - log_msg(LOG_ERR, "unable to load %s: cannot initialize" - "timestamp", filename); + log_msg(LOG_ERR, "unable to load namedb: cannot initialize timestamp"); region_destroy(db_region); return NULL; - } - - /* in dbless mode there is no file to read or mmap */ - if(filename == NULL || filename[0] == 0) { - db->udb = NULL; - return db; } -#ifndef HAVE_MMAP - /* no mmap() system call, use dbless mode */ - VERBOSITY(1, (LOG_INFO, "no mmap(), ignoring database %s", filename)); - db->udb = NULL; - (void)fd; (void)opt; - return db; -#else /* HAVE_MMAP */ - - /* attempt to open, if does not exist, create a new one */ - fd = open(filename, O_RDWR); - if(fd == -1) { - if(errno != ENOENT) { - log_msg(LOG_ERR, "%s: %s", filename, strerror(errno)); - region_destroy(db_region); - return NULL; - } - } - /* attempt to read the file (if it exists) */ - if(fd != -1) { - if(!try_read_udb(db, fd, filename, opt)) - fd = -1; - } - /* attempt to create the file (if necessary or failed read) */ - if(fd == -1) { - if(!(db->udb=udb_base_create_new(filename, &namedb_walkfunc, - NULL))) { - region_destroy(db_region); - return NULL; - } - if(!udb_dns_init_file(db->udb)) { - region_destroy(db->region); - return NULL; - } - } return db; -#endif /* HAVE_MMAP */ } /** get the file mtime stat (or nonexist or error) */ @@ -527,15 +226,6 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb, } else { const char* zone_fname = zone->filename; struct timespec zone_mtime = zone->mtime; - if(nsd->db->udb) { - zone_fname = udb_zone_get_file_str(nsd->db->udb, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size); - udb_zone_get_mtime(nsd->db->udb, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size, - &zone_mtime); - } /* if no zone_fname, then it was acquired in zone transfer, * see if the file is newer than the zone transfer * (regardless if this is a different file), because the @@ -582,60 +272,29 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb, zone->nsec3_param = NULL; #endif delete_zone_rrs(nsd->db, zone); - if(nsd->db->udb) { - region_type* dname_region; - udb_ptr z; - /* see if we can revert to the udb stored version */ - if(!udb_zone_search(nsd->db->udb, &z, dname_name(domain_dname( - zone->apex)), domain_dname(zone->apex)->name_size)) { - /* tell that zone contents has been lost */ - if(taskudb) task_new_soainfo(taskudb, last_task, zone, 0); - ixfr_create_cancel(ixfrcr); - return; - } - /* read from udb */ - dname_region = region_create(xalloc, free); - udb_rrsets = 0; - udb_rrset_count = ZONE(&z)->rrset_count; - udb_time = time(NULL); - read_zone_data(nsd->db->udb, nsd->db, dname_region, &z, zone); - region_destroy(dname_region); - udb_ptr_unlink(&z, nsd->db->udb); - } else { - if(zone->filename) - region_recycle(nsd->db->region, zone->filename, - strlen(zone->filename)+1); - zone->filename = NULL; - if(zone->logstr) - region_recycle(nsd->db->region, zone->logstr, - strlen(zone->logstr)+1); - zone->logstr = NULL; - } + if(zone->filename) + region_recycle(nsd->db->region, zone->filename, + strlen(zone->filename)+1); + zone->filename = NULL; + if(zone->logstr) + region_recycle(nsd->db->region, zone->logstr, + strlen(zone->logstr)+1); + zone->logstr = NULL; } else { VERBOSITY(1, (LOG_INFO, "zone %s read with success", zone->opts->name)); zone->is_ok = 1; zone->is_changed = 0; /* store zone into udb */ - if(nsd->db->udb) { - if(!write_zone_to_udb(nsd->db->udb, zone, &mtime, - fname)) { - log_msg(LOG_ERR, "failed to store zone in db"); - } else { - VERBOSITY(2, (LOG_INFO, "zone %s written to db", - zone->opts->name)); - } - } else { - zone->mtime = mtime; - if(zone->filename) - region_recycle(nsd->db->region, zone->filename, - strlen(zone->filename)+1); - zone->filename = region_strdup(nsd->db->region, fname); - if(zone->logstr) - region_recycle(nsd->db->region, zone->logstr, - strlen(zone->logstr)+1); - zone->logstr = NULL; - } + zone->mtime = mtime; + if(zone->filename) + region_recycle(nsd->db->region, zone->filename, + strlen(zone->filename)+1); + zone->filename = region_strdup(nsd->db->region, fname); + if(zone->logstr) + region_recycle(nsd->db->region, zone->logstr, + strlen(zone->logstr)+1); + zone->logstr = NULL; if(ixfr_create_already_done) { ixfr_readup_exist(zone, nsd, fname); } else if(ixfrcr) { diff --git a/dbcreate.c b/dbcreate.c index 31b6b0c9b..ceff916aa 100644 --- a/dbcreate.c +++ b/dbcreate.c @@ -19,8 +19,6 @@ #include "namedb.h" #include "udb.h" -#include "udbradtree.h" -#include "udbzone.h" #include "options.h" #include "nsd.h" #include "ixfr.h" @@ -66,121 +64,6 @@ rr_marshal_rdata(rr_type* rr, uint8_t* rdata, size_t sz) return len; } -/** delete an RR */ -void -udb_del_rr(udb_base* udb, udb_ptr* z, rr_type* rr) -{ - /* marshal the rdata (uncompressed) into a buffer */ - uint8_t rdata[MAX_RDLENGTH]; - size_t rdatalen = rr_marshal_rdata(rr, rdata, sizeof(rdata)); - assert(udb); - udb_zone_del_rr(udb, z, dname_name(domain_dname(rr->owner)), - domain_dname(rr->owner)->name_size, rr->type, rr->klass, - rdata, rdatalen); -} - -/** write rr */ -int -udb_write_rr(udb_base* udb, udb_ptr* z, rr_type* rr) -{ - /* marshal the rdata (uncompressed) into a buffer */ - uint8_t rdata[MAX_RDLENGTH]; - size_t rdatalen = 0; - unsigned i; - assert(rr); - for(i=0; irdata_count; i++) { - rdatalen += add_rdata(rr, i, rdata+rdatalen, - sizeof(rdata)-rdatalen); - } - assert(udb); - return udb_zone_add_rr(udb, z, dname_name(domain_dname(rr->owner)), - domain_dname(rr->owner)->name_size, rr->type, rr->klass, - rr->ttl, rdata, rdatalen); -} - -/** write rrset */ -static int -write_rrset(udb_base* udb, udb_ptr* z, rrset_type* rrset) -{ - unsigned i; - for(i=0; irr_count; i++) { - if(!udb_write_rr(udb, z, &rrset->rrs[i])) - return 0; - } - return 1; -} - -/** write a zone */ -static int -write_zone(udb_base* udb, udb_ptr* z, zone_type* zone) -{ - /* write all domains in the zone */ - domain_type* walk; - rrset_type* rrset; - unsigned long n = 0, c = 0; - time_t t = time(NULL); - - /* count domains: for pct logging */ - for(walk=zone->apex; walk && domain_is_subdomain(walk, zone->apex); - walk=domain_next(walk)) { - n++; - } - /* write them */ - for(walk=zone->apex; walk && domain_is_subdomain(walk, zone->apex); - walk=domain_next(walk)) { - /* write all rrsets (in the zone) for this domain */ - for(rrset=walk->rrsets; rrset; rrset=rrset->next) { - if(rrset->zone == zone) { - if(!write_rrset(udb, z, rrset)) - return 0; - } - } - /* only check every ... domains, and print pct */ - if(++c % ZONEC_PCT_COUNT == 0 && time(NULL) > t + ZONEC_PCT_TIME) { - t = time(NULL); - VERBOSITY(1, (LOG_INFO, "write %s %d %%", - zone->opts->name, (n==0)?0:(int)(c*((unsigned long)100)/n))); - } - } - return 1; -} - -/** create and write a zone */ -int -write_zone_to_udb(udb_base* udb, zone_type* zone, struct timespec* mtime, - const char* file_str) -{ - udb_ptr z; - /* make udb dirty */ - udb_base_set_userflags(udb, 1); - /* find or create zone */ - if(udb_zone_search(udb, &z, dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) { - /* wipe existing contents */ - udb_zone_clear(udb, &z); - } else { - if(!udb_zone_create(udb, &z, dname_name(domain_dname( - zone->apex)), domain_dname(zone->apex)->name_size)) { - udb_base_set_userflags(udb, 0); - return 0; - } - } - /* set mtime */ - ZONE(&z)->mtime = (uint64_t)mtime->tv_sec; - ZONE(&z)->mtime_nsec = (uint64_t)mtime->tv_nsec; - ZONE(&z)->is_changed = 0; - udb_zone_set_log_str(udb, &z, NULL); - udb_zone_set_file_str(udb, &z, file_str); - /* write zone */ - if(!write_zone(udb, &z, zone)) { - udb_base_set_userflags(udb, 0); - return 0; - } - udb_ptr_unlink(&z, udb); - udb_base_set_userflags(udb, 0); - return 1; -} - int print_rrs(FILE* out, struct zone* zone) { @@ -354,36 +237,21 @@ namedb_write_zonefile(struct nsd* nsd, struct zone_options* zopt) char logs[4096]; char bakfile[4096]; struct timespec mtime; - udb_ptr zudb; - if(nsd->db->udb) { - if(!udb_zone_search(nsd->db->udb, &zudb, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) - return; /* zone does not exist in db */ - } /* write to zfile~ first, then rename if that works */ snprintf(bakfile, sizeof(bakfile), "%s~", zfile); - if(nsd->db->udb && ZONE(&zudb)->log_str.data) { - udb_ptr s; - udb_ptr_new(&s, nsd->db->udb, &ZONE(&zudb)->log_str); - strlcpy(logs, (char*)udb_ptr_data(&s), sizeof(logs)); - udb_ptr_unlink(&s, nsd->db->udb); - } else if(zone->logstr) { + if(zone->logstr) strlcpy(logs, zone->logstr, sizeof(logs)); - } else logs[0] = 0; + else + logs[0] = 0; VERBOSITY(1, (LOG_INFO, "writing zone %s to file %s", zone->opts->name, zfile)); if(!write_to_zonefile(zone, bakfile, logs)) { - if(nsd->db->udb) - udb_ptr_unlink(&zudb, nsd->db->udb); (void)unlink(bakfile); /* delete failed file */ return; /* error already printed */ } if(rename(bakfile, zfile) == -1) { log_msg(LOG_ERR, "rename(%s to %s) failed: %s", bakfile, zfile, strerror(errno)); - if(nsd->db->udb) - udb_ptr_unlink(&zudb, nsd->db->udb); (void)unlink(bakfile); /* delete failed file */ return; } @@ -393,23 +261,15 @@ namedb_write_zonefile(struct nsd* nsd, struct zone_options* zopt) if(!file_get_mtime(zfile, &mtime, ¬exist)) { get_time(&mtime); } - if(nsd->db->udb) { - ZONE(&zudb)->mtime = (uint64_t)mtime.tv_sec; - ZONE(&zudb)->mtime_nsec = (uint64_t)mtime.tv_nsec; - ZONE(&zudb)->is_changed = 0; - udb_zone_set_log_str(nsd->db->udb, &zudb, NULL); - udb_ptr_unlink(&zudb, nsd->db->udb); - } else { - zone->mtime = mtime; - if(zone->filename) - region_recycle(nsd->db->region, zone->filename, - strlen(zone->filename)+1); - zone->filename = region_strdup(nsd->db->region, zfile); - if(zone->logstr) - region_recycle(nsd->db->region, zone->logstr, - strlen(zone->logstr)+1); - zone->logstr = NULL; - } + zone->mtime = mtime; + if(zone->filename) + region_recycle(nsd->db->region, zone->filename, + strlen(zone->filename)+1); + zone->filename = region_strdup(nsd->db->region, zfile); + if(zone->logstr) + region_recycle(nsd->db->region, zone->logstr, + strlen(zone->logstr)+1); + zone->logstr = NULL; if(zone_is_ixfr_enabled(zone) && zone->ixfr) ixfr_write_to_file(zone, zfile); } diff --git a/difffile.c b/difffile.c index d61bc5690..8bcf0a8a5 100644 --- a/difffile.c +++ b/difffile.c @@ -19,7 +19,6 @@ #include "packet.h" #include "rdata.h" #include "udb.h" -#include "udbzone.h" #include "nsec3.h" #include "nsd.h" #include "rrl.h" @@ -462,8 +461,7 @@ find_rr_num(rrset_type* rrset, uint16_t type, uint16_t klass, #ifdef NSEC3 /* see if nsec3 deletion triggers need action */ static void -nsec3_delete_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone, - udb_ptr* udbz) +nsec3_delete_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone) { /* the RR has not actually been deleted yet, so we can inspect it */ if(!zone->nsec3_param) @@ -494,7 +492,7 @@ nsec3_delete_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone, /* clear trees, wipe hashes, wipe precompile */ nsec3_clear_precompile(db, zone); /* pick up new nsec3param (from udb, or avoid deleted rr) */ - nsec3_find_zone_param(db, zone, udbz, rr, 0); + nsec3_find_zone_param(db, zone, rr, 0); /* if no more NSEC3, done */ if(!zone->nsec3_param) return; @@ -583,8 +581,7 @@ nsec3_delete_rrset_trigger(namedb_type* db, domain_type* domain, /* see if nsec3 addition triggers need action */ static void -nsec3_add_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone, - udb_ptr* udbz) +nsec3_add_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone) { /* the RR has been added in full, also to UDB (and thus NSEC3PARAM * in the udb has been adjusted) */ @@ -606,7 +603,7 @@ nsec3_add_rr_trigger(namedb_type* db, rr_type* rr, zone_type* zone, prehash_add(db->domains, rr->owner); } else if(!zone->nsec3_param && rr->type == TYPE_NSEC3PARAM) { /* see if this means NSEC3 chain can be used */ - nsec3_find_zone_param(db, zone, udbz, NULL, 0); + nsec3_find_zone_param(db, zone, NULL, 0); if(!zone->nsec3_param) return; nsec3_zone_trees_create(db->region, zone); @@ -669,7 +666,7 @@ int delete_RR(namedb_type* db, const dname_type* dname, uint16_t type, uint16_t klass, buffer_type* packet, size_t rdatalen, zone_type *zone, - region_type* temp_region, udb_ptr* udbz, int* softfail) + region_type* temp_region, int* softfail) { domain_type *domain; rrset_type *rrset; @@ -715,12 +712,9 @@ delete_RR(namedb_type* db, const dname_type* dname, *softfail = 1; return 1; /* not fatal error */ } - /* delete the normalized RR from the udb */ - if(db->udb) - udb_del_rr(db->udb, udbz, &rrset->rrs[rrnum]); #ifdef NSEC3 /* process triggers for RR deletions */ - nsec3_delete_rr_trigger(db, &rrset->rrs[rrnum], zone, udbz); + nsec3_delete_rr_trigger(db, &rrset->rrs[rrnum], zone); #endif /* lower usage (possibly deleting other domains, and thus * invalidating the current RR's domain pointers) */ @@ -785,7 +779,7 @@ delete_RR(namedb_type* db, const dname_type* dname, int add_RR(namedb_type* db, const dname_type* dname, uint16_t type, uint16_t klass, uint32_t ttl, - buffer_type* packet, size_t rdatalen, zone_type *zone, udb_ptr* udbz, + buffer_type* packet, size_t rdatalen, zone_type *zone, int* softfail) { domain_type* domain; @@ -879,13 +873,6 @@ add_RR(namedb_type* db, const dname_type* dname, #endif /* NSEC3 */ } - /* write the just-normalized RR to the udb */ - if(db->udb) { - if(!udb_write_rr(db->udb, udbz, &rrset->rrs[rrset->rr_count - 1])) { - log_msg(LOG_ERR, "could not add RR to nsd.db, disk-space?"); - return 0; - } - } #ifdef NSEC3 if(rrset_added) { domain_type* p = domain->parent; @@ -897,7 +884,7 @@ add_RR(namedb_type* db, const dname_type* dname, p = p->parent; } } - nsec3_add_rr_trigger(db, &rrset->rrs[rrset->rr_count - 1], zone, udbz); + nsec3_add_rr_trigger(db, &rrset->rrs[rrset->rr_count - 1], zone); #endif /* NSEC3 */ return 1; } @@ -1006,7 +993,7 @@ static int apply_ixfr(nsd_type* nsd, FILE *in, uint32_t serialno, uint32_t seq_nr, uint32_t seq_total, int* is_axfr, int* delete_mode, int* rr_count, - udb_ptr* udbz, struct zone* zone, int* bytes, + struct zone* zone, int* bytes, int* softfail, struct ixfr_store* ixfr_store) { uint32_t msglen, checklen, pkttype; @@ -1128,6 +1115,7 @@ apply_ixfr(nsd_type* nsd, FILE *in, uint32_t serialno, region_destroy(region); return 0; } + serial = buffer_read_u32(packet); buffer_set_position(packet, position); @@ -1215,8 +1203,6 @@ apply_ixfr(nsd_type* nsd, FILE *in, uint32_t serialno, zone->nsec3_param = NULL; #endif delete_zone_rrs(nsd->db, zone); - if(nsd->db->udb) - udb_zone_clear(nsd->db->udb, udbz); if(ixfr_store) { ixfr_store_cancel(ixfr_store); ixfr_store_delixfrs(zone); @@ -1242,7 +1228,7 @@ apply_ixfr(nsd_type* nsd, FILE *in, uint32_t serialno, ixfr_store_delrr(ixfr_store, owner, type, klass, ttl, packet, rrlen, region); if(!delete_RR(nsd->db, owner, type, klass, packet, - rrlen, zone, region, udbz, softfail)) { + rrlen, zone, region, softfail)) { region_destroy(region); return 0; } @@ -1252,7 +1238,7 @@ apply_ixfr(nsd_type* nsd, FILE *in, uint32_t serialno, ixfr_store_addrr(ixfr_store, owner, type, klass, ttl, packet, rrlen, region); if(!add_RR(nsd->db, owner, type, klass, ttl, packet, - rrlen, zone, udbz, softfail)) { + rrlen, zone, softfail)) { region_destroy(region); return 0; } @@ -1368,44 +1354,18 @@ apply_ixfr_for_zone(nsd_type* nsd, zone_type* zone, FILE* in, if(!zone->is_skipped) { int is_axfr=0, delete_mode=0, rr_count=0, softfail=0; - const dname_type* apex = domain_dname_const(zone->apex); - udb_ptr z; struct ixfr_store* ixfr_store = NULL, ixfr_store_mem; DEBUG(DEBUG_XFRD,1, (LOG_INFO, "processing xfr: %s", zone_buf)); if(zone_is_ixfr_enabled(zone)) ixfr_store = ixfr_store_start(zone, &ixfr_store_mem); - memset(&z, 0, sizeof(z)); /* if udb==NULL, have &z defined */ - if(nsd->db->udb) { - if(udb_base_get_userflags(nsd->db->udb) != 0) { - diff_update_commit( - zone_buf, DIFF_CORRUPT, nsd, xfrfilenr); - log_msg(LOG_ERR, "database corrupted, cannot update"); - exit(1); - } - /* all parts were checked by xfrd before commit */ - if(!udb_zone_search(nsd->db->udb, &z, dname_name(apex), - apex->name_size)) { - /* create it */ - if(!udb_zone_create(nsd->db->udb, &z, dname_name(apex), - apex->name_size)) { - /* out of disk space perhaps */ - log_msg(LOG_ERR, "could not udb_create_zone " - "%s, disk space full?", zone_buf); - ixfr_store_free(ixfr_store); - return 0; - } - } - /* set the udb dirty until we are finished applying changes */ - udb_base_set_userflags(nsd->db->udb, 1); - } /* read and apply all of the parts */ for(i=0; idb->udb?&z:NULL), zone, + &rr_count, zone, &num_bytes, &softfail, ixfr_store); if(ret == 0) { log_msg(LOG_ERR, "bad ixfr packet part %d in diff file for %s", (int)i, zone_buf); @@ -1417,8 +1377,6 @@ apply_ixfr_for_zone(nsd_type* nsd, zone_type* zone, FILE* in, break; } } - if(nsd->db->udb) - udb_base_set_userflags(nsd->db->udb, 0); /* read the final log_str: but do not fail on it */ if(!diff_read_str(in, log_buf, sizeof(log_buf))) { log_msg(LOG_ERR, "could not read log for transfer %s", @@ -1431,27 +1389,16 @@ apply_ixfr_for_zone(nsd_type* nsd, zone_type* zone, FILE* in, zone->is_changed = 1; zone->is_updated = 1; zone->is_checked = (committed == DIFF_VERIFIED); - if(nsd->db->udb) { - assert(z.base); - ZONE(&z)->is_changed = 1; - /* FIXME: need to set is_updated here? */ - ZONE(&z)->mtime = time_end_0; - ZONE(&z)->mtime_nsec = time_end_1*1000; - udb_zone_set_log_str(nsd->db->udb, &z, log_buf); - udb_zone_set_file_str(nsd->db->udb, &z, NULL); - udb_ptr_unlink(&z, nsd->db->udb); - } else { - zone->mtime.tv_sec = time_end_0; - zone->mtime.tv_nsec = time_end_1*1000; - if(zone->logstr) - region_recycle(nsd->db->region, zone->logstr, - strlen(zone->logstr)+1); - zone->logstr = region_strdup(nsd->db->region, log_buf); - if(zone->filename) - region_recycle(nsd->db->region, zone->filename, - strlen(zone->filename)+1); - zone->filename = NULL; - } + zone->mtime.tv_sec = time_end_0; + zone->mtime.tv_nsec = time_end_1*1000; + if(zone->logstr) + region_recycle(nsd->db->region, zone->logstr, + strlen(zone->logstr)+1); + zone->logstr = region_strdup(nsd->db->region, log_buf); + if(zone->filename) + region_recycle(nsd->db->region, zone->filename, + strlen(zone->filename)+1); + zone->filename = NULL; if(softfail && taskudb && !is_axfr) { log_msg(LOG_ERR, "Failed to apply IXFR cleanly " "(deletes nonexistent RRs, adds existing RRs). " @@ -1479,9 +1426,31 @@ apply_ixfr_for_zone(nsd_type* nsd, zone_type* zone, FILE* in, return 1; } +static void udb_task_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, void *arg) +{ + struct task_list_d* p = (struct task_list_d*)d; + assert(s >= p->size); + (void)s; + (*cb)(base, &p->next, arg); +} + +void udb_walkfunc(void* base, void* warg, uint8_t t, void* d, uint64_t s, + udb_walk_relptr_cb* cb, void *arg) +{ + (void)warg; + switch(t) { + case udb_chunk_type_task: + udb_task_walk_chunk(base, d, s, cb, arg); + break; + default: + /* no rel ptrs */ + break; + } +} + struct udb_base* task_file_create(const char* file) { - return udb_base_create_new(file, &namedb_walkfunc, NULL); + return udb_base_create_new(file, &udb_walkfunc, NULL); } static int @@ -1933,7 +1902,7 @@ task_process_set_verbosity(struct task_list_d* task) } static void -task_process_checkzones(struct nsd* nsd, udb_base* udb, udb_ptr* last_task, +task_process_checkzones(struct nsd* nsd, udb_base* taskudb, udb_ptr* last_task, struct task_list_d* task) { /* on SIGHUP check if zone-text-files changed and if so, @@ -1942,10 +1911,10 @@ task_process_checkzones(struct nsd* nsd, udb_base* udb, udb_ptr* last_task, struct zone_options* zo = zone_options_find(nsd->options, task->zname); if(zo) - namedb_check_zonefile(nsd, udb, last_task, zo); + namedb_check_zonefile(nsd, taskudb, last_task, zo); } else { /* check all zones */ - namedb_check_zonefiles(nsd, nsd->options, udb, last_task); + namedb_check_zonefiles(nsd, nsd->options, taskudb, last_task); } } @@ -2007,14 +1976,6 @@ task_process_del_zone(struct nsd* nsd, struct task_list_d* task) zone->nsec3_param = NULL; #endif delete_zone_rrs(nsd->db, zone); - if(nsd->db->udb) { - udb_ptr udbz; - if(udb_zone_search(nsd->db->udb, &udbz, dname_name(task->zname), - task->zname->name_size)) { - udb_zone_delete(nsd->db->udb, &udbz); - udb_ptr_unlink(&udbz, nsd->db->udb); - } - } /* remove from zonetree, apex, soa */ zopt = zone->opts; diff --git a/difffile.h b/difffile.h index 77d1dedd7..f6df5b6fa 100644 --- a/difffile.h +++ b/difffile.h @@ -59,12 +59,12 @@ void delete_zone_rrs(namedb_type* db, zone_type* zone); int delete_RR(namedb_type* db, const dname_type* dname, uint16_t type, uint16_t klass, buffer_type* packet, size_t rdatalen, zone_type *zone, - region_type* temp_region, struct udb_ptr* udbz, int* softfail); + region_type* temp_region, int* softfail); /* add an RR */ int add_RR(namedb_type* db, const dname_type* dname, uint16_t type, uint16_t klass, uint32_t ttl, buffer_type* packet, size_t rdatalen, zone_type *zone, - struct udb_ptr* udbz, int* softfail); + int* softfail); enum soainfo_hint { soainfo_ok, diff --git a/dnstap/dnstap_collector.c b/dnstap/dnstap_collector.c index 36edb6cc0..1a0bc8525 100644 --- a/dnstap/dnstap_collector.c +++ b/dnstap/dnstap_collector.c @@ -436,7 +436,6 @@ void dt_collector_start(struct dt_collector* dt_col, struct nsd* nsd) #endif udb_base_free_keep_mmap(nsd->task[0]); udb_base_free_keep_mmap(nsd->task[1]); - namedb_close_udb(nsd->db); /* keeps mmap */ namedb_close(nsd->db); dt_collector_run(dt_col, nsd); diff --git a/doc/ChangeLog b/doc/ChangeLog index 8a064c191..4e15cd917 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,6 @@ +1 November 2023: Jeroen + - Remove on-disk database. + 31 October 2023: Wouter - Merge #301: improve the logging of ixfr fallbacks to axfr. diff --git a/doc/README b/doc/README index 8a32f3aa1..0ab6dc073 100644 --- a/doc/README +++ b/doc/README @@ -194,10 +194,6 @@ addition to standard configure options, one may use the following: Pathname to the NSD pidfile, default is platform specific, mostly /var/run/nsd.pid - --with-dbfile=path - - Pathname to the NSD database, default is /etc/nsd/nsd.db - --with-zonesdir=dir NSD default location for master zone files, default /etc/nsd/ diff --git a/doc/RELNOTES b/doc/RELNOTES index 0d57dded3..232201cf9 100644 --- a/doc/RELNOTES +++ b/doc/RELNOTES @@ -1,6 +1,6 @@ NSD RELEASE NOTES -4.7.1 (upcoming) +4.8.0 (upcoming) ================ FEATURES: - Merge #281: Proxy protocol. An implementation of PROXYv2 for NSD. @@ -22,6 +22,7 @@ BUG FIXES: - Fix for interprocess communication to set quit sync command from main process explicitly. - Fix processing of consolidated IXFRs. + - Remove on-disk database. 4.7.0 ================ diff --git a/namedb.h b/namedb.h index 3143e867d..65cb1aed2 100644 --- a/namedb.h +++ b/namedb.h @@ -329,7 +329,6 @@ struct namedb region_type* region; domain_table_type* domains; struct radtree* zonetree; - struct udb_base* udb; /* the timestamp on the ixfr.db file */ struct timeval diff_timestamp; /* if diff_skip=1, diff_pos contains the nsd.diff place to continue */ @@ -369,12 +368,7 @@ zone_type *namedb_find_zone(namedb_type *db, const dname_type *dname); */ void domain_table_deldomain(namedb_type* db, domain_type* domain); - /** dbcreate.c */ -int udb_write_rr(struct udb_base* udb, struct udb_ptr* z, rr_type* rr); -void udb_del_rr(struct udb_base* udb, struct udb_ptr* z, rr_type* rr); -int write_zone_to_udb(struct udb_base* udb, zone_type* zone, - struct timespec* mtime, const char* file_str); int print_rrs(FILE* out, struct zone* zone); /** marshal rdata into buffer, must be MAX_RDLENGTH in size */ size_t rr_marshal_rdata(rr_type* rr, uint8_t* rdata, size_t sz); @@ -384,8 +378,7 @@ int namedb_lookup (struct namedb* db, domain_type **closest_match, domain_type **closest_encloser); /* pass number of children (to alloc in dirty array */ -struct namedb *namedb_open(const char *filename, struct nsd_options* opt); -void namedb_close_udb(struct namedb* db); +struct namedb *namedb_open(struct nsd_options* opt); void namedb_close(struct namedb* db); /* free ixfr data stored for zones */ void namedb_free_ixfr(struct namedb* db); diff --git a/nsd-checkconf.c b/nsd-checkconf.c index a7a04ea6f..15c96cbf0 100644 --- a/nsd-checkconf.c +++ b/nsd-checkconf.c @@ -420,7 +420,6 @@ config_print_zone(nsd_options_type* opt, const char* k, int s, const char *o, SERV_GET_BIN(tcp_reject_overflow, o); SERV_GET_BIN(log_only_syslog, o); /* str */ - SERV_GET_PATH(final, database, o); SERV_GET_STR(identity, o); SERV_GET_STR(version, o); SERV_GET_STR(nsid, o); @@ -612,7 +611,6 @@ config_test_print_server(nsd_options_type* opt) printf("\tdrop-updates: %s\n", opt->drop_updates?"yes":"no"); printf("\ttcp-reject-overflow: %s\n", opt->tcp_reject_overflow ? "yes" : "no"); - print_string_var("database:", opt->database); print_string_var("identity:", opt->identity); print_string_var("version:", opt->version); print_string_var("nsid:", opt->nsid); @@ -864,11 +862,6 @@ additional_checks(nsd_options_type* opt, const char* filename) filename, opt->pidfile, opt->chroot); errors ++; } - if (!file_inside_chroot(opt->database, opt->chroot)) { - fprintf(stderr, "%s: database %s is not relative to chroot %s.\n", - filename, opt->database, opt->chroot); - errors ++; - } if (!file_inside_chroot(opt->xfrdfile, opt->chroot)) { fprintf(stderr, "%s: xfrdfile %s is not relative to chroot %s.\n", filename, opt->xfrdfile, opt->chroot); diff --git a/nsd-checkzone.c b/nsd-checkzone.c index b7ec3fcad..0fcf4f342 100644 --- a/nsd-checkzone.c +++ b/nsd-checkzone.c @@ -54,7 +54,7 @@ check_zone(struct nsd* nsd, const char* name, const char* fname, FILE *out, struct ixfr_create* ixfrcr = NULL; /* init*/ - nsd->db = namedb_open("", nsd->options); + nsd->db = namedb_open(nsd->options); dname = dname_parse(nsd->options->region, name); if(!dname) { /* parse failure */ diff --git a/nsd-mem.c b/nsd-mem.c index 0cc72bdc2..9f7b6992a 100644 --- a/nsd-mem.c +++ b/nsd-mem.c @@ -21,8 +21,7 @@ #include "tsig.h" #include "options.h" #include "namedb.h" -#include "udb.h" -#include "udbzone.h" +#include "difffile.h" #include "util.h" struct nsd nsd; @@ -45,10 +44,6 @@ struct zone_mem { size_t data; /* unused space (in db.region) due to alignment */ size_t data_unused; - /* udb data allocated */ - size_t udb_data; - /* udb overhead (chunk2**x - data) */ - size_t udb_overhead; /* count of number of domains */ size_t domaincount; @@ -60,10 +55,6 @@ struct tot_mem { size_t data; /* unused space (in db.region) due to alignment */ size_t data_unused; - /* udb data allocated */ - size_t udb_data; - /* udb overhead (chunk2**x - data) */ - size_t udb_overhead; /* count of number of domains */ size_t domaincount; @@ -81,8 +72,6 @@ struct tot_mem { /* total ram usage */ size_t ram; - /* total nsd.db disk usage */ - size_t disk; }; static void @@ -90,11 +79,6 @@ account_zone(struct namedb* db, struct zone_mem* zmem) { zmem->data = region_get_mem(db->region); zmem->data_unused = region_get_mem_unused(db->region); - if(db->udb) { - zmem->udb_data = (size_t)db->udb->alloc->disk->stat_data; - zmem->udb_overhead = (size_t)(db->udb->alloc->disk->stat_alloc - - db->udb->alloc->disk->stat_data); - } zmem->domaincount = domain_table_count(db->domains); } @@ -119,8 +103,6 @@ print_zone_mem(struct zone_mem* z) { pretty_mem(z->data, "zone data"); pretty_mem(z->data_unused, "zone unused space (due to alignment)"); - pretty_mem(z->udb_data, "data in nsd.db"); - pretty_mem(z->udb_overhead, "overhead in nsd.db"); } static void @@ -143,7 +125,6 @@ account_total(struct nsd_options* opt, struct tot_mem* t) #ifdef RATELIMIT t->ram += t->rrl; #endif - t->disk = t->udb_data + t->udb_overhead; } static void @@ -158,12 +139,9 @@ print_tot_mem(struct tot_mem* t) #ifdef RATELIMIT pretty_mem(t->rrl, "RRL table (depends on servercount)"); #endif - pretty_mem(t->udb_data, "data in nsd.db"); - pretty_mem(t->udb_overhead, "overhead in nsd.db"); printf("\nsummary\n"); pretty_mem(t->ram, "ram usage (excl space for buffers)"); - pretty_mem(t->disk, "disk usage (excl 12% space claimed for growth)"); } static void @@ -171,13 +149,11 @@ add_mem(struct tot_mem* t, struct zone_mem* z) { t->data += z->data; t->data_unused += z->data_unused; - t->udb_data += z->udb_data; - t->udb_overhead += z->udb_overhead; t->domaincount += z->domaincount; } static void -check_zone_mem(const char* tf, const char* df, struct zone_options* zo, +check_zone_mem(const char* tf, struct zone_options* zo, struct nsd_options* opt, struct tot_mem* totmem) { struct nsd nsd; @@ -193,10 +169,10 @@ check_zone_mem(const char* tf, const char* df, struct zone_options* zo, /* init*/ memset(&zmem, 0, sizeof(zmem)); memset(&nsd, 0, sizeof(nsd)); - nsd.db = db = namedb_open(df, opt); - if(!db) error("cannot open %s: %s", df, strerror(errno)); + nsd.db = db = namedb_open(opt); + if(!db) error("cannot open namedb"); zone = namedb_zone_create(db, dname, zo); - taskudb = udb_base_create_new(tf, &namedb_walkfunc, NULL); + taskudb = task_file_create(tf); udb_ptr_init(&last_task, taskudb); /* read the zone */ @@ -211,7 +187,6 @@ check_zone_mem(const char* tf, const char* df, struct zone_options* zo, /* delete the zone from memory */ namedb_close(db); udb_base_free(taskudb); - unlink(df); unlink(tf); /* add up totals */ @@ -224,30 +199,18 @@ check_mem(struct nsd_options* opt) struct tot_mem totmem; struct zone_options* zo; char tf[512]; - char df[512]; memset(&totmem, 0, sizeof(totmem)); snprintf(tf, sizeof(tf), "./nsd-mem-task-%u.db", (unsigned)getpid()); - if(opt->database == NULL || opt->database[0] == 0) - df[0] = 0; - else snprintf(df, sizeof(df), "./nsd-mem-db-%u.db", (unsigned)getpid()); /* read all zones and account memory */ RBTREE_FOR(zo, struct zone_options*, opt->zone_options) { - check_zone_mem(tf, df, zo, opt, &totmem); + check_zone_mem(tf, zo, opt, &totmem); } /* calculate more total statistics */ account_total(opt, &totmem); /* print statistics */ print_tot_mem(&totmem); - - /* final advice */ - if(opt->database != NULL && opt->database[0] != 0) { - printf("\nFinal advice estimate:\n"); - printf("(The partial mmap causes reload&AXFR to take longer(disk access))\n"); - pretty_mem(totmem.ram + totmem.disk, "data and big mmap"); - pretty_mem(totmem.ram + totmem.disk/6, "data and partial mmap"); - } } /* dummy functions to link */ diff --git a/nsd.8.in b/nsd.8.in index 5e4889585..2da21adcf 100644 --- a/nsd.8.in +++ b/nsd.8.in @@ -111,16 +111,6 @@ For format description see nsd.conf(5). .B \-d Do not fork, stay in the foreground. .TP -.B \-f\fI database -Use the specified -.I database -instead of the default of -.IR '@dbfile@' . -If a -.B zonesdir: -is specified in the config file this path can be relative to that -directory. -.TP .B \-h Print help information and exit. .TP @@ -224,11 +214,6 @@ SIGUSR1 Dump BIND8\-style statistics into the log. Ignored otherwise. .SH "FILES" .TP -"@dbfile@" -default -.B NSD -database -.TP @pidfile@ the process id of the name server. .TP diff --git a/nsd.c b/nsd.c index bd7e8ce68..f158c4ead 100644 --- a/nsd.c +++ b/nsd.c @@ -84,7 +84,6 @@ usage (void) #ifndef NDEBUG " -F facilities Specify the debug facilities.\n" #endif /* NDEBUG */ - " -f database Specify the database to load.\n" " -h Print this help information.\n" , CONFIGFILE); fprintf(stderr, @@ -951,7 +950,6 @@ main(int argc, char *argv[]) /* Initialize the server handler... */ memset(&nsd, 0, sizeof(struct nsd)); nsd.region = region_create(xalloc, free); - nsd.dbfile = 0; nsd.pidfile = 0; nsd.server_kind = NSD_SERVER_MAIN; memset(&hints, 0, sizeof(hints)); @@ -1019,7 +1017,6 @@ main(int argc, char *argv[]) nsd.debug = 1; break; case 'f': - nsd.dbfile = optarg; break; case 'h': usage(); @@ -1154,13 +1151,6 @@ main(int argc, char *argv[]) verbosity = nsd_debug_level; #endif /* NDEBUG */ if(nsd.options->debug_mode) nsd.debug=1; - if(!nsd.dbfile) - { - if(nsd.options->database) - nsd.dbfile = nsd.options->database; - else - nsd.dbfile = DBFILE; - } if(!nsd.pidfile) { if(nsd.options->pidfile) @@ -1465,9 +1455,6 @@ main(int argc, char *argv[]) } else if (!file_inside_chroot(nsd.pidfile, nsd.chrootdir)) { error("pidfile %s is not relative to %s: chroot not possible", nsd.pidfile, nsd.chrootdir); - } else if (!file_inside_chroot(nsd.dbfile, nsd.chrootdir)) { - error("database %s is not relative to %s: chroot not possible", - nsd.dbfile, nsd.chrootdir); } else if (!file_inside_chroot(nsd.options->xfrdfile, nsd.chrootdir)) { error("xfrdfile %s is not relative to %s: chroot not possible", nsd.options->xfrdfile, nsd.chrootdir); @@ -1645,8 +1632,6 @@ main(int argc, char *argv[]) } if (nsd.pidfile && nsd.pidfile[0] == '/') nsd.pidfile += l; - if (nsd.dbfile[0] == '/') - nsd.dbfile += l; if (nsd.options->xfrdfile[0] == '/') nsd.options->xfrdfile += l; if (nsd.options->zonelistfile[0] == '/') diff --git a/nsd.conf.5.in b/nsd.conf.5.in index 2f100fef3..fa0506c62 100644 --- a/nsd.conf.5.in +++ b/nsd.conf.5.in @@ -207,15 +207,6 @@ If yes, NSD listens to IPv4 connections. Default yes. .B do\-ip6:\fR If yes, NSD listens to IPv6 connections. Default yes. .TP -.B database:\fR -By default -.I @dbfile@ -is used. The specified file is used to store the compiled -zone information. Same as commandline option -.BR \-f. -If set to "" then no database is used. This uses less memory but -zone updates are not (immediately) spooled to disk. -.TP .B zonelistfile:\fR By default .I @zonelistfile@ diff --git a/nsd.conf.sample.in b/nsd.conf.sample.in index b85b2873e..1ffeacd7b 100644 --- a/nsd.conf.sample.in +++ b/nsd.conf.sample.in @@ -100,7 +100,7 @@ server: # username: @user@ # Run NSD in a chroot-jail. - # make sure to have pidfile and database reachable from there. + # make sure to have pidfile reachable from there. # by default, no chroot-jail is used. # chroot: "@configdir@" @@ -110,10 +110,6 @@ server: # the list of dynamically added zones. # zonelistfile: "@zonelistfile@" - # the database to use - # if set to "" then no disk-database is used, less memory usage. - # database: "@dbfile@" - # log messages to file. Default to stderr and syslog (with # facility LOG_DAEMON). stderr disappears when daemon goes to bg. # logfile: "@logfile@" @@ -217,7 +213,7 @@ server: # zonefiles-check: yes # write changed zonefiles to disk, every N seconds. - # default is 0(disabled) or 3600(if database is ""). + # default is 3600. # zonefiles-write: 3600 # RRLconfig diff --git a/nsd.h b/nsd.h index 8fea49d6d..3b43dae2b 100644 --- a/nsd.h +++ b/nsd.h @@ -244,7 +244,6 @@ struct nsd struct daemon_remote* rc; /* Configuration */ - const char *dbfile; const char *pidfile; const char *log_filename; const char *username; diff --git a/nsec3.c b/nsec3.c index 4ed55e68c..9144012ce 100644 --- a/nsec3.c +++ b/nsec3.c @@ -16,7 +16,6 @@ #include "namedb.h" #include "nsd.h" #include "answer.h" -#include "udbzone.h" #include "options.h" #define NSEC3_RDATA_BITMAP 5 @@ -283,60 +282,12 @@ db_find_nsec3param(struct namedb* db, struct zone* z, struct rr* avoid_rr, return NULL; } -static struct rr* -udb_zone_find_nsec3param(struct namedb* db, udb_base* udb, udb_ptr* uz, - struct zone* z, int checkchain) -{ - udb_ptr urr; - unsigned i; - rrset_type* rrset = domain_find_rrset(z->apex, z, TYPE_NSEC3PARAM); - if(!rrset) /* no NSEC3PARAM in mem */ - return NULL; - udb_ptr_new(&urr, udb, &ZONE(uz)->nsec3param); - if(!urr.data || RR(&urr)->len < 5) { - /* no NSEC3PARAM in udb */ - udb_ptr_unlink(&urr, udb); - return NULL; - } - /* find matching NSEC3PARAM RR in memory */ - for(i=0; irr_count; i++) { - /* if this RR matches the udb RR then we are done */ - rdata_atom_type* rd = rrset->rrs[i].rdatas; - if(rrset->rrs[i].rdata_count < 4) continue; - if(RR(&urr)->wire[0] == rdata_atom_data(rd[0])[0] && /*alg*/ - RR(&urr)->wire[1] == rdata_atom_data(rd[1])[0] && /*flg*/ - RR(&urr)->wire[2] == rdata_atom_data(rd[2])[0] && /*iter*/ - RR(&urr)->wire[3] == rdata_atom_data(rd[2])[1] && - RR(&urr)->wire[4] == rdata_atom_data(rd[3])[0] && /*slen*/ - RR(&urr)->len >= 5 + RR(&urr)->wire[4] && - memcmp(RR(&urr)->wire+5, rdata_atom_data(rd[3])+1, - rdata_atom_data(rd[3])[0]) == 0) { - udb_ptr_unlink(&urr, udb); - if(checkchain) { - z->nsec3_param = &rrset->rrs[i]; - if(!check_apex_soa(db, z, 1)) - return db_find_nsec3param(db, z, - NULL, checkchain); - } - return &rrset->rrs[i]; - } - } - udb_ptr_unlink(&urr, udb); - return NULL; -} - void -nsec3_find_zone_param(struct namedb* db, struct zone* zone, udb_ptr* z, +nsec3_find_zone_param(struct namedb* db, struct zone* zone, struct rr* avoid_rr, int checkchain) { - /* get nsec3param RR from udb */ - if(db->udb) - zone->nsec3_param = udb_zone_find_nsec3param(db, db->udb, - z, zone, checkchain); - /* no db, get from memory, avoid using the rr that is going to be - * deleted, avoid_rr */ - else zone->nsec3_param = db_find_nsec3param(db, zone, avoid_rr, - checkchain); + /* avoid using the rr that is going to be deleted, avoid_rr */ + zone->nsec3_param = db_find_nsec3param(db, zone, avoid_rr, checkchain); } /* check params ok for one RR */ @@ -686,30 +637,17 @@ nsec3_precompile_newparam(namedb_type* db, zone_type* zone) void prehash_zone_complete(struct namedb* db, struct zone* zone) { - udb_ptr udbz; - /* robust clear it */ nsec3_clear_precompile(db, zone); /* find zone settings */ assert(db && zone); - udbz.data = 0; - if(db->udb) { - if(!udb_zone_search(db->udb, &udbz, dname_name(domain_dname( - zone->apex)), domain_dname(zone->apex)->name_size)) { - udb_ptr_init(&udbz, db->udb); /* zero the ptr */ - } - } - nsec3_find_zone_param(db, zone, &udbz, NULL, 1); + nsec3_find_zone_param(db, zone, NULL, 1); if(!zone->nsec3_param || !check_apex_soa(db, zone, 0)) { zone->nsec3_param = NULL; zone->nsec3_last = NULL; - if(udbz.data) - udb_ptr_unlink(&udbz, db->udb); return; } - if(udbz.data) - udb_ptr_unlink(&udbz, db->udb); nsec3_precompile_newparam(db, zone); } diff --git a/nsec3.h b/nsec3.h index 43d0dfc94..31acd36fe 100644 --- a/nsec3.h +++ b/nsec3.h @@ -92,7 +92,7 @@ int nsec3_condition_hash(struct domain* d, struct zone* z); int nsec3_condition_dshash(struct domain* d, struct zone* z); /* set nsec3param for this zone or NULL if no NSEC3 available */ void nsec3_find_zone_param(struct namedb* db, struct zone* zone, - struct udb_ptr* z, struct rr* avoid_rr, int checkchain); + struct rr* avoid_rr, int checkchain); /* hash domain and wcchild, and lookup nsec3 in tree, and precompile */ void nsec3_precompile_domain(struct namedb* db, struct domain* domain, struct zone* zone, struct region* tmpregion); diff --git a/options.c b/options.c index 41cfa433c..e662ad147 100644 --- a/options.c +++ b/options.c @@ -66,7 +66,6 @@ nsd_options_create(region_type* region) opt->drop_updates = 0; opt->do_ip4 = 1; opt->do_ip6 = 1; - opt->database = DBFILE; opt->identity = 0; opt->version = 0; opt->nsid = 0; @@ -131,9 +130,7 @@ nsd_options_create(region_type* region) opt->dnstap_log_auth_response_messages = 0; #endif opt->zonefiles_check = 1; - if(opt->database == NULL || opt->database[0] == 0) - opt->zonefiles_write = ZONEFILES_WRITE_INTERVAL; - else opt->zonefiles_write = 0; + opt->zonefiles_write = ZONEFILES_WRITE_INTERVAL; opt->xfrd_reload_timeout = 1; opt->tls_service_key = NULL; opt->tls_service_ocsp = NULL; diff --git a/options.h b/options.h index 9c9a2483b..baf2579f5 100644 --- a/options.h +++ b/options.h @@ -82,7 +82,6 @@ struct nsd_options { int drop_updates; int do_ip4; int do_ip6; - const char* database; const char* identity; const char* version; const char* logfile; diff --git a/server.c b/server.c index deabeda5e..6ae17f962 100644 --- a/server.c +++ b/server.c @@ -489,9 +489,6 @@ restart_child_servers(struct nsd *nsd, region_type* region, netio_type* netio, nsd->children[i].handler->fd = nsd->children[i].child_fd; break; case 0: /* CHILD */ - /* the child need not be able to access the - * nsd.db file */ - namedb_close_udb(nsd->db); #ifdef MEMCLEAN /* OS collects memory pages */ region_destroy(region); #endif @@ -1423,7 +1420,7 @@ int server_prepare(struct nsd *nsd) { #ifdef RATELIMIT - /* set secret modifier for hashing (udb ptr buckets and rate limits) */ + /* set secret modifier for hashing (rate limits) */ #ifdef HAVE_GETRANDOM uint32_t v; if(getrandom(&v, sizeof(v), 0) == -1) { @@ -1452,9 +1449,8 @@ server_prepare(struct nsd *nsd) #endif /* RATELIMIT */ /* Open the database... */ - if ((nsd->db = namedb_open(nsd->dbfile, nsd->options)) == NULL) { - log_msg(LOG_ERR, "unable to open the database %s: %s", - nsd->dbfile, strerror(errno)); + if ((nsd->db = namedb_open(nsd->options)) == NULL) { + log_msg(LOG_ERR, "unable to open the database: %s", strerror(errno)); unlink(nsd->task[0]->fname); unlink(nsd->task[1]->fname); #ifdef USE_ZONE_STATS @@ -1464,12 +1460,10 @@ server_prepare(struct nsd *nsd) xfrd_del_tempdir(nsd); return -1; } - /* check if zone files have been modified */ + /* check if zone files can be read */ /* NULL for taskudb because we send soainfo in a moment, batched up, * for all zones */ - if(nsd->options->zonefiles_check || (nsd->options->database == NULL || - nsd->options->database[0] == 0)) - namedb_check_zonefiles(nsd, nsd->options, NULL, NULL); + namedb_check_zonefiles(nsd, nsd->options, NULL, NULL); zonestatid_tree_set(nsd); compression_table_capacity = 0; @@ -1566,7 +1560,6 @@ server_shutdown(struct nsd *nsd) udb_base_free_keep_mmap(nsd->task[0]); udb_base_free_keep_mmap(nsd->task[1]); namedb_free_ixfr(nsd->db); - namedb_close_udb(nsd->db); /* keeps mmap */ namedb_close(nsd->db); nsd_options_destroy(nsd->options); region_destroy(nsd->region); @@ -1736,9 +1729,6 @@ server_send_soa_xfrd(struct nsd* nsd, int shortsoa) unlink(nsd->zonestatfname[0]); unlink(nsd->zonestatfname[1]); #endif - /* write the nsd.db to disk, wait for it to complete */ - udb_base_sync(nsd->db->udb, 1); - udb_base_close(nsd->db->udb); server_shutdown(nsd); /* ENOTREACH */ exit(0); @@ -2217,8 +2207,6 @@ reload_process_tasks(struct nsd* nsd, udb_ptr* last_task, int cmdsocket) DEBUG(DEBUG_IPC,1, (LOG_INFO, "reload: ipc command from main %d", (int)cmd)); if(cmd == NSD_QUIT) { DEBUG(DEBUG_IPC,1, (LOG_INFO, "reload: quit to follow nsd")); - /* sync to disk (if needed) */ - udb_base_sync(nsd->db->udb, 0); /* unlink files of remainder of tasks */ while(!udb_ptr_is_null(&t)) { if(TASKLIST(&t)->task_type == task_apply_xfr) { @@ -2265,7 +2253,7 @@ reload_do_stats(int cmdfd, struct nsd* nsd, udb_ptr* last) log_msg(LOG_ERR, "could not read stats from oldpar"); return; } - s.db_disk = (nsd->db->udb?nsd->db->udb->base_size:0); + s.db_disk = 0; s.db_mem = region_get_mem(nsd->db->region); p = (stc_type*)task_new_stat_info(nsd->task[nsd->mytask], last, &s, nsd->child_count); @@ -2313,18 +2301,12 @@ server_reload(struct nsd *nsd, region_type* server_region, netio_type* netio, /* see what tasks we got from xfrd */ task_remap(nsd->task[nsd->mytask]); udb_ptr_init(&last_task, nsd->task[nsd->mytask]); - udb_compact_inhibited(nsd->db->udb, 1); reload_process_tasks(nsd, &last_task, cmdsocket); - udb_compact_inhibited(nsd->db->udb, 0); - udb_compact(nsd->db->udb); #ifndef NDEBUG if(nsd_debug_level >= 1) region_log_stats(nsd->db->region); #endif /* NDEBUG */ - /* sync to disk (if needed) */ - udb_base_sync(nsd->db->udb, 0); - initialize_dname_compression_tables(nsd); #ifdef BIND8_STATS @@ -2880,9 +2862,6 @@ server_main(struct nsd *nsd) #ifdef MEMCLEAN /* OS collects memory pages */ region_destroy(server_region); #endif - /* write the nsd.db to disk, wait for it to complete */ - udb_base_sync(nsd->db->udb, 1); - udb_base_close(nsd->db->udb); server_shutdown(nsd); } diff --git a/tpkg/allow_query.tdir/allow_query.conf b/tpkg/allow_query.tdir/allow_query.conf index 7b551c4bf..d27ef4de1 100644 --- a/tpkg/allow_query.tdir/allow_query.conf +++ b/tpkg/allow_query.tdir/allow_query.conf @@ -3,7 +3,6 @@ server: logfile: "nsd.log" zonesdir: "" zonelistfile: "zone.list" - database: "" interface: 127.0.0.1 interface: ::1 diff --git a/tpkg/axfr_incoming.tdir/axfr_incoming.conf b/tpkg/axfr_incoming.tdir/axfr_incoming.conf index 87cd1bfa5..b7a150de4 100644 --- a/tpkg/axfr_incoming.tdir/axfr_incoming.conf +++ b/tpkg/axfr_incoming.tdir/axfr_incoming.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bad_cpu_affinity.tdir/bad_cpu_affinity.conf b/tpkg/bad_cpu_affinity.tdir/bad_cpu_affinity.conf index fc9a47623..e3431871f 100644 --- a/tpkg/bad_cpu_affinity.tdir/bad_cpu_affinity.conf +++ b/tpkg/bad_cpu_affinity.tdir/bad_cpu_affinity.conf @@ -9,7 +9,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bad_cpu_affinity.tdir/bad_server_cpu_affinity.conf b/tpkg/bad_cpu_affinity.tdir/bad_server_cpu_affinity.conf index efd646592..632eb0e38 100644 --- a/tpkg/bad_cpu_affinity.tdir/bad_server_cpu_affinity.conf +++ b/tpkg/bad_cpu_affinity.tdir/bad_server_cpu_affinity.conf @@ -13,7 +13,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bad_cpu_affinity.tdir/bad_xfrd_cpu_affinity.conf b/tpkg/bad_cpu_affinity.tdir/bad_xfrd_cpu_affinity.conf index 8c06a258b..c02052c43 100644 --- a/tpkg/bad_cpu_affinity.tdir/bad_xfrd_cpu_affinity.conf +++ b/tpkg/bad_cpu_affinity.tdir/bad_xfrd_cpu_affinity.conf @@ -13,7 +13,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bad_server_ranges.tdir/bad_server_ranges.conf b/tpkg/bad_server_ranges.tdir/bad_server_ranges.conf index 5f3a3bdfc..1430f39fa 100644 --- a/tpkg/bad_server_ranges.tdir/bad_server_ranges.conf +++ b/tpkg/bad_server_ranges.tdir/bad_server_ranges.conf @@ -8,7 +8,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bug024_zonec_soa.tdir/bug024_zonec_soa.conf b/tpkg/bug024_zonec_soa.tdir/bug024_zonec_soa.conf index 52d3fcb43..6b79f842e 100644 --- a/tpkg/bug024_zonec_soa.tdir/bug024_zonec_soa.conf +++ b/tpkg/bug024_zonec_soa.tdir/bug024_zonec_soa.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug025_srv.tdir/bug025_srv.conf b/tpkg/bug025_srv.tdir/bug025_srv.conf index 363540563..1463a6583 100644 --- a/tpkg/bug025_srv.tdir/bug025_srv.conf +++ b/tpkg/bug025_srv.tdir/bug025_srv.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug052_ent.tdir/bug052_ent.post b/tpkg/bug052_ent.tdir/bug052_ent.post index f3cfa4a24..47e3caaa7 100644 --- a/tpkg/bug052_ent.tdir/bug052_ent.post +++ b/tpkg/bug052_ent.tdir/bug052_ent.post @@ -2,7 +2,6 @@ [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master [ -f .tpkg.var.test ] && source .tpkg.var.test -rm -f bug052_ent.db rm -f bug052_ent.current_respons1 # kill NSD diff --git a/tpkg/bug052_ent.tdir/bug052_ent.pre b/tpkg/bug052_ent.tdir/bug052_ent.pre index c38b60d9f..ba822c8c7 100644 --- a/tpkg/bug052_ent.tdir/bug052_ent.pre +++ b/tpkg/bug052_ent.tdir/bug052_ent.pre @@ -14,5 +14,5 @@ TPKG_NSD="$PRE/nsd" echo "export TPKG_PORT=$TPKG_PORT" >> .tpkg.var.test echo "export TPKG_NSD_PID=$TPKG_NSD_PID" >> .tpkg.var.test -$TPKG_NSD -c bug052_ent.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID -f bug052_ent.db +$TPKG_NSD -c bug052_ent.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID wait_nsd_up nsd.log diff --git a/tpkg/bug058_qn_246.tdir/bug058_qn_246.pre b/tpkg/bug058_qn_246.tdir/bug058_qn_246.pre index 49e23b439..c05127df6 100644 --- a/tpkg/bug058_qn_246.tdir/bug058_qn_246.pre +++ b/tpkg/bug058_qn_246.tdir/bug058_qn_246.pre @@ -14,5 +14,5 @@ TPKG_NSD="$PRE/nsd" echo "export TPKG_PORT=$TPKG_PORT" > .tpkg.var.test echo "export TPKG_NSD_PID=$TPKG_NSD_PID" >> .tpkg.var.test -$TPKG_NSD -c bug058_qn_246.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID -f bug058_qn_246.db +$TPKG_NSD -c bug058_qn_246.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID wait_nsd_up nsd.log diff --git a/tpkg/bug072_parent.tdir/bug072_parent.pre b/tpkg/bug072_parent.tdir/bug072_parent.pre index 6e8118a45..9b95aea8f 100644 --- a/tpkg/bug072_parent.tdir/bug072_parent.pre +++ b/tpkg/bug072_parent.tdir/bug072_parent.pre @@ -17,5 +17,5 @@ TPKG_NSD="$PRE/nsd" echo "export TPKG_PORT=$TPKG_PORT" >> .tpkg.var.test echo "export TPKG_NSD_PID=$TPKG_NSD_PID" >> .tpkg.var.test -$TPKG_NSD -c bug072_parent.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID -f bug072_parent.db +$TPKG_NSD -c bug072_parent.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID wait_nsd_up nsd.log diff --git a/tpkg/bug077_dname_length.tdir/bug077_dname_length.conf b/tpkg/bug077_dname_length.tdir/bug077_dname_length.conf index c0df06400..52e955902 100644 --- a/tpkg/bug077_dname_length.tdir/bug077_dname_length.conf +++ b/tpkg/bug077_dname_length.tdir/bug077_dname_length.conf @@ -4,7 +4,6 @@ server: zonesdir: "" logfile: "nsd.log" pidfile: "nsd.pid" - database: "bug077_dname_length.db" difffile: "bug077_dname_length.ixfr" xfrdfile: "bug077_dname_length.xfrd" zonelistfile: "zone.list" diff --git a/tpkg/bug086_chars.tdir/bug086_chars.conf b/tpkg/bug086_chars.tdir/bug086_chars.conf index 211f1736c..a3c679a2c 100644 --- a/tpkg/bug086_chars.tdir/bug086_chars.conf +++ b/tpkg/bug086_chars.tdir/bug086_chars.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug087_parse_at.tdir/bug087_parse_at.conf b/tpkg/bug087_parse_at.tdir/bug087_parse_at.conf index 13490edac..feb2d0892 100644 --- a/tpkg/bug087_parse_at.tdir/bug087_parse_at.conf +++ b/tpkg/bug087_parse_at.tdir/bug087_parse_at.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bug088_ff_ip4.tdir/bug088_ff_ip4.conf b/tpkg/bug088_ff_ip4.tdir/bug088_ff_ip4.conf index a5e2185fb..44b8b3483 100644 --- a/tpkg/bug088_ff_ip4.tdir/bug088_ff_ip4.conf +++ b/tpkg/bug088_ff_ip4.tdir/bug088_ff_ip4.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bug098_mnemonic_rrsig.tdir/bug098_mnemonic_rrsig.conf b/tpkg/bug098_mnemonic_rrsig.tdir/bug098_mnemonic_rrsig.conf index ee163ee56..e35645c9f 100644 --- a/tpkg/bug098_mnemonic_rrsig.tdir/bug098_mnemonic_rrsig.conf +++ b/tpkg/bug098_mnemonic_rrsig.tdir/bug098_mnemonic_rrsig.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug101_spf.tdir/bug101_spf.conf b/tpkg/bug101_spf.tdir/bug101_spf.conf index 3ab9b8d17..d35e2ab69 100644 --- a/tpkg/bug101_spf.tdir/bug101_spf.conf +++ b/tpkg/bug101_spf.tdir/bug101_spf.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug107_bad_hex_3597.tdir/bug107_bad_hex_3597.conf b/tpkg/bug107_bad_hex_3597.tdir/bug107_bad_hex_3597.conf index 8c7bd702d..be4c8dfec 100644 --- a/tpkg/bug107_bad_hex_3597.tdir/bug107_bad_hex_3597.conf +++ b/tpkg/bug107_bad_hex_3597.tdir/bug107_bad_hex_3597.conf @@ -1,12 +1,11 @@ server: - zonesdir: "" + zonesdir: "" username: "" chroot: "" pidfile: nsd.pid logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bug128_backslash_eos.tdir/bug128_backslash_eos.conf b/tpkg/bug128_backslash_eos.tdir/bug128_backslash_eos.conf index d1823b905..eab5c1d06 100644 --- a/tpkg/bug128_backslash_eos.tdir/bug128_backslash_eos.conf +++ b/tpkg/bug128_backslash_eos.tdir/bug128_backslash_eos.conf @@ -6,7 +6,6 @@ server: logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: diff --git a/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf b/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf index 50611ed22..805a1569a 100644 --- a/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf +++ b/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf @@ -6,7 +6,6 @@ server: pidfile: nsd.pid xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf2 b/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf2 index 383354b1a..7ea762229 100644 --- a/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf2 +++ b/tpkg/bug236_rrs_before_soa.tdir/bug236_rrs_before_soa.conf2 @@ -6,7 +6,6 @@ server: pidfile: nsd.pid xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd_2.db zonelistfile: zone2.list interface: 127.0.0.1 diff --git a/tpkg/bug253_skipns.tdir/bug253_skipns.post b/tpkg/bug253_skipns.tdir/bug253_skipns.post index 2ff32c073..87e61a73e 100644 --- a/tpkg/bug253_skipns.tdir/bug253_skipns.post +++ b/tpkg/bug253_skipns.tdir/bug253_skipns.post @@ -7,7 +7,6 @@ # do your teardown here . ../common.sh -rm bug253_skipns.db # do your teardown here if [ -z $TPKG_NSD_PID ]; then diff --git a/tpkg/bug253_skipns.tdir/bug253_skipns.pre b/tpkg/bug253_skipns.tdir/bug253_skipns.pre index ce4bbaeb5..89a263252 100644 --- a/tpkg/bug253_skipns.tdir/bug253_skipns.pre +++ b/tpkg/bug253_skipns.tdir/bug253_skipns.pre @@ -17,5 +17,5 @@ TPKG_NSD="$PRE/nsd" echo "export TPKG_PORT=$TPKG_PORT" >> .tpkg.var.test echo "export TPKG_NSD_PID=$TPKG_NSD_PID" >> .tpkg.var.test -$TPKG_NSD -c bug253_skipns.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID -f bug253_skipns.db +$TPKG_NSD -c bug253_skipns.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID wait_nsd_up nsd.log diff --git a/tpkg/bug665_ctl_del_subd.tdir/bug665_ctl_del_subd.conf b/tpkg/bug665_ctl_del_subd.tdir/bug665_ctl_del_subd.conf index efc6ecf99..d1c96c400 100644 --- a/tpkg/bug665_ctl_del_subd.tdir/bug665_ctl_del_subd.conf +++ b/tpkg/bug665_ctl_del_subd.tdir/bug665_ctl_del_subd.conf @@ -2,8 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - #database: "nsd.db" - database: "" logfile: "/dev/stderr" zonelistfile: "nsd.zonelist" zonesdir: "" diff --git a/tpkg/checkconf.tdir/checkconf.check b/tpkg/checkconf.tdir/checkconf.check index b74441b31..92ec60e83 100644 --- a/tpkg/checkconf.tdir/checkconf.check +++ b/tpkg/checkconf.tdir/checkconf.check @@ -14,7 +14,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/etc/nsd.db" identity: "server number 23" #version: nsid: "123456" @@ -49,7 +48,7 @@ server: ip-address: 127.0.0.1 ip-address: 10.1.2.3 zonefiles-check: yes - zonefiles-write: 0 + zonefiles-write: 3600 #tls-service-key: #tls-service-pem: #tls-service-ocsp: @@ -150,7 +149,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/etc/nsd/nsd.db" #identity: #version: #nsid: @@ -183,7 +181,7 @@ server: refuse-any: no verbosity: 0 zonefiles-check: yes - zonefiles-write: 0 + zonefiles-write: 3600 #tls-service-key: #tls-service-pem: #tls-service-ocsp: @@ -227,7 +225,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: @@ -260,7 +257,7 @@ server: refuse-any: no verbosity: 0 zonefiles-check: yes - zonefiles-write: 0 + zonefiles-write: 3600 #tls-service-key: #tls-service-pem: #tls-service-ocsp: @@ -313,7 +310,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: @@ -346,7 +342,7 @@ server: refuse-any: no verbosity: 0 zonefiles-check: yes - zonefiles-write: 0 + zonefiles-write: 3600 #tls-service-key: #tls-service-pem: #tls-service-ocsp: @@ -443,7 +439,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: @@ -476,7 +471,7 @@ server: refuse-any: no verbosity: 0 zonefiles-check: yes - zonefiles-write: 0 + zonefiles-write: 3600 #tls-service-key: #tls-service-pem: #tls-service-ocsp: diff --git a/tpkg/checkconf.tdir/checkconf.check2 b/tpkg/checkconf.tdir/checkconf.check2 index 10ec2d4f8..8110829b9 100644 --- a/tpkg/checkconf.tdir/checkconf.check2 +++ b/tpkg/checkconf.tdir/checkconf.check2 @@ -14,7 +14,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/etc/nsd.db" identity: "server number 23" #version: nsid: "123456" @@ -140,7 +139,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/etc/nsd/nsd.db" #identity: #version: #nsid: @@ -207,7 +205,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: @@ -283,7 +280,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: @@ -403,7 +399,6 @@ server: hide-identity: no drop-updates: no tcp-reject-overflow: no - database: "/var/db/nsd/nsd.db" #identity: #version: #nsid: diff --git a/tpkg/checkconf.tdir/checkconf.nsd01.conf b/tpkg/checkconf.tdir/checkconf.nsd01.conf index 40fc3b489..127f20053 100644 --- a/tpkg/checkconf.tdir/checkconf.nsd01.conf +++ b/tpkg/checkconf.tdir/checkconf.nsd01.conf @@ -4,7 +4,6 @@ server: ip-address: 127.0.0.1 ip-address: 10.1.2.3 debug-mode: yes - database: /etc/nsd.db identity: "server number 23" nsid: "123456" logfile: /var/log/nsdlogfile.log @@ -66,4 +65,4 @@ zone: tls-auth: name: XOT1 - auth-domain-name: xot_test \ No newline at end of file + auth-domain-name: xot_test diff --git a/tpkg/checkconf.tdir/checkconf.nsd02.conf b/tpkg/checkconf.tdir/checkconf.nsd02.conf index 92de8ed0d..c780b2084 100644 --- a/tpkg/checkconf.tdir/checkconf.nsd02.conf +++ b/tpkg/checkconf.tdir/checkconf.nsd02.conf @@ -1,7 +1,6 @@ # Example.com nsd.conf file # This is a comment. server: - database: "/etc/nsd/nsd.db" username: nsd logfile: "/var/log/nsdlogfile.log" pidfile: "/var/pid/nsd.pid" diff --git a/tpkg/cname_soa.tdir/cname_soa.conf b/tpkg/cname_soa.tdir/cname_soa.conf index 481152372..1ddd46e41 100644 --- a/tpkg/cname_soa.tdir/cname_soa.conf +++ b/tpkg/cname_soa.tdir/cname_soa.conf @@ -5,7 +5,6 @@ server: chroot: "" pidfile: nsd.pid logfile: nsd.log - database: nsd.db xfrdfile: nsd.xfrd difffile: nsd.ixfr zonelistfile: "zone.list" diff --git a/tpkg/cname_ttl.tdir/cname_ttl.conf b/tpkg/cname_ttl.tdir/cname_ttl.conf index e3ceb6b07..aba63ea78 100644 --- a/tpkg/cname_ttl.tdir/cname_ttl.conf +++ b/tpkg/cname_ttl.tdir/cname_ttl.conf @@ -2,7 +2,6 @@ server: logfile: "/dev/stdout" xfrdfile: "" zonesdir: "" - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf b/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf index 99a4ecb11..e26576d4d 100644 --- a/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf +++ b/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" #difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "control-reconfig-xfrd.zonelist" zonesdir: "" diff --git a/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf2 b/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf2 index affe9bf8c..482455903 100644 --- a/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf2 +++ b/tpkg/control-reconfig-xfrd.tdir/control-reconfig-xfrd.conf2 @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" #difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "control-reconfig-xfrd.zonelist" zonesdir: "" diff --git a/tpkg/control-repat-zone.tdir/control-repat-zone.conf b/tpkg/control-repat-zone.tdir/control-repat-zone.conf index c62698947..cf01d1734 100644 --- a/tpkg/control-repat-zone.tdir/control-repat-zone.conf +++ b/tpkg/control-repat-zone.tdir/control-repat-zone.conf @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "control-repat-zone.zonelist" zonesdir: "" diff --git a/tpkg/control-repat-zone.tdir/control-repat-zone.conf2 b/tpkg/control-repat-zone.tdir/control-repat-zone.conf2 index 5ad662be5..2302466a7 100644 --- a/tpkg/control-repat-zone.tdir/control-repat-zone.conf2 +++ b/tpkg/control-repat-zone.tdir/control-repat-zone.conf2 @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "control-repat-zone.zonelist" zonesdir: "" diff --git a/tpkg/control-repattern.tdir/control-repattern.conf2 b/tpkg/control-repattern.tdir/control-repattern.conf2 index 02eed7089..f267d86dc 100644 --- a/tpkg/control-repattern.tdir/control-repattern.conf2 +++ b/tpkg/control-repattern.tdir/control-repattern.conf2 @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "control-repattern.zonelist" zonesdir: "" diff --git a/tpkg/cpu_affinity.tdir/cpu_affinity.conf b/tpkg/cpu_affinity.tdir/cpu_affinity.conf index 04e7129c7..837a75380 100644 --- a/tpkg/cpu_affinity.tdir/cpu_affinity.conf +++ b/tpkg/cpu_affinity.tdir/cpu_affinity.conf @@ -10,7 +10,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/credns-setup/master.server.cf.in b/tpkg/credns-setup/master.server.cf.in index e31ffd084..6e5375378 100644 --- a/tpkg/credns-setup/master.server.cf.in +++ b/tpkg/credns-setup/master.server.cf.in @@ -1,7 +1,6 @@ server: zonesdir: @ZONESDIR@ username: @USERNAME@ - database: "" logfile: "@abs_builddir@/nsd.log" pidfile: "@abs_builddir@/nsd.pid" difffile: "@abs_builddir@/ixfr.db" diff --git a/tpkg/credns-setup/proxy.server.cf.in b/tpkg/credns-setup/proxy.server.cf.in index 73125fe11..bb645efaa 100644 --- a/tpkg/credns-setup/proxy.server.cf.in +++ b/tpkg/credns-setup/proxy.server.cf.in @@ -1,7 +1,6 @@ server: zonesdir: @ZONESDIR@ username: @USERNAME@ - database: "" logfile: "@abs_builddir@/nsd.log" pidfile: "@abs_builddir@/nsd.pid" difffile: "@abs_builddir@/ixfr.db" diff --git a/tpkg/credns-setup/slave.server.cf.in b/tpkg/credns-setup/slave.server.cf.in index 25b4d865f..3e76811c0 100644 --- a/tpkg/credns-setup/slave.server.cf.in +++ b/tpkg/credns-setup/slave.server.cf.in @@ -1,7 +1,6 @@ server: zonesdir: @ZONESDIR@ username: @USERNAME@ - database: "" logfile: "@abs_builddir@/nsd.log" pidfile: "@abs_builddir@/nsd.pid" difffile: "@abs_builddir@/ixfr.db" diff --git a/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf b/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf index 38062cbbb..539d8fbb9 100644 --- a/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf +++ b/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "ct-repat-interrupt.zonelist" zonesdir: "" diff --git a/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf2 b/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf2 index 983a45515..8245c4ce1 100644 --- a/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf2 +++ b/tpkg/ct-repat-interrupt.tdir/ct-repat-interrupt.conf2 @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "ct-repat-interrupt.zonelist" zonesdir: "" diff --git a/tpkg/cutest/cutest_iter.c b/tpkg/cutest/cutest_iter.c index f936c22f9..72db194c8 100644 --- a/tpkg/cutest/cutest_iter.c +++ b/tpkg/cutest/cutest_iter.c @@ -20,12 +20,12 @@ create_namedb(void) { struct namedb *db; - if((db = namedb_open(NULL, NULL)) == NULL) { - fprintf(stderr, "failed to create namedb\n"); - exit(1); - } + if((db = namedb_open(NULL)) == NULL) { + fprintf(stderr, "failed to create namedb\n"); + exit(1); + } - return db; + return db; } static void diff --git a/tpkg/cutest/cutest_namedb.c b/tpkg/cutest/cutest_namedb.c index d6480564c..173cbf166 100644 --- a/tpkg/cutest/cutest_namedb.c +++ b/tpkg/cutest/cutest_namedb.c @@ -18,7 +18,6 @@ #include "namedb.h" #include "nsec3.h" #include "udb.h" -#include "udbzone.h" #include "difffile.h" #include "zonec.h" #include "nsd.h" @@ -61,7 +60,6 @@ create_and_read_db(CuTest* tc, region_type* region, const char* zonename, struct nsd_options* opt; struct zone_options* zone; namedb_type* db; - char* dbfile = udbtest_get_temp_file("namedb.udb"); char* zonefile = udbtest_get_temp_file("namedb.zone"); FILE* out = fopen(zonefile, "w"); if(!out) { @@ -86,14 +84,13 @@ create_and_read_db(CuTest* tc, region_type* region, const char* zonename, /* read the db */ memset(&nsd, 0, sizeof(nsd)); - nsd.db = db = namedb_open(dbfile, opt); + nsd.db = db = namedb_open(opt); if(!db) { - printf("failed to open %s: %s\n", dbfile, strerror(errno)); + printf("failed to open namedb\n"); exit(1); } namedb_check_zonefiles(&nsd, opt, NULL, NULL); unlink(zonefile); - free(dbfile); free(zonefile); return db; } @@ -603,7 +600,7 @@ find_zone(namedb_type* db, char* z) /* add an RR from string */ static void -add_str(namedb_type* db, zone_type* zone, udb_ptr* udbz, char* str) +add_str(namedb_type* db, zone_type* zone, char* str) { region_type* temp = region_create(xalloc, free); uint8_t rdata[MAX_RDLENGTH]; @@ -619,7 +616,7 @@ add_str(namedb_type* db, zone_type* zone, udb_ptr* udbz, char* str) rdatalen = rr_marshal_rdata(rr, rdata, sizeof(rdata)); buffer_create_from(&databuffer, rdata, rdatalen); if(!add_RR(db, domain_dname(rr->owner), rr->type, rr->klass, rr->ttl, - &databuffer, rdatalen, zone, udbz, &softfail)) { + &databuffer, rdatalen, zone, &softfail)) { printf("cannot add RR: %s\n", str); exit(1); } @@ -628,7 +625,7 @@ add_str(namedb_type* db, zone_type* zone, udb_ptr* udbz, char* str) /* del an RR from string */ static void -del_str(namedb_type* db, zone_type* zone, udb_ptr* udbz, char* str) +del_str(namedb_type* db, zone_type* zone, char* str) { region_type* temp = region_create(xalloc, free); uint8_t rdata[MAX_RDLENGTH]; @@ -644,7 +641,7 @@ del_str(namedb_type* db, zone_type* zone, udb_ptr* udbz, char* str) rdatalen = rr_marshal_rdata(rr, rdata, sizeof(rdata)); buffer_create_from(&databuffer, rdata, rdatalen); if(!delete_RR(db, domain_dname(rr->owner), rr->type, rr->klass, - &databuffer, rdatalen, zone, temp, udbz, &softfail)) { + &databuffer, rdatalen, zone, temp, &softfail)) { printf("cannot delete RR: %s\n", str); exit(1); } @@ -656,128 +653,119 @@ static void test_add_del(CuTest *tc, namedb_type* db) { zone_type* zone = find_zone(db, "example.org"); - udb_ptr udbz; - if(!udb_zone_search(db->udb, &udbz, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) { - printf("cannot find udbzone\n"); - exit(1); - } check_namedb(tc, db); /* plain record */ - add_str(db, zone, &udbz, "added.example.org. IN A 1.2.3.4\n"); + add_str(db, zone, "added.example.org. IN A 1.2.3.4\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "added.example.org. IN A 1.2.3.4\n"); + del_str(db, zone, "added.example.org. IN A 1.2.3.4\n"); check_namedb(tc, db); /* rdata domain name */ - add_str(db, zone, &udbz, "ns2.example.org. IN NS example.org.\n"); + add_str(db, zone, "ns2.example.org. IN NS example.org.\n"); check_namedb(tc, db); - add_str(db, zone, &udbz, "zoop.example.org. IN MX 5 server.example.org.\n"); + add_str(db, zone, "zoop.example.org. IN MX 5 server.example.org.\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "zoop.example.org. IN MX 5 server.example.org.\n"); + del_str(db, zone, "zoop.example.org. IN MX 5 server.example.org.\n"); check_namedb(tc, db); /* empty nonterminal */ - add_str(db, zone, &udbz, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); + add_str(db, zone, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); + del_str(db, zone, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); check_namedb(tc, db); /* wildcard */ - add_str(db, zone, &udbz, "*.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "*.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "*.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "*.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); /* wildcard child closest match */ - add_str(db, zone, &udbz, "!.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "!.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); - add_str(db, zone, &udbz, "%.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "%.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "%.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "%.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "!.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "!.www.example.org. IN A 1.2.3.5\n"); check_namedb(tc, db); /* zone apex : delete all records at apex */ zone->is_ok = 0; - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n" ); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. IN NS ns.example.com.\n" ); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. IN NS ns2.example.com.\n" ); check_namedb(tc, db); /* zone apex : add records at zone apex */ zone->is_ok = 1; - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n" ); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. IN NS ns.example.com.\n" ); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. IN NS ns2.example.com.\n" ); check_namedb(tc, db); /* zonecut: add one */ - add_str(db, zone, &udbz, + add_str(db, zone, "bla.example.org. IN NS ns.bla.example.org.\n" ); check_namedb(tc, db); /* zonecut: add DS and zone is signed */ - add_str(db, zone, &udbz, + add_str(db, zone, "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n" ); check_namedb(tc, db); /* zonecut: remove DS and zone is signed */ - del_str(db, zone, &udbz, + del_str(db, zone, "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n" ); check_namedb(tc, db); /* zonecut: add below */ - add_str(db, zone, &udbz, + add_str(db, zone, "zoink.bla.example.org. IN A 1.2.3.7\n" ); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "ns.bla.example.org. IN A 1.2.3.8\n" ); check_namedb(tc, db); /* zonecut: remove below */ - del_str(db, zone, &udbz, + del_str(db, zone, "zoink.bla.example.org. IN A 1.2.3.7\n" ); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "ns.bla.example.org. IN A 1.2.3.8\n" ); check_namedb(tc, db); /* zonecut: remove one */ - del_str(db, zone, &udbz, + del_str(db, zone, "bla.example.org. IN NS ns.bla.example.org.\n" ); check_namedb(tc, db); /* domain with multiple subdomains (count of subdomains) */ - add_str(db, zone, &udbz, "lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - add_str(db, zone, &udbz, "p1.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p1.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - add_str(db, zone, &udbz, "p2.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p2.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - add_str(db, zone, &udbz, "p3.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p3.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "p1.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p1.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "p2.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p2.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "p3.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p3.lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "lotso.example.org. IN TXT lotso\n"); check_namedb(tc, db); zone->is_ok = 0; delete_zone_rrs(db, zone); check_namedb(tc, db); - - udb_ptr_unlink(&udbz, db->udb); } static void namedb_1(CuTest *tc) @@ -815,7 +803,6 @@ static void namedb_1(CuTest *tc) test_add_del(tc, db); if(v) printf("test namedb end\n"); - unlink(db->udb->fname); namedb_close(db); region_destroy(region); } @@ -824,27 +811,18 @@ static void test_add_del_2(CuTest *tc, namedb_type* db) { zone_type* zone = find_zone(db, "example.org"); - udb_ptr udbz; - if(!udb_zone_search(db->udb, &udbz, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) { - printf("cannot find udbzone\n"); - exit(1); - } check_namedb(tc, db); zone->is_ok = 0; - del_str(db, zone, &udbz, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n"); + del_str(db, zone, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "example.org. IN NS ns.example.com.\n"); + del_str(db, zone, "example.org. IN NS ns.example.com.\n"); check_namedb(tc, db); - del_str(db, zone, &udbz, "example.org. IN NS ns2.example.com.\n"); + del_str(db, zone, "example.org. IN NS ns2.example.com.\n"); check_namedb(tc, db); /* the root has not been deleted */ CuAssertTrue(tc, domain_table_count(db->domains) != 0); CuAssertTrue(tc, db->domains->root && db->domains->root->number); - - udb_ptr_unlink(&udbz, db->udb); } /* test _2 : check that root is not deleted */ @@ -861,7 +839,6 @@ static void namedb_2(CuTest *tc) ); test_add_del_2(tc, db); if(v) printf("test 2 namedb end\n"); - unlink(db->udb->fname); namedb_close(db); region_destroy(region); } @@ -872,296 +849,263 @@ static void test_add_del_3(CuTest *tc, namedb_type* db) { zone_type* zone = find_zone(db, "example.org"); - udb_ptr udbz; - if(!udb_zone_search(db->udb, &udbz, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) { - printf("cannot find udbzone\n"); - exit(1); - } check_namedb(tc, db); /* plain record */ - add_str(db, zone, &udbz, "added.example.org. IN A 1.2.3.4\n"); + add_str(db, zone, "added.example.org. IN A 1.2.3.4\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "added.example.org. IN A 1.2.3.4\n"); + del_str(db, zone, "added.example.org. IN A 1.2.3.4\n"); prehash_zone(db, zone); check_namedb(tc, db); /* rdata domain name */ - add_str(db, zone, &udbz, "ns2.example.org. IN NS example.org.\n"); + add_str(db, zone, "ns2.example.org. IN NS example.org.\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, "zoop.example.org. IN MX 5 server.example.org.\n"); + add_str(db, zone, "zoop.example.org. IN MX 5 server.example.org.\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "zoop.example.org. IN MX 5 server.example.org.\n"); + del_str(db, zone, "zoop.example.org. IN MX 5 server.example.org.\n"); prehash_zone(db, zone); check_namedb(tc, db); /* empty nonterminal */ - add_str(db, zone, &udbz, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); + add_str(db, zone, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); + del_str(db, zone, "a.bb.c.d.example.org. IN A 1.2.3.4\n"); prehash_zone(db, zone); check_namedb(tc, db); /* wildcard */ - add_str(db, zone, &udbz, "*.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "*.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "*.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "*.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); /* wildcard child closest match */ - add_str(db, zone, &udbz, "!.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "!.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, "%.www.example.org. IN A 1.2.3.5\n"); + add_str(db, zone, "%.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "%.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "%.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "!.www.example.org. IN A 1.2.3.5\n"); + del_str(db, zone, "!.www.example.org. IN A 1.2.3.5\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zone apex : delete all records at apex */ zone->is_ok = 0; - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, - "example.org. IN NS ns.example.com.\n" - ); + del_str(db, zone, "example.org. IN NS ns.example.com.\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, - "example.org. IN NS ns2.example.com.\n" - ); + del_str(db, zone, "example.org. IN NS ns2.example.com.\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zone apex : add records at zone apex */ zone->is_ok = 1; - add_str(db, zone, &udbz, - "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n" - ); + add_str(db, zone, "example.org. IN SOA ns.example.org. hostmaster.example.org. 2011041200 28800 7200 604800 3600\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, - "example.org. IN NS ns.example.com.\n" - ); + add_str(db, zone, "example.org. IN NS ns.example.com.\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, - "example.org. IN NS ns2.example.com.\n" - ); + add_str(db, zone, "example.org. IN NS ns2.example.com.\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: add one */ - add_str(db, zone, &udbz, - "bla.example.org. IN NS ns.bla.example.org.\n" - ); + add_str(db, zone, "bla.example.org. IN NS ns.bla.example.org.\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: add DS and zone is signed */ - add_str(db, zone, &udbz, - "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n" - ); + add_str(db, zone, "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: remove DS and zone is signed */ - del_str(db, zone, &udbz, - "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n" - ); + del_str(db, zone, "bla.example.org. IN DS 50602 8 2 FA8EE175C47325F4BD46D8A4083C3EBEB11C977D689069F2B41F1A29 B22446B1\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: add below */ - add_str(db, zone, &udbz, - "zoink.bla.example.org. IN A 1.2.3.7\n" - ); + add_str(db, zone, "zoink.bla.example.org. IN A 1.2.3.7\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, - "ns.bla.example.org. IN A 1.2.3.8\n" - ); + add_str(db, zone, "ns.bla.example.org. IN A 1.2.3.8\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: remove below */ - del_str(db, zone, &udbz, - "zoink.bla.example.org. IN A 1.2.3.7\n" - ); + del_str(db, zone, "zoink.bla.example.org. IN A 1.2.3.7\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, - "ns.bla.example.org. IN A 1.2.3.8\n" - ); + del_str(db, zone, "ns.bla.example.org. IN A 1.2.3.8\n"); prehash_zone(db, zone); check_namedb(tc, db); /* zonecut: remove one */ - del_str(db, zone, &udbz, - "bla.example.org. IN NS ns.bla.example.org.\n" - ); + del_str(db, zone, "bla.example.org. IN NS ns.bla.example.org.\n"); prehash_zone(db, zone); check_namedb(tc, db); /* domain with multiple subdomains (count of subdomains) */ - add_str(db, zone, &udbz, "lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, "p1.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p1.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, "p2.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p2.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, "p3.lotso.example.org. IN TXT lotso\n"); + add_str(db, zone, "p3.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "p1.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p1.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "p2.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p2.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "p3.lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "p3.lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, "lotso.example.org. IN TXT lotso\n"); + del_str(db, zone, "lotso.example.org. IN TXT lotso\n"); prehash_zone(db, zone); check_namedb(tc, db); /* remove last NSEC3 in chain and then add it again */ - del_str(db, zone, &udbz, + del_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN NSEC3 1 0 1 1234 1t1dk1m24102gngs9umpl1s4euti62js A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wzLORHkPVDVVi51HUInYoKgPdnc8+RtVLPcUv1L8EzD6rk7CtI9JEotWlc9az7p07/qAaOc+KpTlckB16KEsEw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wzLORHkPVDVVi51HUInYoKgPdnc8+RtVLPcUv1L8EzD6rk7CtI9JEotWlc9az7p07/qAaOc+KpTlckB16KEsEw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN NSEC3 1 0 1 1234 1t1dk1m24102gngs9umpl1s4euti62js A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove last NSEC3 and add it again, other order */ - del_str(db, zone, &udbz, + del_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wzLORHkPVDVVi51HUInYoKgPdnc8+RtVLPcUv1L8EzD6rk7CtI9JEotWlc9az7p07/qAaOc+KpTlckB16KEsEw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN NSEC3 1 0 1 1234 1t1dk1m24102gngs9umpl1s4euti62js A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN NSEC3 1 0 1 1234 1t1dk1m24102gngs9umpl1s4euti62js A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "t46dlvjh87nm2smr9tshdappe8c6uolu.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wzLORHkPVDVVi51HUInYoKgPdnc8+RtVLPcUv1L8EzD6rk7CtI9JEotWlc9az7p07/qAaOc+KpTlckB16KEsEw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove a domain and its NSEC3, first in one order then the other */ - del_str(db, zone, &udbz, + del_str(db, zone, "server.example.org. 3600 IN A 1.2.3.10\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "server.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. WW+TqIl0EO9lRvKl72iySFxn112KSzZfdYCKD3P34PEvExZ0MxAdgGhnpJH5Styv5i8c7uo2qIVQ/zVCcg9OwQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN NSEC3 1 0 1 1234 3o3tqldra9tgt2e01ikvc1f5r7qjct5q A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wvjHs9xj5M3c/SaGwrUGUVm9zgsNYG/4yxGdwQ5uS1X+mZsbYSYyxz7eoAebkuJTgmd98usoOD/QcxMyI+tUCA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add domain and its nsec3 again */ - add_str(db, zone, &udbz, + add_str(db, zone, "server.example.org. 3600 IN A 1.2.3.10\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "server.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. WW+TqIl0EO9lRvKl72iySFxn112KSzZfdYCKD3P34PEvExZ0MxAdgGhnpJH5Styv5i8c7uo2qIVQ/zVCcg9OwQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN NSEC3 1 0 1 1234 3o3tqldra9tgt2e01ikvc1f5r7qjct5q A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wvjHs9xj5M3c/SaGwrUGUVm9zgsNYG/4yxGdwQ5uS1X+mZsbYSYyxz7eoAebkuJTgmd98usoOD/QcxMyI+tUCA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* and remove domain and its nsec3 in other order */ - del_str(db, zone, &udbz, + del_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wvjHs9xj5M3c/SaGwrUGUVm9zgsNYG/4yxGdwQ5uS1X+mZsbYSYyxz7eoAebkuJTgmd98usoOD/QcxMyI+tUCA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN NSEC3 1 0 1 1234 3o3tqldra9tgt2e01ikvc1f5r7qjct5q A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "server.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. WW+TqIl0EO9lRvKl72iySFxn112KSzZfdYCKD3P34PEvExZ0MxAdgGhnpJH5Styv5i8c7uo2qIVQ/zVCcg9OwQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "server.example.org. 3600 IN A 1.2.3.10\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add domain and its nsec3 again, in other order */ - add_str(db, zone, &udbz, + add_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. wvjHs9xj5M3c/SaGwrUGUVm9zgsNYG/4yxGdwQ5uS1X+mZsbYSYyxz7eoAebkuJTgmd98usoOD/QcxMyI+tUCA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "1t1dk1m24102gngs9umpl1s4euti62js.example.org. 3600 IN NSEC3 1 0 1 1234 3o3tqldra9tgt2e01ikvc1f5r7qjct5q A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "server.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. WW+TqIl0EO9lRvKl72iySFxn112KSzZfdYCKD3P34PEvExZ0MxAdgGhnpJH5Styv5i8c7uo2qIVQ/zVCcg9OwQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "server.example.org. 3600 IN A 1.2.3.10\n" ); prehash_zone(db, zone); @@ -1169,255 +1113,255 @@ test_add_del_3(CuTest *tc, namedb_type* db) /* add and remove the wildcard and its NSEC3 record, first one order * then another order */ - del_str(db, zone, &udbz, + del_str(db, zone, "*.wc.example.org. 3600 IN A 1.2.3.5\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "*.wc.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. fuCdRkvOSUgFuItIsYB51hzuBBDGpWJk4ICZcPrHcEZaZvmiixUbTYDoECb+oGGrsU34Si3QkIAhmUgjNn3WQA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN NSEC3 1 0 1 1234 gtitidhf26une8fj2t3eaj47qf8tbuci A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. qs1ck0jaO2JBiwJ1Gm+vDkDxrqLKq0ASgGSpRPdimCXSv/xje/v6sbuKv2hVkvPLnp2mKsTEuzwahw+Pm09PdQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add wildcard and its NSEC3 */ - add_str(db, zone, &udbz, + add_str(db, zone, "*.wc.example.org. 3600 IN A 1.2.3.5\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "*.wc.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. fuCdRkvOSUgFuItIsYB51hzuBBDGpWJk4ICZcPrHcEZaZvmiixUbTYDoECb+oGGrsU34Si3QkIAhmUgjNn3WQA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN NSEC3 1 0 1 1234 gtitidhf26une8fj2t3eaj47qf8tbuci A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. qs1ck0jaO2JBiwJ1Gm+vDkDxrqLKq0ASgGSpRPdimCXSv/xje/v6sbuKv2hVkvPLnp2mKsTEuzwahw+Pm09PdQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* and remove wildcard and nsec3 in another order */ - del_str(db, zone, &udbz, + del_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. qs1ck0jaO2JBiwJ1Gm+vDkDxrqLKq0ASgGSpRPdimCXSv/xje/v6sbuKv2hVkvPLnp2mKsTEuzwahw+Pm09PdQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN NSEC3 1 0 1 1234 gtitidhf26une8fj2t3eaj47qf8tbuci A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "*.wc.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. fuCdRkvOSUgFuItIsYB51hzuBBDGpWJk4ICZcPrHcEZaZvmiixUbTYDoECb+oGGrsU34Si3QkIAhmUgjNn3WQA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "*.wc.example.org. 3600 IN A 1.2.3.5\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add wildcard and its NSEC3 */ - add_str(db, zone, &udbz, + add_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. qs1ck0jaO2JBiwJ1Gm+vDkDxrqLKq0ASgGSpRPdimCXSv/xje/v6sbuKv2hVkvPLnp2mKsTEuzwahw+Pm09PdQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "g1hcjueqjvfi7f48f5gbncll68nqj0it.example.org. 3600 IN NSEC3 1 0 1 1234 gtitidhf26une8fj2t3eaj47qf8tbuci A RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "*.wc.example.org. 3600 IN RRSIG A 5 3 3600 20110519131330 20110421131330 30899 example.org. fuCdRkvOSUgFuItIsYB51hzuBBDGpWJk4ICZcPrHcEZaZvmiixUbTYDoECb+oGGrsU34Si3QkIAhmUgjNn3WQA== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "*.wc.example.org. 3600 IN A 1.2.3.5\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* delete delegation and its NSEC3, then add again, and other order */ - del_str(db, zone, &udbz, + del_str(db, zone, "deleg.example.org. 3600 IN NS ns.deleg.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "deleg.example.org. 3600 IN NS extns.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN NSEC3 1 0 1 1234 q5f9fvlq89hnof4sbp3uum6233pt6ofi NS \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. zBc4ePB0UmbDRt1NJElooHV5KPFxjZkKq641PonOJdtKp5OIV3bklK/DwXM2MTMa5vzUC+X8h/ePBkyg/7FBzw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add delegation and nsec3 again */ - add_str(db, zone, &udbz, + add_str(db, zone, "deleg.example.org. 3600 IN NS ns.deleg.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "deleg.example.org. 3600 IN NS extns.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN NSEC3 1 0 1 1234 q5f9fvlq89hnof4sbp3uum6233pt6ofi NS \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. zBc4ePB0UmbDRt1NJElooHV5KPFxjZkKq641PonOJdtKp5OIV3bklK/DwXM2MTMa5vzUC+X8h/ePBkyg/7FBzw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove delegation and nsec3 other order */ - del_str(db, zone, &udbz, + del_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. zBc4ePB0UmbDRt1NJElooHV5KPFxjZkKq641PonOJdtKp5OIV3bklK/DwXM2MTMa5vzUC+X8h/ePBkyg/7FBzw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN NSEC3 1 0 1 1234 q5f9fvlq89hnof4sbp3uum6233pt6ofi NS \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "deleg.example.org. 3600 IN NS extns.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "deleg.example.org. 3600 IN NS ns.deleg.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add delegation and nsec3 again */ - add_str(db, zone, &udbz, + add_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. zBc4ePB0UmbDRt1NJElooHV5KPFxjZkKq641PonOJdtKp5OIV3bklK/DwXM2MTMa5vzUC+X8h/ePBkyg/7FBzw== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "os1tu4plekke6t993674mq6j79d73fdo.example.org. 3600 IN NSEC3 1 0 1 1234 q5f9fvlq89hnof4sbp3uum6233pt6ofi NS \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "deleg.example.org. 3600 IN NS extns.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "deleg.example.org. 3600 IN NS ns.deleg.example.org.\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove and add DNAME and nsec3. and then in another order */ - del_str(db, zone, &udbz, + del_str(db, zone, "dname.example.org. 3600 IN DNAME foo.com.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 20110519131330 20110421131330 30899 example.org. EsNccft58pZ0Toi+nX5E/cedeFPxLi+wD1QqP94+jjJwLPl5D959sr21qB164D3pg/DzumNZWHr7y8T7n6xz/Q== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN NSEC3 1 0 1 1234 an5c8h70kkk482f35kojaluuvp2k4al7 DNAME RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. Q6NNfU7UHLFG5ZPlbkPc53M4cAbZh3AxF6qDBKxah0cZd6kpGfRm9myZor0HUAW+XnQuHt96yfZe9M/adH7CXg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add DNAME and nsec3 */ - add_str(db, zone, &udbz, + add_str(db, zone, "dname.example.org. 3600 IN DNAME foo.com.\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 20110519131330 20110421131330 30899 example.org. EsNccft58pZ0Toi+nX5E/cedeFPxLi+wD1QqP94+jjJwLPl5D959sr21qB164D3pg/DzumNZWHr7y8T7n6xz/Q== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN NSEC3 1 0 1 1234 an5c8h70kkk482f35kojaluuvp2k4al7 DNAME RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. Q6NNfU7UHLFG5ZPlbkPc53M4cAbZh3AxF6qDBKxah0cZd6kpGfRm9myZor0HUAW+XnQuHt96yfZe9M/adH7CXg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove and add DNAME and nsec3 in another order */ - del_str(db, zone, &udbz, + del_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. Q6NNfU7UHLFG5ZPlbkPc53M4cAbZh3AxF6qDBKxah0cZd6kpGfRm9myZor0HUAW+XnQuHt96yfZe9M/adH7CXg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN NSEC3 1 0 1 1234 an5c8h70kkk482f35kojaluuvp2k4al7 DNAME RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 20110519131330 20110421131330 30899 example.org. EsNccft58pZ0Toi+nX5E/cedeFPxLi+wD1QqP94+jjJwLPl5D959sr21qB164D3pg/DzumNZWHr7y8T7n6xz/Q== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "dname.example.org. 3600 IN DNAME foo.com.\n" ); prehash_zone(db, zone); check_namedb(tc, db); /* add DNAME and nsec3 */ - add_str(db, zone, &udbz, + add_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. Q6NNfU7UHLFG5ZPlbkPc53M4cAbZh3AxF6qDBKxah0cZd6kpGfRm9myZor0HUAW+XnQuHt96yfZe9M/adH7CXg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "9cq8bno9lfqsbbm51irbq5tb43fl0ls2.example.org. 3600 IN NSEC3 1 0 1 1234 an5c8h70kkk482f35kojaluuvp2k4al7 DNAME RRSIG \n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 20110519131330 20110421131330 30899 example.org. EsNccft58pZ0Toi+nX5E/cedeFPxLi+wD1QqP94+jjJwLPl5D959sr21qB164D3pg/DzumNZWHr7y8T7n6xz/Q== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "dname.example.org. 3600 IN DNAME foo.com.\n" ); prehash_zone(db, zone); @@ -1430,8 +1374,6 @@ test_add_del_3(CuTest *tc, namedb_type* db) zone->nsec3_param = NULL; prehash_zone(db, zone); check_namedb(tc, db); - - udb_ptr_unlink(&udbz, db->udb); } static const char* nsec3zone_txt = @@ -1547,7 +1489,6 @@ static void namedb_3(CuTest *tc) test_add_del_3(tc, db); if(v) printf("test namedb end\n"); - unlink(db->udb->fname); namedb_close(db); region_destroy(region); } @@ -1557,7 +1498,6 @@ static void test_add_del_4(CuTest *tc, namedb_type* db) { zone_type* zone = find_zone(db, "example.org"); - udb_ptr udbz; int i; /* the new nsec3 chain */ char* new_nsec3s[] = { @@ -1635,38 +1575,32 @@ test_add_del_4(CuTest *tc, namedb_type* db) "o334hngponsojfvecb16ef11pluqci6c.example.org. 3600 IN RRSIG NSEC3 5 3 3600 20110519131330 20110421131330 30899 example.org. T/8XSAGtKBcPh2FfsT9qQyen8S2InP+GM/JLULxmZbQTJyRVX4Zoy+pVlAPv2FyiTcYVgjXCv4XF6ewvwqNRtw== ;{id = 30899}\n", NULL }; - if(!udb_zone_search(db->udb, &udbz, - dname_name(domain_dname(zone->apex)), - domain_dname(zone->apex)->name_size)) { - printf("cannot find udbzone\n"); - exit(1); - } check_namedb(tc, db); /* change NSEC3 salt : first add new NSEC3s, then add NSEC3PARAM. * remove old NSEC3PARAM. remove old NSEC3s */ for(i=0; new_nsec3s[i]; i++) { - add_str(db, zone, &udbz, new_nsec3s[i]); + add_str(db, zone, new_nsec3s[i]); prehash_zone(db, zone); check_namedb(tc, db); } - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 2 5678\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. jDz61FLnJs0mOO61HOeB6SuGwWZWahmzMmyNtit/9Yk4+zYrPPs/wJvqNuuuIcyXU5gLih3H+SVUddKaZlskZg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. THFhaMtVP25A31/aGJ7wU2GAMSuJrGCB5vkTZnmIelpQQ7j/uVDuFQRB73Zr87owwP8l02Aqf71iFA3LSdpEyQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 1 1234 \n" ); prehash_zone(db, zone); @@ -1674,40 +1608,40 @@ test_add_del_4(CuTest *tc, namedb_type* db) /* now, try to get the param change in another way: * remove the NSEC3PARAM (none left), then add it */ - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 2 5678\n" ); prehash_zone(db, zone); check_namedb(tc, db); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. jDz61FLnJs0mOO61HOeB6SuGwWZWahmzMmyNtit/9Yk4+zYrPPs/wJvqNuuuIcyXU5gLih3H+SVUddKaZlskZg== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. THFhaMtVP25A31/aGJ7wU2GAMSuJrGCB5vkTZnmIelpQQ7j/uVDuFQRB73Zr87owwP8l02Aqf71iFA3LSdpEyQ== ;{id = 30899}\n" ); prehash_zone(db, zone); check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 1 1234 \n" ); prehash_zone(db, zone); check_namedb(tc, db); /* remove two strings at once */ - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. THFhaMtVP25A31/aGJ7wU2GAMSuJrGCB5vkTZnmIelpQQ7j/uVDuFQRB73Zr87owwP8l02Aqf71iFA3LSdpEyQ== ;{id = 30899}\n" ); - del_str(db, zone, &udbz, + del_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 1 1234 \n" ); prehash_zone(db, zone); check_namedb(tc, db); for(i=0; old_nsec3s[i]; i++) { - del_str(db, zone, &udbz, old_nsec3s[i]); + del_str(db, zone, old_nsec3s[i]); prehash_zone(db, zone); check_namedb(tc, db); } @@ -1715,19 +1649,19 @@ test_add_del_4(CuTest *tc, namedb_type* db) /* change NSEC3PARAM in different order: delete all NSEC3s, then * NSEC3PARAM, then add the new PARAM, then the new NSEC3s */ for(i=0; new_nsec3s[i]; i++) { - del_str(db, zone, &udbz, new_nsec3s[i]); + del_str(db, zone, new_nsec3s[i]); } prehash_zone(db, zone); /* delete all nsec3 chain in one go */ check_namedb(tc, db); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN RRSIG NSEC3PARAM 5 2 3600 20110519131330 20110421131330 30899 example.org. THFhaMtVP25A31/aGJ7wU2GAMSuJrGCB5vkTZnmIelpQQ7j/uVDuFQRB73Zr87owwP8l02Aqf71iFA3LSdpEyQ== ;{id = 30899}\n" ); - add_str(db, zone, &udbz, + add_str(db, zone, "example.org. 3600 IN NSEC3PARAM 1 0 1 1234 \n" ); for(i=0; old_nsec3s[i]; i++) { - add_str(db, zone, &udbz, old_nsec3s[i]); + add_str(db, zone, old_nsec3s[i]); } prehash_zone(db, zone); check_namedb(tc, db); @@ -1738,8 +1672,6 @@ test_add_del_4(CuTest *tc, namedb_type* db) zone->nsec3_param = NULL; prehash_zone(db, zone); check_namedb(tc, db); - - udb_ptr_unlink(&udbz, db->udb); } static void namedb_4(CuTest *tc) @@ -1757,7 +1689,6 @@ static void namedb_4(CuTest *tc) test_add_del_4(tc, db); if(v) printf("test namedb-nsec3-saltchange end\n"); - unlink(db->udb->fname); namedb_close(db); region_destroy(region); } diff --git a/tpkg/cutest/cutest_run.c b/tpkg/cutest/cutest_run.c index e25373313..dd36f0476 100644 --- a/tpkg/cutest/cutest_run.c +++ b/tpkg/cutest/cutest_run.c @@ -23,7 +23,6 @@ CuSuite * reg_cutest_iterated_hash(void); CuSuite * reg_cutest_dname(void); CuSuite * reg_cutest_region(void); CuSuite * reg_cutest_udb(void); -CuSuite * reg_cutest_udb_radtree(void); CuSuite * reg_cutest_namedb(void); CuSuite * reg_cutest_bitset(void); #ifdef RATELIMIT @@ -75,9 +74,8 @@ int runalltests(const char *regex) CuSuiteAddSuite(suite, reg_cutest_iterated_hash()); #ifdef HAVE_MMAP CuSuiteAddSuite(suite, reg_cutest_udb()); - CuSuiteAddSuite(suite, reg_cutest_udb_radtree()); - CuSuiteAddSuite(suite, reg_cutest_namedb()); #endif + CuSuiteAddSuite(suite, reg_cutest_namedb()); #ifdef RATELIMIT CuSuiteAddSuite(suite, reg_cutest_rrl()); #endif diff --git a/tpkg/cutest/cutest_udbrad.c b/tpkg/cutest/cutest_udbrad.c deleted file mode 100644 index 5a775de72..000000000 --- a/tpkg/cutest/cutest_udbrad.c +++ /dev/null @@ -1,778 +0,0 @@ -/* - * test udbradtree -- generic radix tree for binary strings in udb. - * - * Copyright (c) 2010, NLnet Labs. See LICENSE for license. - */ -#include "config.h" -#include "tpkg/cutest/cutest.h" -#include -#include -#include -#include -#include "udbradtree.h" - -#include -#include - -/* from cutest_udb */ -void check_udb_structure(CuTest* t, udb_base* udb); -void check_udb(void); - -#define RADTREE(ptr) ((struct udb_radtree_d*)UDB_PTR(ptr)) -#define RADARRAY(ptr) ((struct udb_radarray_d*)UDB_PTR(ptr)) -#define TESTSTR(ptr) ((struct teststr*)UDB_PTR(ptr)) -#ifndef RAND_MAX -#define RAND_MAX 2147483647 -#endif - -/* a chunk type not in use by radtree or the builtin types */ -#define TESTSTR_CHUNK_TYPE 253 - -/** get the lookup array for a node */ -static struct udb_radarray_d* lookup(udb_ptr* n) -{ - return (struct udb_radarray_d*)UDB_REL(*n->base, - RADNODE(n)->lookup.data); -} - -/** get a string in the lookup array */ -static uint8_t* lookup_string(udb_ptr* n, unsigned i) -{ - return ((uint8_t*)&(lookup(n)->array[lookup(n)->capacity]))+ - i*lookup(n)->str_cap; -} - - -static void udb_radtree_1(CuTest* tc); - -CuSuite* reg_cutest_udb_radtree(void) -{ - CuSuite* suite = CuSuiteNew(); - SUITE_ADD_TEST(suite, udb_radtree_1); - return suite; -} - -static CuTest* tc = NULL; -/* local verbosity */ -static int verb = 0; -static udb_base* base_A = NULL; - -/*********** test code ************/ -/** test data for radix tree tests */ -struct teststr { - udb_rel_ptr mynode; - udb_radstrlen_type mylen; - uint8_t mystr[256]; -}; - -/** max strlen in an array */ -static udb_radstrlen_type udb_radarray_max_len(udb_ptr* n) -{ - unsigned i; - udb_radstrlen_type maxlen = 0; - for(i=0; ilen; i++) { - if(lookup(n)->array[i].node.data && - lookup(n)->array[i].len > maxlen) - maxlen = lookup(n)->array[i].len; - } - return maxlen; -} - -/** check invariants and count number of elems */ -static size_t test_check_invariants(udb_base* udb, udb_ptr* n) -{ - size_t num = 0; - udb_ptr s; - if(udb_ptr_is_null(n)) return 0; - if(RADNODE(n)->elem.data) num++; - CuAssert(tc, "invariant len<=cap", - lookup(n)->len <= lookup(n)->capacity); - CuAssert(tc, "invariant cap<=256", lookup(n)->capacity <= 256); - CuAssert(tc, "invariant offset", - ((int)RADNODE(n)->offset) + ((int)lookup(n)->len) <= 256); - if(lookup(n)->len == 0) { - CuAssert(tc, "invariant empty cap", lookup(n)->capacity == 0); - CuAssert(tc, "invariant empty strcap", lookup(n)->str_cap == 0); - CuAssert(tc, "invariant empty len", lookup(n)->len == 0); - CuAssert(tc, "invariant empty offset", RADNODE(n)->offset == 0); - } else { - unsigned idx; - udb_radstrlen_type maxlen; - CuAssert(tc, "invariant nonempty cap", - lookup(n)->capacity != 0); - CuAssert(tc, "invariant len>cap/2", - lookup(n)->len >= lookup(n)->capacity/2); - for(idx=0; idxlen; idx++) { - struct udb_radsel_d* r = &lookup(n)->array[idx]; - if(r->node.data == 0) { - CuAssert(tc, "empty node", r->len == 0); - /* there may be unused space in the - * string, it is undefined */ - } else { - /* r->len == 0 is an empty string */ - CuAssert(tc, "strcap", - r->len <= lookup(n)->str_cap); - udb_ptr_new(&s, udb, &r->node); - CuAssert(tc, "invariant parent", - n->data == RADNODE(&s)->parent.data); - CuAssert(tc, "invariant pidx", - RADNODE(&s)->pidx == idx); - num += test_check_invariants(udb, &s); - udb_ptr_unlink(&s, udb); - } - } - maxlen = udb_radarray_max_len(n); - CuAssert(tc, "maxlen", maxlen <= lookup(n)->str_cap); - if(maxlen != lookup(n)->str_cap) { - CuAssert(tc, "maxlen", maxlen >= lookup(n)->str_cap/2); - } - } - return num; -} - -/** find all elems in the list and check that the name as indicated by the - * lookup structure matches the one in the element */ -static void -test_check_list_keys(udb_base* udb, udb_ptr* n, struct teststr** all, - size_t* all_idx, size_t all_num, uint8_t* fullkey, - udb_radstrlen_type fullkey_len, udb_radstrlen_type fullkey_max) -{ - unsigned idx; - if(udb_ptr_is_null(n)) return; - if(RADNODE(n)->elem.data) { - /* check this elements key */ - udb_ptr t; - udb_ptr_new(&t, udb, &RADNODE(n)->elem); - CuAssert(tc, "testkey node", TESTSTR(&t)->mynode.data==n->data); - CuAssert(tc, "testkey elem", t.data== RADNODE(n)->elem.data); - CuAssert(tc, "testkey len", TESTSTR(&t)->mylen == fullkey_len); - CuAssert(tc, "testkey val", memcmp(TESTSTR(&t)->mystr, fullkey, fullkey_len) == 0); - /* add to all list */ - CuAssert(tc, "testkey list", (*all_idx) < all_num); - all[ (*all_idx)++ ] = TESTSTR(&t); - udb_ptr_unlink(&t, udb); - } - for(idx=0; idxlen; idx++) { - udb_ptr s; - struct udb_radsel_d* r = &lookup(n)->array[idx]; - udb_radstrlen_type newlen = fullkey_len; - if(!r->node.data) - continue; - /* lengthen fullkey with the character and r->str */ - CuAssert(tc, "testkey len", newlen+1 < fullkey_max); - fullkey[newlen++] = idx + RADNODE(n)->offset; - if(r->len != 0) { - CuAssert(tc, "testkey len", newlen+r->len < fullkey_max); - memmove(fullkey+newlen, lookup_string(n, idx), r->len); - newlen += r->len; - } - udb_ptr_new(&s, udb, &r->node); - test_check_list_keys(udb, &s, all, all_idx, all_num, fullkey, - newlen, fullkey_max); - udb_ptr_unlink(&s, udb); - } -} - -/** compare byte strings like the tree does */ -static int bstr_cmp(uint8_t* x, udb_radstrlen_type lenx, uint8_t* y, - udb_radstrlen_type leny) -{ - size_t m = (lenx leny) - return +1; - return 0; -} - -/** compare for qsort */ -int udb_test_sort_cmp(const void *a, const void *b) -{ - struct teststr* x = *(struct teststr**)a; - struct teststr* y = *(struct teststr**)b; - return bstr_cmp(x->mystr, x->mylen, y->mystr, y->mylen); -} - -/** check walk functions */ -static void test_check_walk(udb_base* udb, udb_ptr* rt, struct teststr** all, - size_t num) -{ - udb_ptr n; - unsigned idx; - - /* check _first */ - udb_radix_first(udb, rt, &n); - if(num == 0) { - CuAssert(tc, "walk first", n.data == 0); - } else { - CuAssert(tc, "walk first", n.data == all[0]->mynode.data); - } - udb_ptr_unlink(&n, udb); - - /* check _last */ - udb_radix_last(udb, rt, &n); - if(num == 0) { - CuAssert(tc, "walk last", n.data == 0); - } else { - CuAssert(tc, "walk last", n.data == all[num-1]->mynode.data); - } - udb_ptr_unlink(&n, udb); - - /* check _next */ - for(idx = 0; idx < num; idx++) { - udb_ptr_init(&n, udb); - udb_ptr_set(&n, udb, all[idx]->mynode.data); - udb_radix_next(udb, &n); - if(idx == num-1) { - CuAssert(tc, "radix_next", n.data == 0); - } else { - CuAssert(tc, "radix_next", - n.data == all[idx+1]->mynode.data); - } - udb_ptr_unlink(&n, udb); - } - - /* check _prev */ - for(idx = 0; idx < num; idx++) { - udb_ptr_init(&n, udb); - udb_ptr_set(&n, udb, all[idx]->mynode.data); - udb_radix_prev(udb, &n); - if(idx == 0) { - CuAssert(tc, "radix_prev", n.data == 0); - } else { - CuAssert(tc, "radix_prev", - n.data == all[idx-1]->mynode.data); - } - udb_ptr_unlink(&n, udb); - } -} - -/** check search function */ -static void test_check_search(udb_ptr* rt, struct teststr** all, size_t num) -{ - udb_void n; - unsigned idx; - for(idx = 0; idx < num; idx++) { - n = udb_radix_search(rt, all[idx]->mystr, all[idx]->mylen); - CuAssert(tc, "radix_search", n == all[idx]->mynode.data); - } -} - -/** check closest match function for exact matches */ -static void test_check_closest_match_exact(udb_base* udb, udb_ptr* rt, - struct teststr** all, size_t num) -{ - udb_ptr n; - unsigned idx; - udb_ptr_init(&n, udb); - for(idx = 0; idx < num; idx++) { - udb_ptr_zero(&n, udb); - if(udb_radix_find_less_equal(udb, rt, all[idx]->mystr, - all[idx]->mylen, &n)) { - /* check if exact match is correct */ - CuAssert(tc, "find_le exact match", - n.data == all[idx]->mynode.data); - } else { - /* should have returned true: exact match */ - CuAssert(tc, "find_le", 0); - } - } - udb_ptr_unlink(&n, udb); -} - -/** get a random value */ -static unsigned -get_ran_val(unsigned max) -{ - unsigned r = (random() & RAND_MAX); - double ret = ((double)r * (double)max) / (1.0 + RAND_MAX); - return (unsigned)ret; -} - -/** generate random string and length */ -static void -gen_ran_str_len(uint8_t* buf, udb_radstrlen_type* len, udb_radstrlen_type max) -{ - udb_radstrlen_type i; - *len = get_ran_val(5); - CuAssert(tc, "ranstrlen", *len < max); - buf[*len] = 0; /* zero terminate for easy debug */ - for(i=0; i< *len; i++) { - /*buf[i] = get_ran_val(256); */ - buf[i] = 'a' + get_ran_val(26); - } -} - -/** check closest match function for inexact matches */ -static void test_check_closest_match_inexact(udb_base* udb, udb_ptr* rt) -{ - uint8_t buf[1024]; - udb_radstrlen_type len; - udb_ptr n, t; - int i = 0, num=1000; - udb_ptr_init(&n, udb); - udb_ptr_init(&t, udb); - /* what strings to try out? random */ - /* how to check result? use prev and next (they work checked before)*/ - for(i=0; ielem.data != 0); - /* check exact match */ - udb_ptr_set_rptr(&t, udb, &RADNODE(&n)->elem); - CuAssert(tc, "find_le", TESTSTR(&t)->mylen == len); - CuAssert(tc, "find_le", memcmp(TESTSTR(&t)->mystr, - buf, len) == 0); - } else { - /* check inexact match */ - if(n.data == 0) { - /* no elements in rt or before first item */ - if(RADTREE(rt)->count != 0) { - udb_radix_first(udb, rt, &n); - udb_ptr_set_rptr(&t, udb, - &RADNODE(&n)->elem); - CuAssert(tc, "find_le", bstr_cmp( - buf, len, TESTSTR(&t)->mystr, - TESTSTR(&t)->mylen) < 0); - } - } else { - udb_ptr nx; - CuAssert(tc, "ptrforsmallerhaselem", - RADNODE(&n)->elem.data != 0); - /* n is before the item */ - udb_ptr_set_rptr(&t, udb, &RADNODE(&n)->elem); - CuAssert(tc, "find_le", bstr_cmp( - TESTSTR(&t)->mystr, TESTSTR(&t)->mylen, - buf, len) < 0); - /* the next item is NULL or after it */ - udb_ptr_init(&nx, udb); - udb_ptr_set_ptr(&nx, udb, &n); - udb_radix_next(udb, &nx); - if(nx.data) { - udb_ptr_set_rptr(&t, udb, - &RADNODE(&nx)->elem); - CuAssert(tc, "find_le", bstr_cmp( - TESTSTR(&t)->mystr, - TESTSTR(&t)->mylen, - buf, len) > 0); - } - udb_ptr_unlink(&nx, udb); - } - } - } - udb_ptr_unlink(&t, udb); - udb_ptr_unlink(&n, udb); -} - -/** calc size of node and below */ -static uint64_t udb_radtree_size_node(udb_base* udb, udb_ptr* n) -{ - uint64_t s; - unsigned i; - if(n->data == 0) - return 0; - s = sizeof(struct udb_radnode_d) + size_of_lookup_ext(n); - for(i=0; ilen; i++) { - udb_ptr sub; - udb_ptr_new(&sub, udb, &lookup(n)->array[i].node); - s += udb_radtree_size_node(udb, &sub); - udb_ptr_unlink(&sub, udb); - } - return s; -} - -/** calculate the allocated(data) size of the radtree (base, nodes, arrays) */ -static uint64_t udb_radtree_size(udb_base* udb, udb_ptr* rt) -{ - uint64_t s; - udb_ptr n; - udb_ptr_new(&n, udb, &RADTREE(rt)->root); - s = sizeof(struct udb_radtree_d) + udb_radtree_size_node(udb, &n); - udb_ptr_unlink(&n, udb); - return s; -} - -/** perform lots of checks on the test tree */ -static void test_checks(udb_base* udb, udb_ptr* rt) -{ - struct teststr* all[10240]; - size_t i=0; - uint8_t fullkey_buf[1024]; - udb_ptr root; - uint64_t mem; - - /* tree structure invariants */ - size_t num; - udb_ptr_new(&root, udb, &RADTREE(rt)->root); - num = test_check_invariants(udb, &root); - CuAssert(tc, "count", (uint64_t)num == RADTREE(rt)->count); - - /* otherwise does not fit in array */ - CuAssert(tc, "counts", num < sizeof(all)/sizeof(struct teststr*)); - - /* check that keys appended match test-elem contents, and also - * produce a list of all elements */ - test_check_list_keys(udb, &root, all, &i, num, fullkey_buf, 0, - sizeof(fullkey_buf)); - CuAssert(tc, "testlistkey count", i == num); - - /* qsort that list */ - qsort(all, num, sizeof(struct teststr*), &udb_test_sort_cmp); - - test_check_walk(udb, rt, all, num); - - /* check searches for every element */ - test_check_search(rt, all, num); - - /* check closest_match_searches for every exact element */ - test_check_closest_match_exact(udb, rt, all, num); - /* check closest_match_searches for every inexact element */ - test_check_closest_match_inexact(udb, rt); - - udb_ptr_unlink(&root, udb); - - /* check allocated sizes in the udb */ - mem = udb_radtree_size(udb, rt); - if(verb) printf("radtree takes %llu\n", (unsigned long long)mem); - mem += RADTREE(rt)->count * sizeof(struct teststr); - if(verb) printf("radtree+teststrs takes %llu\n", - (unsigned long long)mem); - if(verb) printf("statdata %llu\n", - (unsigned long long)udb->alloc->disk->stat_data); - CuAssert(tc, "allocated memory accounted for", - mem == udb->alloc->disk->stat_data); - - check_udb_structure(tc, udb); -} - - -static void test_print_str(uint8_t* str, udb_radstrlen_type len) -{ - udb_radstrlen_type x; - for(x=0; xram_num; - if(udb_ptr_is_null(n)) return; - udb_ptr_init(&s, udb); - udb_ptr_set_rptr(&s, udb, &RADNODE(n)->parent); - par_offset = RADNODE(&s)->offset; - for(i=0; iparent.data) - fprintf(stderr, "%c node=%llu.", - RADNODE(n)->pidx+par_offset? - RADNODE(n)->pidx+par_offset:'.', - (long long unsigned)n->data); - else - fprintf(stderr, "rootnode=%llu.", (long long unsigned)n->data); - fprintf(stderr, " pidx=%d off=%d(%c) len=%d cap=%d strcap=%d parent=%llu lookup=%llu\n", - RADNODE(n)->pidx, RADNODE(n)->offset, - isprint(RADNODE(n)->offset)?RADNODE(n)->offset:'.', - lookup(n)->len, lookup(n)->capacity, lookup(n)->str_cap, - (long long unsigned)RADNODE(n)->parent.data, - (long long unsigned)RADNODE(n)->lookup.data); - for(i=0; ielem.data) { - /* for test setup */ - udb_ptr_set_rptr(&s, udb, &RADNODE(n)->elem); - fprintf(stderr, " elem '"); - test_print_str(TESTSTR(&s)->mystr, TESTSTR(&s)->mylen); - fprintf(stderr, "'"); - fprintf(stderr, " teststr=%llu", - (unsigned long long)s.data); - fprintf(stderr, "\n"); - if(TESTSTR(&s)->mynode.data != n->data) - fprintf(stderr, "elem data ptr fail\n"); - CuAssertTrue(tc, TESTSTR(&s)->mynode.data == n->data); - } else fprintf(stderr, " elem NULL\n"); - udb_ptr_zero(&s, udb); - for(idx=0; idxlen; idx++) { - struct udb_radsel_d* d = &lookup(n)->array[idx]; - if(!d->node.data) { - CuAssertTrue(tc, d->len == 0); - continue; - } - for(i=0; ioffset+idx == 0) fprintf(stderr, "[.]"); - else fprintf(stderr, "[%c]", RADNODE(n)->offset + idx); - if(d->len != 0) { - fprintf(stderr, "+'"); - test_print_str(lookup_string(n, idx), d->len); - fprintf(stderr, "'"); - } - if(d->node.data) { - fprintf(stderr, " node=%llu\n", - (long long unsigned)d->node.data); - udb_ptr_set_rptr(&s, udb, &d->node); - test_node_print(udb, &s, depth+2); - } else fprintf(stderr, " node NULL\n"); - CuAssertTrue(tc, rh+1 == udb->ram_num); - } - udb_ptr_unlink(&s, udb); - CuAssertTrue(tc, rh == udb->ram_num); -} - -static void test_tree_print(udb_base* udb, udb_ptr* rt) -{ - udb_ptr n; - size_t rh = udb->ram_num; - fprintf(stderr, "udbradtree %llu elements\n", - (long long unsigned)RADTREE(rt)->count); - udb_ptr_new(&n, udb, &RADTREE(rt)->root); - test_node_print(udb, &n, 0); - udb_ptr_unlink(&n, udb); - CuAssertTrue(tc, rh == udb->ram_num); -} - -int when = 0; -static void -test_insert_string(udb_base* udb, udb_ptr* rt, char* str) -{ - size_t len = strlen(str); - udb_ptr s, n; - size_t rh = udb->ram_num, rh2; - if(strcmp(str, "e") == 0) when = 1; - if(!udb_ptr_alloc_space(&s, udb, TESTSTR_CHUNK_TYPE, - sizeof(struct teststr))) { - CuAssert(tc, "alloc udb", 0); - } - /* MUST initialize the rel_ptr in the teststr */ - memset(TESTSTR(&s), 0, sizeof(struct teststr)); - CuAssertTrue(tc, udb->ram_num == rh+1); - CuAssert(tc, "insert", s.data != 0); - TESTSTR(&s)->mylen = len; - CuAssert(tc, "mystr len", len < sizeof(TESTSTR(&s)->mystr)); - memmove(TESTSTR(&s)->mystr, str, len); - if(verb) fprintf(stderr, "radix insert: '%s'\n", str); - rh2 = udb->ram_num; - /* Note, cannot pass TESTSTR(&s)->mystr, because that pointer - * becomes invalid if the udb changes */ - if(!udb_radix_insert(udb, rt, (uint8_t*)str, len, &s, &n)) { - CuAssert(tc, "insertmustwork", 0); - } - CuAssertTrue(tc, udb->ram_num == rh2+1); - udb_rptr_set_ptr(&TESTSTR(&s)->mynode, udb, &n); - CuAssert(tc, "insert", n.data != 0); - udb_ptr_unlink(&s, udb); - udb_ptr_unlink(&n, udb); - - rh2 = udb->ram_num; - if(verb) test_tree_print(udb, rt); - CuAssertTrue(tc, udb->ram_num == rh2); - test_checks(udb, rt); - CuAssertTrue(tc, udb->ram_num == rh2); - - CuAssertTrue(tc, udb->ram_num == rh); -} - -/** browse all elem's from tree with a for loop */ -static void test_browse(udb_base* udb, udb_ptr* rt) -{ - udb_ptr n; - udb_ptr_init(&n, udb); - for(udb_radix_first(udb, rt, &n); !udb_ptr_is_null(&n); - udb_radix_next(udb, &n)) { - udb_ptr elem; - udb_ptr_new(&elem, udb, &RADNODE(&n)->elem); - if(verb) fprintf(stderr, "radix %llu \telem ", - (unsigned long long)n.data); - if(verb) test_print_str(TESTSTR(&elem)->mystr, - TESTSTR(&elem)->mylen); - if(verb) fprintf(stderr, "\n"); - CuAssert(tc, "walk", TESTSTR(&elem)->mynode.data == n.data); - udb_ptr_unlink(&elem, udb); - } - udb_ptr_unlink(&n, udb); -} - -/** delete all elem's from tree with a for loop */ -static void test_del(udb_base* udb, udb_ptr* rt) -{ - udb_ptr n; - udb_ptr_init(&n, udb); - for(udb_radix_first(udb, rt, &n); !udb_ptr_is_null(&n); - udb_radix_next(udb, &n)) { - udb_ptr elem; - udb_ptr_new(&elem, udb, &RADNODE(&n)->elem); - if(verb) fprintf(stderr, "del %llu \telem ", - (unsigned long long)n.data); - if(verb) test_print_str(TESTSTR(&elem)->mystr, - TESTSTR(&elem)->mylen); - if(verb) fprintf(stderr, "\n"); - CuAssert(tc, "del", TESTSTR(&elem)->mynode.data == n.data); - udb_ptr_free_space(&elem, udb, sizeof(struct teststr)); - } - udb_ptr_unlink(&n, udb); -} - -/* delete a random key */ -static void -test_del_a_key(udb_base* udb, udb_ptr* rt) -{ - unsigned x = get_ran_val(RADTREE(rt)->count); - unsigned i = 0; - udb_ptr n; - udb_ptr t; - size_t rh; - - udb_radix_first(udb, rt, &n); - while(i++ < x) { - udb_radix_next(udb, &n); - } - if(udb_ptr_is_null(&n)) { - udb_ptr_unlink(&n, udb); - return; - } - CuAssert(tc, "radix_delete", RADNODE(&n)->elem.data != 0); - udb_ptr_new(&t, udb, &RADNODE(&n)->elem); - CuAssert(tc, "refintegrity", TESTSTR(&t)->mynode.data == n.data); - CuAssert(tc, "refintegrity", t.data == RADNODE(&n)->elem.data); - if(verb) fprintf(stderr, "delkey %llu \telem ", - (unsigned long long)n.data); - if(verb) test_print_str(TESTSTR(&t)->mystr, TESTSTR(&t)->mylen); - if(verb) fprintf(stderr, "\n"); - udb_rptr_zero(&TESTSTR(&t)->mynode, udb); - rh = udb->ram_num; - udb_radix_delete(udb, rt, &n); - CuAssertTrue(tc, udb->ram_num == rh-1); - /* and delete the test elem */ - udb_ptr_free_space(&t, udb, sizeof(struct teststr)); - udb_ptr_unlink(&n, udb); - - if(verb) test_tree_print(udb, rt); - test_checks(udb, rt); -} - -/* random add and dell test */ -static void -test_ran_add_del(udb_base* udb, udb_ptr* rt) -{ - unsigned i, num = 200; - unsigned target = 40; - for(i=0; iram_num == 1); - if( (RADTREE(rt)->count < target && ran%4 != 0) - || (ran%2 == 0)) { - uint8_t key[1024]; - udb_radstrlen_type len; - /* new string key */ - gen_ran_str_len(key, &len, sizeof(key)); - if(!udb_radix_search(rt, key, len)) { - test_insert_string(udb, rt, (char*)key); - } - } else { - test_del_a_key(udb, rt); - } - CuAssertTrue(tc, udb->ram_num == 1); - - } - CuAssertTrue(tc, udb->ram_num == 1); - if(verb) test_tree_print(udb, rt); - while(RADTREE(rt)->count != 0) { - test_del_a_key(udb, rt); - } - CuAssertTrue(tc, udb->ram_num == 1); -} - - -/** test udb radix tree with this udb base */ -static void -udb_radix_test_file(udb_base* udb) -{ - udb_ptr rt; - CuAssertTrue(tc, udb->ram_num == 0); - if(!udb_radix_tree_create(udb, &rt)) { - CuAssert(tc, "udb_radix_tree_create", 0); - } - CuAssertTrue(tc, udb->ram_num == 1); - if(verb) test_tree_print(udb, &rt); - CuAssertTrue(tc, udb->ram_num == 1); - - test_checks(udb, &rt); - CuAssertTrue(tc, udb->ram_num == 1); - - test_ran_add_del(udb, &rt); - if(verb) test_tree_print(udb, &rt); - - test_browse(udb, &rt); - test_checks(udb, &rt); - - test_del(udb, &rt); - udb_radix_tree_delete(udb, &rt); -} - -/** walk through relptrs in struct teststr */ -static void test_str_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - struct teststr* p = (struct teststr*)d; - CuAssertTrue(tc, s >= sizeof(struct teststr)); - (*cb)(base, &p->mynode, arg); -} - -/** walk through relptrs in types */ -static void testRADwalk(void* base, void* warg, uint8_t t, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - (void)warg; - switch(t) { - case udb_chunk_type_radtree: - udb_radix_tree_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_radnode: - udb_radix_node_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_radarray: - udb_radix_array_walk_chunk(base, d, s, cb, arg); - break; - case TESTSTR_CHUNK_TYPE: - test_str_walk_chunk(base, d, s, cb, arg); - break; - default: - /* no rel ptrs */ - break; - } -} - -/** return getpid and suffix a temp file (malloced string) */ -char* udbtest_get_temp_file(char* suffix); - -static void udb_radtree_1(CuTest* t) -{ - char* fname = udbtest_get_temp_file("rt.udb"); - udb_base* udb; - if(verb) printf("test udb rad tree (%s)\n", fname); - tc = t; - udb = udb_base_create_new(fname, testRADwalk, NULL); - base_A = udb; - - /* perform udb radix tree tests on this udb file */ - udb_radix_test_file(udb); - - /* close and free it */ - udb_base_close(udb); - udb_base_free(udb); - if(verb) printf("End test udb rad tree (%s)\n", fname); - if(unlink(fname) != 0) - perror(fname); - free(fname); -} diff --git a/tpkg/cutest/qtest.c b/tpkg/cutest/qtest.c index 408a4dbae..b730d6ee6 100644 --- a/tpkg/cutest/qtest.c +++ b/tpkg/cutest/qtest.c @@ -90,12 +90,10 @@ qsetup(nsd_type* nsd, region_type* region, query_type** query, char* config) #endif /* defined(INET6) */ /* read db */ - printf("read %s (%d zones)\n", nsd->options->database, - (int)nsd_options_num_zones(nsd->options)); - nsd->db = namedb_open(nsd->options->database, nsd->options); + printf("open namedb (%d zones)\n", (int)nsd_options_num_zones(nsd->options)); + nsd->db = namedb_open(nsd->options); if(!nsd->db) { - printf("failed to open %s: %s\n", nsd->options->database, - strerror(errno)); + printf("failed to open namedb\n"); exit(1); } namedb_check_zonefiles(nsd, nsd->options, NULL, NULL); diff --git a/tpkg/cutest/udb-inspect.c b/tpkg/cutest/udb-inspect.c deleted file mode 100644 index c86d2174a..000000000 --- a/tpkg/cutest/udb-inspect.c +++ /dev/null @@ -1,684 +0,0 @@ -/* udb-inspect - list the contents and inspect a udb file. - * By W.C.A. Wijngaards - * Copyright 2010, NLnet Labs. - * BSD, see LICENSE. - */ - -#include "config.h" -#include "udb.h" -#include "udbradtree.h" -#include "udbzone.h" -#include "util.h" -#include "buffer.h" -#include "packet.h" -#include "rdata.h" -#include "namedb.h" -#include "difffile.h" -#include -#include -#include -#include -#include -#include - -/* mmap and friends */ -#include -#include -#include -#include - -/** verbosity for udb inspect */ -static int v = 0; -/** shorthand for ease */ -#ifdef ULL -#undef ULL -#endif -#define ULL (unsigned long long) - -#ifndef MAP_FAILED -#define MAP_FAILED ((void*)-1) -#endif - -/* udb type is a uint8 */ -#define NUM_UDB_TYPES 256 - -/** print usage text */ -static void -usage(void) -{ - printf("usage: udb-inspect [options] file\n"); - printf(" -h this help\n"); - printf(" -v increase verbosity: " - "with -v(list chunks), -vv(inside chunks)\n"); - printf(" -l list contents of nsd db file: " - "with -v(zone info), -vv(RRs)\n"); -} - -/** inspect header enough to mmap it */ -static uint64_t -inspect_initial(int fd) -{ - uint64_t m, sz, fsz; - udb_glob_d g; - ssize_t r; - r = read(fd, &m, sizeof(m)); - if(r == -1 || r != (ssize_t)sizeof(m)) { - printf("readfail magic: %s\n", strerror(errno)); - exit(1); - } - r = read(fd, &g, sizeof(g)); - if(r == -1 || r != (ssize_t)sizeof(g)) { - printf("readfail globdata: %s\n", strerror(errno)); - exit(1); - } - if(m != UDB_MAGIC) { - printf("bad magic number\n"); - exit(1); - } - sz = g.fsize; - fsz = (uint64_t)lseek(fd, (off_t)0, SEEK_END); - (void)lseek(fd, (off_t)0, SEEK_SET); - printf("mmap size/file size: %llu / %llu\n", ULL sz, ULL fsz); - if(sz != fsz) { - printf(" bad mmap size in header, using file size\n"); - return fsz; - } - return sz; -} - -/** printout relptr line */ -static void -print_relptr(char* s, udb_rel_ptr* p) -{ - printf("%s d=%llu p=%llu n=%llu\n", - s, ULL p->data, ULL p->prev, ULL p->next); -} - -/** inspect glob data part */ -static udb_glob_d* -inspect_glob_data(void* base) -{ - udb_glob_d* g = (udb_glob_d*)(base+8); - uint64_t magic = *(uint64_t*)base; - printf("filetype: 0x%16.16llx (%s)\n", ULL magic, - magic==UDB_MAGIC?"ok":"wrong"); - printf("header size: %llu\n", ULL g->hsize); - if(g->hsize != UDB_HEADER_SIZE) - printf(" header size is wrong\n"); - printf("version: %u\n", (unsigned)g->version); - printf("clean_close: %u\n", (unsigned)g->clean_close); - if(g->clean_close != 1) - printf(" file was not cleanly closed\n"); - printf("dirty_alloc: %u\n", (unsigned)g->dirty_alloc); - printf("userflags: %u\n", (unsigned)g->userflags); - printf("padbytes: 0x%2.2x%2.2x%2.2x%2.2x\n", - g->pad1[0], g->pad1[1], g->pad1[2], g->pad1[3]); - printf("file size: %llu\n", ULL g->fsize); - printf("rb_old: %llu\n", ULL g->rb_old); - printf("rb_new: %llu\n", ULL g->rb_new); - printf("rb_size: %llu\n", ULL g->rb_size); - printf("rb_seg: %llu\n", ULL g->rb_seg); - print_relptr("content_list: ", &g->content_list); - print_relptr("user_global: ", &g->user_global); - return g; -} - -/** inspect alloc global part */ -static udb_alloc_d* -inspect_alloc(udb_glob_d* g) -{ - int i; - udb_alloc_d* a = (udb_alloc_d*)((void*)g + sizeof(*g)); - printf("bytes data allocated: %llu\n", ULL a->stat_data); - printf("bytes used for chunks: %llu\n", ULL a->stat_alloc); - printf("bytes free in chunks: %llu\n", ULL a->stat_free); - printf(" lost space: %llu\n", ULL - (a->stat_alloc-a->stat_data)); - printf("next chunk placement: %llu\n", ULL a->nextgrow); - printf(" unused space at EOF: %llu\n", ULL g->fsize-a->nextgrow); - - if(v) { - for(i=0; ifree[i]); - } - printf("header size: %llu\n", - ULL *(uint64_t*)((void*)a+sizeof(*a))); - printf("header endmarker exp: %llu\n", - ULL *(uint64_t*)((void*)a+sizeof(*a)+sizeof(uint64_t))); - } - return a; -} - -/** inspection result total values */ -struct inspect_totals { - /** number of chunks */ - uint64_t num_chunks; - /** count per size */ - uint64_t exp_num[UDB_ALLOC_CHUNKS_MAX+1]; - /** numfree per size */ - uint64_t exp_free[UDB_ALLOC_CHUNKS_MAX+1]; - - /** count per type */ - uint64_t type_num[NUM_UDB_TYPES]; - /** count per size per type */ - uint64_t type_exp_num[NUM_UDB_TYPES][UDB_ALLOC_CHUNKS_MAX+1]; -}; - -/** convert chunk type to string */ -static const char* -chunk_type2str(enum udb_chunk_type tp) -{ - switch(tp) { - case udb_chunk_type_free: return "free"; - case udb_chunk_type_data: return "data"; - case udb_chunk_type_index: return "index"; - case udb_chunk_type_internal: return "internal"; - case udb_chunk_type_radtree: return "radtree"; - case udb_chunk_type_radnode: return "radnode"; - case udb_chunk_type_radarray: return "radarray"; - case udb_chunk_type_zone: return "zone"; - case udb_chunk_type_domain: return "domain"; - case udb_chunk_type_rrset: return "rrset"; - case udb_chunk_type_rr: return "rr"; - case udb_chunk_type_task: return "task"; - } - return "unknown"; -} - -/** print escaped string */ -static void -print_escaped(uint8_t* s, size_t len) -{ - size_t i; - for(i=0; i len) { - printf(" malformed!"); - return; - } - print_escaped(&d[i], lablen); - i += lablen; - printf("."); - } -} - -/** print hex */ -static void -print_hex(uint8_t* d, size_t len) -{ - size_t i; - for(i=0; iexp; - uint8_t tp = cp->type; - uint8_t flags = cp->flags; - uint64_t sz = 0; - if(exp == UDB_EXP_XL) { - sz = ((udb_xl_chunk_d*)cp)->size; - data = c + sizeof(udb_xl_chunk_d); - } else { - sz = (uint64_t)1<prev); - printf("next: %llu\n", ULL fp->next); - } else { - printf("ptrlist: %llu\n", - ULL cp->ptrlist); - } - } - if(v>=2 && tp != udb_chunk_type_free && cp->ptrlist) { - /* follow the pointer list */ - udb_rel_ptr* pl = UDB_REL_PTR(cp->ptrlist); - while(pl->next) { - printf("relptr %llu\n", ULL UDB_SYSTOREL(base, pl)); - printf(" prev-ptrlist: %llu\n", ULL pl->prev); - printf(" data: %llu\n", ULL pl->data); - printf(" next-ptrlist: %llu\n", ULL pl->next); - pl = UDB_REL_PTR(pl->next); - } - } - /* print data details */ - if(v>=2) { - if(cp->type == udb_chunk_type_radtree) { - struct udb_radtree_d* d = (struct udb_radtree_d*)UDB_REL(base, - data); - printf(" radtree count=%llu root=%llu\n", - ULL d->count, ULL d->root.data); - } else if(cp->type == udb_chunk_type_radnode) { - struct udb_radnode_d* d = (struct udb_radnode_d*)UDB_REL(base, - data); - printf(" radnode pidx=%d offset=%d elem=%llu " - "parent=%llu lookup=%llu\n", - (int)d->pidx, (int)d->offset, ULL d->elem.data, - ULL d->parent.data, ULL d->lookup.data); - } else if(cp->type == udb_chunk_type_radarray) { - struct udb_radarray_d* d = (struct udb_radarray_d*)UDB_REL( - base, data); - unsigned i; - printf(" radarray len=%d capacity=%d str_cap=%d\n", - (int)d->len, (int)d->capacity, (int)d->str_cap); - for(i=0; ilen; i++) - if(d->array[i].node.data) { - printf(" [%u] node=%llu len=%d ", - i, ULL d->array[i].node.data, - (int)d->array[i].len); - print_escaped( - ((uint8_t*)&d->array[d->capacity])+ - i*d->str_cap, (size_t)d->array[i].len); - printf("\n"); - } - } else if(cp->type == udb_chunk_type_zone) { - struct zone_d* d = (struct zone_d*)UDB_REL(base, data); - printf(" zone "); - print_dname(d->name, d->namelen); - printf(" rr_count=%llu rrset_count=%llu expired=%d " - "node=%llu domains=%llu\n", - ULL d->rr_count, ULL d->rrset_count, (int)d->expired, - ULL d->node.data, ULL d->domains.data); - } else if(cp->type == udb_chunk_type_domain) { - struct domain_d* d = (struct domain_d*)UDB_REL(base, data); - printf(" domain "); - print_dname(d->name, d->namelen); - printf(" node=%llu rrsets=%llu\n", ULL d->node.data, - ULL d->rrsets.data); - } else if(cp->type == udb_chunk_type_rrset) { - struct rrset_d* d = (struct rrset_d*)UDB_REL(base, data); - printf(" rrset type=%d next=%llu rrs=%llu\n", - (int)d->type, ULL d->next.data, ULL d->rrs.data); - } else if(cp->type == udb_chunk_type_rr) { - struct rr_d* d = (struct rr_d*)UDB_REL(base, data); - printf(" rr type=%d class=%d ttl=%u next=%llu len=%d ", - (int)d->type, (int)d->klass, (unsigned)d->ttl, - ULL d->next.data, (int)d->len); - print_hex(d->wire, d->len); - printf("\n"); - } else if(cp->type == udb_chunk_type_task) { - struct task_list_d* d = (struct task_list_d*)UDB_REL(base, data); - printf(" task type=%d next=%llu yesno=%d oldserial=%u newserial=%u zone=%s\n", - (int)d->task_type, ULL d->next.data, (int)d->yesno, - (unsigned)d->oldserial, (unsigned)d->newserial, - d->size > sizeof(*d)? - dname_to_string(d->zname, NULL):"\"\""); - } - } /* end verbosity 2 */ - - /* update stats */ - t->exp_num[exp]++; - if(tp == udb_chunk_type_free) { - t->exp_free[exp]++; - } else { - t->type_num[tp]++; - t->type_exp_num[tp][exp]++; - } - - /* check end marker */ - if(exp == UDB_EXP_XL) { - if(sz != *(uint64_t*)(cv+sz-2*sizeof(uint64_t))) { - printf(" end xl size is wrong: %llu\n", - ULL *(uint64_t*)(cv+sz-2*sizeof(uint64_t))); - } - } - if(exp != *(uint8_t*)(cv+sz-1)) { - printf(" end exp is wrong: %d\n", *(uint8_t*)(cv+sz-1)); - } - return cv+sz; -} - -/** walk through file and inspect contents */ -static void -inspect_all_chunks(void* base, udb_glob_d* g, udb_alloc_d* a, - struct inspect_totals* t) -{ - void* at = base + g->hsize; - while(at < base+a->nextgrow) { - t->num_chunks++; - at = inspect_chunk(base, at, t); - } - printf("end of chunks at %llu\n", ULL (uint64_t)(at-base)); -} - -/** print totals */ -static void -print_totals(struct inspect_totals* t) -{ - int i, tp; - printf("*** total num chunks: %llu\n", ULL t->num_chunks); - for(i=0; i<=UDB_ALLOC_CHUNKS_MAX; i++) { - if(t->exp_num[i] != 0 || t->exp_free[i] != 0) - printf("exp %d chunks: free %llu alloc %llu " - "total %llu\n", i, ULL t->exp_free[i], - ULL (t->exp_num[i] - t->exp_free[i]), - ULL t->exp_num[i]); - } - for(tp=0; tptype_num[tp] == 0) - continue; - printf("type %s num chunks: %llu\n", - chunk_type2str(tp), ULL t->type_num[tp]); - for(i=0; i<=UDB_ALLOC_CHUNKS_MAX; i++) { - if(t->type_exp_num[tp][i] != 0) - printf("type %s exp %d chunks: %llu\n", - chunk_type2str(tp), i, - ULL t->type_exp_num[tp][i]); - } - } -} - -/** inspect contents of mmap */ -static void -inspect_contents(void* base) -{ - udb_glob_d* g; - udb_alloc_d* a; - struct inspect_totals t; - memset(&t, 0, sizeof(t)); - g = inspect_glob_data(base); - a = inspect_alloc(g); - /* walk through file */ - inspect_all_chunks(base, g, a, &t); - print_totals(&t); -} - -/** inspect udb file */ -static void -inspect_file(char* fname) -{ - int fd; - uint64_t sz; - void* base; - printf("inspect file %s\n", fname); - fd = open(fname, O_RDONLY); - if(fd == -1) { - printf("open %s: %s\n", fname, strerror(errno)); - exit(1); - } - sz = inspect_initial(fd); -#ifndef HAVE_MMAP - printf("do not have mmap\n"); - exit(1); -#else - base = mmap(NULL, (size_t)sz, (int)PROT_READ, (int)MAP_SHARED, - (int)fd, (off_t)0); -#endif - if(base == MAP_FAILED) { - printf("mmap %s %u: %s\n", fname, (unsigned)sz, - strerror(errno)); - exit(1); - } - inspect_contents(base); - close(fd); -} - -/** find soa serial (if any) */ -static int -udb_zone_get_serial(udb_base* udb, udb_ptr* zone, uint32_t* serial) -{ - udb_ptr domain, rrset, rr; - buffer_type buffer; - if(!udb_domain_find(udb, zone, ZONE(zone)->name, ZONE(zone)->namelen, - &domain)) - return 0; - if(!udb_rrset_find(udb, &domain, TYPE_SOA, &rrset)) { - udb_ptr_unlink(&domain, udb); - return 0; - } - /* got SOA rrset, use first RR */ - if(!RRSET(&rrset)->rrs.data) { - udb_ptr_unlink(&domain, udb); - udb_ptr_unlink(&rrset, udb); - return 0; - } - udb_ptr_new(&rr, udb, &RRSET(&rrset)->rrs); - udb_ptr_unlink(&domain, udb); - udb_ptr_unlink(&rrset, udb); - /* find serial */ - buffer_create_from(&buffer, RR(&rr)->wire, RR(&rr)->len); - /* skip two dnames */ - if(!packet_skip_dname(&buffer) || !packet_skip_dname(&buffer)) { - udb_ptr_unlink(&rr, udb); - return 0; - } - if(!buffer_available(&buffer, 4*5)) { /* soa rdata u32s */ - udb_ptr_unlink(&rr, udb); - return 0; - } - *serial = buffer_read_u32(&buffer); - udb_ptr_unlink(&rr, udb); - return 1; -} - -/** print one line with udb RR */ -static void -print_udb_rr(uint8_t* name, udb_ptr* urr) -{ - buffer_type buffer; - region_type* region = region_create(xalloc, free); - region_type* tmpregion = region_create(xalloc, free); - buffer_type* tmpbuffer = buffer_create(region, MAX_RDLENGTH); - rr_type rr; - ssize_t c; - domain_table_type* owners; - - owners = domain_table_create(region); - rr.owner = domain_table_insert(owners, dname_make(region, name, 0)); - - /* to RR */ - rr.type = RR(urr)->type; - rr.klass = RR(urr)->klass; - rr.ttl = RR(urr)->ttl; - buffer_create_from(&buffer, RR(urr)->wire, RR(urr)->len); - c = rdata_wireformat_to_rdata_atoms(region, owners, RR(urr)->type, - RR(urr)->len, &buffer, &rr.rdatas); - if(c == -1) { - printf("cannot parse wireformat\n"); - region_destroy(region); - return; - } - rr.rdata_count = c; - - print_rr(stdout, NULL, &rr, tmpregion, tmpbuffer); - - region_destroy(region); - region_destroy(tmpregion); -} - -/** list rrs */ -static void -list_rrs(udb_base* udb, udb_ptr* rrset, udb_ptr* domain) -{ - udb_ptr rr; - udb_ptr_new(&rr, udb, &RRSET(rrset)->rrs); - while(rr.data) { - print_udb_rr(DOMAIN(domain)->name, &rr); - udb_ptr_set_rptr(&rr, udb, &RR(&rr)->next); - } - udb_ptr_unlink(&rr, udb); -} - -/** list RRsets */ -static void -list_rrsets(udb_base* udb, udb_ptr* domain) -{ - udb_ptr rrset; - udb_ptr_new(&rrset, udb, &DOMAIN(domain)->rrsets); - while(rrset.data) { - list_rrs(udb, &rrset, domain); - udb_ptr_set_rptr(&rrset, udb, &RRSET(&rrset)->next); - } - udb_ptr_unlink(&rrset, udb); -} - -/** list domain RRs */ -static void -list_domains(udb_base* udb, udb_ptr* dtree) -{ - udb_ptr d; - for(udb_radix_first(udb,dtree,&d); d.data; udb_radix_next(udb,&d)) { - udb_ptr domain; - udb_ptr_new(&domain, udb, &RADNODE(&d)->elem); - list_rrsets(udb, &domain); - udb_ptr_unlink(&domain, udb); - } - udb_ptr_unlink(&d, udb); -} - -/** list zone contents */ -static void -list_zone_contents(udb_base* udb, udb_ptr* zone) -{ - udb_ptr dtree; - udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); - if(v) { - time_t t = (time_t)ZONE(zone)->mtime; - uint32_t serial; - printf("# %llu domains, %llu RRsets, %llu RRs%s, ", - ULL RADTREE(&dtree)->count, - ULL ZONE(zone)->rrset_count, - ULL ZONE(zone)->rr_count, - ZONE(zone)->expired?", is_expired":""); - if(udb_zone_get_serial(udb, zone, &serial)) { - printf("%u, ", (unsigned)serial); - } - printf("%s", ctime(&t)); - if(ZONE(zone)->nsec3param.data) { - udb_ptr n3; - udb_ptr_new(&n3, udb, &ZONE(zone)->nsec3param); -#ifdef NSEC3 - printf("# nsec3param %s\n", udb_nsec3param_string(&n3)); -#else - printf("# nsec3param "); - print_udb_rr(ZONE(zone)->name, &n3); -#endif - udb_ptr_unlink(&n3, udb); - } - } - if(v >= 2) { - list_domains(udb, &dtree); - } - udb_ptr_unlink(&dtree, udb); -} - -/** list zones in zone tree */ -static void -list_zones(udb_base* udb, udb_ptr* ztree) -{ - udb_ptr z; - for(udb_radix_first(udb,ztree,&z); z.data; udb_radix_next(udb,&z)) { - udb_ptr zone; - udb_ptr_new(&zone, udb, &RADNODE(&z)->elem); - printf("zone: name: \""); - print_dname(ZONE(&zone)->name, ZONE(&zone)->namelen); - printf("\"\n"); - if(v) list_zone_contents(udb, &zone); - udb_ptr_unlink(&zone, udb); - } - udb_ptr_unlink(&z, udb); -} - -/** list contents of NSD.DB file */ -static void -list_file(char* fname) -{ - udb_base* udb; - udb_ptr ztree; - log_init("udb-inspect"); - udb = udb_base_create_read(fname, &namedb_walkfunc, NULL); - if(!udb) { printf("cannot open udb %s\n", fname); exit(1); } - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - if(udb_ptr_is_null(&ztree)) { - printf("file is not inited\n"); - exit(1); - } - /* print header info */ - printf("%s: %llu zones, %llu bytes\n", fname, - ULL RADTREE(&ztree)->count, - ULL udb->alloc->disk->nextgrow); - if(udb_base_get_userflags(udb)) { - printf("file is corrupted! (%u)\n", - (unsigned)udb_base_get_userflags(udb)); - } - /* print detail info */ - list_zones(udb, &ztree); - udb_ptr_unlink(&ztree, udb); - udb_base_free(udb); -} - - -/** getopt global, in case header files fail to declare it. */ -extern int optind; -/** getopt global, in case header files fail to declare it. */ -extern char* optarg; - -/** - * main program. Set options given commandline arguments. - * @param argc: number of commandline arguments. - * @param argv: array of commandline arguments. - * @return: exit status of the program. - */ -int -main(int argc, char* argv[]) -{ - int c, list=0; - while( (c=getopt(argc, argv, "hlv")) != -1) { - switch(c) { - case 'l': - list=1; - break; - case 'v': - v++; - break; - default: - case 'h': - usage(); - return 1; - } - } - argc -= optind; - argv += optind; - if(argc != 1) { - usage(); - return 1; - } - if(list) list_file(argv[0]); - else inspect_file(argv[0]); - - return 0; -} diff --git a/tpkg/cutest_qroot.tdir/root.conf b/tpkg/cutest_qroot.tdir/root.conf index e1fb9900b..e98d3ae79 100644 --- a/tpkg/cutest_qroot.tdir/root.conf +++ b/tpkg/cutest_qroot.tdir/root.conf @@ -1,7 +1,6 @@ server: #logfile: "test.log" logfile: "/dev/stderr" - database: "root.db" difffile: "root.ixfr.db" xfrdfile: "root.xfrd.state" zonesdir: "" diff --git a/tpkg/cutest_qroot.tdir/root2.conf b/tpkg/cutest_qroot.tdir/root2.conf index d2d0f4162..cf0725a65 100644 --- a/tpkg/cutest_qroot.tdir/root2.conf +++ b/tpkg/cutest_qroot.tdir/root2.conf @@ -1,7 +1,6 @@ server: #logfile: "test.log" logfile: "/dev/stderr" - database: "root2.db" difffile: "root2.ixfr.db" xfrdfile: "root2.xfrd.state" zonesdir: "" diff --git a/tpkg/cutest_qroot.tdir/unsigned.conf b/tpkg/cutest_qroot.tdir/unsigned.conf index 80559fb97..0363c466f 100644 --- a/tpkg/cutest_qroot.tdir/unsigned.conf +++ b/tpkg/cutest_qroot.tdir/unsigned.conf @@ -1,7 +1,6 @@ server: #logfile: "test.log" logfile: "/dev/stderr" - database: "unsigned.db" difffile: "unsigned.ixfr.db" xfrdfile: "unsigned.xfrd.state" zonesdir: "" diff --git a/tpkg/dname_below.tdir/dname_below.conf b/tpkg/dname_below.tdir/dname_below.conf index 97425fd71..9b08b2e69 100644 --- a/tpkg/dname_below.tdir/dname_below.conf +++ b/tpkg/dname_below.tdir/dname_below.conf @@ -1,11 +1,10 @@ # config server: - zonesdir: "" + zonesdir: "" username: "" chroot: "" pidfile: nsd.pid logfile: nsd.log - database: nsd.db xfrdfile: nsd.xfrd difffile: nsd.ixfr zonelistfile: "zone.list" diff --git a/tpkg/dname_test.tdir/dname_test.conf b/tpkg/dname_test.tdir/dname_test.conf index 02315fd5a..a8079d62b 100644 --- a/tpkg/dname_test.tdir/dname_test.conf +++ b/tpkg/dname_test.tdir/dname_test.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" #logfile: "dname_test.log" - database: "dname_test.db" username: "" pidfile: "dname_test.pid" zonesdir: "" diff --git a/tpkg/dname_test.tdir/dname_test_x.conf b/tpkg/dname_test.tdir/dname_test_x.conf index 0e976a576..6c15a25b8 100644 --- a/tpkg/dname_test.tdir/dname_test_x.conf +++ b/tpkg/dname_test.tdir/dname_test_x.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" #logfile: "dname_test.log" - database: "dname_test.db" username: "" pidfile: "dname_test.pid" zonesdir: "" diff --git a/tpkg/dns-cookies.tdir/dns-cookies.test.conf b/tpkg/dns-cookies.tdir/dns-cookies.test.conf index bcd209960..a14750f57 100644 --- a/tpkg/dns-cookies.tdir/dns-cookies.test.conf +++ b/tpkg/dns-cookies.tdir/dns-cookies.test.conf @@ -1,6 +1,5 @@ server: username: "" - database: "" zonesdir: "" xfrdfile: "" cookie-secret-file: "cookiesecrets.txt" diff --git a/tpkg/drop_updates.tdir/drop_updates.conf b/tpkg/drop_updates.tdir/drop_updates.conf index 26a69eda1..2b4e9f2b2 100644 --- a/tpkg/drop_updates.tdir/drop_updates.conf +++ b/tpkg/drop_updates.tdir/drop_updates.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 drop-updates: NSD_DROP_UPDATES zonelistfile: "zone.list" diff --git a/tpkg/drop_updates.tdir/drop_updates.test b/tpkg/drop_updates.tdir/drop_updates.test index d3b8f410b..2c642a2f1 100644 --- a/tpkg/drop_updates.tdir/drop_updates.test +++ b/tpkg/drop_updates.tdir/drop_updates.test @@ -17,7 +17,7 @@ exit_code=0 $TPKG_NSD -c $(pwd)/drop_updates_no.conf -V 5 -a 127.0.0.1 -p $TPKG_PORT wait_nsd_up nsd.log -dig @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns www.example.net \ +dig -4 @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns www.example.net \ > drop_updates_no.query 2>&1 if [ ${?} -eq 0 ] && grep 'status: NOERROR' drop_updates_no.query >/dev/null \ && grep 'www\.example\.net\.' drop_updates_no.query >/dev/null; then @@ -29,7 +29,7 @@ else cat drop_updates_no.query fi -dig @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns +opcode=UPDATE www.example.net \ +dig -4 @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns +opcode=UPDATE www.example.net \ > drop_updates_no.update 2>&1 if [ ${?} -eq 0 ] && grep 'status: NOTIMP' drop_updates_no.update >/dev/null; then echo "UPDATE result with drop-updates: no was correct" @@ -54,7 +54,7 @@ rm -f nsd.log nsd.pid $TPKG_NSD -c $(pwd)/drop_updates_yes.conf -V 5 -a 127.0.0.1 -p $TPKG_PORT wait_nsd_up nsd.log -dig @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns www.example.net \ +dig -4 @127.0.0.1 -p ${TPKG_PORT} +timeout=1 +noedns www.example.net \ > drop_updates_yes.query 2>&1 if [ ${?} -eq 0 ] && grep 'status: NOERROR' drop_updates_yes.query >/dev/null \ && grep 'www\.example\.net\.' drop_updates_yes.query >/dev/null; then @@ -66,9 +66,9 @@ else cat drop_updates_yes.query fi -dig @127.0.0.1 -p ${TPKG_PORT} +noedns +opcode=UPDATE +timeout=1 www.example.net \ +dig -4 @127.0.0.1 -p ${TPKG_PORT} +noedns +opcode=UPDATE +timeout=1 www.example.net \ > drop_updates_yes.update 2>&1 -if [ ${?} -eq 9 ] && grep 'connection timed out' drop_updates_yes.update >/dev/null; then +if [ ${?} -eq 9 ] && grep 'timed out' drop_updates_yes.update >/dev/null; then echo "UPDATE result with drop-updates: yes was correct" else exit_code=1 diff --git a/tpkg/ipseckey.tdir/ipseckey.conf b/tpkg/ipseckey.tdir/ipseckey.conf index d8fecaca3..29b4333ea 100644 --- a/tpkg/ipseckey.tdir/ipseckey.conf +++ b/tpkg/ipseckey.tdir/ipseckey.conf @@ -1,6 +1,5 @@ # config server: - database: "ipseckey.db" difffile: "ixfr.db" zonesdir: "" username: "" diff --git a/tpkg/ixfr_and_restart.tdir/ixfr_and_restart.conf b/tpkg/ixfr_and_restart.tdir/ixfr_and_restart.conf index 5b53216f7..8c976875c 100644 --- a/tpkg/ixfr_and_restart.tdir/ixfr_and_restart.conf +++ b/tpkg/ixfr_and_restart.tdir/ixfr_and_restart.conf @@ -3,7 +3,6 @@ server: xfrdir: "" xfrdfile: "xfrd.state" zonelistfile: "zone.list" - database: "" pidfile: "nsd.pid" server-count: 1 port: NSD_PORT diff --git a/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf b/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf index 0fcb07ef7..ee83cacff 100644 --- a/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf +++ b/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf2 b/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf2 index c3c9cce5d..272a2242b 100644 --- a/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf2 +++ b/tpkg/ixfr_badformat.tdir/ixfr_badformat.conf2 @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone2.list" interface: 127.0.0.1 diff --git a/tpkg/ixfr_faildel.tdir/ixfr_faildel.conf b/tpkg/ixfr_faildel.tdir/ixfr_faildel.conf index 9e814ba2a..00f802a46 100644 --- a/tpkg/ixfr_faildel.tdir/ixfr_faildel.conf +++ b/tpkg/ixfr_faildel.tdir/ixfr_faildel.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "ixfr_faildel.db" zonesdir: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/ixfr_gone.tdir/ixfr_gone.conf b/tpkg/ixfr_gone.tdir/ixfr_gone.conf index f8d0dd275..309e0314a 100644 --- a/tpkg/ixfr_gone.tdir/ixfr_gone.conf +++ b/tpkg/ixfr_gone.tdir/ixfr_gone.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" xfrdir: NSD_XFRDIR xfrdfile: xfrd.state - database: "" pidfile: nsd.pid verbosity: 5 ip-address: 127.0.0.1@NSD_PORT diff --git a/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf b/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf index cd89b5cab..a221bacfe 100644 --- a/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf +++ b/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf2 b/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf2 index 32269e13d..ba6b4a051 100644 --- a/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf2 +++ b/tpkg/ixfr_outsync.tdir/ixfr_outsync.conf2 @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone2.list" interface: 127.0.0.1 diff --git a/tpkg/ixfr_wildcard.tdir/ixfr_wildcard.conf b/tpkg/ixfr_wildcard.tdir/ixfr_wildcard.conf index 8cd88cb22..15463edf9 100644 --- a/tpkg/ixfr_wildcard.tdir/ixfr_wildcard.conf +++ b/tpkg/ixfr_wildcard.tdir/ixfr_wildcard.conf @@ -7,8 +7,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" - #nsd.db xfrd-reload-timeout: 1 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/ixfrout-add-delete.tdir/ixfrout-add-delete.conf b/tpkg/ixfrout-add-delete.tdir/ixfrout-add-delete.conf index 69f0fef7a..50544bff7 100644 --- a/tpkg/ixfrout-add-delete.tdir/ixfrout-add-delete.conf +++ b/tpkg/ixfrout-add-delete.tdir/ixfrout-add-delete.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" diff --git a/tpkg/ixfrout.tdir/ixfrout.conf b/tpkg/ixfrout.tdir/ixfrout.conf index 0005f8e5e..ac828f51c 100644 --- a/tpkg/ixfrout.tdir/ixfrout.conf +++ b/tpkg/ixfrout.tdir/ixfrout.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_create.tdir/ixfrout_create.conf b/tpkg/ixfrout_create.tdir/ixfrout_create.conf index f77ad4658..12b943c57 100644 --- a/tpkg/ixfrout_create.tdir/ixfrout_create.conf +++ b/tpkg/ixfrout_create.tdir/ixfrout_create.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_create_num.tdir/ixfrout_create_num.conf b/tpkg/ixfrout_create_num.tdir/ixfrout_create_num.conf index 50ce6ea01..bdec268bd 100644 --- a/tpkg/ixfrout_create_num.tdir/ixfrout_create_num.conf +++ b/tpkg/ixfrout_create_num.tdir/ixfrout_create_num.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_create_size.tdir/ixfrout_create_size.conf b/tpkg/ixfrout_create_size.tdir/ixfrout_create_size.conf index 7f6789507..b736cdce9 100644 --- a/tpkg/ixfrout_create_size.tdir/ixfrout_create_size.conf +++ b/tpkg/ixfrout_create_size.tdir/ixfrout_create_size.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_fetch_num.tdir/ixfrout_fetch_num.conf b/tpkg/ixfrout_fetch_num.tdir/ixfrout_fetch_num.conf index febd98e40..b0703134a 100644 --- a/tpkg/ixfrout_fetch_num.tdir/ixfrout_fetch_num.conf +++ b/tpkg/ixfrout_fetch_num.tdir/ixfrout_fetch_num.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_fetch_size.tdir/ixfrout_fetch_size.conf b/tpkg/ixfrout_fetch_size.tdir/ixfrout_fetch_size.conf index feb0be3ac..14642827b 100644 --- a/tpkg/ixfrout_fetch_size.tdir/ixfrout_fetch_size.conf +++ b/tpkg/ixfrout_fetch_size.tdir/ixfrout_fetch_size.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_large.tdir/ixfrout_large.conf b/tpkg/ixfrout_large.tdir/ixfrout_large.conf index 3cc29d509..ef635c211 100644 --- a/tpkg/ixfrout_large.tdir/ixfrout_large.conf +++ b/tpkg/ixfrout_large.tdir/ixfrout_large.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_stats.tdir/ixfrout_stats.conf b/tpkg/ixfrout_stats.tdir/ixfrout_stats.conf index c1f72c067..38951a0e2 100644 --- a/tpkg/ixfrout_stats.tdir/ixfrout_stats.conf +++ b/tpkg/ixfrout_stats.tdir/ixfrout_stats.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_threeread.tdir/ixfrout_threeread.conf b/tpkg/ixfrout_threeread.tdir/ixfrout_threeread.conf index 561d289ef..e71ac780b 100644 --- a/tpkg/ixfrout_threeread.tdir/ixfrout_threeread.conf +++ b/tpkg/ixfrout_threeread.tdir/ixfrout_threeread.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_threeversions.tdir/ixfrout_threeversions.conf b/tpkg/ixfrout_threeversions.tdir/ixfrout_threeversions.conf index 861f1f931..7f87a4bb7 100644 --- a/tpkg/ixfrout_threeversions.tdir/ixfrout_threeversions.conf +++ b/tpkg/ixfrout_threeversions.tdir/ixfrout_threeversions.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_threewrite.tdir/ixfrout_threewrite.conf b/tpkg/ixfrout_threewrite.tdir/ixfrout_threewrite.conf index 6e30ebed5..3eb27f606 100644 --- a/tpkg/ixfrout_threewrite.tdir/ixfrout_threewrite.conf +++ b/tpkg/ixfrout_threewrite.tdir/ixfrout_threewrite.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/ixfrout_tsig.tdir/ixfrout_tsig.conf b/tpkg/ixfrout_tsig.tdir/ixfrout_tsig.conf index 340898dbc..e828b435b 100644 --- a/tpkg/ixfrout_tsig.tdir/ixfrout_tsig.conf +++ b/tpkg/ixfrout_tsig.tdir/ixfrout_tsig.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "" zonesdir: "" zonelistfile: "zone.list" xfrdfile: "nsd.xfrd" diff --git a/tpkg/long/bug145_multiple_zone_xfr.tdir/bug145_multiple_zone_xfr.conf b/tpkg/long/bug145_multiple_zone_xfr.tdir/bug145_multiple_zone_xfr.conf index b0be2fba9..7fd9198f5 100644 --- a/tpkg/long/bug145_multiple_zone_xfr.tdir/bug145_multiple_zone_xfr.conf +++ b/tpkg/long/bug145_multiple_zone_xfr.tdir/bug145_multiple_zone_xfr.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" username: "" diff --git a/tpkg/long/ixfr_malformed.tdir/ixfr_malformed.conf b/tpkg/long/ixfr_malformed.tdir/ixfr_malformed.conf index cc59c3b45..9f7308e0a 100644 --- a/tpkg/long/ixfr_malformed.tdir/ixfr_malformed.conf +++ b/tpkg/long/ixfr_malformed.tdir/ixfr_malformed.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" zonesdir: "" username: "" chroot: "" diff --git a/tpkg/long/ixfr_remove_unknown.tdir/ixfr_remove_unknown.conf b/tpkg/long/ixfr_remove_unknown.tdir/ixfr_remove_unknown.conf index e974de543..fc6bba001 100644 --- a/tpkg/long/ixfr_remove_unknown.tdir/ixfr_remove_unknown.conf +++ b/tpkg/long/ixfr_remove_unknown.tdir/ixfr_remove_unknown.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" zonesdir: "" xfrd-reload-timeout: 0 zonelistfile: "zone.list" diff --git a/tpkg/long/ixfr_rollback.tdir/ixfr_rollback.conf b/tpkg/long/ixfr_rollback.tdir/ixfr_rollback.conf index 72b259bd9..ef6576576 100644 --- a/tpkg/long/ixfr_rollback.tdir/ixfr_rollback.conf +++ b/tpkg/long/ixfr_rollback.tdir/ixfr_rollback.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/notify_interrupts_axfr.tdir/notify_interrupts_axfr.conf b/tpkg/long/notify_interrupts_axfr.tdir/notify_interrupts_axfr.conf index 8093dacd1..f651b9820 100644 --- a/tpkg/long/notify_interrupts_axfr.tdir/notify_interrupts_axfr.conf +++ b/tpkg/long/notify_interrupts_axfr.tdir/notify_interrupts_axfr.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/reload_timeout.tdir/reload_timeout.conf b/tpkg/long/reload_timeout.tdir/reload_timeout.conf index 83446560c..294015585 100644 --- a/tpkg/long/reload_timeout.tdir/reload_timeout.conf +++ b/tpkg/long/reload_timeout.tdir/reload_timeout.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 10 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf b/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf index a6c6d7601..d27c6c390 100644 --- a/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf +++ b/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf @@ -2,7 +2,6 @@ # conf file for test tsig server: logfile: "/dev/stdout" - database: "master.db" difffile: ixfr.db xfrdfile: xfrd.state zonesdir: "" diff --git a/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf2 b/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf2 index 7d753895a..132c17d1f 100644 --- a/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf2 +++ b/tpkg/long/testplan_axfr.tdir/testplan_axfr.conf2 @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone2.list" diff --git a/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf b/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf index 6343b8e1f..39567f5ef 100644 --- a/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf +++ b/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf @@ -2,7 +2,6 @@ # conf file for test tsig server: logfile: "/dev/stdout" - database: "master.db" difffile: ixfr.db xfrdfile: xfrd.state zonesdir: "" diff --git a/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf2 b/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf2 index 1099e81f0..02194b21d 100644 --- a/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf2 +++ b/tpkg/long/testplan_axfr_tsig.tdir/testplan_axfr_tsig.conf2 @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone2.list" diff --git a/tpkg/long/testplan_deadlock.tdir/testplan_deadlock.conf b/tpkg/long/testplan_deadlock.tdir/testplan_deadlock.conf index dc30d3618..b8fa2cffd 100644 --- a/tpkg/long/testplan_deadlock.tdir/testplan_deadlock.conf +++ b/tpkg/long/testplan_deadlock.tdir/testplan_deadlock.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "nsd.log" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/testplan_ixfr.tdir/testplan_ixfr.conf b/tpkg/long/testplan_ixfr.tdir/testplan_ixfr.conf index 6d1cf7209..233f3aab8 100644 --- a/tpkg/long/testplan_ixfr.tdir/testplan_ixfr.conf +++ b/tpkg/long/testplan_ixfr.tdir/testplan_ixfr.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" verbosity: 5 diff --git a/tpkg/long/testplan_ixfr_pkts.tdir/testplan_ixfr_pkts.conf b/tpkg/long/testplan_ixfr_pkts.tdir/testplan_ixfr_pkts.conf index a8530e58e..acab00c6a 100644 --- a/tpkg/long/testplan_ixfr_pkts.tdir/testplan_ixfr_pkts.conf +++ b/tpkg/long/testplan_ixfr_pkts.tdir/testplan_ixfr_pkts.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/testplan_ixfr_remove.tdir/testplan_ixfr_remove.conf b/tpkg/long/testplan_ixfr_remove.tdir/testplan_ixfr_remove.conf index 1013d0ae2..cf5ec96bc 100644 --- a/tpkg/long/testplan_ixfr_remove.tdir/testplan_ixfr_remove.conf +++ b/tpkg/long/testplan_ixfr_remove.tdir/testplan_ixfr_remove.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "nsd.log" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i1 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i1 index dedab91f3..b4ea45d40 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i1 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i1 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../i1.log" - database: "nsdb.i1.db" xfrdfile: "xfrd.i1.db" difffile: "diff.i1.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i2 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i2 index 7918c4855..ee5e31ac6 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i2 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i2 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../i2.log" - database: "nsdb.i2.db" xfrdfile: "xfrd.i2.db" difffile: "diff.i2.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i3 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i3 index 27ddeeb07..34bc2d7e6 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i3 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_i3 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../i3.log" - database: "nsdb.i3.db" xfrdfile: "xfrd.i3.db" difffile: "diff.i3.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m1 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m1 index 6dbb171a5..ea3d39b41 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m1 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m1 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../m1.log" - database: "nsdb.m1.db" xfrdfile: "xfrd.m1.db" difffile: "diff.m1.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m2 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m2 index 7fbe7b3e9..4bf529fff 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m2 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_m2 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../m2.log" - database: "nsdb.m2.db" xfrdfile: "xfrd.m2.db" difffile: "diff.m2.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s1 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s1 index c303f106a..e043defb9 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s1 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s1 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../s1.log" - database: "nsdb.s1.db" xfrdfile: "xfrd.s1.db" difffile: "diff.s1.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s2 b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s2 index 8468e9587..9fb0ed6dc 100644 --- a/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s2 +++ b/tpkg/long/testplan_mess.tdir/testplan_mess.conf_s2 @@ -2,7 +2,6 @@ server: #logfile: "/dev/stdout" logfile: "../s2.log" - database: "nsdb.s2.db" xfrdfile: "xfrd.s2.db" difffile: "diff.s2.db" xfrd-reload-timeout: 0 diff --git a/tpkg/long/testplan_timeout.tdir/testplan_timeout.conf b/tpkg/long/testplan_timeout.tdir/testplan_timeout.conf index e5068368c..0027baa07 100644 --- a/tpkg/long/testplan_timeout.tdir/testplan_timeout.conf +++ b/tpkg/long/testplan_timeout.tdir/testplan_timeout.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "nsd.log" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" verbosity: 5 diff --git a/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf b/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf index f7d4bf9f5..edf58c274 100644 --- a/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf +++ b/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf @@ -2,7 +2,6 @@ # conf file for test tsig server: logfile: "/dev/stdout" - database: "master.db" difffile: ixfr.db xfrdfile: xfrd.state zonesdir: "" diff --git a/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf2 b/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf2 index 9d6372dba..032d42ea6 100644 --- a/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf2 +++ b/tpkg/long/testplan_tsig_34.tdir/testplan_tsig_34.conf2 @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "/dev/stdout" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone2.list" diff --git a/tpkg/long/xfrd_tcp_overload.tdir/xfrd_tcp_overload.conf b/tpkg/long/xfrd_tcp_overload.tdir/xfrd_tcp_overload.conf index fdaa1a88e..bfe666e68 100644 --- a/tpkg/long/xfrd_tcp_overload.tdir/xfrd_tcp_overload.conf +++ b/tpkg/long/xfrd_tcp_overload.tdir/xfrd_tcp_overload.conf @@ -4,7 +4,6 @@ server: xfrdfile: "xfrd.state.slave" difffile: "ixfr.db.slave" logfile: "nsd.log" - database: "slave.db" xfrd-reload-timeout: 0 zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/manual/size_0.tdir/size_0.conf b/tpkg/manual/size_0.tdir/size_0.conf index 454d2c96a..5186a13bf 100644 --- a/tpkg/manual/size_0.tdir/size_0.conf +++ b/tpkg/manual/size_0.tdir/size_0.conf @@ -1,5 +1,4 @@ server: - database: size_0.db logfile: nsd.log zonesdir: "" zonelistfile: "zone.list" diff --git a/tpkg/manual/source_port_0.tdir/source_port_0.conf b/tpkg/manual/source_port_0.tdir/source_port_0.conf index 8644fc817..29758466d 100644 --- a/tpkg/manual/source_port_0.tdir/source_port_0.conf +++ b/tpkg/manual/source_port_0.tdir/source_port_0.conf @@ -1,6 +1,5 @@ server: logfile: nsd.log - database: source_port_0.db zonesdir: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/minimal_responses.tdir/minimal_responses.conf b/tpkg/minimal_responses.tdir/minimal_responses.conf index 2e3d88174..6991c9b62 100644 --- a/tpkg/minimal_responses.tdir/minimal_responses.conf +++ b/tpkg/minimal_responses.tdir/minimal_responses.conf @@ -1,7 +1,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state - database: nsd.db pidfile: nsd.pid verbosity: 5 ip-address: 127.0.0.1 diff --git a/tpkg/no_cpu_affinity.tdir/no_cpu_affinity.conf b/tpkg/no_cpu_affinity.tdir/no_cpu_affinity.conf index d6112b4f5..4f78c156a 100644 --- a/tpkg/no_cpu_affinity.tdir/no_cpu_affinity.conf +++ b/tpkg/no_cpu_affinity.tdir/no_cpu_affinity.conf @@ -7,7 +7,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nodb.tdir/nodb.conf b/tpkg/nodb.tdir/nodb.conf index f8e6a367e..84980966a 100644 --- a/tpkg/nodb.tdir/nodb.conf +++ b/tpkg/nodb.tdir/nodb.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state zonesdir: "" - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nodb_nsec3_ixfr.tdir/nodb_nsec3_ixfr.conf b/tpkg/nodb_nsec3_ixfr.tdir/nodb_nsec3_ixfr.conf index 14cc324cb..e81db3e4a 100644 --- a/tpkg/nodb_nsec3_ixfr.tdir/nodb_nsec3_ixfr.conf +++ b/tpkg/nodb_nsec3_ixfr.tdir/nodb_nsec3_ixfr.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nodb_write.tdir/nodb_write.conf b/tpkg/nodb_write.tdir/nodb_write.conf index 60c9cf12c..e0d51c55c 100644 --- a/tpkg/nodb_write.tdir/nodb_write.conf +++ b/tpkg/nodb_write.tdir/nodb_write.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state zonesdir: "" - database: "" zonefiles-write: 2 zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/notify_nokey.tdir/notify_nokey.post b/tpkg/notify_nokey.tdir/notify_nokey.post index ff20a152b..2fab24a08 100644 --- a/tpkg/notify_nokey.tdir/notify_nokey.post +++ b/tpkg/notify_nokey.tdir/notify_nokey.post @@ -5,7 +5,6 @@ [ -f .tpkg.var.test ] && source .tpkg.var.test . ../common.sh -rm notify_nokey.db # do your teardown here if [ -z $TPKG_NSD_PID ]; then diff --git a/tpkg/notify_nokey.tdir/notify_nokey.pre b/tpkg/notify_nokey.tdir/notify_nokey.pre index 6173345c6..8666621ef 100644 --- a/tpkg/notify_nokey.tdir/notify_nokey.pre +++ b/tpkg/notify_nokey.tdir/notify_nokey.pre @@ -17,5 +17,5 @@ TPKG_NSD="$PRE/nsd" echo "export TPKG_PORT=$TPKG_PORT" >> .tpkg.var.test echo "export TPKG_NSD_PID=$TPKG_NSD_PID" >> .tpkg.var.test -$TPKG_NSD -c notify_nokey.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID -f notify_nokey.db +$TPKG_NSD -c notify_nokey.conf -u "" -p $TPKG_PORT -P $TPKG_NSD_PID wait_nsd_up nsd.log diff --git a/tpkg/nsd-control.tdir/nsd-control.conf b/tpkg/nsd-control.tdir/nsd-control.conf index 6c76dbff7..b60c8b892 100644 --- a/tpkg/nsd-control.tdir/nsd-control.conf +++ b/tpkg/nsd-control.tdir/nsd-control.conf @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "nsd.zonelist" zonesdir: "" diff --git a/tpkg/nsec3_axfr.tdir/nsec3_axfr.conf b/tpkg/nsec3_axfr.tdir/nsec3_axfr.conf index 2cb0643e6..337c5976b 100644 --- a/tpkg/nsec3_axfr.tdir/nsec3_axfr.conf +++ b/tpkg/nsec3_axfr.tdir/nsec3_axfr.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_axfr_add.tdir/nsec3_axfr_add.conf b/tpkg/nsec3_axfr_add.tdir/nsec3_axfr_add.conf index dd845c01d..6571a1855 100644 --- a/tpkg/nsec3_axfr_add.tdir/nsec3_axfr_add.conf +++ b/tpkg/nsec3_axfr_add.tdir/nsec3_axfr_add.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_ixfr.tdir/nsec3_ixfr.conf b/tpkg/nsec3_ixfr.tdir/nsec3_ixfr.conf index 300f27c28..5f8b9bebc 100644 --- a/tpkg/nsec3_ixfr.tdir/nsec3_ixfr.conf +++ b/tpkg/nsec3_ixfr.tdir/nsec3_ixfr.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_ixfr_neg.tdir/nsec3_ixfr_neg.conf b/tpkg/nsec3_ixfr_neg.tdir/nsec3_ixfr_neg.conf index 899ad59b7..d29f445c2 100644 --- a/tpkg/nsec3_ixfr_neg.tdir/nsec3_ixfr_neg.conf +++ b/tpkg/nsec3_ixfr_neg.tdir/nsec3_ixfr_neg.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_parentaxfr.tdir/nsec3_parentaxfr.conf b/tpkg/nsec3_parentaxfr.tdir/nsec3_parentaxfr.conf index 56797b1ef..15507c1e1 100644 --- a/tpkg/nsec3_parentaxfr.tdir/nsec3_parentaxfr.conf +++ b/tpkg/nsec3_parentaxfr.tdir/nsec3_parentaxfr.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" pidfile: "nsd.pid" - database: "nsec3_parentaxfr.db" zonesdir: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_resalt.tdir/nsec3_resalt.conf b/tpkg/nsec3_resalt.tdir/nsec3_resalt.conf index 73964a4d4..7a39bca3b 100644 --- a/tpkg/nsec3_resalt.tdir/nsec3_resalt.conf +++ b/tpkg/nsec3_resalt.tdir/nsec3_resalt.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_resaltbroken.tdir/nsec3_resaltbroken.conf b/tpkg/nsec3_resaltbroken.tdir/nsec3_resaltbroken.conf index f8ea710c2..abb1498ea 100644 --- a/tpkg/nsec3_resaltbroken.tdir/nsec3_resaltbroken.conf +++ b/tpkg/nsec3_resaltbroken.tdir/nsec3_resaltbroken.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/nsec3_wildnodatads.tdir/nsec3_wildnodatads.conf b/tpkg/nsec3_wildnodatads.tdir/nsec3_wildnodatads.conf index 54f248bd8..01a2eecbc 100644 --- a/tpkg/nsec3_wildnodatads.tdir/nsec3_wildnodatads.conf +++ b/tpkg/nsec3_wildnodatads.tdir/nsec3_wildnodatads.conf @@ -6,7 +6,6 @@ server: xfrdir: "." xfrdfile: "nsd.xfrd" zonelistfile: "zone.list" - database: "" interface: 127.0.0.1 zone: diff --git a/tpkg/nsec3param_detect.tdir/nsec3param_detect.conf b/tpkg/nsec3param_detect.tdir/nsec3param_detect.conf index 63e5f4fc2..5732ce7e6 100644 --- a/tpkg/nsec3param_detect.tdir/nsec3param_detect.conf +++ b/tpkg/nsec3param_detect.tdir/nsec3param_detect.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" zonesdir: "" - database: nsec3param_detect.db username: "" chroot: "" xfrdfile: nsd.xfrd diff --git a/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf b/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf index ab6e0ada0..60f6bee02 100644 --- a/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf +++ b/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf @@ -3,7 +3,6 @@ server: logfile: "master.log" difffile: ixfr.db xfrdfile: xfrd.state - database: outgoing_ifc.db zonesdir: "" pidfile: outgoing_ifc.pid.master username: "" diff --git a/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf2 b/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf2 index f2933da3b..73edef5d7 100644 --- a/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf2 +++ b/tpkg/outgoing_ifc.tdir/outgoing_ifc.conf2 @@ -3,7 +3,6 @@ server: logfile: "slave.log" difffile: "ixfr.db.2" xfrdfile: "xfrd.state.2" - database: outgoing_ifc.db.2 zonesdir: "" pidfile: outgoing_ifc.pid.slave username: "" diff --git a/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf b/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf index cf5f53a70..b4dbaf5c1 100644 --- a/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf +++ b/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf @@ -3,7 +3,6 @@ server: logfile: "master.log" difffile: ixfr.db xfrdfile: xfrd.state - database: outgoing_ifc_denied.db zonesdir: "" pidfile: outgoing_ifc_denied.pid.master username: "" diff --git a/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf2 b/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf2 index 1ffd20b45..f55335bed 100644 --- a/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf2 +++ b/tpkg/outgoing_ifc_denied.tdir/outgoing_ifc_denied.conf2 @@ -3,7 +3,6 @@ server: logfile: "slave.log" difffile: "ixfr.db.2" xfrdfile: "xfrd.state.2" - database: outgoing_ifc_denied.db.2 zonesdir: "" pidfile: outgoing_ifc_denied.pid.slave username: "" diff --git a/tpkg/rr-test.tdir/rr-test.conf b/tpkg/rr-test.tdir/rr-test.conf index d7dde8f51..ddfc911b5 100644 --- a/tpkg/rr-test.tdir/rr-test.conf +++ b/tpkg/rr-test.tdir/rr-test.conf @@ -1,6 +1,5 @@ # config server: - database: "rr-test.db" difffile: "ixfr.db" zonesdir: "" username: "" diff --git a/tpkg/rr-test.tdir/rr-test.test b/tpkg/rr-test.tdir/rr-test.test index 65ebee77e..1a316b095 100644 --- a/tpkg/rr-test.tdir/rr-test.test +++ b/tpkg/rr-test.tdir/rr-test.test @@ -38,50 +38,51 @@ else fi # test wireformat parse routine, by reading the db again. -echo "" -echo "second test (read own wireformat from db)" -rm -f rr-test.zone +# on-disk binary database has been removed +#echo "" +#echo "second test (read own wireformat from db)" +#rm -f rr-test.zone mv cmp.zone firstwrite.zone -../../nsd -c nsd.conf -p $RND_PORT -wait_nsd_up nsd.log -../../nsd-control -c nsd.conf write -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -if test ! -f rr-test.zone; then sleep 1; fi -kill_pid `cat nsd.pid` - -grep -v "^;" rr-test.zone > cmp.zone - -if wdiff bak.zone cmp.zone >/dev/null; then - echo "diff ok, for read of database (wireformat read)" -else - echo "zone printed differently, the second time (wireformat read)" - cat nsd.log - wdiff -3 bak.zone cmp.zone - exit 1 -fi - -mv cmp.zone secondwrite.zone -if wdiff firstwrite.zone secondwrite.zone >/dev/null; then - echo "diff ok" -else - echo "zone printed differently, the second time" - cat nsd.log - wdiff -3 firstwrite.zone secondwrite.zone - exit 1 -fi +#../../nsd -c nsd.conf -p $RND_PORT +#wait_nsd_up nsd.log +#../../nsd-control -c nsd.conf write +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#if test ! -f rr-test.zone; then sleep 1; fi +#kill_pid `cat nsd.pid` +# +#grep -v "^;" rr-test.zone > cmp.zone +# +#if wdiff bak.zone cmp.zone >/dev/null; then +# echo "diff ok, for read of database (wireformat read)" +#else +# echo "zone printed differently, the second time (wireformat read)" +# cat nsd.log +# wdiff -3 bak.zone cmp.zone +# exit 1 +#fi +# +#mv cmp.zone secondwrite.zone +#if wdiff firstwrite.zone secondwrite.zone >/dev/null; then +# echo "diff ok" +#else +# echo "zone printed differently, the second time" +# cat nsd.log +# wdiff -3 firstwrite.zone secondwrite.zone +# exit 1 +#fi # now read its own output. echo "" echo "third test (read own text output)" -rm -f rr-test.db +#rm -f rr-test.db ../../nsd -c nsd.conf -p $RND_PORT -V 3 wait_nsd_up nsd.log wait_logfile nsd.log "read with success" 10 diff --git a/tpkg/rr-wks.tdir/rr-wks.conf b/tpkg/rr-wks.tdir/rr-wks.conf index d8e84c80a..e9fb1ebb1 100644 --- a/tpkg/rr-wks.tdir/rr-wks.conf +++ b/tpkg/rr-wks.tdir/rr-wks.conf @@ -1,6 +1,5 @@ # config server: - database: "rr-wks.db" difffile: "ixfr.db" zonesdir: "" username: "" diff --git a/tpkg/soa_test.tdir/soa_test.conf b/tpkg/soa_test.tdir/soa_test.conf index afbd0ac83..f42573be7 100644 --- a/tpkg/soa_test.tdir/soa_test.conf +++ b/tpkg/soa_test.tdir/soa_test.conf @@ -5,7 +5,6 @@ server: zonesdir: "" logfile: nsd.log xfrdfile: nsd.xfrd difffile: nsd.ixfr - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 zone: name: example1.com. zonefile: soa_test.zone1 diff --git a/tpkg/socket_partitioning.tdir/socket_partitioning.conf b/tpkg/socket_partitioning.tdir/socket_partitioning.conf index 26fd8b155..00ef421e3 100644 --- a/tpkg/socket_partitioning.tdir/socket_partitioning.conf +++ b/tpkg/socket_partitioning.tdir/socket_partitioning.conf @@ -9,7 +9,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" diff --git a/tpkg/svcb.tdir/svcb.primary.conf b/tpkg/svcb.tdir/svcb.primary.conf index 8a49b543c..c5cea9396 100644 --- a/tpkg/svcb.tdir/svcb.primary.conf +++ b/tpkg/svcb.tdir/svcb.primary.conf @@ -1,6 +1,5 @@ server: logfile: "nsd.log" - database: "" zonesdir: "" xfrdfile: "" zonelistfile: "" diff --git a/tpkg/svcb.tdir/svcb.secondary.conf.in b/tpkg/svcb.tdir/svcb.secondary.conf.in index 00e827c2f..17bd68819 100644 --- a/tpkg/svcb.tdir/svcb.secondary.conf.in +++ b/tpkg/svcb.tdir/svcb.secondary.conf.in @@ -1,6 +1,5 @@ server: logfile: "nsd-secondary.log" - database: "" zonesdir: "" xfrdfile: "" zonelistfile: "" diff --git a/tpkg/terminate_unclean.tdir/terminate_unclean.conf b/tpkg/terminate_unclean.tdir/terminate_unclean.conf index b3e40053b..948709ba2 100644 --- a/tpkg/terminate_unclean.tdir/terminate_unclean.conf +++ b/tpkg/terminate_unclean.tdir/terminate_unclean.conf @@ -2,7 +2,6 @@ server: xfrdfile: "xfrd.state" #difffile: "ixfr.db" - database: "nsd.db" logfile: "/dev/stderr" zonelistfile: "terminate_unclean.zonelist" zonesdir: "" diff --git a/tpkg/tls.tdir/tls.conf b/tpkg/tls.tdir/tls.conf index 205c66e43..f71f50160 100644 --- a/tpkg/tls.tdir/tls.conf +++ b/tpkg/tls.tdir/tls.conf @@ -4,7 +4,6 @@ server: xfrdfile: tls.xfrd.state identity: "testserver" zonesdir: "" - database: "" interface: 127.0.0.1 interface: 127.0.0.1@TLSPORT tls-service-key: "nsd_server.key" diff --git a/tpkg/unknown_rr.tdir/unknown_rr.conf b/tpkg/unknown_rr.tdir/unknown_rr.conf index e9fc38815..89e210dea 100644 --- a/tpkg/unknown_rr.tdir/unknown_rr.conf +++ b/tpkg/unknown_rr.tdir/unknown_rr.conf @@ -1,6 +1,5 @@ server: difffile: "ixfr.db" - database: unknown_rr.db zonesdir: "" username: "" chroot: "" diff --git a/tpkg/verify.tdir/verify.conf b/tpkg/verify.tdir/verify.conf index f18a7daa2..f0c91ed46 100644 --- a/tpkg/verify.tdir/verify.conf +++ b/tpkg/verify.tdir/verify.conf @@ -1,7 +1,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state - database: "" pidfile: nsd.pid verbosity: 5 ip-address: 127.0.0.1@NSD_PORT diff --git a/tpkg/verify_again.tdir/verify_again.conf b/tpkg/verify_again.tdir/verify_again.conf index 8bac105e3..aba74616d 100644 --- a/tpkg/verify_again.tdir/verify_again.conf +++ b/tpkg/verify_again.tdir/verify_again.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" verbosity: 5 zonelistfile: "zone.list" diff --git a/tpkg/verify_no.tdir/verify_no.conf b/tpkg/verify_no.tdir/verify_no.conf index a0b22f383..aaff5b44d 100644 --- a/tpkg/verify_no.tdir/verify_no.conf +++ b/tpkg/verify_no.tdir/verify_no.conf @@ -1,7 +1,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state - database: "" pidfile: nsd.pid verbosity: 5 ip-address: 127.0.0.1@NSD_PORT diff --git a/tpkg/verify_repat.tdir/verify_repat.conf.in b/tpkg/verify_repat.tdir/verify_repat.conf.in index 95875a5f9..c832a65a3 100644 --- a/tpkg/verify_repat.tdir/verify_repat.conf.in +++ b/tpkg/verify_repat.tdir/verify_repat.conf.in @@ -1,7 +1,6 @@ server: xfrdfile: "xfrd.state" difffile: "ixfr.db" - database: "" pidfile: nsd.pid logfile: nsd.log zonelistfile: "control-repat-zone-verifier.zonelist" diff --git a/tpkg/verify_timeout.tdir/verify_timeout.conf b/tpkg/verify_timeout.tdir/verify_timeout.conf index 1a374128c..e052d4c63 100644 --- a/tpkg/verify_timeout.tdir/verify_timeout.conf +++ b/tpkg/verify_timeout.tdir/verify_timeout.conf @@ -1,7 +1,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state - database: "" pidfile: nsd.pid verbosity: 5 ip-address: 127.0.0.1@NSD_PORT diff --git a/tpkg/xfr_update.tdir/nsd_control.key b/tpkg/xfr_update.tdir/nsd_control.key new file mode 100644 index 000000000..df560829a --- /dev/null +++ b/tpkg/xfr_update.tdir/nsd_control.key @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG5AIBAAKCAYEAp6tA9X7sVaSMYtQh8FkQLhXERl05wDDxKr+Sqap/mctNoh27 +f7Y37actgIkjw0FqJByrg73j1bqoVvRwJMWCrQCYP/oAw66rG4FDSN3jBg8lCeXz +4qJETiZnZQRdWeJyjap6mm6Gj1CzWqmKq9bH+sJEEpXEA/rQM8PL1fSm5RXExSo4 +7RoemL8jafZd3j/JPUSunj/2/TLRKvJsCJV2JLFLQFvt/4G56C++ExQKsuN6QpfE +xZmC5cEHhpYQBk5AfvbSqwzxGgldFQLyboA22spvh3uxVrYJj1bMDfO8Ij5d0Ku/ +rulsZVoaukudr/hhmI56A2IkYZemYdTMAeCrflYJD9TPx0eXzPtLoPJIyUlJ7MCu +0rgN+FbH7jDM1GC9zpQyBtLr97/rNHzk+z2N2WcgYbDhBW13Dv9QkIb2+ZPxhu2W +5OTNEdu4+SHZOtYdPXN7NssiS2ZSIp8+ohkRzZgc8hsPr0yjt78IlzR5DVayz6ve +v9aRjdao0vlAroIvAgMBAAECggGAD7f+XwWHIoBKqPk6NU4kNi3UOMSEpX/xHBDZ +rw5M6B4nKQugiFiM5brGiUZSE/wN91S4v6ENuvvEzGIeIVRi69UicNz/NVkqsWls +5Wfn4KmKz2K/en+755eyGcZO+h5Anwdcdx3lf4oRRm6ekX2RQfD0cMmZlsXsvu2c +LnLBMrjXuaQ7sf7A35ELwONX6X4RX60QscVNYm9hLKWNe0CH0ujMJTx5E3sV8q6H +I0K9vgeVbqjLybqaiu+NxRBMcErlmiTbc2z6818xa3FjHJ7d+535waJdQcaodlPz +ofWO+FZv6n/ww7EZrYpOI21Trv1DAJO5+R6edXD0mpd4Q276zqHvssXxOomm6ZtW +EySQ3hdV2SEnqbQPBpI1KWcgBjTzZiW/REt8S4txXzpUPOlM9pSDQa9tSVd0GKPT +J16qdMHB2cngJoW0zQ7sfQ9BxJ+DfUBPjBsuTcZwzomMNWrpx30GQNR+dAh9RUI2 +GXO+cS+tdmdO++acOOOA5DDDU0ABAoHBANUyHIENLNlytg6TJorCL6wCC87yZcdp +JUyiJYEGB3Oy3K02hwHZyGNRBoY9Q+PFREzRYSr/mueKhfXs7q704b9VIN7K9FvF +iMz+51g6MxGWltzjJLGQKtao4Vrh47zexocu0qrM9Ge0/HjrpSYDOvn8Rhn8Ss10 +xN080K5ShBm5muJHP3De8fX3XZ0Lhh90zvtAHmGoa2yijX2ad71JwyHotPfBPOdC +C7Ve1UCGf23DDPRyU1OZBV/b0MSnTSWgewKBwQDJVSUm+yrnf8k/pzCjqOtpnipn +XVdjIyG4MDxN4QAaUdPEIWsw+8AQiUJMPrieKQgNdVL6BuNOvgqbZxQz89yDI6Sp +eFtmY1TdOb0Dm+rwsIkK6CxYADCwS2lsy9neojt7rnrw6JvvuGT0acWH/z7gsHFa +7UvacM2GGKzAIQoQrWV+0+1vx2JTvKAxmQpHU6JktX77WvJ/O9PFQP7v2KySEYAR +PIUXwIoaZbovmlAVp7RFBqdKAeAzUxpm6vizaN0CgcEA0LxdmCT0MnrTsXV1mQoD +buAZ+6bs688Qy/U9zxO+HBOVaKooiTFXt5XPU4OMgufTtXqTLmxQmD7SZjRyhS4S +ESkiI8CGe4vuIve4PnPNKH1OfDqQ5KEIsF9tNXRRa8yaiCTZ8oz1Bsz3HNVrPsqO +5c+QO0T/YCXh0dMHZoY3/I/zC3VCsho2wOJO78ImsYnGVc0zcd5aP2TwL3gboGMm +AH89IA48uRe7KvsMxD5raWY9uuBsoT8DOhWYU9KSADMdAoHAeLmnt4IwrfRANv0H ++3sU/pYrEyQzfGzakVnLL1/V8fJTK25mmk67Uq8bpCCQD7bG71sE0IxEzTjDn3/l +62k1NyWuXTighfrWLnmqz3k1HfKdmn6x6GrkxzHRG734/LkHNhjf+4lfyBUn5C9w +lSYHDDCBKGbWbzvo4Zn2LJcjM/DlxXFLFRXX7iJTZKpCMZcC76StageVFZpIWCWr +OSMSB9yakLtbi2yW41FQna7IitOvExz0Pzp0uBIC6OfJDbu5AoHBAJz9cG1KdUuq +/F1MLqyRaq0K3O+Fk2uc0u+KVttzT9jfSqpvplzikQYDcCy2Igr9zwE7aubBYoW1 +VqrHy40ExuS7vzCVb8k98e5LHQZZ/NaHgHKCaC+umZ6YfIuV+4VWZHnvZ0F4Het3 +hDg5epntEEEWeBTKyZQIvwKP7lW4h2Gee/I3EnqFIFsiEPQ2eMMyqMJsU+rLyvEP +Ki1Jd8rQ3lqRpoVPAr1EA1tSqSaxqlsxWxRafuFfQQf7gITJEZQlug== +-----END RSA PRIVATE KEY----- diff --git a/tpkg/xfr_update.tdir/nsd_control.pem b/tpkg/xfr_update.tdir/nsd_control.pem new file mode 100644 index 000000000..93e7ca511 --- /dev/null +++ b/tpkg/xfr_update.tdir/nsd_control.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqzCCAhMCFBPBN+c2KtT5mAvLhxdCKNiMyNAKMA0GCSqGSIb3DQEBCwUAMA4x +DDAKBgNVBAMMA25zZDAeFw0xOTA0MjUxNTEzMjdaFw0yOTA0MjIxNTEzMjdaMBYx +FDASBgNVBAMMC25zZC1jb250cm9sMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB +igKCAYEAp6tA9X7sVaSMYtQh8FkQLhXERl05wDDxKr+Sqap/mctNoh27f7Y37act +gIkjw0FqJByrg73j1bqoVvRwJMWCrQCYP/oAw66rG4FDSN3jBg8lCeXz4qJETiZn +ZQRdWeJyjap6mm6Gj1CzWqmKq9bH+sJEEpXEA/rQM8PL1fSm5RXExSo47RoemL8j +afZd3j/JPUSunj/2/TLRKvJsCJV2JLFLQFvt/4G56C++ExQKsuN6QpfExZmC5cEH +hpYQBk5AfvbSqwzxGgldFQLyboA22spvh3uxVrYJj1bMDfO8Ij5d0Ku/rulsZVoa +ukudr/hhmI56A2IkYZemYdTMAeCrflYJD9TPx0eXzPtLoPJIyUlJ7MCu0rgN+FbH +7jDM1GC9zpQyBtLr97/rNHzk+z2N2WcgYbDhBW13Dv9QkIb2+ZPxhu2W5OTNEdu4 ++SHZOtYdPXN7NssiS2ZSIp8+ohkRzZgc8hsPr0yjt78IlzR5DVayz6vev9aRjdao +0vlAroIvAgMBAAEwDQYJKoZIhvcNAQELBQADggGBADc3NTIs6gf+//qcdyTR4hYc +oF53cJ4nWRMmoOJIk4ojF77rzoD2UjQye1X0gpZx55UYyu6O/Mq40krPX4FbMSzA +zLAyzuUPwJGdcgjvvlmSym/LAwTXwGYF32S/qKtpJKFSWny08JBt7DT8fV2P00zE +bV6ozg5HKukEcd2dQczsE3+gHwx7P+jsBBnWZzIgCkPwp4amzpahbQZRH2v9OboX +c1zR/8xXaYbes/BdqzzudhFV/Xd9wHH2EV4mRKPvQMY87FV6eGKYNL2UvPfr4/SH +yiIvd4Rw/vgMtpH9cYMov1v2Qkk9qvV9w5OPYu/4HzCVGssbkUPQX0AAWrUYIdo4 +ZqEAzyr1/IevTRYtsA4qkqJqgFfwRmNQH2blRX3vzgNvj2+v4DjvC+HYHuwzkwl8 +rbbs+9Ta+SBljSIPFb1+OMBAvgin/kAaYRxfQs6yrIO5abIBm+gfEiFLaP9yqerE +L+oT94EwsPMPVJ09yuVrjVUU430GMS2uqgTIj35TPQ== +-----END CERTIFICATE----- diff --git a/tpkg/xfr_update.tdir/nsd_server.key b/tpkg/xfr_update.tdir/nsd_server.key new file mode 100644 index 000000000..5d9f61031 --- /dev/null +++ b/tpkg/xfr_update.tdir/nsd_server.key @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG5QIBAAKCAYEAxLy5fFUI1OjXXbPcQ13303/K5AliTq6bCnS57edzQIbmPZj7 +XbGZ0RnU47cZ11GSAI9ptDIrSidNTsHzaqWZn431/IVjwrIkRgz95/aOWRov4fwm +cS5qvbYV60l384NZLqmF4BDDxSt2MLT2+jWxFEK2iUm2YXZewifQ8zaHmjfAWlo8 +TlK5jzt0Qc0qPv5nCC6mwtjb7OHul3N3QolW6hZOc1KZVEeBdELedoU9TyMyzhPB +vkqAXWoti/CwWj3YMTj/L7zNfQ9F1HW6n67Y+ltO8IadILPiZiiAVIrLqUh3EL2X +fq+BcJ3QvADjyL9F5TH3AaWoi6iYgMGcgdqK9k6hj+ziuMxX6OsgzfzxTEzZCHhP +Er39SX6j/fHzJP4aGQxAAHLAmv2p9P/oEZeZsvWPsBWYpULKgMZ0JDZhf26ddrB1 +mpTaqRQsG384dUZR9f/iyzTszwgc2PQ7JG6gVg723KoBhlD0g+DlC8XdxiRyaDbJ +PXzSoXgLWumx02OhAgMBAAECggGBAMS7MARriBRX7hzuYaEgE1V0oe+cjqi9o542 +EUMcQjzRaOVJ2HrdwUG+wgsgKwAMuqJCxuIBlRZm7MCH5CDODivmKohk3thviSRf +k3tlKv1g2Wby3YIqd2TT82FAK2nf+8tUi+H/AbVl+59DJwIXtMbc22m3w1/8nU8r +v5+l9L27aGcxesKbqKDZRC0Uu10YyvD8rZeEgY+EcjESrrxjV/1nZvWdMGR9yK74 +uzrri95aBVDbos7l8yz2oysf+UmUMp5U9rWwuU4M/34pFSGeo7CHjtliwbBF4FHn +uyompXaOr7Qrgeg4fc9NbZNaB4OAOV2d1sI202q6j3kEkhG4pD8LAG/RRnugCj7D +PKGJL3iZKxknjA+tAKkgq50EbMpLHHv1qSiKWy8p+bR5FyBYPSheOSkOKTywpqnd +OU+VDTi4iLDvkENt6E0TghSyhncl8yIcomYPktqepaNekCHquK5sX8NUhOzRe3WH +gX7l3e/o8JRvbwXJ8UWfQlKhPO/hvQKBwQDiLXVMf+Hjl/OoXHtF6huerNBux5CS +KYha5BLARs9W74kd9mTJ9F5IflenpzQJc1b/PnvvlcDDlniUvlgk463EA2th4qWp +50jFniq/l4rUMFk1vZBXldvuUaL6f+Ihi8WmoUAyguEVAB9G/EJ1bXqHKdJtxuz+ +/TXGBsXrF5+sZOTjfq96CgQtBmbPXMncPto0NndoMqcEB0bjsFywQXGCk6ZZZ3Ac +vwnZFqVwqro3aTwD+xllzVz+xBNK8GU+zW8CgcEA3q2EepAT7dlZAveC7VSLnFF/ +w86ziynGEuhoJly+zedDPkFIGxYje1SPaKhpMH2jOdCajyHPOGuWEeVfKMbzCrHP +GdFyiTQDk3Pq0JRXpUUJSPGPusAQnPruE68XccDb+eBiJR6y+0vXHd1J3F8B4BMQ +AloZZtlx9BkEZaaRjROxM7Ilbev4IjOcScTREb2GL8gU3vnI2FJjBMy6fI5cm4QK +XEgiLcxGniM77bAZTeoVFbpd4SSICDXVn/NM/XfvAoHBAMHbjKphAc/9MY6gldg6 +7Cl4nb4VtshQaNremWPMTXKKJNBVm9WtahJgl+jO2z8uaOalO70CchIyKm/zJcGY +lBtpguSHSs7xueIHy0QkM43jUtNJAyrO+46s0jA65Cs0jdhgZZHls944GJbTKHNV +vquTIRWOZxu3FBwDOihiOy2b3MNQlj7XzvR4hC4/rZTlGkmeVYItyBEf25bUVt2L +eisdOntuuR0qcNptGqgS7UEJJbOTyRUEjCyhCpg0q9LEaQKBwDF7N1wQ1gzdZlUt +cO+SAO/8gDqfnPAImVYsRLB5nYCdqiiUUxSJx9qpALEN80nuMS4wt5ekuKpd5dwW +Lx4dj3ZJ6q5fB2eLolvKv1wYCp3UCGsoGnsyIL7xV6QSHVCOvZL6FHURLE6BHM0r +FjWc+wqy0bTkFo7vNM48HOkFqYRC4vaM2JpjfCEFfO47iQW7Kq1FdbXSpZnEPPKd +F7eD3vpDzhWRhd7NbMfJJpD7t7PDl2nbnu7fska4x76iTvJoCwKBwQCcqj2yhl69 +1GfpzsOtfzh9rECrnKjAhmVbwRfKB1ivwe8G2tobgQjOUajBqkCYKpZgTy3wyhWn +0D4AdwonGu1XYLZWX+Hw/ZWhNEg/6Ju2wfiMJfFWmy5pvTSvmOlNWvYKwmH/TDjX +tEctSVj6D67xE5v6s3donTI0NFa1u7i1hwoGu4POCockbau52YN4n20R5K7enu2+ +YYpXfcUOmCi91Hpv+X1YbmY1tOo0m1ItYqupbuRFXnHVXJhKxsYXqlA= +-----END RSA PRIVATE KEY----- diff --git a/tpkg/xfr_update.tdir/nsd_server.pem b/tpkg/xfr_update.tdir/nsd_server.pem new file mode 100644 index 000000000..5d41ad2d6 --- /dev/null +++ b/tpkg/xfr_update.tdir/nsd_server.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDozCCAgsCFCAZislHgIerlrBBkLFt/ZOkKYVZMA0GCSqGSIb3DQEBCwUAMA4x +DDAKBgNVBAMMA25zZDAeFw0xOTA0MjUxNTEzMjdaFw0yOTA0MjIxNTEzMjdaMA4x +DDAKBgNVBAMMA25zZDCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAMS8 +uXxVCNTo112z3ENd99N/yuQJYk6umwp0ue3nc0CG5j2Y+12xmdEZ1OO3GddRkgCP +abQyK0onTU7B82qlmZ+N9fyFY8KyJEYM/ef2jlkaL+H8JnEuar22FetJd/ODWS6p +heAQw8UrdjC09vo1sRRCtolJtmF2XsIn0PM2h5o3wFpaPE5SuY87dEHNKj7+Zwgu +psLY2+zh7pdzd0KJVuoWTnNSmVRHgXRC3naFPU8jMs4Twb5KgF1qLYvwsFo92DE4 +/y+8zX0PRdR1up+u2PpbTvCGnSCz4mYogFSKy6lIdxC9l36vgXCd0LwA48i/ReUx +9wGlqIuomIDBnIHaivZOoY/s4rjMV+jrIM388UxM2Qh4TxK9/Ul+o/3x8yT+GhkM +QABywJr9qfT/6BGXmbL1j7AVmKVCyoDGdCQ2YX9unXawdZqU2qkULBt/OHVGUfX/ +4ss07M8IHNj0OyRuoFYO9tyqAYZQ9IPg5QvF3cYkcmg2yT180qF4C1rpsdNjoQID +AQABMA0GCSqGSIb3DQEBCwUAA4IBgQB+WGMopDqNkv7yDAO8Ik2EWieDqxTshqR4 +bT1do9zsC9WDrIVxoVcn+dtlIpEQl8MN9U5DTKBbRgk3grOwUsg2kC0Gujv3vAyQ +bF+jxjHWd1xzrbQ+QUgz07P1OMFWxMzECL2L2078UZbawFqKqlmNv5avUk27G8nB +GrujT/pUOIpRXC+rao8e14R84dPJLZuGm9IAeEBQIIdhY9sjFRyoQdCUubyKPpkm +/fpcDMkt7PzZ4nTovj4NUxnnoUGonpXuj0pHA/RDDJkPYaRrND4OGldQXdZ9LJNM +pROL6aCZ5iog74OY8yutVzCgGge9vZLkysceVP7Lyks9/fEAtIuozmulp9TUQAeR +MVdDOcREWRd0vFNtAC9xSloRqV+66CzrFHwkSMpLo+gdgcAZ8s33rgQk+I4gfavU +jPWMZVcZHXevtWuTRnxfOpMkbwiRyr2J8m549K7OKZgr+JRhdJTev4lvXVyfFia4 +zr6UOK4exZWP6VDXb4IyZbJh+LMjmws= +-----END CERTIFICATE----- diff --git a/tpkg/xfr_update.tdir/xfr_update.conf b/tpkg/xfr_update.tdir/xfr_update.conf index 67bb94c77..b8c6fd447 100644 --- a/tpkg/xfr_update.tdir/xfr_update.conf +++ b/tpkg/xfr_update.tdir/xfr_update.conf @@ -6,17 +6,25 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 +remote-control: + control-enable: yes + control-interface: 127.0.0.1 + control-port: CONTROLPORT + server-key-file: "nsd_server.key" + server-cert-file: "nsd_server.pem" + control-key-file: "nsd_control.key" + control-cert-file: "nsd_control.pem" + zone: - name: example.net - zonefile: xfr_update.zone - request-xfr: UDP 127.0.0.1@PORT NOKEY - allow-notify: 127.0.0.1 NOKEY - allow-notify: ::1 NOKEY - allow-notify: ::ffff:127.0.0.1 NOKEY - provide-xfr: 127.0.0.1 NOKEY - provide-xfr: ::1 NOKEY - provide-xfr: ::ffff:127.0.0.1 NOKEY + name: example.net + zonefile: xfr_update.zone + request-xfr: UDP 127.0.0.1@PORT NOKEY + allow-notify: 127.0.0.1 NOKEY + allow-notify: ::1 NOKEY + allow-notify: ::ffff:127.0.0.1 NOKEY + provide-xfr: 127.0.0.1 NOKEY + provide-xfr: ::1 NOKEY + provide-xfr: ::ffff:127.0.0.1 NOKEY diff --git a/tpkg/xfr_update.tdir/xfr_update.pre b/tpkg/xfr_update.tdir/xfr_update.pre index e0947b801..7c052d1c8 100644 --- a/tpkg/xfr_update.tdir/xfr_update.pre +++ b/tpkg/xfr_update.tdir/xfr_update.pre @@ -6,9 +6,11 @@ . ../common.sh # start NSD -get_random_port 1 +get_random_port 2 LDNS_PORT=$RND_PORT +CONTROLPORT=`expr $RND_PORT + 1` echo port: $LDNS_PORT +echo controlport: $CONTROL_PORT # start ldns-testns, be extra verbose ldns-testns -p $LDNS_PORT xfr_update.datafile & @@ -17,9 +19,10 @@ sleep 1 # share the vars echo "export LDNS_PORT=$LDNS_PORT" >> .tpkg.var.test +echo "export CONTROLPORT=$CONTROLPORT" >> .tpkg.var.test # replace PORT with $LDNS_PORT and put it in nsd_update.conf -cat xfr_update.conf | sed "s/PORT/$LDNS_PORT/g" > nsd.conf +cat xfr_update.conf | sed -e "s/CONTROLPORT/$CONTROLPORT/g" -e "s/PORT/$LDNS_PORT/g" > nsd.conf if [[ $? -ne 0 ]]; then exit 1 fi diff --git a/tpkg/xfr_update.tdir/xfr_update.test b/tpkg/xfr_update.tdir/xfr_update.test index 84af53a2f..e664fed86 100644 --- a/tpkg/xfr_update.tdir/xfr_update.test +++ b/tpkg/xfr_update.tdir/xfr_update.test @@ -20,7 +20,7 @@ sleep 3 # now query for the update I sent and compare that with a known good one echo port: $TPKG_PORT -dig @127.0.0.1 -p $TPKG_PORT example.net axfr | tee axfr +dig -4 @127.0.0.1 -p $TPKG_PORT example.net axfr | tee axfr grep -v "^;" < axfr | sort > axfr.clean # see that is it updated echo diff @@ -31,15 +31,20 @@ if test $? -ne 0; then fi echo OK +# on-disk binary database has been obsoleted, force a write using nsd-control +../../nsd-control -c nsd.conf write +sleep 3 + # stop the server kill_pid `cat nsd.pid` # delete ixfr file -# and start again, (with the nsd.db), and check the changes are in nsd.db +# and start again, (previously with the nsd.db, now with updated zone file), +# and check the changes are in nsd.db rm -f ixfr.db $TPKG_NSD -c nsd.conf -p $TPKG_PORT -l nsd.log -V 3 wait_server_up nsd.log -dig @127.0.0.1 -p $TPKG_PORT example.net axfr | tee axfr +dig -4 @127.0.0.1 -p $TPKG_PORT example.net axfr | tee axfr grep -v "^;" < axfr | sort > axfr.clean # see that is it updated echo diff diff --git a/tpkg/xot.tdir/xot.primary.conf.in b/tpkg/xot.tdir/xot.primary.conf.in index 1f4009da4..4fec08ef5 100644 --- a/tpkg/xot.tdir/xot.primary.conf.in +++ b/tpkg/xot.tdir/xot.primary.conf.in @@ -1,6 +1,5 @@ server: username: "" - database: "" zonesdir: "" xfrdfile: "" zonelistfile: "" diff --git a/tpkg/xot.tdir/xot.secondary.conf.in b/tpkg/xot.tdir/xot.secondary.conf.in index d0f241d31..e2aee4522 100644 --- a/tpkg/xot.tdir/xot.secondary.conf.in +++ b/tpkg/xot.tdir/xot.secondary.conf.in @@ -1,6 +1,5 @@ server: username: "" - database: "" zonesdir: "" xfrdfile: "" zonelistfile: "" diff --git a/tpkg/xot.tdir/xot.tertiary.conf.in b/tpkg/xot.tdir/xot.tertiary.conf.in index 360517b3d..612215289 100644 --- a/tpkg/xot.tdir/xot.tertiary.conf.in +++ b/tpkg/xot.tdir/xot.tertiary.conf.in @@ -1,6 +1,5 @@ server: username: "" - database: "" zonesdir: "" xfrdfile: "" zonelistfile: "" diff --git a/tpkg/zone_expire_notauth.tdir/zone_expire_notauth.conf b/tpkg/zone_expire_notauth.tdir/zone_expire_notauth.conf index a9dd57d8c..ec45cf186 100644 --- a/tpkg/zone_expire_notauth.tdir/zone_expire_notauth.conf +++ b/tpkg/zone_expire_notauth.tdir/zone_expire_notauth.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/zone_expire_parent.tdir/zone_expire_parent.conf b/tpkg/zone_expire_parent.tdir/zone_expire_parent.conf index 4591a4b1f..1b4db0f1c 100644 --- a/tpkg/zone_expire_parent.tdir/zone_expire_parent.conf +++ b/tpkg/zone_expire_parent.tdir/zone_expire_parent.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/zone_expire_restart.tdir/zone_expire_restart.conf b/tpkg/zone_expire_restart.tdir/zone_expire_restart.conf index 5cf6af0e8..7e7323259 100644 --- a/tpkg/zone_expire_restart.tdir/zone_expire_restart.conf +++ b/tpkg/zone_expire_restart.tdir/zone_expire_restart.conf @@ -6,7 +6,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: nsd.db zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/zone_expire_serial.tdir/zone_expire_serial.conf b/tpkg/zone_expire_serial.tdir/zone_expire_serial.conf index e8b2221aa..3373f1f32 100644 --- a/tpkg/zone_expire_serial.tdir/zone_expire_serial.conf +++ b/tpkg/zone_expire_serial.tdir/zone_expire_serial.conf @@ -7,8 +7,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - #database: nsd.db - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/zone_notloaded.tdir/zone_notloaded.conf b/tpkg/zone_notloaded.tdir/zone_notloaded.conf index e4f0df96b..e8b78b583 100644 --- a/tpkg/zone_notloaded.tdir/zone_notloaded.conf +++ b/tpkg/zone_notloaded.tdir/zone_notloaded.conf @@ -5,7 +5,6 @@ server: username: "" chroot: "" pidfile: nsd.pid - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/tpkg/zonec_tests.tdir/zonec_tests.conf b/tpkg/zonec_tests.tdir/zonec_tests.conf index a96e7307a..83cd19b03 100644 --- a/tpkg/zonec_tests.tdir/zonec_tests.conf +++ b/tpkg/zonec_tests.tdir/zonec_tests.conf @@ -4,7 +4,6 @@ server: chroot: "" pidfile: nsd.pid logfile: nsd.log - database: nsd.db xfrdfile: nsd.xfrd difffile: nsd.ixfr zonelistfile: "zone.list" diff --git a/tpkg/zonec_tests.tdir/zonec_tests.conf2 b/tpkg/zonec_tests.tdir/zonec_tests.conf2 index 1094bb38c..5fc37b62c 100644 --- a/tpkg/zonec_tests.tdir/zonec_tests.conf2 +++ b/tpkg/zonec_tests.tdir/zonec_tests.conf2 @@ -4,7 +4,6 @@ server: chroot: "" pidfile: nsd.pid logfile: nsd.log - database: nsd.db xfrdfile: nsd.xfrd difffile: nsd.ixfr zonelistfile: zone2.list diff --git a/tpkg/zonec_tests.tdir/zonec_tests.conf3 b/tpkg/zonec_tests.tdir/zonec_tests.conf3 index ab990e07a..1a1082d89 100644 --- a/tpkg/zonec_tests.tdir/zonec_tests.conf3 +++ b/tpkg/zonec_tests.tdir/zonec_tests.conf3 @@ -4,7 +4,6 @@ server: chroot: "" pidfile: nsd.pid logfile: nsd.log - database: nsd.db xfrdfile: nsd.xfrd difffile: nsd.ixfr zonelistfile: zone2.list diff --git a/tpkg/zonestats.tdir/zonestats.conf b/tpkg/zonestats.tdir/zonestats.conf index d8643cb30..e219da410 100644 --- a/tpkg/zonestats.tdir/zonestats.conf +++ b/tpkg/zonestats.tdir/zonestats.conf @@ -2,7 +2,6 @@ server: logfile: "nsd.log" xfrdfile: xfrd.state zonesdir: "" - database: "" zonelistfile: "zone.list" interface: 127.0.0.1 diff --git a/udb.h b/udb.h index b3f495d9b..dcca36754 100644 --- a/udb.h +++ b/udb.h @@ -218,14 +218,6 @@ typedef enum udb_chunk_type udb_chunk_type; enum udb_chunk_type { udb_chunk_type_free = 0, udb_chunk_type_data, /* alloced data */ - udb_chunk_type_index, - udb_chunk_type_radtree, - udb_chunk_type_radnode, - udb_chunk_type_radarray, - udb_chunk_type_zone, - udb_chunk_type_domain, - udb_chunk_type_rrset, - udb_chunk_type_rr, udb_chunk_type_task, udb_chunk_type_internal }; diff --git a/udbradtree.c b/udbradtree.c deleted file mode 100644 index 5de16c7bb..000000000 --- a/udbradtree.c +++ /dev/null @@ -1,1466 +0,0 @@ -/* - * udbradtree -- radix tree for binary strings for in udb file. - * - * Copyright (c) 2011, NLnet Labs. See LICENSE for license. - */ -#include "config.h" -#include -#include -#include -#include "udbradtree.h" -#include "radtree.h" -#define RADARRAY(ptr) ((struct udb_radarray_d*)UDB_PTR(ptr)) - -/** see if radarray can be reduced (by a factor of two) */ -static int udb_radarray_reduce_if_needed(udb_base* udb, udb_ptr* n); - -int udb_radix_tree_create(udb_base* udb, udb_ptr* ptr) -{ - if(!udb_ptr_alloc_space(ptr, udb, udb_chunk_type_radtree, - sizeof(struct udb_radtree_d))) - return 0; - udb_rel_ptr_init(&RADTREE(ptr)->root); - RADTREE(ptr)->count = 0; - return 1; -} - -/** size of radarray */ -static size_t size_of_radarray(struct udb_radarray_d* a) -{ - return sizeof(struct udb_radarray_d)+((size_t)a->capacity)*( - sizeof(struct udb_radsel_d)+(size_t)a->str_cap); -} - -/** size in bytes of data in the array lookup structure */ -static size_t size_of_lookup(udb_ptr* node) -{ - assert(udb_ptr_get_type(node) == udb_chunk_type_radnode); - return size_of_radarray((struct udb_radarray_d*)UDB_REL(*node->base, - RADNODE(node)->lookup.data)); -} - -/** external variant, size in bytes of data in the array lookup structure */ -size_t size_of_lookup_ext(udb_ptr* lookup) -{ - return size_of_lookup(lookup); -} - -/** size needed for a lookup array like this */ -static size_t size_of_lookup_needed(uint16_t capacity, - udb_radstrlen_type str_cap) -{ - return sizeof(struct udb_radarray_d)+ ((size_t)capacity)*( - sizeof(struct udb_radsel_d)+(size_t)str_cap); -} - -/** get the lookup array for a node */ -static struct udb_radarray_d* lookup(udb_ptr* n) -{ - assert(udb_ptr_get_type(n) == udb_chunk_type_radnode); - return (struct udb_radarray_d*)UDB_REL(*n->base, - RADNODE(n)->lookup.data); -} - -/** get a length in the lookup array */ -static udb_radstrlen_type lookup_len(udb_ptr* n, unsigned i) -{ - return lookup(n)->array[i].len; -} - -/** get a string in the lookup array */ -static uint8_t* lookup_string(udb_ptr* n, unsigned i) -{ - return ((uint8_t*)&(lookup(n)->array[lookup(n)->capacity]))+ - i*lookup(n)->str_cap; -} - -/** get a node in the lookup array */ -static struct udb_radnode_d* lookup_node(udb_ptr* n, unsigned i) -{ - return (struct udb_radnode_d*)UDB_REL(*n->base, - lookup(n)->array[i].node.data); -} - -/** zero the relptrs in radarray */ -static void udb_radarray_zero_ptrs(udb_base* udb, udb_ptr* n) -{ - unsigned i; - for(i=0; ilen; i++) { - udb_rptr_zero(&lookup(n)->array[i].node, udb); - } -} - -/** delete a radnode */ -static void udb_radnode_delete(udb_base* udb, udb_ptr* n) -{ - if(udb_ptr_is_null(n)) - return; - if(RADNODE(n)->lookup.data) { - udb_radarray_zero_ptrs(udb, n); - udb_rel_ptr_free_space(&RADNODE(n)->lookup, udb, - size_of_lookup(n)); - } - udb_rptr_zero(&RADNODE(n)->lookup, udb); - udb_rptr_zero(&RADNODE(n)->parent, udb); - udb_rptr_zero(&RADNODE(n)->elem, udb); - udb_ptr_free_space(n, udb, sizeof(struct udb_radnode_d)); -} - -/** delete radnodes in postorder recursion, n is ptr to node */ -static void udb_radnode_del_postorder(udb_base* udb, udb_ptr* n) -{ - unsigned i; - udb_ptr sub; - if(udb_ptr_is_null(n)) - return; - /* clear subnodes */ - udb_ptr_init(&sub, udb); - for(i=0; ilen; i++) { - udb_ptr_set_rptr(&sub, udb, &lookup(n)->array[i].node); - udb_rptr_zero(&lookup(n)->array[i].node, udb); - udb_radnode_del_postorder(udb, &sub); - } - udb_ptr_unlink(&sub, udb); - /* clear lookup */ - udb_rel_ptr_free_space(&RADNODE(n)->lookup, udb, size_of_lookup(n)); - udb_rptr_zero(&RADNODE(n)->parent, udb); - udb_rptr_zero(&RADNODE(n)->elem, udb); - udb_ptr_free_space(n, udb, sizeof(struct udb_radnode_d)); -} - -void udb_radix_tree_clear(udb_base* udb, udb_ptr* rt) -{ - udb_ptr root; - udb_ptr_new(&root, udb, &RADTREE(rt)->root); - udb_rptr_zero(&RADTREE(rt)->root, udb); - /* free the root node (and its descendants, if any) */ - udb_radnode_del_postorder(udb, &root); - udb_ptr_unlink(&root, udb); - - RADTREE(rt)->count = 0; -} - -void udb_radix_tree_delete(udb_base* udb, udb_ptr* rt) -{ - if(rt->data == 0) return; - assert(udb_ptr_get_type(rt) == udb_chunk_type_radtree); - udb_radix_tree_clear(udb, rt); - udb_ptr_free_space(rt, udb, sizeof(struct udb_radtree_d)); -} - -/** - * Find a prefix of the key, in whole-nodes. - * Finds the longest prefix that corresponds to a whole radnode entry. - * There may be a slightly longer prefix in one of the array elements. - * @param result: the longest prefix, the entry itself if *respos==len, - * otherwise an array entry, residx. Output. - * @param respos: pos in string where next unmatched byte is, if == len an - * exact match has been found. If == 0 then a "" match was found. - * @return false if no prefix found, not even the root "" prefix. - */ -static int udb_radix_find_prefix_node(udb_base* udb, udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len, udb_ptr* result, udb_radstrlen_type* respos) -{ - udb_radstrlen_type pos = 0; - uint8_t byte; - udb_ptr n; - udb_ptr_new(&n, udb, &RADTREE(rt)->root); - - *respos = 0; - udb_ptr_set_ptr(result, udb, &n); - if(udb_ptr_is_null(&n)) { - udb_ptr_unlink(&n, udb); - return 0; - } - while(!udb_ptr_is_null(&n)) { - if(pos == len) { - break; - } - byte = k[pos]; - if(byte < RADNODE(&n)->offset) { - break; - } - byte -= RADNODE(&n)->offset; - if(byte >= lookup(&n)->len) { - break; - } - pos++; - if(lookup(&n)->array[byte].len != 0) { - /* must match additional string */ - if(pos+lookup(&n)->array[byte].len > len) { - break; - } - if(memcmp(&k[pos], lookup_string(&n, byte), - lookup(&n)->array[byte].len) != 0) { - break; - } - pos += lookup(&n)->array[byte].len; - } - udb_ptr_set_rptr(&n, udb, &lookup(&n)->array[byte].node); - if(udb_ptr_is_null(&n)) { - break; - } - *respos = pos; - udb_ptr_set_ptr(result, udb, &n); - } - udb_ptr_unlink(&n, udb); - return 1; -} - -/** grow the radnode stringcapacity, copy existing elements */ -static int udb_radnode_str_grow(udb_base* udb, udb_ptr* n, - udb_radstrlen_type want) -{ - unsigned ns = ((unsigned)lookup(n)->str_cap)*2; - unsigned i; - udb_ptr a; - if(want > ns) - ns = want; - if(ns > 65535) ns = 65535; /* MAX of udb_radstrlen_type range */ - /* if this fails, the tree is still usable */ - if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray, - size_of_lookup_needed(lookup(n)->capacity, ns))) - return 0; - /* make sure to zero the newly allocated relptrs to init them */ - memcpy(RADARRAY(&a), lookup(n), sizeof(struct udb_radarray_d)); - RADARRAY(&a)->str_cap = ns; - for(i = 0; i < lookup(n)->len; i++) { - udb_rel_ptr_init(&RADARRAY(&a)->array[i].node); - udb_rptr_set_rptr(&RADARRAY(&a)->array[i].node, udb, - &lookup(n)->array[i].node); - RADARRAY(&a)->array[i].len = lookup_len(n, i); - memmove(((uint8_t*)(&RADARRAY(&a)->array[ - lookup(n)->capacity]))+i*ns, - lookup_string(n, i), lookup(n)->str_cap); - } - udb_radarray_zero_ptrs(udb, n); - udb_rel_ptr_free_space(&RADNODE(n)->lookup, udb, size_of_lookup(n)); - udb_rptr_set_ptr(&RADNODE(n)->lookup, udb, &a); - udb_ptr_unlink(&a, udb); - return 1; -} - -/** grow the radnode array, copy existing elements to start of new array */ -static int udb_radnode_array_grow(udb_base* udb, udb_ptr* n, size_t want) -{ - unsigned i; - unsigned ns = ((unsigned)lookup(n)->capacity)*2; - udb_ptr a; - assert(want <= 256); /* cannot be more, range of uint8 */ - if(want > ns) - ns = want; - if(ns > 256) ns = 256; - /* if this fails, the tree is still usable */ - if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray, - size_of_lookup_needed(ns, lookup(n)->str_cap))) - return 0; - /* zero the newly allocated rel ptrs to init them */ - memset(UDB_PTR(&a), 0, size_of_lookup_needed(ns, lookup(n)->str_cap)); - assert(lookup(n)->len <= lookup(n)->capacity); - assert(lookup(n)->capacity < ns); - memcpy(RADARRAY(&a), lookup(n), sizeof(struct udb_radarray_d)); - RADARRAY(&a)->capacity = ns; - for(i=0; ilen; i++) { - udb_rptr_set_rptr(&RADARRAY(&a)->array[i].node, udb, - &lookup(n)->array[i].node); - RADARRAY(&a)->array[i].len = lookup_len(n, i); - } - memmove(&RADARRAY(&a)->array[ns], lookup_string(n, 0), - ((size_t)lookup(n)->len) * ((size_t)lookup(n)->str_cap)); - udb_radarray_zero_ptrs(udb, n); - udb_rel_ptr_free_space(&RADNODE(n)->lookup, udb, size_of_lookup(n)); - udb_rptr_set_ptr(&RADNODE(n)->lookup, udb, &a); - udb_ptr_unlink(&a, udb); - return 1; -} - -/** make empty array in radnode */ -static int udb_radnode_array_create(udb_base* udb, udb_ptr* n) -{ - /* is there an array? */ - if(RADNODE(n)->lookup.data == 0) { - /* create array */ - udb_ptr a; - uint16_t cap = 0; - udb_radstrlen_type len = 0; - if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray, - size_of_lookup_needed(cap, len))) - return 0; - memset(UDB_PTR(&a), 0, size_of_lookup_needed(cap, len)); - udb_rptr_set_ptr(&RADNODE(n)->lookup, udb, &a); - RADARRAY(&a)->len = cap; - RADARRAY(&a)->capacity = cap; - RADARRAY(&a)->str_cap = len; - RADNODE(n)->offset = 0; - udb_ptr_unlink(&a, udb); - } - return 1; -} - -/** make space in radnode for another byte, or longer strings */ -static int udb_radnode_array_space(udb_base* udb, udb_ptr* n, uint8_t byte, - udb_radstrlen_type len) -{ - /* is there an array? */ - if(RADNODE(n)->lookup.data == 0) { - /* create array */ - udb_ptr a; - uint16_t cap = 1; - if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray, - size_of_lookup_needed(cap, len))) - return 0; - /* this memset inits the relptr that is allocated */ - memset(UDB_PTR(&a), 0, size_of_lookup_needed(cap, len)); - udb_rptr_set_ptr(&RADNODE(n)->lookup, udb, &a); - RADARRAY(&a)->len = cap; - RADARRAY(&a)->capacity = cap; - RADARRAY(&a)->str_cap = len; - RADNODE(n)->offset = byte; - udb_ptr_unlink(&a, udb); - return 1; - } - if(lookup(n)->capacity == 0) { - if(!udb_radnode_array_grow(udb, n, 1)) - return 0; - } - - /* make space for this stringsize */ - if(lookup(n)->str_cap < len) { - /* must resize for stringsize */ - if(!udb_radnode_str_grow(udb, n, len)) - return 0; - } - - /* other cases */ - /* is the array unused? */ - if(lookup(n)->len == 0 && lookup(n)->capacity != 0) { - lookup(n)->len = 1; - RADNODE(n)->offset = byte; - memset(&lookup(n)->array[0], 0, sizeof(struct udb_radsel_d)); - /* is it below the offset? */ - } else if(byte < RADNODE(n)->offset) { - /* is capacity enough? */ - int i; - unsigned need = RADNODE(n)->offset-byte; - if(lookup(n)->len+need > lookup(n)->capacity) { - /* grow array */ - if(!udb_radnode_array_grow(udb, n, lookup(n)->len+need)) - return 0; - } - /* take a piece of capacity into use, init the relptrs */ - for(i = lookup(n)->len; i< (int)(lookup(n)->len + need); i++) { - udb_rel_ptr_init(&lookup(n)->array[i].node); - } - /* reshuffle items to end */ - for(i = lookup(n)->len-1; i >= 0; i--) { - udb_rptr_set_rptr(&lookup(n)->array[need+i].node, - udb, &lookup(n)->array[i].node); - lookup(n)->array[need+i].len = lookup_len(n, i); - /* fixup pidx */ - if(lookup(n)->array[i+need].node.data) - lookup_node(n, i+need)->pidx = i+need; - } - memmove(lookup_string(n, need), lookup_string(n, 0), - ((size_t)lookup(n)->len)*((size_t)lookup(n)->str_cap)); - /* zero the first */ - for(i = 0; i < (int)need; i++) { - udb_rptr_zero(&lookup(n)->array[i].node, udb); - lookup(n)->array[i].len = 0; - } - lookup(n)->len += need; - RADNODE(n)->offset = byte; - /* is it above the max? */ - } else if(byte - RADNODE(n)->offset >= lookup(n)->len) { - /* is capacity enough? */ - int i; - unsigned need = (byte-RADNODE(n)->offset) - lookup(n)->len + 1; - /* grow array */ - if(lookup(n)->len + need > lookup(n)->capacity) { - if(!udb_radnode_array_grow(udb, n, lookup(n)->len+need)) - return 0; - } - /* take new entries into use, init relptrs */ - for(i = lookup(n)->len; i< (int)(lookup(n)->len + need); i++) { - udb_rel_ptr_init(&lookup(n)->array[i].node); - lookup(n)->array[i].len = 0; - } - /* grow length */ - lookup(n)->len += need; - } - return 1; -} - -/** make space for string size */ -static int udb_radnode_str_space(udb_base* udb, udb_ptr* n, - udb_radstrlen_type len) -{ - if(RADNODE(n)->lookup.data == 0) { - return udb_radnode_array_space(udb, n, 0, len); - } - if(lookup(n)->str_cap < len) { - /* must resize for stringsize */ - if(!udb_radnode_str_grow(udb, n, len)) - return 0; - } - return 1; -} - -/** copy remainder from prefixes for a split: - * plen: len prefix, l: longer bstring, llen: length of l. */ -static void udb_radsel_prefix_remainder(udb_radstrlen_type plen, - uint8_t* l, udb_radstrlen_type llen, - uint8_t* s, udb_radstrlen_type* slen) -{ - *slen = llen - plen; - /* assert(*slen <= lookup(n)->str_cap); */ - memmove(s, l+plen, llen-plen); -} - -/** create a prefix in the array strs */ -static void udb_radsel_str_create(uint8_t* s, udb_radstrlen_type* slen, - uint8_t* k, udb_radstrlen_type pos, udb_radstrlen_type len) -{ - *slen = len-pos; - /* assert(*slen <= lookup(n)->str_cap); */ - memmove(s, k+pos, len-pos); -} - -static udb_radstrlen_type -udb_bstr_common(uint8_t* x, udb_radstrlen_type xlen, - uint8_t* y, udb_radstrlen_type ylen) -{ - assert(sizeof(radstrlen_type) == sizeof(udb_radstrlen_type)); - return bstr_common_ext(x, xlen, y, ylen); -} - -static int -udb_bstr_is_prefix(uint8_t* p, udb_radstrlen_type plen, - uint8_t* x, udb_radstrlen_type xlen) -{ - assert(sizeof(radstrlen_type) == sizeof(udb_radstrlen_type)); - return bstr_is_prefix_ext(p, plen, x, xlen); -} - -/** grow array space for byte N after a string, (but if string shorter) */ -static int -udb_radnode_array_space_strremain(udb_base* udb, udb_ptr* n, - uint8_t* str, udb_radstrlen_type len, udb_radstrlen_type pos) -{ - assert(pos < len); - /* shift by one char because it goes in lookup array */ - return udb_radnode_array_space(udb, n, str[pos], len-(pos+1)); -} - - -/** radsel create a split when two nodes have shared prefix. - * @param udb: udb - * @param n: node with the radsel that gets changed, it contains a node. - * @param idx: the index of the radsel that gets changed. - * @param k: key byte string - * @param pos: position where the string enters the radsel (e.g. r.str) - * @param len: length of k. - * @param add: additional node for the string k. - * removed by called on failure. - * @return false on alloc failure, no changes made. - */ -static int udb_radsel_split(udb_base* udb, udb_ptr* n, uint8_t idx, uint8_t* k, - udb_radstrlen_type pos, udb_radstrlen_type len, udb_ptr* add) -{ - uint8_t* addstr = k+pos; - udb_radstrlen_type addlen = len-pos; - if(udb_bstr_is_prefix(addstr, addlen, lookup_string(n, idx), - lookup_len(n, idx))) { - udb_radstrlen_type split_len = 0; - /* 'add' is a prefix of r.node */ - /* also for empty addstr */ - /* set it up so that the 'add' node has r.node as child */ - /* so, r.node gets moved below the 'add' node, but we do - * this so that the r.node stays the same pointer for its - * key name */ - assert(addlen != lookup_len(n, idx)); - assert(addlen < lookup_len(n, idx)); - /* make space for new string sizes */ - if(!udb_radnode_str_space(udb, n, addlen)) - return 0; - if(lookup_len(n, idx) - addlen > 1) - /* shift one because a char is in the lookup array */ - split_len = lookup_len(n, idx) - (addlen+1); - if(!udb_radnode_array_space(udb, add, - lookup_string(n, idx)[addlen], split_len)) - return 0; - /* alloc succeeded, now link it in */ - udb_rptr_set_rptr(&RADNODE(add)->parent, udb, - &lookup_node(n, idx)->parent); - RADNODE(add)->pidx = lookup_node(n, idx)->pidx; - udb_rptr_set_rptr(&lookup(add)->array[0].node, udb, - &lookup(n)->array[idx].node); - if(lookup_len(n, idx) - addlen > 1) { - udb_radsel_prefix_remainder(addlen+1, - lookup_string(n, idx), lookup_len(n, idx), - lookup_string(add, 0), - &lookup(add)->array[0].len); - } else { - lookup(add)->array[0].len = 0; - } - udb_rptr_set_ptr(&lookup_node(n, idx)->parent, udb, add); - lookup_node(n, idx)->pidx = 0; - - udb_rptr_set_ptr(&lookup(n)->array[idx].node, udb, add); - memmove(lookup_string(n, idx), addstr, addlen); - lookup(n)->array[idx].len = addlen; - /* n's string may have become shorter */ - if(!udb_radarray_reduce_if_needed(udb, n)) { - /* ignore this, our tree has become inefficient */ - } - } else if(udb_bstr_is_prefix(lookup_string(n, idx), lookup_len(n, idx), - addstr, addlen)) { - udb_radstrlen_type split_len = 0; - udb_ptr rnode; - /* r.node is a prefix of 'add' */ - /* set it up so that the 'r.node' has 'add' as child */ - /* and basically, r.node is already completely fine, - * we only need to create a node as its child */ - assert(addlen != lookup_len(n, idx)); - assert(lookup_len(n, idx) < addlen); - udb_ptr_new(&rnode, udb, &lookup(n)->array[idx].node); - /* make space for string length */ - if(addlen-lookup_len(n, idx) > 1) { - /* shift one because a character goes into array */ - split_len = addlen - (lookup_len(n, idx)+1); - } - if(!udb_radnode_array_space(udb, &rnode, - addstr[lookup_len(n, idx)], split_len)) { - udb_ptr_unlink(&rnode, udb); - return 0; - } - /* alloc succeeded, now link it in */ - udb_rptr_set_ptr(&RADNODE(add)->parent, udb, &rnode); - RADNODE(add)->pidx = addstr[lookup_len(n, idx)] - - RADNODE(&rnode)->offset; - udb_rptr_set_ptr(&lookup(&rnode)->array[ RADNODE(add)->pidx ] - .node, udb, add); - if(addlen-lookup_len(n, idx) > 1) { - udb_radsel_prefix_remainder(lookup_len(n, idx)+1, - addstr, addlen, - lookup_string(&rnode, RADNODE(add)->pidx), - &lookup(&rnode)->array[ RADNODE(add)->pidx] - .len); - } else { - lookup(&rnode)->array[ RADNODE(add)->pidx].len = 0; - } - /* rnode's string has become shorter */ - if(!udb_radarray_reduce_if_needed(udb, &rnode)) { - /* ignore this, our tree has become inefficient */ - } - udb_ptr_unlink(&rnode, udb); - } else { - /* okay we need to create a new node that chooses between - * the nodes 'add' and r.node - * We do this so that r.node stays the same pointer for its - * key name. */ - udb_ptr com, rnode; - udb_radstrlen_type common_len = udb_bstr_common( - lookup_string(n, idx), lookup_len(n, idx), - addstr, addlen); - assert(common_len < lookup_len(n, idx)); - assert(common_len < addlen); - udb_ptr_new(&rnode, udb, &lookup(n)->array[idx].node); - - /* create the new node for choice */ - if(!udb_ptr_alloc_space(&com, udb, udb_chunk_type_radnode, - sizeof(struct udb_radnode_d))) { - udb_ptr_unlink(&rnode, udb); - return 0; /* out of space */ - } - memset(UDB_PTR(&com), 0, sizeof(struct udb_radnode_d)); - /* make stringspace for the two substring choices */ - /* this allocates the com->lookup array */ - if(!udb_radnode_array_space_strremain(udb, &com, - lookup_string(n, idx), lookup_len(n, idx), common_len) - || !udb_radnode_array_space_strremain(udb, &com, - addstr, addlen, common_len)) { - udb_ptr_unlink(&rnode, udb); - udb_radnode_delete(udb, &com); - return 0; - } - /* create stringspace for the shared prefix */ - if(common_len > 0) { - if(!udb_radnode_str_space(udb, n, common_len-1)) { - udb_ptr_unlink(&rnode, udb); - udb_radnode_delete(udb, &com); - return 0; - } - } - /* allocs succeeded, proceed to link it all up */ - udb_rptr_set_rptr(&RADNODE(&com)->parent, udb, - &RADNODE(&rnode)->parent); - RADNODE(&com)->pidx = RADNODE(&rnode)->pidx; - udb_rptr_set_ptr(&RADNODE(&rnode)->parent, udb, &com); - RADNODE(&rnode)->pidx = lookup_string(n, idx)[common_len] - - RADNODE(&com)->offset; - udb_rptr_set_ptr(&RADNODE(add)->parent, udb, &com); - RADNODE(add)->pidx = addstr[common_len] - - RADNODE(&com)->offset; - udb_rptr_set_ptr(&lookup(&com)->array[RADNODE(&rnode)->pidx] - .node, udb, &rnode); - if(lookup_len(n, idx)-common_len > 1) { - udb_radsel_prefix_remainder(common_len+1, - lookup_string(n, idx), lookup_len(n, idx), - lookup_string(&com, RADNODE(&rnode)->pidx), - &lookup(&com)->array[RADNODE(&rnode)->pidx].len); - } else { - lookup(&com)->array[RADNODE(&rnode)->pidx].len= 0; - } - udb_rptr_set_ptr(&lookup(&com)->array[RADNODE(add)->pidx] - .node, udb, add); - if(addlen-common_len > 1) { - udb_radsel_prefix_remainder(common_len+1, - addstr, addlen, - lookup_string(&com, RADNODE(add)->pidx), - &lookup(&com)->array[RADNODE(add)->pidx].len); - } else { - lookup(&com)->array[RADNODE(add)->pidx].len = 0; - } - memmove(lookup_string(n, idx), addstr, common_len); - lookup(n)->array[idx].len = common_len; - udb_rptr_set_ptr(&lookup(n)->array[idx].node, udb, &com); - udb_ptr_unlink(&rnode, udb); - udb_ptr_unlink(&com, udb); - /* n's string has become shorter */ - if(!udb_radarray_reduce_if_needed(udb, n)) { - /* ignore this, our tree has become inefficient */ - } - } - return 1; -} - -uint64_t* result_data = NULL; -udb_void udb_radix_insert(udb_base* udb, udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len, udb_ptr* elem, udb_ptr* result) -{ - udb_void ret; - udb_ptr add, n; /* type udb_radnode_d */ - udb_radstrlen_type pos = 0; - /* create new element to add */ - if(!udb_ptr_alloc_space(&add, udb, udb_chunk_type_radnode, - sizeof(struct udb_radnode_d))) { - return 0; /* alloc failure */ - } - memset(UDB_PTR(&add), 0, sizeof(struct udb_radnode_d)); - udb_rptr_set_ptr(&RADNODE(&add)->elem, udb, elem); - if(!udb_radnode_array_create(udb, &add)) { - udb_ptr_free_space(&add, udb, sizeof(struct udb_radnode_d)); - return 0; /* alloc failure */ - } - udb_ptr_init(&n, udb); - result_data = &n.data; - - /* find out where to add it */ - if(!udb_radix_find_prefix_node(udb, rt, k, len, &n, &pos)) { - /* new root */ - assert(RADTREE(rt)->root.data == 0); - if(len == 0) { - udb_rptr_set_ptr(&RADTREE(rt)->root, udb, &add); - } else { - /* add a root to point to new node */ - udb_ptr_zero(&n, udb); - if(!udb_ptr_alloc_space(&n, udb, - udb_chunk_type_radnode, - sizeof(struct udb_radnode_d))) { - udb_radnode_delete(udb, &add); - udb_ptr_unlink(&n, udb); - return 0; /* alloc failure */ - } - memset(RADNODE(&n), 0, sizeof(struct udb_radnode_d)); - /* this creates the array lookup structure for n */ - if(!udb_radnode_array_space(udb, &n, k[0], len-1)) { - udb_radnode_delete(udb, &add); - udb_ptr_free_space(&n, udb, - sizeof(struct udb_radnode_d)); - return 0; /* alloc failure */ - } - udb_rptr_set_ptr(&RADNODE(&add)->parent, udb, &n); - RADNODE(&add)->pidx = 0; - udb_rptr_set_ptr(&lookup(&n)->array[0].node, udb, &add); - if(len > 1) { - udb_radsel_prefix_remainder(1, k, len, - lookup_string(&n, 0), - &lookup(&n)->array[0].len); - } - udb_rptr_set_ptr(&RADTREE(rt)->root, udb, &n); - } - } else if(pos == len) { - /* found an exact match */ - if(RADNODE(&n)->elem.data) { - /* already exists, failure */ - udb_radnode_delete(udb, &add); - udb_ptr_unlink(&n, udb); - return 0; - } - udb_rptr_set_ptr(&RADNODE(&n)->elem, udb, elem); - udb_radnode_delete(udb, &add); - udb_ptr_set_ptr(&add, udb, &n); - } else { - /* n is a node which can accomodate */ - uint8_t byte; - assert(pos < len); - byte = k[pos]; - - /* see if it falls outside of array */ - if(byte < RADNODE(&n)->offset || byte-RADNODE(&n)->offset >= - lookup(&n)->len) { - /* make space in the array for it; adjusts offset */ - if(!udb_radnode_array_space(udb, &n, byte, - len-(pos+1))) { - udb_radnode_delete(udb, &add); - udb_ptr_unlink(&n, udb); - return 0; - } - assert(byte>=RADNODE(&n)->offset && byte-RADNODE(&n)-> - offsetlen); - byte -= RADNODE(&n)->offset; - /* see if more prefix needs to be split off */ - if(pos+1 < len) { - udb_radsel_str_create(lookup_string(&n, byte), - &lookup(&n)->array[byte].len, - k, pos+1, len); - } - /* insert the new node in the new bucket */ - udb_rptr_set_ptr(&RADNODE(&add)->parent, udb, &n); - RADNODE(&add)->pidx = byte; - udb_rptr_set_ptr(&lookup(&n)->array[byte].node, udb, - &add); - /* so a bucket exists and byte falls in it */ - } else if(lookup(&n)->array[byte - RADNODE(&n)->offset] - .node.data == 0) { - /* use existing bucket */ - byte -= RADNODE(&n)->offset; - if(pos+1 < len) { - /* make space and split off more prefix */ - if(!udb_radnode_str_space(udb, &n, - len-(pos+1))) { - udb_radnode_delete(udb, &add); - udb_ptr_unlink(&n, udb); - return 0; - } - udb_radsel_str_create(lookup_string(&n, byte), - &lookup(&n)->array[byte].len, - k, pos+1, len); - } - /* insert the new node in the new bucket */ - udb_rptr_set_ptr(&RADNODE(&add)->parent, udb, &n); - RADNODE(&add)->pidx = byte; - udb_rptr_set_ptr(&lookup(&n)->array[byte].node, udb, - &add); - } else { - /* use bucket but it has a shared prefix, - * split that out and create a new intermediate - * node to split out between the two. - * One of the two might exactmatch the new - * intermediate node */ - if(!udb_radsel_split(udb, &n, byte-RADNODE(&n)->offset, - k, pos+1, len, &add)) { - udb_radnode_delete(udb, &add); - udb_ptr_unlink(&n, udb); - return 0; - } - } - } - RADTREE(rt)->count ++; - ret = add.data; - udb_ptr_init(result, udb); - udb_ptr_set_ptr(result, udb, &add); - udb_ptr_unlink(&add, udb); - udb_ptr_unlink(&n, udb); - return ret; -} - -/** Cleanup node with one child, it is removed and joined into parent[x] str */ -static int -udb_radnode_cleanup_onechild(udb_base* udb, udb_ptr* n) -{ - udb_ptr par, child; - uint8_t pidx = RADNODE(n)->pidx; - radstrlen_type joinlen; - udb_ptr_new(&par, udb, &RADNODE(n)->parent); - udb_ptr_new(&child, udb, &lookup(n)->array[0].node); - - /* node had one child, merge them into the parent. */ - /* keep the child node, so its pointers stay valid. */ - - /* at parent, append child->str to array str */ - assert(pidx < lookup(&par)->len); - joinlen = lookup_len(&par, pidx) + lookup_len(n, 0) + 1; - /* make stringspace for the joined string */ - if(!udb_radnode_str_space(udb, &par, joinlen)) { - /* cleanup failed due to out of memory */ - /* the tree is inefficient, with node n still existing */ - udb_ptr_unlink(&par, udb); - udb_ptr_unlink(&child, udb); - udb_ptr_zero(n, udb); - return 0; - } - /* the string(par, pidx) is already there */ - /* the array lookup is gone, put its character in the lookup string*/ - lookup_string(&par, pidx)[lookup_len(&par, pidx)] = - RADNODE(&child)->pidx + RADNODE(n)->offset; - memmove(lookup_string(&par, pidx)+lookup_len(&par, pidx)+1, - lookup_string(n, 0), lookup_len(n, 0)); - lookup(&par)->array[pidx].len = joinlen; - /* and set the node to our child. */ - udb_rptr_set_ptr(&lookup(&par)->array[pidx].node, udb, &child); - udb_rptr_set_ptr(&RADNODE(&child)->parent, udb, &par); - RADNODE(&child)->pidx = pidx; - /* we are unlinked, delete our node */ - udb_radnode_delete(udb, n); - udb_ptr_unlink(&par, udb); - udb_ptr_unlink(&child, udb); - udb_ptr_zero(n, udb); - return 1; -} - -/** reduce the size of radarray, does a malloc */ -static int -udb_radarray_reduce(udb_base* udb, udb_ptr* n, uint16_t cap, - udb_radstrlen_type strcap) -{ - udb_ptr a; - unsigned i; - assert(lookup(n)->len <= cap); - assert(cap <= lookup(n)->capacity); - assert(strcap <= lookup(n)->str_cap); - if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray, - size_of_lookup_needed(cap, strcap))) - return 0; - memset(RADARRAY(&a), 0, size_of_lookup_needed(cap, strcap)); - memcpy(RADARRAY(&a), lookup(n), sizeof(struct udb_radarray_d)); - RADARRAY(&a)->capacity = cap; - RADARRAY(&a)->str_cap = strcap; - for(i=0; ilen; i++) { - udb_rel_ptr_init(&RADARRAY(&a)->array[i].node); - udb_rptr_set_rptr(&RADARRAY(&a)->array[i].node, udb, - &lookup(n)->array[i].node); - RADARRAY(&a)->array[i].len = lookup_len(n, i); - memmove(((uint8_t*)(&RADARRAY(&a)->array[cap]))+i*strcap, - lookup_string(n, i), lookup_len(n, i)); - } - udb_radarray_zero_ptrs(udb, n); - udb_rel_ptr_free_space(&RADNODE(n)->lookup, udb, size_of_lookup(n)); - udb_rptr_set_ptr(&RADNODE(n)->lookup, udb, &a); - udb_ptr_unlink(&a, udb); - return 1; -} - -/** find the max stringlength in the array */ -static udb_radstrlen_type udb_radarray_max_len(udb_ptr* n) -{ - unsigned i; - udb_radstrlen_type maxlen = 0; - for(i=0; ilen; i++) { - if(lookup(n)->array[i].node.data && - lookup(n)->array[i].len > maxlen) - maxlen = lookup(n)->array[i].len; - } - return maxlen; -} - -/** see if radarray can be reduced (by a factor of two) */ -static int -udb_radarray_reduce_if_needed(udb_base* udb, udb_ptr* n) -{ - udb_radstrlen_type maxlen = udb_radarray_max_len(n); - if((lookup(n)->len <= lookup(n)->capacity/2 || lookup(n)->len == 0 - || maxlen <= lookup(n)->str_cap/2 || maxlen == 0) && - (lookup(n)->len != lookup(n)->capacity || - lookup(n)->str_cap != maxlen)) - return udb_radarray_reduce(udb, n, lookup(n)->len, maxlen); - return 1; -} - -static int -udb_radnode_array_clean_all(udb_base* udb, udb_ptr* n) -{ - RADNODE(n)->offset = 0; - lookup(n)->len = 0; - /* reallocate lookup to a smaller capacity structure */ - return udb_radarray_reduce(udb, n, 0, 0); -} - -/** remove NULL nodes from front of array */ -static int -udb_radnode_array_clean_front(udb_base* udb, udb_ptr* n) -{ - /* move them up and adjust offset */ - unsigned idx, shuf = 0; - /* remove until a nonNULL entry */ - while(shuf < lookup(n)->len && lookup(n)->array[shuf].node.data == 0) - shuf++; - if(shuf == 0) - return 1; - if(shuf == lookup(n)->len) { - /* the array is empty, the tree is inefficient */ - return udb_radnode_array_clean_all(udb, n); - } - assert(shuf < lookup(n)->len); - assert((int)shuf <= 255-(int)RADNODE(n)->offset); - /* move them */ - for(idx=0; idxlen-shuf; idx++) { - udb_rptr_set_rptr(&lookup(n)->array[idx].node, udb, - &lookup(n)->array[shuf+idx].node); - lookup(n)->array[idx].len = lookup_len(n, shuf+idx); - memmove(lookup_string(n, idx), lookup_string(n, shuf+idx), - lookup(n)->array[idx].len); - } - /* zero the to-be-unused entries */ - for(idx=lookup(n)->len-shuf; idxlen; idx++) { - udb_rptr_zero(&lookup(n)->array[idx].node, udb); - memset(lookup_string(n, idx), 0, lookup(n)->array[idx].len); - lookup(n)->array[idx].len = 0; - } - RADNODE(n)->offset += shuf; - lookup(n)->len -= shuf; - for(idx=0; idxlen; idx++) - if(lookup(n)->array[idx].node.data) - lookup_node(n, idx)->pidx = idx; - - /* see if capacity has to shrink */ - return udb_radarray_reduce_if_needed(udb, n); -} - -/** remove NULL nodes from end of array */ -static int -udb_radnode_array_clean_end(udb_base* udb, udb_ptr* n) -{ - /* shorten it */ - unsigned shuf = 0; - /* remove until a nonNULL entry */ - /* remove until a nonNULL entry */ - while(shuf < lookup(n)->len && lookup(n)->array[lookup(n)->len-1-shuf] - .node.data == 0) - shuf++; - if(shuf == 0) - return 1; - if(shuf == lookup(n)->len) { - /* the array is empty, the tree is inefficient */ - return udb_radnode_array_clean_all(udb, n); - } - assert(shuf < lookup(n)->len); - lookup(n)->len -= shuf; - /* array elements can stay where they are */ - /* see if capacity has to shrink */ - return udb_radarray_reduce_if_needed(udb, n); -} - -/** clean up radnode leaf, where we know it has a parent */ -static int -udb_radnode_cleanup_leaf(udb_base* udb, udb_ptr* n, udb_ptr* par) -{ - uint8_t pidx; - /* node was a leaf */ - - /* delete leaf node, but store parent+idx */ - pidx = RADNODE(n)->pidx; - assert(pidx < lookup(par)->len); - - /** set parent ptr to this node to NULL before deleting the node, - * because otherwise ptrlinks fail */ - udb_rptr_zero(&lookup(par)->array[pidx].node, udb); - - udb_radnode_delete(udb, n); - - /* set parent+idx entry to NULL str and node.*/ - lookup(par)->array[pidx].len = 0; - - /* see if par offset or len must be adjusted */ - if(lookup(par)->len == 1) { - /* removed final element from array */ - if(!udb_radnode_array_clean_all(udb, par)) - return 0; - } else if(pidx == 0) { - /* removed first element from array */ - if(!udb_radnode_array_clean_front(udb, par)) - return 0; - } else if(pidx == lookup(par)->len-1) { - /* removed last element from array */ - if(!udb_radnode_array_clean_end(udb, par)) - return 0; - } - return 1; -} - -/** - * Cleanup a radix node that was made smaller, see if it can - * be merged with others. - * @param udb: the udb - * @param rt: tree to remove root if needed. - * @param n: node to cleanup - * @return false on alloc failure. - */ -static int -udb_radnode_cleanup(udb_base* udb, udb_ptr* rt, udb_ptr* n) -{ - while(!udb_ptr_is_null(n)) { - if(RADNODE(n)->elem.data) { - /* see if if needs to be reduced in stringsize */ - if(!udb_radarray_reduce_if_needed(udb, n)) { - udb_ptr_zero(n, udb); - return 0; - } - /* cannot delete node with a data element */ - udb_ptr_zero(n, udb); - return 1; - } else if(lookup(n)->len == 1 && RADNODE(n)->parent.data) { - return udb_radnode_cleanup_onechild(udb, n); - } else if(lookup(n)->len == 0) { - udb_ptr par; - if(!RADNODE(n)->parent.data) { - /* root deleted */ - udb_rptr_zero(&RADTREE(rt)->root, udb); - udb_radnode_delete(udb, n); - return 1; - } - udb_ptr_new(&par, udb, &RADNODE(n)->parent); - /* remove and delete the leaf node */ - if(!udb_radnode_cleanup_leaf(udb, n, &par)) { - udb_ptr_unlink(&par, udb); - udb_ptr_zero(n, udb); - return 0; - } - /* see if parent can now be cleaned up */ - udb_ptr_set_ptr(n, udb, &par); - udb_ptr_unlink(&par, udb); - } else { - /* see if if needs to be reduced in stringsize */ - if(!udb_radarray_reduce_if_needed(udb, n)) { - udb_ptr_zero(n, udb); - return 0; - } - /* node cannot be cleaned up */ - udb_ptr_zero(n, udb); - return 1; - } - } - /* ENOTREACH */ - return 1; -} - -void udb_radix_delete(udb_base* udb, udb_ptr* rt, udb_ptr* n) -{ - if(udb_ptr_is_null(n)) - return; - udb_rptr_zero(&RADNODE(n)->elem, udb); - RADTREE(rt)->count --; - if(!udb_radnode_cleanup(udb, rt, n)) { - /* out of memory in cleanup. the elem ptr is NULL, but - * the radix tree could be inefficient. */ - } -} - -udb_void udb_radix_search(udb_ptr* rt, uint8_t* k, udb_radstrlen_type len) -{ - /* since we only perform reads, and no udb_mallocs or udb_frees - * we know the pointers stay the same */ - struct udb_radnode_d* n; - udb_radstrlen_type pos = 0; - uint8_t byte; - void* base = *rt->base; - - n = (struct udb_radnode_d*)UDB_REL(base, RADTREE(rt)->root.data); -#define NARRAY(n) ((struct udb_radarray_d*)UDB_REL(base, n->lookup.data)) -#define NSTR(n, byte) (((uint8_t*)(&NARRAY(n)->array[NARRAY(n)->capacity]))+byte*NARRAY(n)->str_cap) - while(n != *rt->base) { - if(pos == len) - return UDB_SYSTOREL(*rt->base, n); - byte = k[pos]; - if(byte < n->offset) - return 0; - byte -= n->offset; - if(byte >= NARRAY(n)->len) - return 0; - pos++; - if(NARRAY(n)->array[byte].len != 0) { - /* must match additional string */ - if(pos+NARRAY(n)->array[byte].len > len) - return 0; /* no match */ - if(memcmp(&k[pos], NSTR(n, byte), - NARRAY(n)->array[byte].len) != 0) - return 0; /* no match */ - pos += NARRAY(n)->array[byte].len; - } - n = (struct udb_radnode_d*)UDB_REL(base, - NARRAY(n)->array[byte].node.data); - } - return 0; -} - -/** go to last elem-containing node in this subtree (excl self) */ -static void -udb_radnode_last_in_subtree(udb_base* udb, udb_ptr* n) -{ - int idx; - /* try last entry in array first */ - for(idx=((int)lookup(n)->len)-1; idx >= 0; idx--) { - if(lookup(n)->array[idx].node.data) { - udb_ptr s; - udb_ptr_init(&s, udb); - udb_ptr_set_rptr(&s, udb, &lookup(n)->array[idx].node); - /* does it have entries in its subtrees? */ - if(lookup(&s)->len > 0) { - udb_radnode_last_in_subtree(udb, &s); - if(!udb_ptr_is_null(&s)) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - } - udb_ptr_set_rptr(&s, udb, &lookup(n)->array[idx].node); - /* no, does it have an entry itself? */ - if(RADNODE(&s)->elem.data) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - udb_ptr_unlink(&s, udb); - } - } - udb_ptr_zero(n, udb); -} - -/** last in subtree, incl self */ -static void -udb_radnode_last_in_subtree_incl_self(udb_base* udb, udb_ptr* n) -{ - udb_ptr self; - udb_ptr_init(&self, udb); - udb_ptr_set_ptr(&self, udb, n); - udb_radnode_last_in_subtree(udb, n); - if(!udb_ptr_is_null(n)) { - udb_ptr_unlink(&self, udb); - return; - } - if(RADNODE(&self)->elem.data) { - udb_ptr_set_ptr(n, udb, &self); - udb_ptr_unlink(&self, udb); - return; - } - udb_ptr_zero(n, udb); - udb_ptr_unlink(&self, udb); -} - -/** return first elem-containing node in this subtree (excl self) */ -static void -udb_radnode_first_in_subtree(udb_base* udb, udb_ptr* n) -{ - unsigned idx; - /* try every subnode */ - for(idx=0; idxlen; idx++) { - if(lookup(n)->array[idx].node.data) { - udb_ptr s; - udb_ptr_init(&s, udb); - udb_ptr_set_rptr(&s, udb, &lookup(n)->array[idx].node); - /* does it have elem itself? */ - if(RADNODE(&s)->elem.data) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - /* try its subtrees */ - udb_radnode_first_in_subtree(udb, &s); - if(!udb_ptr_is_null(&s)) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - - } - } - udb_ptr_zero(n, udb); -} - -/** Find an entry in arrays from idx-1 to 0 */ -static void -udb_radnode_find_prev_from_idx(udb_base* udb, udb_ptr* n, unsigned from) -{ - unsigned idx = from; - while(idx > 0) { - idx --; - if(lookup(n)->array[idx].node.data) { - udb_ptr_set_rptr(n, udb, &lookup(n)->array[idx].node); - udb_radnode_last_in_subtree_incl_self(udb, n); - if(!udb_ptr_is_null(n)) - return; - } - } - udb_ptr_zero(n, udb); -} - -/** return self or a previous element */ -static int udb_ret_self_or_prev(udb_base* udb, udb_ptr* n, udb_ptr* result) -{ - if(RADNODE(n)->elem.data) { - udb_ptr_set_ptr(result, udb, n); - } else { - udb_ptr_set_ptr(result, udb, n); - udb_radix_prev(udb, result); - } - udb_ptr_unlink(n, udb); - return 0; -} - - -int udb_radix_find_less_equal(udb_base* udb, udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len, udb_ptr* result) -{ - udb_ptr n; - udb_radstrlen_type pos = 0; - uint8_t byte; - int r; - /* set result to NULL */ - udb_ptr_init(result, udb); - if(RADTREE(rt)->count == 0) { - /* empty tree */ - return 0; - } - udb_ptr_new(&n, udb, &RADTREE(rt)->root); - while(pos < len) { - byte = k[pos]; - if(byte < RADNODE(&n)->offset) { - /* so the previous is the element itself */ - /* or something before this element */ - return udb_ret_self_or_prev(udb, &n, result); - } - byte -= RADNODE(&n)->offset; - if(byte >= lookup(&n)->len) { - /* so, the previous is the last of array, or itself */ - /* or something before this element */ - udb_ptr_set_ptr(result, udb, &n); - udb_radnode_last_in_subtree_incl_self(udb, result); - if(udb_ptr_is_null(result)) { - udb_ptr_set_ptr(result, udb, &n); - udb_radix_prev(udb, result); - } - goto done_fail; - } - pos++; - if(!lookup(&n)->array[byte].node.data) { - /* no match */ - /* Find an entry in arrays from byte-1 to 0 */ - udb_ptr_set_ptr(result, udb, &n); - udb_radnode_find_prev_from_idx(udb, result, byte); - if(!udb_ptr_is_null(result)) - goto done_fail; - /* this entry or something before it */ - udb_ptr_zero(result, udb); - return udb_ret_self_or_prev(udb, &n, result); - } - if(lookup_len(&n, byte) != 0) { - /* must match additional string */ - if(pos+lookup_len(&n, byte) > len) { - /* the additional string is longer than key*/ - if( (memcmp(&k[pos], lookup_string(&n, byte), - len-pos)) <= 0) { - /* and the key is before this node */ - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radix_prev(udb, result); - } else { - /* the key is after the additional - * string, thus everything in that - * subtree is smaller. */ - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radnode_last_in_subtree_incl_self(udb, result); - /* if somehow that is NULL, - * then we have an inefficient tree: - * byte+1 is larger than us, so find - * something in byte-1 and before */ - if(udb_ptr_is_null(result)) { - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radix_prev(udb, result); - } - } - goto done_fail; /* no match */ - } - if( (r=memcmp(&k[pos], lookup_string(&n, byte), - lookup_len(&n, byte))) < 0) { - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radix_prev(udb, result); - goto done_fail; /* no match */ - } else if(r > 0) { - /* the key is larger than the additional - * string, thus everything in that subtree - * is smaller */ - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radnode_last_in_subtree_incl_self(udb, result); - /* if we have an inefficient tree */ - if(udb_ptr_is_null(result)) { - udb_ptr_set_rptr(result, udb, - &lookup(&n)->array[byte].node); - udb_radix_prev(udb, result); - } - goto done_fail; /* no match */ - } - pos += lookup_len(&n, byte); - } - udb_ptr_set_rptr(&n, udb, &lookup(&n)->array[byte].node); - } - if(RADNODE(&n)->elem.data) { - /* exact match */ - udb_ptr_set_ptr(result, udb, &n); - udb_ptr_unlink(&n, udb); - return 1; - } - /* there is a node which is an exact match, but it has no element */ - udb_ptr_set_ptr(result, udb, &n); - udb_radix_prev(udb, result); -done_fail: - udb_ptr_unlink(&n, udb); - return 0; -} - -void udb_radix_first(udb_base* udb, udb_ptr* rt, udb_ptr* p) -{ - udb_ptr_init(p, udb); - if(!rt || udb_ptr_is_null(rt) || RADTREE(rt)->count == 0) - return; - udb_ptr_set_rptr(p, udb, &RADTREE(rt)->root); - if(RADNODE(p)->elem.data) - return; - udb_radix_next(udb, p); -} - -void udb_radix_last(udb_base* udb, udb_ptr* rt, udb_ptr* p) -{ - udb_ptr_init(p, udb); - if(!rt || udb_ptr_is_null(rt) || RADTREE(rt)->count == 0) - return; - udb_ptr_set_rptr(p, udb, &RADTREE(rt)->root); - udb_radnode_last_in_subtree_incl_self(udb, p); -} - -void udb_radix_next(udb_base* udb, udb_ptr* n) -{ - udb_ptr s; - udb_ptr_init(&s, udb); - if(lookup(n)->len) { - /* go down */ - udb_ptr_set_ptr(&s, udb, n); - udb_radnode_first_in_subtree(udb, &s); - if(!udb_ptr_is_null(&s)) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - } - /* go up - the parent->elem is not useful, because it is before us */ - while(RADNODE(n)->parent.data) { - unsigned idx = RADNODE(n)->pidx; - udb_ptr_set_rptr(n, udb, &RADNODE(n)->parent); - idx++; - for(; idx < lookup(n)->len; idx++) { - /* go down the next branch */ - if(lookup(n)->array[idx].node.data) { - udb_ptr_set_rptr(&s, udb, - &lookup(n)->array[idx].node); - /* node itself */ - if(RADNODE(&s)->elem.data) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - /* or subtree */ - udb_radnode_first_in_subtree(udb, &s); - if(!udb_ptr_is_null(&s)) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - } - } - } - udb_ptr_unlink(&s, udb); - udb_ptr_zero(n, udb); -} - -void udb_radix_prev(udb_base* udb, udb_ptr* n) -{ - /* must go up, since all array nodes are after this node */ - while(RADNODE(n)->parent.data) { - uint8_t idx = RADNODE(n)->pidx; - udb_ptr s; - udb_ptr_set_rptr(n, udb, &RADNODE(n)->parent); - assert(lookup(n)->len > 0); /* since we are a child */ - /* see if there are elements in previous branches there */ - udb_ptr_init(&s, udb); - udb_ptr_set_ptr(&s, udb, n); - udb_radnode_find_prev_from_idx(udb, &s, idx); - if(!udb_ptr_is_null(&s)) { - udb_ptr_set_ptr(n, udb, &s); - udb_ptr_unlink(&s, udb); - return; - } - udb_ptr_unlink(&s, udb); - /* the current node is before the array */ - if(RADNODE(n)->elem.data) - return; - } - udb_ptr_zero(n, udb); -} - -udb_void udb_radname_insert(udb_base* udb, udb_ptr* rt, const uint8_t* dname, - size_t dlen, udb_ptr* elem, udb_ptr* result) -{ - uint8_t k[300]; - radstrlen_type klen = (radstrlen_type)sizeof(k); - radname_d2r(k, &klen, dname, dlen); - return udb_radix_insert(udb, rt, k, klen, elem, result); -} - -int udb_radname_search(udb_base* udb, udb_ptr* rt, const uint8_t* dname, - size_t dlen, udb_ptr* result) -{ - udb_void r; - uint8_t k[300]; - radstrlen_type klen = (radstrlen_type)sizeof(k); - radname_d2r(k, &klen, dname, dlen); - r = udb_radix_search(rt, k, klen); - udb_ptr_init(result, udb); - udb_ptr_set(result, udb, r); - return (r != 0); -} - -void udb_radix_tree_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - struct udb_radtree_d* p = (struct udb_radtree_d*)d; - assert(s >= sizeof(struct udb_radtree_d)); - (void)s; - (*cb)(base, &p->root, arg); -} - -void udb_radix_node_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - struct udb_radnode_d* p = (struct udb_radnode_d*)d; - assert(s >= sizeof(struct udb_radnode_d)); - (void)s; - (*cb)(base, &p->elem, arg); - (*cb)(base, &p->parent, arg); - (*cb)(base, &p->lookup, arg); -} - -void udb_radix_array_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - struct udb_radarray_d* p = (struct udb_radarray_d*)d; - unsigned i; - assert(s >= sizeof(struct udb_radarray_d)+ - p->capacity*(sizeof(struct udb_radsel_d)+p->str_cap)); - (void)s; - for(i=0; ilen; i++) { - (*cb)(base, &p->array[i].node, arg); - } -} diff --git a/udbradtree.h b/udbradtree.h deleted file mode 100644 index b8e6186ae..000000000 --- a/udbradtree.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * udbradtree -- radix tree for binary strings for in udb file. - * - * Copyright (c) 2011, NLnet Labs. See LICENSE for license. - */ -#ifndef UDB_RADTREE_H -#define UDB_RADTREE_H -#include "udb.h" -struct udb_radnode; - -/** length of the binary string */ -typedef uint16_t udb_radstrlen_type; - -/** - * The radix tree - * - * The elements are stored based on binary strings(0-255) of a given length. - * They are sorted, a prefix is sorted before its suffixes. - * If you want to know the key string, you should store it yourself, the - * tree stores it in the parts necessary for lookup. - * For binary strings for domain names see the radname routines. - * - * This is the tree on disk representation. It has _d suffix in the name - * to help delineate disk structures from normal structures. - */ -struct udb_radtree_d { - /** root node in tree, to udb_radnode_d */ - struct udb_rel_ptr root; - /** count of number of elements */ - uint64_t count; -}; - -/** - * A radix tree lookup node. It is stored on disk, and the lookup array - * is allocated. - */ -struct udb_radnode_d { - /** data element associated with the binary string up to this node */ - struct udb_rel_ptr elem; - /** parent node (NULL for the root), to udb_radnode_d */ - struct udb_rel_ptr parent; - /** the array structure, for lookup by [byte-offset]. udb_radarray_d */ - struct udb_rel_ptr lookup; - /** index in the parent lookup array */ - uint8_t pidx; - /** offset of the lookup array, add to [i] for lookups */ - uint8_t offset; -}; - -/** - * radix select edge in array - * The string for this element is the Nth string in the stringarray. - */ -struct udb_radsel_d { - /** length of the additional string for this edge, - * additional string after the selection-byte for this edge.*/ - udb_radstrlen_type len; - /** padding for non64bit compilers to 64bit boundaries, to make - * the udb file more portable, without this the file would work - * on the system it is created on (which is what we promise), but - * with this, you have a chance of it working on other platforms */ - uint16_t padding16; - uint32_t padding32; - /** node that deals with byte+str, to udb_radnode_d */ - struct udb_rel_ptr node; -}; - -/** - * Array of radsel elements. - * This is the header, the array is allocated contiguously behind it. - * The strings (often very short) are allocated behind the array. - * All strings are given the same amount of space (str_cap), - * so there is capacity*str_cap bytes at the end. - */ -struct udb_radarray_d { - /** length of the lookup array */ - uint16_t len; - /** capacity of the lookup array (can be larger than length) */ - uint16_t capacity; - /** space capacity of for every string */ - udb_radstrlen_type str_cap; - /** padding to 64bit alignment, just in case compiler goes mad */ - uint16_t padding; - /** the elements (allocated contiguously after this structure) */ - struct udb_radsel_d array[0]; -}; - -/** - * Create new radix tree on udb storage - * @param udb: the udb to allocate space on. - * @param ptr: ptr to the udbradtree is returned here. Pass uninitialised. - * type is udb_radtree_d. - * @return 0 on alloc failure. - */ -int udb_radix_tree_create(udb_base* udb, udb_ptr* ptr); - -/** - * Delete intermediate nodes from radix tree - * @param udb: the udb. - * @param rt: radix tree to be cleared. type udb_radtree_d. - */ -void udb_radix_tree_clear(udb_base* udb, udb_ptr* rt); - -/** - * Delete radix tree. - * You must have deleted the elements, this deletes the nodes. - * @param udb: the udb. - * @param rt: radix tree to be deleted. type udb_radtree_d. - */ -void udb_radix_tree_delete(udb_base* udb, udb_ptr* rt); - -/** - * Insert element into radix tree. - * @param udb: the udb. - * @param rt: the radix tree, type udb_radtree_d. - * @param key: key string. - * @param len: length of key. - * @param elem: pointer to element data, on the udb store. - * @param result: the inserted node is set to this value. Pass uninitialised. - Not set if the routine fails. - * @return NULL on failure - out of memory. - * NULL on failure - duplicate entry. - * On success the new radix node for this element (udb_radnode_d). - */ -udb_void udb_radix_insert(udb_base* udb, udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len, udb_ptr* elem, udb_ptr* result); - -/** - * Delete element from radix tree. - * @param udb: the udb. - * @param rt: the radix tree. type udb_radtree_d - * @param n: radix node for that element. type udb_radnode_d - * if NULL, nothing is deleted. - */ -void udb_radix_delete(udb_base* udb, udb_ptr* rt, udb_ptr* n); - -/** - * Find radix element in tree. - * @param rt: the radix tree, type udb_radtree_d. - * @param key: key string. - * @param len: length of key. - * @return the radix node or NULL if not found. type udb_radnode_d - */ -udb_void udb_radix_search(udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len); - -/** - * Find radix element in tree, and if not found, find the closest smaller or - * equal element in the tree. - * @param udb: the udb. - * @param rt: the radix tree, type udb_radtree_d. - * @param key: key string. - * @param len: length of key. - * @param result: returns the radix node or closest match (NULL if key is - * smaller than the smallest key in the tree). type udb_radnode_d. - * you can pass an uninitialized ptr, an unlinked or a zeroed one. - * @return true if exact match, false if no match. - */ -int udb_radix_find_less_equal(udb_base* udb, udb_ptr* rt, uint8_t* k, - udb_radstrlen_type len, udb_ptr* result); - -/** - * Return the first (smallest) element in the tree. - * @param udb: the udb. - * @param rt: the radix tree, type udb_radtree_d. - * @param p: set to the first node in the tree, or NULL if none. - * type udb_radnode_d. - * pass uninitialised, zero or unlinked udb_ptr. - */ -void udb_radix_first(udb_base* udb, udb_ptr* rt, udb_ptr* p); - -/** - * Return the last (largest) element in the tree. - * @param udb: the udb. - * @param rt: the radix tree, type udb_radtree_d. - * @param p: last node or NULL if none, type udb_radnode_d. - * pass uninitialised, zero or unlinked udb_ptr. - */ -void udb_radix_last(udb_base* udb, udb_ptr* rt, udb_ptr* p); - -/** - * Return the next element. - * @param udb: the udb. - * @param n: adjusted to the next element, or NULL if none. type udb_radnode_d. - */ -void udb_radix_next(udb_base* udb, udb_ptr* n); - -/** - * Return the previous element. - * @param udb: the udb. - * @param n: adjusted to the prev node or NULL if none. type udb_radnode_d. - */ -void udb_radix_prev(udb_base* udb, udb_ptr* n); - -/* - * Perform a walk through all elements of the tree. - * node: variable of type struct radnode*. - * tree: pointer to the tree. - * for(udb_radix_first(tree, node); node->data; udb_radix_next(node)) -*/ - -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_radtree */ -void udb_radix_tree_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); - -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_radnode */ -void udb_radix_node_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); - -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_radarray */ -void udb_radix_array_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); - -/** get the memory used by the lookup structure for a radnode */ -size_t size_of_lookup_ext(udb_ptr* node); - -/** insert radtree element, key is a domain name - * @param udb: udb. - * @param rt: the tree. - * @param dname: domain name in uncompressed wireformat. - * @param dlen: length of k. - * @param elem: element to store - * @param result: the inserted node is set to this value. Pass uninitialised. - Not set if the routine fails. - * @return 0 on failure - */ -udb_void udb_radname_insert(udb_base* udb, udb_ptr* rt, const uint8_t* dname, - size_t dlen, udb_ptr* elem, udb_ptr* result); - -/** search for a radname element, key is a domain name. - * @param udb: udb - * @param rt: the tree - * @param dname: domain name in uncompressed wireformat. - * @param dlen: length of k. - * @param result: result ptr to store the node into. - * may be uninitialized. - * @return 0 if not found. - */ -int udb_radname_search(udb_base* udb, udb_ptr* rt, const uint8_t* dname, - size_t dlen, udb_ptr* result); - -#define RADNODE(ptr) ((struct udb_radnode_d*)UDB_PTR(ptr)) -#define RADTREE(ptr) ((struct udb_radtree_d*)UDB_PTR(ptr)) - -#endif /* UDB_RADTREE_H */ diff --git a/udbzone.c b/udbzone.c deleted file mode 100644 index 30f1c4beb..000000000 --- a/udbzone.c +++ /dev/null @@ -1,838 +0,0 @@ -/* - * udbzone -- store zone and rrset information in udb file. - * - * Copyright (c) 2011, NLnet Labs. See LICENSE for license. - */ -#include "config.h" -#include "udbzone.h" -#include "util.h" -#include "iterated_hash.h" -#include "dns.h" -#include "dname.h" -#include "difffile.h" -#include - -/** delete the zone plain its own data */ -static void -udb_zone_delete_plain(udb_base* udb, udb_ptr* zone) -{ - udb_ptr dtree; - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - udb_zone_clear(udb, zone); - udb_rptr_zero(&ZONE(zone)->node, udb); - udb_rptr_zero(&ZONE(zone)->nsec3param, udb); - udb_rptr_zero(&ZONE(zone)->log_str, udb); - udb_rptr_zero(&ZONE(zone)->file_str, udb); - udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); - udb_rptr_zero(&ZONE(zone)->domains, udb); - udb_radix_tree_delete(udb, &dtree); - udb_ptr_free_space(zone, udb, - sizeof(struct zone_d)+ZONE(zone)->namelen); -} - -int -udb_dns_init_file(udb_base* udb) -{ - udb_ptr ztree; - if(!udb_radix_tree_create(udb, &ztree)) { - return 0; - } - udb_base_set_userdata(udb, ztree.data); - udb_ptr_unlink(&ztree, udb); - return 1; -} - -void -udb_dns_deinit_file(udb_base* udb) -{ - udb_ptr ztree; - udb_ptr z; - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - if(udb_ptr_is_null(&ztree)) { - return; - } - assert(udb_ptr_get_type(&ztree) == udb_chunk_type_radtree); - /* delete all zones */ - for(udb_radix_first(udb, &ztree, &z); z.data; udb_radix_next(udb, &z)){ - udb_ptr zone; - udb_ptr_new(&zone, udb, &RADNODE(&z)->elem); - udb_rptr_zero(&RADNODE(&z)->elem, udb); - udb_zone_delete_plain(udb, &zone); - } - udb_ptr_unlink(&z, udb); - - udb_base_set_userdata(udb, 0); - udb_radix_tree_delete(udb, &ztree); -} - -int -udb_zone_create(udb_base* udb, udb_ptr* result, const uint8_t* dname, - size_t dlen) -{ - udb_ptr ztree, z, node, dtree; - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - assert(udb_ptr_get_type(&ztree) == udb_chunk_type_radtree); - udb_ptr_init(result, udb); - if(udb_zone_search(udb, &z, dname, dlen)) { - udb_ptr_unlink(&ztree, udb); - udb_ptr_unlink(&z, udb); - /* duplicate */ - return 0; - } - if(!udb_ptr_alloc_space(&z, udb, udb_chunk_type_zone, - sizeof(struct zone_d)+dlen)) { - udb_ptr_unlink(&ztree, udb); - /* failed alloc */ - return 0; - } - /* init the zone object */ - udb_rel_ptr_init(&ZONE(&z)->node); - udb_rel_ptr_init(&ZONE(&z)->domains); - udb_rel_ptr_init(&ZONE(&z)->nsec3param); - udb_rel_ptr_init(&ZONE(&z)->log_str); - udb_rel_ptr_init(&ZONE(&z)->file_str); - ZONE(&z)->rrset_count = 0; - ZONE(&z)->rr_count = 0; - ZONE(&z)->expired = 0; - ZONE(&z)->mtime = 0; - ZONE(&z)->mtime_nsec = 0; - ZONE(&z)->namelen = dlen; - memmove(ZONE(&z)->name, dname, dlen); - if(!udb_radix_tree_create(udb, &dtree)) { - udb_ptr_free_space(&z, udb, sizeof(struct zone_d)+dlen); - udb_ptr_unlink(&ztree, udb); - /* failed alloc */ - return 0; - } - udb_rptr_set_ptr(&ZONE(&z)->domains, udb, &dtree); - - /* insert it */ - if(!udb_radname_insert(udb, &ztree, dname, dlen, &z, &node)) { - udb_ptr_free_space(&z, udb, sizeof(struct zone_d)+dlen); - udb_ptr_unlink(&ztree, udb); - udb_radix_tree_delete(udb, &dtree); - udb_ptr_unlink(&dtree, udb); - /* failed alloc */ - return 0; - } - udb_rptr_set_ptr(&ZONE(&z)->node, udb, &node); - udb_ptr_set_ptr(result, udb, &z); - udb_ptr_unlink(&z, udb); - udb_ptr_unlink(&dtree, udb); - udb_ptr_unlink(&ztree, udb); - udb_ptr_unlink(&node, udb); - return 1; -} - -/** delete an RR */ -static void -rr_delete(udb_base* udb, udb_ptr* rr) -{ - assert(udb_ptr_get_type(rr) == udb_chunk_type_rr); - udb_rptr_zero(&RR(rr)->next, udb); - udb_ptr_free_space(rr, udb, sizeof(struct rr_d)+RR(rr)->len); -} - -/** delete an rrset */ -static void -rrset_delete(udb_base* udb, udb_ptr* rrset) -{ - udb_ptr rr, n; - assert(udb_ptr_get_type(rrset) == udb_chunk_type_rrset); - - /* free RRs */ - udb_ptr_new(&rr, udb, &RRSET(rrset)->rrs); - udb_ptr_init(&n, udb); - udb_rptr_zero(&RRSET(rrset)->rrs, udb); - while(!udb_ptr_is_null(&rr)) { - udb_ptr_set_rptr(&n, udb, &RR(&rr)->next); - rr_delete(udb, &rr); - udb_ptr_set_ptr(&rr, udb, &n); - udb_ptr_zero(&n, udb); - } - udb_ptr_unlink(&n, udb); - udb_ptr_unlink(&rr, udb); - - udb_rptr_zero(&RRSET(rrset)->next, udb); - udb_ptr_free_space(rrset, udb, sizeof(struct rrset_d)); -} - -/** clear a domain of its rrsets, rrs */ -static void -domain_clear(udb_base* udb, udb_ptr* d) -{ - udb_ptr rrset, n; - assert(udb_ptr_get_type(d) == udb_chunk_type_domain); - udb_ptr_new(&rrset, udb, &DOMAIN(d)->rrsets); - udb_ptr_init(&n, udb); - udb_rptr_zero(&DOMAIN(d)->rrsets, udb); - while(!udb_ptr_is_null(&rrset)) { - udb_ptr_set_rptr(&n, udb, &RRSET(&rrset)->next); - rrset_delete(udb, &rrset); - udb_ptr_set_ptr(&rrset, udb, &n); - udb_ptr_zero(&n, udb); - } - udb_ptr_unlink(&n, udb); - udb_ptr_unlink(&rrset, udb); -} - -/** delete a domain and all its rrsets, rrs */ -static void -domain_delete(udb_base* udb, udb_ptr* d) -{ - domain_clear(udb, d); - udb_rptr_zero(&DOMAIN(d)->node, udb); - udb_ptr_free_space(d, udb, - sizeof(struct domain_d)+DOMAIN(d)->namelen); -} - -/** delete domain but also unlink from tree at zone */ -static void -domain_delete_unlink(udb_base* udb, udb_ptr* z, udb_ptr* d) -{ - udb_ptr dtree, n; - udb_ptr_new(&dtree, udb, &ZONE(z)->domains); - udb_ptr_new(&n, udb, &DOMAIN(d)->node); - udb_rptr_zero(&DOMAIN(d)->node, udb); - udb_radix_delete(udb, &dtree, &n); - udb_ptr_unlink(&dtree, udb); - udb_ptr_unlink(&n, udb); - domain_delete(udb, d); -} - -void -udb_zone_clear(udb_base* udb, udb_ptr* zone) -{ - udb_ptr dtree, d; - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); - udb_rptr_zero(&ZONE(zone)->nsec3param, udb); - udb_zone_set_log_str(udb, zone, NULL); - udb_zone_set_file_str(udb, zone, NULL); - - /* walk and delete all domains, rrsets, rrs, but keep tree */ - for(udb_radix_first(udb, &dtree, &d); d.data; udb_radix_next(udb, &d)){ - udb_ptr domain; - udb_ptr_new(&domain, udb, &RADNODE(&d)->elem); - udb_rptr_zero(&RADNODE(&d)->elem, udb); - domain_delete(udb, &domain); - } - udb_ptr_unlink(&d, udb); - udb_radix_tree_clear(udb, &dtree); - ZONE(zone)->rrset_count = 0; - ZONE(zone)->rr_count = 0; - ZONE(zone)->expired = 0; - ZONE(zone)->mtime = 0; - ZONE(zone)->mtime_nsec = 0; - udb_ptr_unlink(&dtree, udb); -} - -void -udb_zone_delete(udb_base* udb, udb_ptr* zone) -{ - udb_ptr ztree, n; - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - udb_ptr_new(&n, udb, &ZONE(zone)->node); - udb_rptr_zero(&ZONE(zone)->node, udb); - udb_radix_delete(udb, &ztree, &n); - udb_ptr_unlink(&ztree, udb); - udb_ptr_unlink(&n, udb); - udb_zone_delete_plain(udb, zone); -} - -int -udb_zone_search(udb_base* udb, udb_ptr* result, const uint8_t* dname, - size_t dname_len) -{ - udb_ptr ztree; - udb_ptr_new(&ztree, udb, udb_base_get_userdata(udb)); - assert(udb_ptr_get_type(&ztree) == udb_chunk_type_radtree); - if(udb_radname_search(udb, &ztree, dname, dname_len, result)) { - if(result->data) - udb_ptr_set_rptr(result, udb, &RADNODE(result)->elem); - udb_ptr_unlink(&ztree, udb); - return (result->data != 0); - } - udb_ptr_unlink(&ztree, udb); - return 0; -} - -void udb_zone_get_mtime(udb_base* udb, const uint8_t* dname, size_t dlen, - struct timespec* mtime) -{ - udb_ptr z; - if(udb_zone_search(udb, &z, dname, dlen)) { - mtime->tv_sec = ZONE(&z)->mtime; - mtime->tv_nsec = ZONE(&z)->mtime_nsec; - udb_ptr_unlink(&z, udb); - return; - } - mtime->tv_sec = 0; - mtime->tv_nsec = 0; -} - -void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str) -{ - /* delete original log str (if any) */ - if(ZONE(zone)->log_str.data) { - udb_ptr s; - size_t sz; - udb_ptr_new(&s, udb, &ZONE(zone)->log_str); - udb_rptr_zero(&ZONE(zone)->log_str, udb); - sz = strlen((char*)udb_ptr_data(&s))+1; - udb_ptr_free_space(&s, udb, sz); - } - - /* set new log str */ - if(str) { - udb_ptr s; - size_t sz = strlen(str)+1; - if(!udb_ptr_alloc_space(&s, udb, udb_chunk_type_data, sz)) { - return; /* failed to allocate log string */ - } - memmove(udb_ptr_data(&s), str, sz); - udb_rptr_set_ptr(&ZONE(zone)->log_str, udb, &s); - udb_ptr_unlink(&s, udb); - } -} - -void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str) -{ - /* delete original file str (if any) */ - if(ZONE(zone)->file_str.data) { - udb_ptr s; - size_t sz; - udb_ptr_new(&s, udb, &ZONE(zone)->file_str); - udb_rptr_zero(&ZONE(zone)->file_str, udb); - sz = strlen((char*)udb_ptr_data(&s))+1; - udb_ptr_free_space(&s, udb, sz); - } - - /* set new file str */ - if(str) { - udb_ptr s; - size_t sz = strlen(str)+1; - if(!udb_ptr_alloc_space(&s, udb, udb_chunk_type_data, sz)) { - return; /* failed to allocate file string */ - } - memmove(udb_ptr_data(&s), str, sz); - udb_rptr_set_ptr(&ZONE(zone)->file_str, udb, &s); - udb_ptr_unlink(&s, udb); - } -} - -const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, - size_t dlen) -{ - udb_ptr z; - if(udb_zone_search(udb, &z, dname, dlen)) { - const char* str; - if(ZONE(&z)->file_str.data) { - udb_ptr s; - udb_ptr_new(&s, udb, &ZONE(&z)->file_str); - str = (const char*)udb_ptr_data(&s); - udb_ptr_unlink(&s, udb); - } else str = NULL; - udb_ptr_unlink(&z, udb); - return str; - } - return NULL; -} - -#ifdef NSEC3 -/** select the nsec3param for nsec3 usage */ -static void -select_nsec3_param(udb_base* udb, udb_ptr* zone, udb_ptr* rrset) -{ - udb_ptr rr; - udb_ptr_new(&rr, udb, &RRSET(rrset)->rrs); - while(rr.data) { - if(RR(&rr)->len >= 5 && RR(&rr)->wire[0] == NSEC3_SHA1_HASH && - RR(&rr)->wire[1] == 0) { - udb_rptr_set_ptr(&ZONE(zone)->nsec3param, udb, &rr); - udb_ptr_unlink(&rr, udb); - return; - } - udb_ptr_set_rptr(&rr, udb, &RR(&rr)->next); - } - udb_ptr_unlink(&rr, udb); -} - -const char* -udb_nsec3param_string(udb_ptr* rr) -{ - /* max saltlenth plus first couple of numbers (3+1+5+1+3+1) */ - static char params[MAX_RDLENGTH*2+16]; - char* p; - assert(RR(rr)->len >= 5); - p = params + snprintf(params, sizeof(params), "%u %u %u ", - (unsigned)RR(rr)->wire[0], (unsigned)RR(rr)->wire[1], - (unsigned)read_uint16(&RR(rr)->wire[2])); - if(RR(rr)->wire[4] == 0) { - *p++ = '-'; - } else { - assert(RR(rr)->len >= 5+RR(rr)->wire[4]); - p += hex_ntop(&RR(rr)->wire[5], RR(rr)->wire[4], p, - sizeof(params)-strlen(params)-1); - } - *p = 0; - return params; -} - -/** look in zone for new selected nsec3param record from rrset */ -static void -zone_hash_nsec3param(udb_base* udb, udb_ptr* zone, udb_ptr* rrset) -{ - select_nsec3_param(udb, zone, rrset); - if(ZONE(zone)->nsec3param.data == 0) - return; - /* prettyprint the nsec3 parameters we are using */ - if(2 <= verbosity) { - udb_ptr par; - udb_ptr_new(&par, udb, &ZONE(zone)->nsec3param); - VERBOSITY(1, (LOG_INFO, "rehash of zone %s with parameters %s", - wiredname2str(ZONE(zone)->name), - udb_nsec3param_string(&par))); - udb_ptr_unlink(&par, udb); - } -} -#endif /* NSEC3 */ - -/** create a new domain name */ -static int -domain_create(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, - udb_ptr* result) -{ - udb_ptr dtree, node; - /* create domain chunk */ - if(!udb_ptr_alloc_space(result, udb, udb_chunk_type_domain, - sizeof(struct domain_d)+nmlen)) - return 0; - udb_rel_ptr_init(&DOMAIN(result)->node); - udb_rel_ptr_init(&DOMAIN(result)->rrsets); - DOMAIN(result)->namelen = nmlen; - memmove(DOMAIN(result)->name, nm, nmlen); - - /* insert into domain tree */ - udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); - if(!udb_radname_insert(udb, &dtree, nm, nmlen, result, &node)) { - udb_ptr_free_space(result, udb, sizeof(struct domain_d)+nmlen); - udb_ptr_unlink(&dtree, udb); - return 0; - } - udb_rptr_set_ptr(&DOMAIN(result)->node, udb, &node); - udb_ptr_unlink(&dtree, udb); - udb_ptr_unlink(&node, udb); - return 1; -} - -int -udb_domain_find(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, - udb_ptr* result) -{ - int r; - udb_ptr dtree; - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); - r = udb_radname_search(udb, &dtree, nm, nmlen, result); - if(result->data) - udb_ptr_set_rptr(result, udb, &RADNODE(result)->elem); - udb_ptr_unlink(&dtree, udb); - return r && result->data; -} - -/** find or create a domain name in the zone domain tree */ -static int -domain_find_or_create(udb_base* udb, udb_ptr* zone, const uint8_t* nm, - size_t nmlen, udb_ptr* result) -{ - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - if(udb_domain_find(udb, zone, nm, nmlen, result)) - return 1; - return domain_create(udb, zone, nm, nmlen, result); -} - -/** remove rrset from the domain name rrset-list */ -static void -domain_remove_rrset(udb_base* udb, udb_ptr* domain, uint16_t t) -{ - udb_ptr p, prev; - assert(udb_ptr_get_type(domain) == udb_chunk_type_domain); - udb_ptr_new(&p, udb, &DOMAIN(domain)->rrsets); - udb_ptr_init(&prev, udb); - while(p.data) { - if(RRSET(&p)->type == t) { - /* remove it */ - if(prev.data == 0) { - /* first rrset */ - udb_rptr_set_rptr(&DOMAIN(domain)->rrsets, - udb, &RRSET(&p)->next); - } else { - udb_rptr_set_rptr(&RRSET(&prev)->next, - udb, &RRSET(&p)->next); - } - udb_ptr_unlink(&prev, udb); - rrset_delete(udb, &p); - return; - } - udb_ptr_set_ptr(&prev, udb, &p); - udb_ptr_set_rptr(&p, udb, &RRSET(&p)->next); - } - /* rrset does not exist */ - udb_ptr_unlink(&prev, udb); - udb_ptr_unlink(&p, udb); -} - -/** create rrset in the domain rrset list */ -static int -rrset_create(udb_base* udb, udb_ptr* domain, uint16_t t, udb_ptr* res) -{ - /* create it */ - if(!udb_ptr_alloc_space(res, udb, udb_chunk_type_rrset, - sizeof(struct rrset_d))) - return 0; - udb_rel_ptr_init(&RRSET(res)->next); - udb_rel_ptr_init(&RRSET(res)->rrs); - RRSET(res)->type = t; - -#if 0 - /* link it in, at the front */ - udb_rptr_set_rptr(&RRSET(res)->next, udb, &DOMAIN(domain)->rrsets); - udb_rptr_set_ptr(&DOMAIN(domain)->rrsets, udb, res); -#else - /* preserve RRset order, link at end */ - if(DOMAIN(domain)->rrsets.data == 0) { - udb_rptr_set_ptr(&DOMAIN(domain)->rrsets, udb, res); - } else { - udb_ptr p; - udb_ptr_new(&p, udb, &DOMAIN(domain)->rrsets); - while(RRSET(&p)->next.data) - udb_ptr_set_rptr(&p, udb, &RRSET(&p)->next); - udb_rptr_set_ptr(&RRSET(&p)->next, udb, res); - udb_ptr_unlink(&p, udb); - } -#endif - return 1; -} - -int -udb_rrset_find(udb_base* udb, udb_ptr* domain, uint16_t t, udb_ptr* res) -{ - assert(udb_ptr_get_type(domain) == udb_chunk_type_domain); - udb_ptr_init(res, udb); - udb_ptr_set_rptr(res, udb, &DOMAIN(domain)->rrsets); - while(res->data) { - if(RRSET(res)->type == t) - return 1; - udb_ptr_set_rptr(res, udb, &RRSET(res)->next); - } - /* rrset does not exist and res->data is conveniently zero */ - return 0; -} - -/** find or create rrset in the domain rrset list */ -static int -rrset_find_or_create(udb_base* udb, udb_ptr* domain, uint16_t t, udb_ptr* res) -{ - if(udb_rrset_find(udb, domain, t, res)) - return 1; - return rrset_create(udb, domain, t, res); -} - -/** see if RR matches type, class and rdata */ -static int -rr_match(udb_ptr* rr, uint16_t t, uint16_t k, uint8_t* rdata, size_t rdatalen) -{ - return RR(rr)->type == t && RR(rr)->klass == k && - RR(rr)->len == rdatalen && - memcmp(RR(rr)->wire, rdata, rdatalen) == 0; -} - -/** see if RR exists in the RR list that matches the rdata, and return it */ -static int -rr_search(udb_base* udb, udb_ptr* rrset, uint16_t t, uint16_t k, - uint8_t* rdata, size_t rdatalen, udb_ptr* result) -{ - assert(udb_ptr_get_type(rrset) == udb_chunk_type_rrset); - udb_ptr_init(result, udb); - udb_ptr_set_rptr(result, udb, &RRSET(rrset)->rrs); - while(result->data) { - if(rr_match(result, t, k, rdata, rdatalen)) - return 1; /* found */ - udb_ptr_set_rptr(result, udb, &RR(result)->next); - } - /* not found and result->data is conveniently zero */ - return 0; -} - -/** create RR chunk */ -static int -rr_create(udb_base* udb, uint16_t t, uint16_t k, uint32_t ttl, - uint8_t* rdata, size_t rdatalen, udb_ptr* rr) -{ - if(!udb_ptr_alloc_space(rr, udb, udb_chunk_type_rr, - sizeof(struct rr_d)+rdatalen)) - return 0; - udb_rel_ptr_init(&RR(rr)->next); - RR(rr)->type = t; - RR(rr)->klass = k; - RR(rr)->ttl = ttl; - RR(rr)->len = rdatalen; - memmove(RR(rr)->wire, rdata, rdatalen); - return 1; -} - -/** add an RR to an RRset. */ -static int -rrset_add_rr(udb_base* udb, udb_ptr* rrset, uint16_t t, uint16_t k, - uint32_t ttl, uint8_t* rdata, size_t rdatalen) -{ - udb_ptr rr; - assert(udb_ptr_get_type(rrset) == udb_chunk_type_rrset); - /* create it */ - if(!rr_create(udb, t, k, ttl, rdata, rdatalen, &rr)) - return 0; - - /* add at end, to preserve order of RRs */ - if(RRSET(rrset)->rrs.data == 0) { - udb_rptr_set_ptr(&RRSET(rrset)->rrs, udb, &rr); - } else { - udb_ptr lastrr; - udb_ptr_new(&lastrr, udb, &RRSET(rrset)->rrs); - while(RR(&lastrr)->next.data) - udb_ptr_set_rptr(&lastrr, udb, &RR(&lastrr)->next); - udb_rptr_set_ptr(&RR(&lastrr)->next, udb, &rr); - udb_ptr_unlink(&lastrr, udb); - } - udb_ptr_unlink(&rr, udb); - return 1; -} - -/** remove an RR from an RRset. return 0 if RR did not exist. */ -static int -rrset_del_rr(udb_base* udb, udb_ptr* rrset, uint16_t t, uint16_t k, - uint8_t* rdata, size_t rdatalen) -{ - udb_ptr p, prev; - assert(udb_ptr_get_type(rrset) == udb_chunk_type_rrset); - udb_ptr_new(&p, udb, &RRSET(rrset)->rrs); - udb_ptr_init(&prev, udb); - while(p.data) { - if(rr_match(&p, t, k, rdata, rdatalen)) { - /* remove it */ - if(prev.data == 0) { - /* first in list */ - udb_rptr_set_rptr(&RRSET(rrset)->rrs, udb, - &RR(&p)->next); - } else { - udb_rptr_set_rptr(&RR(&prev)->next, udb, - &RR(&p)->next); - } - udb_ptr_unlink(&prev, udb); - rr_delete(udb, &p); - return 1; - } - udb_ptr_set_ptr(&prev, udb, &p); - udb_ptr_set_rptr(&p, udb, &RR(&p)->next); - } - /* not found */ - udb_ptr_unlink(&prev, udb); - udb_ptr_unlink(&p, udb); - return 0; -} - -int -udb_zone_add_rr(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, - uint16_t t, uint16_t k, uint32_t ttl, uint8_t* rdata, size_t rdatalen) -{ - udb_ptr domain, rrset, rr; - int created_rrset = 0; - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - - /* find or create domain */ - if(!domain_find_or_create(udb, zone, nm, nmlen, &domain)) { - return 0; - } - /* find or create rrset(type) */ - if(!rrset_find_or_create(udb, &domain, t, &rrset)) { - goto exit_clean_domain; - } - if(RRSET(&rrset)->rrs.data == 0) - created_rrset = 1; - /* test for duplicate RRs */ - if(rr_search(udb, &rrset, t, k, rdata, rdatalen, &rr)) { - udb_ptr_unlink(&rr, udb); - goto exit_clean_domain_rrset; - } - /* add RR to rrset */ - if(!rrset_add_rr(udb, &rrset, t, k, ttl, rdata, rdatalen)) { - exit_clean_domain_rrset: - /* if rrset was created, remove it */ - if(RRSET(&rrset)->rrs.data == 0) { - udb_ptr_zero(&rrset, udb); - domain_remove_rrset(udb, &domain, t); - } - udb_ptr_unlink(&rrset, udb); - exit_clean_domain: - /* if domain created, delete it */ - if(DOMAIN(&domain)->rrsets.data == 0) - domain_delete_unlink(udb, zone, &domain); - udb_ptr_unlink(&domain, udb); - return 0; - } - /* success, account changes */ - if(created_rrset) - ZONE(zone)->rrset_count ++; - ZONE(zone)->rr_count ++; -#ifdef NSEC3 - if(t == TYPE_NSEC3PARAM && ZONE(zone)->nsec3param.data == 0) - zone_hash_nsec3param(udb, zone, &rrset); -#endif /* NSEC3 */ - udb_ptr_unlink(&domain, udb); - udb_ptr_unlink(&rrset, udb); - return 1; -} - -void -udb_zone_del_rr(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, - uint16_t t, uint16_t k, uint8_t* rdata, size_t rdatalen) -{ - udb_ptr domain, rrset; - assert(udb_ptr_get_type(zone) == udb_chunk_type_zone); - /* find the domain */ - if(!udb_domain_find(udb, zone, nm, nmlen, &domain)) - return; - /* find the rrset */ - if(!udb_rrset_find(udb, &domain, t, &rrset)) { - udb_ptr_unlink(&domain, udb); - return; - } - /* remove the RR */ -#ifdef NSEC3 - if(t == TYPE_NSEC3PARAM) { - udb_ptr rr; - if(rr_search(udb, &rrset, t, k, rdata, rdatalen, &rr)) { - if(rr.data == ZONE(zone)->nsec3param.data) { - udb_rptr_zero(&ZONE(zone)->nsec3param, udb); - } - udb_ptr_unlink(&rr, udb); - } - } -#endif /* NSEC3 */ - if(!rrset_del_rr(udb, &rrset, t, k, rdata, rdatalen)) { - /* rr did not exist */ - udb_ptr_unlink(&domain, udb); - udb_ptr_unlink(&rrset, udb); - return; - } - ZONE(zone)->rr_count --; -#ifdef NSEC3 - if(t == TYPE_NSEC3PARAM && ZONE(zone)->nsec3param.data == 0 && - RRSET(&rrset)->rrs.data != 0) { - zone_hash_nsec3param(udb, zone, &rrset); - } -#endif /* NSEC3 */ - /* see we we can remove the rrset too */ - if(RRSET(&rrset)->rrs.data == 0) { - udb_ptr_zero(&rrset, udb); - domain_remove_rrset(udb, &domain, t); - ZONE(zone)->rrset_count --; - } - /* see if we can remove the domain name too */ - if(DOMAIN(&domain)->rrsets.data == 0) { - domain_delete_unlink(udb, zone, &domain); - } - udb_ptr_unlink(&rrset, udb); - udb_ptr_unlink(&domain, udb); -} - -void -udb_zone_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, - void* arg) -{ - struct zone_d* p = (struct zone_d*)d; - assert(s >= sizeof(struct zone_d)+p->namelen); - (void)s; - (*cb)(base, &p->node, arg); - (*cb)(base, &p->domains, arg); - (*cb)(base, &p->nsec3param, arg); - (*cb)(base, &p->log_str, arg); - (*cb)(base, &p->file_str, arg); -} - -void -udb_domain_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, - void* arg) -{ - struct domain_d* p = (struct domain_d*)d; - assert(s >= sizeof(struct domain_d)+p->namelen); - (void)s; - (*cb)(base, &p->node, arg); - (*cb)(base, &p->rrsets, arg); -} - -void -udb_rrset_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, - void* arg) -{ - struct rrset_d* p = (struct rrset_d*)d; - assert(s >= sizeof(struct rrset_d)); - (void)s; - (*cb)(base, &p->next, arg); - (*cb)(base, &p->rrs, arg); -} - -void -udb_rr_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, - void* arg) -{ - struct rr_d* p = (struct rr_d*)d; - assert(s >= sizeof(struct rr_d)+p->len); - (void)s; - (*cb)(base, &p->next, arg); -} - -void -udb_task_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, - void* arg) -{ - struct task_list_d* p = (struct task_list_d*)d; - assert(s >= p->size); - (void)s; - (*cb)(base, &p->next, arg); -} - -void namedb_walkfunc(void* base, void* warg, uint8_t t, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg) -{ - (void)warg; - switch(t) { - case udb_chunk_type_radtree: - udb_radix_tree_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_radnode: - udb_radix_node_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_radarray: - udb_radix_array_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_zone: - udb_zone_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_domain: - udb_domain_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_rrset: - udb_rrset_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_rr: - udb_rr_walk_chunk(base, d, s, cb, arg); - break; - case udb_chunk_type_task: - udb_task_walk_chunk(base, d, s, cb, arg); - break; - default: - /* no rel ptrs */ - break; - } -} diff --git a/udbzone.h b/udbzone.h deleted file mode 100644 index 8c5c53255..000000000 --- a/udbzone.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * udbzone -- store zone and rrset information in udb file. - * - * Copyright (c) 2011, NLnet Labs. See LICENSE for license. - */ -#ifndef UDB_ZONE_H -#define UDB_ZONE_H -#include "udb.h" -#include "dns.h" -#include "udbradtree.h" - -/** - * Store the DNS information in udb file on disk. - * udb_global - * | - * v - * zonetree -> zone -- zone_name - * radtree |--> nsec3param - * |--> log_str - * |--> file_str - * | - * v - * domain --> rrset -> rr - * radtree list list - * |-- name - */ - -/** zone information in the nsd.udb. Name allocated after it. */ -struct zone_d { - /** radtree node in the zonetree for this zone */ - udb_rel_ptr node; - /** the radtree for the domain names in the zone */ - udb_rel_ptr domains; - /** the NSEC3PARAM rr used for hashing (or 0), rr_d pointer */ - udb_rel_ptr nsec3param; - /** the log_str for the AXFR change, or 0 */ - udb_rel_ptr log_str; - /** the file name when read from a file, or 0 */ - udb_rel_ptr file_str; - /** modification time, time when the zone data was changed */ - uint64_t mtime; - /** modification time, nsecs */ - uint64_t mtime_nsec; - /** number of RRsets in the zone */ - uint64_t rrset_count; - /** number of RRs in the zone */ - uint64_t rr_count; - /** the length of the zone name */ - udb_radstrlen_type namelen; - /** if the zone is expired */ - uint8_t expired; - /** if the zone has been changed by AXFR */ - uint8_t is_changed; - /** the zone (wire uncompressed) name in DNS format */ - uint8_t name[0]; -}; - -/** domain name in the nametree. name allocated after it */ -struct domain_d { - /** radtree node in the nametree for this domain */ - udb_rel_ptr node; - /** the list of rrsets for this name, single linked */ - udb_rel_ptr rrsets; - /** length of the domain name */ - udb_radstrlen_type namelen; - /** the domain (wire uncompressed) name in DNS format */ - uint8_t name[0]; -}; - -/** rrset information. */ -struct rrset_d { - /** next in rrset list */ - udb_rel_ptr next; - /** the singly linked list of rrs for this rrset */ - udb_rel_ptr rrs; - /** type of the RRs in this rrset (host order) */ - uint16_t type; -}; - -/** rr information; wireformat data allocated after it */ -struct rr_d { - /** next in rr list */ - udb_rel_ptr next; - /** type (host order) */ - uint16_t type; - /** class (host order) */ - uint16_t klass; - /** ttl (host order) */ - uint32_t ttl; - /** length of wireformat */ - uint16_t len; - /** wireformat of rdata (without rdatalen) */ - uint8_t wire[0]; -}; - -/** init an udb for use as DNS store */ -int udb_dns_init_file(udb_base* udb); -/** de-init an udb for use as DNS store */ -void udb_dns_deinit_file(udb_base* udb); - -/** create a zone */ -int udb_zone_create(udb_base* udb, udb_ptr* result, const uint8_t* dname, - size_t dlen); -/** clear all RRsets from a zone */ -void udb_zone_clear(udb_base* udb, udb_ptr* zone); -/** delete a zone */ -void udb_zone_delete(udb_base* udb, udb_ptr* zone); -/** find a zone by name (exact match) */ -int udb_zone_search(udb_base* udb, udb_ptr* result, const uint8_t* dname, - size_t dlen); -/** get modification time for zone or 0 */ -void udb_zone_get_mtime(udb_base* udb, const uint8_t* dname, size_t dlen, - struct timespec* mtime); -/** set log str in udb, or remove it */ -void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str); -/** set file str in udb, or remove it */ -void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str); -/** get file string for zone or NULL */ -const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, - size_t dlen); -/** find a domain name in the zone domain tree */ -int udb_domain_find(udb_base* udb, udb_ptr* zone, const uint8_t* nm, - size_t nmlen, udb_ptr* result); -/** find rrset in domain */ -int udb_rrset_find(udb_base* udb, udb_ptr* domain, uint16_t t, udb_ptr* res); - -/** add an RR to a zone */ -int udb_zone_add_rr(udb_base* udb, udb_ptr* zone, const uint8_t* nm, - size_t nmlen, uint16_t t, uint16_t k, uint32_t ttl, uint8_t* rdata, - size_t rdatalen); -/** del an RR from a zone */ -void udb_zone_del_rr(udb_base* udb, udb_ptr* zone, const uint8_t* nm, - size_t nmlen, uint16_t t, uint16_t k, uint8_t* rdata, size_t rdatalen); - -/** get pretty string for nsec3parameters (static buffer returned) */ -const char* udb_nsec3param_string(udb_ptr* rr); - -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_zone */ -void udb_zone_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_domain */ -void udb_domain_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_rrset */ -void udb_rrset_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); -/** for use in udb-walkfunc, walks relptrs in udb_chunk_type_rr */ -void udb_rr_walk_chunk(void* base, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); - -/** walk through relptrs in registered types */ -void namedb_walkfunc(void* base, void* warg, uint8_t t, void* d, uint64_t s, - udb_walk_relptr_cb* cb, void* arg); - -#define ZONE(ptr) ((struct zone_d*)UDB_PTR(ptr)) -#define DOMAIN(ptr) ((struct domain_d*)UDB_PTR(ptr)) -#define RRSET(ptr) ((struct rrset_d*)UDB_PTR(ptr)) -#define RR(ptr) ((struct rr_d*)UDB_PTR(ptr)) - -#endif /* UDB_ZONE_H */ diff --git a/xfr-inspect.c b/xfr-inspect.c index c87ff47eb..e6a52a226 100644 --- a/xfr-inspect.c +++ b/xfr-inspect.c @@ -5,7 +5,6 @@ */ #include "config.h" -#include "udbzone.h" #include "util.h" #include "buffer.h" #include "packet.h" diff --git a/xfrd.c b/xfrd.c index 6006ff777..7abbff382 100644 --- a/xfrd.c +++ b/xfrd.c @@ -869,7 +869,6 @@ xfrd_del_slave_zone(xfrd_state_type* xfrd, const dname_type* dname) void xfrd_free_namedb(struct nsd* nsd) { - namedb_close_udb(nsd->db); namedb_close(nsd->db); nsd->db = 0; }