Skip to content

Commit

Permalink
Replace zone compiler with simdzone
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Koekkoek committed Apr 4, 2024
1 parent b516dbb commit 6c73e68
Show file tree
Hide file tree
Showing 24 changed files with 884 additions and 4,922 deletions.
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ task:
LIBEVENT: "/opt/homebrew/opt/libevent"

build_script:
- git submodule update
- autoconf && autoheader
- (cd simdzone && autoconf)
- libtoolize -c -i || glibtoolize -c -i
- ./configure --enable-checking --disable-flto --with-ssl=${OPENSSL:-yes} --with-libevent=${LIBEVENT:-yes}
- make -j 2
Expand Down
66 changes: 24 additions & 42 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DNSTAP_OBJ=@DNSTAP_OBJ@
U=

CC = @CC@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS = @CPPFLAGS@ -Isimdzone/include
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
Expand Down Expand Up @@ -78,13 +78,13 @@ 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 util.o bitset.o popen3.o proxy_protocol.o
XFRD_OBJ=xfrd-catalog-zones.o 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
NSD_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) difffile.o ipc.o mini_event.o netio.o nsd.o server.o dbaccess.o dbcreate.o zonec.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_CHECKZONE_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) dbaccess.o dbcreate.o difffile.o ipc.o mini_event.o netio.o server.o zonec.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_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
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 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 nsd-mem.o
all: $(TARGETS) $(MANUALS)

$(ALL_OBJ):
Expand Down Expand Up @@ -152,26 +152,29 @@ uninstall:

test:

nsd: $(NSD_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS)
simdzone/libzone.a:
$(MAKE) -C simdzone

nsd-checkconf: $(NSD_CHECKCONF_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CHECKCONF_OBJ) $(LIBOBJS) $(LIBS)
nsd: simdzone/libzone.a $(NSD_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_OBJ) $(LIBOBJS) simdzone/libzone.a $(SSL_LIBS) $(LIBS)

nsd-checkzone: $(NSD_CHECKZONE_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CHECKZONE_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS)
nsd-checkconf: simdzone/libzone.a $(NSD_CHECKCONF_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CHECKCONF_OBJ) simdzone/libzone.a $(LIBOBJS) $(LIBS)

nsd-control: $(NSD_CONTROL_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CONTROL_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS)
nsd-checkzone: simdzone/libzone.a $(NSD_CHECKZONE_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CHECKZONE_OBJ) $(LIBOBJS) simdzone/libzone.a $(SSL_LIBS) $(LIBS)

nsd-control: simdzone/libzone.a $(NSD_CONTROL_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_CONTROL_OBJ) $(LIBOBJS) simdzone/libzone.a $(SSL_LIBS) $(LIBS)

nsd-mem: $(NSD_MEM_OBJ) $(LIBOBJS)
$(LINK) -o $@ $(NSD_MEM_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS)

cutest: $(CUTEST_OBJ) $(LIBOBJS) popen3_echo
$(LINK) -o $@ $(CUTEST_OBJ) $(LIBOBJS) $(SSL_LIBS) $(LIBS)
cutest: simdzone/libzone.a $(CUTEST_OBJ) $(LIBOBJS) popen3_echo
$(LINK) -o $@ $(CUTEST_OBJ) $(LIBOBJS) simdzone/libzone.a $(SSL_LIBS) $(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)
xfr-inspect: xfr-inspect.o $(COMMON_OBJ) zonec.o $(LIBOBJS)
$(LINK) -o $@ xfr-inspect.o $(COMMON_OBJ) zonec.o $(LIBOBJS) $(LIBS)

popen3_echo: popen3.o popen3_echo.o
$(LINK) -o $@ popen3.o popen3_echo.o
Expand All @@ -195,7 +198,6 @@ distclean: clean

realclean: distclean
rm -rf autom4te*
rm -f zlexer.c zparser.h zparser.c zparser.stamp
rm -f configlexer.c configparser.h configparser.c configparser.stamp

maintainer-clean: realclean
Expand Down Expand Up @@ -326,16 +328,6 @@ cutest.o: $(srcdir)/tpkg/cutest/cutest.c
qtest.o: $(srcdir)/tpkg/cutest/qtest.c
$(COMPILE) -c $(srcdir)/tpkg/cutest/qtest.c

zlexer.c: $(srcdir)/zlexer.lex
if test "$(LEX)" != ":"; then rm -f $@ ;\
echo '#include "config.h"' > $@ ;\
$(LEX) -i -t $(srcdir)/zlexer.lex >> $@ ;\
fi
@if test ! -f $@; then echo "No $@ : need flex and bison to compile from source repository"; exit 1; fi

zparser.c zparser.h: $(srcdir)/zparser.y
$(YACC) -d -o zparser.c $(srcdir)/zparser.y

configlexer.c: $(srcdir)/configlexer.lex
if test "$(LEX)" != ":"; then rm -f $@ ;\
echo '#include "config.h"' > $@ ;\
Expand All @@ -350,10 +342,8 @@ configparser.c configparser.h: $(srcdir)/configparser.y
configlexer.o: configlexer.c config.h configparser.h
configparser.o: configparser.c config.h configparser.h
options.o: $(srcdir)/options.c config.h configparser.h
zlexer.o: zlexer.c config.h zparser.h
zparser.o: zparser.c config.h zparser.h
dns.o: $(srcdir)/dns.c config.h zparser.h
zonec.o: $(srcdir)/zonec.c config.h zparser.h
dns.o: $(srcdir)/dns.c config.h
zonec.o: $(srcdir)/zonec.c config.h

# dnstap
dnstap.o: $(srcdir)/dnstap/dnstap.c config.h dnstap/dnstap_config.h \
Expand Down Expand Up @@ -396,9 +386,6 @@ depend:
-e 's?$$(srcdir)/dnstap/dnstap_config.h??g' \
-e 's?$$(srcdir)/dnstap/dnstap.pb-c.c?dnstap/dnstap.pb-c.c?g' \
-e 's?$$(srcdir)/dnstap/dnstap.pb-c.h?dnstap/dnstap.pb-c.h?g' \
-e 's?$$(srcdir)/zlexer.c?zlexer.c?g' \
-e 's?$$(srcdir)/zparser.c?zparser.c?g' \
-e 's?$$(srcdir)/zparser.h?zparser.h?g' \
> $(DEPEND_TMP)
cp $(DEPEND_TARGET) $(DEPEND_TMP2)
head -`$(EGREP) -n "# Dependencies" $(DEPEND_TARGET) | tail -1 | $(SED) -e 's/:.*$$//'` $(DEPEND_TMP2) > $(DEPEND_TARGET)
Expand Down Expand Up @@ -444,7 +431,7 @@ dname.o: $(srcdir)/dname.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dns.h $(
$(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/query.h $(srcdir)/namedb.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/nsd.h \
$(srcdir)/edns.h $(srcdir)/bitset.h $(srcdir)/packet.h $(srcdir)/tsig.h
dns.o: $(srcdir)/dns.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dns.h $(srcdir)/zonec.h $(srcdir)/namedb.h $(srcdir)/dname.h \
$(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/radtree.h $(srcdir)/rbtree.h zparser.h
$(srcdir)/buffer.h $(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/radtree.h $(srcdir)/rbtree.h
edns.o: $(srcdir)/edns.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dns.h $(srcdir)/edns.h $(srcdir)/buffer.h \
$(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/nsd.h $(srcdir)/bitset.h $(srcdir)/query.h $(srcdir)/namedb.h $(srcdir)/dname.h \
$(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/packet.h $(srcdir)/tsig.h
Expand Down Expand Up @@ -551,14 +538,9 @@ xfrd-tcp.o: $(srcdir)/xfrd-tcp.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/ns
xfr-inspect.o: $(srcdir)/xfr-inspect.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/util.h $(srcdir)/buffer.h \
$(srcdir)/region-allocator.h $(srcdir)/packet.h $(srcdir)/dns.h $(srcdir)/namedb.h $(srcdir)/dname.h $(srcdir)/radtree.h $(srcdir)/rbtree.h \
$(srcdir)/rdata.h $(srcdir)/difffile.h $(srcdir)/options.h $(srcdir)/udb.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
zonec.o: $(srcdir)/zonec.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 $(srcdir)/rdata.h \
zparser.h $(srcdir)/options.h $(srcdir)/nsec3.h
zparser.o: zparser.c config.h $(srcdir)/compat/cpuset.h $(srcdir)/dname.h $(srcdir)/buffer.h \
$(srcdir)/region-allocator.h $(srcdir)/util.h $(srcdir)/namedb.h $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h $(srcdir)/zonec.h \
zparser.h
$(srcdir)/options.h $(srcdir)/nsec3.h
b64_ntop.o: $(srcdir)/compat/b64_ntop.c config.h $(srcdir)/compat/cpuset.h
b64_pton.o: $(srcdir)/compat/b64_pton.c config.h $(srcdir)/compat/cpuset.h
basename.o: $(srcdir)/compat/basename.c
Expand Down
2 changes: 1 addition & 1 deletion buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ buffer_create(region_type *region, size_t capacity)
}

void
buffer_create_from(buffer_type *buffer, void *data, size_t size)
buffer_create_from(buffer_type *buffer, const void *data, size_t size)
{
assert(data);

Expand Down
2 changes: 1 addition & 1 deletion buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ buffer_type *buffer_create(region_type *region, size_t capacity);
* and no memory allocations are done. The buffer is fixed and cannot
* be resized using buffer_reserve().
*/
void buffer_create_from(buffer_type *buffer, void *data, size_t size);
void buffer_create_from(buffer_type *buffer, const void *data, size_t size);

/*
* Clear the buffer and make it ready for writing. The buffer's limit
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1399,4 +1399,5 @@ if test "$enable_checking" = "yes"; then
fi

AC_CONFIG_FILES([Makefile $dnstap_config])
AC_CONFIG_SUBDIRS([simdzone])
AC_OUTPUT
5 changes: 1 addition & 4 deletions dbaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void
namedb_close(struct namedb* db)
{
if(db) {
zonec_desetup_parser();
region_destroy(db->region);
}
}
Expand Down Expand Up @@ -155,7 +154,6 @@ namedb_open (struct nsd_options* opt)
db->zonetree = radix_tree_create(db->region);
db->diff_skip = 0;
db->diff_pos = 0;
zonec_setup_parser(db);

if (gettimeofday(&(db->diff_timestamp), NULL) != 0) {
log_msg(LOG_ERR, "unable to load namedb: cannot initialize timestamp");
Expand Down Expand Up @@ -254,14 +252,13 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb,
}
}

assert(parser);
/* wipe zone from memory */
#ifdef NSEC3
nsec3_clear_precompile(nsd->db, zone);
zone->nsec3_param = NULL;
#endif
delete_zone_rrs(nsd->db, zone);
errors = zonec_read(zone->opts->name, fname, zone);
errors = zonec_read(nsd->db, nsd->db->domains, zone->opts->name, fname, zone);
if(errors > 0) {
log_msg(LOG_ERR, "zone %s file %s read with %u errors",
zone->opts->name, fname, errors);
Expand Down
Loading

0 comments on commit 6c73e68

Please sign in to comment.