summaryrefslogtreecommitdiff
path: root/external/mpl/bind
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2021-08-19 11:50:14 +0000
committerchristos <christos@NetBSD.org>2021-08-19 11:50:14 +0000
commitfadf07584fd551f5e272ec53cbbaefc998d87613 (patch)
tree54b0629449e681f5e3b23d7f4c5c22ea34e5adf9 /external/mpl/bind
parentb9eb1a827076e1b46036f208d07d8fcd18b7fd22 (diff)
Merge changes between bind 9.16.15 and 9.16.20 and restore dns client APIs
needed by dhcpd.
Diffstat (limited to 'external/mpl/bind')
-rw-r--r--external/mpl/bind/Makefile.inc8
-rw-r--r--external/mpl/bind/dist/Makefile.in4
-rw-r--r--external/mpl/bind/dist/bin/delv/delv.c19
-rw-r--r--external/mpl/bind/dist/bin/dig/dighost.c59
-rw-r--r--external/mpl/bind/dist/bin/dig/host.c7
-rw-r--r--external/mpl/bind/dist/bin/dnssec/dnssec-signzone.c41
-rw-r--r--external/mpl/bind/dist/bin/dnssec/dnssectool.c4
-rw-r--r--external/mpl/bind/dist/bin/named/config.c45
-rw-r--r--external/mpl/bind/dist/bin/named/controlconf.c6
-rw-r--r--external/mpl/bind/dist/bin/named/include/named/config.h11
-rw-r--r--external/mpl/bind/dist/bin/named/main.c70
-rw-r--r--external/mpl/bind/dist/bin/named/server.c197
-rw-r--r--external/mpl/bind/dist/bin/named/unix/os.c4
-rw-r--r--external/mpl/bind/dist/bin/named/zoneconf.c101
-rw-r--r--external/mpl/bind/dist/bin/nsupdate/nsupdate.c55
-rw-r--r--external/mpl/bind/dist/bin/rndc/rndc.c8
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/adb_test.c45
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/byaddr_test.c34
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/byname_test.c32
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/gsstest.c40
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/ratelimiter_test.c8
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/shutdown_test.c28
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/sig0_test.c36
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/sock_test.c46
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/task_test.c20
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/timer_test.c18
-rw-r--r--external/mpl/bind/dist/bin/tests/optional/zone_test.c8
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp1.conf22
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp5.conf22
-rwxr-xr-xexternal/mpl/bind/dist/bin/tests/system/checkds/dig.bat32
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/dig.pl39
-rwxr-xr-xexternal/mpl/bind/dist/bin/tests/system/checkds/dig.sh22
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/missing.example.dnskey.db3
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/missing.example.ds.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/none.example.dnskey.db3
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/none.example.ds.db0
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/ok.example.dnskey.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/ok.example.ds.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/prep.example.db121
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/prep.example.ds.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/tests.sh115
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.dnskey.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.ds.db2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/dyndb/driver/driver.c9
-rw-r--r--external/mpl/bind/dist/bin/tests/system/nsupdate/ns8/dns.keytabbin166 -> 0 bytes
-rw-r--r--external/mpl/bind/dist/bin/tests/system/pipelined/pipequeries.c57
-rw-r--r--external/mpl/bind/dist/bin/tests/system/resolve.c2
-rw-r--r--external/mpl/bind/dist/bin/tests/system/serve-stale/ns3/named.conf.in37
-rw-r--r--external/mpl/bind/dist/bin/tests/system/tkey/keycreate.c67
-rw-r--r--external/mpl/bind/dist/bin/tests/system/tkey/keydelete.c66
-rw-r--r--external/mpl/bind/dist/bin/tools/mdig.c76
-rw-r--r--external/mpl/bind/dist/bin/tools/named-journalprint.c19
-rw-r--r--external/mpl/bind/dist/config.h.in33
-rwxr-xr-xexternal/mpl/bind/dist/configure391
-rw-r--r--external/mpl/bind/dist/lib/bind9/check.c277
-rw-r--r--external/mpl/bind/dist/lib/dns/cache.c5
-rw-r--r--external/mpl/bind/dist/lib/dns/client.c106
-rw-r--r--external/mpl/bind/dist/lib/dns/dnssec.c82
-rw-r--r--external/mpl/bind/dist/lib/dns/dst_api.c201
-rw-r--r--external/mpl/bind/dist/lib/dns/dst_internal.h3
-rw-r--r--external/mpl/bind/dist/lib/dns/dst_parse.c4
-rw-r--r--external/mpl/bind/dist/lib/dns/dyndb.c13
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/client.h15
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/db.h11
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/diff.h9
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/dyndb.h4
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/events.h3
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/keymgr.h10
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/masterdump.h34
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/message.h25
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/name.h27
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/nsec3.h19
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/rdata.h4
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/rdataset.h10
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/rpz.h11
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dns/zone.h200
-rw-r--r--external/mpl/bind/dist/lib/dns/include/dst/dst.h15
-rw-r--r--external/mpl/bind/dist/lib/dns/journal.c282
-rw-r--r--external/mpl/bind/dist/lib/dns/keymgr.c159
-rw-r--r--external/mpl/bind/dist/lib/dns/masterdump.c210
-rw-r--r--external/mpl/bind/dist/lib/dns/message.c168
-rw-r--r--external/mpl/bind/dist/lib/dns/name.c11
-rw-r--r--external/mpl/bind/dist/lib/dns/nsec3.c84
-rw-r--r--external/mpl/bind/dist/lib/dns/openssl_link.c3
-rw-r--r--external/mpl/bind/dist/lib/dns/rbt.c31
-rw-r--r--external/mpl/bind/dist/lib/dns/rbtdb.c235
-rw-r--r--external/mpl/bind/dist/lib/dns/rcode.c6
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata.c27
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/avc_258.c28
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/cdnskey_60.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/cds_59.c15
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/dlv_32769.c15
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/dnskey_48.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c15
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c20
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c28
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/rkey_57.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c15
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c28
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c14
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/txt_16.c15
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/x25_19.c7
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.c73
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.h9
-rw-r--r--external/mpl/bind/dist/lib/dns/rdata/in_1/atma_34.c6
-rw-r--r--external/mpl/bind/dist/lib/dns/resolver.c3
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/db_test.c9
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/dnstest.c25
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/nsec3_test.c11
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/rbtdb_test.c2
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/rdata_test.c202
-rw-r--r--external/mpl/bind/dist/lib/dns/tests/update_test.c39
-rw-r--r--external/mpl/bind/dist/lib/dns/tkey.c24
-rw-r--r--external/mpl/bind/dist/lib/dns/tsig.c11
-rw-r--r--external/mpl/bind/dist/lib/dns/update.c36
-rw-r--r--external/mpl/bind/dist/lib/dns/validator.c38
-rw-r--r--external/mpl/bind/dist/lib/dns/xfrin.c30
-rw-r--r--external/mpl/bind/dist/lib/dns/zone.c2550
-rw-r--r--external/mpl/bind/dist/lib/dns/zoneverify.c24
-rw-r--r--external/mpl/bind/dist/lib/irs/context.c43
-rw-r--r--external/mpl/bind/dist/lib/irs/getnameinfo.c7
-rw-r--r--external/mpl/bind/dist/lib/isc/app.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/app.h13
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/barrier.h2
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/managers.h2
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/mem.h49
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/netmgr.h115
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/result.h7
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/socket.h46
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/task.h201
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/taskpool.h19
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/timer.h40
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/tls.h50
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/types.h33
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/url.h2
-rw-r--r--external/mpl/bind/dist/lib/isc/include/isc/util.h73
-rw-r--r--external/mpl/bind/dist/lib/isc/lib.c7
-rw-r--r--external/mpl/bind/dist/lib/isc/managers.c2
-rw-r--r--external/mpl/bind/dist/lib/isc/mem.c36
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h320
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/netmgr.c1070
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/tcp.c515
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/tcpdns.c375
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/tlsdns.c1938
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/udp.c367
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/uv-compat.c10
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/uv-compat.h58
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr/uverr2result.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/netmgr_p.h2
-rw-r--r--external/mpl/bind/dist/lib/isc/result.c150
-rw-r--r--external/mpl/bind/dist/lib/isc/rwlock.c9
-rw-r--r--external/mpl/bind/dist/lib/isc/stats.c6
-rw-r--r--external/mpl/bind/dist/lib/isc/task.c1224
-rw-r--r--external/mpl/bind/dist/lib/isc/task_p.h100
-rw-r--r--external/mpl/bind/dist/lib/isc/taskpool.c31
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/isctest.c31
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/netmgr_test.c2
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/quota_test.c6
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/task_test.c123
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/taskpool_test.c45
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/tcp_quota_test.c738
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/tcp_test.c1050
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/tcpdns_test.c877
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/timer_test.c94
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/tlsdns_test.c899
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/udp_test.c894
-rw-r--r--external/mpl/bind/dist/lib/isc/tests/uv_wrap.h20
-rw-r--r--external/mpl/bind/dist/lib/isc/timer.c123
-rw-r--r--external/mpl/bind/dist/lib/isc/tls.c2
-rw-r--r--external/mpl/bind/dist/lib/isc/tm.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/trampoline_p.h2
-rw-r--r--external/mpl/bind/dist/lib/isc/unix/dir.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h6
-rw-r--r--external/mpl/bind/dist/lib/isc/unix/socket.c423
-rw-r--r--external/mpl/bind/dist/lib/isc/url.c2
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/DLLMain.c3
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/dir.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/file.c4
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/include/isc/time.h34
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/socket.c23
-rw-r--r--external/mpl/bind/dist/lib/isc/win32/time.c106
-rw-r--r--external/mpl/bind/dist/lib/isccfg/kaspconf.c16
-rw-r--r--external/mpl/bind/dist/lib/isccfg/namedconf.c58
-rw-r--r--external/mpl/bind/dist/lib/ns/client.c128
-rw-r--r--external/mpl/bind/dist/lib/ns/include/ns/query.h41
-rw-r--r--external/mpl/bind/dist/lib/ns/interfacemgr.c13
-rw-r--r--external/mpl/bind/dist/lib/ns/query.c134
-rw-r--r--external/mpl/bind/dist/lib/ns/tests/nstest.c40
-rw-r--r--external/mpl/bind/dist/lib/ns/update.c11
-rw-r--r--external/mpl/bind/dist/lib/ns/xfrout.c4
-rw-r--r--external/mpl/bind/dist/lib/samples/Makefile-postinstall.in66
-rw-r--r--external/mpl/bind/dist/lib/samples/Makefile.in86
-rw-r--r--external/mpl/bind/dist/lib/samples/nsprobe.c1235
-rw-r--r--external/mpl/bind/dist/lib/samples/resolve.c498
-rw-r--r--external/mpl/bind/dist/lib/samples/rootkey.sh26
-rw-r--r--external/mpl/bind/dist/lib/samples/sample-async.c411
-rw-r--r--external/mpl/bind/dist/lib/samples/sample-gai.c73
-rw-r--r--external/mpl/bind/dist/lib/samples/sample-request.c250
-rw-r--r--external/mpl/bind/dist/lib/samples/sample-update.c782
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/async.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/async.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/async.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/request.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/request.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/request.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/update.vcxproj.filters.in22
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/update.vcxproj.in119
-rw-r--r--external/mpl/bind/dist/lib/samples/win32/update.vcxproj.user3
-rw-r--r--external/mpl/bind/dist/win32utils/libuv.diff27
-rw-r--r--external/mpl/bind/include/config.h35
-rw-r--r--external/mpl/bind/include/dns/rdatastruct.h7
-rw-r--r--external/mpl/bind/include/irs/netdb.h2
-rw-r--r--external/mpl/bind/include/isc/stdatomic.h6
-rw-r--r--external/mpl/bind/lib/libbind9/shlib_version4
-rw-r--r--external/mpl/bind/lib/libdns/shlib_version4
-rw-r--r--external/mpl/bind/lib/libirs/shlib_version4
-rw-r--r--external/mpl/bind/lib/libisc/Makefile6
-rw-r--r--external/mpl/bind/lib/libisc/shlib_version4
-rw-r--r--external/mpl/bind/lib/libisccc/shlib_version4
-rw-r--r--external/mpl/bind/lib/libisccfg/shlib_version4
-rw-r--r--external/mpl/bind/lib/libns/shlib_version4
232 files changed, 7877 insertions, 17187 deletions
diff --git a/external/mpl/bind/Makefile.inc b/external/mpl/bind/Makefile.inc
index 5cc01deafd3..e0c26c1f7a4 100644
--- a/external/mpl/bind/Makefile.inc
+++ b/external/mpl/bind/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.11 2021/04/13 01:15:57 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.12 2021/08/19 11:50:14 christos Exp $
.if !defined(BIND9_MAKEFILE_INC)
BIND9_MAKEFILE_INC=yes
@@ -72,16 +72,16 @@ DBG=-g3 -gstabs
LDADD+= -lbind9_g -lisccfg_g -ldns_g -lns_g -lirs_g
LDADD+= -lisccc_g -lisc_g
LDADD+= -L${LIBUVOBJDIR} -luv_g
-LDADD+= -lkvm_g -lz_g
+LDADD+= -lexecinfo_g -lkvm_g -lz_g
.else
LDADD+= -lbind9 -lisccfg -ldns -lns -lirs
DPADD+= ${LIBBIND9} ${LIBISCCFG} ${LIBDNS} ${LIBNS} ${LIBIRS}
LDADD+= -lisccc -lisc
LDADD+= -L${LIBUVOBJDIR} -luv
-LDADD+= -lkvm -lz
+LDADD+= -lexecinfo -lkvm -lz
DPADD+= ${LIBISCCC} ${LIBISC}
DPADD+= ${LIBUVOBJDIR}/libuv.a
-DPADD+= ${LIBKVM} ${LIBZ}
+DPADD+= ${LIBEXECINFO} ${LIBKVM} ${LIBZ}
.endif
.else
CPPFLAGS+= -DLIBINTERFACE=${LIBINTERFACE} \
diff --git a/external/mpl/bind/dist/Makefile.in b/external/mpl/bind/dist/Makefile.in
index fbaeaa06a1c..0b0cca2f528 100644
--- a/external/mpl/bind/dist/Makefile.in
+++ b/external/mpl/bind/dist/Makefile.in
@@ -48,9 +48,7 @@ docclean manclean maintainer-clean::
doc man:: ${MANOBJS}
installdirs:
- $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir} \
- ${DESTDIR}${localstatedir}/run ${DESTDIR}${sysconfdir}
- $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
+ $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sysconfdir}
install:: installdirs
${INSTALL_DATA} ${top_srcdir}/bind.keys ${DESTDIR}${sysconfdir}
diff --git a/external/mpl/bind/dist/bin/delv/delv.c b/external/mpl/bind/dist/bin/delv/delv.c
index e249653a13b..fe32ee279bf 100644
--- a/external/mpl/bind/dist/bin/delv/delv.c
+++ b/external/mpl/bind/dist/bin/delv/delv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: delv.c,v 1.9 2021/04/05 11:27:00 rillig Exp $ */
+/* $NetBSD: delv.c,v 1.10 2021/08/19 11:50:14 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -35,6 +35,7 @@
#include <isc/hex.h>
#include <isc/lib.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/md.h>
#include <isc/mem.h>
#ifdef WIN32
@@ -73,7 +74,6 @@
#include <isccfg/log.h>
#include <isccfg/namedconf.h>
-#include <irs/netdb.h>
#include <irs/resconf.h>
#define CHECK(r) \
@@ -1729,6 +1729,7 @@ main(int argc, char *argv[]) {
dns_namelist_t namelist;
unsigned int resopt, clopt;
isc_appctx_t *actx = NULL;
+ isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
isc_timermgr_t *timermgr = NULL;
@@ -1752,9 +1753,9 @@ main(int argc, char *argv[]) {
isc_mem_create(&mctx);
CHECK(isc_appctx_create(mctx, &actx));
- CHECK(isc_taskmgr_createinctx(mctx, 1, 0, &taskmgr));
- CHECK(isc_socketmgr_createinctx(mctx, &socketmgr));
- CHECK(isc_timermgr_createinctx(mctx, &timermgr));
+ CHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
+ CHECK(isc_socketmgr_create(mctx, &socketmgr));
+ CHECK(isc_timermgr_create(mctx, &timermgr));
parse_args(argc, argv);
@@ -1775,8 +1776,8 @@ main(int argc, char *argv[]) {
/* Create client */
clopt = DNS_CLIENTCREATEOPT_USECACHE;
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr,
- clopt, &client, srcaddr4, srcaddr6);
+ result = dns_client_create(mctx, actx, taskmgr, socketmgr, timermgr,
+ clopt, &client, srcaddr4, srcaddr6);
if (result != ISC_R_SUCCESS) {
delv_log(ISC_LOG_ERROR, "dns_client_create: %s",
isc_result_totext(result));
@@ -1796,7 +1797,7 @@ main(int argc, char *argv[]) {
CHECK(convert_name(&qfn, &query_name, qname));
/* Set up resolution options */
- resopt = DNS_CLIENTRESOPT_ALLOWRUN | DNS_CLIENTRESOPT_NOCDFLAG;
+ resopt = DNS_CLIENTRESOPT_NOCDFLAG;
if (no_sigs) {
resopt |= DNS_CLIENTRESOPT_NODNSSEC;
}
@@ -1859,7 +1860,7 @@ cleanup:
dns_client_destroy(&client);
}
if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
}
if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
diff --git a/external/mpl/bind/dist/bin/dig/dighost.c b/external/mpl/bind/dist/bin/dig/dighost.c
index cb5481065a7..40b650064e5 100644
--- a/external/mpl/bind/dist/bin/dig/dighost.c
+++ b/external/mpl/bind/dist/bin/dig/dighost.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dighost.c,v 1.11 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: dighost.c,v 1.12 2021/08/19 11:50:14 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -43,6 +43,7 @@
#include <isc/hex.h>
#include <isc/lang.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/netaddr.h>
#include <isc/netdb.h>
#include <isc/nonce.h>
@@ -100,6 +101,14 @@
#define NS_IN6ADDRSZ 16
#endif /* if !defined(NS_IN6ADDRSZ) */
+#if HAVE_SETLOCALE
+#define systemlocale(l) (void)setlocale(l, "")
+#define resetlocale(l) (void)setlocale(l, "C")
+#else
+#define systemlocale(l)
+#define resetlocale(l)
+#endif /* HAVE_SETLOCALE */
+
dig_lookuplist_t lookup_list;
dig_serverlist_t server_list;
dig_searchlistlist_t search_list;
@@ -113,6 +122,7 @@ unsigned int timeout = 0;
unsigned int extrabytes;
isc_mem_t *mctx = NULL;
isc_log_t *lctx = NULL;
+isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *global_task = NULL;
isc_timermgr_t *timermgr = NULL;
@@ -1339,11 +1349,6 @@ setup_system(bool ipv4only, bool ipv6only) {
irs_resconf_destroy(&resconf);
-#ifdef HAVE_SETLOCALE
- /* Set locale */
- (void)setlocale(LC_ALL, "");
-#endif /* ifdef HAVE_SETLOCALE */
-
if (keyfile[0] != 0) {
setup_file_key();
} else if (keysecret[0] != 0) {
@@ -1406,8 +1411,8 @@ setup_libs(void) {
isc_log_setdebuglevel(lctx, 0);
- result = isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr);
- check_result(result, "isc_taskmgr_create");
+ result = isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr);
+ check_result(result, "isc_managers_create");
result = isc_task_create(taskmgr, 0, &global_task);
check_result(result, "isc_task_create");
@@ -2055,7 +2060,6 @@ insert_soa(dig_lookup_t *lookup) {
result = dns_message_gettempname(lookup->sendmsg, &soaname);
check_result(result, "dns_message_gettempname");
- dns_name_init(soaname, NULL);
dns_name_clone(lookup->name, soaname);
ISC_LIST_INIT(soaname->list);
ISC_LIST_APPEND(soaname->list, rdataset, link);
@@ -2116,7 +2120,6 @@ setup_lookup(dig_lookup_t *lookup) {
}
result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
check_result(result, "dns_message_gettempname");
- dns_name_init(lookup->name, NULL);
isc_buffer_init(&lookup->namebuf, lookup->name_space,
sizeof(lookup->name_space));
@@ -2160,7 +2163,6 @@ setup_lookup(dig_lookup_t *lookup) {
result = dns_message_gettempname(lookup->sendmsg,
&lookup->oname);
check_result(result, "dns_message_gettempname");
- dns_name_init(lookup->oname, NULL);
/* XXX Helper funct to conv char* to name? */
origin = lookup->origin->origin;
#ifdef HAVE_LIBIDN2
@@ -4353,13 +4355,10 @@ destroy_libs(void) {
debug("freeing task");
isc_task_detach(&global_task);
}
- /*
- * The taskmgr_destroy() call blocks until all events are cleared
- * from the task.
- */
+
if (taskmgr != NULL) {
debug("freeing taskmgr");
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
}
LOCK_LOOKUP;
REQUIRE(sockcount == 0);
@@ -4424,8 +4423,9 @@ destroy_libs(void) {
#ifdef HAVE_LIBIDN2
static isc_result_t
idn_output_filter(isc_buffer_t *buffer, unsigned int used_org) {
- char src[MXNAME], *dst;
+ char src[MXNAME], *dst = NULL;
size_t srclen, dstlen;
+ isc_result_t result = ISC_R_SUCCESS;
/*
* Copy name from 'buffer' to 'src' and terminate it with NULL.
@@ -4433,23 +4433,27 @@ idn_output_filter(isc_buffer_t *buffer, unsigned int used_org) {
srclen = isc_buffer_usedlength(buffer) - used_org;
if (srclen >= sizeof(src)) {
warn("Input name too long to perform IDN conversion");
- return (ISC_R_SUCCESS);
+ goto cleanup;
}
memmove(src, (char *)isc_buffer_base(buffer) + used_org, srclen);
src[srclen] = '\0';
+ systemlocale(LC_ALL);
+
/*
* Convert 'src' to the current locale's character encoding.
*/
idn_ace_to_locale(src, &dst);
+ resetlocale(LC_ALL);
+
/*
* Check whether the converted name will fit back into 'buffer'.
*/
dstlen = strlen(dst);
if (isc_buffer_length(buffer) < used_org + dstlen) {
- idn2_free(dst);
- return (ISC_R_NOSPACE);
+ result = ISC_R_NOSPACE;
+ goto cleanup;
}
/*
@@ -4462,9 +4466,12 @@ idn_output_filter(isc_buffer_t *buffer, unsigned int used_org) {
/*
* Clean up.
*/
- idn2_free(dst);
+cleanup:
+ if (dst != NULL) {
+ idn2_free(dst);
+ }
- return (ISC_R_SUCCESS);
+ return (result);
}
/*%
@@ -4480,6 +4487,8 @@ idn_locale_to_ace(const char *src, char *dst, size_t dstlen) {
char *ascii_src;
int res;
+ systemlocale(LC_ALL);
+
/*
* We trust libidn2 to return an error if 'src' is too large to be a
* valid domain name.
@@ -4500,6 +4509,8 @@ idn_locale_to_ace(const char *src, char *dst, size_t dstlen) {
(void)strlcpy(dst, final_src, dstlen);
idn2_free(ascii_src);
+
+ resetlocale(LC_ALL);
}
/*%
@@ -4514,6 +4525,8 @@ idn_ace_to_locale(const char *src, char **dst) {
char *local_src, *utf8_src;
int res;
+ systemlocale(LC_ALL);
+
/*
* We need to:
*
@@ -4579,5 +4592,7 @@ idn_ace_to_locale(const char *src, char **dst) {
idn2_free(utf8_src);
*dst = local_src;
+
+ resetlocale(LC_ALL);
}
#endif /* HAVE_LIBIDN2 */
diff --git a/external/mpl/bind/dist/bin/dig/host.c b/external/mpl/bind/dist/bin/dig/host.c
index 8fee1db466c..82977ddc089 100644
--- a/external/mpl/bind/dist/bin/dig/host.c
+++ b/external/mpl/bind/dist/bin/dig/host.c
@@ -1,4 +1,4 @@
-/* $NetBSD: host.c,v 1.7 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: host.c,v 1.8 2021/08/19 11:50:14 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,13 +15,10 @@
#include <inttypes.h>
#include <limits.h>
+#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif /* ifdef HAVE_LOCALE_H */
-
#include <isc/app.h>
#include <isc/commandline.h>
#include <isc/netaddr.h>
diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.c b/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.c
index 8de46f7944a..630b449b1a9 100644
--- a/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.c
+++ b/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dnssec-signzone.c,v 1.7 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: dnssec-signzone.c,v 1.8 2021/08/19 11:50:15 christos Exp $ */
/*
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -41,6 +41,7 @@
#include <isc/file.h>
#include <isc/hash.h>
#include <isc/hex.h>
+#include <isc/managers.h>
#include <isc/md.h>
#include <isc/mem.h>
#include <isc/mutex.h>
@@ -125,7 +126,7 @@ struct signer_event {
static dns_dnsseckeylist_t keylist;
static unsigned int keycount = 0;
-isc_rwlock_t keylist_lock;
+static isc_rwlock_t keylist_lock;
static isc_stdtime_t starttime = 0, endtime = 0, dnskey_endtime = 0, now;
static int cycle = -1;
static int jitter = 0;
@@ -145,6 +146,7 @@ static unsigned int nsigned = 0, nretained = 0, ndropped = 0;
static unsigned int nverified = 0, nverifyfailed = 0;
static const char *directory = NULL, *dsdir = NULL;
static isc_mutex_t namelock, statslock;
+static isc_nm_t *netmgr = NULL;
static isc_taskmgr_t *taskmgr = NULL;
static dns_db_t *gdb; /* The database */
static dns_dbversion_t *gversion; /* The database version */
@@ -178,8 +180,9 @@ static bool remove_orphansigs = false;
static bool remove_inactkeysigs = false;
static bool output_dnssec_only = false;
static bool output_stdout = false;
-bool set_maxttl = false;
+static bool set_maxttl = false;
static dns_ttl_t maxttl = 0;
+static bool no_max_check = false;
#define INCSTAT(counter) \
if (printstats) { \
@@ -382,9 +385,9 @@ keythatsigned(dns_rdata_rrsig_t *rrsig) {
dst_key_t *pubkey = NULL, *privkey = NULL;
dns_dnsseckey_t *key = NULL;
- isc_rwlock_lock(&keylist_lock, isc_rwlocktype_read);
+ RWLOCK(&keylist_lock, isc_rwlocktype_read);
key = keythatsigned_unlocked(rrsig);
- isc_rwlock_unlock(&keylist_lock, isc_rwlocktype_read);
+ RWUNLOCK(&keylist_lock, isc_rwlocktype_read);
if (key != NULL) {
return (key);
}
@@ -1335,8 +1338,8 @@ get_soa_ttls(void) {
result = dns_rdataset_first(&soaset);
check_result(result, "dns_rdataset_first");
dns_rdataset_current(&soaset, &rdata);
- zone_soa_min_ttl = dns_soa_getminimum(&rdata);
soa_ttl = soaset.ttl;
+ zone_soa_min_ttl = ISC_MIN(dns_soa_getminimum(&rdata), soa_ttl);
if (set_maxttl) {
zone_soa_min_ttl = ISC_MIN(zone_soa_min_ttl, maxttl);
soa_ttl = ISC_MIN(soa_ttl, maxttl);
@@ -3439,6 +3442,12 @@ main(int argc, char *argv[]) {
case 'H':
set_iter = true;
+ /* too-many is NOT DOCUMENTED */
+ if (strcmp(isc_commandline_argument, "too-many") == 0) {
+ nsec3iter = 151;
+ no_max_check = true;
+ break;
+ }
nsec3iter = strtoul(isc_commandline_argument, &endp, 0);
if (*endp != '\0') {
fatal("iterations must be numeric");
@@ -3857,7 +3866,6 @@ main(int argc, char *argv[]) {
warnifallksk(gdb);
if (IS_NSEC3) {
- unsigned int max;
bool answer;
hash_length = dns_nsec3_hashlength(dns_hash_sha1);
@@ -3876,12 +3884,15 @@ main(int argc, char *argv[]) {
"NSEC-only DNSKEY");
}
- result = dns_nsec3_maxiterations(gdb, NULL, mctx, &max);
- check_result(result, "dns_nsec3_maxiterations()");
- if (nsec3iter > max) {
- fatal("NSEC3 iterations too big for weakest DNSKEY "
- "strength. Maximum iterations allowed %u.",
- max);
+ if (nsec3iter > dns_nsec3_maxiterations()) {
+ if (no_max_check) {
+ fprintf(stderr,
+ "Ignoring max iterations check.\n");
+ } else {
+ fatal("NSEC3 iterations too big. Maximum "
+ "iterations allowed %u.",
+ dns_nsec3_maxiterations());
+ }
}
} else {
hashlist_init(&hashlist, 0, 0); /* silence clang */
@@ -3954,7 +3965,7 @@ main(int argc, char *argv[]) {
print_time(outfp);
print_version(outfp);
- result = isc_taskmgr_create(mctx, ntasks, 0, NULL, &taskmgr);
+ result = isc_managers_create(mctx, ntasks, 0, &netmgr, &taskmgr);
if (result != ISC_R_SUCCESS) {
fatal("failed to create task manager: %s",
isc_result_totext(result));
@@ -4009,7 +4020,7 @@ main(int argc, char *argv[]) {
for (i = 0; i < (int)ntasks; i++) {
isc_task_detach(&tasks[i]);
}
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_mem_put(mctx, tasks, ntasks * sizeof(isc_task_t *));
postsign();
TIME_NOW(&sign_finish);
diff --git a/external/mpl/bind/dist/bin/dnssec/dnssectool.c b/external/mpl/bind/dist/bin/dnssec/dnssectool.c
index ab642e10200..ec65a188ca1 100644
--- a/external/mpl/bind/dist/bin/dnssec/dnssectool.c
+++ b/external/mpl/bind/dist/bin/dnssec/dnssectool.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dnssectool.c,v 1.5 2021/02/19 16:42:10 christos Exp $ */
+/* $NetBSD: dnssectool.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -278,7 +278,7 @@ strtokeystate(const char *str) {
return ((dst_key_state_t)i);
}
}
- fatal("unknown key state");
+ fatal("unknown key state %s", str);
}
isc_stdtime_t
diff --git a/external/mpl/bind/dist/bin/named/config.c b/external/mpl/bind/dist/bin/named/config.c
index b34c07867f0..fe90813107d 100644
--- a/external/mpl/bind/dist/bin/named/config.c
+++ b/external/mpl/bind/dist/bin/named/config.c
@@ -1,4 +1,4 @@
-/* $NetBSD: config.c,v 1.11 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: config.c,v 1.12 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -83,7 +83,7 @@ options {\n\
listen-on-v6 {any;};\n\
# lock-file \"" NAMED_LOCALSTATEDIR "/run/named/named.lock\";\n\
match-mapped-addresses no;\n\
- max-ixfr-ratio 100%;\n\
+ max-ixfr-ratio unlimited;\n\
max-rsa-exponent-size 0; /* no limit */\n\
max-udp-size 1232;\n\
memstatistics-file \"named.memstats\";\n\
@@ -182,6 +182,8 @@ options {\n\
notify-source *;\n\
notify-source-v6 *;\n\
nsec3-test-zone no;\n\
+ parental-source *;\n\
+ parental-source-v6 *;\n\
provide-ixfr true;\n\
qname-minimization relaxed;\n\
query-source address *;\n\
@@ -196,8 +198,8 @@ options {\n\
root-key-sentinel yes;\n\
servfail-ttl 1;\n\
# sortlist <none>\n\
- stale-answer-enable false;\n\
stale-answer-client-timeout off;\n\
+ stale-answer-enable false;\n\
stale-answer-ttl 30; /* 30 seconds */\n\
stale-cache-enable true;\n\
stale-refresh-time 30; /* 30 seconds */\n\
@@ -226,7 +228,7 @@ options {\n\
dnssec-update-mode maintain;\n\
# forward <none>\n\
# forwarders <none>\n\
- inline-signing no;\n\
+# inline-signing no;\n\
ixfr-from-differences false;\n\
# maintain-ixfr-base <obsolete>;\n\
# max-ixfr-log-size <obsolete>\n\
@@ -266,6 +268,7 @@ view \"_bind\" chaos {\n\
recursion no;\n\
notify no;\n\
allow-new-zones no;\n\
+ max-cache-size 2M;\n\
\n\
# Prevent use of this zone in DNS amplified reflection DoS attacks\n\
rate-limit {\n\
@@ -572,8 +575,8 @@ named_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
}
static isc_result_t
-getprimariesdef(const cfg_obj_t *cctx, const char *list, const char *name,
- const cfg_obj_t **ret) {
+getremotesdef(const cfg_obj_t *cctx, const char *list, const char *name,
+ const cfg_obj_t **ret) {
isc_result_t result;
const cfg_obj_t *obj = NULL;
const cfg_listelt_t *elt;
@@ -600,20 +603,26 @@ getprimariesdef(const cfg_obj_t *cctx, const char *list, const char *name,
}
isc_result_t
-named_config_getprimariesdef(const cfg_obj_t *cctx, const char *name,
- const cfg_obj_t **ret) {
+named_config_getremotesdef(const cfg_obj_t *cctx, const char *list,
+ const char *name, const cfg_obj_t **ret) {
isc_result_t result;
- result = getprimariesdef(cctx, "primaries", name, ret);
- if (result != ISC_R_SUCCESS) {
- result = getprimariesdef(cctx, "masters", name, ret);
+ if (strcmp(list, "parental-agents") == 0) {
+ return (getremotesdef(cctx, list, name, ret));
+ } else if (strcmp(list, "primaries") == 0) {
+ result = getremotesdef(cctx, list, name, ret);
+ if (result != ISC_R_SUCCESS) {
+ result = getremotesdef(cctx, "masters", name, ret);
+ }
+ return (result);
}
- return (result);
+ return (ISC_R_NOTFOUND);
}
isc_result_t
-named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
- isc_mem_t *mctx, dns_ipkeylist_t *ipkl) {
+named_config_getipandkeylist(const cfg_obj_t *config, const char *listtype,
+ const cfg_obj_t *list, isc_mem_t *mctx,
+ dns_ipkeylist_t *ipkl) {
uint32_t addrcount = 0, dscpcount = 0, keycount = 0, i = 0;
uint32_t listcount = 0, l = 0, j;
uint32_t stackcount = 0, pushed = 0;
@@ -696,7 +705,7 @@ resume:
isc_buffer_t b;
addr = cfg_tuple_get(cfg_listelt_value(element),
- "primarieselement");
+ "remoteselement");
key = cfg_tuple_get(cfg_listelt_value(element), "key");
if (!cfg_obj_issockaddr(addr)) {
@@ -729,11 +738,11 @@ resume:
continue;
}
list = NULL;
- tresult = named_config_getprimariesdef(config, listname,
- &list);
+ tresult = named_config_getremotesdef(config, listtype,
+ listname, &list);
if (tresult == ISC_R_NOTFOUND) {
cfg_obj_log(addr, named_g_lctx, ISC_LOG_ERROR,
- "primaries \"%s\" not found",
+ "%s \"%s\" not found", listtype,
listname);
result = tresult;
diff --git a/external/mpl/bind/dist/bin/named/controlconf.c b/external/mpl/bind/dist/bin/named/controlconf.c
index 00387c4c22d..4d6458a4537 100644
--- a/external/mpl/bind/dist/bin/named/controlconf.c
+++ b/external/mpl/bind/dist/bin/named/controlconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: controlconf.c,v 1.7 2021/04/05 11:27:00 rillig Exp $ */
+/* $NetBSD: controlconf.c,v 1.8 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -394,10 +394,6 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
break;
}
isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
- if (result != ISCCC_R_BADAUTH) {
- log_invalid(&conn->ccmsg, result);
- goto cleanup;
- }
}
if (key == NULL) {
diff --git a/external/mpl/bind/dist/bin/named/include/named/config.h b/external/mpl/bind/dist/bin/named/include/named/config.h
index 74ac6e61eb8..ddb239ba766 100644
--- a/external/mpl/bind/dist/bin/named/include/named/config.h
+++ b/external/mpl/bind/dist/bin/named/include/named/config.h
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.5 2021/02/19 16:42:10 christos Exp $ */
+/* $NetBSD: config.h,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -61,12 +61,13 @@ named_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
isc_dscp_t **dscpsp, uint32_t count);
isc_result_t
-named_config_getprimariesdef(const cfg_obj_t *cctx, const char *name,
- const cfg_obj_t **ret);
+named_config_getremotesdef(const cfg_obj_t *cctx, const char *list,
+ const char *name, const cfg_obj_t **ret);
isc_result_t
-named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
- isc_mem_t *mctx, dns_ipkeylist_t *ipkl);
+named_config_getipandkeylist(const cfg_obj_t *config, const char *listtype,
+ const cfg_obj_t *list, isc_mem_t *mctx,
+ dns_ipkeylist_t *ipkl);
isc_result_t
named_config_getport(const cfg_obj_t *config, in_port_t *portp);
diff --git a/external/mpl/bind/dist/bin/named/main.c b/external/mpl/bind/dist/bin/named/main.c
index 765fa7c72f1..ca3a28c8a24 100644
--- a/external/mpl/bind/dist/bin/named/main.c
+++ b/external/mpl/bind/dist/bin/named/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.11 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: main.c,v 1.12 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,6 +20,10 @@
#include <string.h>
#include <uv.h>
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#ifdef HAVE_DNSTAP
#include <protobuf-c/protobuf-c.h>
#endif
@@ -32,6 +36,7 @@
#include <isc/hash.h>
#include <isc/hp.h>
#include <isc/httpd.h>
+#include <isc/managers.h>
#include <isc/netmgr.h>
#include <isc/os.h>
#include <isc/platform.h>
@@ -341,11 +346,14 @@ library_unexpected_error(const char *file, int line, const char *format,
static void
usage(void) {
fprintf(stderr, "usage: named [-4|-6] [-c conffile] [-d debuglevel] "
- "[-E engine] [-f|-g]\n"
- " [-n number_of_cpus] [-p port] [-s] "
- "[-S sockets] [-t chrootdir]\n"
- " [-u username] [-U listeners] "
- "[-m {usage|trace|record|size|mctx}]\n"
+ "[-D comment] [-E engine]\n"
+ " [-f|-g] [-L logfile] [-n number_of_cpus] "
+ "[-p port] [-s]\n"
+ " [-S sockets] [-t chrootdir] [-u "
+ "username] [-U listeners]\n"
+ " [-X lockfile] [-m "
+ "{usage|trace|record|size|mctx}]\n"
+ " [-M fill|nofill]\n"
"usage: named [-v|-V]\n");
}
@@ -917,23 +925,11 @@ create_managers(void) {
"using %u UDP listener%s per interface", named_g_udpdisp,
named_g_udpdisp == 1 ? "" : "s");
- /*
- * We have ncpus network threads, ncpus worker threads, ncpus
- * old network threads - make it 4x just to be safe. The memory
- * impact is negligible.
- */
- isc_hp_init(4 * named_g_cpus);
- named_g_nm = isc_nm_start(named_g_mctx, named_g_cpus);
- if (named_g_nm == NULL) {
- UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_nm_start() failed");
- return (ISC_R_UNEXPECTED);
- }
-
- result = isc_taskmgr_create(named_g_mctx, named_g_cpus, 0, named_g_nm,
- &named_g_taskmgr);
+ result = isc_managers_create(named_g_mctx, named_g_cpus, 0, &named_g_nm,
+ &named_g_taskmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_taskmgr_create() failed: %s",
+ "isc_managers_create() failed: %s",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
@@ -968,25 +964,9 @@ create_managers(void) {
static void
destroy_managers(void) {
- /*
- * isc_nm_closedown() closes all active connections, freeing
- * attached clients and other resources and preventing new
- * connections from being established, but it not does not
- * stop all processing or destroy the netmgr yet.
- */
- isc_nm_closedown(named_g_nm);
-
- /*
- * isc_taskmgr_destroy() will block until all tasks have exited.
- */
- isc_taskmgr_destroy(&named_g_taskmgr);
+ isc_managers_destroy(&named_g_nm, &named_g_taskmgr);
isc_timermgr_destroy(&named_g_timermgr);
isc_socketmgr_destroy(&named_g_socketmgr);
-
- /*
- * At this point is safe to destroy the netmgr.
- */
- isc_nm_destroy(&named_g_nm);
}
static void
@@ -1504,6 +1484,20 @@ main(int argc, char *argv[]) {
#endif /* HAVE_LIBXML2 */
/*
+ * Technically, this call is superfluous because on startup of the main
+ * program, the portable "C" locale is selected by default. This
+ * explicit call here is for a reference that the BIND 9 code base is
+ * not locale aware and the locale MUST be set to "C" (or "POSIX") when
+ * calling any BIND 9 library code. If you are calling external
+ * libraries that use locale, such calls must be wrapped into
+ * setlocale(LC_ALL, ""); before the call and setlocale(LC_ALL, "C");
+ * after the call, and no BIND 9 library calls must be made in between.
+ */
+#if HAVE_SETLOCALE
+ setlocale(LC_ALL, "C");
+#endif /* HAVE_SETLOCALE */
+
+ /*
* Record version in core image.
* strings named.core | grep "named version:"
*/
diff --git a/external/mpl/bind/dist/bin/named/server.c b/external/mpl/bind/dist/bin/named/server.c
index 29216dc161a..8f937ee0efc 100644
--- a/external/mpl/bind/dist/bin/named/server.c
+++ b/external/mpl/bind/dist/bin/named/server.c
@@ -1,4 +1,4 @@
-/* $NetBSD: server.c,v 1.16 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: server.c,v 1.17 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -3077,8 +3077,8 @@ configure_catz_zone(dns_view_t *view, const cfg_obj_t *config,
obj = cfg_tuple_get(catz_obj, "default-masters");
if (obj != NULL && cfg_obj_istuple(obj)) {
- result = named_config_getipandkeylist(config, obj, view->mctx,
- &opts->masters);
+ result = named_config_getipandkeylist(
+ config, "primaries", obj, view->mctx, &opts->masters);
}
obj = cfg_tuple_get(catz_obj, "in-memory");
@@ -3883,6 +3883,42 @@ register_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
#endif /* ifdef HAVE_DLOPEN */
/*
+ * Determine if a minimal-sized cache can be used for a given view, according
+ * to 'maps' (implicit defaults, global options, view options) and 'optionmaps'
+ * (global options, view options). This is only allowed for views which have
+ * recursion disabled and do not have "max-cache-size" set explicitly. Using
+ * minimal-sized caches prevents a situation in which all explicitly configured
+ * and built-in views inherit the default "max-cache-size 90%;" setting, which
+ * could lead to memory exhaustion with multiple views configured.
+ */
+static bool
+minimal_cache_allowed(const cfg_obj_t *maps[4],
+ const cfg_obj_t *optionmaps[3]) {
+ const cfg_obj_t *obj;
+
+ /*
+ * Do not use a minimal-sized cache for a view with recursion enabled.
+ */
+ obj = NULL;
+ (void)named_config_get(maps, "recursion", &obj);
+ INSIST(obj != NULL);
+ if (cfg_obj_asboolean(obj)) {
+ return (false);
+ }
+
+ /*
+ * Do not use a minimal-sized cache if a specific size was requested.
+ */
+ obj = NULL;
+ (void)named_config_get(optionmaps, "max-cache-size", &obj);
+ if (obj != NULL) {
+ return (false);
+ }
+
+ return (true);
+}
+
+/*
* Configure 'view' according to 'vconfig', taking defaults from 'config'
* where values are missing in 'vconfig'.
*
@@ -4146,6 +4182,12 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
*/
if (named_g_maxcachesize != 0) {
max_cache_size = named_g_maxcachesize;
+ } else if (minimal_cache_allowed(maps, optionmaps)) {
+ /*
+ * dns_cache_setcachesize() will adjust this to the smallest
+ * allowed value.
+ */
+ max_cache_size = 1;
} else if (cfg_obj_isstring(obj)) {
str = cfg_obj_asstring(obj);
INSIST(strcasecmp(str, "unlimited") == 0);
@@ -8985,7 +9027,7 @@ load_configuration(const char *filename, named_server_t *server,
dns_kasp_detach(&kasp);
}
/*
- * Create the built-in kasp policies ("default", "none").
+ * Create the built-in kasp policies ("default", "insecure").
*/
kasp = NULL;
CHECK(cfg_kasp_fromconfig(NULL, "default", named_g_mctx, named_g_lctx,
@@ -8995,7 +9037,7 @@ load_configuration(const char *filename, named_server_t *server,
dns_kasp_detach(&kasp);
kasp = NULL;
- CHECK(cfg_kasp_fromconfig(NULL, "none", named_g_mctx, named_g_lctx,
+ CHECK(cfg_kasp_fromconfig(NULL, "insecure", named_g_mctx, named_g_lctx,
&kasplist, &kasp));
INSIST(kasp != NULL);
dns_kasp_freeze(kasp);
@@ -9681,8 +9723,9 @@ view_loaded(void *arg) {
static isc_result_t
load_zones(named_server_t *server, bool init, bool reconfig) {
isc_result_t result;
- dns_view_t *view;
- ns_zoneload_t *zl;
+ isc_taskmgr_t *taskmgr = dns_zonemgr_gettaskmgr(server->zonemgr);
+ dns_view_t *view = NULL;
+ ns_zoneload_t *zl = NULL;
zl = isc_mem_get(server->mctx, sizeof(*zl));
zl->server = server;
@@ -9734,19 +9777,28 @@ cleanup:
if (isc_refcount_decrement(&zl->refs) == 1) {
isc_refcount_destroy(&zl->refs);
isc_mem_put(server->mctx, zl, sizeof(*zl));
- } else if (init) {
+ }
+
+ if (init) {
/*
- * Place the task manager into privileged mode. This
- * ensures that after we leave task-exclusive mode, no
- * other tasks will be able to run except for the ones
- * that are loading zones. (This should only be done during
- * the initial server setup; it isn't necessary during
- * a reload.)
+ * If we're setting up the server for the first time, set
+ * the task manager into privileged mode; this ensures
+ * that no other tasks will begin to run until after zone
+ * loading is complete. We won't return from exclusive mode
+ * until the loading is finished; we can then drop out of
+ * privileged mode.
+ *
+ * We do *not* want to do this in the case of reload or
+ * reconfig, as loading a large zone could cause the server
+ * to be inactive for too long a time.
*/
- isc_taskmgr_setprivilegedmode(named_g_taskmgr);
+ isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
+ isc_task_endexclusive(server->task);
+ isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_normal);
+ } else {
+ isc_task_endexclusive(server->task);
}
- isc_task_endexclusive(server->task);
return (result);
}
@@ -10012,7 +10064,7 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
* startup and shutdown of the server, as well as all exclusive
* tasks.
*/
- CHECKFATAL(isc_task_create(named_g_taskmgr, 0, &server->task),
+ CHECKFATAL(isc_task_create_bound(named_g_taskmgr, 0, &server->task, 0),
"creating server task");
isc_task_setname(server->task, "server", server);
isc_taskmgr_setexcltask(named_g_taskmgr, server->task);
@@ -10607,6 +10659,8 @@ named_server_retransfercommand(named_server_t *server, isc_lex_t *lex,
dns_zone_t *raw = NULL;
dns_zonetype_t type;
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &zone, NULL, text, true);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -10654,6 +10708,8 @@ named_server_reloadcommand(named_server_t *server, isc_lex_t *lex,
dns_zonetype_t type;
const char *msg = NULL;
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &zone, NULL, text, true);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -10734,6 +10790,8 @@ named_server_notifycommand(named_server_t *server, isc_lex_t *lex,
dns_zone_t *zone = NULL;
const char msg[] = "zone notify queued";
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &zone, NULL, text, true);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -10762,6 +10820,8 @@ named_server_refreshcommand(named_server_t *server, isc_lex_t *lex,
const char msg2[] = "not a slave, mirror, or stub zone";
dns_zonetype_t type;
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &zone, NULL, text, true);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -11085,7 +11145,7 @@ resume:
";\n; Cache dump of view '%s' (cache %s)\n;\n",
dctx->view->view->name,
dns_cache_getname(dctx->view->view->cache));
- result = dns_master_dumptostreaminc(
+ result = dns_master_dumptostreamasync(
dctx->mctx, dctx->cache, NULL, style, dctx->fp,
dctx->task, dumpdone, dctx, &dctx->mdctx);
if (result == DNS_R_CONTINUE) {
@@ -11145,7 +11205,7 @@ resume:
goto nextzone;
}
dns_db_currentversion(dctx->db, &dctx->version);
- result = dns_master_dumptostreaminc(
+ result = dns_master_dumptostreamasync(
dctx->mctx, dctx->db, dctx->version, style,
dctx->fp, dctx->task, dumpdone, dctx,
&dctx->mdctx);
@@ -11197,6 +11257,8 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
const char *sep;
bool found;
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, NULL);
if (ptr == NULL) {
@@ -11320,6 +11382,8 @@ named_server_dumpsecroots(named_server_t *server, isc_lex_t *lex,
unsigned int used = isc_buffer_usedlength(*text);
bool first = true;
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, text);
if (ptr == NULL) {
@@ -11508,6 +11572,8 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
isc_result_t result;
bool enable = true, set = true, first = true;
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, text);
if (ptr == NULL) {
@@ -11828,6 +11894,8 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
char line[1024], hostname[256];
named_reload_t reload_status;
+ REQUIRE(text != NULL);
+
if (named_g_server->version_set) {
ob = " (";
cb = ")";
@@ -11955,6 +12023,8 @@ named_server_testgen(isc_lex_t *lex, isc_buffer_t **text) {
unsigned long i;
const unsigned char chars[] = "abcdefghijklmnopqrstuvwxyz0123456789";
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, text);
if (ptr == NULL) {
@@ -12050,6 +12120,8 @@ named_server_tsigdelete(named_server_t *server, isc_lex_t *lex,
char target[DNS_NAME_FORMATSIZE];
char fbuf[16];
+ REQUIRE(text != NULL);
+
(void)next_token(lex, text); /* skip command name */
ptr = next_token(lex, text);
@@ -12174,6 +12246,8 @@ named_server_tsiglist(named_server_t *server, isc_buffer_t **text) {
dns_view_t *view;
unsigned int foundkeys = 0;
+ REQUIRE(text != NULL);
+
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
view = ISC_LIST_NEXT(view, link))
{
@@ -12218,6 +12292,8 @@ named_server_rekey(named_server_t *server, isc_lex_t *lex,
bool fullsign = false;
char *ptr;
+ REQUIRE(text != NULL);
+
ptr = next_token(lex, text);
if (ptr == NULL) {
return (ISC_R_UNEXPECTEDEND);
@@ -12227,6 +12303,8 @@ named_server_rekey(named_server_t *server, isc_lex_t *lex,
fullsign = true;
}
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &zone, NULL, text, false);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -12299,6 +12377,8 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
const char *vname, *sep, *arg;
bool cleanup = false;
+ REQUIRE(text != NULL);
+
(void)next_token(lex, text);
arg = next_token(lex, text);
@@ -12308,6 +12388,8 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
arg = next_token(lex, text);
}
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, arg, &zone, NULL, text, false);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -12378,6 +12460,8 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
bool frozen;
const char *msg = NULL;
+ REQUIRE(text != NULL);
+
result = zone_from_args(server, lex, NULL, &mayberaw, NULL, text, true);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -12494,6 +12578,8 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
*/
isc_result_t
named_smf_add_message(isc_buffer_t **text) {
+ REQUIRE(text != NULL);
+
return (putstr(text, "use svcadm(1M) to manage named"));
}
#endif /* HAVE_LIBSCF */
@@ -13348,13 +13434,13 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
#ifndef HAVE_LMDB
FILE *fp = NULL;
bool cleanup_config = false;
-#else /* HAVE_LMDB */
+#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
+ bool locked = false;
UNUSED(zoneconf);
- LOCK(&view->new_zone_lock);
-#endif /* HAVE_LMDB */
+#endif
/* Zone shouldn't already exist */
if (redirect) {
@@ -13374,12 +13460,16 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
goto cleanup;
}
+ result = isc_task_beginexclusive(server->task);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+
#ifndef HAVE_LMDB
/*
* Make sure we can open the configuration save file
*/
result = isc_stdio_open(view->new_zone_file, "a", &fp);
if (result != ISC_R_SUCCESS) {
+ isc_task_endexclusive(server->task);
TCHECK(putstr(text, "unable to create '"));
TCHECK(putstr(text, view->new_zone_file));
TCHECK(putstr(text, "': "));
@@ -13390,9 +13480,12 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
+ LOCK(&view->new_zone_lock);
+ locked = true;
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
+ isc_task_endexclusive(server->task);
TCHECK(putstr(text, "unable to open NZD database for '"));
TCHECK(putstr(text, view->new_zone_db));
TCHECK(putstr(text, "'"));
@@ -13401,9 +13494,6 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
}
#endif /* HAVE_LMDB */
- result = isc_task_beginexclusive(server->task);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
/* Mark view unfrozen and configure zone */
dns_view_thaw(view);
result = configure_zone(cfg->config, zoneobj, cfg->vconfig,
@@ -13507,7 +13597,9 @@ cleanup:
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- UNLOCK(&view->new_zone_lock);
+ if (locked) {
+ UNLOCK(&view->new_zone_lock);
+ }
#endif /* HAVE_LMDB */
if (zone != NULL) {
@@ -13531,7 +13623,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
#else /* HAVE_LMDB */
MDB_txn *txn = NULL;
MDB_dbi dbi;
- LOCK(&view->new_zone_lock);
+ bool locked = false;
#endif /* HAVE_LMDB */
/* Zone must already exist */
@@ -13577,6 +13669,8 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
(void)isc_stdio_close(fp);
fp = NULL;
#else /* HAVE_LMDB */
+ LOCK(&view->new_zone_lock);
+ locked = true;
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
@@ -13729,7 +13823,9 @@ cleanup:
if (txn != NULL) {
(void)nzd_close(&txn, false);
}
- UNLOCK(&view->new_zone_lock);
+ if (locked) {
+ UNLOCK(&view->new_zone_lock);
+ }
#endif /* HAVE_LMDB */
if (zone != NULL) {
@@ -13757,6 +13853,8 @@ named_server_changezone(named_server_t *server, char *command,
dns_fixedname_t fname;
dns_name_t *dnsname;
+ REQUIRE(text != NULL);
+
if (strncasecmp(command, "add", 3) == 0) {
addzone = true;
} else {
@@ -14032,6 +14130,8 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
isc_event_t *dzevent = NULL;
isc_task_t *task = NULL;
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, text);
if (ptr == NULL) {
@@ -14246,6 +14346,8 @@ named_server_showzone(named_server_t *server, isc_lex_t *lex,
bool added, redirect;
ns_dzarg_t dzarg;
+ REQUIRE(text != NULL);
+
/* Parse parameters */
CHECK(zone_from_args(server, lex, NULL, &zone, zonename, text, true));
if (zone == NULL) {
@@ -14381,6 +14483,8 @@ named_server_signing(named_server_t *server, isc_lex_t *lex,
const char *ptr;
size_t n;
+ REQUIRE(text != NULL);
+
dns_rdataset_init(&privset);
/* Skip the command name. */
@@ -14441,7 +14545,8 @@ named_server_signing(named_server_t *server, isc_lex_t *lex,
return (ISC_R_BADNUMBER);
}
- if (hash > 0xffU || flags > 0xffU) {
+ if (hash > 0xffU || flags > 0xffU ||
+ iter > dns_nsec3_maxiterations()) {
return (ISC_R_RANGE);
}
@@ -14481,7 +14586,7 @@ named_server_signing(named_server_t *server, isc_lex_t *lex,
CHECK(ISC_R_UNEXPECTEDEND);
}
- if (dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) != NULL) {
(void)putstr(text, "zone uses dnssec-policy, use rndc dnssec "
"command instead");
(void)putnull(text);
@@ -14607,6 +14712,10 @@ named_server_dnssec(named_server_t *server, isc_lex_t *lex,
isc_stdtime_t now, when;
isc_time_t timenow, timewhen;
const char *dir;
+ dns_db_t *db = NULL;
+ dns_dbversion_t *version = NULL;
+
+ REQUIRE(text != NULL);
/* Skip the command name. */
ptr = next_token(lex, text);
@@ -14738,12 +14847,15 @@ named_server_dnssec(named_server_t *server, isc_lex_t *lex,
/* Get DNSSEC keys. */
dir = dns_zone_getkeydirectory(zone);
+ CHECK(dns_zone_getdb(zone, &db));
+ dns_db_currentversion(db, &version);
LOCK(&kasp->lock);
- result = dns_dnssec_findmatchingkeys(dns_zone_getorigin(zone), dir, now,
- dns_zone_getmctx(zone), &keys);
+ result = dns_zone_getdnsseckeys(zone, db, version, now, &keys);
UNLOCK(&kasp->lock);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
- goto cleanup;
+ if (result != ISC_R_SUCCESS) {
+ if (result != ISC_R_NOTFOUND) {
+ goto cleanup;
+ }
}
if (status) {
@@ -14864,6 +14976,13 @@ cleanup:
(void)putnull(text);
}
+ if (version != NULL) {
+ dns_db_closeversion(db, &version, false);
+ }
+ if (db != NULL) {
+ dns_db_detach(&db);
+ }
+
while (!ISC_LIST_EMPTY(keys)) {
key = ISC_LIST_HEAD(keys);
ISC_LIST_UNLINK(keys, key, link);
@@ -14938,6 +15057,8 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
char **incfiles = NULL;
int nfiles = 0;
+ REQUIRE(text != NULL);
+
isc_time_settoepoch(&loadtime);
isc_time_settoepoch(&refreshtime);
isc_time_settoepoch(&expiretime);
@@ -15204,6 +15325,8 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
dns_rdataclass_t rdclass = dns_rdataclass_in;
bool first = true;
+ REQUIRE(text != NULL);
+
UNUSED(force);
fname = dns_fixedname_initname(&fn);
@@ -15757,6 +15880,8 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
bool found = false;
bool first = true;
+ REQUIRE(text != NULL);
+
/* Skip rndc command name */
cmd = next_token(lex, text);
if (cmd == NULL) {
@@ -15876,6 +16001,8 @@ named_server_dnstap(named_server_t *server, isc_lex_t *lex,
bool reopen = false;
int backups = 0;
+ REQUIRE(text != NULL);
+
if (server->dtenv == NULL) {
return (ISC_R_NOTFOUND);
}
@@ -16030,6 +16157,8 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
isc_result_t result = ISC_R_SUCCESS;
bool exclusive = false;
+ REQUIRE(text != NULL);
+
/* Skip the command name. */
ptr = next_token(lex, text);
if (ptr == NULL) {
diff --git a/external/mpl/bind/dist/bin/named/unix/os.c b/external/mpl/bind/dist/bin/named/unix/os.c
index 58cae8a7c4e..6c90e4baee7 100644
--- a/external/mpl/bind/dist/bin/named/unix/os.c
+++ b/external/mpl/bind/dist/bin/named/unix/os.c
@@ -1,4 +1,4 @@
-/* $NetBSD: os.c,v 1.7 2021/04/05 11:27:00 rillig Exp $ */
+/* $NetBSD: os.c,v 1.8 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -380,7 +380,7 @@ all_digits(const char *s) {
return (false);
}
while (*s != '\0') {
- if (!isdigit((*s) & 0xff)) {
+ if (!isdigit((unsigned char)(*s))) {
return (false);
}
s++;
diff --git a/external/mpl/bind/dist/bin/named/zoneconf.c b/external/mpl/bind/dist/bin/named/zoneconf.c
index 5e12d45685c..4dade86ef91 100644
--- a/external/mpl/bind/dist/bin/named/zoneconf.c
+++ b/external/mpl/bind/dist/bin/named/zoneconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zoneconf.c,v 1.10 2021/04/05 11:27:00 rillig Exp $ */
+/* $NetBSD: zoneconf.c,v 1.11 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1230,15 +1230,23 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
result = named_config_get(maps, "dnssec-policy", &obj);
if (result == ISC_R_SUCCESS) {
kaspname = cfg_obj_asstring(obj);
- result = dns_kasplist_find(kasplist, kaspname, &kasp);
- if (result != ISC_R_SUCCESS) {
- cfg_obj_log(obj, named_g_lctx, ISC_LOG_ERROR,
- "'dnssec-policy '%s' not found ",
- kaspname);
- RETERR(result);
+ if (strcmp(kaspname, "none") != 0) {
+ result = dns_kasplist_find(kasplist, kaspname,
+ &kasp);
+ if (result != ISC_R_SUCCESS) {
+ cfg_obj_log(
+ obj, named_g_lctx,
+ ISC_LOG_ERROR,
+ "dnssec-policy '%s' not found ",
+ kaspname);
+ RETERR(result);
+ }
+ dns_zone_setkasp(zone, kasp);
+ use_kasp = true;
}
- dns_zone_setkasp(zone, kasp);
- use_kasp = dns_zone_use_kasp(zone);
+ }
+ if (!use_kasp) {
+ dns_zone_setkasp(zone, NULL);
}
obj = NULL;
@@ -1281,8 +1289,8 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
dns_ipkeylist_t ipkl;
dns_ipkeylist_init(&ipkl);
- RETERR(named_config_getipandkeylist(config, obj, mctx,
- &ipkl));
+ RETERR(named_config_getipandkeylist(config, "primaries",
+ obj, mctx, &ipkl));
result = dns_zone_setalsonotifydscpkeys(
zone, ipkl.addrs, ipkl.dscps, ipkl.keys,
ipkl.count);
@@ -1293,6 +1301,30 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
}
obj = NULL;
+ result = named_config_get(maps, "parental-source", &obj);
+ INSIST(result == ISC_R_SUCCESS && obj != NULL);
+ RETERR(dns_zone_setparentalsrc4(zone, cfg_obj_assockaddr(obj)));
+ dscp = cfg_obj_getdscp(obj);
+ if (dscp == -1) {
+ dscp = named_g_dscp;
+ }
+ RETERR(dns_zone_setparentalsrc4dscp(zone, dscp));
+ named_add_reserved_dispatch(named_g_server,
+ cfg_obj_assockaddr(obj));
+
+ obj = NULL;
+ result = named_config_get(maps, "parental-source-v6", &obj);
+ INSIST(result == ISC_R_SUCCESS && obj != NULL);
+ RETERR(dns_zone_setparentalsrc6(zone, cfg_obj_assockaddr(obj)));
+ dscp = cfg_obj_getdscp(obj);
+ if (dscp == -1) {
+ dscp = named_g_dscp;
+ }
+ RETERR(dns_zone_setparentalsrc6dscp(zone, dscp));
+ named_add_reserved_dispatch(named_g_server,
+ cfg_obj_assockaddr(obj));
+
+ obj = NULL;
result = named_config_get(maps, "notify-source", &obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
RETERR(dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj)));
@@ -1651,10 +1683,11 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
obj = NULL;
result = cfg_map_get(zoptions, "auto-dnssec", &obj);
- if (kasp != NULL && strcmp(dns_kasp_getname(kasp), "none") != 0)
- {
+ if (kasp != NULL) {
+ bool s2i = (strcmp(dns_kasp_getname(kasp),
+ "insecure") != 0);
dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, true);
- dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, true);
+ dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, !s2i);
dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, true);
} else if (result == ISC_R_SUCCESS) {
const char *arg = cfg_obj_asstring(obj);
@@ -1671,11 +1704,6 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, allow);
dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, false);
dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, maint);
- } else {
- bool s2i = dns_zone_secure_to_insecure(zone, false);
- dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, s2i);
- dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, false);
- dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, s2i);
}
}
@@ -1687,6 +1715,26 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
}
/*%
+ * Configure parental agents, applies to primary and secondary zones.
+ */
+ if (ztype == dns_zone_master || ztype == dns_zone_slave) {
+ obj = NULL;
+ (void)cfg_map_get(zoptions, "parental-agents", &obj);
+ if (obj != NULL) {
+ dns_ipkeylist_t ipkl;
+ dns_ipkeylist_init(&ipkl);
+ RETERR(named_config_getipandkeylist(
+ config, "parental-agents", obj, mctx, &ipkl));
+ result = dns_zone_setparentals(zone, ipkl.addrs,
+ ipkl.keys, ipkl.count);
+ dns_ipkeylist_clear(mctx, &ipkl);
+ RETERR(result);
+ } else {
+ RETERR(dns_zone_setparentals(zone, NULL, NULL, 0));
+ }
+ }
+
+ /*%
* Primary master functionality.
*/
if (ztype == dns_zone_master) {
@@ -1880,8 +1928,8 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
if (obj == NULL && ztype == dns_zone_mirror &&
dns_name_equal(dns_zone_getorigin(zone), dns_rootname))
{
- result = named_config_getprimariesdef(
- named_g_config,
+ result = named_config_getremotesdef(
+ named_g_config, "primaries",
DEFAULT_IANA_ROOT_ZONE_PRIMARIES, &obj);
RETERR(result);
}
@@ -1889,8 +1937,8 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
dns_ipkeylist_t ipkl;
dns_ipkeylist_init(&ipkl);
- RETERR(named_config_getipandkeylist(config, obj, mctx,
- &ipkl));
+ RETERR(named_config_getipandkeylist(config, "primaries",
+ obj, mctx, &ipkl));
result = dns_zone_setprimarieswithkeys(
mayberaw, ipkl.addrs, ipkl.keys, ipkl.count);
count = ipkl.count;
@@ -2194,13 +2242,6 @@ named_zone_inlinesigning(dns_zone_t *zone, const cfg_obj_t *zconfig,
dns_zone_log(zone, ISC_LOG_DEBUG(1),
"inline-signing: "
"implicitly through dnssec-policy");
- } else {
- inline_signing = dns_zone_secure_to_insecure(zone,
- true);
- dns_zone_log(
- zone, ISC_LOG_DEBUG(1), "inline-signing: %s",
- inline_signing ? "transitioning to insecure"
- : "no");
}
}
diff --git a/external/mpl/bind/dist/bin/nsupdate/nsupdate.c b/external/mpl/bind/dist/bin/nsupdate/nsupdate.c
index bfedecc501d..b70724ad40a 100644
--- a/external/mpl/bind/dist/bin/nsupdate/nsupdate.c
+++ b/external/mpl/bind/dist/bin/nsupdate/nsupdate.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nsupdate.c,v 1.9 2021/04/29 17:26:09 christos Exp $ */
+/* $NetBSD: nsupdate.c,v 1.10 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -30,6 +30,7 @@
#include <isc/hash.h>
#include <isc/lex.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/nonce.h>
#include <isc/parseint.h>
@@ -58,6 +59,7 @@
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/name.h>
+#include <dns/nsec3.h>
#include <dns/rcode.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -140,6 +142,7 @@ static bool usegsstsig = false;
static bool use_win2k_gsstsig = false;
static bool tried_other_gsstsig = false;
static bool local_only = false;
+static isc_nm_t *netmgr = NULL;
static isc_taskmgr_t *taskmgr = NULL;
static isc_task_t *global_task = NULL;
static isc_event_t *global_event = NULL;
@@ -941,8 +944,8 @@ setup_system(void) {
result = isc_timermgr_create(gmctx, &timermgr);
check_result(result, "dns_timermgr_create");
- result = isc_taskmgr_create(gmctx, 1, 0, NULL, &taskmgr);
- check_result(result, "isc_taskmgr_create");
+ result = isc_managers_create(gmctx, 1, 0, &netmgr, &taskmgr);
+ check_result(result, "isc_managers_create");
result = isc_task_create(taskmgr, 0, &global_task);
check_result(result, "isc_task_create");
@@ -1281,7 +1284,6 @@ static uint16_t
parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
isc_result_t result;
char *word;
- isc_buffer_t *namebuf = NULL;
isc_buffer_t source;
word = nsu_strsep(cmdlinep, " \t\r\n");
@@ -1292,10 +1294,6 @@ parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
result = dns_message_gettempname(msg, namep);
check_result(result, "dns_message_gettempname");
- isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
- dns_name_init(*namep, NULL);
- dns_name_setbuffer(*namep, namebuf);
- dns_message_takebuffer(msg, &namebuf);
isc_buffer_init(&source, word, strlen(word));
isc_buffer_add(&source, strlen(word));
result = dns_name_fromtext(*namep, &source, dns_rootname, 0, NULL);
@@ -1979,6 +1977,19 @@ parseclass:
}
}
+ if (!isdelete && rdata->type == dns_rdatatype_nsec3param) {
+ dns_rdata_nsec3param_t nsec3param;
+
+ result = dns_rdata_tostruct(rdata, &nsec3param, NULL);
+ check_result(result, "dns_rdata_tostruct");
+ if (nsec3param.iterations > dns_nsec3_maxiterations()) {
+ fprintf(stderr,
+ "NSEC3PARAM has excessive iterations (> %u)\n",
+ dns_nsec3_maxiterations());
+ goto failure;
+ }
+ }
+
doneparsing:
result = dns_message_gettemprdatalist(updatemsg, &rdatalist);
@@ -2077,7 +2088,6 @@ setzone(dns_name_t *zonename) {
if (zonename != NULL) {
result = dns_message_gettempname(updatemsg, &name);
check_result(result, "dns_message_gettempname");
- dns_name_init(name, NULL);
dns_name_clone(zonename, name);
result = dns_message_gettemprdataset(updatemsg, &rdataset);
check_result(result, "dns_message_gettemprdataset");
@@ -2462,6 +2472,10 @@ update_completed(isc_task_t *task, isc_event_t *event) {
check_result(result, "dns_request_getresponse");
}
+ if (answer->opcode != dns_opcode_update) {
+ fatal("invalid OPCODE in response to UPDATE request");
+ }
+
if (answer->rcode != dns_rcode_noerror) {
seenerror = true;
if (!debugging) {
@@ -2651,12 +2665,27 @@ recvsoa(isc_task_t *task, isc_event_t *event) {
return;
}
check_result(result, "dns_request_getresponse");
+
+ if (rcvmsg->rcode == dns_rcode_refused) {
+ next_server("recvsoa", addr, DNS_R_REFUSED);
+ dns_message_detach(&rcvmsg);
+ dns_request_destroy(&request);
+ dns_message_renderreset(soaquery);
+ dns_message_settsigkey(soaquery, NULL);
+ sendrequest(&servers[ns_inuse], soaquery, &request);
+ return;
+ }
+
section = DNS_SECTION_ANSWER;
POST(section);
if (debugging) {
show_message(stderr, rcvmsg, "Reply from SOA query:");
}
+ if (rcvmsg->opcode != dns_opcode_query) {
+ fatal("invalid OPCODE in response to SOA query");
+ }
+
if (rcvmsg->rcode != dns_rcode_noerror &&
rcvmsg->rcode != dns_rcode_nxdomain) {
fatal("response to SOA query was unsuccessful");
@@ -3130,6 +3159,10 @@ recvgss(isc_task_t *task, isc_event_t *event) {
"recvmsg reply from GSS-TSIG query");
}
+ if (rcvmsg->opcode != dns_opcode_query) {
+ fatal("invalid OPCODE in response to GSS-TSIG query");
+ }
+
if (rcvmsg->rcode == dns_rcode_formerr && !tried_other_gsstsig) {
ddebug("recvgss trying %s GSS-TSIG",
use_win2k_gsstsig ? "Standard" : "Win2k");
@@ -3259,7 +3292,6 @@ start_update(void) {
dns_rdataset_makequestion(rdataset, getzoneclass(), dns_rdatatype_soa);
if (userzone != NULL) {
- dns_name_init(name, NULL);
dns_name_clone(userzone, name);
} else {
dns_rdataset_t *tmprdataset;
@@ -3278,7 +3310,6 @@ start_update(void) {
}
firstname = NULL;
dns_message_currentname(updatemsg, section, &firstname);
- dns_name_init(name, NULL);
dns_name_clone(firstname, name);
/*
* Looks to see if the first name references a DS record
@@ -3330,7 +3361,7 @@ cleanup(void) {
}
ddebug("Shutting down task manager");
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
ddebug("Destroying event");
isc_event_free(&global_event);
diff --git a/external/mpl/bind/dist/bin/rndc/rndc.c b/external/mpl/bind/dist/bin/rndc/rndc.c
index 0c444ee8873..ae4ea4bc493 100644
--- a/external/mpl/bind/dist/bin/rndc/rndc.c
+++ b/external/mpl/bind/dist/bin/rndc/rndc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rndc.c,v 1.6 2021/02/19 16:42:11 christos Exp $ */
+/* $NetBSD: rndc.c,v 1.7 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -23,6 +23,7 @@
#include <isc/commandline.h>
#include <isc/file.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/print.h>
@@ -861,6 +862,7 @@ int
main(int argc, char **argv) {
isc_result_t result = ISC_R_SUCCESS;
bool show_final_mem = false;
+ isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *task = NULL;
isc_log_t *log = NULL;
@@ -998,7 +1000,7 @@ main(int argc, char **argv) {
DO("create socket manager",
isc_socketmgr_create(rndc_mctx, &socketmgr));
DO("create task manager",
- isc_taskmgr_create(rndc_mctx, 1, 0, NULL, &taskmgr));
+ isc_managers_create(rndc_mctx, 1, 0, &netmgr, &taskmgr));
DO("create task", isc_task_create(taskmgr, 0, &task));
isc_log_create(rndc_mctx, &log, &logconfig);
@@ -1070,7 +1072,7 @@ main(int argc, char **argv) {
}
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socketmgr_destroy(&socketmgr);
isc_log_destroy(&log);
isc_log_setcontext(NULL);
diff --git a/external/mpl/bind/dist/bin/tests/optional/adb_test.c b/external/mpl/bind/dist/bin/tests/optional/adb_test.c
index cdfbd5e9f2d..94670bdabe3 100644
--- a/external/mpl/bind/dist/bin/tests/optional/adb_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/adb_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: adb_test.c,v 1.5 2021/02/19 16:42:11 christos Exp $ */
+/* $NetBSD: adb_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,6 +20,7 @@
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/hash.h>
+#include <isc/managers.h>
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/task.h>
@@ -43,20 +44,21 @@ struct client {
};
static isc_mem_t *mctx = NULL;
-static isc_mempool_t *cmp;
-static isc_log_t *lctx;
-static isc_logconfig_t *lcfg;
-static isc_taskmgr_t *taskmgr;
-static isc_socketmgr_t *socketmgr;
-static isc_timermgr_t *timermgr;
-static dns_dispatchmgr_t *dispatchmgr;
-static isc_task_t *t1, *t2;
-static dns_view_t *view;
-static dns_db_t *rootdb;
+static isc_mempool_t *cmp = NULL;
+static isc_log_t *lctx = NULL;
+static isc_logconfig_t *lcfg = NULL;
+static isc_nm_t *netmgr = NULL;
+static isc_taskmgr_t *taskmgr = NULL;
+static isc_socketmgr_t *socketmgr = NULL;
+static isc_timermgr_t *timermgr = NULL;
+static dns_dispatchmgr_t *dispatchmgr = NULL;
+static isc_task_t *t1 = NULL, *t2 = NULL;
+static dns_view_t *view = NULL;
+static dns_db_t *rootdb = NULL;
static ISC_LIST(client_t) clients;
static isc_mutex_t client_lock;
static isc_stdtime_t now;
-static dns_adb_t *adb;
+static dns_adb_t *adb = NULL;
static void
check_result(isc_result_t result, const char *format, ...)
@@ -146,39 +148,33 @@ static void
create_managers(void) {
isc_result_t result;
- taskmgr = NULL;
- result = isc_taskmgr_create(mctx, 5, 0, NULL, &taskmgr);
- check_result(result, "isc_taskmgr_create");
+ result = isc_managers_create(mctx, 5, 0, &netmgr, &taskmgr);
+ check_result(result, "isc_managers_create");
- timermgr = NULL;
result = isc_timermgr_create(mctx, &timermgr);
check_result(result, "isc_timermgr_create");
- socketmgr = NULL;
result = isc_socketmgr_create(mctx, &socketmgr);
check_result(result, "isc_socketmgr_create");
- dispatchmgr = NULL;
result = dns_dispatchmgr_create(mctx, &dispatchmgr);
check_result(result, "dns_dispatchmgr_create");
}
static void
create_view(void) {
- dns_cache_t *cache;
+ dns_cache_t *cache = NULL;
isc_result_t result;
/*
* View.
*/
- view = NULL;
result = dns_view_create(mctx, dns_rdataclass_in, "_default", &view);
check_result(result, "dns_view_create");
/*
* Cache.
*/
- cache = NULL;
result = dns_cache_create(mctx, mctx, taskmgr, timermgr,
dns_rdataclass_in, "", "rbt", 0, NULL,
&cache);
@@ -324,10 +320,8 @@ main(int argc, char **argv) {
create_managers();
- t1 = NULL;
result = isc_task_create(taskmgr, 0, &t1);
check_result(result, "isc_task_create t1");
- t2 = NULL;
result = isc_task_create(taskmgr, 0, &t2);
check_result(result, "isc_task_create t2");
@@ -335,6 +329,7 @@ main(int argc, char **argv) {
printf("task 2 = %p\n", t2);
create_view();
+ RUNTIME_CHECK(view != NULL);
adb = view->adb;
@@ -400,8 +395,8 @@ main(int argc, char **argv) {
fprintf(stderr, "Destroying timer manager\n");
isc_timermgr_destroy(&timermgr);
- fprintf(stderr, "Destroying task manager\n");
- isc_taskmgr_destroy(&taskmgr);
+ fprintf(stderr, "Destroying task and network managers\n");
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_log_destroy(&lctx);
diff --git a/external/mpl/bind/dist/bin/tests/optional/byaddr_test.c b/external/mpl/bind/dist/bin/tests/optional/byaddr_test.c
index 5de03c0a34c..f0a2fae4d25 100644
--- a/external/mpl/bind/dist/bin/tests/optional/byaddr_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/byaddr_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: byaddr_test.c,v 1.5 2021/02/19 16:42:11 christos Exp $ */
+/* $NetBSD: byaddr_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -19,6 +19,7 @@
#include <isc/app.h>
#include <isc/commandline.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netaddr.h>
#include <isc/print.h>
@@ -67,18 +68,19 @@ done(isc_task_t *task, isc_event_t *event) {
int
main(int argc, char *argv[]) {
- isc_mem_t *mctx;
+ isc_mem_t *mctx = NULL;
bool verbose = false;
unsigned int workers = 2;
- isc_taskmgr_t *taskmgr;
- isc_task_t *task;
- isc_timermgr_t *timermgr;
- dns_view_t *view;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_task_t *task = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ dns_view_t *view = NULL;
int ch;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
isc_netaddr_t na;
- dns_byaddr_t *byaddr;
+ dns_byaddr_t *byaddr = NULL;
isc_result_t result;
unsigned int options = 0;
dns_cache_t *cache;
@@ -87,7 +89,6 @@ main(int argc, char *argv[]) {
dns_result_register();
- mctx = NULL;
isc_mem_create(&mctx);
while ((ch = isc_commandline_parse(argc, argv, "nvw:")) != -1) {
@@ -112,28 +113,21 @@ main(int argc, char *argv[]) {
printf("IPv6: %s\n", isc_result_totext(isc_net_probeipv6()));
}
- taskmgr = NULL;
- RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &taskmgr) ==
- ISC_R_SUCCESS);
- task = NULL;
+ RUNTIME_CHECK(isc_managers_create(mctx, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
isc_task_setname(task, "byaddr", NULL);
- dispatchmgr = NULL;
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr) ==
ISC_R_SUCCESS);
- timermgr = NULL;
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
- socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
- cache = NULL;
RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr,
dns_rdataclass_in, "", "rbt", 0, NULL,
&cache) == ISC_R_SUCCESS);
- view = NULL;
RUNTIME_CHECK(dns_view_create(mctx, dns_rdataclass_in, "default",
&view) == ISC_R_SUCCESS);
@@ -238,7 +232,7 @@ main(int argc, char *argv[]) {
dns_dispatchmgr_destroy(&dispatchmgr);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socketmgr_destroy(&socketmgr);
isc_timermgr_destroy(&timermgr);
diff --git a/external/mpl/bind/dist/bin/tests/optional/byname_test.c b/external/mpl/bind/dist/bin/tests/optional/byname_test.c
index b28c95add5a..eb053dce0a6 100644
--- a/external/mpl/bind/dist/bin/tests/optional/byname_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/byname_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: byname_test.c,v 1.5 2021/02/19 16:42:11 christos Exp $ */
+/* $NetBSD: byname_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -21,6 +21,7 @@
#include <isc/app.h>
#include <isc/commandline.h>
#include <isc/hash.h>
+#include <isc/managers.h>
#include <isc/netaddr.h>
#include <isc/print.h>
#include <isc/task.h>
@@ -37,14 +38,15 @@
#include <dns/result.h>
static isc_mem_t *mctx = NULL;
-static isc_taskmgr_t *taskmgr;
+static isc_nm_t *netmgr = NULL;
+static isc_taskmgr_t *taskmgr = NULL;
static dns_view_t *view = NULL;
static dns_adbfind_t *find = NULL;
static isc_task_t *task = NULL;
static dns_fixedname_t fixed;
static dns_fixedname_t target;
-static isc_log_t *lctx;
-static isc_logconfig_t *lcfg;
+static isc_log_t *lctx = NULL;
+static isc_logconfig_t *lcfg = NULL;
static unsigned int level = 0;
static void
@@ -191,18 +193,17 @@ int
main(int argc, char *argv[]) {
bool verbose = false;
unsigned int workers = 2;
- isc_timermgr_t *timermgr;
+ isc_timermgr_t *timermgr = NULL;
int ch;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
- dns_cache_t *cache;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_cache_t *cache = NULL;
isc_buffer_t b;
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
dns_result_register();
- mctx = NULL;
isc_mem_create(&mctx);
while ((ch = isc_commandline_parse(argc, argv, "d:vw:")) != -1) {
@@ -227,28 +228,21 @@ main(int argc, char *argv[]) {
printf("IPv6: %s\n", isc_result_totext(isc_net_probeipv6()));
}
- taskmgr = NULL;
- RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &taskmgr) ==
- ISC_R_SUCCESS);
- task = NULL;
+ RUNTIME_CHECK(isc_managers_create(mctx, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
isc_task_setname(task, "byname", NULL);
- dispatchmgr = NULL;
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr) ==
ISC_R_SUCCESS);
- timermgr = NULL;
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
- socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
- cache = NULL;
RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr,
dns_rdataclass_in, "", "rbt", 0, NULL,
&cache) == ISC_R_SUCCESS);
- view = NULL;
RUNTIME_CHECK(dns_view_create(mctx, dns_rdataclass_in, "default",
&view) == ISC_R_SUCCESS);
@@ -338,7 +332,7 @@ main(int argc, char *argv[]) {
dns_dispatchmgr_destroy(&dispatchmgr);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socketmgr_destroy(&socketmgr);
isc_timermgr_destroy(&timermgr);
diff --git a/external/mpl/bind/dist/bin/tests/optional/gsstest.c b/external/mpl/bind/dist/bin/tests/optional/gsstest.c
index 819fdfde215..fd995547bbc 100644
--- a/external/mpl/bind/dist/bin/tests/optional/gsstest.c
+++ b/external/mpl/bind/dist/bin/tests/optional/gsstest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: gsstest.c,v 1.6 2021/04/29 17:26:10 christos Exp $ */
+/* $NetBSD: gsstest.c,v 1.7 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -18,6 +18,7 @@
#include <isc/app.h>
#include <isc/base64.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/sockaddr.h>
@@ -60,11 +61,11 @@
static dns_fixedname_t servername, gssname;
-static isc_mem_t *mctx;
-static dns_requestmgr_t *requestmgr;
+static isc_mem_t *mctx = NULL;
+static dns_requestmgr_t *requestmgr = NULL;
static isc_sockaddr_t address;
-static dns_tsig_keyring_t *ring;
+static dns_tsig_keyring_t *ring = NULL;
static dns_tsigkey_t *tsigkey = NULL;
static dns_gss_ctx_id_t gssctx;
static dns_gss_ctx_id_t *gssctxp = &gssctx;
@@ -430,16 +431,17 @@ setup(void) {
int
main(int argc, char *argv[]) {
- isc_taskmgr_t *taskmgr;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *sock;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *sock = NULL;
unsigned int attrs, attrmask;
isc_sockaddr_t bind_any;
- dns_dispatchmgr_t *dispatchmgr;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
- isc_task_t *task;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
+ isc_task_t *task = NULL;
isc_log_t *lctx = NULL;
isc_logconfig_t *lcfg = NULL;
isc_logdestination_t destination;
@@ -475,38 +477,28 @@ main(int argc, char *argv[]) {
RUNCHECK(dst_lib_init(mctx, NULL));
- taskmgr = NULL;
- RUNCHECK(isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr));
- task = NULL;
+ RUNCHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
isc_sockaddr_any(&bind_any);
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
DNS_DISPATCHATTR_IPV4;
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
- dispatchv4 = NULL;
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
4096, 4, 2, 3, 5, attrs, attrmask,
&dispatchv4));
- requestmgr = NULL;
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
dispatchmgr, dispatchv4, NULL,
&requestmgr));
- ring = NULL;
RUNCHECK(dns_tsigkeyring_create(mctx, &ring));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
dns_view_setkeyring(view, ring);
- sock = NULL;
RUNCHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
&sock));
@@ -529,7 +521,7 @@ main(int argc, char *argv[]) {
isc_timermgr_destroy(&timermgr);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socket_detach(&sock);
isc_socketmgr_destroy(&socketmgr);
diff --git a/external/mpl/bind/dist/bin/tests/optional/ratelimiter_test.c b/external/mpl/bind/dist/bin/tests/optional/ratelimiter_test.c
index a43a4041bf9..df7b63af451 100644
--- a/external/mpl/bind/dist/bin/tests/optional/ratelimiter_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/ratelimiter_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ratelimiter_test.c,v 1.4 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: ratelimiter_test.c,v 1.5 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -12,6 +12,7 @@
*/
#include <isc/app.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/ratelimiter.h>
@@ -21,6 +22,7 @@
#include <isc/util.h>
isc_ratelimiter_t *rlim = NULL;
+isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_timermgr_t *timermgr = NULL;
isc_task_t *g_task = NULL;
@@ -102,7 +104,7 @@ main(int argc, char *argv[]) {
isc_interval_set(&linterval, 1, 0);
isc_mem_create(&mctx);
- RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, NULL, &taskmgr) ==
+ RUNTIME_CHECK(isc_managers_create(mctx, 3, 0, &netmgr, &taskmgr) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) == ISC_R_SUCCESS);
@@ -131,7 +133,7 @@ main(int argc, char *argv[]) {
isc_ratelimiter_detach(&rlim);
isc_timermgr_destroy(&timermgr);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_mem_stats(mctx, stdout);
diff --git a/external/mpl/bind/dist/bin/tests/optional/shutdown_test.c b/external/mpl/bind/dist/bin/tests/optional/shutdown_test.c
index 09316024666..03dea9429bc 100644
--- a/external/mpl/bind/dist/bin/tests/optional/shutdown_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/shutdown_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: shutdown_test.c,v 1.5 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: shutdown_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,6 +16,7 @@
#include <string.h>
#include <isc/app.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/string.h>
@@ -41,7 +42,8 @@ typedef struct {
static t_info tasks[MAX_TASKS];
static unsigned int task_count;
-static isc_taskmgr_t *task_manager;
+static isc_nm_t *netmgr = NULL;
+static isc_taskmgr_t *taskmgr = NULL;
static isc_timermgr_t *timer_manager;
static void
@@ -140,8 +142,7 @@ new_task(isc_mem_t *mctx, const char *name) {
} else {
snprintf(ti->name, sizeof(ti->name), "%u", task_count);
}
- RUNTIME_CHECK(isc_task_create(task_manager, 0, &ti->task) ==
- ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &ti->task) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(ti->task, shutdown_action, ti) ==
ISC_R_SUCCESS);
@@ -159,9 +160,9 @@ new_task(isc_mem_t *mctx, const char *name) {
int
main(int argc, char *argv[]) {
unsigned int workers;
- t_info *t1, *t2;
- isc_task_t *task;
- isc_mem_t *mctx, *mctx2;
+ t_info *t1, *t2 = NULL;
+ isc_task_t *task = NULL;
+ isc_mem_t *mctx = NULL, *mctx2 = NULL;
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
@@ -178,12 +179,10 @@ main(int argc, char *argv[]) {
}
printf("%u workers\n", workers);
- mctx = NULL;
isc_mem_create(&mctx);
- mctx2 = NULL;
isc_mem_create(&mctx2);
- RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL,
- &task_manager) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_managers_create(mctx, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
ISC_R_SUCCESS);
@@ -200,19 +199,18 @@ main(int argc, char *argv[]) {
/*
* Test implicit shutdown.
*/
- task = NULL;
- RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
isc_task_detach(&task);
/*
* Test anti-zombie code.
*/
- RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
isc_task_detach(&task);
RUNTIME_CHECK(isc_app_run() == ISC_R_SUCCESS);
- isc_taskmgr_destroy(&task_manager);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_timermgr_destroy(&timer_manager);
printf("Statistics for mctx:\n");
diff --git a/external/mpl/bind/dist/bin/tests/optional/sig0_test.c b/external/mpl/bind/dist/bin/tests/optional/sig0_test.c
index 5e99ecf5887..b332b7d3012 100644
--- a/external/mpl/bind/dist/bin/tests/optional/sig0_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/sig0_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sig0_test.c,v 1.5 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: sig0_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -21,6 +21,7 @@
#include <isc/commandline.h>
#include <isc/error.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/net.h>
@@ -54,15 +55,16 @@
}
isc_mutex_t lock;
-dst_key_t *key;
-isc_mem_t *mctx;
+dst_key_t *key = NULL;
+isc_mem_t *mctx = NULL;
unsigned char qdata[1024], rdata[1024];
isc_buffer_t qbuffer, rbuffer;
-isc_taskmgr_t *taskmgr;
-isc_task_t *task1;
+isc_nm_t *netmgr = NULL;
+isc_taskmgr_t *taskmgr = NULL;
+isc_task_t *task1 = NULL;
isc_log_t *lctx = NULL;
isc_logconfig_t *logconfig = NULL;
-isc_socket_t *s;
+isc_socket_t *s = NULL;
isc_sockaddr_t address;
char output[10 * 1024];
isc_buffer_t outbuf;
@@ -86,7 +88,7 @@ recvdone(isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
isc_buffer_t source;
isc_result_t result;
- dns_message_t *response;
+ dns_message_t *response = NULL;
REQUIRE(sevent != NULL);
REQUIRE(sevent->ev_type == ISC_SOCKEVENT_RECVDONE);
@@ -101,7 +103,6 @@ recvdone(isc_task_t *task, isc_event_t *event) {
isc_buffer_init(&source, sevent->region.base, sevent->region.length);
isc_buffer_add(&source, sevent->n);
- response = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
result = dns_message_parse(response, &source, 0);
CHECK("dns_message_parse", result);
@@ -124,14 +125,13 @@ buildquery(void) {
dns_rdataset_t *question = NULL;
dns_name_t *qname = NULL;
isc_region_t r, inr;
- dns_message_t *query;
+ dns_message_t *query = NULL;
char nametext[] = "host.example";
isc_buffer_t namesrc, namedst;
unsigned char namedata[256];
isc_sockaddr_t sa;
dns_compress_t cctx;
- query = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
result = dns_message_setsig0key(query, key);
CHECK("dns_message_setsig0key", result);
@@ -192,11 +192,11 @@ buildquery(void) {
int
main(int argc, char *argv[]) {
bool verbose = false;
- isc_socketmgr_t *socketmgr;
- isc_timermgr_t *timermgr;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_timermgr_t *timermgr = NULL;
struct in_addr inaddr;
dns_fixedname_t fname;
- dns_name_t *name;
+ dns_name_t *name = NULL;
isc_buffer_t b;
int ch;
isc_result_t result;
@@ -225,20 +225,15 @@ main(int argc, char *argv[]) {
dns_result_register();
dst_result_register();
- taskmgr = NULL;
- RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, NULL, &taskmgr) ==
+ RUNTIME_CHECK(isc_managers_create(mctx, 2, 0, &netmgr, &taskmgr) ==
ISC_R_SUCCESS);
- task1 = NULL;
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task1) == ISC_R_SUCCESS);
- timermgr = NULL;
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
- socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
isc_log_create(mctx, &lctx, &logconfig);
- s = NULL;
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
&s) == ISC_R_SUCCESS);
@@ -251,7 +246,6 @@ main(int argc, char *argv[]) {
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
CHECK("dns_name_fromtext", result);
- key = NULL;
result = dst_key_fromfile(name, 33180, DNS_KEYALG_RSASHA1,
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, NULL,
mctx, &key);
@@ -263,7 +257,7 @@ main(int argc, char *argv[]) {
isc_task_shutdown(task1);
isc_task_detach(&task1);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socket_detach(&s);
isc_socketmgr_destroy(&socketmgr);
diff --git a/external/mpl/bind/dist/bin/tests/optional/sock_test.c b/external/mpl/bind/dist/bin/tests/optional/sock_test.c
index 76d970baa32..cb009de873f 100644
--- a/external/mpl/bind/dist/bin/tests/optional/sock_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/sock_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sock_test.c,v 1.4 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: sock_test.c,v 1.5 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,6 +15,7 @@
#include <string.h>
#include <unistd.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/socket.h>
@@ -23,8 +24,9 @@
#include <isc/timer.h>
#include <isc/util.h>
-isc_mem_t *mctx;
-isc_taskmgr_t *manager;
+isc_mem_t *mctx = NULL;
+isc_nm_t *netmgr = NULL;
+isc_taskmgr_t *taskmgr = NULL;
static void
my_shutdown(isc_task_t *task, isc_event_t *event) {
@@ -191,10 +193,10 @@ my_connect(isc_task_t *task, isc_event_t *event) {
static void
my_listen(isc_task_t *task, isc_event_t *event) {
char *name = event->ev_arg;
- isc_socket_newconnev_t *dev;
+ isc_socket_newconnev_t *dev = NULL;
isc_region_t region;
- isc_socket_t *oldsock;
- isc_task_t *newtask;
+ isc_socket_t *oldsock = NULL;
+ isc_task_t *newtask = NULL;
dev = (isc_socket_newconnev_t *)event;
@@ -217,8 +219,7 @@ my_listen(isc_task_t *task, isc_event_t *event) {
* Create a new task for this socket, and queue up a
* recv on it.
*/
- newtask = NULL;
- RUNTIME_CHECK(isc_task_create(manager, 0, &newtask) ==
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &newtask) ==
ISC_R_SUCCESS);
isc_socket_recv(dev->newsocket, &region, 1, newtask, my_recv,
event->ev_arg);
@@ -255,14 +256,14 @@ static char xso2[] = "so2";
int
main(int argc, char *argv[]) {
- isc_task_t *t1, *t2;
- isc_timermgr_t *timgr;
+ isc_task_t *t1 = NULL, *t2 = NULL;
+ isc_timermgr_t *timgr = NULL;
isc_time_t expires;
isc_interval_t interval;
- isc_timer_t *ti1;
+ isc_timer_t *ti1 = NULL;
unsigned int workers;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *so1, *so2;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *so1 = NULL, *so2 = NULL;
isc_sockaddr_t sockaddr;
struct in_addr ina;
struct in6_addr in6a;
@@ -291,26 +292,21 @@ main(int argc, char *argv[]) {
/*
* EVERYTHING needs a memory context.
*/
- mctx = NULL;
isc_mem_create(&mctx);
/*
* The task manager is independent (other than memory context)
*/
- manager = NULL;
- RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &manager) ==
- ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_managers_create(mctx, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
/*
* Timer manager depends only on the memory context as well.
*/
- timgr = NULL;
RUNTIME_CHECK(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
- t1 = NULL;
- RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
- t2 = NULL;
- RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t1) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, my_shutdown, one) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t2, my_shutdown, two) ==
@@ -319,13 +315,11 @@ main(int argc, char *argv[]) {
printf("task 1 = %p\n", t1);
printf("task 2 = %p\n", t2);
- socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
/*
* Open up a listener socket.
*/
- so1 = NULL;
if (pf == PF_INET6) {
in6a = in6addr_any;
@@ -347,7 +341,6 @@ main(int argc, char *argv[]) {
ISC_R_SUCCESS);
isc_time_settoepoch(&expires);
isc_interval_set(&interval, 10, 0);
- ti1 = NULL;
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
&interval, t1, timeout, so1,
&ti1) == ISC_R_SUCCESS);
@@ -356,7 +349,6 @@ main(int argc, char *argv[]) {
* Open up a socket that will connect to www.flame.org, port 80.
* Why not. :)
*/
- so2 = NULL;
ina.s_addr = inet_addr("204.152.184.97");
if (0 && pf == PF_INET6) {
isc_sockaddr_v6fromin(&sockaddr, &ina, 80);
@@ -393,7 +385,7 @@ main(int argc, char *argv[]) {
isc_timermgr_destroy(&timgr);
fprintf(stderr, "Destroying task manager\n");
- isc_taskmgr_destroy(&manager);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_mem_stats(mctx, stdout);
isc_mem_destroy(&mctx);
diff --git a/external/mpl/bind/dist/bin/tests/optional/task_test.c b/external/mpl/bind/dist/bin/tests/optional/task_test.c
index 60e1736bb4f..2fd982edf9f 100644
--- a/external/mpl/bind/dist/bin/tests/optional/task_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/task_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: task_test.c,v 1.4 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: task_test.c,v 1.5 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/task.h>
@@ -61,7 +62,8 @@ static char bar[] = "bar";
int
main(int argc, char *argv[]) {
- isc_taskmgr_t *manager = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
isc_task_t *t1 = NULL, *t2 = NULL;
isc_task_t *t3 = NULL, *t4 = NULL;
isc_event_t *event;
@@ -85,13 +87,13 @@ main(int argc, char *argv[]) {
isc_mem_create(&mctx);
- RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &manager) ==
- ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_managers_create(mctx, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t4) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t1) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t2) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t3) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t4) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, my_shutdown, one) ==
ISC_R_SUCCESS);
@@ -195,7 +197,7 @@ main(int argc, char *argv[]) {
isc_timer_detach(&ti1);
isc_timer_detach(&ti2);
isc_timermgr_destroy(&timgr);
- isc_taskmgr_destroy(&manager);
+ isc_managers_destroy(&netmgr, &taskmgr);
printf("destroyed\n");
isc_mem_stats(mctx, stdout);
diff --git a/external/mpl/bind/dist/bin/tests/optional/timer_test.c b/external/mpl/bind/dist/bin/tests/optional/timer_test.c
index 39cdc019942..cb3537a5000 100644
--- a/external/mpl/bind/dist/bin/tests/optional/timer_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/timer_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: timer_test.c,v 1.5 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: timer_test.c,v 1.6 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,6 +15,7 @@
#include <string.h>
#include <unistd.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/task.h>
@@ -95,7 +96,8 @@ static char three[] = "3";
int
main(int argc, char *argv[]) {
- isc_taskmgr_t *manager = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
isc_timermgr_t *timgr = NULL;
unsigned int workers;
isc_time_t expires, now;
@@ -115,13 +117,13 @@ main(int argc, char *argv[]) {
printf("%u workers\n", workers);
isc_mem_create(&mctx1);
- RUNTIME_CHECK(isc_taskmgr_create(mctx1, workers, 0, NULL, &manager) ==
- ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_managers_create(mctx1, workers, 0, &netmgr,
+ &taskmgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx1, &timgr) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t1) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t2) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_task_create(taskmgr, 0, &t3) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, shutdown_task, one) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t2, shutdown_task, two) ==
@@ -171,7 +173,7 @@ main(int argc, char *argv[]) {
Sleep(2000);
#endif /* ifndef WIN32 */
isc_timermgr_destroy(&timgr);
- isc_taskmgr_destroy(&manager);
+ isc_managers_destroy(&netmgr, &taskmgr);
printf("destroyed\n");
printf("Statistics for mctx1:\n");
diff --git a/external/mpl/bind/dist/bin/tests/optional/zone_test.c b/external/mpl/bind/dist/bin/tests/optional/zone_test.c
index b0efea31131..37678312ae5 100644
--- a/external/mpl/bind/dist/bin/tests/optional/zone_test.c
+++ b/external/mpl/bind/dist/bin/tests/optional/zone_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zone_test.c,v 1.6 2021/02/19 16:42:12 christos Exp $ */
+/* $NetBSD: zone_test.c,v 1.7 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,6 +20,7 @@
#include <isc/app.h>
#include <isc/commandline.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/socket.h>
@@ -40,6 +41,7 @@ static int quiet = 0;
static int stats = 0;
static isc_mem_t *mctx = NULL;
dns_zone_t *zone = NULL;
+isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
@@ -287,7 +289,7 @@ main(int argc, char **argv) {
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
isc_mem_create(&mctx);
- RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, NULL, &taskmgr) ==
+ RUNTIME_CHECK(isc_managers_create(mctx, 2, 0, NULL, &taskmgr) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
@@ -304,7 +306,7 @@ main(int argc, char **argv) {
dns_zonemgr_shutdown(zonemgr);
dns_zonemgr_detach(&zonemgr);
isc_socketmgr_destroy(&socketmgr);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_timermgr_destroy(&timermgr);
if (!quiet && stats) {
isc_mem_stats(mctx, stdout);
diff --git a/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp1.conf b/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp1.conf
deleted file mode 100644
index 686160f983c..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp1.conf
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-// Using the keyword 'default' is not allowed.
-dnssec-policy "default" {
- signatures-refresh P5D;
-};
-
-zone "example.net" {
- type master;
- file "example.db";
- dnssec-policy "default";
-};
-
diff --git a/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp5.conf b/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp5.conf
deleted file mode 100644
index a399079db5b..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkconf/bad-kasp5.conf
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-// Using the keyword 'none' is not allowed.
-dnssec-policy "none" {
- signatures-refresh P5D;
-};
-
-zone "example.net" {
- type master;
- file "example.db";
- dnssec-policy "none";
-};
-
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/dig.bat b/external/mpl/bind/dist/bin/tests/system/checkds/dig.bat
deleted file mode 100755
index 9465a460259..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/dig.bat
+++ /dev/null
@@ -1,32 +0,0 @@
-@echo off
-set ext=
-set file=
-
-:loop
-@set arg=%1
-if "%arg%" == "" goto end
-if "%arg:~0,1%" == "+" goto next
-if "%arg%" == "-t" goto next
-if "%arg%" == "ds" goto ds
-if "%arg%" == "DS" goto ds
-if "%arg%" == "dnskey" goto dnskey
-if "%arg%" == "DNSKEY" goto dnskey
-set file=%arg%
-goto next
-
-:ds
-set ext=ds
-goto next
-
-:dnskey
-set ext=dnskey
-goto next
-
-:next
-shift
-goto loop
-
-:end
-
-set name=%file%.%ext%.db
-type %name%
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/dig.pl b/external/mpl/bind/dist/bin/tests/system/checkds/dig.pl
deleted file mode 100644
index c6ae5eb3aef..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/dig.pl
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-my $arg;
-my $ext;
-my $file;
-
-foreach $arg (@ARGV) {
- if ($arg =~ /^\+/) {
- next;
- }
- if ($arg =~ /^-t/) {
- next;
- }
- if ($arg =~ /^ds$/i) {
- $ext = "ds";
- next;
- }
- if ($arg =~ /^dnskey$/i) {
- $ext = "dnskey";
- next;
- }
- $file = $arg;
- next;
-}
-
-open F, $file . "." . $ext . ".db" || die $!;
-while (<F>) {
- print;
-}
-close F;
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/dig.sh b/external/mpl/bind/dist/bin/tests/system/checkds/dig.sh
deleted file mode 100755
index 02b44147817..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/dig.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-while [ "$#" != 0 ]; do
- case $1 in
- +*) shift ;;
- -t) shift ;;
- DS|ds) ext=ds ; shift ;;
- DNSKEY|dnskey) ext=dnskey ; shift ;;
- *) file=$1 ; shift ;;
- esac
-done
-
-cat ${file}.${ext}.db
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.dnskey.db b/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.dnskey.db
deleted file mode 100644
index e372130f1dc..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.dnskey.db
+++ /dev/null
@@ -1,3 +0,0 @@
-missing.example. 3600 IN DNSKEY 257 3 5 AwEAAc6Cz10GXEh5lxA9ujTY/QarTajcUOBwwBYIeldjRsgoouK/UioY FYgxEFL0O5JK6YCRUoGzl3EgLr5GvNyhIp1PZpOpHf7o/4MVOZTGJzm/ sHWP5B+KcYjQOxJiDb433iCmRM4DpHPUUoxw0QbZglzAzl5MfKBoyZud lH59DdT/50bkBg8iVu35EzuW0SYt31k70hxHBSb2wAGWeqxEPKJ1nQiI UcrWNDeem7byrqjPN9wyZhq0XkQ9qbcYxAkRNd8Y7P0FyR1YKJMc6SWZ Ru7muvxqTHgCtJVgxVz4qndCFKdYidiDeKe2/X/z5gf7pyYl3549O8JR tWdNKqutppk=
-missing.example. 3600 IN DNSKEY 257 3 5 BEAAAAOhHQDBrhQbtphgq2wQUpEQ5t4DtUHxoMVFu2hWLDMvoOMRXjG rhhCeFvAZih7yJHf8ZGfW6hd38hXG/xylYCO6Krpbdojwx8YMXLA5/kA +u50WIL8ZR1R6KTbsYVMf/Qx5RiNbPClw+vT+U8eXEJmO20jIS1ULgqy 347cBB1zMnnz/4LJpA0da9CbKj3A254T515sNIMcwsB8/2+2E63/zZrQ zBkj0BrN/9Bexjpiks3jRhZatEsXn3dTy47R09Uix5WcJt+xzqZ7+ysy LKOOedS39Z7SDmsn2eA0FKtQpwA6LXeG2w+jxmw3oA8lVUgEf/rzeC/b ByBNsO70aEFTd
-missing.example. 3600 IN DNSKEY 256 3 5 BQEAAAAB2F1v2HWzCCE9vNsKfk0K8vd4EBwizNT9KO6WYXj0oxEL4eOJ aXbax/BzPFx+3qO8B8pu8E/JjkWH0oaYz4guUyTVmT5Eelg44Vb1kssy q8W27oQ+9qNiP8Jv6zdOj0uCB/N0fxfVL3371xbednFqoECfSFDZa6Hw jU1qzveSsW0=
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.ds.db b/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.ds.db
deleted file mode 100644
index 540ec0bdcbe..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/missing.example.ds.db
+++ /dev/null
@@ -1,2 +0,0 @@
-missing.example. 3600 IN DS 12892 5 2 EF59E5C70BC4153B7DB4C11F9C36B729577DA71474E0A5C9B8875173 6E583200
-missing.example. 3600 IN DS 12892 5 1 9D4CD60491D372207FA584D2EE460CC51D7FF8A7
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/none.example.dnskey.db b/external/mpl/bind/dist/bin/tests/system/checkds/none.example.dnskey.db
deleted file mode 100644
index 76ae905ffd5..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/none.example.dnskey.db
+++ /dev/null
@@ -1,3 +0,0 @@
-none.example. 3600 IN DNSKEY 257 3 5 AwEAAc6Cz10GXEh5lxA9ujTY/QarTajcUOBwwBYIeldjRsgoouK/UioY FYgxEFL0O5JK6YCRUoGzl3EgLr5GvNyhIp1PZpOpHf7o/4MVOZTGJzm/ sHWP5B+KcYjQOxJiDb433iCmRM4DpHPUUoxw0QbZglzAzl5MfKBoyZud lH59DdT/50bkBg8iVu35EzuW0SYt31k70hxHBSb2wAGWeqxEPKJ1nQiI UcrWNDeem7byrqjPN9wyZhq0XkQ9qbcYxAkRNd8Y7P0FyR1YKJMc6SWZ Ru7muvxqTHgCtJVgxVz4qndCFKdYidiDeKe2/X/z5gf7pyYl3549O8JR tWdNKqutppk=
-none.example. 3600 IN DNSKEY 257 3 5 BEAAAAOhHQDBrhQbtphgq2wQUpEQ5t4DtUHxoMVFu2hWLDMvoOMRXjG rhhCeFvAZih7yJHf8ZGfW6hd38hXG/xylYCO6Krpbdojwx8YMXLA5/kA +u50WIL8ZR1R6KTbsYVMf/Qx5RiNbPClw+vT+U8eXEJmO20jIS1ULgqy 347cBB1zMnnz/4LJpA0da9CbKj3A254T515sNIMcwsB8/2+2E63/zZrQ zBkj0BrN/9Bexjpiks3jRhZatEsXn3dTy47R09Uix5WcJt+xzqZ7+ysy LKOOedS39Z7SDmsn2eA0FKtQpwA6LXeG2w+jxmw3oA8lVUgEf/rzeC/b ByBNsO70aEFTd
-none.example. 3600 IN DNSKEY 256 3 5 BQEAAAAB2F1v2HWzCCE9vNsKfk0K8vd4EBwizNT9KO6WYXj0oxEL4eOJ aXbax/BzPFx+3qO8B8pu8E/JjkWH0oaYz4guUyTVmT5Eelg44Vb1kssy q8W27oQ+9qNiP8Jv6zdOj0uCB/N0fxfVL3371xbednFqoECfSFDZa6Hw jU1qzveSsW0=
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/none.example.ds.db b/external/mpl/bind/dist/bin/tests/system/checkds/none.example.ds.db
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/none.example.ds.db
+++ /dev/null
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.dnskey.db b/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.dnskey.db
deleted file mode 100644
index c767c8fc783..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.dnskey.db
+++ /dev/null
@@ -1,2 +0,0 @@
-ok.example. 625 IN DNSKEY 257 3 5 BEAAAAOhHQDBrhQbtphgq2wQUpEQ5t4DtUHxoMVFu2hWLDMvoOMRXjGr hhCeFvAZih7yJHf8ZGfW6hd38hXG/xylYCO6Krpbdojwx8YMXLA5/kA+ u50WIL8ZR1R6KTbsYVMf/Qx5RiNbPClw+vT+U8eXEJmO20jIS1ULgqy3 47cBB1zMnnz/4LJpA0da9CbKj3A254T515sNIMcwsB8/2+2E63/zZrQz Bkj0BrN/9Bexjpiks3jRhZatEsXn3dTy47R09Uix5WcJt+xzqZ7+ysyL KOOedS39Z7SDmsn2eA0FKtQpwA6LXeG2w+jxmw3oA8lVUgEf/rzeC/bB yBNsO70aEFTd
-ok.example. 625 IN DNSKEY 256 3 5 BQEAAAAB2F1v2HWzCCE9vNsKfk0K8vd4EBwizNT9KO6WYXj0oxEL4eOJ aXbax/BzPFx+3qO8B8pu8E/JjkWH0oaYz4guUyTVmT5Eelg44Vb1kssy q8W27oQ+9qNiP8Jv6zdOj0uCB/N0fxfVL3371xbednFqoECfSFDZa6Hw jU1qzveSsW0=
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.ds.db b/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.ds.db
deleted file mode 100644
index 96b159bc9b5..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/ok.example.ds.db
+++ /dev/null
@@ -1,2 +0,0 @@
-ok.example. 3600 IN DS 12892 5 2 26584835CA80C81C91999F31CFAF2A0E89D4FF1C8FAFD0DDB31A85C7 19277C13
-ok.example. 3600 IN DS 12892 5 1 7AA4A3F416C2F2391FB7AB0D434F762CD62D1390
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.db b/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.db
deleted file mode 100644
index 5ba5987cabb..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.db
+++ /dev/null
@@ -1,121 +0,0 @@
-; File written on Thu Oct 5 23:44:34 2017
-; dnssec_signzone version 9.12.0a1
-prep.example. 300 IN SOA ns1.prep.example. hostmaster.prep.example. (
- 1 ; serial
- 2000 ; refresh (33 minutes 20 seconds)
- 2000 ; retry (33 minutes 20 seconds)
- 1814400 ; expire (3 weeks)
- 3600 ; minimum (1 hour)
- )
- 300 RRSIG SOA 8 2 300 (
- 20171105054434 20171006054434 19260 prep.example.
- 1fX0z7Swu4gMPews/ZE8bzNg+JXNedFBDGIH
- PTSfVQtVLIvRWpME+PylX7MdVMZE/PST+x4/
- mWyveyjetEOo7/7aQL236FfI0y6TxQFy7HwC
- FMieqoQCUluuKOvToxg4vUp4GOdlUGbqC63h
- DbX5Z37VptJXLkt4niF4Kl2iD+U9/bk7HAEU
- 4zDiKroYnusGKfVB9xAWddzoHdLxhVuPi7ut
- 328suPdgX0bfs7uB+y4cikhGzAmPpNMlGHju
- qYG74NcFGQNutLB7ayx/m87t7mTty7jbNKm3
- QWJSPf5IR8/kmzAi8HMnapY5vUmm+hX8JOfU
- UtH7i0iEsUqRbEwu5A== )
- 300 NS ns1.prep.example.
- 300 RRSIG NS 8 2 300 (
- 20171105054434 20171006054434 19260 prep.example.
- u5sU2cfqNqIyCLw18ZNnFw28/GyRt0EOiPYS
- dygmpfMDrvDaxjiiai8zWYjnl/E3qzVH9Zku
- 07lEDORZdVb0uCDe1NynjAyw4AHps85cAwVc
- 8HTSbzdVZsQTELpunYFJffh24PDr9unw7KOY
- jzTP6qNedJ1uM54TOr177zfmBh7N2fkAoGyV
- NjvTKrlgDYGNIn8/YMgHb4sNgyfe54MYY00f
- kehVxfKnRCgDsbJ0Pk6jhBMCQWvOh8jG8WyV
- ElAa/eMqlxUC1idF8ydWefjsI/7lPcjSalw9
- qZw4CDCLHHZy0TOSmCYRRZuIeVXzBfDPJyi4
- 2A3iLntKFJ4AOLFMJg== )
- 3600 NSEC ns1.prep.example. NS SOA RRSIG NSEC DNSKEY
- 3600 RRSIG NSEC 8 2 3600 (
- 20171105054434 20171006054434 19260 prep.example.
- Aed99/jdG82YAkKVWjoKOsAGtB3JnyKkCaAq
- zgMrYkXU41y3KDCAmGzooGPQY7NN+WxX7FJ2
- 1nXkgljma/azgpsbi9ssneFtv7PPFClVmN+u
- j+mM4MK/ZR7eJOsMqETg4PAO5VAh6c/GVmyA
- RD/m6EhJVZEjPfLWbDoC4hVAgem7DP/NMjyI
- GfztpDjMmyLQyv6tL+UEXSJHGp3ZEa5Z5i7X
- Nl/bRTUlZs7L4rTgoqHv6LEmsXKAf9rZYq4b
- eP6GF9I1Ry41MfHLc7lPUmtR38ErEsM5uGzw
- trCQYEFhuRWUBxZ8OSL2EZK9rUBXZX+cwK/8
- ZP7mIfDfljkXPQcmow== )
- 3600 DNSKEY 256 3 8 (
- AwEAAfMzj6aZIgZDVcpH1pKOtq998E85+nEY
- YJa0lLS8+QTCC1Efke8GLwsXT0IPTuwnOuXM
- RjySirab0NuEr69T8KP/43YxcRdmCg89mjjN
- szoVPPstC9xBKVOc0pRMDF7sfsTrSye3RY7+
- Z6uZEH5FOAkz2hNbJJHOn4HpNUhLPJGRauhf
- 0evamwUmQ/mlhkVW5q4WmqPCDMNY3K6XtkEm
- cvm8n9ZCXC9Z5AX6KpynujzLdKyxpdGqUk6r
- lavp9ILPpRKoTZDX+2q1pDgP5cDndwtgNSvU
- DBQZoD0psS2cyB3PHo+dPwwpEyM//ZSKsH9m
- e85Ti0413TOWFyFd/jUOUA8=
- ) ; ZSK; alg = RSASHA256 ; key id = 19260
- 3600 DNSKEY 257 3 8 (
- AwEAAbV8X06Qvk350aZ6eZ1d7WbT1H/Y0Sv7
- qAdbk5fbYIKpMvZ8D9xqoTHgD0z0uCgWWIcm
- /xyKBfmax76oLwMBpR/kdtuJz0irgFITnJCH
- pEfR9AJ/Mfm7NyMglq+/39I03E1/LXvpXQLG
- tg+Mo/2CUE5sbG31jmPNK/2J8RMESkIi87fW
- azZU/oyUEtECE5PGbdyw+4PacAsXNjnwl30T
- aatL277wX4pt+IUPdE6EIph3t+dxXJ7OpHgW
- 8g+YSHLlCImLVapdg3oD/cs6ncaBq9z7la5Y
- dHNw2QAIAvQ11EsonrkonPqO6zNVZAVdT2VB
- X5YzGAoCFUvbCvlnl2a7SxM=
- ) ; KSK; alg = RSASHA256 ; key id = 65482
- 3600 RRSIG DNSKEY 8 2 3600 (
- 20171105054434 20171006054434 19260 prep.example.
- pPw81pJ3PeF+tqEswTul9N8Qsl9JKgK4v8SV
- lPfP0pnlMBMbtMFFkx5ZmhQg3Z3U8SdE64Bt
- C5St3qItyyKdTQ0Rbm9mfV6twxDB8lVry8F7
- Pv7gJmmcWzBcbLGcrXIrVNSZhigkemQXTElj
- P8y1j7kaNFWBWbDMn7KesiZ9BiC6sqvuKa3R
- wSofjwXTESspWZP0NtXr5ymaBIMR9UtNj5Wh
- jm1+tg6BxNBKxhCHlSC0ltPS/qq9J1ZUmtJz
- sj/EAFfPVJVuEveebMvi1oDWPTgajO9+EHl4
- ELrgnQHCgaybMzbpd/A5+Tr1hQkv48I8Mb0/
- 8LJ2/6xrvJm64yRteg== )
- 3600 RRSIG DNSKEY 8 2 3600 (
- 20171105054434 20171006054434 65482 prep.example.
- WeIWiC9SnBe2+UocVjpap62O8Rz+iljwJiu9
- VlGUwct3Vydq4/4FVAKdPklXV5cYbBLhO2MB
- 3R4toX8RNU/0Ny8DnugQzLKvVfg0xoyU/UAJ
- k4aWa/vPivSLGouLQPiNp71bdXN4LB/2xmzu
- cPYXzS9ePpwCOp/9JLoNjBSMQkfjfWAcaNtj
- 1DKDmHHL1sPMizninxSJLQOAKb+JwUAjAkOM
- O1JqwkB12/IZuzxN5hly+uNsbFFxPzQkcnJ4
- 5bhzxuh5D/JRXW0nF5aO4aR+9X+lSUpDJQZ1
- 5fOt1cybZCn/ag68RA92zrnisdbrggJGS003
- wn/VKbLVfFj3eQrfNA== )
-ns1.prep.example. 300 IN A 1.1.1.1
- 300 RRSIG A 8 3 300 (
- 20171105054434 20171006054434 19260 prep.example.
- QUyDyJVk3JGEq+VTZtY3firzsRqOA0LUm3Tf
- /fnemQBeOlMda2ErA7DqYVriIGfM8jph416E
- YX8SKAZXGEAlsEbC9cWBVyc5TYH6tZ43sV51
- 55kGTiUY92NnrH10Q+m2SLAEEaKCA/cgBwOR
- tN2Wb1meHgiLbGYN2LbANfDQzoEk4AYAgT6r
- wDKVVg/V9Ed7JnCnBQc9MN9+LQ3h4NBGUiEY
- mr7HX2w+yzqcGFNLI1aFPe2IwFt120QPLyyl
- cZgc6FUBX4YCnWoCb0aFyyOT76AQkKF5YBRn
- gAv6S8q1pZ/0B5w4gjaLEGlts3LG0bxZ1GJd
- gCQMEhgYgyXUchTtZA== )
- 3600 NSEC prep.example. A RRSIG NSEC
- 3600 RRSIG NSEC 8 3 3600 (
- 20171105054434 20171006054434 19260 prep.example.
- rDWN40u1a3DSzWOrS+4YR2XOxaem0BAQ/glN
- QkXNDew1WsZo3fe0IHIhDKlJ/5MJAfAHq8Xs
- A5UGUw2efoNAN/0LuWsI/9IPm4dwQOXiTCly
- uxugXf5islPYyvn1Z14ay/7/2P3W6HZknXzo
- lZFpwqfFZQCxz7c/1aH+2ntAMeqx8LHuewSr
- Rz/sLsSiCcZQ6NMWnZdoC5SGy4CTcIIPPS8z
- 9dQ6QYTC5iq4MKRfyJUyvODyU9be4e6jbo5b
- mjRcov4ttbImhD5jrLAZIfjO6DSazGNVFf/x
- 6rjxjrc8SISPkt2xYwcOlYch9OZuoH86wcZu
- 3Don6yAnLDYDrZylAA== )
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.ds.db b/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.ds.db
deleted file mode 100644
index dddcad64684..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/prep.example.ds.db
+++ /dev/null
@@ -1,2 +0,0 @@
-prep.example. IN DS 65482 8 1 F3673708FBADDEC3EB55933E2E393ACE85EAC2BB
-prep.example. IN DS 65482 8 2 51A7C97AAC42803DA515D1CAFEE28031A5018F6345F12F4B6C1B6D20 02B59820
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/tests.sh b/external/mpl/bind/dist/bin/tests/system/checkds/tests.sh
deleted file mode 100644
index 27e51811e5c..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/tests.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-SYSTEMTESTTOP=..
-. $SYSTEMTESTTOP/conf.sh
-
-if [ "$CYGWIN" ]; then
- DIG=".\dig.bat"
- WINDSFROMKEY=`cygpath -w $DSFROMKEY`
- CHECKDS="$CHECKDS -a sha1 -a sha256 -d $DIG -D $WINDSFROMKEY"
-else
- DIG="./dig.sh"
- CHECKDS="$CHECKDS -a sha1 -a sha256 -d $DIG -D $DSFROMKEY"
-fi
-chmod +x $DIG
-
-status=0
-n=1
-
-echo_i "checking for correct DS, looking up key via 'dig' ($n)"
-ret=0
-$CHECKDS ok.example > checkds.out.$n 2>&1 || ret=1
-grep 'SHA-1' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for correct DS, obtaining key from file ($n)"
-ret=0
-$CHECKDS -f ok.example.dnskey.db ok.example > checkds.out.$n 2>&1 || ret=1
-grep 'SHA-1' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for incorrect DS, looking up key via 'dig' ($n)"
-ret=0
-$CHECKDS wrong.example > checkds.out.$n 2>&1 || ret=1
-grep 'SHA-1' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for incorrect DS, obtaining key from file ($n)"
-ret=0
-$CHECKDS -f wrong.example.dnskey.db wrong.example > checkds.out.$n 2>&1 || ret=1
-grep 'SHA-1' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for partially missing DS, looking up key via 'dig' ($n)"
-ret=0
-$CHECKDS missing.example > checkds.out.$n 2>&1 && ret=1
-grep 'SHA-1.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-1.*missing' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256.*missing' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for partially missing DS, obtaining key from file ($n)"
-ret=0
-$CHECKDS -f missing.example.dnskey.db missing.example > checkds.out.$n 2>&1 && ret=1
-grep 'SHA-1.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-1.*missing' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256.*missing' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for entirely missing DS, looking up key via 'dig' ($n)"
-ret=0
-$CHECKDS none.example > checkds.out.$n 2>&1 && ret=1
-grep 'SHA-1.*found' checkds.out.$n > /dev/null 2>&1 && ret=1
-grep 'SHA-256.*found' checkds.out.$n > /dev/null 2>&1 && ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking for entirely missing DS, obtaining key from file ($n)"
-ret=0
-$CHECKDS -f none.example.dnskey.db none.example > checkds.out.$n 2>&1 && ret=1
-grep 'SHA-1.*found' checkds.out.$n > /dev/null 2>&1 && ret=1
-grep 'SHA-256.*found' checkds.out.$n > /dev/null 2>&1 && ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-echo_i "checking with prepared dsset file ($n)"
-ret=0
-$CHECKDS -f prep.example.db -s prep.example.ds.db prep.example > checkds.out.$n 2>&1 || ret=1
-grep 'SHA-1.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-grep 'SHA-256.*found' checkds.out.$n > /dev/null 2>&1 || ret=1
-n=`expr $n + 1`
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-
-if [ $status = 0 ]; then $SHELL clean.sh; fi
-echo_i "exit status: $status"
-[ $status -eq 0 ] || exit 1
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.dnskey.db b/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.dnskey.db
deleted file mode 100644
index cc5bfd6fa10..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.dnskey.db
+++ /dev/null
@@ -1,2 +0,0 @@
-wrong.example. 3600 IN DNSKEY 257 3 5 AwEAAc6Cz10GXEh5lxA9ujTY/QarTajcUOBwwBYIeldjRsgoouK/UioY FYgxEFL0O5JK6YCRUoGzl3EgLr5GvNyhIp1PZpOpHf7o/4MVOZTGJzm/ sHWP5B+KcYjQOxJiDb433iCmRM4DpHPUUoxw0QbZglzAzl5MfKBoyZud lH59DdT/50bkBg8iVu35EzuW0SYt31k70hxHBSb2wAGWeqxEPKJ1nQiI UcrWNDeem7byrqjPN9wyZhq0XkQ9qbcYxAkRNd8Y7P0FyR1YKJMc6SWZ Ru7muvxqTHgCtJVgxVz4qndCFKdYidiDeKe2/X/z5gf7pyYl3549O8JR tWdNKqutppk=
-wrong.example. 3600 IN DNSKEY 256 3 5 BQEAAAAB2F1v2HWzCCE9vNsKfk0K8vd4EBwizNT9KO6WYXj0oxEL4eOJ aXbax/BzPFx+3qO8B8pu8E/JjkWH0oaYz4guUyTVmT5Eelg44Vb1kssy q8W27oQ+9qNiP8Jv6zdOj0uCB/N0fxfVL3371xbednFqoECfSFDZa6Hw jU1qzveSsW0=
diff --git a/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.ds.db b/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.ds.db
deleted file mode 100644
index d7df6104a21..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/checkds/wrong.example.ds.db
+++ /dev/null
@@ -1,2 +0,0 @@
-wrong.example. 3600 IN DS 1192 5 1 684BB5119673C9272A0A7582AF8576561B5D80EC
-wrong.example. 3600 IN DS 1192 5 2 14E4A873360E512CD2E8C2C331C4472F5EDAB0736669901F4D42E976 3D7B1F5C
diff --git a/external/mpl/bind/dist/bin/tests/system/dyndb/driver/driver.c b/external/mpl/bind/dist/bin/tests/system/dyndb/driver/driver.c
index 35075390740..999e028d624 100644
--- a/external/mpl/bind/dist/bin/tests/system/dyndb/driver/driver.c
+++ b/external/mpl/bind/dist/bin/tests/system/dyndb/driver/driver.c
@@ -1,4 +1,4 @@
-/* $NetBSD: driver.c,v 1.5 2020/05/24 19:46:16 christos Exp $ */
+/* $NetBSD: driver.c,v 1.6 2021/08/19 11:50:16 christos Exp $ */
/*
* Driver API implementation and main entry point for BIND.
@@ -73,13 +73,16 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
/*
* Depending on how dlopen() was called, we may not have
* access to named's global namespace, in which case we need
- * to initialize libisc/libdns
+ * to initialize libisc/libdns. We check this by comparing
+ * the value of isc_mem_debugging to the value passed via
+ * the context object.
*/
- if (dctx->refvar != &isc_bind9) {
+ if (dctx->memdebug != &isc_mem_debugging) {
isc_lib_register();
isc_log_setcontext(dctx->lctx);
dns_log_setcontext(dctx->lctx);
isc_hash_set_initializer(dctx->hashinit);
+ isc_mem_debugging = *(unsigned int *)dctx->memdebug;
}
s = isc_mem_strdup(mctx, parameters);
diff --git a/external/mpl/bind/dist/bin/tests/system/nsupdate/ns8/dns.keytab b/external/mpl/bind/dist/bin/tests/system/nsupdate/ns8/dns.keytab
deleted file mode 100644
index 33400498c93..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/nsupdate/ns8/dns.keytab
+++ /dev/null
Binary files differ
diff --git a/external/mpl/bind/dist/bin/tests/system/pipelined/pipequeries.c b/external/mpl/bind/dist/bin/tests/system/pipelined/pipequeries.c
index be66f229fb1..aaa7ad3d094 100644
--- a/external/mpl/bind/dist/bin/tests/system/pipelined/pipequeries.c
+++ b/external/mpl/bind/dist/bin/tests/system/pipelined/pipequeries.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pipequeries.c,v 1.5 2021/02/19 16:42:13 christos Exp $ */
+/* $NetBSD: pipequeries.c,v 1.6 2021/08/19 11:50:16 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -22,6 +22,7 @@
#include <isc/commandline.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/parseint.h>
@@ -61,8 +62,8 @@
#define PORT 5300
#define TIMEOUT 30
-static isc_mem_t *mctx;
-static dns_requestmgr_t *requestmgr;
+static isc_mem_t *mctx = NULL;
+static dns_requestmgr_t *requestmgr = NULL;
static bool have_src = false;
static isc_sockaddr_t srcaddr;
static isc_sockaddr_t dstaddr;
@@ -72,7 +73,7 @@ static void
recvresponse(isc_task_t *task, isc_event_t *event) {
dns_requestevent_t *reqev = (dns_requestevent_t *)event;
isc_result_t result;
- dns_message_t *query, *response;
+ dns_message_t *query = NULL, *response = NULL;
isc_buffer_t outbuf;
char output[1024];
@@ -88,7 +89,6 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
query = reqev->ev_arg;
- response = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
result = dns_request_getresponse(reqev->request, response,
@@ -128,10 +128,10 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
static isc_result_t
sendquery(isc_task_t *task) {
- dns_request_t *request;
- dns_message_t *message;
- dns_name_t *qname;
- dns_rdataset_t *qrdataset;
+ dns_request_t *request = NULL;
+ dns_message_t *message = NULL;
+ dns_name_t *qname = NULL;
+ dns_rdataset_t *qrdataset = NULL;
isc_result_t result;
dns_fixedname_t queryname;
isc_buffer_t buf;
@@ -152,7 +152,6 @@ sendquery(isc_task_t *task) {
dns_rootname, 0, NULL);
CHECK("dns_name_fromtext", result);
- message = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
message->opcode = dns_opcode_query;
@@ -160,22 +159,18 @@ sendquery(isc_task_t *task) {
message->rdclass = dns_rdataclass_in;
message->id = (unsigned short)(random() & 0xFFFF);
- qname = NULL;
result = dns_message_gettempname(message, &qname);
CHECK("dns_message_gettempname", result);
- qrdataset = NULL;
result = dns_message_gettemprdataset(message, &qrdataset);
CHECK("dns_message_gettemprdataset", result);
- dns_name_init(qname, NULL);
dns_name_clone(dns_fixedname_name(&queryname), qname);
dns_rdataset_makequestion(qrdataset, dns_rdataclass_in,
dns_rdatatype_a);
ISC_LIST_APPEND(qname->list, qrdataset, link);
dns_message_addname(message, qname, DNS_SECTION_QUESTION);
- request = NULL;
result = dns_request_createvia(
requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, -1,
DNS_REQUESTOPT_TCP | DNS_REQUESTOPT_SHARE, NULL, TIMEOUT, 0, 0,
@@ -206,16 +201,17 @@ main(int argc, char *argv[]) {
isc_sockaddr_t bind_any;
struct in_addr inaddr;
isc_result_t result;
- isc_log_t *lctx;
- isc_logconfig_t *lcfg;
- isc_taskmgr_t *taskmgr;
- isc_task_t *task;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
+ isc_log_t *lctx = NULL;
+ isc_logconfig_t *lcfg = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_task_t *task = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
unsigned int attrs, attrmask;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
uint16_t port = PORT;
int c;
@@ -269,41 +265,30 @@ main(int argc, char *argv[]) {
}
isc_sockaddr_fromin(&dstaddr, &inaddr, port);
- mctx = NULL;
isc_mem_create(&mctx);
- lctx = NULL;
- lcfg = NULL;
isc_log_create(mctx, &lctx, &lcfg);
RUNCHECK(dst_lib_init(mctx, NULL));
- taskmgr = NULL;
- RUNCHECK(isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr));
- task = NULL;
+ RUNCHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
DNS_DISPATCHATTR_IPV4;
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
- dispatchv4 = NULL;
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
have_src ? &srcaddr : &bind_any, 4096, 4,
2, 3, 5, attrs, attrmask, &dispatchv4));
- requestmgr = NULL;
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
dispatchmgr, dispatchv4, NULL,
&requestmgr));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
RUNCHECK(isc_app_onrun(mctx, task, sendqueries, NULL));
@@ -323,7 +308,7 @@ main(int argc, char *argv[]) {
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
dst_lib_destroy();
diff --git a/external/mpl/bind/dist/bin/tests/system/resolve.c b/external/mpl/bind/dist/bin/tests/system/resolve.c
index a711a6aa151..3b951cef16c 100644
--- a/external/mpl/bind/dist/bin/tests/system/resolve.c
+++ b/external/mpl/bind/dist/bin/tests/system/resolve.c
@@ -1,4 +1,4 @@
-/* $NetBSD: resolve.c,v 1.1.1.1 2021/08/19 11:45:15 christos Exp $ */
+/* $NetBSD: resolve.c,v 1.2 2021/08/19 11:50:15 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/bin/tests/system/serve-stale/ns3/named.conf.in b/external/mpl/bind/dist/bin/tests/system/serve-stale/ns3/named.conf.in
deleted file mode 100644
index 709fd03bb8f..00000000000
--- a/external/mpl/bind/dist/bin/tests/system/serve-stale/ns3/named.conf.in
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-key rndc_key {
- secret "1234abcd8765";
- algorithm hmac-sha256;
-};
-
-controls {
- inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
-};
-
-options {
- query-source address 10.53.0.3;
- notify-source 10.53.0.3;
- transfer-source 10.53.0.3;
- port @PORT@;
- pid-file "named.pid";
- listen-on { 10.53.0.3; };
- listen-on-v6 { none; };
- recursion yes;
- dump-file "named_dump3.db";
-};
-
-zone "." {
- type secondary;
- primaries { 10.53.0.1; };
- file "root.bk";
-};
diff --git a/external/mpl/bind/dist/bin/tests/system/tkey/keycreate.c b/external/mpl/bind/dist/bin/tests/system/tkey/keycreate.c
index 3de5e4bb371..8df2c8c36fc 100644
--- a/external/mpl/bind/dist/bin/tests/system/tkey/keycreate.c
+++ b/external/mpl/bind/dist/bin/tests/system/tkey/keycreate.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keycreate.c,v 1.5 2021/02/19 16:42:14 christos Exp $ */
+/* $NetBSD: keycreate.c,v 1.6 2021/08/19 11:50:16 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -18,6 +18,7 @@
#include <isc/base64.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/nonce.h>
#include <isc/print.h>
@@ -57,20 +58,20 @@
#define PORT 5300
#define TIMEOUT 30
-static dst_key_t *ourkey;
-static isc_mem_t *mctx;
-static dns_tsigkey_t *tsigkey, *initialkey;
-static dns_tsig_keyring_t *ring;
+static dst_key_t *ourkey = NULL;
+static isc_mem_t *mctx = NULL;
+static dns_tsigkey_t *tsigkey = NULL, *initialkey = NULL;
+static dns_tsig_keyring_t *ring = NULL;
static unsigned char noncedata[16];
static isc_buffer_t nonce;
-static dns_requestmgr_t *requestmgr;
+static dns_requestmgr_t *requestmgr = NULL;
static const char *ownername_str = ".";
static void
recvquery(isc_task_t *task, isc_event_t *event) {
dns_requestevent_t *reqev = (dns_requestevent_t *)event;
isc_result_t result;
- dns_message_t *query, *response;
+ dns_message_t *query = NULL, *response = NULL;
char keyname[256];
isc_buffer_t keynamebuf;
int type;
@@ -87,7 +88,6 @@ recvquery(isc_task_t *task, isc_event_t *event) {
query = reqev->ev_arg;
- response = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
result = dns_request_getresponse(reqev->request, response,
@@ -135,8 +135,8 @@ sendquery(isc_task_t *task, isc_event_t *event) {
dns_fixedname_t ownername;
isc_buffer_t namestr, keybuf;
unsigned char keydata[9];
- dns_message_t *query;
- dns_request_t *request;
+ dns_message_t *query = NULL;
+ dns_request_t *request = NULL;
static char keystr[] = "0123456789ab";
isc_event_free(&event);
@@ -167,14 +167,12 @@ sendquery(isc_task_t *task, isc_event_t *event) {
isc_buffer_usedregion(&keybuf, &r);
- initialkey = NULL;
result = dns_tsigkey_create(
dns_fixedname_name(&keyname), DNS_TSIG_HMACMD5_NAME,
isc_buffer_base(&keybuf), isc_buffer_usedlength(&keybuf), false,
NULL, 0, 0, mctx, ring, &initialkey);
CHECK("dns_tsigkey_create", result);
- query = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
result = dns_tkey_builddhquery(query, ourkey,
@@ -182,7 +180,6 @@ sendquery(isc_task_t *task, isc_event_t *event) {
DNS_TSIG_HMACMD5_NAME, &nonce, 3600);
CHECK("dns_tkey_builddhquery", result);
- request = NULL;
result = dns_request_create(requestmgr, query, &address,
DNS_REQUESTOPT_TCP, initialkey, TIMEOUT,
task, recvquery, query, &request);
@@ -191,20 +188,21 @@ sendquery(isc_task_t *task, isc_event_t *event) {
int
main(int argc, char *argv[]) {
- char *ourkeyname;
- isc_taskmgr_t *taskmgr;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *sock;
+ char *ourkeyname = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *sock = NULL;
unsigned int attrs, attrmask;
isc_sockaddr_t bind_any;
- dns_dispatchmgr_t *dispatchmgr;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
- dns_tkeyctx_t *tctx;
- isc_log_t *log;
- isc_logconfig_t *logconfig;
- isc_task_t *task;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
+ dns_tkeyctx_t *tctx = NULL;
+ isc_log_t *log = NULL;
+ isc_logconfig_t *logconfig = NULL;
+ isc_task_t *task = NULL;
isc_result_t result;
int type;
@@ -226,57 +224,42 @@ main(int argc, char *argv[]) {
dns_result_register();
- mctx = NULL;
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
- log = NULL;
- logconfig = NULL;
isc_log_create(mctx, &log, &logconfig);
RUNCHECK(dst_lib_init(mctx, NULL));
- taskmgr = NULL;
- RUNCHECK(isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr));
- task = NULL;
+ RUNCHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
isc_sockaddr_any(&bind_any);
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
DNS_DISPATCHATTR_IPV4;
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
- dispatchv4 = NULL;
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
4096, 4, 2, 3, 5, attrs, attrmask,
&dispatchv4));
- requestmgr = NULL;
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
dispatchmgr, dispatchv4, NULL,
&requestmgr));
- ring = NULL;
RUNCHECK(dns_tsigkeyring_create(mctx, &ring));
- tctx = NULL;
RUNCHECK(dns_tkeyctx_create(mctx, &tctx));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
dns_view_setkeyring(view, ring);
dns_tsigkeyring_detach(&ring);
- sock = NULL;
RUNCHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
&sock));
RUNCHECK(isc_app_onrun(mctx, task, sendquery, NULL));
- ourkey = NULL;
type = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_KEY;
result = dst_key_fromnamedfile(ourkeyname, NULL, type, mctx, &ourkey);
CHECK("dst_key_fromnamedfile", result);
@@ -293,7 +276,7 @@ main(int argc, char *argv[]) {
dns_dispatchmgr_destroy(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socket_detach(&sock);
isc_socketmgr_destroy(&socketmgr);
isc_timermgr_destroy(&timermgr);
diff --git a/external/mpl/bind/dist/bin/tests/system/tkey/keydelete.c b/external/mpl/bind/dist/bin/tests/system/tkey/keydelete.c
index b8bbb3e308b..60f19e28cf5 100644
--- a/external/mpl/bind/dist/bin/tests/system/tkey/keydelete.c
+++ b/external/mpl/bind/dist/bin/tests/system/tkey/keydelete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keydelete.c,v 1.5 2021/02/19 16:42:14 christos Exp $ */
+/* $NetBSD: keydelete.c,v 1.6 2021/08/19 11:50:16 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -18,6 +18,7 @@
#include <isc/base64.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/random.h>
@@ -56,16 +57,16 @@
#define PORT 5300
#define TIMEOUT 30
-static isc_mem_t *mctx;
-static dns_tsigkey_t *tsigkey;
-static dns_tsig_keyring_t *ring;
-static dns_requestmgr_t *requestmgr;
+static isc_mem_t *mctx = NULL;
+static dns_tsigkey_t *tsigkey = NULL;
+static dns_tsig_keyring_t *ring = NULL;
+static dns_requestmgr_t *requestmgr = NULL;
static void
recvquery(isc_task_t *task, isc_event_t *event) {
dns_requestevent_t *reqev = (dns_requestevent_t *)event;
isc_result_t result;
- dns_message_t *query, *response;
+ dns_message_t *query = NULL, *response = NULL;
UNUSED(task);
@@ -79,7 +80,6 @@ recvquery(isc_task_t *task, isc_event_t *event) {
query = reqev->ev_arg;
- response = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
result = dns_request_getresponse(reqev->request, response,
@@ -109,8 +109,8 @@ sendquery(isc_task_t *task, isc_event_t *event) {
struct in_addr inaddr;
isc_sockaddr_t address;
isc_result_t result;
- dns_message_t *query;
- dns_request_t *request;
+ dns_message_t *query = NULL;
+ dns_request_t *request = NULL;
isc_event_free(&event);
@@ -120,13 +120,11 @@ sendquery(isc_task_t *task, isc_event_t *event) {
}
isc_sockaddr_fromin(&address, &inaddr, PORT);
- query = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
result = dns_tkey_builddeletequery(query, tsigkey);
CHECK("dns_tkey_builddeletequery", result);
- request = NULL;
result = dns_request_create(requestmgr, query, &address,
DNS_REQUESTOPT_TCP, tsigkey, TIMEOUT, task,
recvquery, query, &request);
@@ -135,21 +133,22 @@ sendquery(isc_task_t *task, isc_event_t *event) {
int
main(int argc, char **argv) {
- char *keyname;
- isc_taskmgr_t *taskmgr;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *sock;
+ char *keyname = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *sock = NULL;
unsigned int attrs, attrmask;
isc_sockaddr_t bind_any;
- dns_dispatchmgr_t *dispatchmgr;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
- dns_tkeyctx_t *tctx;
- dst_key_t *dstkey;
- isc_log_t *log;
- isc_logconfig_t *logconfig;
- isc_task_t *task;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
+ dns_tkeyctx_t *tctx = NULL;
+ dst_key_t *dstkey = NULL;
+ isc_log_t *log = NULL;
+ isc_logconfig_t *logconfig = NULL;
+ isc_task_t *task = NULL;
isc_result_t result;
int type;
@@ -167,55 +166,40 @@ main(int argc, char **argv) {
dns_result_register();
- mctx = NULL;
isc_mem_create(&mctx);
- log = NULL;
- logconfig = NULL;
isc_log_create(mctx, &log, &logconfig);
RUNCHECK(dst_lib_init(mctx, NULL));
- taskmgr = NULL;
- RUNCHECK(isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr));
- task = NULL;
+ RUNCHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
isc_sockaddr_any(&bind_any);
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
DNS_DISPATCHATTR_IPV4;
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
- dispatchv4 = NULL;
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
4096, 4, 2, 3, 5, attrs, attrmask,
&dispatchv4));
- requestmgr = NULL;
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
dispatchmgr, dispatchv4, NULL,
&requestmgr));
- ring = NULL;
RUNCHECK(dns_tsigkeyring_create(mctx, &ring));
- tctx = NULL;
RUNCHECK(dns_tkeyctx_create(mctx, &tctx));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
dns_view_setkeyring(view, ring);
- sock = NULL;
RUNCHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
&sock));
RUNCHECK(isc_app_onrun(mctx, task, sendquery, NULL));
- dstkey = NULL;
type = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_KEY;
result = dst_key_fromnamedfile(keyname, NULL, type, mctx, &dstkey);
CHECK("dst_key_fromnamedfile", result);
@@ -233,7 +217,7 @@ main(int argc, char **argv) {
dns_dispatchmgr_destroy(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
isc_socket_detach(&sock);
isc_socketmgr_destroy(&socketmgr);
isc_timermgr_destroy(&timermgr);
diff --git a/external/mpl/bind/dist/bin/tools/mdig.c b/external/mpl/bind/dist/bin/tools/mdig.c
index 5162bb35d25..a11d25244e7 100644
--- a/external/mpl/bind/dist/bin/tools/mdig.c
+++ b/external/mpl/bind/dist/bin/tools/mdig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mdig.c,v 1.8 2021/04/29 17:26:10 christos Exp $ */
+/* $NetBSD: mdig.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -22,6 +22,7 @@
#include <isc/hash.h>
#include <isc/hex.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/nonce.h>
@@ -88,10 +89,10 @@
#define US_PER_SEC 1000000 /*%< Microseconds per second. */
#define US_PER_MS 1000 /*%< Microseconds per millisecond. */
-static isc_mem_t *mctx;
-static dns_requestmgr_t *requestmgr;
-static const char *batchname;
-static FILE *batchfp;
+static isc_mem_t *mctx = NULL;
+static dns_requestmgr_t *requestmgr = NULL;
+static const char *batchname = NULL;
+static FILE *batchfp = NULL;
static bool burst = false;
static bool have_ipv4 = false;
static bool have_ipv6 = false;
@@ -116,7 +117,7 @@ static bool yaml = false;
static bool continue_on_error = false;
static uint32_t display_splitwidth = 0xffffffff;
static isc_sockaddr_t srcaddr;
-static char *server;
+static char *server = NULL;
static isc_sockaddr_t dstaddr;
static in_port_t port = 53;
static isc_dscp_t dscp = -1;
@@ -580,10 +581,10 @@ compute_cookie(unsigned char *cookie, size_t len) {
static isc_result_t
sendquery(struct query *query, isc_task_t *task) {
- dns_request_t *request;
- dns_message_t *message;
- dns_name_t *qname;
- dns_rdataset_t *qrdataset;
+ dns_request_t *request = NULL;
+ dns_message_t *message = NULL;
+ dns_name_t *qname = NULL;
+ dns_rdataset_t *qrdataset = NULL;
isc_result_t result;
dns_fixedname_t queryname;
isc_buffer_t buf;
@@ -598,7 +599,6 @@ sendquery(struct query *query, isc_task_t *task) {
dns_rootname, 0, NULL);
CHECK("dns_name_fromtext", result);
- message = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
message->opcode = dns_opcode_query;
@@ -620,15 +620,12 @@ sendquery(struct query *query, isc_task_t *task) {
message->rdclass = query->rdclass;
message->id = (unsigned short)(random() & 0xFFFF);
- qname = NULL;
result = dns_message_gettempname(message, &qname);
CHECK("dns_message_gettempname", result);
- qrdataset = NULL;
result = dns_message_gettemprdataset(message, &qrdataset);
CHECK("dns_message_gettemprdataset", result);
- dns_name_init(qname, NULL);
dns_name_clone(dns_fixedname_name(&queryname), qname);
dns_rdataset_makequestion(qrdataset, query->rdclass, query->rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
@@ -2062,37 +2059,23 @@ parse_args(bool is_batchfile, int argc, char **argv) {
}
}
-#ifdef WIN32
-static void
-usleep(unsigned int usec) {
- HANDLE timer;
- LARGE_INTEGER ft;
-
- ft.QuadPart = -(10 * (__int64)usec);
-
- timer = CreateWaitableTimer(NULL, TRUE, NULL);
- SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
- WaitForSingleObject(timer, INFINITE);
- CloseHandle(timer);
-}
-#endif
-
/*% Main processing routine for mdig */
int
main(int argc, char *argv[]) {
- struct query *query;
+ struct query *query = NULL;
isc_result_t result;
isc_sockaddr_t bind_any;
- isc_log_t *lctx;
- isc_logconfig_t *lcfg;
- isc_taskmgr_t *taskmgr;
- isc_task_t *task;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
+ isc_log_t *lctx = NULL;
+ isc_logconfig_t *lcfg = NULL;
+ isc_nm_t *netmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_task_t *task = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
unsigned int attrs, attrmask;
- dns_dispatch_t *dispatchvx;
- dns_view_t *view;
+ dns_dispatch_t *dispatchvx = NULL;
+ dns_view_t *view = NULL;
int ns;
unsigned int i;
@@ -2112,11 +2095,8 @@ main(int argc, char *argv[]) {
preparse_args(argc, argv);
- mctx = NULL;
isc_mem_create(&mctx);
- lctx = NULL;
- lcfg = NULL;
isc_log_create(mctx, &lctx, &lcfg);
RUNCHECK(dst_lib_init(mctx, NULL));
@@ -2146,16 +2126,11 @@ main(int argc, char *argv[]) {
fatal("can't choose between IPv4 and IPv6");
}
- taskmgr = NULL;
- RUNCHECK(isc_taskmgr_create(mctx, 1, 0, NULL, &taskmgr));
- task = NULL;
+ RUNCHECK(isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr));
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY;
@@ -2168,18 +2143,15 @@ main(int argc, char *argv[]) {
}
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
- dispatchvx = NULL;
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
have_src ? &srcaddr : &bind_any, 4096, 100,
100, 17, 19, attrs, attrmask,
&dispatchvx));
- requestmgr = NULL;
RUNCHECK(dns_requestmgr_create(
mctx, timermgr, socketmgr, taskmgr, dispatchmgr,
have_ipv4 ? dispatchvx : NULL, have_ipv6 ? dispatchvx : NULL,
&requestmgr));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
query = ISC_LIST_HEAD(queries);
@@ -2226,7 +2198,7 @@ main(int argc, char *argv[]) {
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
dst_lib_destroy();
diff --git a/external/mpl/bind/dist/bin/tools/named-journalprint.c b/external/mpl/bind/dist/bin/tools/named-journalprint.c
index 1b0e29ec07c..9f4db1d4f64 100644
--- a/external/mpl/bind/dist/bin/tools/named-journalprint.c
+++ b/external/mpl/bind/dist/bin/tools/named-journalprint.c
@@ -1,4 +1,4 @@
-/* $NetBSD: named-journalprint.c,v 1.5 2021/04/29 17:26:10 christos Exp $ */
+/* $NetBSD: named-journalprint.c,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -70,12 +70,24 @@ main(int argc, char **argv) {
isc_log_t *lctx = NULL;
uint32_t flags = 0U;
int ch;
+ bool compact = false;
bool downgrade = false;
bool upgrade = false;
+ unsigned int serial = 0;
+ char *endp = NULL;
progname = argv[0];
- while ((ch = isc_commandline_parse(argc, argv, "dux")) != -1) {
+ while ((ch = isc_commandline_parse(argc, argv, "c:dux")) != -1) {
switch (ch) {
+ case 'c':
+ compact = true;
+ serial = strtoul(isc_commandline_argument, &endp, 0);
+ if (endp == isc_commandline_argument || *endp != 0) {
+ fprintf(stderr, "invalid serial: %s\n",
+ isc_commandline_argument);
+ exit(1);
+ }
+ break;
case 'd':
downgrade = true;
break;
@@ -107,6 +119,9 @@ main(int argc, char **argv) {
} else if (downgrade) {
flags = DNS_JOURNAL_COMPACTALL | DNS_JOURNAL_VERSION1;
result = dns_journal_compact(mctx, file, 0, flags, 0);
+ } else if (compact) {
+ flags = 0;
+ result = dns_journal_compact(mctx, file, serial, flags, 0);
} else {
result = dns_journal_print(mctx, flags, file, stdout);
if (result == DNS_R_NOJOURNAL) {
diff --git a/external/mpl/bind/dist/config.h.in b/external/mpl/bind/dist/config.h.in
index 350f98dd310..39c140a3685 100644
--- a/external/mpl/bind/dist/config.h.in
+++ b/external/mpl/bind/dist/config.h.in
@@ -156,9 +156,6 @@
/* Define to 1 if you have the `EVP_sha512' function. */
#undef HAVE_EVP_SHA512
-/* Define to 1 if you have the `explicit_bzero' function. */
-#undef HAVE_EXPLICIT_BZERO
-
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@@ -177,6 +174,12 @@
/* Define to 1 if the system has the `destructor' function attribute */
#undef HAVE_FUNC_ATTRIBUTE_DESTRUCTOR
+/* Define to 1 if the system has the `malloc' function attribute */
+#undef HAVE_FUNC_ATTRIBUTE_MALLOC
+
+/* Define to 1 if the system has the `returns_nonnull' function attribute */
+#undef HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
+
/* Build with GeoIP2 support */
#undef HAVE_GEOIP2
@@ -270,15 +273,15 @@
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
+/* define if extended attributes for malloc are available */
+#undef HAVE_MALLOC_EXT_ATTR
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
-/* Define to 1 if you have the `nanosleep' function. */
-#undef HAVE_NANOSLEEP
-
/* Define to 1 if you have the <net/if6.h> header file. */
#undef HAVE_NET_IF6_H
@@ -501,24 +504,6 @@
/* define if the compiler supports _Unwind_Backtrace() */
#undef HAVE_UNWIND_BACKTRACE
-/* Define to 1 if you have the `usleep' function. */
-#undef HAVE_USLEEP
-
-/* Define to 1 if you have the `uv_handle_get_data' function. */
-#undef HAVE_UV_HANDLE_GET_DATA
-
-/* Define to 1 if you have the `uv_handle_set_data' function. */
-#undef HAVE_UV_HANDLE_SET_DATA
-
-/* Define to 1 if you have the `uv_import' function. */
-#undef HAVE_UV_IMPORT
-
-/* Define to 1 if you have the `uv_translate_sys_error' function. */
-#undef HAVE_UV_TRANSLATE_SYS_ERROR
-
-/* Define to 1 if you have the `uv_udp_connect' function. */
-#undef HAVE_UV_UDP_CONNECT
-
/* Use zlib library */
#undef HAVE_ZLIB
diff --git a/external/mpl/bind/dist/configure b/external/mpl/bind/dist/configure
index 93833e06cce..b8c5b0fe6d6 100755
--- a/external/mpl/bind/dist/configure
+++ b/external/mpl/bind/dist/configure
@@ -12798,7 +12798,7 @@ COVERAGE=''
KEYMGR=''
if test "X$PYTHON" != "X"; then :
PYTHON_TOOLS=python
- CHECKDS=checkds
+ CHECKDS=checkdstool
COVERAGE=coverage
KEYMGR=keymgr
PYTHON_INSTALL_DIR="$with_python_install_dir"
@@ -12845,7 +12845,7 @@ case "$INSTALL" in
;;
esac
-for ac_prog in pytest-3 py.test-3 pytest pytest-pypy
+for ac_prog in pytest-3 py.test-3 pytest py.test pytest-pypy
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -14354,6 +14354,148 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
#
+# check for GCC malloc attribute
+#
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((malloc))" >&5
+$as_echo_n "checking for __attribute__((malloc))... " >&6; }
+if ${ax_cv_have_func_attribute_malloc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+ void *foo( void ) __attribute__((malloc));
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ if test -s conftest.err; then :
+ ax_cv_have_func_attribute_malloc=no
+else
+ ax_cv_have_func_attribute_malloc=yes
+fi
+else
+ ax_cv_have_func_attribute_malloc=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_malloc" >&5
+$as_echo "$ax_cv_have_func_attribute_malloc" >&6; }
+
+ if test yes = $ax_cv_have_func_attribute_malloc; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FUNC_ATTRIBUTE_MALLOC 1
+_ACEOF
+
+fi
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for extended malloc attributes" >&5
+$as_echo_n "checking for extended malloc attributes... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <stddef.h>
+ #include <stdlib.h>
+ __attribute__ ((malloc, malloc (free, 1))
+ void * xmalloc(size_t sz) { return malloc(sz); }
+
+int
+main ()
+{
+
+ void *p = xmalloc(8);
+ free(p);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_MALLOC_EXT_ATTR 1" >>confdefs.h
+
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+#
+# check for GCC returns_nonnull attribute
+#
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((returns_nonnull))" >&5
+$as_echo_n "checking for __attribute__((returns_nonnull))... " >&6; }
+if ${ax_cv_have_func_attribute_returns_nonnull+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+ void *foo( void ) __attribute__((returns_nonnull));
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ if test -s conftest.err; then :
+ ax_cv_have_func_attribute_returns_nonnull=no
+else
+ ax_cv_have_func_attribute_returns_nonnull=yes
+fi
+else
+ ax_cv_have_func_attribute_returns_nonnull=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_returns_nonnull" >&5
+$as_echo "$ax_cv_have_func_attribute_returns_nonnull" >&6; }
+
+ if test yes = $ax_cv_have_func_attribute_returns_nonnull; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL 1
+_ACEOF
+
+fi
+
+
+
+
+#
# check if we have kqueue
#
# [pairwise: --enable-kqueue, --disable-kqueue]
@@ -16079,148 +16221,6 @@ $as_echo "yes" >&6; }
fi
-
-
-
-
- CCASFLAGS_libuv_ax_save_flags=$CCASFLAGS
-
-
-
- CFLAGS_libuv_ax_save_flags=$CFLAGS
-
-
-
- CPPFLAGS_libuv_ax_save_flags=$CPPFLAGS
-
-
-
- CXXFLAGS_libuv_ax_save_flags=$CXXFLAGS
-
-
-
- ERLCFLAGS_libuv_ax_save_flags=$ERLCFLAGS
-
-
-
- FCFLAGS_libuv_ax_save_flags=$FCFLAGS
-
-
-
- FCLIBS_libuv_ax_save_flags=$FCLIBS
-
-
-
- FFLAGS_libuv_ax_save_flags=$FFLAGS
-
-
-
- FLIBS_libuv_ax_save_flags=$FLIBS
-
-
-
- GCJFLAGS_libuv_ax_save_flags=$GCJFLAGS
-
-
-
- JAVACFLAGS_libuv_ax_save_flags=$JAVACFLAGS
-
-
-
- LDFLAGS_libuv_ax_save_flags=$LDFLAGS
-
-
-
- LIBS_libuv_ax_save_flags=$LIBS
-
-
-
- OBJCFLAGS_libuv_ax_save_flags=$OBJCFLAGS
-
-
-
- OBJCXXFLAGS_libuv_ax_save_flags=$OBJCXXFLAGS
-
-
-
- UPCFLAGS_libuv_ax_save_flags=$UPCFLAGS
-
-
-
- VALAFLAGS_libuv_ax_save_flags=$VALAFLAGS
-
-
-
-CFLAGS="$CFLAGS $LIBUV_CFLAGS"
-LIBS="$LDFLAGS $LIBUV_LIBS"
-# Those functions are only provided in newer versions of libuv, we'll be emulating them
-# for now
-for ac_func in uv_handle_get_data uv_handle_set_data uv_import uv_udp_connect uv_translate_sys_error
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
- CCASFLAGS=$CCASFLAGS_libuv_ax_save_flags
-
-
- CFLAGS=$CFLAGS_libuv_ax_save_flags
-
-
- CPPFLAGS=$CPPFLAGS_libuv_ax_save_flags
-
-
- CXXFLAGS=$CXXFLAGS_libuv_ax_save_flags
-
-
- ERLCFLAGS=$ERLCFLAGS_libuv_ax_save_flags
-
-
- FCFLAGS=$FCFLAGS_libuv_ax_save_flags
-
-
- FCLIBS=$FCLIBS_libuv_ax_save_flags
-
-
- FFLAGS=$FFLAGS_libuv_ax_save_flags
-
-
- FLIBS=$FLIBS_libuv_ax_save_flags
-
-
- GCJFLAGS=$GCJFLAGS_libuv_ax_save_flags
-
-
- JAVACFLAGS=$JAVACFLAGS_libuv_ax_save_flags
-
-
- LDFLAGS=$LDFLAGS_libuv_ax_save_flags
-
-
- LIBS=$LIBS_libuv_ax_save_flags
-
-
- OBJCFLAGS=$OBJCFLAGS_libuv_ax_save_flags
-
-
- OBJCXXFLAGS=$OBJCXXFLAGS_libuv_ax_save_flags
-
-
- UPCFLAGS=$UPCFLAGS_libuv_ax_save_flags
-
-
- VALAFLAGS=$VALAFLAGS_libuv_ax_save_flags
-
-
-
-
#
# flockfile is usually provided by pthreads
#
@@ -19213,6 +19213,49 @@ if test "$enable_backtrace" = "yes"; then :
$as_echo "#define USE_BACKTRACE 1" >>confdefs.h
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for backtrace in -lexecinfo" >&5
+$as_echo_n "checking for backtrace in -lexecinfo... " >&6; }
+if ${ac_cv_lib_execinfo_backtrace+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lexecinfo $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char backtrace ();
+int
+main ()
+{
+return backtrace ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_execinfo_backtrace=yes
+else
+ ac_cv_lib_execinfo_backtrace=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_execinfo_backtrace" >&5
+$as_echo "$ac_cv_lib_execinfo_backtrace" >&6; }
+if test "x$ac_cv_lib_execinfo_backtrace" = xyes; then :
+ EXILIBS=-lexecinfo
+else
+ EXILIBS=
+fi
+
+ LIBS="$LIBS $EXILIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <execinfo.h>
@@ -19909,19 +19952,6 @@ fi
done
-for ac_func in nanosleep usleep explicit_bzero
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
ISC_ATOMIC_LIBS=""
for ac_header in stdatomic.h
do :
@@ -21787,19 +21817,19 @@ case $with_cmocka in #(
detect) :
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.0.0" >&5
-$as_echo_n "checking for cmocka >= 1.0.0... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.1.3" >&5
+$as_echo_n "checking for cmocka >= 1.1.3... " >&6; }
if test -n "$CMOCKA_CFLAGS"; then
pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.1.3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "cmocka >= 1.1.3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_CMOCKA_CFLAGS=`$PKG_CONFIG --cflags "cmocka >= 1.0.0" 2>/dev/null`
+ pkg_cv_CMOCKA_CFLAGS=`$PKG_CONFIG --cflags "cmocka >= 1.1.3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -21811,12 +21841,12 @@ if test -n "$CMOCKA_LIBS"; then
pkg_cv_CMOCKA_LIBS="$CMOCKA_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.1.3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "cmocka >= 1.1.3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_CMOCKA_LIBS=`$PKG_CONFIG --libs "cmocka >= 1.0.0" 2>/dev/null`
+ pkg_cv_CMOCKA_LIBS=`$PKG_CONFIG --libs "cmocka >= 1.1.3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -21837,9 +21867,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1`
+ CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka >= 1.1.3" 2>&1`
else
- CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1`
+ CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka >= 1.1.3" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$CMOCKA_PKG_ERRORS" >&5
@@ -21857,23 +21887,24 @@ $as_echo "yes" >&6; }
$as_echo "#define HAVE_CMOCKA 1" >>confdefs.h
+ with_cmocka=yes
fi ;; #(
yes) :
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.0.0" >&5
-$as_echo_n "checking for cmocka >= 1.0.0... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.1.3" >&5
+$as_echo_n "checking for cmocka >= 1.1.3... " >&6; }
if test -n "$CMOCKA_CFLAGS"; then
pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.1.3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "cmocka >= 1.1.3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_CMOCKA_CFLAGS=`$PKG_CONFIG --cflags "cmocka >= 1.0.0" 2>/dev/null`
+ pkg_cv_CMOCKA_CFLAGS=`$PKG_CONFIG --cflags "cmocka >= 1.1.3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -21885,12 +21916,12 @@ if test -n "$CMOCKA_LIBS"; then
pkg_cv_CMOCKA_LIBS="$CMOCKA_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.1.3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "cmocka >= 1.1.3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_CMOCKA_LIBS=`$PKG_CONFIG --libs "cmocka >= 1.0.0" 2>/dev/null`
+ pkg_cv_CMOCKA_LIBS=`$PKG_CONFIG --libs "cmocka >= 1.1.3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -21911,14 +21942,14 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1`
+ CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka >= 1.1.3" 2>&1`
else
- CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1`
+ CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka >= 1.1.3" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$CMOCKA_PKG_ERRORS" >&5
- as_fn_error $? "Package requirements (cmocka >= 1.0.0) were not met:
+ as_fn_error $? "Package requirements (cmocka >= 1.1.3) were not met:
$CMOCKA_PKG_ERRORS
@@ -23952,7 +23983,7 @@ ac_config_commands="$ac_config_commands chmod"
# elsewhere if there's a good reason for doing so.
#
-ac_config_files="$ac_config_files Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/plugins/Makefile bin/python/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/Makefile bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/Makefile bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/python/isc/utils.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/man/Makefile doc/misc/Makefile fuzz/Makefile lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/netmgr/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/tests/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccc/tests/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall make/Makefile make/mkdep unit/unittest.sh util/check-make-install"
+ac_config_files="$ac_config_files Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/plugins/Makefile bin/python/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/Makefile bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/Makefile bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/python/isc/utils.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/man/Makefile doc/misc/Makefile fuzz/Makefile lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/netmgr/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/tests/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccc/tests/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile make/Makefile make/mkdep unit/unittest.sh util/check-make-install"
#
@@ -25068,8 +25099,6 @@ do
"lib/ns/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/include/Makefile" ;;
"lib/ns/include/ns/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/include/ns/Makefile" ;;
"lib/ns/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/tests/Makefile" ;;
- "lib/samples/Makefile") CONFIG_FILES="$CONFIG_FILES lib/samples/Makefile" ;;
- "lib/samples/Makefile-postinstall") CONFIG_FILES="$CONFIG_FILES lib/samples/Makefile-postinstall" ;;
"make/Makefile") CONFIG_FILES="$CONFIG_FILES make/Makefile" ;;
"make/mkdep") CONFIG_FILES="$CONFIG_FILES make/mkdep" ;;
"unit/unittest.sh") CONFIG_FILES="$CONFIG_FILES unit/unittest.sh" ;;
diff --git a/external/mpl/bind/dist/lib/bind9/check.c b/external/mpl/bind/dist/lib/bind9/check.c
index 1a7859aabf2..cecce53f16c 100644
--- a/external/mpl/bind/dist/lib/bind9/check.c
+++ b/external/mpl/bind/dist/lib/bind9/check.c
@@ -1,4 +1,4 @@
-/* $NetBSD: check.c,v 1.12 2021/04/29 17:26:10 christos Exp $ */
+/* $NetBSD: check.c,v 1.13 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -13,6 +13,7 @@
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -72,6 +73,9 @@ static isc_result_t
fileexist(const cfg_obj_t *obj, isc_symtab_t *symtab, bool writeable,
isc_log_t *logctxlogc);
+static isc_result_t
+keydirexist(const cfg_obj_t *zcgf, const char *dir, const char *kaspnamestr,
+ isc_symtab_t *symtab, isc_log_t *logctx, isc_mem_t *mctx);
static void
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) {
UNUSED(type);
@@ -894,6 +898,9 @@ kasp_name_allowed(const cfg_listelt_t *element) {
if (strcmp("default", name) == 0) {
return (false);
}
+ if (strcmp("insecure", name) == 0) {
+ return (false);
+ }
return (true);
}
@@ -1051,18 +1058,17 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx,
if (result == ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
}
- }
-
- if (bad_name) {
+ } else if (bad_name) {
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
- "dnssec-policy name may not be 'none' or "
- "'default' (which is the built-in policy)");
+ "dnssec-policy name may not be 'insecure', "
+ "'none', or 'default' (which are built-in "
+ "policies)");
if (result == ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
}
+ } else {
+ has_dnssecpolicy = true;
}
-
- has_dnssecpolicy = true;
}
obj = NULL;
@@ -1682,12 +1688,12 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx,
}
/*
- * Check "primaries" style list.
+ * Check "remote-servers" style list.
*/
static isc_result_t
-bind9_check_primarylist(const cfg_obj_t *cctx, const char *list,
- isc_log_t *logctx, isc_symtab_t *symtab,
- isc_mem_t *mctx) {
+bind9_check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
+ isc_log_t *logctx, isc_symtab_t *symtab,
+ isc_mem_t *mctx) {
isc_symvalue_t symvalue;
isc_result_t result, tresult;
const cfg_obj_t *obj = NULL;
@@ -1724,9 +1730,9 @@ bind9_check_primarylist(const cfg_obj_t *cctx, const char *list,
file = "<unknown file>";
}
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
- "primaries list '%s' is duplicated: "
+ "%s list '%s' is duplicated: "
"also defined at %s:%u",
- name, file, line);
+ list, name, file, line);
isc_mem_free(mctx, tmp);
result = tresult;
break;
@@ -1754,13 +1760,35 @@ bind9_check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx,
if (result != ISC_R_SUCCESS) {
return (result);
}
- tresult = bind9_check_primarylist(cctx, "primaries", logctx, symtab,
- mctx);
+ tresult = bind9_check_remoteserverlist(cctx, "primaries", logctx,
+ symtab, mctx);
+ if (tresult != ISC_R_SUCCESS) {
+ result = tresult;
+ }
+ tresult = bind9_check_remoteserverlist(cctx, "masters", logctx, symtab,
+ mctx);
if (tresult != ISC_R_SUCCESS) {
result = tresult;
}
- tresult = bind9_check_primarylist(cctx, "masters", logctx, symtab,
- mctx);
+ isc_symtab_destroy(&symtab);
+ return (result);
+}
+
+/*
+ * Check parental-agents lists for duplicates.
+ */
+static isc_result_t
+bind9_check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
+ isc_mem_t *mctx) {
+ isc_result_t result, tresult;
+ isc_symtab_t *symtab = NULL;
+
+ result = isc_symtab_create(mctx, 100, freekey, mctx, false, &symtab);
+ if (result != ISC_R_SUCCESS) {
+ return (result);
+ }
+ tresult = bind9_check_remoteserverlist(cctx, "parental-agents", logctx,
+ symtab, mctx);
if (tresult != ISC_R_SUCCESS) {
result = tresult;
}
@@ -1769,8 +1797,8 @@ bind9_check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx,
}
static isc_result_t
-get_primaries(const cfg_obj_t *cctx, const char *list, const char *name,
- const cfg_obj_t **ret) {
+get_remotes(const cfg_obj_t *cctx, const char *list, const char *name,
+ const cfg_obj_t **ret) {
isc_result_t result;
const cfg_obj_t *obj = NULL;
const cfg_listelt_t *elt = NULL;
@@ -1799,20 +1827,25 @@ get_primaries(const cfg_obj_t *cctx, const char *list, const char *name,
}
static isc_result_t
-get_primaries_def(const cfg_obj_t *cctx, const char *name,
- const cfg_obj_t **ret) {
- isc_result_t result;
+get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx,
+ const cfg_obj_t **ret) {
+ isc_result_t result = ISC_R_NOTFOUND;
- result = get_primaries(cctx, "primaries", name, ret);
- if (result != ISC_R_SUCCESS) {
- result = get_primaries(cctx, "masters", name, ret);
+ if (strcmp(list, "primaries") == 0) {
+ result = get_remotes(cctx, "primaries", name, ret);
+ if (result != ISC_R_SUCCESS) {
+ result = get_remotes(cctx, "masters", name, ret);
+ }
+ } else if (strcmp(list, "parental-agents") == 0) {
+ result = get_remotes(cctx, "parental-agents", name, ret);
}
return (result);
}
static isc_result_t
-validate_primaries(const cfg_obj_t *obj, const cfg_obj_t *config,
- uint32_t *countp, isc_log_t *logctx, isc_mem_t *mctx) {
+validate_remotes(const char *list, const cfg_obj_t *obj,
+ const cfg_obj_t *config, uint32_t *countp, isc_log_t *logctx,
+ isc_mem_t *mctx) {
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
uint32_t count = 0;
@@ -1821,7 +1854,7 @@ validate_primaries(const cfg_obj_t *obj, const cfg_obj_t *config,
const cfg_listelt_t *element;
const cfg_listelt_t **stack = NULL;
uint32_t stackcount = 0, pushed = 0;
- const cfg_obj_t *list;
+ const cfg_obj_t *listobj;
REQUIRE(countp != NULL);
result = isc_symtab_create(mctx, 100, NULL, NULL, false, &symtab);
@@ -1831,8 +1864,8 @@ validate_primaries(const cfg_obj_t *obj, const cfg_obj_t *config,
}
newlist:
- list = cfg_tuple_get(obj, "addresses");
- element = cfg_list_first(list);
+ listobj = cfg_tuple_get(obj, "addresses");
+ element = cfg_list_first(listobj);
resume:
for (; element != NULL; element = cfg_list_next(element)) {
const char *listname;
@@ -1840,7 +1873,7 @@ resume:
const cfg_obj_t *key;
addr = cfg_tuple_get(cfg_listelt_value(element),
- "primarieselement");
+ "remoteselement");
key = cfg_tuple_get(cfg_listelt_value(element), "key");
if (cfg_obj_issockaddr(addr)) {
@@ -1862,13 +1895,13 @@ resume:
if (tresult == ISC_R_EXISTS) {
continue;
}
- tresult = get_primaries_def(config, listname, &obj);
+ tresult = get_remoteservers_def(list, listname, config, &obj);
if (tresult != ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS) {
result = tresult;
}
cfg_obj_log(addr, logctx, ISC_LOG_ERROR,
- "unable to find primaries list '%s'",
+ "unable to find %s list '%s'", list,
listname);
continue;
}
@@ -2201,9 +2234,9 @@ cleanup:
static isc_result_t
check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
const cfg_obj_t *config, isc_symtab_t *symtab,
- isc_symtab_t *files, isc_symtab_t *inview, const char *viewname,
- dns_rdataclass_t defclass, cfg_aclconfctx_t *actx,
- isc_log_t *logctx, isc_mem_t *mctx) {
+ isc_symtab_t *files, isc_symtab_t *keydirs, isc_symtab_t *inview,
+ const char *viewname, dns_rdataclass_t defclass,
+ cfg_aclconfctx_t *actx, isc_log_t *logctx, isc_mem_t *mctx) {
const char *znamestr;
const char *typestr = NULL;
const char *target = NULL;
@@ -2228,6 +2261,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
bool has_dnssecpolicy = false;
const void *clauses = NULL;
const char *option = NULL;
+ const char *kaspname = NULL;
+ const char *dir = NULL;
static const char *acls[] = {
"allow-notify",
"allow-transfer",
@@ -2455,12 +2490,20 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
*/
obj = NULL;
(void)cfg_map_get(zoptions, "dnssec-policy", &obj);
+ if (obj == NULL && voptions != NULL) {
+ (void)cfg_map_get(voptions, "dnssec-policy", &obj);
+ }
+ if (obj == NULL && goptions != NULL) {
+ (void)cfg_map_get(goptions, "dnssec-policy", &obj);
+ }
if (obj != NULL) {
const cfg_obj_t *kasps = NULL;
- const char *kaspname = cfg_obj_asstring(obj);
+ kaspname = cfg_obj_asstring(obj);
if (strcmp(kaspname, "default") == 0) {
has_dnssecpolicy = true;
+ } else if (strcmp(kaspname, "insecure") == 0) {
+ has_dnssecpolicy = true;
} else if (strcmp(kaspname, "none") == 0) {
has_dnssecpolicy = false;
} else {
@@ -2575,8 +2618,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
}
if (tresult == ISC_R_SUCCESS && donotify) {
uint32_t count;
- tresult = validate_primaries(obj, config, &count,
- logctx, mctx);
+ tresult = validate_remotes("primaries", obj, config,
+ &count, logctx, mctx);
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
{
result = tresult;
@@ -2617,8 +2660,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
result = ISC_R_FAILURE;
} else {
uint32_t count;
- tresult = validate_primaries(obj, config, &count,
- logctx, mctx);
+ tresult = validate_remotes("primaries", obj, config,
+ &count, logctx, mctx);
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
{
result = tresult;
@@ -2634,6 +2677,32 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
}
/*
+ * Primary and secondary zones that have a "parental-agents" field,
+ * must have a corresponding "parental-agents" clause.
+ */
+ if (ztype == CFG_ZONE_MASTER || ztype == CFG_ZONE_SLAVE) {
+ obj = NULL;
+ (void)cfg_map_get(zoptions, "parental-agents", &obj);
+ if (obj != NULL) {
+ uint32_t count;
+ tresult = validate_remotes("parental-agents", obj,
+ config, &count, logctx,
+ mctx);
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
+ {
+ result = tresult;
+ }
+ if (tresult == ISC_R_SUCCESS && count == 0) {
+ cfg_obj_log(zoptions, logctx, ISC_LOG_ERROR,
+ "zone '%s': "
+ "empty 'parental-agents' entry",
+ znamestr);
+ result = ISC_R_FAILURE;
+ }
+ }
+ }
+
+ /*
* Configuring a mirror zone and disabling recursion at the same time
* contradicts the purpose of the former.
*/
@@ -3008,9 +3077,16 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
* Warn if key-directory doesn't exist
*/
obj = NULL;
- tresult = cfg_map_get(zoptions, "key-directory", &obj);
- if (tresult == ISC_R_SUCCESS) {
- const char *dir = cfg_obj_asstring(obj);
+ (void)cfg_map_get(zoptions, "key-directory", &obj);
+ if (obj == NULL && voptions != NULL) {
+ (void)cfg_map_get(voptions, "key-directory", &obj);
+ }
+ if (obj == NULL && goptions != NULL) {
+ (void)cfg_map_get(goptions, "key-directory", &obj);
+ }
+ if (obj != NULL) {
+ dir = cfg_obj_asstring(obj);
+
tresult = isc_file_isdirectory(dir);
switch (tresult) {
case ISC_R_SUCCESS:
@@ -3033,6 +3109,25 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
}
/*
+ * Make sure there is no other zone with the same
+ * key-directory and a different dnssec-policy.
+ */
+ if (zname != NULL) {
+ char keydirbuf[DNS_NAME_FORMATSIZE + 128];
+ char *tmp = keydirbuf;
+ size_t len = sizeof(keydirbuf);
+ dns_name_format(zname, keydirbuf, sizeof(keydirbuf));
+ tmp += strlen(tmp);
+ len -= strlen(tmp);
+ (void)snprintf(tmp, len, "/%s", (dir == NULL) ? "(null)" : dir);
+ tresult = keydirexist(zconfig, (const char *)keydirbuf,
+ kaspname, keydirs, logctx, mctx);
+ if (tresult != ISC_R_SUCCESS) {
+ result = tresult;
+ }
+ }
+
+ /*
* Check various options.
*/
tresult = check_options(zoptions, logctx, mctx, optlevel_zone);
@@ -3041,10 +3136,9 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
}
/*
- * If the zone type is rbt/rbt64 then master/hint zones
- * require file clauses.
- * If inline signing is used, then slave zones require a
- * file clause as well
+ * If the zone type is rbt/rbt64 then master/hint zones require file
+ * clauses. If inline-signing is used, then slave zones require a
+ * file clause as well.
*/
obj = NULL;
dlz = false;
@@ -3082,7 +3176,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
result = tresult;
} else if (tresult == ISC_R_SUCCESS &&
(ztype == CFG_ZONE_SLAVE ||
- ztype == CFG_ZONE_MIRROR || ddns))
+ ztype == CFG_ZONE_MIRROR || ddns ||
+ has_dnssecpolicy))
{
tresult = fileexist(fileobj, files, true, logctx);
if (tresult != ISC_R_SUCCESS) {
@@ -3242,6 +3337,56 @@ fileexist(const cfg_obj_t *obj, isc_symtab_t *symtab, bool writeable,
return (result);
}
+static isc_result_t
+keydirexist(const cfg_obj_t *zcfg, const char *keydir, const char *kaspnamestr,
+ isc_symtab_t *symtab, isc_log_t *logctx, isc_mem_t *mctx) {
+ isc_result_t result;
+ isc_symvalue_t symvalue;
+ char *symkey;
+
+ if (kaspnamestr == NULL || strcmp(kaspnamestr, "none") == 0) {
+ return (ISC_R_SUCCESS);
+ }
+
+ result = isc_symtab_lookup(symtab, keydir, 0, &symvalue);
+ if (result == ISC_R_SUCCESS) {
+ const cfg_obj_t *kasp = NULL;
+ const cfg_obj_t *exist = symvalue.as_cpointer;
+ const char *file = cfg_obj_file(exist);
+ unsigned int line = cfg_obj_line(exist);
+
+ /*
+ * Having the same key-directory for the same zone is fine
+ * iff the zone is using the same policy, or has no policy.
+ */
+ (void)cfg_map_get(cfg_tuple_get(exist, "options"),
+ "dnssec-policy", &kasp);
+ if (kasp == NULL ||
+ strcmp(cfg_obj_asstring(kasp), "none") == 0 ||
+ strcmp(cfg_obj_asstring(kasp), kaspnamestr) == 0)
+ {
+ return (ISC_R_SUCCESS);
+ }
+
+ cfg_obj_log(zcfg, logctx, ISC_LOG_ERROR,
+ "key-directory '%s' already in use by zone %s with "
+ "policy %s: %s:%u",
+ keydir,
+ cfg_obj_asstring(cfg_tuple_get(exist, "name")),
+ cfg_obj_asstring(kasp), file, line);
+ return (ISC_R_EXISTS);
+ }
+
+ /*
+ * Add the new zone plus key-directory.
+ */
+ symkey = isc_mem_strdup(mctx, keydir);
+ symvalue.as_cpointer = zcfg;
+ result = isc_symtab_define(symtab, symkey, 2, symvalue,
+ isc_symexists_reject);
+ return (result);
+}
+
/*
* Check key list for duplicates key names and that the key names
* are valid domain names as these keys are used for TSIG.
@@ -3319,6 +3464,7 @@ static struct {
const char *v6;
} sources[] = { { "transfer-source", "transfer-source-v6" },
{ "notify-source", "notify-source-v6" },
+ { "parental-source", "parental-source-v6" },
{ "query-source", "query-source-v6" },
{ NULL, NULL } };
@@ -4203,8 +4349,8 @@ check_dnstap(const cfg_obj_t *voptions, const cfg_obj_t *config,
static isc_result_t
check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
const char *viewname, dns_rdataclass_t vclass,
- isc_symtab_t *files, bool check_plugins, isc_symtab_t *inview,
- isc_log_t *logctx, isc_mem_t *mctx) {
+ isc_symtab_t *files, isc_symtab_t *keydirs, bool check_plugins,
+ isc_symtab_t *inview, isc_log_t *logctx, isc_mem_t *mctx) {
const cfg_obj_t *zones = NULL;
const cfg_obj_t *view_tkeys = NULL, *global_tkeys = NULL;
const cfg_obj_t *view_mkeys = NULL, *global_mkeys = NULL;
@@ -4264,8 +4410,8 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
const cfg_obj_t *zone = cfg_listelt_value(element);
tresult = check_zoneconf(zone, voptions, config, symtab, files,
- inview, viewname, vclass, actx, logctx,
- mctx);
+ keydirs, inview, viewname, vclass,
+ actx, logctx, mctx);
if (tresult != ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
}
@@ -4878,6 +5024,7 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
isc_result_t tresult;
isc_symtab_t *symtab = NULL;
isc_symtab_t *files = NULL;
+ isc_symtab_t *keydirs = NULL;
isc_symtab_t *inview = NULL;
static const char *builtin[] = { "localhost", "localnets", "any",
@@ -4903,6 +5050,11 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
result = ISC_R_FAILURE;
}
+ if (bind9_check_parentalagentlists(config, logctx, mctx) !=
+ ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+
(void)cfg_map_get(config, "view", &views);
if (views != NULL && options != NULL) {
@@ -4929,6 +5081,12 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
goto cleanup;
}
+ tresult = isc_symtab_create(mctx, 100, freekey, mctx, false, &keydirs);
+ if (tresult != ISC_R_SUCCESS) {
+ result = tresult;
+ goto cleanup;
+ }
+
tresult = isc_symtab_create(mctx, 100, freekey, mctx, true, &inview);
if (tresult != ISC_R_SUCCESS) {
result = tresult;
@@ -4937,8 +5095,8 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
if (views == NULL) {
tresult = check_viewconf(config, NULL, NULL, dns_rdataclass_in,
- files, check_plugins, inview, logctx,
- mctx);
+ files, keydirs, check_plugins, inview,
+ logctx, mctx);
if (result == ISC_R_SUCCESS && tresult != ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
}
@@ -5029,8 +5187,8 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
}
if (tresult == ISC_R_SUCCESS) {
tresult = check_viewconf(config, voptions, key, vclass,
- files, check_plugins, inview,
- logctx, mctx);
+ files, keydirs, check_plugins,
+ inview, logctx, mctx);
}
if (tresult != ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
@@ -5149,6 +5307,9 @@ cleanup:
if (files != NULL) {
isc_symtab_destroy(&files);
}
+ if (keydirs != NULL) {
+ isc_symtab_destroy(&keydirs);
+ }
return (result);
}
diff --git a/external/mpl/bind/dist/lib/dns/cache.c b/external/mpl/bind/dist/lib/dns/cache.c
index e280cc2db50..5e48c0f2ef7 100644
--- a/external/mpl/bind/dist/lib/dns/cache.c
+++ b/external/mpl/bind/dist/lib/dns/cache.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cache.c,v 1.7 2021/04/05 11:29:49 rillig Exp $ */
+/* $NetBSD: cache.c,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -959,8 +959,9 @@ dns_cache_setcachesize(dns_cache_t *cache, size_t size) {
* time, or replacing other limits).
*/
isc_mem_setwater(cache->mctx, water, cache, hiwater, lowater);
- dns_db_adjusthashsize(cache->db, size);
}
+
+ dns_db_adjusthashsize(cache->db, size);
}
size_t
diff --git a/external/mpl/bind/dist/lib/dns/client.c b/external/mpl/bind/dist/lib/dns/client.c
index 5edcecd5ca3..547be3020a7 100644
--- a/external/mpl/bind/dist/lib/dns/client.c
+++ b/external/mpl/bind/dist/lib/dns/client.c
@@ -1,4 +1,4 @@
-/* $NetBSD: client.c,v 1.9 2021/04/05 11:27:01 rillig Exp $ */
+/* $NetBSD: client.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -410,92 +410,15 @@ createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, unsigned int options,
return (ISC_R_SUCCESS);
}
-isc_result_t
-dns_client_create(dns_client_t **clientp, unsigned int options) {
- isc_result_t result;
- isc_mem_t *mctx = NULL;
- isc_appctx_t *actx = NULL;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
-#if 0
- /* XXXMPA add debug logging support */
- isc_log_t *lctx = NULL;
- isc_logconfig_t *logconfig = NULL;
- unsigned int logdebuglevel = 0;
-#endif /* if 0 */
-
- isc_mem_create(&mctx);
- result = isc_appctx_create(mctx, &actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_app_ctxstart(actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_taskmgr_createinctx(mctx, 1, 0, &taskmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_socketmgr_createinctx(mctx, &socketmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_timermgr_createinctx(mctx, &timermgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-#if 0
- isc_log_create(mctx, &lctx, &logconfig);
- isc_log_setcontext(lctx);
- dns_log_init(lctx);
- dns_log_setcontext(lctx);
- result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- isc_log_setdebuglevel(lctx, logdebuglevel);
-#endif /* if 0 */
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr,
- options, clientp, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- (*clientp)->attributes |= DNS_CLIENTATTR_OWNCTX;
-
- /* client has its own reference to mctx, so we can detach it here */
- isc_mem_detach(&mctx);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- if (actx != NULL) {
- isc_appctx_destroy(&actx);
- }
- isc_mem_detach(&mctx);
-
- return (result);
-}
isc_result_t
-dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
- isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
- unsigned int options, dns_client_t **clientp,
- const isc_sockaddr_t *localaddr4,
- const isc_sockaddr_t *localaddr6) {
- dns_client_t *client;
+dns_client_create(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
+ isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
+ unsigned int options, dns_client_t **clientp,
+ const isc_sockaddr_t *localaddr4,
+ const isc_sockaddr_t *localaddr6) {
isc_result_t result;
+ dns_client_t *client;
dns_dispatchmgr_t *dispatchmgr = NULL;
dns_dispatch_t *dispatchv4 = NULL;
dns_dispatch_t *dispatchv6 = NULL;
@@ -633,21 +556,6 @@ destroyclient(dns_client_t *client) {
dns_dispatchmgr_destroy(&client->dispatchmgr);
isc_task_detach(&client->task);
-
- /*
- * If the client has created its own running environments,
- * destroy them.
- */
- if ((client->attributes & DNS_CLIENTATTR_OWNCTX) != 0) {
- isc_taskmgr_destroy(&client->taskmgr);
- isc_timermgr_destroy(&client->timermgr);
- isc_socketmgr_destroy(&client->socketmgr);
-
- isc_app_ctxfinish(client->actx);
- isc_appctx_destroy(&client->actx);
- }
-
- isc_mutex_destroy(&client->lock);
client->magic = 0;
isc_mem_putanddetach(&client->mctx, client, sizeof(*client));
diff --git a/external/mpl/bind/dist/lib/dns/dnssec.c b/external/mpl/bind/dist/lib/dns/dnssec.c
index 16ba566743a..f2724fea58c 100644
--- a/external/mpl/bind/dist/lib/dns/dnssec.c
+++ b/external/mpl/bind/dist/lib/dns/dnssec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dnssec.c,v 1.10 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: dnssec.c,v 1.11 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -13,6 +13,7 @@
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -1435,8 +1436,7 @@ dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory,
alg = 0;
for (i = len + 1 + 1; i < dir.entry.length; i++) {
- if (dir.entry.name[i] < '0' || dir.entry.name[i] > '9')
- {
+ if (!isdigit((unsigned char)dir.entry.name[i])) {
break;
}
alg *= 10;
@@ -1454,15 +1454,8 @@ dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory,
}
for (i++; i < dir.entry.length; i++) {
- if (dir.entry.name[i] < '0' || dir.entry.name[i] > '9')
- {
+ if (!isdigit((unsigned char)dir.entry.name[i])) {
break;
-
- /*
- * Did we not read exactly 5 more digits?
- * Did we overflow?
- * Did we correctly terminate?
- */
}
}
@@ -1659,7 +1652,7 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
dns_dnsseckeylist_t *keylist) {
dns_rdataset_t keys;
dns_rdata_t rdata = DNS_RDATA_INIT;
- dst_key_t *pubkey = NULL, *privkey = NULL;
+ dst_key_t *dnskey = NULL, *pubkey = NULL, *privkey = NULL;
isc_result_t result;
REQUIRE(keyset != NULL && dns_rdataset_isassociated(keyset));
@@ -1682,27 +1675,38 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
goto skip;
}
- RETERR(dns_dnssec_keyfromrdata(origin, &rdata, mctx, &pubkey));
- dst_key_setttl(pubkey, keys.ttl);
+ RETERR(dns_dnssec_keyfromrdata(origin, &rdata, mctx, &dnskey));
+ dst_key_setttl(dnskey, keys.ttl);
- if (!is_zone_key(pubkey) ||
- (dst_key_flags(pubkey) & DNS_KEYTYPE_NOAUTH) != 0) {
+ if (!is_zone_key(dnskey) ||
+ (dst_key_flags(dnskey) & DNS_KEYTYPE_NOAUTH) != 0) {
goto skip;
}
/* Corrupted .key file? */
- if (!dns_name_equal(origin, dst_key_name(pubkey))) {
+ if (!dns_name_equal(origin, dst_key_name(dnskey))) {
goto skip;
}
if (publickey) {
- RETERR(addkey(keylist, &pubkey, savekeys, mctx));
+ RETERR(addkey(keylist, &dnskey, savekeys, mctx));
goto skip;
}
+ /* Try to read the public key. */
result = dst_key_fromfile(
- dst_key_name(pubkey), dst_key_id(pubkey),
- dst_key_alg(pubkey),
+ dst_key_name(dnskey), dst_key_id(dnskey),
+ dst_key_alg(dnskey), (DST_TYPE_PUBLIC | DST_TYPE_STATE),
+ directory, mctx, &pubkey);
+ if (result == ISC_R_FILENOTFOUND || result == ISC_R_NOPERM) {
+ result = ISC_R_SUCCESS;
+ }
+ RETERR(result);
+
+ /* Now read the private key. */
+ result = dst_key_fromfile(
+ dst_key_name(dnskey), dst_key_id(dnskey),
+ dst_key_alg(dnskey),
(DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE),
directory, mctx, &privkey);
@@ -1713,22 +1717,22 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
*/
if (result == ISC_R_FILENOTFOUND) {
uint32_t flags;
- flags = dst_key_flags(pubkey);
+ flags = dst_key_flags(dnskey);
if ((flags & DNS_KEYFLAG_REVOKE) != 0) {
- dst_key_setflags(pubkey,
+ dst_key_setflags(dnskey,
flags & ~DNS_KEYFLAG_REVOKE);
result = dst_key_fromfile(
- dst_key_name(pubkey),
- dst_key_id(pubkey), dst_key_alg(pubkey),
+ dst_key_name(dnskey),
+ dst_key_id(dnskey), dst_key_alg(dnskey),
(DST_TYPE_PUBLIC | DST_TYPE_PRIVATE |
DST_TYPE_STATE),
directory, mctx, &privkey);
if (result == ISC_R_SUCCESS &&
- dst_key_pubcompare(pubkey, privkey, false))
+ dst_key_pubcompare(dnskey, privkey, false))
{
dst_key_setflags(privkey, flags);
}
- dst_key_setflags(pubkey, flags);
+ dst_key_setflags(dnskey, flags);
}
}
@@ -1741,8 +1745,8 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
isc_buffer_init(&buf, filename, NAME_MAX);
result2 = dst_key_getfilename(
- dst_key_name(pubkey), dst_key_id(pubkey),
- dst_key_alg(pubkey),
+ dst_key_name(dnskey), dst_key_id(dnskey),
+ dst_key_alg(dnskey),
(DST_TYPE_PUBLIC | DST_TYPE_PRIVATE |
DST_TYPE_STATE),
directory, mctx, &buf);
@@ -1750,13 +1754,13 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
char namebuf[DNS_NAME_FORMATSIZE];
char algbuf[DNS_SECALG_FORMATSIZE];
- dns_name_format(dst_key_name(pubkey), namebuf,
+ dns_name_format(dst_key_name(dnskey), namebuf,
sizeof(namebuf));
- dns_secalg_format(dst_key_alg(pubkey), algbuf,
+ dns_secalg_format(dst_key_alg(dnskey), algbuf,
sizeof(algbuf));
snprintf(filename, sizeof(filename) - 1,
"key file for %s/%s/%d", namebuf,
- algbuf, dst_key_id(pubkey));
+ algbuf, dst_key_id(dnskey));
}
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
@@ -1767,7 +1771,13 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
}
if (result == ISC_R_FILENOTFOUND || result == ISC_R_NOPERM) {
- RETERR(addkey(keylist, &pubkey, savekeys, mctx));
+ if (pubkey != NULL) {
+ RETERR(addkey(keylist, &pubkey, savekeys,
+ mctx));
+ } else {
+ RETERR(addkey(keylist, &dnskey, savekeys,
+ mctx));
+ }
goto skip;
}
RETERR(result);
@@ -1781,10 +1791,13 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, const char *directory,
* Whatever the key's default TTL may have
* been, the rdataset TTL takes priority.
*/
- dst_key_setttl(privkey, dst_key_getttl(pubkey));
+ dst_key_setttl(privkey, dst_key_getttl(dnskey));
RETERR(addkey(keylist, &privkey, savekeys, mctx));
skip:
+ if (dnskey != NULL) {
+ dst_key_free(&dnskey);
+ }
if (pubkey != NULL) {
dst_key_free(&pubkey);
}
@@ -1811,6 +1824,9 @@ failure:
if (dns_rdataset_isassociated(&keys)) {
dns_rdataset_disassociate(&keys);
}
+ if (dnskey != NULL) {
+ dst_key_free(&dnskey);
+ }
if (pubkey != NULL) {
dst_key_free(&pubkey);
}
diff --git a/external/mpl/bind/dist/lib/dns/dst_api.c b/external/mpl/bind/dist/lib/dns/dst_api.c
index ead021878a7..03eb7b68a98 100644
--- a/external/mpl/bind/dist/lib/dns/dst_api.c
+++ b/external/mpl/bind/dist/lib/dns/dst_api.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dst_api.c,v 1.10 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: dst_api.c,v 1.11 2021/08/19 11:50:17 christos Exp $ */
/*
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -99,7 +99,8 @@
#define NUMERIC_NTAGS (DST_MAX_NUMERIC + 1)
static const char *numerictags[NUMERIC_NTAGS] = {
- "Predecessor:", "Successor:", "MaxTTL:", "RollPeriod:", "Lifetime:"
+ "Predecessor:", "Successor:", "MaxTTL:", "RollPeriod:",
+ "Lifetime:", "DSPubCount:", "DSRemCount:"
};
#define BOOLEAN_NTAGS (DST_MAX_BOOLEAN + 1)
@@ -571,8 +572,8 @@ dst_key_fromnamedfile(const char *filename, const char *dirname, int type,
isc_mem_t *mctx, dst_key_t **keyp) {
isc_result_t result;
dst_key_t *pubkey = NULL, *key = NULL;
- char *newfilename = NULL;
- int newfilenamelen = 0;
+ char *newfilename = NULL, *statefilename = NULL;
+ int newfilenamelen = 0, statefilenamelen = 0;
isc_lex_t *lex = NULL;
REQUIRE(dst_initialized);
@@ -601,69 +602,58 @@ dst_key_fromnamedfile(const char *filename, const char *dirname, int type,
".key");
INSIST(result == ISC_R_SUCCESS);
- result = dst_key_read_public(newfilename, type, mctx, &pubkey);
+ RETERR(dst_key_read_public(newfilename, type, mctx, &pubkey));
isc_mem_put(mctx, newfilename, newfilenamelen);
- newfilename = NULL;
- RETERR(result);
+
+ /*
+ * Read the state file, if requested by type.
+ */
+ if ((type & DST_TYPE_STATE) != 0) {
+ statefilenamelen = strlen(filename) + 7;
+ if (dirname != NULL) {
+ statefilenamelen += strlen(dirname) + 1;
+ }
+ statefilename = isc_mem_get(mctx, statefilenamelen);
+ result = addsuffix(statefilename, statefilenamelen, dirname,
+ filename, ".state");
+ INSIST(result == ISC_R_SUCCESS);
+ }
+
+ pubkey->kasp = false;
+ if ((type & DST_TYPE_STATE) != 0) {
+ result = dst_key_read_state(statefilename, mctx, &pubkey);
+ if (result == ISC_R_SUCCESS) {
+ pubkey->kasp = true;
+ } else if (result == ISC_R_FILENOTFOUND) {
+ /* Having no state is valid. */
+ result = ISC_R_SUCCESS;
+ }
+ RETERR(result);
+ }
if ((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) == DST_TYPE_PUBLIC ||
(pubkey->key_flags & DNS_KEYFLAG_TYPEMASK) == DNS_KEYTYPE_NOKEY)
{
- result = computeid(pubkey);
- if (result != ISC_R_SUCCESS) {
- dst_key_free(&pubkey);
- return (result);
- }
-
+ RETERR(computeid(pubkey));
*keyp = pubkey;
- return (ISC_R_SUCCESS);
+ pubkey = NULL;
+ goto out;
}
- result = algorithm_status(pubkey->key_alg);
- if (result != ISC_R_SUCCESS) {
- dst_key_free(&pubkey);
- return (result);
- }
+ RETERR(algorithm_status(pubkey->key_alg));
key = get_key_struct(pubkey->key_name, pubkey->key_alg,
pubkey->key_flags, pubkey->key_proto,
pubkey->key_size, pubkey->key_class,
pubkey->key_ttl, mctx);
if (key == NULL) {
- dst_key_free(&pubkey);
- return (ISC_R_NOMEMORY);
+ RETERR(ISC_R_NOMEMORY);
}
if (key->func->parse == NULL) {
RETERR(DST_R_UNSUPPORTEDALG);
}
- /*
- * Read the state file, if requested by type.
- */
- if ((type & DST_TYPE_STATE) != 0) {
- newfilenamelen = strlen(filename) + 7;
- if (dirname != NULL) {
- newfilenamelen += strlen(dirname) + 1;
- }
- newfilename = isc_mem_get(mctx, newfilenamelen);
- result = addsuffix(newfilename, newfilenamelen, dirname,
- filename, ".state");
- INSIST(result == ISC_R_SUCCESS);
-
- key->kasp = false;
- result = dst_key_read_state(newfilename, mctx, &key);
- if (result == ISC_R_SUCCESS) {
- key->kasp = true;
- } else if (result == ISC_R_FILENOTFOUND) {
- /* Having no state is valid. */
- result = ISC_R_SUCCESS;
- }
- isc_mem_put(mctx, newfilename, newfilenamelen);
- newfilename = NULL;
- RETERR(result);
- }
-
newfilenamelen = strlen(filename) + 9;
if (dirname != NULL) {
newfilenamelen += strlen(dirname) + 1;
@@ -680,15 +670,26 @@ dst_key_fromnamedfile(const char *filename, const char *dirname, int type,
RETERR(key->func->parse(key, lex, pubkey));
isc_lex_destroy(&lex);
+ key->kasp = false;
+ if ((type & DST_TYPE_STATE) != 0) {
+ result = dst_key_read_state(statefilename, mctx, &key);
+ if (result == ISC_R_SUCCESS) {
+ key->kasp = true;
+ } else if (result == ISC_R_FILENOTFOUND) {
+ /* Having no state is valid. */
+ result = ISC_R_SUCCESS;
+ }
+ RETERR(result);
+ }
+
RETERR(computeid(key));
if (pubkey->key_id != key->key_id) {
RETERR(DST_R_INVALIDPRIVATEKEY);
}
- dst_key_free(&pubkey);
*keyp = key;
- return (ISC_R_SUCCESS);
+ key = NULL;
out:
if (pubkey != NULL) {
@@ -697,6 +698,9 @@ out:
if (newfilename != NULL) {
isc_mem_put(mctx, newfilename, newfilenamelen);
}
+ if (statefilename != NULL) {
+ isc_mem_put(mctx, statefilename, statefilenamelen);
+ }
if (lex != NULL) {
isc_lex_destroy(&lex);
}
@@ -1016,13 +1020,22 @@ dst_key_generate(const dns_name_t *name, unsigned int alg, unsigned int bits,
isc_result_t
dst_key_getbool(const dst_key_t *key, int type, bool *valuep) {
+ dst_key_t *k;
+
REQUIRE(VALID_KEY(key));
REQUIRE(valuep != NULL);
REQUIRE(type <= DST_MAX_BOOLEAN);
+
+ DE_CONST(key, k);
+
+ isc_mutex_lock(&k->mdlock);
if (!key->boolset[type]) {
+ isc_mutex_unlock(&k->mdlock);
return (ISC_R_NOTFOUND);
}
*valuep = key->bools[type];
+ isc_mutex_unlock(&k->mdlock);
+
return (ISC_R_SUCCESS);
}
@@ -1030,26 +1043,41 @@ void
dst_key_setbool(dst_key_t *key, int type, bool value) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_BOOLEAN);
+
+ isc_mutex_lock(&key->mdlock);
key->bools[type] = value;
key->boolset[type] = true;
+ isc_mutex_unlock(&key->mdlock);
}
void
dst_key_unsetbool(dst_key_t *key, int type) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_BOOLEAN);
+
+ isc_mutex_lock(&key->mdlock);
key->boolset[type] = false;
+ isc_mutex_unlock(&key->mdlock);
}
isc_result_t
dst_key_getnum(const dst_key_t *key, int type, uint32_t *valuep) {
+ dst_key_t *k;
+
REQUIRE(VALID_KEY(key));
REQUIRE(valuep != NULL);
REQUIRE(type <= DST_MAX_NUMERIC);
+
+ DE_CONST(key, k);
+
+ isc_mutex_lock(&k->mdlock);
if (!key->numset[type]) {
+ isc_mutex_unlock(&k->mdlock);
return (ISC_R_NOTFOUND);
}
*valuep = key->nums[type];
+ isc_mutex_unlock(&k->mdlock);
+
return (ISC_R_SUCCESS);
}
@@ -1057,26 +1085,40 @@ void
dst_key_setnum(dst_key_t *key, int type, uint32_t value) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_NUMERIC);
+
+ isc_mutex_lock(&key->mdlock);
key->nums[type] = value;
key->numset[type] = true;
+ isc_mutex_unlock(&key->mdlock);
}
void
dst_key_unsetnum(dst_key_t *key, int type) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_NUMERIC);
+
+ isc_mutex_lock(&key->mdlock);
key->numset[type] = false;
+ isc_mutex_unlock(&key->mdlock);
}
isc_result_t
dst_key_gettime(const dst_key_t *key, int type, isc_stdtime_t *timep) {
+ dst_key_t *k;
+
REQUIRE(VALID_KEY(key));
REQUIRE(timep != NULL);
REQUIRE(type <= DST_MAX_TIMES);
+
+ DE_CONST(key, k);
+
+ isc_mutex_lock(&k->mdlock);
if (!key->timeset[type]) {
+ isc_mutex_unlock(&k->mdlock);
return (ISC_R_NOTFOUND);
}
*timep = key->times[type];
+ isc_mutex_unlock(&k->mdlock);
return (ISC_R_SUCCESS);
}
@@ -1084,26 +1126,41 @@ void
dst_key_settime(dst_key_t *key, int type, isc_stdtime_t when) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_TIMES);
+
+ isc_mutex_lock(&key->mdlock);
key->times[type] = when;
key->timeset[type] = true;
+ isc_mutex_unlock(&key->mdlock);
}
void
dst_key_unsettime(dst_key_t *key, int type) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_TIMES);
+
+ isc_mutex_lock(&key->mdlock);
key->timeset[type] = false;
+ isc_mutex_unlock(&key->mdlock);
}
isc_result_t
dst_key_getstate(const dst_key_t *key, int type, dst_key_state_t *statep) {
+ dst_key_t *k;
+
REQUIRE(VALID_KEY(key));
REQUIRE(statep != NULL);
REQUIRE(type <= DST_MAX_KEYSTATES);
+
+ DE_CONST(key, k);
+
+ isc_mutex_lock(&k->mdlock);
if (!key->keystateset[type]) {
+ isc_mutex_unlock(&k->mdlock);
return (ISC_R_NOTFOUND);
}
*statep = key->keystates[type];
+ isc_mutex_unlock(&k->mdlock);
+
return (ISC_R_SUCCESS);
}
@@ -1111,15 +1168,21 @@ void
dst_key_setstate(dst_key_t *key, int type, dst_key_state_t state) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_KEYSTATES);
+
+ isc_mutex_lock(&key->mdlock);
key->keystates[type] = state;
key->keystateset[type] = true;
+ isc_mutex_unlock(&key->mdlock);
}
void
dst_key_unsetstate(dst_key_t *key, int type) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_KEYSTATES);
+
+ isc_mutex_lock(&key->mdlock);
key->keystateset[type] = false;
+ isc_mutex_unlock(&key->mdlock);
}
isc_result_t
@@ -1291,6 +1354,7 @@ dst_key_free(dst_key_t **keyp) {
if (key->key_tkeytoken) {
isc_buffer_free(&key->key_tkeytoken);
}
+ isc_mutex_destroy(&key->mdlock);
isc_safe_memwipe(key, sizeof(*key));
isc_mem_putanddetach(&mctx, key, sizeof(*key));
}
@@ -1486,6 +1550,7 @@ get_key_struct(const dns_name_t *name, unsigned int alg, unsigned int flags,
key->times[i] = 0;
key->timeset[i] = false;
}
+ isc_mutex_init(&key->mdlock);
key->inactive = false;
key->magic = KEY_MAGIC;
return (key);
@@ -2019,6 +2084,9 @@ write_key_state(const dst_key_t *key, int type, const char *directory) {
printtime(key, DST_TIME_SYNCPUBLISH, "PublishCDS", fp);
printtime(key, DST_TIME_SYNCDELETE, "DeleteCDS", fp);
+ printnum(key, DST_NUM_DSPUBCOUNT, "DSPubCount", fp);
+ printnum(key, DST_NUM_DSDELCOUNT, "DSDelCount", fp);
+
printtime(key, DST_TIME_DNSKEY, "DNSKEYChange", fp);
printtime(key, DST_TIME_ZRRSIG, "ZRRSIGChange", fp);
printtime(key, DST_TIME_KRRSIG, "KRRSIGChange", fp);
@@ -2377,20 +2445,31 @@ dst_key_is_unused(dst_key_t *key) {
return (true);
}
-static void
-get_ksk_zsk(dst_key_t *key, bool *ksk, bool *zsk) {
+isc_result_t
+dst_key_role(dst_key_t *key, bool *ksk, bool *zsk) {
bool k = false, z = false;
+ isc_result_t result, ret = ISC_R_SUCCESS;
- if (dst_key_getbool(key, DST_BOOL_KSK, &k) == ISC_R_SUCCESS) {
- *ksk = k;
- } else {
- *ksk = ((dst_key_flags(key) & DNS_KEYFLAG_KSK) != 0);
+ if (ksk != NULL) {
+ result = dst_key_getbool(key, DST_BOOL_KSK, &k);
+ if (result == ISC_R_SUCCESS) {
+ *ksk = k;
+ } else {
+ *ksk = ((dst_key_flags(key) & DNS_KEYFLAG_KSK) != 0);
+ ret = result;
+ }
}
- if (dst_key_getbool(key, DST_BOOL_ZSK, &z) == ISC_R_SUCCESS) {
- *zsk = z;
- } else {
- *zsk = ((dst_key_flags(key) & DNS_KEYFLAG_KSK) == 0);
+
+ if (zsk != NULL) {
+ result = dst_key_getbool(key, DST_BOOL_ZSK, &z);
+ if (result == ISC_R_SUCCESS) {
+ *zsk = z;
+ } else {
+ *zsk = ((dst_key_flags(key) & DNS_KEYFLAG_KSK) == 0);
+ ret = result;
+ }
}
+ return (ret);
}
/* Hints on key whether it can be published and/or used for signing. */
@@ -2449,7 +2528,7 @@ dst_key_is_active(dst_key_t *key, isc_stdtime_t now) {
time_ok = (when <= now);
}
- get_ksk_zsk(key, &ksk, &zsk);
+ (void)dst_key_role(key, &ksk, &zsk);
/* Check key states:
* KSK: If the DS is RUMOURED or OMNIPRESENT the key is considered
@@ -2510,7 +2589,7 @@ dst_key_is_signing(dst_key_t *key, int role, isc_stdtime_t now,
time_ok = (when <= now);
}
- get_ksk_zsk(key, &ksk, &zsk);
+ (void)dst_key_role(key, &ksk, &zsk);
/* Check key states:
* If the RRSIG state is RUMOURED or OMNIPRESENT, it means the key
diff --git a/external/mpl/bind/dist/lib/dns/dst_internal.h b/external/mpl/bind/dist/lib/dns/dst_internal.h
index 34450f20375..0552f2945a2 100644
--- a/external/mpl/bind/dist/lib/dns/dst_internal.h
+++ b/external/mpl/bind/dist/lib/dns/dst_internal.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dst_internal.h,v 1.6 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: dst_internal.h,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -96,6 +96,7 @@ typedef enum { DO_SIGN, DO_VERIFY } dst_use_t;
struct dst_key {
unsigned int magic;
isc_refcount_t refs;
+ isc_mutex_t mdlock; /*%< lock for read/write metadata */
dns_name_t *key_name; /*%< name of the key */
unsigned int key_size; /*%< size of the key in bits */
unsigned int key_proto; /*%< protocols this key is used for
diff --git a/external/mpl/bind/dist/lib/dns/dst_parse.c b/external/mpl/bind/dist/lib/dns/dst_parse.c
index 2b923a7b458..a4ba7aa0faa 100644
--- a/external/mpl/bind/dist/lib/dns/dst_parse.c
+++ b/external/mpl/bind/dist/lib/dns/dst_parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dst_parse.c,v 1.7 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: dst_parse.c,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -63,7 +63,7 @@ static const char *timetags[TIMING_NTAGS] = {
#define NUMERIC_NTAGS (DST_MAX_NUMERIC + 1)
static const char *numerictags[NUMERIC_NTAGS] = {
- "Predecessor:", "Successor:", "MaxTTL:", "RollPeriod:", NULL
+ "Predecessor:", "Successor:", "MaxTTL:", "RollPeriod:", NULL, NULL, NULL
};
struct parse_map {
diff --git a/external/mpl/bind/dist/lib/dns/dyndb.c b/external/mpl/bind/dist/lib/dns/dyndb.c
index e0ab9ec1ed9..9f0888fd8a6 100644
--- a/external/mpl/bind/dist/lib/dns/dyndb.c
+++ b/external/mpl/bind/dist/lib/dns/dyndb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dyndb.c,v 1.8 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: dyndb.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -124,7 +124,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
dns_dyndb_register_t *register_func = NULL;
dns_dyndb_destroy_t *destroy_func = NULL;
dns_dyndb_version_t *version_func = NULL;
- int version, flags;
+ int version;
REQUIRE(impp != NULL && *impp == NULL);
@@ -132,12 +132,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
ISC_LOG_INFO, "loading DynDB instance '%s' driver '%s'",
instname, filename);
- flags = RTLD_NOW | RTLD_LOCAL;
-#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__
- flags |= RTLD_DEEPBIND;
-#endif /* if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__ */
-
- handle = dlopen(filename, flags);
+ handle = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
if (handle == NULL) {
CHECK(ISC_R_FAILURE);
}
@@ -433,7 +428,7 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
dctx->timermgr = tmgr;
dctx->hashinit = hashinit;
dctx->lctx = lctx;
- dctx->refvar = &isc_bind9;
+ dctx->memdebug = &isc_mem_debugging;
isc_mem_attach(mctx, &dctx->mctx);
dctx->magic = DNS_DYNDBCTX_MAGIC;
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/client.h b/external/mpl/bind/dist/lib/dns/include/dns/client.h
index f9531732a61..e39b2e08cda 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/client.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/client.h
@@ -1,4 +1,4 @@
-/* $NetBSD: client.h,v 1.5 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: client.h,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -159,14 +159,11 @@ typedef struct dns_clientupdateevent {
} dns_clientupdateevent_t; /* too long? */
isc_result_t
-dns_client_create(dns_client_t **clientp, unsigned int options);
-
-isc_result_t
-dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
- isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
- unsigned int options, dns_client_t **clientp,
- const isc_sockaddr_t *localaddr4,
- const isc_sockaddr_t *localaddr6);
+dns_client_create(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
+ isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
+ unsigned int options, dns_client_t **clientp,
+ const isc_sockaddr_t *localaddr4,
+ const isc_sockaddr_t *localaddr6);
/*%<
* Create a DNS client. These functions create a new client object with
* minimal internal resources such as the default 'view' for the IN class and
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/db.h b/external/mpl/bind/dist/lib/dns/include/dns/db.h
index ea29410c5a8..b0bc54da247 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/db.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/db.h
@@ -1,4 +1,4 @@
-/* $NetBSD: db.h,v 1.6 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: db.h,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1402,14 +1402,15 @@ dns_db_hashsize(dns_db_t *db);
isc_result_t
dns_db_adjusthashsize(dns_db_t *db, size_t size);
/*%<
- * For database implementations using a hash table, adjust
- * the size of the hash table to store objects with size
- * memory footprint.
+ * For database implementations using a hash table, adjust the size of
+ * the hash table to store objects with a maximum total memory footprint
+ * of 'size' bytes. If 'size' is set to 0, it means no finite limit is
+ * requested.
*
* Requires:
*
* \li 'db' is a valid database.
- * \li 'size' is maximum memory footprint of the database
+ * \li 'size' is maximum memory footprint of the database in bytes
*
* Returns:
* \li #ISC_R_SUCCESS The registration succeeded
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/diff.h b/external/mpl/bind/dist/lib/dns/include/dns/diff.h
index 33451c170c0..5e43fef4031 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/diff.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/diff.h
@@ -1,4 +1,4 @@
-/* $NetBSD: diff.h,v 1.4 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: diff.h,v 1.5 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -68,6 +68,7 @@ typedef enum {
} dns_diffop_t;
typedef struct dns_difftuple dns_difftuple_t;
+typedef ISC_LIST(dns_difftuple_t) dns_difftuplelist_t;
#define DNS_DIFFTUPLE_MAGIC ISC_MAGIC('D', 'I', 'F', 'T')
#define DNS_DIFFTUPLE_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFFTUPLE_MAGIC)
@@ -94,9 +95,9 @@ typedef struct dns_diff dns_diff_t;
#define DNS_DIFF_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFF_MAGIC)
struct dns_diff {
- unsigned int magic;
- isc_mem_t * mctx;
- ISC_LIST(dns_difftuple_t) tuples;
+ unsigned int magic;
+ isc_mem_t * mctx;
+ dns_difftuplelist_t tuples;
};
/* Type of comparison function for sorting diffs. */
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/dyndb.h b/external/mpl/bind/dist/lib/dns/include/dns/dyndb.h
index d9ce171c3c5..d32a885f523 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/dyndb.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/dyndb.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dyndb.h,v 1.5 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: dyndb.h,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -42,7 +42,7 @@ struct dns_dyndbctx {
dns_zonemgr_t * zmgr;
isc_task_t * task;
isc_timermgr_t *timermgr;
- bool * refvar;
+ unsigned int * memdebug;
};
#define DNS_DYNDBCTX_MAGIC ISC_MAGIC('D', 'd', 'b', 'c')
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/events.h b/external/mpl/bind/dist/lib/dns/include/dns/events.h
index 5b03ed1382d..761e7086a12 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/events.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/events.h
@@ -1,4 +1,4 @@
-/* $NetBSD: events.h,v 1.5 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: events.h,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -82,6 +82,7 @@
#define DNS_EVENT_STARTUPDATE (ISC_EVENTCLASS_DNS + 58)
#define DNS_EVENT_TRYSTALE (ISC_EVENTCLASS_DNS + 59)
#define DNS_EVENT_ZONEFLUSH (ISC_EVENTCLASS_DNS + 60)
+#define DNS_EVENT_CHECKDSSENDTOADDR (ISC_EVENTCLASS_DNS + 61)
#define DNS_EVENT_FIRSTEVENT (ISC_EVENTCLASS_DNS + 0)
#define DNS_EVENT_LASTEVENT (ISC_EVENTCLASS_DNS + 65535)
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/keymgr.h b/external/mpl/bind/dist/lib/dns/include/dns/keymgr.h
index 495e853dd73..5d1b91588a0 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/keymgr.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/keymgr.h
@@ -1,4 +1,4 @@
-/* $NetBSD: keymgr.h,v 1.4 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: keymgr.h,v 1.5 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -28,12 +28,12 @@ ISC_LANG_BEGINDECLS
isc_result_t
dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
const char *directory, isc_mem_t *mctx,
- dns_dnsseckeylist_t *keyring, dns_kasp_t *kasp,
- isc_stdtime_t now, isc_stdtime_t *nexttime);
+ dns_dnsseckeylist_t *keyring, dns_dnsseckeylist_t *dnskeys,
+ dns_kasp_t *kasp, isc_stdtime_t now, isc_stdtime_t *nexttime);
/*%<
- * Manage keys in 'keylist' and update timing data according to 'kasp' policy.
+ * Manage keys in 'keyring' and update timing data according to 'kasp' policy.
* Create new keys for 'origin' if necessary in 'directory'. Append all such
- * keys, along with use hints gleaned from their metadata, onto 'keylist'.
+ * keys, along with use hints gleaned from their metadata, onto 'keyring'.
*
* Update key states and store changes back to disk. Store when to run next
* in 'nexttime'.
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/masterdump.h b/external/mpl/bind/dist/lib/dns/include/dns/masterdump.h
index ff2d9df9002..31fa1f6cba9 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/masterdump.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/masterdump.h
@@ -1,4 +1,4 @@
-/* $NetBSD: masterdump.h,v 1.5 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: masterdump.h,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -245,11 +245,11 @@ dns_dumpctx_db(dns_dumpctx_t *dctx);
/*@{*/
isc_result_t
-dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
- dns_dbversion_t * version,
- const dns_master_style_t *style, FILE *f,
- isc_task_t *task, dns_dumpdonefunc_t done,
- void *done_arg, dns_dumpctx_t **dctxp);
+dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db,
+ dns_dbversion_t * version,
+ const dns_master_style_t *style, FILE *f,
+ isc_task_t *task, dns_dumpdonefunc_t done,
+ void *done_arg, dns_dumpctx_t **dctxp);
isc_result_t
dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
@@ -261,11 +261,6 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
* 'format'. If the format is dns_masterformat_text (the RFC1035 format),
* 'style' specifies the file style (e.g., &dns_master_style_default).
*
- * dns_master_dumptostream() is an old form of dns_master_dumptostream3(),
- * which always specifies the dns_masterformat_text format.
- * dns_master_dumptostream2() is an old form which always specifies
- * a NULL header.
- *
* If 'format' is dns_masterformat_raw, then 'header' can contain
* information to be written to the file header.
*
@@ -278,7 +273,6 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
*
* Returns:
*\li ISC_R_SUCCESS
- *\li ISC_R_CONTINUE dns_master_dumptostreaminc() only.
*\li ISC_R_NOMEMORY
*\li Any database or rrset iterator error.
*\li Any dns_rdata_totext() error code.
@@ -288,11 +282,11 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
/*@{*/
isc_result_t
-dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
- const dns_master_style_t *style, const char *filename,
- isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
- dns_dumpctx_t **dctxp, dns_masterformat_t format,
- dns_masterrawheader_t *header);
+dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
+ const dns_master_style_t *style, const char *filename,
+ isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
+ dns_dumpctx_t **dctxp, dns_masterformat_t format,
+ dns_masterrawheader_t *header);
isc_result_t
dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
@@ -304,11 +298,6 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
* 'format'. If the format is dns_masterformat_text (the RFC1035 format),
* 'style' specifies the file style (e.g., &dns_master_style_default).
*
- * dns_master_dumpinc() and dns_master_dump() are old forms of _dumpinc3()
- * and _dump3(), respectively, which always specify the dns_masterformat_text
- * format. dns_master_dumpinc2() and dns_master_dump2() are old forms which
- * always specify a NULL header.
- *
* If 'format' is dns_masterformat_raw, then 'header' can contain
* information to be written to the file header.
*
@@ -316,7 +305,6 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
*
* Returns:
*\li ISC_R_SUCCESS
- *\li ISC_R_CONTINUE dns_master_dumpinc() only.
*\li ISC_R_NOMEMORY
*\li Any database or rrset iterator error.
*\li Any dns_rdata_totext() error code.
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/message.h b/external/mpl/bind/dist/lib/dns/include/dns/message.h
index 215655284a9..1dbe70385e8 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/message.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/message.h
@@ -1,4 +1,4 @@
-/* $NetBSD: message.h,v 1.9 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: message.h,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -76,8 +76,7 @@
* \code
* buffer = isc_buffer_allocate(mctx, 512);
* name = NULL;
- * name = dns_message_gettempname(message, &name);
- * dns_name_init(name, NULL);
+ * result = dns_message_gettempname(message, &name);
* result = dns_name_fromtext(name, &source, dns_rootname, 0, buffer);
* dns_message_takebuffer(message, &buffer);
* \endcode
@@ -892,24 +891,8 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item);
* to the message code using dns_message_puttempname() or inserted into
* one of the message's sections before the message is destroyed.
*
- * It is the caller's responsibility to initialize this name.
- *
- * Requires:
- *\li msg be a valid message
- *
- *\li item != NULL && *item == NULL
- *
- * Returns:
- *\li #ISC_R_SUCCESS -- All is well.
- *\li #ISC_R_NOMEMORY -- No item can be allocated.
- */
-
-isc_result_t
-dns_message_gettempoffsets(dns_message_t *msg, dns_offsets_t **item);
-/*%<
- * Return an offsets array that can be used for any temporary purpose,
- * such as attaching to a temporary name. The offsets will be freed
- * when the message is destroyed or reset.
+ * The name will be associated with a dns_fixedname object, and will
+ * be initialized.
*
* Requires:
*\li msg be a valid message
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/name.h b/external/mpl/bind/dist/lib/dns/include/dns/name.h
index ad21932a5db..06288d86bcc 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/name.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/name.h
@@ -1,4 +1,4 @@
-/* $NetBSD: name.h,v 1.7 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: name.h,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -640,7 +640,7 @@ dns_name_clone(const dns_name_t *source, dns_name_t *target);
* Notes:
*
* \li 'target' refers to the same memory as 'source', so 'source'
- * must not be changed while 'target' is still in use.
+ * must not be changed or freed while 'target' is still in use.
*
* \li This call is functionally equivalent to:
*
@@ -1244,22 +1244,17 @@ dns_name_settotextfilter(dns_name_totextfilter_t *proc);
isc_result_t
dns_name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target);
-void
-dns_name_copynf(const dns_name_t *source, dns_name_t *dest);
/*%<
- * Makes 'dest' refer to a copy of the name in 'source'. The data are either
- * copied to 'target' or in case of dns_name_copynf the dedicated buffer in
- * 'dest'.
+ * Copies the name in 'source' into 'dest'. The name data is copied to
+ * the 'target' buffer, which is then set as the buffer for 'dest'.
*
* Requires:
* \li 'source' is a valid name.
*
- * \li 'dest' is an initialized name with a dedicated buffer.
+ * \li 'dest' is an initialized name.
*
* \li 'target' is an initialized buffer.
*
- * \li Either dest has a dedicated buffer or target != NULL.
- *
* Ensures:
*
*\li On success, the used space in target is updated.
@@ -1269,6 +1264,18 @@ dns_name_copynf(const dns_name_t *source, dns_name_t *dest);
*\li #ISC_R_NOSPACE
*/
+void
+dns_name_copynf(const dns_name_t *source, dns_name_t *dest);
+/*%<
+ * Copies the name in 'source' into 'dest'. The name data is copied to
+ * the dedicated buffer for 'dest'.
+ *
+ * Requires:
+ * \li 'source' is a valid name.
+ *
+ * \li 'dest' is an initialized name with a dedicated buffer.
+ */
+
bool
dns_name_ishostname(const dns_name_t *name, bool wildcard);
/*%<
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/nsec3.h b/external/mpl/bind/dist/lib/dns/include/dns/nsec3.h
index 9af54f3a539..6c53c0e2ce6 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/nsec3.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/nsec3.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nsec3.h,v 1.5 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: nsec3.h,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -26,7 +26,8 @@
#include <dns/rdatastruct.h>
#include <dns/types.h>
-#define DNS_NSEC3_SALTSIZE 255
+#define DNS_NSEC3_SALTSIZE 255
+#define DNS_NSEC3_MAXITERATIONS 150U
/*
* hash = 1, flags =1, iterations = 2, salt length = 1, salt = 255 (max)
@@ -210,18 +211,10 @@ dns_nsec3_activex(dns_db_t *db, dns_dbversion_t *version, bool complete,
* 'answer' to be non NULL.
*/
-isc_result_t
-dns_nsec3_maxiterations(dns_db_t *db, dns_dbversion_t *version, isc_mem_t *mctx,
- unsigned int *iterationsp);
+unsigned int
+dns_nsec3_maxiterations(void);
/*%<
- * Find the maximum permissible number of iterations allowed based on
- * the key strength.
- *
- * Requires:
- * 'db' to be valid.
- * 'version' to be valid or NULL.
- * 'mctx' to be valid.
- * 'iterationsp' to be non NULL.
+ * Return the maximum permissible number of NSEC3 iterations.
*/
bool
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/rdata.h b/external/mpl/bind/dist/lib/dns/include/dns/rdata.h
index a30ca7f1e05..f34b2dc837e 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/rdata.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/rdata.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rdata.h,v 1.6 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: rdata.h,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -518,7 +518,7 @@ dns_rdata_tostruct(const dns_rdata_t *rdata, void *target, isc_mem_t *mctx);
*
* Requires:
*
- *\li 'rdata' is a valid, non-empty rdata.
+ *\li 'rdata' is a valid, non-empty, non-pseudo rdata.
*
*\li 'target' to point to a valid pointer for the type and class.
*
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h b/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h
index 8ab6af1ca0f..45ae15a7eb6 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rdataset.h,v 1.7 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: rdataset.h,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -97,7 +97,7 @@ typedef struct dns_rdatasetmethods {
* rdataset implementations may change any of the fields.
*/
struct dns_rdataset {
- unsigned int magic; /* XXX ? */
+ unsigned int magic;
dns_rdatasetmethods_t *methods;
ISC_LINK(dns_rdataset_t) link;
@@ -109,11 +109,7 @@ struct dns_rdataset {
dns_rdataclass_t rdclass;
dns_rdatatype_t type;
dns_ttl_t ttl;
- /*
- * Stale ttl is used to see how long this RRset can still be used
- * to serve to clients, after the TTL has expired.
- */
- dns_ttl_t stale_ttl;
+
dns_trust_t trust;
dns_rdatatype_t covers;
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/rpz.h b/external/mpl/bind/dist/lib/dns/include/dns/rpz.h
index 65290e1aac3..3f896ab992e 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/rpz.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/rpz.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rpz.h,v 1.7 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: rpz.h,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -98,10 +98,11 @@ typedef uint64_t dns_rpz_zbits_t;
* Mask of the specified and higher numbered policy zones
* Avoid hassles with (1<<33) or (1<<65)
*/
-#define DNS_RPZ_ZMASK(n) \
- ((dns_rpz_zbits_t)( \
- (((n) >= DNS_RPZ_MAX_ZONES - 1) ? 0 : (1ULL << ((n) + 1))) - \
- 1))
+#define DNS_RPZ_ZMASK(n) \
+ ((dns_rpz_zbits_t)((((n) >= DNS_RPZ_MAX_ZONES - 1) \
+ ? 0 \
+ : (1ULL << ((n) + 1))) - \
+ 1))
/*
* The trigger counter type.
diff --git a/external/mpl/bind/dist/lib/dns/include/dns/zone.h b/external/mpl/bind/dist/lib/dns/include/dns/zone.h
index 973e7ad6df5..4b6852d1cf8 100644
--- a/external/mpl/bind/dist/lib/dns/include/dns/zone.h
+++ b/external/mpl/bind/dist/lib/dns/include/dns/zone.h
@@ -1,4 +1,4 @@
-/* $NetBSD: zone.h,v 1.7 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: zone.h,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -352,6 +352,24 @@ dns_zone_getmaxttl(dns_zone_t *zone);
*\li dns_ttl_t maxttl.
*/
+void
+dns_zone_lock_keyfiles(dns_zone_t *zone);
+/*%<
+ * Lock associated keyfiles for this zone.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+void
+dns_zone_unlock_keyfiles(dns_zone_t *zone);
+/*%<
+ * Unlock associated keyfiles for this zone.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
isc_result_t
dns_zone_load(dns_zone_t *zone, bool newonly);
@@ -457,16 +475,6 @@ dns_zone_idetach(dns_zone_t **zonep);
*\li 'zonep' to point to a valid zone.
*/
-void
-dns_zone_setflag(dns_zone_t *zone, unsigned int flags, bool value);
-/*%<
- * Sets ('value' == 'true') / clears ('value' == 'IS_FALSE')
- * zone flags. Valid flag bits are DNS_ZONE_F_*.
- *
- * Requires
- *\li 'zone' to be a valid zone.
- */
-
isc_result_t
dns_zone_getdb(dns_zone_t *zone, dns_db_t **dbp);
/*%<
@@ -625,12 +633,29 @@ dns_zone_setprimarieswithkeys(dns_zone_t *zone, const isc_sockaddr_t *primaries,
*\li 'zone' to be a valid zone.
*\li 'primaries' array of isc_sockaddr_t with port set or NULL.
*\li 'count' the number of primaries.
- *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
+ *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
*
- * \li dns_zone_setprimaries() is just a wrapper to setprimarieswithkeys(),
- * passing NULL in the keynames field.
+ *\li If 'primaries' is NULL then 'count' must be zero.
*
- * \li If 'primaries' is NULL then 'count' must be zero.
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ *\li #ISC_R_NOMEMORY
+ *\li Any result dns_name_dup() can return, if keynames!=NULL
+ */
+
+isc_result_t
+dns_zone_setparentals(dns_zone_t *zone, const isc_sockaddr_t *parentals,
+ dns_name_t **keynames, uint32_t count);
+/*%<
+ * Set the list of parental agents for the zone.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *\li 'parentals' array of isc_sockaddr_t with port set or NULL.
+ *\li 'count' the number of primaries.
+ *\li 'keynames' array of dns_name_t's for tsig keys or NULL.
+ *
+ *\li If 'parentals' is NULL then 'count' must be zero.
*
* Returns:
*\li #ISC_R_SUCCESS
@@ -683,32 +708,6 @@ dns_zone_getkasp(dns_zone_t *zone);
*\li 'zone' to be a valid zone.
*/
-bool
-dns_zone_secure_to_insecure(dns_zone_t *zone, bool reconfig);
-/*%<
- * Returns true if the zone is transitioning to insecure.
- * Only can happen if a zone previously used a dnssec-policy,
- * but changed the value to "none" (or removed the configuration
- * option). If 'reconfig' is true, only check the key files,
- * because the zone structure is not yet updated with the
- * newest configuration.
- *
- * Require:
- *\li 'zone' to be a valid zone.
- */
-
-bool
-dns_zone_use_kasp(dns_zone_t *zone);
-/*%<
- * Check if zone needs to use kasp.
- * True if there is a policy that is not "none",
- * or if there are state files associated with the keys
- * related to this zone.
- *
- * Require:
- *\li 'zone' to be a valid zone.
- */
-
void
dns_zone_setkasp(dns_zone_t *zone, dns_kasp_t *kasp);
/*%<
@@ -901,6 +900,94 @@ dns_zone_setaltxfrsource6dscp(dns_zone_t *zone, isc_dscp_t dscp);
*/
isc_result_t
+dns_zone_setparentalsrc4(dns_zone_t *zone, const isc_sockaddr_t *parentalsrc);
+/*%<
+ * Set the source address to be used with IPv4 parental DS queries.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *\li 'parentalsrc' to contain the address.
+ *
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ */
+
+isc_sockaddr_t *
+dns_zone_getparentalsrc4(dns_zone_t *zone);
+/*%<
+ * Returns the source address set by a previous dns_zone_setparentalsrc4
+ * call, or the default of inaddr_any, port 0.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+isc_dscp_t
+dns_zone_getparentalsrc4dscp(dns_zone_t *zone);
+/*%/
+ * Get the DSCP value associated with the IPv4 parental source.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+isc_result_t
+dns_zone_setparentalsrc4dscp(dns_zone_t *zone, isc_dscp_t dscp);
+/*%<
+ * Set the DSCP value associated with the IPv4 parental source.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ */
+
+isc_result_t
+dns_zone_setparentalsrc6(dns_zone_t *zone, const isc_sockaddr_t *parentalsrc);
+/*%<
+ * Set the source address to be used with IPv6 parental DS queries.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *\li 'parentalsrc' to contain the address.
+ *
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ */
+
+isc_sockaddr_t *
+dns_zone_getparentalsrc6(dns_zone_t *zone);
+/*%<
+ * Returns the source address set by a previous dns_zone_setparentalsrc6
+ * call, or the default of in6addr_any, port 0.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+isc_dscp_t
+dns_zone_getparentalsrc6dscp(dns_zone_t *zone);
+/*%/
+ * Get the DSCP value associated with the IPv6 parental source.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+isc_result_t
+dns_zone_setparentalsrc6dscp(dns_zone_t *zone, isc_dscp_t dscp);
+/*%<
+ * Set the DSCP value associated with the IPv6 parental source.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ */
+
+isc_result_t
dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
/*%<
* Set the source address to be used with IPv4 NOTIFY messages.
@@ -1643,6 +1730,22 @@ dns_zone_getkeydirectory(dns_zone_t *zone);
*/
isc_result_t
+dns_zone_getdnsseckeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
+ isc_stdtime_t now, dns_dnsseckeylist_t *keys);
+/*%
+ * Find DNSSEC keys used for signing with dnssec-policy. Load these keys
+ * into 'keys'.
+ *
+ * Requires:
+ *\li 'zone' to be valid initialised zone.
+ *\li 'keys' to be an initialised DNSSEC keylist.
+ *
+ * Returns:
+ *\li #ISC_R_SUCCESS
+ *\li Error
+ */
+
+isc_result_t
dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
dns_zonemgr_t **zmgrp);
@@ -1758,6 +1861,12 @@ dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
*\li 'zone->zmgr' == NULL;
*/
+isc_taskmgr_t *
+dns_zonemgr_gettaskmgr(dns_zonemgr_t *zmgr);
+/*%
+ * Get the tasmkgr object attached to 'zmgr'.
+ */
+
void
dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, uint32_t value);
/*%<
@@ -1817,6 +1926,15 @@ dns_zonemgr_getiolimit(dns_zonemgr_t *zmgr);
*/
void
+dns_zonemgr_setcheckdsrate(dns_zonemgr_t *zmgr, unsigned int value);
+/*%<
+ * Set the number of parental DS queries sent per second.
+ *
+ * Requires:
+ *\li 'zmgr' to be a valid zone manager
+ */
+
+void
dns_zonemgr_setnotifyrate(dns_zonemgr_t *zmgr, unsigned int value);
/*%<
* Set the number of NOTIFY requests sent per second.
diff --git a/external/mpl/bind/dist/lib/dns/include/dst/dst.h b/external/mpl/bind/dist/lib/dns/include/dst/dst.h
index 0ce1846d5f0..5e8ab35fc55 100644
--- a/external/mpl/bind/dist/lib/dns/include/dst/dst.h
+++ b/external/mpl/bind/dist/lib/dns/include/dst/dst.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dst.h,v 1.7 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: dst.h,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -144,7 +144,9 @@ typedef enum dst_key_state {
#define DST_NUM_MAXTTL 2
#define DST_NUM_ROLLPERIOD 3
#define DST_NUM_LIFETIME 4
-#define DST_MAX_NUMERIC 4
+#define DST_NUM_DSPUBCOUNT 5
+#define DST_NUM_DSDELCOUNT 6
+#define DST_MAX_NUMERIC 6
/* Boolean metadata definitions */
#define DST_BOOL_KSK 0
@@ -1182,6 +1184,15 @@ dst_key_goal(dst_key_t *key);
* 'key' to be valid.
*/
+isc_result_t
+dst_key_role(dst_key_t *key, bool *ksk, bool *zsk);
+/*%<
+ * Get the key role. A key can have the KSK or the ZSK role, or both.
+ *
+ * Requires:
+ * 'key' to be valid.
+ */
+
void
dst_key_copy_metadata(dst_key_t *to, dst_key_t *from);
/*%<
diff --git a/external/mpl/bind/dist/lib/dns/journal.c b/external/mpl/bind/dist/lib/dns/journal.c
index 6e3494eb1da..cc9ee1090a1 100644
--- a/external/mpl/bind/dist/lib/dns/journal.c
+++ b/external/mpl/bind/dist/lib/dns/journal.c
@@ -1,4 +1,4 @@
-/* $NetBSD: journal.c,v 1.8 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: journal.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -856,6 +856,73 @@ ixfr_order(const void *av, const void *bv) {
return (r);
}
+static isc_result_t
+maybe_fixup_xhdr(dns_journal_t *j, journal_xhdr_t *xhdr, uint32_t serial,
+ isc_offset_t offset) {
+ isc_result_t result = ISC_R_SUCCESS;
+
+ /*
+ * Handle mixture of version 1 and version 2
+ * transaction headers in a version 1 journal.
+ */
+ if ((xhdr->serial0 != serial ||
+ isc_serial_le(xhdr->serial1, xhdr->serial0))) {
+ if (j->xhdr_version == XHDR_VERSION1 && xhdr->serial1 == serial)
+ {
+ isc_log_write(
+ JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
+ "%s: XHDR_VERSION1 -> XHDR_VERSION2 at %u",
+ j->filename, serial);
+ j->xhdr_version = XHDR_VERSION2;
+ CHECK(journal_seek(j, offset));
+ CHECK(journal_read_xhdr(j, xhdr));
+ j->recovered = true;
+ } else if (j->xhdr_version == XHDR_VERSION2 &&
+ xhdr->count == serial) {
+ isc_log_write(
+ JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
+ "%s: XHDR_VERSION2 -> XHDR_VERSION1 at %u",
+ j->filename, serial);
+ j->xhdr_version = XHDR_VERSION1;
+ CHECK(journal_seek(j, offset));
+ CHECK(journal_read_xhdr(j, xhdr));
+ j->recovered = true;
+ }
+ }
+
+ /*
+ * Handle <size, serial0, serial1, 0> transaction header.
+ */
+ if (j->xhdr_version == XHDR_VERSION1) {
+ uint32_t value;
+
+ CHECK(journal_read(j, &value, sizeof(value)));
+ if (value != 0L) {
+ CHECK(journal_seek(j, offset + 12));
+ } else {
+ isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
+ "%s: XHDR_VERSION1 count zero at %u",
+ j->filename, serial);
+ j->xhdr_version = XHDR_VERSION2;
+ j->recovered = true;
+ }
+ } else if (j->xhdr_version == XHDR_VERSION2 && xhdr->count == serial &&
+ xhdr->serial1 == 0U &&
+ isc_serial_gt(xhdr->serial0, xhdr->count))
+ {
+ isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
+ "%s: XHDR_VERSION2 count zero at %u", j->filename,
+ serial);
+ xhdr->serial1 = xhdr->serial0;
+ xhdr->serial0 = xhdr->count;
+ xhdr->count = 0;
+ j->recovered = true;
+ }
+
+failure:
+ return (result);
+}
+
/*
* Advance '*pos' to the next journal transaction.
*
@@ -873,7 +940,7 @@ ixfr_order(const void *av, const void *bv) {
* Other results due to file errors are possible.
*/
static isc_result_t
-journal_next(dns_journal_t *j, journal_pos_t *pos, bool retry) {
+journal_next(dns_journal_t *j, journal_pos_t *pos) {
isc_result_t result;
journal_xhdr_t xhdr;
size_t hdrsize;
@@ -898,46 +965,20 @@ journal_next(dns_journal_t *j, journal_pos_t *pos, bool retry) {
return (result);
}
+ if (j->header_ver1) {
+ CHECK(maybe_fixup_xhdr(j, &xhdr, pos->serial, pos->offset));
+ }
+
/*
* Check serial number consistency.
*/
if (xhdr.serial0 != pos->serial ||
isc_serial_le(xhdr.serial1, xhdr.serial0)) {
- if (j->header_ver1 && j->xhdr_version == XHDR_VERSION1 &&
- xhdr.serial1 == pos->serial && !retry)
- {
- /* XHDR_VERSION1 -> XHDR_VERSION2 */
- isc_log_write(
- JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
- "%s: XHDR_VERSION1 -> XHDR_VERSION2 at %u",
- j->filename, pos->serial);
- j->xhdr_version = XHDR_VERSION2;
- result = journal_next(j, pos, true);
- if (result == ISC_R_SUCCESS) {
- j->recovered = true;
- }
- return (result);
- } else if (j->header_ver1 && j->xhdr_version == XHDR_VERSION2 &&
- xhdr.count == pos->serial && !retry)
- {
- /* XHDR_VERSION2 -> XHDR_VERSION1 */
- isc_log_write(
- JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(3),
- "%s: XHDR_VERSION2 -> XHDR_VERSION1 at %u",
- j->filename, pos->serial);
- j->xhdr_version = XHDR_VERSION1;
- result = journal_next(j, pos, true);
- if (result == ISC_R_SUCCESS) {
- j->recovered = true;
- }
- return (result);
- } else {
- isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
- "%s: journal file corrupt: "
- "expected serial %u, got %u",
- j->filename, pos->serial, xhdr.serial0);
- return (ISC_R_UNEXPECTED);
- }
+ isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
+ "%s: journal file corrupt: "
+ "expected serial %u, got %u",
+ j->filename, pos->serial, xhdr.serial0);
+ return (ISC_R_UNEXPECTED);
}
/*
@@ -947,29 +988,6 @@ journal_next(dns_journal_t *j, journal_pos_t *pos, bool retry) {
? sizeof(journal_rawxhdr_t)
: sizeof(journal_rawxhdr_ver1_t);
- /*
- * Handle <size, serial0, serial1, 0> transaction header.
- */
- if (j->header_ver1 && j->xhdr_version == XHDR_VERSION1) {
- uint32_t value;
-
- CHECK(journal_read(j, &value, sizeof(value)));
- if (value != 0L) {
- CHECK(journal_seek(j, pos->offset + 12));
- } else {
- j->recovered = true;
- hdrsize += 4;
- }
- } else if (j->header_ver1 && j->xhdr_version == XHDR_VERSION2 &&
- xhdr.count == pos->serial && xhdr.serial1 == 0U &&
- isc_serial_ge(xhdr.serial0, xhdr.count))
- {
- xhdr.serial1 = xhdr.serial0;
- xhdr.serial0 = xhdr.count;
- xhdr.count = 0;
- j->recovered = true;
- }
-
if ((isc_offset_t)(pos->offset + hdrsize + xhdr.size) < pos->offset) {
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
"%s: offset too large", j->filename);
@@ -1116,7 +1134,7 @@ journal_find(dns_journal_t *j, uint32_t serial, journal_pos_t *pos) {
if (DNS_SERIAL_GT(current_pos.serial, serial)) {
return (ISC_R_NOTFOUND);
}
- result = journal_next(j, &current_pos, false);
+ result = journal_next(j, &current_pos);
if (result != ISC_R_SUCCESS) {
return (result);
}
@@ -1328,7 +1346,7 @@ dns_journal_commit(dns_journal_t *j) {
if (!JOURNAL_EMPTY(&j->header)) {
while (!DNS_SERIAL_GT(j->x.pos[1].serial,
j->header.begin.serial)) {
- CHECK(journal_next(j, &j->header.begin, false));
+ CHECK(journal_next(j, &j->header.begin));
}
index_invalidate(j, j->x.pos[1].serial);
}
@@ -1808,7 +1826,7 @@ dns_journal_get_sourceserial(dns_journal_t *j, uint32_t *sourceserial) {
*/
static isc_result_t
-read_one_rr(dns_journal_t *j, bool retry);
+read_one_rr(dns_journal_t *j);
/*
* Make sure the buffer 'b' is has at least 'size' bytes
@@ -1859,14 +1877,27 @@ dns_journal_iter_init(dns_journal_t *j, uint32_t begin_serial,
* adding up sizes and RR counts so we can calculate
* the IXFR size.
*/
- CHECK(journal_seek(j, pos.offset));
do {
+ CHECK(journal_seek(j, pos.offset));
CHECK(journal_read_xhdr(j, &xhdr));
+ if (j->header_ver1) {
+ CHECK(maybe_fixup_xhdr(j, &xhdr, pos.serial,
+ pos.offset));
+ }
+
+ /*
+ * Check that xhdr is consistent.
+ */
+ if (xhdr.serial0 != pos.serial ||
+ isc_serial_le(xhdr.serial1, xhdr.serial0)) {
+ CHECK(ISC_R_UNEXPECTED);
+ }
+
size += xhdr.size;
count += xhdr.count;
- result = journal_next(j, &pos, false);
+ result = journal_next(j, &pos);
if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
}
@@ -1902,14 +1933,14 @@ dns_journal_first_rr(dns_journal_t *j) {
j->it.xsize = 0; /* We have no transaction data yet... */
j->it.xpos = 0; /* ...and haven't used any of it. */
- return (read_one_rr(j, false));
+ return (read_one_rr(j));
failure:
return (result);
}
static isc_result_t
-read_one_rr(dns_journal_t *j, bool retry) {
+read_one_rr(dns_journal_t *j) {
isc_result_t result;
dns_rdatatype_t rdtype;
dns_rdataclass_t rdclass;
@@ -1940,34 +1971,15 @@ read_one_rr(dns_journal_t *j, bool retry) {
j->filename);
FAIL(ISC_R_UNEXPECTED);
}
+
+ if (j->header_ver1) {
+ CHECK(maybe_fixup_xhdr(j, &xhdr, j->it.current_serial,
+ save.offset));
+ }
+
if (xhdr.serial0 != j->it.current_serial ||
isc_serial_le(xhdr.serial1, xhdr.serial0))
{
- if (!retry && j->header_ver1 &&
- j->xhdr_version == XHDR_VERSION2 &&
- xhdr.count == j->it.current_serial)
- {
- /* XHDR_VERSION2 -> XHDR_VERSION1 */
- j->xhdr_version = XHDR_VERSION1;
- CHECK(journal_seek(j, save.offset));
- result = read_one_rr(j, true);
- if (result == ISC_R_SUCCESS) {
- j->recovered = true;
- }
- return (result);
- } else if (!retry && j->header_ver1 &&
- j->xhdr_version == XHDR_VERSION1 &&
- xhdr.serial1 == j->it.current_serial)
- {
- /* XHDR_VERSION1 -> XHDR_VERSION2 */
- j->xhdr_version = XHDR_VERSION2;
- CHECK(journal_seek(j, save.offset));
- result = read_one_rr(j, true);
- if (result == ISC_R_SUCCESS) {
- j->recovered = true;
- }
- return (result);
- }
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
"%s: journal file corrupt: "
"expected serial %u, got %u",
@@ -1976,29 +1988,6 @@ read_one_rr(dns_journal_t *j, bool retry) {
FAIL(ISC_R_UNEXPECTED);
}
- /*
- * Handle <size, serial0, serial1, 0> transaction header.
- */
- if (j->header_ver1 && j->xhdr_version == XHDR_VERSION1) {
- uint32_t value;
-
- CHECK(journal_read(j, &value, sizeof(value)));
- if (value != 0L) {
- CHECK(journal_seek(j, save.offset + 12));
- } else {
- j->recovered = true;
- }
- } else if (j->header_ver1 && j->xhdr_version == XHDR_VERSION2 &&
- xhdr.count == j->it.current_serial &&
- xhdr.serial1 == 0U &&
- isc_serial_ge(xhdr.serial0, xhdr.count))
- {
- xhdr.serial1 = xhdr.serial0;
- xhdr.serial0 = xhdr.count;
- xhdr.count = 0;
- j->recovered = true;
- }
-
j->it.xsize = xhdr.size;
j->it.xpos = 0;
}
@@ -2055,6 +2044,14 @@ read_one_rr(dns_journal_t *j, bool retry) {
ttl = isc_buffer_getuint32(&j->it.source);
rdlen = isc_buffer_getuint16(&j->it.source);
+ if (rdlen > DNS_RDATA_MAXLENGTH) {
+ isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
+ "%s: journal corrupt: impossible rdlen "
+ "(%u bytes)",
+ j->filename, rdlen);
+ FAIL(ISC_R_FAILURE);
+ }
+
/*
* Parse the rdata.
*/
@@ -2082,7 +2079,7 @@ failure:
isc_result_t
dns_journal_next_rr(dns_journal_t *j) {
- j->it.result = read_one_rr(j, false);
+ j->it.result = read_one_rr(j);
return (j->it.result);
}
@@ -2198,9 +2195,12 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
dns_difftuple_t *p[2];
int i, t;
bool append;
+ dns_difftuplelist_t add, del;
CHECK(dns_diff_sort(&diff[0], rdata_order));
CHECK(dns_diff_sort(&diff[1], rdata_order));
+ ISC_LIST_INIT(add);
+ ISC_LIST_INIT(del);
for (;;) {
p[0] = ISC_LIST_HEAD(diff[0].tuples);
@@ -2211,23 +2211,21 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
for (i = 0; i < 2; i++) {
if (p[!i] == NULL) {
- {
- ISC_LIST_UNLINK(diff[i].tuples, p[i],
- link);
- ISC_LIST_APPEND(r->tuples, p[i], link);
- goto next;
- }
+ dns_difftuplelist_t *l = (i == 0) ? &add : &del;
+ ISC_LIST_UNLINK(diff[i].tuples, p[i], link);
+ ISC_LIST_APPEND(*l, p[i], link);
+ goto next;
}
}
t = rdata_order(&p[0], &p[1]);
if (t < 0) {
ISC_LIST_UNLINK(diff[0].tuples, p[0], link);
- ISC_LIST_APPEND(r->tuples, p[0], link);
+ ISC_LIST_APPEND(add, p[0], link);
goto next;
}
if (t > 0) {
ISC_LIST_UNLINK(diff[1].tuples, p[1], link);
- ISC_LIST_APPEND(r->tuples, p[1], link);
+ ISC_LIST_APPEND(del, p[1], link);
goto next;
}
INSIST(t == 0);
@@ -2239,13 +2237,16 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
for (i = 0; i < 2; i++) {
ISC_LIST_UNLINK(diff[i].tuples, p[i], link);
if (append) {
- ISC_LIST_APPEND(r->tuples, p[i], link);
+ dns_difftuplelist_t *l = (i == 0) ? &add : &del;
+ ISC_LIST_APPEND(*l, p[i], link);
} else {
dns_difftuple_free(&p[i]);
}
}
next:;
}
+ ISC_LIST_APPENDLIST(r->tuples, del, link);
+ ISC_LIST_APPENDLIST(r->tuples, add, link);
result = ISC_R_SUCCESS;
failure:
return (result);
@@ -2496,6 +2497,11 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
}
/*
+ * Always perform a re-write when processing a version 1 journal.
+ */
+ rewrite = j1->header_ver1;
+
+ /*
* Check whether we need to rewrite the whole journal
* file (for example, to upversion it).
*/
@@ -2564,7 +2570,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
current_pos = best_guess;
while (current_pos.serial != serial) {
- CHECK(journal_next(j1, &current_pos, false));
+ CHECK(journal_next(j1, &current_pos));
if (current_pos.serial == j1->header.end.serial) {
break;
}
@@ -2582,7 +2588,8 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
INSIST(best_guess.serial != j1->header.end.serial);
if (best_guess.serial != serial) {
- CHECK(journal_next(j1, &best_guess, false));
+ CHECK(journal_next(j1, &best_guess));
+ serial = best_guess.serial;
}
/*
@@ -2619,6 +2626,14 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
CHECK(result);
size = xhdr.size;
+ if (size > len) {
+ isc_log_write(JOURNAL_COMMON_LOGARGS,
+ ISC_LOG_ERROR,
+ "%s: journal file corrupt, "
+ "transaction too large",
+ j1->filename);
+ CHECK(ISC_R_FAILURE);
+ }
buf = isc_mem_get(mctx, size);
result = journal_read(j1, buf, size);
@@ -2643,6 +2658,15 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
/* Check again */
isc_mem_put(mctx, buf, size);
size = xhdr.size;
+ if (size > len) {
+ isc_log_write(
+ JOURNAL_COMMON_LOGARGS,
+ ISC_LOG_ERROR,
+ "%s: journal file corrupt, "
+ "transaction too large",
+ j1->filename);
+ CHECK(ISC_R_FAILURE);
+ }
buf = isc_mem_get(mctx, size);
CHECK(journal_read(j1, buf, size));
@@ -2661,7 +2685,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
*/
if (j1->xhdr_version == XHDR_VERSION2 &&
xhdr.count == serial && xhdr.serial1 == 0U &&
- isc_serial_ge(xhdr.serial0, xhdr.count))
+ isc_serial_gt(xhdr.serial0, xhdr.count))
{
xhdr.serial1 = xhdr.serial0;
xhdr.serial0 = xhdr.count;
@@ -2727,7 +2751,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
current_pos = j2->header.begin;
while (current_pos.serial != j2->header.end.serial) {
index_add(j2, &current_pos);
- CHECK(journal_next(j2, &current_pos, false));
+ CHECK(journal_next(j2, &current_pos));
}
/*
diff --git a/external/mpl/bind/dist/lib/dns/keymgr.c b/external/mpl/bind/dist/lib/dns/keymgr.c
index 895da794510..daecd4b3eb5 100644
--- a/external/mpl/bind/dist/lib/dns/keymgr.c
+++ b/external/mpl/bind/dist/lib/dns/keymgr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keymgr.c,v 1.6 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: keymgr.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -394,6 +394,29 @@ keymgr_dnsseckey_kaspkey_match(dns_dnsseckey_t *dkey, dns_kasp_key_t *kkey) {
return (true);
}
+static bool
+keymgr_keyid_conflict(dst_key_t *newkey, dns_dnsseckeylist_t *keys) {
+ uint16_t id = dst_key_id(newkey);
+ uint32_t rid = dst_key_rid(newkey);
+ uint32_t alg = dst_key_alg(newkey);
+
+ for (dns_dnsseckey_t *dkey = ISC_LIST_HEAD(*keys); dkey != NULL;
+ dkey = ISC_LIST_NEXT(dkey, link))
+ {
+ if (dst_key_alg(dkey->key) != alg) {
+ continue;
+ }
+ if (dst_key_id(dkey->key) == id ||
+ dst_key_rid(dkey->key) == id ||
+ dst_key_id(dkey->key) == rid ||
+ dst_key_rid(dkey->key) == rid)
+ {
+ return (true);
+ }
+ }
+ return (false);
+}
+
/*
* Create a new key for 'origin' given the kasp key configuration 'kkey'.
* This will check for key id collisions with keys in 'keylist'.
@@ -403,20 +426,17 @@ keymgr_dnsseckey_kaspkey_match(dns_dnsseckey_t *dkey, dns_kasp_key_t *kkey) {
static isc_result_t
keymgr_createkey(dns_kasp_key_t *kkey, const dns_name_t *origin,
dns_rdataclass_t rdclass, isc_mem_t *mctx,
- dns_dnsseckeylist_t *keylist, dst_key_t **dst_key) {
- bool conflict;
+ dns_dnsseckeylist_t *keylist, dns_dnsseckeylist_t *newkeys,
+ dst_key_t **dst_key) {
+ bool conflict = false;
int keyflags = DNS_KEYOWNER_ZONE;
isc_result_t result = ISC_R_SUCCESS;
dst_key_t *newkey = NULL;
do {
- uint16_t id;
- uint32_t rid;
uint32_t algo = dns_kasp_key_algorithm(kkey);
int size = dns_kasp_key_size(kkey);
- conflict = false;
-
if (dns_kasp_key_ksk(kkey)) {
keyflags |= DNS_KEYFLAG_KSK;
}
@@ -425,28 +445,17 @@ keymgr_createkey(dns_kasp_key_t *kkey, const dns_name_t *origin,
&newkey, NULL));
/* Key collision? */
- id = dst_key_id(newkey);
- rid = dst_key_rid(newkey);
- for (dns_dnsseckey_t *dkey = ISC_LIST_HEAD(*keylist);
- dkey != NULL; dkey = ISC_LIST_NEXT(dkey, link))
- {
- if (dst_key_alg(dkey->key) != algo) {
- continue;
- }
- if (dst_key_id(dkey->key) == id ||
- dst_key_rid(dkey->key) == id ||
- dst_key_id(dkey->key) == rid ||
- dst_key_rid(dkey->key) == rid)
- {
- /* Try again. */
- conflict = true;
- isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
- DNS_LOGMODULE_DNSSEC,
- ISC_LOG_WARNING,
- "keymgr: key collision id %d",
- dst_key_id(newkey));
- dst_key_free(&newkey);
- }
+ conflict = keymgr_keyid_conflict(newkey, keylist);
+ if (!conflict) {
+ conflict = keymgr_keyid_conflict(newkey, newkeys);
+ }
+ if (conflict) {
+ /* Try again. */
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
+ DNS_LOGMODULE_DNSSEC, ISC_LOG_WARNING,
+ "keymgr: key collision id %d",
+ dst_key_id(newkey));
+ dst_key_free(&newkey);
}
} while (conflict);
@@ -1633,8 +1642,9 @@ static isc_result_t
keymgr_key_rollover(dns_kasp_key_t *kaspkey, dns_dnsseckey_t *active_key,
dns_dnsseckeylist_t *keyring, dns_dnsseckeylist_t *newkeys,
const dns_name_t *origin, dns_rdataclass_t rdclass,
- dns_kasp_t *kasp, uint32_t lifetime, isc_stdtime_t now,
- isc_stdtime_t *nexttime, isc_mem_t *mctx) {
+ dns_kasp_t *kasp, uint32_t lifetime, bool rollover,
+ isc_stdtime_t now, isc_stdtime_t *nexttime,
+ isc_mem_t *mctx) {
char keystr[DST_KEY_FORMATSIZE];
isc_stdtime_t retire = 0, active = 0, prepub = 0;
dns_dnsseckey_t *new_key = NULL;
@@ -1705,6 +1715,20 @@ keymgr_key_rollover(dns_kasp_key_t *kaspkey, dns_dnsseckey_t *active_key,
keystr, keymgr_keyrole(active_key->key),
dns_kasp_getname(kasp));
}
+
+ /*
+ * If rollover is not allowed, warn.
+ */
+ if (!rollover) {
+ dst_key_format(active_key->key, keystr, sizeof(keystr));
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
+ DNS_LOGMODULE_DNSSEC, ISC_LOG_WARNING,
+ "keymgr: DNSKEY %s (%s) is offline in "
+ "policy %s, cannot start rollover",
+ keystr, keymgr_keyrole(active_key->key),
+ dns_kasp_getname(kasp));
+ return (ISC_R_SUCCESS);
+ }
} else if (isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(1))) {
char namestr[DNS_NAME_FORMATSIZE];
dns_name_format(origin, namestr, sizeof(namestr));
@@ -1734,7 +1758,8 @@ keymgr_key_rollover(dns_kasp_key_t *kaspkey, dns_dnsseckey_t *active_key,
if (candidate == NULL) {
/* No key available in keyring, create a new one. */
isc_result_t result = keymgr_createkey(kaspkey, origin, rdclass,
- mctx, keyring, &dst_key);
+ mctx, keyring, newkeys,
+ &dst_key);
if (result != ISC_R_SUCCESS) {
return (result);
}
@@ -1921,8 +1946,8 @@ keymgr_purge_keyfile(dst_key_t *key, const char *dir, int type) {
isc_result_t
dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
const char *directory, isc_mem_t *mctx,
- dns_dnsseckeylist_t *keyring, dns_kasp_t *kasp,
- isc_stdtime_t now, isc_stdtime_t *nexttime) {
+ dns_dnsseckeylist_t *keyring, dns_dnsseckeylist_t *dnskeys,
+ dns_kasp_t *kasp, isc_stdtime_t now, isc_stdtime_t *nexttime) {
isc_result_t result = ISC_R_SUCCESS;
dns_dnsseckeylist_t newkeys;
dns_kasp_key_t *kkey;
@@ -1966,8 +1991,17 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
dst_key_format(dkey->key, keystr, sizeof(keystr));
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
DNS_LOGMODULE_DNSSEC, ISC_LOG_DEBUG(1),
- "keymgr: keyring: dnskey %s (policy %s)",
- keystr, dns_kasp_getname(kasp));
+ "keymgr: keyring: %s (policy %s)", keystr,
+ dns_kasp_getname(kasp));
+ }
+ for (dns_dnsseckey_t *dkey = ISC_LIST_HEAD(*dnskeys);
+ dkey != NULL; dkey = ISC_LIST_NEXT(dkey, link))
+ {
+ dst_key_format(dkey->key, keystr, sizeof(keystr));
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
+ DNS_LOGMODULE_DNSSEC, ISC_LOG_DEBUG(1),
+ "keymgr: dnskeys: %s (policy %s)", keystr,
+ dns_kasp_getname(kasp));
}
}
@@ -2021,6 +2055,7 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
{
uint32_t lifetime = dns_kasp_key_lifetime(kkey);
dns_dnsseckey_t *active_key = NULL;
+ bool rollover_allowed = true;
/* Do we have keys available for this kasp key? */
for (dns_dnsseckey_t *dkey = ISC_LIST_HEAD(*keyring);
@@ -2081,10 +2116,43 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
}
}
+ if (active_key == NULL) {
+ /*
+ * We didn't found an active key, perhaps the .private
+ * key file is offline. If so, we don't want to create
+ * a successor key. Check if we have an appropriate
+ * state file.
+ */
+ for (dns_dnsseckey_t *dnskey = ISC_LIST_HEAD(*dnskeys);
+ dnskey != NULL;
+ dnskey = ISC_LIST_NEXT(dnskey, link))
+ {
+ if (keymgr_dnsseckey_kaspkey_match(dnskey,
+ kkey)) {
+ /* Found a match. */
+ dst_key_format(dnskey->key, keystr,
+ sizeof(keystr));
+ isc_log_write(
+ dns_lctx,
+ DNS_LOGCATEGORY_DNSSEC,
+ DNS_LOGMODULE_DNSSEC,
+ ISC_LOG_DEBUG(1),
+ "keymgr: DNSKEY %s (%s) "
+ "offline, policy %s",
+ keystr,
+ keymgr_keyrole(dnskey->key),
+ dns_kasp_getname(kasp));
+ rollover_allowed = false;
+ active_key = dnskey;
+ break;
+ }
+ }
+ }
+
/* See if this key requires a rollover. */
- RETERR(keymgr_key_rollover(kkey, active_key, keyring, &newkeys,
- origin, rdclass, kasp, lifetime, now,
- nexttime, mctx));
+ RETERR(keymgr_key_rollover(
+ kkey, active_key, keyring, &newkeys, origin, rdclass,
+ kasp, lifetime, rollover_allowed, now, nexttime, mctx));
}
/* Walked all kasp key configurations. Append new keys. */
@@ -2179,6 +2247,19 @@ keymgr_checkds(dns_kasp_t *kasp, dns_dnsseckeylist_t *keyring,
dst_key_settime(ksk_key->key, DST_TIME_DSDELETE, when);
}
+ if (isc_log_wouldlog(dns_lctx, ISC_LOG_NOTICE)) {
+ char keystr[DST_KEY_FORMATSIZE];
+ char timestr[26]; /* Minimal buf as per ctime_r() spec. */
+
+ dst_key_format(ksk_key->key, keystr, sizeof(keystr));
+ isc_stdtime_tostring(when, timestr, sizeof(timestr));
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSSEC,
+ DNS_LOGMODULE_DNSSEC, ISC_LOG_NOTICE,
+ "keymgr: checkds DS for key %s seen %s at %s",
+ keystr, dspublish ? "published" : "withdrawn",
+ timestr);
+ }
+
/* Store key state and update hints. */
isc_dir_init(&dir);
if (directory == NULL) {
diff --git a/external/mpl/bind/dist/lib/dns/masterdump.c b/external/mpl/bind/dist/lib/dns/masterdump.c
index 08752cb1f9e..3796c1be1b7 100644
--- a/external/mpl/bind/dist/lib/dns/masterdump.c
+++ b/external/mpl/bind/dist/lib/dns/masterdump.c
@@ -1,4 +1,4 @@
-/* $NetBSD: masterdump.c,v 1.10 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: masterdump.c,v 1.11 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -256,7 +256,6 @@ struct dns_dumpctx {
isc_mutex_t lock;
isc_refcount_t references;
atomic_bool canceled;
- bool first;
bool do_date;
isc_stdtime_t now;
FILE *f;
@@ -267,8 +266,8 @@ struct dns_dumpctx {
isc_task_t *task;
dns_dumpdonefunc_t done;
void *done_arg;
- unsigned int nodes;
- /* dns_master_dumpinc() */
+ /* dns_master_dumpasync() */
+ isc_result_t result;
char *file;
char *tmpfile;
dns_masterformat_t format;
@@ -1110,17 +1109,13 @@ again:
} else {
isc_result_t result;
if (STALE(rds)) {
- fprintf(f,
- "; stale (will be retained for %u more "
- "seconds)\n",
- (rds->stale_ttl -
- ctx->serve_stale_ttl));
+ fprintf(f, "; stale\n");
} else if (ANCIENT(rds)) {
isc_buffer_t b;
char buf[sizeof("YYYYMMDDHHMMSS")];
memset(buf, 0, sizeof(buf));
isc_buffer_init(&b, buf, sizeof(buf) - 1);
- dns_time64_totext((uint64_t)rds->stale_ttl, &b);
+ dns_time64_totext((uint64_t)rds->ttl, &b);
fprintf(f,
"; expired since %s "
"(awaiting cleanup)\n",
@@ -1349,7 +1344,7 @@ dump_rdatasets_map(isc_mem_t *mctx, const dns_name_t *name,
static const int initial_buffer_length = 1200;
static isc_result_t
-dumptostreaminc(dns_dumpctx_t *dctx);
+dumptostream(dns_dumpctx_t *dctx);
static void
dumpctx_destroy(dns_dumpctx_t *dctx) {
@@ -1492,27 +1487,23 @@ closeandrename(FILE *f, isc_result_t result, const char *temp,
return (result);
}
+/*
+ * This will run in a libuv threadpool thread.
+ */
static void
-dump_quantum(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
- isc_result_t tresult;
- dns_dumpctx_t *dctx;
-
- REQUIRE(event != NULL);
- dctx = event->ev_arg;
+master_dump_cb(void *data) {
+ isc_result_t result = ISC_R_UNSET;
+ dns_dumpctx_t *dctx = data;
REQUIRE(DNS_DCTX_VALID(dctx));
+
if (atomic_load_acquire(&dctx->canceled)) {
result = ISC_R_CANCELED;
} else {
- result = dumptostreaminc(dctx);
- }
- if (result == DNS_R_CONTINUE) {
- event->ev_arg = dctx;
- isc_task_send(task, &event);
- return;
+ result = dumptostream(dctx);
}
if (dctx->file != NULL) {
+ isc_result_t tresult = ISC_R_UNSET;
tresult = closeandrename(dctx->f, result, dctx->tmpfile,
dctx->file);
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS) {
@@ -1521,17 +1512,51 @@ dump_quantum(isc_task_t *task, isc_event_t *event) {
} else {
result = flushandsync(dctx->f, result, NULL);
}
+
+ dctx->result = result;
+}
+
+/*
+ * This will run in a network/task manager thread when the dump is complete.
+ */
+static void
+master_dump_done_cb(void *data, isc_result_t result) {
+ dns_dumpctx_t *dctx = data;
+
+ if (result == ISC_R_SUCCESS && dctx->result != ISC_R_SUCCESS) {
+ result = dctx->result;
+ }
+
(dctx->done)(dctx->done_arg, result);
- isc_event_free(&event);
dns_dumpctx_detach(&dctx);
}
+/*
+ * This must be run from a network/task manager thread.
+ */
+static void
+setup_dump(isc_task_t *task, isc_event_t *event) {
+ dns_dumpctx_t *dctx = NULL;
+
+ REQUIRE(isc_nm_tid() >= 0);
+ REQUIRE(event != NULL);
+
+ dctx = event->ev_arg;
+
+ REQUIRE(DNS_DCTX_VALID(dctx));
+
+ isc_nm_work_offload(isc_task_getnetmgr(task), master_dump_cb,
+ master_dump_done_cb, dctx);
+
+ isc_event_free(&event);
+}
+
static isc_result_t
task_send(dns_dumpctx_t *dctx) {
isc_event_t *event;
event = isc_event_allocate(dctx->mctx, NULL, DNS_EVENT_DUMPQUANTUM,
- dump_quantum, dctx, sizeof(*event));
+ setup_dump, dctx, sizeof(*event));
isc_task_send(dctx->task, &event);
return (ISC_R_SUCCESS);
}
@@ -1554,8 +1579,6 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
dctx->done = NULL;
dctx->done_arg = NULL;
dctx->task = NULL;
- dctx->nodes = 0;
- dctx->first = true;
atomic_init(&dctx->canceled, false);
dctx->file = NULL;
dctx->tmpfile = NULL;
@@ -1593,14 +1616,8 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
dctx->do_date = dns_db_iscache(dctx->db);
if (dctx->do_date) {
- /*
- * Adjust the date backwards by the serve-stale TTL, if any.
- * This is so the TTL will be loaded correctly when next
- * started.
- */
(void)dns_db_getservestalettl(dctx->db,
&dctx->tctx.serve_stale_ttl);
- dctx->now -= dctx->tctx.serve_stale_ttl;
}
if (dctx->format == dns_masterformat_text &&
@@ -1714,14 +1731,12 @@ writeheader(dns_dumpctx_t *dctx) {
}
static isc_result_t
-dumptostreaminc(dns_dumpctx_t *dctx) {
+dumptostream(dns_dumpctx_t *dctx) {
isc_result_t result = ISC_R_SUCCESS;
isc_buffer_t buffer;
char *bufmem;
dns_name_t *name;
dns_fixedname_t fixname;
- unsigned int nodes;
- isc_time_t start;
bufmem = isc_mem_get(dctx->mctx, initial_buffer_length);
@@ -1729,34 +1744,25 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
name = dns_fixedname_initname(&fixname);
- if (dctx->first) {
- CHECK(writeheader(dctx));
-
- /*
- * Fast format is not currently written incrementally,
- * so we make the call to dns_db_serialize() here.
- * If the database is anything other than an rbtdb,
- * this should result in not implemented
- */
- if (dctx->format == dns_masterformat_map) {
- result = dns_db_serialize(dctx->db, dctx->version,
- dctx->f);
- goto cleanup;
- }
+ CHECK(writeheader(dctx));
- result = dns_dbiterator_first(dctx->dbiter);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE) {
- goto cleanup;
- }
+ /*
+ * Fast format is not currently written incrementally,
+ * so we make the call to dns_db_serialize() here.
+ * If the database is anything other than an rbtdb,
+ * this should result in not implemented
+ */
+ if (dctx->format == dns_masterformat_map) {
+ result = dns_db_serialize(dctx->db, dctx->version, dctx->f);
+ goto cleanup;
+ }
- dctx->first = false;
- } else {
- result = ISC_R_SUCCESS;
+ result = dns_dbiterator_first(dctx->dbiter);
+ if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE) {
+ goto cleanup;
}
- nodes = dctx->nodes;
- isc_time_now(&start);
- while (result == ISC_R_SUCCESS && (dctx->nodes == 0 || nodes--)) {
+ while (result == ISC_R_SUCCESS) {
dns_rdatasetiter_t *rdsiter = NULL;
dns_dbnode_t *node = NULL;
@@ -1775,6 +1781,10 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
}
dctx->tctx.neworigin = origin;
}
+
+ result = dns_dbiterator_pause(dctx->dbiter);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+
result = dns_db_allrdatasets(dctx->db, node, dctx->version,
dctx->now, &rdsiter);
if (result != ISC_R_SUCCESS) {
@@ -1792,52 +1802,7 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
result = dns_dbiterator_next(dctx->dbiter);
}
- /*
- * Work out how many nodes can be written in the time between
- * two requests to the nameserver. Smooth the resulting number and
- * use it as a estimate for the number of nodes to be written in the
- * next iteration.
- */
- if (dctx->nodes != 0 && result == ISC_R_SUCCESS) {
- unsigned int pps = dns_pps; /* packets per second */
- unsigned int interval;
- uint64_t usecs;
- isc_time_t end;
-
- isc_time_now(&end);
- if (pps < 100) {
- pps = 100;
- }
- interval = 1000000 / pps; /* interval in usecs */
- if (interval == 0) {
- interval = 1;
- }
- usecs = isc_time_microdiff(&end, &start);
- if (usecs == 0) {
- dctx->nodes = dctx->nodes * 2;
- if (dctx->nodes > 1000) {
- dctx->nodes = 1000;
- }
- } else {
- nodes = dctx->nodes * interval;
- nodes /= (unsigned int)usecs;
- if (nodes == 0) {
- nodes = 1;
- } else if (nodes > 1000) {
- nodes = 1000;
- }
-
- /* Smooth and assign. */
- dctx->nodes = (nodes + dctx->nodes * 7) / 8;
-
- isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL,
- DNS_LOGMODULE_MASTERDUMP,
- ISC_LOG_DEBUG(1),
- "dumptostreaminc(%p) new nodes -> %d",
- dctx, dctx->nodes);
- }
- result = DNS_R_CONTINUE;
- } else if (result == ISC_R_NOMORE) {
+ if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
}
cleanup:
@@ -1847,11 +1812,11 @@ cleanup:
}
isc_result_t
-dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
- dns_dbversion_t *version,
- const dns_master_style_t *style, FILE *f,
- isc_task_t *task, dns_dumpdonefunc_t done,
- void *done_arg, dns_dumpctx_t **dctxp) {
+dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db,
+ dns_dbversion_t *version,
+ const dns_master_style_t *style, FILE *f,
+ isc_task_t *task, dns_dumpdonefunc_t done,
+ void *done_arg, dns_dumpctx_t **dctxp) {
dns_dumpctx_t *dctx = NULL;
isc_result_t result;
@@ -1867,7 +1832,6 @@ dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db,
isc_task_attach(task, &dctx->task);
dctx->done = done;
dctx->done_arg = done_arg;
- dctx->nodes = 100;
result = task_send(dctx);
if (result == ISC_R_SUCCESS) {
@@ -1893,7 +1857,7 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
return (result);
}
- result = dumptostreaminc(dctx);
+ result = dumptostream(dctx);
INSIST(result != DNS_R_CONTINUE);
dns_dumpctx_detach(&dctx);
@@ -1929,6 +1893,11 @@ opentmp(isc_mem_t *mctx, dns_masterformat_t format, const char *file,
isc_result_totext(result));
goto cleanup;
}
+
+#if defined(POSIX_FADV_DONTNEED)
+ posix_fadvise(fileno(f), 0, 0, POSIX_FADV_DONTNEED);
+#endif
+
*tempp = tempname;
*fp = f;
return (ISC_R_SUCCESS);
@@ -1939,11 +1908,11 @@ cleanup:
}
isc_result_t
-dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
- const dns_master_style_t *style, const char *filename,
- isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
- dns_dumpctx_t **dctxp, dns_masterformat_t format,
- dns_masterrawheader_t *header) {
+dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
+ const dns_master_style_t *style, const char *filename,
+ isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
+ dns_dumpctx_t **dctxp, dns_masterformat_t format,
+ dns_masterrawheader_t *header) {
FILE *f = NULL;
isc_result_t result;
char *tempname = NULL;
@@ -1968,7 +1937,6 @@ dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
isc_task_attach(task, &dctx->task);
dctx->done = done;
dctx->done_arg = done_arg;
- dctx->nodes = 100;
dctx->file = file;
file = NULL;
dctx->tmpfile = tempname;
@@ -2013,7 +1981,7 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
goto cleanup;
}
- result = dumptostreaminc(dctx);
+ result = dumptostream(dctx);
INSIST(result != DNS_R_CONTINUE);
dns_dumpctx_detach(&dctx);
diff --git a/external/mpl/bind/dist/lib/dns/message.c b/external/mpl/bind/dist/lib/dns/message.c
index de0b3618192..78185d80a86 100644
--- a/external/mpl/bind/dist/lib/dns/message.c
+++ b/external/mpl/bind/dist/lib/dns/message.c
@@ -1,4 +1,4 @@
-/* $NetBSD: message.c,v 1.12 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: message.c,v 1.13 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -468,10 +468,7 @@ msgresetnames(dns_message_t *msg, unsigned int first_section) {
isc_mempool_put(msg->rdspool, rds);
rds = next_rds;
}
- if (dns_name_dynamic(name)) {
- dns_name_free(name, msg->mctx);
- }
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = next_name;
}
}
@@ -513,12 +510,8 @@ msgresetsigs(dns_message_t *msg, bool replying) {
isc_mempool_put(msg->rdspool, msg->querytsig);
}
}
- if (dns_name_dynamic(msg->tsigname)) {
- dns_name_free(msg->tsigname, msg->mctx);
- }
- isc_mempool_put(msg->namepool, msg->tsigname);
+ dns_message_puttempname(msg, &msg->tsigname);
msg->tsig = NULL;
- msg->tsigname = NULL;
} else if (msg->querytsig != NULL && !replying) {
dns_rdataset_disassociate(msg->querytsig);
isc_mempool_put(msg->rdspool, msg->querytsig);
@@ -529,10 +522,7 @@ msgresetsigs(dns_message_t *msg, bool replying) {
dns_rdataset_disassociate(msg->sig0);
isc_mempool_put(msg->rdspool, msg->sig0);
if (msg->sig0name != NULL) {
- if (dns_name_dynamic(msg->sig0name)) {
- dns_name_free(msg->sig0name, msg->mctx);
- }
- isc_mempool_put(msg->namepool, msg->sig0name);
+ dns_message_puttempname(msg, &msg->sig0name);
}
msg->sig0 = NULL;
msg->sig0name = NULL;
@@ -718,8 +708,8 @@ spacefortsig(dns_tsigkey_t *key, int otherlen) {
void
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
- dns_message_t *m;
- isc_buffer_t *dynbuf;
+ dns_message_t *m = NULL;
+ isc_buffer_t *dynbuf = NULL;
unsigned int i;
REQUIRE(mctx != NULL);
@@ -729,29 +719,23 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
intent == DNS_MESSAGE_INTENTRENDER);
m = isc_mem_get(mctx, sizeof(dns_message_t));
-
- m->magic = DNS_MESSAGE_MAGIC;
- m->from_to_wire = intent;
+ *m = (dns_message_t){ .from_to_wire = intent };
+ isc_mem_attach(mctx, &m->mctx);
msginit(m);
for (i = 0; i < DNS_SECTION_MAX; i++) {
ISC_LIST_INIT(m->sections[i]);
}
- m->mctx = NULL;
- isc_mem_attach(mctx, &m->mctx);
-
ISC_LIST_INIT(m->scratchpad);
ISC_LIST_INIT(m->cleanup);
- m->namepool = NULL;
- m->rdspool = NULL;
ISC_LIST_INIT(m->rdatas);
ISC_LIST_INIT(m->rdatalists);
ISC_LIST_INIT(m->offsets);
ISC_LIST_INIT(m->freerdata);
ISC_LIST_INIT(m->freerdatalist);
- isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
+ isc_mempool_create(m->mctx, sizeof(dns_fixedname_t), &m->namepool);
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
isc_mempool_setname(m->namepool, "msg:names");
@@ -761,13 +745,11 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
isc_mempool_setname(m->rdspool, "msg:rdataset");
- dynbuf = NULL;
isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
ISC_LIST_APPEND(m->scratchpad, dynbuf, link);
- m->cctx = NULL;
-
isc_refcount_init(&m->refcount, 1);
+ m->magic = DNS_MESSAGE_MAGIC;
*msgp = m;
}
@@ -987,41 +969,26 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
unsigned int options) {
isc_region_t r;
unsigned int count;
- dns_name_t *name;
- dns_name_t *name2;
- dns_offsets_t *offsets;
- dns_rdataset_t *rdataset;
- dns_rdatalist_t *rdatalist;
+ dns_name_t *name = NULL;
+ dns_name_t *name2 = NULL;
+ dns_rdataset_t *rdataset = NULL;
+ dns_rdatalist_t *rdatalist = NULL;
isc_result_t result;
dns_rdatatype_t rdtype;
dns_rdataclass_t rdclass;
- dns_namelist_t *section;
- bool free_name;
- bool best_effort;
- bool seen_problem;
-
- section = &msg->sections[DNS_SECTION_QUESTION];
-
- best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
- seen_problem = false;
-
- name = NULL;
- rdataset = NULL;
- rdatalist = NULL;
+ dns_namelist_t *section = &msg->sections[DNS_SECTION_QUESTION];
+ bool best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
+ bool seen_problem = false;
+ bool free_name = false;
for (count = 0; count < msg->counts[DNS_SECTION_QUESTION]; count++) {
- name = isc_mempool_get(msg->namepool);
- if (name == NULL) {
- return (ISC_R_NOMEMORY);
- }
- free_name = true;
-
- offsets = newoffsets(msg);
- if (offsets == NULL) {
- result = ISC_R_NOMEMORY;
+ name = NULL;
+ result = dns_message_gettempname(msg, &name);
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- dns_name_init(name, *offsets);
+ name->offsets = (unsigned char *)newoffsets(msg);
+ free_name = true;
/*
* Parse the name out of this packet.
@@ -1058,7 +1025,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
ISC_LIST_APPEND(*section, name, link);
free_name = false;
} else {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = name2;
name2 = NULL;
free_name = false;
@@ -1144,13 +1111,8 @@ cleanup:
INSIST(!dns_rdataset_isassociated(rdataset));
isc_mempool_put(msg->rdspool, rdataset);
}
-#if 0
- if (rdatalist != NULL) {
- isc_mempool_put(msg->rdlpool, rdatalist);
- }
-#endif /* if 0 */
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
return (result);
@@ -1231,25 +1193,19 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
unsigned int count, rdatalen;
dns_name_t *name = NULL;
dns_name_t *name2 = NULL;
- dns_offsets_t *offsets;
dns_rdataset_t *rdataset = NULL;
- dns_rdatalist_t *rdatalist;
+ dns_rdatalist_t *rdatalist = NULL;
isc_result_t result;
dns_rdatatype_t rdtype, covers;
dns_rdataclass_t rdclass;
- dns_rdata_t *rdata;
+ dns_rdata_t *rdata = NULL;
dns_ttl_t ttl;
- dns_namelist_t *section;
- bool free_name = false, free_rdataset = false;
- bool preserve_order, best_effort, seen_problem;
+ dns_namelist_t *section = &msg->sections[sectionid];
+ bool free_name = false, free_rdataset = false, seen_problem = false;
+ bool preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0);
+ bool best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
bool isedns, issigzero, istsig;
- preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0);
- best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
- seen_problem = false;
-
- section = &msg->sections[sectionid];
-
for (count = 0; count < msg->counts[sectionid]; count++) {
int recstart = source->current;
bool skip_name_search, skip_type_search;
@@ -1261,18 +1217,13 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
issigzero = false;
istsig = false;
- name = isc_mempool_get(msg->namepool);
- if (name == NULL) {
- return (ISC_R_NOMEMORY);
- }
- free_name = true;
-
- offsets = newoffsets(msg);
- if (offsets == NULL) {
- result = ISC_R_NOMEMORY;
+ name = NULL;
+ result = dns_message_gettempname(msg, &name);
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- dns_name_init(name, *offsets);
+ name->offsets = (unsigned char *)newoffsets(msg);
+ free_name = true;
/*
* Parse the name out of this packet.
@@ -1509,7 +1460,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
* If it is a new name, append to the section.
*/
if (result == ISC_R_SUCCESS) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = name2;
} else {
ISC_LIST_APPEND(*section, name, link);
@@ -1626,11 +1577,11 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
msg->opt = rdataset;
rdataset = NULL;
free_rdataset = false;
- ercode = (dns_rcode_t)(
- (msg->opt->ttl & DNS_MESSAGE_EDNSRCODE_MASK) >>
- 20);
+ ercode = (dns_rcode_t)((msg->opt->ttl &
+ DNS_MESSAGE_EDNSRCODE_MASK) >>
+ 20);
msg->rcode |= ercode;
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
free_name = false;
} else if (issigzero) {
msg->sig0 = rdataset;
@@ -1654,7 +1605,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
if (seen_problem) {
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
if (free_rdataset) {
isc_mempool_put(msg->rdspool, rdataset);
@@ -1686,7 +1637,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
cleanup:
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
if (free_rdataset) {
isc_mempool_put(msg->rdspool, rdataset);
@@ -2570,27 +2521,16 @@ dns_message_removename(dns_message_t *msg, dns_name_t *name,
isc_result_t
dns_message_gettempname(dns_message_t *msg, dns_name_t **item) {
- REQUIRE(DNS_MESSAGE_VALID(msg));
- REQUIRE(item != NULL && *item == NULL);
-
- *item = isc_mempool_get(msg->namepool);
- if (*item == NULL) {
- return (ISC_R_NOMEMORY);
- }
- dns_name_init(*item, NULL);
+ dns_fixedname_t *fn = NULL;
- return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-dns_message_gettempoffsets(dns_message_t *msg, dns_offsets_t **item) {
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(item != NULL && *item == NULL);
- *item = newoffsets(msg);
- if (*item == NULL) {
+ fn = isc_mempool_get(msg->namepool);
+ if (fn == NULL) {
return (ISC_R_NOMEMORY);
}
+ *item = dns_fixedname_initname(fn);
return (ISC_R_SUCCESS);
}
@@ -2619,7 +2559,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item) {
}
dns_rdataset_init(*item);
-
return (ISC_R_SUCCESS);
}
@@ -2638,18 +2577,29 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item) {
void
dns_message_puttempname(dns_message_t *msg, dns_name_t **itemp) {
- dns_name_t *item;
+ dns_name_t *item = NULL;
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(itemp != NULL && *itemp != NULL);
+
item = *itemp;
*itemp = NULL;
+
REQUIRE(!ISC_LINK_LINKED(item, link));
REQUIRE(ISC_LIST_HEAD(item->list) == NULL);
+ /*
+ * we need to check this in case dns_name_dup() was used.
+ */
if (dns_name_dynamic(item)) {
dns_name_free(item, msg->mctx);
}
+
+ /*
+ * 'name' is the first field in dns_fixedname_t, so putting
+ * back the address of name is the same as putting back
+ * the fixedname.
+ */
isc_mempool_put(msg->namepool, item);
}
diff --git a/external/mpl/bind/dist/lib/dns/name.c b/external/mpl/bind/dist/lib/dns/name.c
index 873cf2db2d1..4f66580656a 100644
--- a/external/mpl/bind/dist/lib/dns/name.c
+++ b/external/mpl/bind/dist/lib/dns/name.c
@@ -1,4 +1,4 @@
-/* $NetBSD: name.c,v 1.9 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: name.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1206,7 +1206,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
POST(state);
/* FALLTHROUGH */
case ft_escape:
- if (!isdigit(c & 0xff)) {
+ if (!isdigit((unsigned char)c)) {
if (count >= 63) {
return (DNS_R_LABELTOOLONG);
}
@@ -1226,7 +1226,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
state = ft_escdecimal;
/* FALLTHROUGH */
case ft_escdecimal:
- if (!isdigit(c & 0xff)) {
+ if (!isdigit((unsigned char)c)) {
return (DNS_R_BADESCAPE);
}
value *= 10;
@@ -1266,6 +1266,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
}
if (state == ft_ordinary) {
INSIST(count != 0);
+ INSIST(label != NULL);
*label = count;
labels++;
INSIST(labels <= 127);
@@ -2465,7 +2466,7 @@ dns_name_fromstring2(dns_name_t *target, const char *src,
static isc_result_t
name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) {
- unsigned char *ndata;
+ unsigned char *ndata = NULL;
/*
* Make dest a copy of source.
@@ -2497,7 +2498,7 @@ name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) {
}
if (dest->labels > 0 && dest->offsets != NULL) {
- if (source->offsets != NULL) {
+ if (source->offsets != NULL && source->labels != 0) {
memmove(dest->offsets, source->offsets, source->labels);
} else {
set_offsets(dest, dest->offsets, NULL);
diff --git a/external/mpl/bind/dist/lib/dns/nsec3.c b/external/mpl/bind/dist/lib/dns/nsec3.c
index 3be7ab97bc2..eeadcf6734f 100644
--- a/external/mpl/bind/dist/lib/dns/nsec3.c
+++ b/external/mpl/bind/dist/lib/dns/nsec3.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nsec3.c,v 1.8 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: nsec3.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1880,78 +1880,9 @@ try_private:
return (result);
}
-isc_result_t
-dns_nsec3_maxiterations(dns_db_t *db, dns_dbversion_t *version, isc_mem_t *mctx,
- unsigned int *iterationsp) {
- dns_dbnode_t *node = NULL;
- dns_rdataset_t rdataset;
- dst_key_t *key = NULL;
- isc_buffer_t buffer;
- isc_result_t result;
- unsigned int bits, minbits = 4096;
-
- result = dns_db_getoriginnode(db, &node);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- dns_rdataset_init(&rdataset);
- result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey, 0,
- 0, &rdataset, NULL);
- dns_db_detachnode(db, &node);
- if (result == ISC_R_NOTFOUND) {
- *iterationsp = 0;
- return (ISC_R_SUCCESS);
- }
- if (result != ISC_R_SUCCESS) {
- goto failure;
- }
-
- for (result = dns_rdataset_first(&rdataset); result == ISC_R_SUCCESS;
- result = dns_rdataset_next(&rdataset))
- {
- dns_rdata_t rdata = DNS_RDATA_INIT;
- dns_rdataset_current(&rdataset, &rdata);
-
- REQUIRE(rdata.type == dns_rdatatype_key ||
- rdata.type == dns_rdatatype_dnskey);
- REQUIRE(rdata.length > 3);
-
- /* Skip unsupported algorithms when
- * calculating the maximum iterations.
- */
- if (!dst_algorithm_supported(rdata.data[3])) {
- continue;
- }
-
- isc_buffer_init(&buffer, rdata.data, rdata.length);
- isc_buffer_add(&buffer, rdata.length);
- CHECK(dst_key_fromdns(dns_db_origin(db), rdataset.rdclass,
- &buffer, mctx, &key));
- bits = dst_key_size(key);
- dst_key_free(&key);
- if (minbits > bits) {
- minbits = bits;
- }
- }
- if (result != ISC_R_NOMORE) {
- goto failure;
- }
-
- if (minbits <= 1024) {
- *iterationsp = 150;
- } else if (minbits <= 2048) {
- *iterationsp = 500;
- } else {
- *iterationsp = 2500;
- }
- result = ISC_R_SUCCESS;
-
-failure:
- if (dns_rdataset_isassociated(&rdataset)) {
- dns_rdataset_disassociate(&rdataset);
- }
- return (result);
+unsigned int
+dns_nsec3_maxiterations(void) {
+ return (DNS_NSEC3_MAXITERATIONS);
}
isc_result_t
@@ -2093,6 +2024,13 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, const dns_name_t *name,
first = true;
while (qlabels >= zlabels) {
+ /*
+ * If there are too many iterations reject the NSEC3 record.
+ */
+ if (nsec3.iterations > DNS_NSEC3_MAXITERATIONS) {
+ return (DNS_R_NSEC3ITERRANGE);
+ }
+
length = isc_iterated_hash(hash, nsec3.hash, nsec3.iterations,
nsec3.salt, nsec3.salt_length,
qname->ndata, qname->length);
diff --git a/external/mpl/bind/dist/lib/dns/openssl_link.c b/external/mpl/bind/dist/lib/dns/openssl_link.c
index 02fcb1320ae..651561dbf38 100644
--- a/external/mpl/bind/dist/lib/dns/openssl_link.c
+++ b/external/mpl/bind/dist/lib/dns/openssl_link.c
@@ -1,4 +1,4 @@
-/* $NetBSD: openssl_link.c,v 1.6 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: openssl_link.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -31,7 +31,6 @@
#include <isc/platform.h>
#include <isc/string.h>
#include <isc/thread.h>
-#include <isc/tls.h>
#include <isc/util.h>
#include <dns/log.h>
diff --git a/external/mpl/bind/dist/lib/dns/rbt.c b/external/mpl/bind/dist/lib/dns/rbt.c
index a462dce667c..78c045f79e4 100644
--- a/external/mpl/bind/dist/lib/dns/rbt.c
+++ b/external/mpl/bind/dist/lib/dns/rbt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rbt.c,v 1.9 2021/04/05 11:29:49 rillig Exp $ */
+/* $NetBSD: rbt.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1084,11 +1084,28 @@ isc_result_t
dns_rbt_adjusthashsize(dns_rbt_t *rbt, size_t size) {
REQUIRE(VALID_RBT(rbt));
- size_t newsize = size / RBT_HASH_BUCKETSIZE;
-
- rbt->maxhashbits = rehash_bits(rbt, newsize);
-
- maybe_rehash(rbt, newsize);
+ if (size > 0) {
+ /*
+ * Setting a new, finite size limit was requested for the RBT.
+ * Estimate how many hash table slots are needed for the
+ * requested size and how many bits would be needed to index
+ * those hash table slots, then rehash the RBT if necessary.
+ * Note that the hash table can only grow, it is not shrunk if
+ * the requested size limit is lower than the current one.
+ */
+ size_t newsize = size / RBT_HASH_BUCKETSIZE;
+ rbt->maxhashbits = rehash_bits(rbt, newsize);
+ maybe_rehash(rbt, newsize);
+ } else {
+ /*
+ * Setting an infinite size limit was requested for the RBT.
+ * Increase the maximum allowed number of hash table slots to
+ * 2^32, which enables the hash table to grow as nodes are
+ * added to the RBT without immediately preallocating 2^32 hash
+ * table slots.
+ */
+ rbt->maxhashbits = RBT_HASH_MAX_BITS;
+ }
return (ISC_R_SUCCESS);
}
@@ -2341,7 +2358,7 @@ static uint32_t
rehash_bits(dns_rbt_t *rbt, size_t newcount) {
uint32_t newbits = rbt->hashbits;
- while (newcount >= HASHSIZE(newbits) && newbits < rbt->maxhashbits) {
+ while (newcount >= HASHSIZE(newbits) && newbits < RBT_HASH_MAX_BITS) {
newbits += 1;
}
diff --git a/external/mpl/bind/dist/lib/dns/rbtdb.c b/external/mpl/bind/dist/lib/dns/rbtdb.c
index 75356bb261d..9a70342a9c4 100644
--- a/external/mpl/bind/dist/lib/dns/rbtdb.c
+++ b/external/mpl/bind/dist/lib/dns/rbtdb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rbtdb.c,v 1.13 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: rbtdb.c,v 1.14 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,6 +15,7 @@
/* #define inline */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -349,7 +350,7 @@ typedef ISC_LIST(dns_rbtnode_t) rbtnodelist_t;
(((header)->rdh_ttl > (now)) || \
((header)->rdh_ttl == (now) && ZEROTTL(header)))
-#define DEFAULT_NODE_LOCK_COUNT 53 /*%< Should be prime. */
+#define DEFAULT_NODE_LOCK_COUNT 7 /*%< Should be prime. */
#define RBTDB_GLUE_TABLE_INIT_BITS 2U
#define RBTDB_GLUE_TABLE_MAX_BITS 32U
#define RBTDB_GLUE_TABLE_OVERCOMMIT 3
@@ -381,7 +382,7 @@ hash_32(uint32_t val, unsigned int bits) {
#define DEFAULT_CACHE_NODE_LOCK_COUNT DNS_RBTDB_CACHE_NODE_LOCK_COUNT
#endif /* if DNS_RBTDB_CACHE_NODE_LOCK_COUNT <= 1 */
#else /* ifdef DNS_RBTDB_CACHE_NODE_LOCK_COUNT */
-#define DEFAULT_CACHE_NODE_LOCK_COUNT 97
+#define DEFAULT_CACHE_NODE_LOCK_COUNT 17
#endif /* DNS_RBTDB_CACHE_NODE_LOCK_COUNT */
typedef struct {
@@ -769,7 +770,7 @@ static char FILE_VERSION[32] = "\0";
* that indicates that the database does not implement cyclic
* processing.
*/
-static atomic_uint_fast32_t init_count;
+static atomic_uint_fast32_t init_count = ATOMIC_VAR_INIT(0);
/*
* Locking
@@ -3091,6 +3092,8 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header,
isc_stdtime_t now, isc_rwlocktype_t locktype,
dns_rdataset_t *rdataset) {
unsigned char *raw; /* RDATASLAB */
+ bool stale = STALE(header);
+ bool ancient = ANCIENT(header);
/*
* Caller must be holding the node reader lock.
@@ -3108,12 +3111,36 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header,
INSIST(rdataset->methods == NULL); /* We must be disassociated. */
+ /*
+ * Mark header stale or ancient if the RRset is no longer active.
+ */
+ if (!ACTIVE(header, now)) {
+ dns_ttl_t stale_ttl = header->rdh_ttl + rbtdb->serve_stale_ttl;
+ /*
+ * If this data is in the stale window keep it and if
+ * DNS_DBFIND_STALEOK is not set we tell the caller to
+ * skip this record. We skip the records with ZEROTTL
+ * (these records should not be cached anyway).
+ */
+
+ if (KEEPSTALE(rbtdb) && stale_ttl > now) {
+ stale = true;
+ } else {
+ /*
+ * We are not keeping stale, or it is outside the
+ * stale window. Mark ancient, i.e. ready for cleanup.
+ */
+ ancient = true;
+ }
+ }
+
rdataset->methods = &rdataset_methods;
rdataset->rdclass = rbtdb->common.rdclass;
rdataset->type = RBTDB_RDATATYPE_BASE(header->type);
rdataset->covers = RBTDB_RDATATYPE_EXT(header->type);
rdataset->ttl = header->rdh_ttl - now;
rdataset->trust = header->trust;
+
if (NEGATIVE(header)) {
rdataset->attributes |= DNS_RDATASETATTR_NEGATIVE;
}
@@ -3126,18 +3153,21 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header,
if (PREFETCH(header)) {
rdataset->attributes |= DNS_RDATASETATTR_PREFETCH;
}
- if (STALE(header)) {
+
+ if (stale && !ancient) {
+ dns_ttl_t stale_ttl = header->rdh_ttl + rbtdb->serve_stale_ttl;
+ if (stale_ttl > now) {
+ rdataset->ttl = stale_ttl - now;
+ } else {
+ rdataset->ttl = 0;
+ }
if (STALE_WINDOW(header)) {
rdataset->attributes |= DNS_RDATASETATTR_STALE_WINDOW;
}
rdataset->attributes |= DNS_RDATASETATTR_STALE;
- rdataset->stale_ttl =
- (rbtdb->serve_stale_ttl + header->rdh_ttl) - now;
- rdataset->ttl = 0;
} else if (IS_CACHE(rbtdb) && !ACTIVE(header, now)) {
rdataset->attributes |= DNS_RDATASETATTR_ANCIENT;
- rdataset->stale_ttl = header->rdh_ttl;
- rdataset->ttl = 0;
+ rdataset->ttl = header->rdh_ttl;
}
rdataset->private1 = rbtdb;
@@ -3670,6 +3700,7 @@ previous_closest_nsec(dns_rdatatype_t type, rbtdb_search_t *search,
isc_result_t result;
REQUIRE(nodep != NULL && *nodep == NULL);
+ REQUIRE(type == dns_rdatatype_nsec3 || firstp != NULL);
if (type == dns_rdatatype_nsec3) {
result = dns_rbtnodechain_prev(&search->chain, NULL, NULL);
@@ -5561,7 +5592,8 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) {
isc_rwlocktype_write);
for (header = rbtnode->data; header != NULL; header = header->next) {
- if (header->rdh_ttl <= now - RBTDB_VIRTUAL) {
+ if (header->rdh_ttl + rbtdb->serve_stale_ttl <=
+ now - RBTDB_VIRTUAL) {
/*
* We don't check if refcurrent(rbtnode) == 0 and try
* to free like we do in cache_find(), because
@@ -5832,7 +5864,8 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
for (header = rbtnode->data; header != NULL; header = header_next) {
header_next = header->next;
if (!ACTIVE(header, now)) {
- if ((header->rdh_ttl < now - RBTDB_VIRTUAL) &&
+ if ((header->rdh_ttl + rbtdb->serve_stale_ttl <
+ now - RBTDB_VIRTUAL) &&
(locktype == isc_rwlocktype_write ||
NODE_TRYUPGRADE(lock) == ISC_R_SUCCESS))
{
@@ -6829,8 +6862,10 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
RDATASET_ATTR_SET(newheader, RDATASET_ATTR_RESIGN);
- newheader->resign = (isc_stdtime_t)(
- dns_time64_from32(rdataset->resign) >> 1);
+ newheader->resign =
+ (isc_stdtime_t)(dns_time64_from32(
+ rdataset->resign) >>
+ 1);
newheader->resign_lsb = rdataset->resign & 0x1;
} else {
newheader->resign = 0;
@@ -6929,7 +6964,9 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
}
header = isc_heap_element(rbtdb->heaps[rbtnode->locknum], 1);
- if (header && header->rdh_ttl < now - RBTDB_VIRTUAL) {
+ if (header != NULL && header->rdh_ttl + rbtdb->serve_stale_ttl <
+ now - RBTDB_VIRTUAL)
+ {
expire_header(rbtdb, header, tree_locked, expire_ttl);
}
@@ -7037,8 +7074,9 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
newheader->node = rbtnode;
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
RDATASET_ATTR_SET(newheader, RDATASET_ATTR_RESIGN);
- newheader->resign = (isc_stdtime_t)(
- dns_time64_from32(rdataset->resign) >> 1);
+ newheader->resign =
+ (isc_stdtime_t)(dns_time64_from32(rdataset->resign) >>
+ 1);
newheader->resign_lsb = rdataset->resign & 0x1;
} else {
newheader->resign = 0;
@@ -7447,8 +7485,9 @@ loading_addrdataset(void *arg, const dns_name_t *name,
if ((rdataset->attributes & DNS_RDATASETATTR_RESIGN) != 0) {
RDATASET_ATTR_SET(newheader, RDATASET_ATTR_RESIGN);
- newheader->resign = (isc_stdtime_t)(
- dns_time64_from32(rdataset->resign) >> 1);
+ newheader->resign =
+ (isc_stdtime_t)(dns_time64_from32(rdataset->resign) >>
+ 1);
newheader->resign_lsb = rdataset->resign & 0x1;
} else {
newheader->resign = 0;
@@ -9820,11 +9859,9 @@ setownercase(rdatasetheader_t *header, const dns_name_t *name) {
memset(header->upper, 0, sizeof(header->upper));
fully_lower = true;
for (i = 0; i < name->length; i++) {
- if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a) {
- {
- header->upper[i / 8] |= 1 << (i % 8);
- fully_lower = false;
- }
+ if (isupper(name->ndata[i])) {
+ header->upper[i / 8] |= 1 << (i % 8);
+ fully_lower = false;
}
}
RDATASET_ATTR_SET(header, RDATASET_ATTR_CASESET);
@@ -9849,65 +9886,14 @@ rdataset_setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) {
isc_rwlocktype_write);
}
-static const unsigned char charmask[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
-};
-
-static const unsigned char maptolower[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
- 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
- 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
- 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
- 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
- 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb,
- 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
- 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
- 0xfc, 0xfd, 0xfe, 0xff
-};
-
static void
rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
dns_rbtdb_t *rbtdb = rdataset->private1;
dns_rbtnode_t *rbtnode = rdataset->private2;
unsigned char *raw = rdataset->private3; /* RDATASLAB */
- rdatasetheader_t *header;
- unsigned int i, j;
- unsigned char bits;
- unsigned char c, flip;
+ rdatasetheader_t *header = NULL;
+ uint8_t mask = (1 << 7);
+ uint8_t bits = 0;
header = (struct rdatasetheader *)(raw - sizeof(*header));
@@ -9918,85 +9904,25 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
goto unlock;
}
-#if 0
- /*
- * This was the original code, and is implemented differently in
- * the #else block that follows.
- */
- for (i = 0; i < name->length; i++) {
- /*
- * Set the case bit if it does not match the recorded bit.
- */
- if (name->ndata[i] >= 0x61 && name->ndata[i] <= 0x7a &&
- (header->upper[i / 8] & (1 << (i % 8))) != 0)
- {
- name->ndata[i] &= ~0x20; /* clear the lower case bit */
- } else if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a &&
- (header->upper[i / 8] & (1 << (i % 8))) == 0)
- {
- name->ndata[i] |= 0x20; /* set the lower case bit */
- }
- }
-#else /* if 0 */
-
if (ISC_LIKELY(CASEFULLYLOWER(header))) {
- unsigned char *bp, *be;
- bp = name->ndata;
- be = bp + name->length;
-
- while (bp <= be - 4) {
- c = bp[0];
- bp[0] = maptolower[c];
- c = bp[1];
- bp[1] = maptolower[c];
- c = bp[2];
- bp[2] = maptolower[c];
- c = bp[3];
- bp[3] = maptolower[c];
- bp += 4;
- }
- while (bp < be) {
- c = *bp;
- *bp++ = maptolower[c];
+ for (size_t i = 0; i < name->length; i++) {
+ name->ndata[i] = tolower(name->ndata[i]);
}
- goto unlock;
- }
-
- i = 0;
- for (j = 0; j < (name->length >> 3); j++) {
- unsigned int k;
-
- bits = ~(header->upper[j]);
-
- for (k = 0; k < 8; k++) {
- c = name->ndata[i];
- flip = (bits & 1) << 5;
- flip ^= c;
- flip &= charmask[c];
- name->ndata[i] ^= flip;
+ } else {
+ for (size_t i = 0; i < name->length; i++) {
+ if (mask == (1 << 7)) {
+ bits = header->upper[i / 8];
+ mask = 1;
+ } else {
+ mask <<= 1;
+ }
- i++;
- bits >>= 1;
+ name->ndata[i] = ((bits & mask) != 0)
+ ? toupper(name->ndata[i])
+ : tolower(name->ndata[i]);
}
}
- if (ISC_UNLIKELY(i == name->length)) {
- goto unlock;
- }
-
- bits = ~(header->upper[j]);
-
- for (; i < name->length; i++) {
- c = name->ndata[i];
- flip = (bits & 1) << 5;
- flip ^= c;
- flip &= charmask[c];
- name->ndata[i] ^= flip;
-
- bits >>= 1;
- }
-#endif /* if 0 */
-
unlock:
NODE_UNLOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
isc_rwlocktype_read);
@@ -10343,7 +10269,6 @@ restart:
}
for (; ge != NULL; ge = ge->next) {
- isc_buffer_t *buffer = NULL;
dns_name_t *name = NULL;
dns_rdataset_t *rdataset_a = NULL;
dns_rdataset_t *sigrdataset_a = NULL;
@@ -10351,16 +10276,12 @@ restart:
dns_rdataset_t *sigrdataset_aaaa = NULL;
dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
- isc_buffer_allocate(msg->mctx, &buffer, 512);
-
result = dns_message_gettempname(msg, &name);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
- isc_buffer_free(&buffer);
goto no_glue;
}
- dns_name_copy(gluename, name, buffer);
- dns_message_takebuffer(msg, &buffer);
+ dns_name_copynf(gluename, name);
if (dns_rdataset_isassociated(&ge->rdataset_a)) {
result = dns_message_gettemprdataset(msg, &rdataset_a);
diff --git a/external/mpl/bind/dist/lib/dns/rcode.c b/external/mpl/bind/dist/lib/dns/rcode.c
index bd36003f8a3..572c3957d55 100644
--- a/external/mpl/bind/dist/lib/dns/rcode.c
+++ b/external/mpl/bind/dist/lib/dns/rcode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rcode.c,v 1.9 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: rcode.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -221,8 +221,8 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source, unsigned int max,
char buffer[NUMBERSIZE];
int v;
- if (!isdigit(source->base[0] & 0xff) || source->length > NUMBERSIZE - 1)
- {
+ if (!isdigit((unsigned char)source->base[0]) ||
+ source->length > NUMBERSIZE - 1) {
return (ISC_R_BADNUMBER);
}
diff --git a/external/mpl/bind/dist/lib/dns/rdata.c b/external/mpl/bind/dist/lib/dns/rdata.c
index 2831d7a80b4..33c56d408ce 100644
--- a/external/mpl/bind/dist/lib/dns/rdata.c
+++ b/external/mpl/bind/dist/lib/dns/rdata.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rdata.c,v 1.10 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: rdata.c,v 1.11 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -84,38 +84,62 @@
const dns_name_t *origin, unsigned int options, \
isc_buffer_t *target, dns_rdatacallbacks_t *callbacks
+#define CALL_FROMTEXT rdclass, type, lexer, origin, options, target, callbacks
+
#define ARGS_TOTEXT \
dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target
+#define CALL_TOTEXT rdata, tctx, target
+
#define ARGS_FROMWIRE \
int rdclass, dns_rdatatype_t type, isc_buffer_t *source, \
dns_decompress_t *dctx, unsigned int options, \
isc_buffer_t *target
+#define CALL_FROMWIRE rdclass, type, source, dctx, options, target
+
#define ARGS_TOWIRE \
dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target
+#define CALL_TOWIRE rdata, cctx, target
+
#define ARGS_COMPARE const dns_rdata_t *rdata1, const dns_rdata_t *rdata2
+#define CALL_COMPARE rdata1, rdata2
+
#define ARGS_FROMSTRUCT \
int rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target
+#define CALL_FROMSTRUCT rdclass, type, source, target
+
#define ARGS_TOSTRUCT const dns_rdata_t *rdata, void *target, isc_mem_t *mctx
+#define CALL_TOSTRUCT rdata, target, mctx
+
#define ARGS_FREESTRUCT void *source
+#define CALL_FREESTRUCT source
+
#define ARGS_ADDLDATA \
dns_rdata_t *rdata, dns_additionaldatafunc_t add, void *arg
+#define CALL_ADDLDATA rdata, add, arg
+
#define ARGS_DIGEST dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg
+#define CALL_DIGEST rdata, digest, arg
+
#define ARGS_CHECKOWNER \
const dns_name_t *name, dns_rdataclass_t rdclass, \
dns_rdatatype_t type, bool wildcard
+#define CALL_CHECKOWNER name, rdclass, type, wildcard
+
#define ARGS_CHECKNAMES \
dns_rdata_t *rdata, const dns_name_t *owner, dns_name_t *bad
+#define CALL_CHECKNAMES rdata, owner, bad
+
/*%
* Context structure for the totext_ functions.
* Contains formatting options for rdata-to-text
@@ -1200,6 +1224,7 @@ dns_rdata_tostruct(const dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
REQUIRE(rdata != NULL);
REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
+ REQUIRE((rdata->flags & DNS_RDATA_UPDATE) == 0);
TOSTRUCTSWITCH
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/avc_258.c b/external/mpl/bind/dist/lib/dns/rdata/generic/avc_258.c
index acb0dc4eef4..06d3d72fda5 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/avc_258.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/avc_258.c
@@ -1,4 +1,4 @@
-/* $NetBSD: avc_258.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: avc_258.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,36 +20,22 @@ static inline isc_result_t
fromtext_avc(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_avc);
- UNUSED(type);
- UNUSED(rdclass);
- UNUSED(origin);
- UNUSED(options);
- UNUSED(callbacks);
-
- return (generic_fromtext_txt(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_txt(CALL_FROMTEXT));
}
static inline isc_result_t
totext_avc(ARGS_TOTEXT) {
- UNUSED(tctx);
-
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_avc);
- return (generic_totext_txt(rdata, tctx, target));
+ return (generic_totext_txt(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_avc(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_avc);
- UNUSED(type);
- UNUSED(dctx);
- UNUSED(rdclass);
- UNUSED(options);
-
- return (generic_fromwire_txt(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_txt(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -79,7 +65,7 @@ static inline isc_result_t
fromstruct_avc(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_avc);
- return (generic_fromstruct_txt(rdclass, type, source, target));
+ return (generic_fromstruct_txt(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -93,7 +79,7 @@ tostruct_avc(ARGS_TOSTRUCT) {
avc->common.rdtype = rdata->type;
ISC_LINK_INIT(&avc->common, link);
- return (generic_tostruct_txt(rdata, target, mctx));
+ return (generic_tostruct_txt(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/cdnskey_60.c b/external/mpl/bind/dist/lib/dns/rdata/generic/cdnskey_60.c
index 945f52bf7bc..e79d491cae7 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/cdnskey_60.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/cdnskey_60.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cdnskey_60.c,v 1.5 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: cdnskey_60.c,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,8 +24,7 @@ static inline isc_result_t
fromtext_cdnskey(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_cdnskey);
- return (generic_fromtext_key(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_key(CALL_FROMTEXT));
}
static inline isc_result_t
@@ -33,15 +32,14 @@ totext_cdnskey(ARGS_TOTEXT) {
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_cdnskey);
- return (generic_totext_key(rdata, tctx, target));
+ return (generic_totext_key(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_cdnskey(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_cdnskey);
- return (generic_fromwire_key(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_key(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -79,7 +77,7 @@ static inline isc_result_t
fromstruct_cdnskey(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_cdnskey);
- return (generic_fromstruct_key(rdclass, type, source, target));
+ return (generic_fromstruct_key(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -94,7 +92,7 @@ tostruct_cdnskey(ARGS_TOSTRUCT) {
dnskey->common.rdtype = rdata->type;
ISC_LINK_INIT(&dnskey->common, link);
- return (generic_tostruct_key(rdata, target, mctx));
+ return (generic_tostruct_key(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/cds_59.c b/external/mpl/bind/dist/lib/dns/rdata/generic/cds_59.c
index 5cc2ec30251..c68b0278c05 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/cds_59.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/cds_59.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cds_59.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: cds_59.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,23 +24,22 @@ static inline isc_result_t
fromtext_cds(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_cds);
- return (generic_fromtext_ds(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_ds(CALL_FROMTEXT));
}
static inline isc_result_t
totext_cds(ARGS_TOTEXT) {
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_cds);
- return (generic_totext_ds(rdata, tctx, target));
+ return (generic_totext_ds(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_cds(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_cds);
- return (generic_fromwire_ds(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_ds(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -76,7 +75,7 @@ static inline isc_result_t
fromstruct_cds(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_cds);
- return (generic_fromstruct_ds(rdclass, type, source, target));
+ return (generic_fromstruct_ds(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -94,7 +93,7 @@ tostruct_cds(ARGS_TOSTRUCT) {
cds->common.rdtype = rdata->type;
ISC_LINK_INIT(&cds->common, link);
- return (generic_tostruct_ds(rdata, target, mctx));
+ return (generic_tostruct_ds(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/dlv_32769.c b/external/mpl/bind/dist/lib/dns/rdata/generic/dlv_32769.c
index 244733e7845..5149fe44e0e 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/dlv_32769.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/dlv_32769.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dlv_32769.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: dlv_32769.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,23 +24,22 @@ static inline isc_result_t
fromtext_dlv(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_dlv);
- return (generic_fromtext_ds(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_ds(CALL_FROMTEXT));
}
static inline isc_result_t
totext_dlv(ARGS_TOTEXT) {
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_dlv);
- return (generic_totext_ds(rdata, tctx, target));
+ return (generic_totext_ds(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_dlv(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_dlv);
- return (generic_fromwire_ds(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_ds(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -76,7 +75,7 @@ static inline isc_result_t
fromstruct_dlv(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_dlv);
- return (generic_fromstruct_ds(rdclass, type, source, target));
+ return (generic_fromstruct_ds(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -90,7 +89,7 @@ tostruct_dlv(ARGS_TOSTRUCT) {
dlv->common.rdtype = rdata->type;
ISC_LINK_INIT(&dlv->common, link);
- return (generic_tostruct_ds(rdata, target, mctx));
+ return (generic_tostruct_ds(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/dnskey_48.c b/external/mpl/bind/dist/lib/dns/rdata/generic/dnskey_48.c
index f18ef4e048b..d1547979c02 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/dnskey_48.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/dnskey_48.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dnskey_48.c,v 1.5 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: dnskey_48.c,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,8 +24,7 @@ static inline isc_result_t
fromtext_dnskey(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_dnskey);
- return (generic_fromtext_key(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_key(CALL_FROMTEXT));
}
static inline isc_result_t
@@ -33,15 +32,14 @@ totext_dnskey(ARGS_TOTEXT) {
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_dnskey);
- return (generic_totext_key(rdata, tctx, target));
+ return (generic_totext_key(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_dnskey(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_dnskey);
- return (generic_fromwire_key(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_key(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -80,7 +78,7 @@ static inline isc_result_t
fromstruct_dnskey(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_dnskey);
- return (generic_fromstruct_key(rdclass, type, source, target));
+ return (generic_fromstruct_key(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -95,7 +93,7 @@ tostruct_dnskey(ARGS_TOSTRUCT) {
dnskey->common.rdtype = rdata->type;
ISC_LINK_INIT(&dnskey->common, link);
- return (generic_tostruct_key(rdata, target, mctx));
+ return (generic_tostruct_key(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c b/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c
index d2b95413c80..d90cece3349 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ds_43.c,v 1.8 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: ds_43.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -86,8 +86,7 @@ static inline isc_result_t
fromtext_ds(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_ds);
- return (generic_fromtext_ds(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_ds(CALL_FROMTEXT));
}
static inline isc_result_t
@@ -151,9 +150,10 @@ generic_totext_ds(ARGS_TOTEXT) {
static inline isc_result_t
totext_ds(ARGS_TOTEXT) {
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_ds);
- return (generic_totext_ds(rdata, tctx, target));
+ return (generic_totext_ds(CALL_TOTEXT));
}
static inline isc_result_t
@@ -202,8 +202,7 @@ static inline isc_result_t
fromwire_ds(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_ds);
- return (generic_fromwire_ds(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_ds(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -269,7 +268,7 @@ static inline isc_result_t
fromstruct_ds(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_ds);
- return (generic_fromstruct_ds(rdclass, type, source, target));
+ return (generic_fromstruct_ds(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -313,7 +312,7 @@ tostruct_ds(ARGS_TOSTRUCT) {
ds->common.rdtype = rdata->type;
ISC_LINK_INIT(&ds->common, link);
- return (generic_tostruct_ds(rdata, target, mctx));
+ return (generic_tostruct_ds(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c b/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c
index 7f47b48355b..d00ee8da8c6 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c
@@ -1,4 +1,4 @@
-/* $NetBSD: key_25.c,v 1.8 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: key_25.c,v 1.9 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -238,8 +238,7 @@ static inline isc_result_t
fromtext_key(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_key);
- return (generic_fromtext_key(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_key(CALL_FROMTEXT));
}
static inline isc_result_t
@@ -247,15 +246,14 @@ totext_key(ARGS_TOTEXT) {
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_key);
- return (generic_totext_key(rdata, tctx, target));
+ return (generic_totext_key(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_key(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_key);
- return (generic_fromwire_key(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_key(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -385,7 +383,7 @@ static inline isc_result_t
fromstruct_key(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_key);
- return (generic_fromstruct_key(rdclass, type, source, target));
+ return (generic_fromstruct_key(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -400,7 +398,7 @@ tostruct_key(ARGS_TOSTRUCT) {
key->common.rdtype = rdata->type;
ISC_LINK_INIT(&key->common, link);
- return (generic_tostruct_key(rdata, target, mctx));
+ return (generic_tostruct_key(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c b/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c
index 81aeae75579..8bed975e480 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keydata_65533.c,v 1.7 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: keydata_65533.c,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -73,6 +73,11 @@ fromtext_keydata(ARGS_FROMTEXT) {
RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
RETERR(mem_tobuffer(target, &alg, 1));
+ /* Do we have a placeholder KEYDATA record? */
+ if (flags == 0 && proto == 0 && alg == 0) {
+ return (ISC_R_SUCCESS);
+ }
+
/* No Key? */
if ((flags & 0xc000) == 0xc000) {
return (ISC_R_SUCCESS);
@@ -86,7 +91,7 @@ totext_keydata(ARGS_TOTEXT) {
isc_region_t sr;
char buf[sizeof("64000")];
unsigned int flags;
- unsigned char algorithm;
+ unsigned char proto, algorithm;
unsigned long refresh, add, deltime;
char algbuf[DNS_NAME_FORMATSIZE];
const char *keyinfo;
@@ -134,7 +139,8 @@ totext_keydata(ARGS_TOTEXT) {
}
/* protocol */
- snprintf(buf, sizeof(buf), "%u", sr.base[0]);
+ proto = sr.base[0];
+ snprintf(buf, sizeof(buf), "%u", proto);
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
@@ -145,6 +151,14 @@ totext_keydata(ARGS_TOTEXT) {
isc_region_consume(&sr, 1);
RETERR(str_totext(buf, target));
+ /* Do we have a placeholder KEYDATA record? */
+ if (flags == 0 && proto == 0 && algorithm == 0) {
+ if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
+ RETERR(str_totext(" ; placeholder", target));
+ }
+ return (ISC_R_SUCCESS);
+ }
+
/* No Key? */
if ((flags & 0xc000) == 0xc000) {
return (ISC_R_SUCCESS);
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c b/external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c
index 6060a644784..d6ffa19b6aa 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ninfo_56.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: ninfo_56.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,36 +20,22 @@ static inline isc_result_t
fromtext_ninfo(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_ninfo);
- UNUSED(type);
- UNUSED(rdclass);
- UNUSED(origin);
- UNUSED(options);
- UNUSED(callbacks);
-
- return (generic_fromtext_txt(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_txt(CALL_FROMTEXT));
}
static inline isc_result_t
totext_ninfo(ARGS_TOTEXT) {
- UNUSED(tctx);
-
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_ninfo);
- return (generic_totext_txt(rdata, tctx, target));
+ return (generic_totext_txt(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_ninfo(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_ninfo);
- UNUSED(type);
- UNUSED(dctx);
- UNUSED(rdclass);
- UNUSED(options);
-
- return (generic_fromwire_txt(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_txt(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -79,7 +65,7 @@ static inline isc_result_t
fromstruct_ninfo(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_ninfo);
- return (generic_fromstruct_txt(rdclass, type, source, target));
+ return (generic_fromstruct_txt(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -93,7 +79,7 @@ tostruct_ninfo(ARGS_TOSTRUCT) {
ninfo->common.rdtype = rdata->type;
ISC_LINK_INIT(&ninfo->common, link);
- return (generic_tostruct_txt(rdata, target, mctx));
+ return (generic_tostruct_txt(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/rkey_57.c b/external/mpl/bind/dist/lib/dns/rdata/generic/rkey_57.c
index a7e10cec10f..c7ff25a7ec8 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/rkey_57.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/rkey_57.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rkey_57.c,v 1.5 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: rkey_57.c,v 1.6 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,8 +20,7 @@ static inline isc_result_t
fromtext_rkey(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_rkey);
- return (generic_fromtext_key(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_key(CALL_FROMTEXT));
}
static inline isc_result_t
@@ -29,15 +28,14 @@ totext_rkey(ARGS_TOTEXT) {
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_rkey);
- return (generic_totext_key(rdata, tctx, target));
+ return (generic_totext_key(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_rkey(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_rkey);
- return (generic_fromwire_key(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_key(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -76,7 +74,7 @@ static inline isc_result_t
fromstruct_rkey(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_rkey);
- return (generic_fromstruct_key(rdclass, type, source, target));
+ return (generic_fromstruct_key(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -91,7 +89,7 @@ tostruct_rkey(ARGS_TOSTRUCT) {
rkey->common.rdtype = rdata->type;
ISC_LINK_INIT(&rkey->common, link);
- return (generic_tostruct_key(rdata, target, mctx));
+ return (generic_tostruct_key(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c b/external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c
index 649a2ba89ee..c358dd7e316 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c
@@ -1,4 +1,4 @@
-/* $NetBSD: smimea_53.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: smimea_53.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,23 +20,22 @@ static inline isc_result_t
fromtext_smimea(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_smimea);
- return (generic_fromtext_tlsa(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_tlsa(CALL_FROMTEXT));
}
static inline isc_result_t
totext_smimea(ARGS_TOTEXT) {
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_smimea);
- return (generic_totext_tlsa(rdata, tctx, target));
+ return (generic_totext_tlsa(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_smimea(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_smimea);
- return (generic_fromwire_tlsa(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_tlsa(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -72,7 +71,7 @@ static inline isc_result_t
fromstruct_smimea(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_smimea);
- return (generic_fromstruct_tlsa(rdclass, type, source, target));
+ return (generic_fromstruct_tlsa(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -87,7 +86,7 @@ tostruct_smimea(ARGS_TOSTRUCT) {
smimea->common.rdtype = rdata->type;
ISC_LINK_INIT(&smimea->common, link);
- return (generic_tostruct_tlsa(rdata, target, mctx));
+ return (generic_tostruct_tlsa(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c b/external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c
index ede5549f505..11fadb9fd03 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c
@@ -1,4 +1,4 @@
-/* $NetBSD: spf_99.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: spf_99.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -20,36 +20,22 @@ static inline isc_result_t
fromtext_spf(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_spf);
- UNUSED(type);
- UNUSED(rdclass);
- UNUSED(origin);
- UNUSED(options);
- UNUSED(callbacks);
-
- return (generic_fromtext_txt(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_txt(CALL_FROMTEXT));
}
static inline isc_result_t
totext_spf(ARGS_TOTEXT) {
- UNUSED(tctx);
-
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_spf);
- return (generic_totext_txt(rdata, tctx, target));
+ return (generic_totext_txt(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_spf(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_spf);
- UNUSED(type);
- UNUSED(dctx);
- UNUSED(rdclass);
- UNUSED(options);
-
- return (generic_fromwire_txt(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_txt(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -79,7 +65,7 @@ static inline isc_result_t
fromstruct_spf(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_spf);
- return (generic_fromstruct_txt(rdclass, type, source, target));
+ return (generic_fromstruct_txt(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -94,7 +80,7 @@ tostruct_spf(ARGS_TOSTRUCT) {
spf->common.rdtype = rdata->type;
ISC_LINK_INIT(&spf->common, link);
- return (generic_tostruct_txt(rdata, target, mctx));
+ return (generic_tostruct_txt(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c b/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c
index 9818dbb065b..c44f814c604 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ta_32768.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: ta_32768.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -22,23 +22,21 @@ static inline isc_result_t
fromtext_ta(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_ta);
- return (generic_fromtext_ds(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_ds(CALL_FROMTEXT));
}
static inline isc_result_t
totext_ta(ARGS_TOTEXT) {
REQUIRE(rdata->type == dns_rdatatype_ta);
- return (generic_totext_ds(rdata, tctx, target));
+ return (generic_totext_ds(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_ta(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_ta);
- return (generic_fromwire_ds(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_ds(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -74,7 +72,7 @@ static inline isc_result_t
fromstruct_ta(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_ta);
- return (generic_fromstruct_ds(rdclass, type, source, target));
+ return (generic_fromstruct_ds(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -91,7 +89,7 @@ tostruct_ta(ARGS_TOSTRUCT) {
ds->common.rdtype = rdata->type;
ISC_LINK_INIT(&ds->common, link);
- return (generic_tostruct_ds(rdata, target, mctx));
+ return (generic_tostruct_ds(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c b/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c
index b2f2a5310f7..39c30c3aefa 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tlsa_52.c,v 1.7 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: tlsa_52.c,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -143,23 +143,21 @@ static inline isc_result_t
fromtext_tlsa(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_tlsa);
- return (generic_fromtext_tlsa(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_tlsa(CALL_FROMTEXT));
}
static inline isc_result_t
totext_tlsa(ARGS_TOTEXT) {
REQUIRE(rdata->type == dns_rdatatype_tlsa);
- return (generic_totext_tlsa(rdata, tctx, target));
+ return (generic_totext_tlsa(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_tlsa(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_tlsa);
- return (generic_fromwire_tlsa(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_tlsa(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -261,7 +259,7 @@ static inline isc_result_t
fromstruct_tlsa(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_tlsa);
- return (generic_fromstruct_tlsa(rdclass, type, source, target));
+ return (generic_fromstruct_tlsa(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -275,7 +273,7 @@ tostruct_tlsa(ARGS_TOSTRUCT) {
tlsa->common.rdtype = rdata->type;
ISC_LINK_INIT(&tlsa->common, link);
- return (generic_tostruct_tlsa(rdata, target, mctx));
+ return (generic_tostruct_tlsa(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/txt_16.c b/external/mpl/bind/dist/lib/dns/rdata/generic/txt_16.c
index aaca1bc4b88..6b767a4cb49 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/txt_16.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/txt_16.c
@@ -1,4 +1,4 @@
-/* $NetBSD: txt_16.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: txt_16.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -90,23 +90,22 @@ static inline isc_result_t
fromtext_txt(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_txt);
- return (generic_fromtext_txt(rdclass, type, lexer, origin, options,
- target, callbacks));
+ return (generic_fromtext_txt(CALL_FROMTEXT));
}
static inline isc_result_t
totext_txt(ARGS_TOTEXT) {
+ REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_txt);
- return (generic_totext_txt(rdata, tctx, target));
+ return (generic_totext_txt(CALL_TOTEXT));
}
static inline isc_result_t
fromwire_txt(ARGS_FROMWIRE) {
REQUIRE(type == dns_rdatatype_txt);
- return (generic_fromwire_txt(rdclass, type, source, dctx, options,
- target));
+ return (generic_fromwire_txt(CALL_FROMWIRE));
}
static inline isc_result_t
@@ -202,7 +201,7 @@ static inline isc_result_t
fromstruct_txt(ARGS_FROMSTRUCT) {
REQUIRE(type == dns_rdatatype_txt);
- return (generic_fromstruct_txt(rdclass, type, source, target));
+ return (generic_fromstruct_txt(CALL_FROMSTRUCT));
}
static inline isc_result_t
@@ -216,7 +215,7 @@ tostruct_txt(ARGS_TOSTRUCT) {
txt->common.rdtype = rdata->type;
ISC_LINK_INIT(&txt->common, link);
- return (generic_tostruct_txt(rdata, target, mctx));
+ return (generic_tostruct_txt(CALL_TOSTRUCT));
}
static inline void
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/x25_19.c b/external/mpl/bind/dist/lib/dns/rdata/generic/x25_19.c
index 5190a7c7bd2..c72466e7842 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/x25_19.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/x25_19.c
@@ -1,4 +1,4 @@
-/* $NetBSD: x25_19.c,v 1.6 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: x25_19.c,v 1.7 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -37,7 +37,8 @@ fromtext_x25(ARGS_FROMTEXT) {
RETTOK(DNS_R_SYNTAX);
}
for (i = 0; i < token.value.as_textregion.length; i++) {
- if (!isdigit(token.value.as_textregion.base[i] & 0xff)) {
+ if (!isdigit((unsigned char)token.value.as_textregion.base[i]))
+ {
RETTOK(ISC_R_RANGE);
}
}
@@ -127,7 +128,7 @@ fromstruct_x25(ARGS_FROMSTRUCT) {
}
for (i = 0; i < x25->x25_len; i++) {
- if (!isdigit(x25->x25[i] & 0xff)) {
+ if (!isdigit((unsigned char)x25->x25[i])) {
return (ISC_R_RANGE);
}
}
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.c b/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.c
index 00f96e7d027..9efdc370c03 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zonemd_63.c,v 1.3 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: zonemd_63.c,v 1.4 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -11,7 +11,7 @@
* information regarding copyright ownership.
*/
-/* draft-wessels-zone-digest-05 */
+/* RFC 8976 */
#ifndef RDATA_GENERIC_ZONEMD_63_C
#define RDATA_GENERIC_ZONEMD_63_C
@@ -22,6 +22,8 @@ static inline isc_result_t
fromtext_zonemd(ARGS_FROMTEXT) {
isc_token_t token;
int digest_type, length;
+ isc_buffer_t save;
+ isc_result_t result;
UNUSED(type);
UNUSED(rdclass);
@@ -30,26 +32,26 @@ fromtext_zonemd(ARGS_FROMTEXT) {
UNUSED(callbacks);
/*
- * Serial.
+ * Zone Serial.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
false));
RETERR(uint32_tobuffer(token.value.as_ulong, target));
/*
- * Digest type.
+ * Digest Scheme.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
false));
- digest_type = token.value.as_ulong;
- RETERR(uint8_tobuffer(digest_type, target));
+ RETERR(uint8_tobuffer(token.value.as_ulong, target));
/*
- * Reserved.
+ * Digest Type.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
false));
- RETERR(uint8_tobuffer(token.value.as_ulong, target));
+ digest_type = token.value.as_ulong;
+ RETERR(uint8_tobuffer(digest_type, target));
/*
* Digest.
@@ -58,12 +60,21 @@ fromtext_zonemd(ARGS_FROMTEXT) {
case DNS_ZONEMD_DIGEST_SHA384:
length = ISC_SHA384_DIGESTLENGTH;
break;
+ case DNS_ZONEMD_DIGEST_SHA512:
+ length = ISC_SHA512_DIGESTLENGTH;
+ break;
default:
length = -2;
break;
}
- return (isc_hex_tobuffer(lexer, target, length));
+ save = *target;
+ result = isc_hex_tobuffer(lexer, target, length);
+ /* Minimum length of digest is 12 octets. */
+ if (isc_buffer_usedlength(target) - isc_buffer_usedlength(&save) < 12) {
+ return (ISC_R_UNEXPECTEDEND);
+ }
+ return (result);
}
static inline isc_result_t
@@ -79,7 +90,7 @@ totext_zonemd(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &sr);
/*
- * Serial.
+ * Zone Serial.
*/
num = uint32_fromregion(&sr);
isc_region_consume(&sr, 4);
@@ -89,7 +100,7 @@ totext_zonemd(ARGS_TOTEXT) {
RETERR(str_totext(" ", target));
/*
- * Digest type.
+ * Digest scheme.
*/
num = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
@@ -97,8 +108,9 @@ totext_zonemd(ARGS_TOTEXT) {
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
+
/*
- * Reserved.
+ * Digest type.
*/
num = uint8_fromregion(&sr);
isc_region_consume(&sr, 1);
@@ -131,6 +143,7 @@ totext_zonemd(ARGS_TOTEXT) {
static inline isc_result_t
fromwire_zonemd(ARGS_FROMWIRE) {
isc_region_t sr;
+ size_t digestlen = 0;
UNUSED(type);
UNUSED(rdclass);
@@ -140,15 +153,28 @@ fromwire_zonemd(ARGS_FROMWIRE) {
isc_buffer_activeregion(source, &sr);
/*
- * If we do not recognize the digest type, only ensure that the digest
- * is present at all.
+ * If we do not recognize the digest type, ensure that the digest
+ * meets minimum length (12).
*
* If we do recognize the digest type, ensure that the digest is of the
* correct length.
*/
- if (sr.length < 7 || (sr.base[4] == DNS_ZONEMD_DIGEST_SHA384 &&
- sr.length < 6 + ISC_SHA384_DIGESTLENGTH))
- {
+ if (sr.length < 18) {
+ return (ISC_R_UNEXPECTEDEND);
+ }
+
+ switch (sr.base[5]) {
+ case DNS_ZONEMD_DIGEST_SHA384:
+ digestlen = ISC_SHA384_DIGESTLENGTH;
+ break;
+ case DNS_ZONEMD_DIGEST_SHA512:
+ digestlen = ISC_SHA512_DIGESTLENGTH;
+ break;
+ default:
+ break;
+ }
+
+ if (digestlen != 0 && sr.length < 6 + digestlen) {
return (ISC_R_UNEXPECTEDEND);
}
@@ -158,8 +184,8 @@ fromwire_zonemd(ARGS_FROMWIRE) {
*
* If there is extra data, dns_rdata_fromwire() will detect that.
*/
- if (sr.base[4] == DNS_ZONEMD_DIGEST_SHA384) {
- sr.length = 6 + ISC_SHA384_DIGESTLENGTH;
+ if (digestlen != 0) {
+ sr.length = 6 + digestlen;
}
isc_buffer_forward(source, sr.length);
@@ -210,11 +236,14 @@ fromstruct_zonemd(ARGS_FROMSTRUCT) {
case DNS_ZONEMD_DIGEST_SHA384:
REQUIRE(zonemd->length == ISC_SHA384_DIGESTLENGTH);
break;
+ case DNS_ZONEMD_DIGEST_SHA512:
+ REQUIRE(zonemd->length == ISC_SHA512_DIGESTLENGTH);
+ break;
}
RETERR(uint32_tobuffer(zonemd->serial, target));
+ RETERR(uint8_tobuffer(zonemd->scheme, target));
RETERR(uint8_tobuffer(zonemd->digest_type, target));
- RETERR(uint8_tobuffer(zonemd->reserved, target));
return (mem_tobuffer(target, zonemd->digest, zonemd->length));
}
@@ -236,9 +265,9 @@ tostruct_zonemd(ARGS_TOSTRUCT) {
zonemd->serial = uint32_fromregion(&region);
isc_region_consume(&region, 4);
- zonemd->digest_type = uint8_fromregion(&region);
+ zonemd->scheme = uint8_fromregion(&region);
isc_region_consume(&region, 1);
- zonemd->reserved = uint8_fromregion(&region);
+ zonemd->digest_type = uint8_fromregion(&region);
isc_region_consume(&region, 1);
zonemd->length = region.length;
diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.h b/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.h
index ef31871c2f8..e3da0959ff2 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.h
+++ b/external/mpl/bind/dist/lib/dns/rdata/generic/zonemd_63.h
@@ -1,4 +1,4 @@
-/* $NetBSD: zonemd_63.h,v 1.3 2021/02/19 16:42:17 christos Exp $ */
+/* $NetBSD: zonemd_63.h,v 1.4 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -14,18 +14,19 @@
#ifndef GENERIC_ZONEMD_63_H
#define GENERIC_ZONEMD_63_H 1
-/* Digest type(s). Currently only SHA-384 is defined. */
+/* Known digest type(s). */
#define DNS_ZONEMD_DIGEST_SHA384 (1)
+#define DNS_ZONEMD_DIGEST_SHA512 (2)
/*
- * \brief per draft-wessels-zone-digest-05
+ * \brief per RFC 8976
*/
typedef struct dns_rdata_zonemd {
dns_rdatacommon_t common;
isc_mem_t *mctx;
uint32_t serial;
+ uint8_t scheme;
uint8_t digest_type;
- uint8_t reserved;
unsigned char *digest;
uint16_t length;
} dns_rdata_zonemd_t;
diff --git a/external/mpl/bind/dist/lib/dns/rdata/in_1/atma_34.c b/external/mpl/bind/dist/lib/dns/rdata/in_1/atma_34.c
index 6c8185bc746..5e1e63821fe 100644
--- a/external/mpl/bind/dist/lib/dns/rdata/in_1/atma_34.c
+++ b/external/mpl/bind/dist/lib/dns/rdata/in_1/atma_34.c
@@ -1,4 +1,4 @@
-/* $NetBSD: atma_34.c,v 1.5 2021/02/19 16:42:18 christos Exp $ */
+/* $NetBSD: atma_34.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -93,7 +93,7 @@ fromtext_in_atma(ARGS_FROMTEXT) {
lastwasperiod = true;
continue;
}
- if ((sr->base[0] < '0') || (sr->base[0] > '9')) {
+ if (!isdigit((unsigned char)sr->base[0])) {
RETTOK(DNS_R_SYNTAX);
}
RETERR(mem_tobuffer(target, sr->base, 1));
@@ -159,7 +159,7 @@ fromwire_in_atma(ARGS_FROMWIRE) {
if (region.base[0] == 1) {
unsigned int i;
for (i = 1; i < region.length; i++) {
- if (region.base[i] < '0' || region.base[i] > '9') {
+ if (!isdigit((unsigned char)region.base[i])) {
return (DNS_R_FORMERR);
}
}
diff --git a/external/mpl/bind/dist/lib/dns/resolver.c b/external/mpl/bind/dist/lib/dns/resolver.c
index 6efed2b3a0f..8811f79e4f2 100644
--- a/external/mpl/bind/dist/lib/dns/resolver.c
+++ b/external/mpl/bind/dist/lib/dns/resolver.c
@@ -1,4 +1,4 @@
-/* $NetBSD: resolver.c,v 1.13 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: resolver.c,v 1.14 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -2581,7 +2581,6 @@ resquery_send(resquery_t *query) {
/*
* Set up question.
*/
- dns_name_init(qname, NULL);
dns_name_clone(&fctx->name, qname);
dns_rdataset_makequestion(qrdataset, res->rdclass, fctx->type);
ISC_LIST_APPEND(qname->list, qrdataset, link);
diff --git a/external/mpl/bind/dist/lib/dns/tests/db_test.c b/external/mpl/bind/dist/lib/dns/tests/db_test.c
index 73bd32ea6ac..a3e95ba5b8c 100644
--- a/external/mpl/bind/dist/lib/dns/tests/db_test.c
+++ b/external/mpl/bind/dist/lib/dns/tests/db_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: db_test.c,v 1.8 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: db_test.c,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -250,7 +250,6 @@ dns_dbfind_staleok_test(void **state) {
count++;
assert_in_range(count, 0, 49); /* loop sanity */
assert_int_equal(result, ISC_R_SUCCESS);
- assert_int_equal(rdataset.ttl, 0);
assert_int_equal(rdataset.attributes &
DNS_RDATASETATTR_STALE,
DNS_RDATASETATTR_STALE);
@@ -264,7 +263,11 @@ dns_dbfind_staleok_test(void **state) {
DNS_DBFIND_STALEOK, 0, &node, found,
&rdataset, NULL);
} while (result == ISC_R_SUCCESS);
- assert_in_range(count, 1, 10);
+ /*
+ * usleep(100000) can be slightly less than 10ms so
+ * allow the count to reach 11.
+ */
+ assert_in_range(count, 1, 11);
assert_int_equal(result, ISC_R_NOTFOUND);
break;
case 2:
diff --git a/external/mpl/bind/dist/lib/dns/tests/dnstest.c b/external/mpl/bind/dist/lib/dns/tests/dnstest.c
index 8643ba001c4..324277227f4 100644
--- a/external/mpl/bind/dist/lib/dns/tests/dnstest.c
+++ b/external/mpl/bind/dist/lib/dns/tests/dnstest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dnstest.c,v 1.9 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: dnstest.c,v 1.10 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -34,6 +34,7 @@
#include <isc/hash.h>
#include <isc/hex.h>
#include <isc/lex.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/print.h>
@@ -65,6 +66,7 @@
isc_mem_t *dt_mctx = NULL;
isc_log_t *lctx = NULL;
+isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *maintask = NULL;
isc_timermgr_t *timermgr = NULL;
@@ -96,12 +98,13 @@ cleanup_managers(void) {
isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
}
+
+ isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
+ taskmgr == NULL ? NULL : &taskmgr);
+
if (socketmgr != NULL) {
isc_socketmgr_destroy(&socketmgr);
}
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
}
@@ -115,10 +118,10 @@ create_managers(void) {
isc_result_t result;
ncpus = isc_os_ncpus();
- CHECK(isc_taskmgr_create(dt_mctx, ncpus, 0, NULL, &taskmgr));
+ CHECK(isc_managers_create(dt_mctx, ncpus, 0, &netmgr, &taskmgr));
CHECK(isc_timermgr_create(dt_mctx, &timermgr));
CHECK(isc_socketmgr_create(dt_mctx, &socketmgr));
- CHECK(isc_task_create(taskmgr, 0, &maintask));
+ CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
return (ISC_R_SUCCESS);
cleanup:
@@ -337,21 +340,11 @@ dns_test_closezonemgr(void) {
*/
void
dns_test_nap(uint32_t usec) {
-#ifdef HAVE_NANOSLEEP
struct timespec ts;
ts.tv_sec = usec / 1000000;
ts.tv_nsec = (usec % 1000000) * 1000;
nanosleep(&ts, NULL);
-#elif HAVE_USLEEP
- usleep(usec);
-#else /* ifdef HAVE_NANOSLEEP */
- /*
- * No fractional-second sleep function is available, so we
- * round up to the nearest second and sleep instead
- */
- sleep((usec / 1000000) + 1);
-#endif /* ifdef HAVE_NANOSLEEP */
}
isc_result_t
diff --git a/external/mpl/bind/dist/lib/dns/tests/nsec3_test.c b/external/mpl/bind/dist/lib/dns/tests/nsec3_test.c
index 7fab3f4d919..3ad62d88f0c 100644
--- a/external/mpl/bind/dist/lib/dns/tests/nsec3_test.c
+++ b/external/mpl/bind/dist/lib/dns/tests/nsec3_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nsec3_test.c,v 1.7 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: nsec3_test.c,v 1.8 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -62,8 +62,7 @@ iteration_test(const char *file, unsigned int expected) {
result = dns_test_loaddb(&db, dns_dbtype_zone, "test", file);
assert_int_equal(result, ISC_R_SUCCESS);
- result = dns_nsec3_maxiterations(db, NULL, dt_mctx, &iterations);
- assert_int_equal(result, ISC_R_SUCCESS);
+ iterations = dns_nsec3_maxiterations();
assert_int_equal(iterations, expected);
@@ -140,10 +139,10 @@ max_iterations(void **state) {
UNUSED(state);
iteration_test("testdata/nsec3/1024.db", 150);
- iteration_test("testdata/nsec3/2048.db", 500);
- iteration_test("testdata/nsec3/4096.db", 2500);
+ iteration_test("testdata/nsec3/2048.db", 150);
+ iteration_test("testdata/nsec3/4096.db", 150);
iteration_test("testdata/nsec3/min-1024.db", 150);
- iteration_test("testdata/nsec3/min-2048.db", 500);
+ iteration_test("testdata/nsec3/min-2048.db", 150);
}
/* check dns_nsec3param_salttotext() */
diff --git a/external/mpl/bind/dist/lib/dns/tests/rbtdb_test.c b/external/mpl/bind/dist/lib/dns/tests/rbtdb_test.c
index bb48fe46117..d2016870f99 100644
--- a/external/mpl/bind/dist/lib/dns/tests/rbtdb_test.c
+++ b/external/mpl/bind/dist/lib/dns/tests/rbtdb_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rbtdb_test.c,v 1.1.1.1 2021/08/19 11:45:26 christos Exp $ */
+/* $NetBSD: rbtdb_test.c,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/dns/tests/rdata_test.c b/external/mpl/bind/dist/lib/dns/tests/rdata_test.c
index 545e475725d..fdbb651c2ab 100644
--- a/external/mpl/bind/dist/lib/dns/tests/rdata_test.c
+++ b/external/mpl/bind/dist/lib/dns/tests/rdata_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rdata_test.c,v 1.9 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: rdata_test.c,v 1.10 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -622,6 +622,10 @@ check_wire_ok(const wire_ok_t *wire_ok, bool empty_ok, dns_rdataclass_t rdclass,
* Check all entries in the supplied array.
*/
for (i = 0; wire_ok[i].len != 0; i++) {
+ if (debug) {
+ fprintf(stderr, "calling check_wire_ok_single on %zu\n",
+ i);
+ }
check_wire_ok_single(&wire_ok[i], rdclass, type, structsize);
}
@@ -2413,7 +2417,7 @@ wks(void **state) {
/*
* ZONEMD tests.
*
- * Excerpted from draft-wessels-dns-zone-digest:
+ * Excerpted from RFC 8976:
*
* The ZONEMD RDATA wire format is encoded as follows:
*
@@ -2422,56 +2426,131 @@ wks(void **state) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Serial |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Digest Type | Reserved | |
+ * | Scheme |Hash Algorithm | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
* | Digest |
* / /
* / /
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
- * 2.1.1. The Serial Field
+ * 2.2.1. The Serial Field
+ *
+ * The Serial field is a 32-bit unsigned integer in network byte order.
+ * It is the serial number from the zone's SOA record ([RFC1035],
+ * Section 3.3.13) for which the zone digest was generated.
+ *
+ * It is included here to clearly bind the ZONEMD RR to a particular
+ * version of the zone's content. Without the serial number, a stand-
+ * alone ZONEMD digest has no obvious association to any particular
+ * instance of a zone.
+ *
+ * 2.2.2. The Scheme Field
+ *
+ * The Scheme field is an 8-bit unsigned integer that identifies the
+ * methods by which data is collated and presented as input to the
+ * hashing function.
+ *
+ * Herein, SIMPLE, with Scheme value 1, is the only standardized Scheme
+ * defined for ZONEMD records and it MUST be supported by
+ * implementations. The "ZONEMD Schemes" registry is further described
+ * in Section 5.
+ *
+ * Scheme values 240-254 are allocated for Private Use.
*
- * The Serial field is a 32-bit unsigned integer in network order. It
- * is equal to the serial number from the zone's SOA record
+ * 2.2.3. The Hash Algorithm Field
*
- * 2.1.2. The Digest Type Field
+ * The Hash Algorithm field is an 8-bit unsigned integer that identifies
+ * the cryptographic hash algorithm used to construct the digest.
*
- * The Digest Type field is an 8-bit unsigned integer that identifies
- * the algorithm used to construct the digest.
+ * Herein, SHA384 ([RFC6234]), with Hash Algorithm value 1, is the only
+ * standardized Hash Algorithm defined for ZONEMD records that MUST be
+ * supported by implementations. When SHA384 is used, the size of the
+ * Digest field is 48 octets. The result of the SHA384 digest algorithm
+ * MUST NOT be truncated, and the entire 48-octet digest is published in
+ * the ZONEMD record.
*
- * At the time of this writing, SHA384, with value 1, is the only Digest
- * Type defined for ZONEMD records.
+ * SHA512 ([RFC6234]), with Hash Algorithm value 2, is also defined for
+ * ZONEMD records and SHOULD be supported by implementations. When
+ * SHA512 is used, the size of the Digest field is 64 octets. The
+ * result of the SHA512 digest algorithm MUST NOT be truncated, and the
+ * entire 64-octet digest is published in the ZONEMD record.
*
- * 2.1.3. The Reserved Field
+ * Hash Algorithm values 240-254 are allocated for Private Use.
*
- * The Reserved field is an 8-bit unsigned integer, which is always set
- * to zero.
+ * The "ZONEMD Hash Algorithms" registry is further described in
+ * Section 5.
*
- * 2.1.4. The Digest Field
+ * 2.2.4. The Digest Field
*
* The Digest field is a variable-length sequence of octets containing
- * the message digest.
+ * the output of the hash algorithm. The length of the Digest field is
+ * determined by deducting the fixed size of the Serial, Scheme, and
+ * Hash Algorithm fields from the RDATA size in the ZONEMD RR header.
+ *
+ * The Digest field MUST NOT be shorter than 12 octets. Digests for the
+ * SHA384 and SHA512 hash algorithms specified herein are never
+ * truncated. Digests for future hash algorithms MAY be truncated but
+ * MUST NOT be truncated to a length that results in less than 96 bits
+ * (12 octets) of equivalent strength.
+ *
+ * Section 3 describes how to calculate the digest for a zone.
+ * Section 4 describes how to use the digest to verify the contents of a
+ * zone.
+ *
*/
static void
zonemd(void **state) {
- text_ok_t text_ok[] = { TEXT_INVALID(""),
- TEXT_INVALID("0"),
- TEXT_INVALID("0 0"),
- TEXT_INVALID("0 0 0"),
- TEXT_INVALID("99999999 0 0"),
- TEXT_INVALID("2019020700 0 0"),
- TEXT_INVALID("2019020700 1 0 DEADBEEF"),
- TEXT_VALID("2019020700 2 0 DEADBEEF"),
- TEXT_VALID("2019020700 255 0 DEADBEEF"),
- TEXT_INVALID("2019020700 256 0 DEADBEEF"),
- TEXT_VALID("2019020700 2 255 DEADBEEF"),
- TEXT_INVALID("2019020700 2 256 DEADBEEF"),
- TEXT_VALID("2019020700 1 0 "
- "7162D2BB75C047A53DE98767C9192BEB"
- "14DB01E7E2267135DAF0230A 19BA4A31"
- "6AF6BF64AA5C7BAE24B2992850300509"),
- TEXT_SENTINEL() };
+ text_ok_t text_ok[] = {
+ TEXT_INVALID(""),
+ /* No digest scheme or digest type*/
+ TEXT_INVALID("0"),
+ /* No digest type */
+ TEXT_INVALID("0 0"),
+ /* No digest */
+ TEXT_INVALID("0 0 0"),
+ /* No digest */
+ TEXT_INVALID("99999999 0 0"),
+ /* No digest */
+ TEXT_INVALID("2019020700 0 0"),
+ /* Digest too short */
+ TEXT_INVALID("2019020700 1 1 DEADBEEF"),
+ /* Digest too short */
+ TEXT_INVALID("2019020700 1 2 DEADBEEF"),
+ /* Digest too short */
+ TEXT_INVALID("2019020700 1 3 DEADBEEFDEADBEEFDEADBE"),
+ /* Digest type unknown */
+ TEXT_VALID("2019020700 1 3 DEADBEEFDEADBEEFDEADBEEF"),
+ /* Digest type max */
+ TEXT_VALID("2019020700 1 255 DEADBEEFDEADBEEFDEADBEEF"),
+ /* Digest type too big */
+ TEXT_INVALID("2019020700 0 256 DEADBEEFDEADBEEFDEADBEEF"),
+ /* Scheme max */
+ TEXT_VALID("2019020700 255 3 DEADBEEFDEADBEEFDEADBEEF"),
+ /* Scheme too big */
+ TEXT_INVALID("2019020700 256 3 DEADBEEFDEADBEEFDEADBEEF"),
+ /* SHA384 */
+ TEXT_VALID("2019020700 1 1 "
+ "7162D2BB75C047A53DE98767C9192BEB"
+ "14DB01E7E2267135DAF0230A 19BA4A31"
+ "6AF6BF64AA5C7BAE24B2992850300509"),
+ /* SHA512 */
+ TEXT_VALID("2019020700 1 2 "
+ "08CFA1115C7B948C4163A901270395EA"
+ "226A930CD2CBCF2FA9A5E6EB 85F37C8A"
+ "4E114D884E66F176EAB121CB02DB7D65"
+ "2E0CC4827E7A3204 F166B47E5613FD27"),
+ /* SHA384 too short and with private scheme */
+ TEXT_INVALID("2021042801 0 1 "
+ "7162D2BB75C047A53DE98767C9192BEB"
+ "6AF6BF64AA5C7BAE24B2992850300509"),
+ /* SHA512 too short and with private scheme */
+ TEXT_INVALID("2021042802 5 2 "
+ "A897B40072ECAE9E4CA3F1F227DE8F5E"
+ "480CDEBB16DFC64C1C349A7B5F6C71AB"
+ "E8A88B76EF0BA1604EC25752E946BF98"),
+ TEXT_SENTINEL()
+ };
wire_ok_t wire_ok[] = {
/*
* Short.
@@ -2498,18 +2577,28 @@ zonemd(void **state) {
*/
WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
/*
- * Minimal, one-octet hash for an undefined digest type.
+ * Short 11-octet digest.
+ */
+ WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00),
+ /*
+ * Minimal, 12-octet hash for an undefined digest type.
*/
- WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
+ WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00),
/*
* SHA-384 is defined, so we insist there be a digest of
* the expected length.
*/
- WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00),
+ WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00),
/*
* 48-octet digest, valid for SHA-384.
*/
- WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xde, 0xad, 0xbe,
+ WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xde, 0xad, 0xbe,
0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
@@ -2519,7 +2608,7 @@ zonemd(void **state) {
/*
* 56-octet digest, too long for SHA-384.
*/
- WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xde, 0xad,
+ WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xde, 0xad,
0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
@@ -2528,9 +2617,44 @@ zonemd(void **state) {
0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
0xbe, 0xef, 0xfa, 0xce),
/*
+ * 56-octet digest, too short for SHA-512
+ */
+ WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad),
+ /*
+ * 64-octet digest, just right for SHA-512
+ */
+ WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad, 0xbe,
+ 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
+ 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
+ 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
+ 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef),
+ /*
+ * 72-octet digest, too long for SHA-512
+ */
+ WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad,
+ 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
+ 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce),
+ /*
* 56-octet digest, valid for an undefined digest type.
*/
- WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xad, 0xbe,
+ WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xde, 0xad, 0xbe,
0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe,
0xef, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce,
diff --git a/external/mpl/bind/dist/lib/dns/tests/update_test.c b/external/mpl/bind/dist/lib/dns/tests/update_test.c
index 3d7b19b57db..c1fcc7f1f4e 100644
--- a/external/mpl/bind/dist/lib/dns/tests/update_test.c
+++ b/external/mpl/bind/dist/lib/dns/tests/update_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: update_test.c,v 1.9 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: update_test.c,v 1.10 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -258,6 +258,7 @@ unixtime_zero_test(void **state) {
static void
past_to_date_test(void **state) {
uint32_t old, serial;
+ dns_updatemethod_t used = dns_updatemethod_none;
UNUSED(state);
@@ -265,11 +266,11 @@ past_to_date_test(void **state) {
old = dns_update_soaserial(0, dns_updatemethod_date, NULL);
set_mystdtime(2014, 4, 1);
- serial = dns_update_soaserial(old, dns_updatemethod_date, NULL);
-
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
assert_true(isc_serial_lt(old, serial));
assert_int_not_equal(serial, 0);
assert_int_equal(serial, 2014040100);
+ assert_int_equal(dns_updatemethod_date, used);
}
/* now to date */
@@ -277,16 +278,35 @@ static void
now_to_date_test(void **state) {
uint32_t old;
uint32_t serial;
+ dns_updatemethod_t used = dns_updatemethod_none;
UNUSED(state);
set_mystdtime(2014, 4, 1);
old = dns_update_soaserial(0, dns_updatemethod_date, NULL);
- serial = dns_update_soaserial(old, dns_updatemethod_date, NULL);
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
assert_true(isc_serial_lt(old, serial));
assert_int_not_equal(serial, 0);
assert_int_equal(serial, 2014040101);
+ assert_int_equal(dns_updatemethod_date, used);
+
+ old = 2014040198;
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
+ assert_true(isc_serial_lt(old, serial));
+ assert_int_not_equal(serial, 0);
+ assert_int_equal(serial, 2014040199);
+ assert_int_equal(dns_updatemethod_date, used);
+
+ /*
+ * Stealing from "tomorrow".
+ */
+ old = 2014040199;
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
+ assert_true(isc_serial_lt(old, serial));
+ assert_int_not_equal(serial, 0);
+ assert_int_equal(serial, 2014040200);
+ assert_int_equal(dns_updatemethod_increment, used);
}
/* future to date */
@@ -294,6 +314,7 @@ static void
future_to_date_test(void **state) {
uint32_t old;
uint32_t serial;
+ dns_updatemethod_t used = dns_updatemethod_none;
UNUSED(state);
@@ -301,10 +322,18 @@ future_to_date_test(void **state) {
old = dns_update_soaserial(0, dns_updatemethod_date, NULL);
set_mystdtime(2014, 3, 31);
- serial = dns_update_soaserial(old, dns_updatemethod_date, NULL);
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
assert_true(isc_serial_lt(old, serial));
assert_int_not_equal(serial, 0);
assert_int_equal(serial, 2014040101);
+ assert_int_equal(dns_updatemethod_increment, used);
+
+ old = serial;
+ serial = dns_update_soaserial(old, dns_updatemethod_date, &used);
+ assert_true(isc_serial_lt(old, serial));
+ assert_int_not_equal(serial, 0);
+ assert_int_equal(serial, 2014040102);
+ assert_int_equal(dns_updatemethod_increment, used);
}
int
diff --git a/external/mpl/bind/dist/lib/dns/tkey.c b/external/mpl/bind/dist/lib/dns/tkey.c
index 8d258058264..1c1e5223b05 100644
--- a/external/mpl/bind/dist/lib/dns/tkey.c
+++ b/external/mpl/bind/dist/lib/dns/tkey.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tkey.c,v 1.10 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: tkey.c,v 1.11 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -176,8 +176,7 @@ add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
dns_message_takebuffer(msg, &tmprdatabuf);
RETERR(dns_message_gettempname(msg, &newname));
- dns_name_init(newname, NULL);
- dns_name_dup(name, msg->mctx, newname);
+ dns_name_copynf(name, newname);
RETERR(dns_message_gettemprdatalist(msg, &newlist));
newlist->rdclass = newrdata->rdclass;
@@ -952,7 +951,7 @@ buildquery(dns_message_t *msg, const dns_name_t *name, dns_rdata_tkey_t *tkey,
dns_rdataset_t *question = NULL, *tkeyset = NULL;
dns_rdatalist_t *tkeylist = NULL;
dns_rdata_t *rdata = NULL;
- isc_buffer_t *dynbuf = NULL, *anamebuf = NULL, *qnamebuf = NULL;
+ isc_buffer_t *dynbuf = NULL;
isc_result_t result;
unsigned int len;
@@ -969,8 +968,6 @@ buildquery(dns_message_t *msg, const dns_name_t *name, dns_rdata_tkey_t *tkey,
len = 16 + tkey->algorithm.length + tkey->keylen + tkey->otherlen;
isc_buffer_allocate(msg->mctx, &dynbuf, len);
- isc_buffer_allocate(msg->mctx, &anamebuf, name->length);
- isc_buffer_allocate(msg->mctx, &qnamebuf, name->length);
RETERR(dns_message_gettemprdata(msg, &rdata));
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
@@ -985,17 +982,13 @@ buildquery(dns_message_t *msg, const dns_name_t *name, dns_rdata_tkey_t *tkey,
RETERR(dns_message_gettemprdataset(msg, &tkeyset));
RETERR(dns_rdatalist_tordataset(tkeylist, tkeyset));
- dns_name_init(qname, NULL);
- RETERR(dns_name_copy(name, qname, qnamebuf));
-
- dns_name_init(aname, NULL);
- RETERR(dns_name_copy(name, aname, anamebuf));
+ dns_name_copynf(name, qname);
+ dns_name_copynf(name, aname);
ISC_LIST_APPEND(qname->list, question, link);
ISC_LIST_APPEND(aname->list, tkeyset, link);
dns_message_addname(msg, qname, DNS_SECTION_QUESTION);
- dns_message_takebuffer(msg, &qnamebuf);
/*
* Windows 2000 needs this in the answer section, not the additional
@@ -1006,7 +999,6 @@ buildquery(dns_message_t *msg, const dns_name_t *name, dns_rdata_tkey_t *tkey,
} else {
dns_message_addname(msg, aname, DNS_SECTION_ADDITIONAL);
}
- dns_message_takebuffer(msg, &anamebuf);
return (ISC_R_SUCCESS);
@@ -1024,12 +1016,6 @@ failure:
if (dynbuf != NULL) {
isc_buffer_free(&dynbuf);
}
- if (qnamebuf != NULL) {
- isc_buffer_free(&qnamebuf);
- }
- if (anamebuf != NULL) {
- isc_buffer_free(&anamebuf);
- }
return (result);
}
diff --git a/external/mpl/bind/dist/lib/dns/tsig.c b/external/mpl/bind/dist/lib/dns/tsig.c
index ddc6a8fb1fd..1b5780718d3 100644
--- a/external/mpl/bind/dist/lib/dns/tsig.c
+++ b/external/mpl/bind/dist/lib/dns/tsig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tsig.c,v 1.9 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: tsig.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -762,7 +762,7 @@ dns_tsig_sign(dns_message_t *msg) {
unsigned char data[128];
isc_buffer_t databuf, sigbuf;
isc_buffer_t *dynbuf = NULL;
- dns_name_t *owner;
+ dns_name_t *owner = NULL;
dns_rdata_t *rdata = NULL;
dns_rdatalist_t *datalist = NULL;
dns_rdataset_t *dataset = NULL;
@@ -1018,20 +1018,17 @@ dns_tsig_sign(dns_message_t *msg) {
tsig.signature = NULL;
}
- owner = NULL;
ret = dns_message_gettempname(msg, &owner);
if (ret != ISC_R_SUCCESS) {
goto cleanup_rdata;
}
- dns_name_init(owner, NULL);
- dns_name_dup(&key->name, msg->mctx, owner);
+ dns_name_copynf(&key->name, owner);
- datalist = NULL;
ret = dns_message_gettemprdatalist(msg, &datalist);
if (ret != ISC_R_SUCCESS) {
goto cleanup_owner;
}
- dataset = NULL;
+
ret = dns_message_gettemprdataset(msg, &dataset);
if (ret != ISC_R_SUCCESS) {
goto cleanup_rdatalist;
diff --git a/external/mpl/bind/dist/lib/dns/update.c b/external/mpl/bind/dist/lib/dns/update.c
index 8fd89dffc69..efb6e7562fc 100644
--- a/external/mpl/bind/dist/lib/dns/update.c
+++ b/external/mpl/bind/dist/lib/dns/update.c
@@ -1,4 +1,4 @@
-/* $NetBSD: update.c,v 1.9 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: update.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1066,11 +1066,16 @@ find_zone_keys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
isc_stdtime_t now;
dns_dbnode_t *node = NULL;
const char *directory = dns_zone_getkeydirectory(zone);
+
CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node));
isc_stdtime_get(&now);
- CHECK(dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db),
- directory, now, mctx, maxkeys, keys,
- nkeys));
+
+ dns_zone_lock_keyfiles(zone);
+ result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db),
+ directory, now, mctx, maxkeys, keys,
+ nkeys);
+ dns_zone_unlock_keyfiles(zone);
+
failure:
if (node != NULL) {
dns_db_detachnode(db, &node);
@@ -1089,6 +1094,7 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
bool keyset_kskonly) {
isc_result_t result;
dns_dbnode_t *node = NULL;
+ dns_kasp_t *kasp = dns_zone_getkasp(zone);
dns_rdataset_t rdataset;
dns_rdata_t sig_rdata = DNS_RDATA_INIT;
dns_stats_t *dnssecsignstats = dns_zone_getdnssecsignstats(zone);
@@ -1099,7 +1105,7 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
bool use_kasp = false;
isc_mem_t *mctx = diff->mctx;
- if (dns_zone_use_kasp(zone)) {
+ if (kasp != NULL) {
check_ksk = false;
keyset_kskonly = true;
use_kasp = true;
@@ -1580,7 +1586,8 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
DNS_ZONEOPT_DNSKEYKSKONLY) != 0);
/*
- * Get the NSEC/NSEC3 TTL from the SOA MINIMUM field.
+ * Calculate the NSEC/NSEC3 TTL as a minimum of the SOA TTL and
+ * MINIMUM field.
*/
CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node));
dns_rdataset_init(&rdataset);
@@ -1590,7 +1597,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
CHECK(dns_rdataset_first(&rdataset));
dns_rdataset_current(&rdataset, &rdata);
CHECK(dns_rdata_tostruct(&rdata, &soa, NULL));
- state->nsecttl = soa.minimum;
+ state->nsecttl = ISC_MIN(rdataset.ttl, soa.minimum);
dns_rdataset_disassociate(&rdataset);
dns_db_detachnode(db, &node);
@@ -2244,8 +2251,19 @@ dns_update_soaserial(uint32_t serial, dns_updatemethod_t method,
case dns_updatemethod_unixtime:
case dns_updatemethod_date:
if (!(new_serial != 0 && isc_serial_gt(new_serial, serial))) {
- method = dns_updatemethod_increment;
- new_serial = dns__update_soaserial(serial, method);
+ /*
+ * If the new date serial following YYYYMMDD00 is equal
+ * to or smaller than the current serial, but YYYYMMDD99
+ * would be larger, pretend we have used the
+ * "dns_updatemethod_date" method.
+ */
+ if (method == dns_updatemethod_unixtime ||
+ !isc_serial_gt(new_serial + 99, serial))
+ {
+ method = dns_updatemethod_increment;
+ }
+ new_serial = dns__update_soaserial(
+ serial, dns_updatemethod_increment);
}
break;
default:
diff --git a/external/mpl/bind/dist/lib/dns/validator.c b/external/mpl/bind/dist/lib/dns/validator.c
index f9ad7ba5d19..9984a0882b4 100644
--- a/external/mpl/bind/dist/lib/dns/validator.c
+++ b/external/mpl/bind/dist/lib/dns/validator.c
@@ -1,4 +1,4 @@
-/* $NetBSD: validator.c,v 1.9 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: validator.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -2247,6 +2247,26 @@ findnsec3proofs(dns_validator_t *val) {
if (unknown) {
val->attributes |= VALATTR_FOUNDUNKNOWN;
}
+ if (result == DNS_R_NSEC3ITERRANGE) {
+ /*
+ * We don't really know which NSEC3 record provides
+ * which proof. Just populate them.
+ */
+ if (NEEDNOQNAME(val) &&
+ proofs[DNS_VALIDATOR_NOQNAMEPROOF] == NULL) {
+ proofs[DNS_VALIDATOR_NOQNAMEPROOF] = name;
+ } else if (setclosest) {
+ proofs[DNS_VALIDATOR_CLOSESTENCLOSER] = name;
+ } else if (NEEDNODATA(val) &&
+ proofs[DNS_VALIDATOR_NODATAPROOF] == NULL) {
+ proofs[DNS_VALIDATOR_NODATAPROOF] = name;
+ } else if (NEEDNOWILDCARD(val) &&
+ proofs[DNS_VALIDATOR_NOWILDCARDPROOF] ==
+ NULL) {
+ proofs[DNS_VALIDATOR_NOWILDCARDPROOF] = name;
+ }
+ return (result);
+ }
if (result != ISC_R_SUCCESS) {
continue;
}
@@ -2503,7 +2523,13 @@ validate_nx(dns_validator_t *val, bool resume) {
*/
if (!NEEDNODATA(val) && !NEEDNOWILDCARD(val) && NEEDNOQNAME(val)) {
if (!FOUNDNOQNAME(val)) {
- findnsec3proofs(val);
+ result = findnsec3proofs(val);
+ if (result == DNS_R_NSEC3ITERRANGE) {
+ validator_log(val, ISC_LOG_DEBUG(3),
+ "too many iterations");
+ markanswer(val, "validate_nx (3)", NULL);
+ return (ISC_R_SUCCESS);
+ }
}
if (FOUNDNOQNAME(val) && FOUNDCLOSEST(val) && !FOUNDOPTOUT(val))
@@ -2533,7 +2559,13 @@ validate_nx(dns_validator_t *val, bool resume) {
}
if (!FOUNDNOQNAME(val) && !FOUNDNODATA(val)) {
- findnsec3proofs(val);
+ result = findnsec3proofs(val);
+ if (result == DNS_R_NSEC3ITERRANGE) {
+ validator_log(val, ISC_LOG_DEBUG(3),
+ "too many iterations");
+ markanswer(val, "validate_nx (4)", NULL);
+ return (ISC_R_SUCCESS);
+ }
}
/*
diff --git a/external/mpl/bind/dist/lib/dns/xfrin.c b/external/mpl/bind/dist/lib/dns/xfrin.c
index 76814102e3a..f57e24c3f91 100644
--- a/external/mpl/bind/dist/lib/dns/xfrin.c
+++ b/external/mpl/bind/dist/lib/dns/xfrin.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xfrin.c,v 1.9 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: xfrin.c,v 1.10 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -181,6 +181,9 @@ struct dns_xfrin_ctx {
uint32_t current_serial;
dns_journal_t *journal;
} ixfr;
+
+ dns_rdata_t firstsoa;
+ unsigned char *firstsoa_data;
};
#define XFRIN_MAGIC ISC_MAGIC('X', 'f', 'r', 'I')
@@ -570,6 +573,13 @@ redo:
if (xfr->reqtype == dns_rdatatype_axfr) {
xfr->checkid = false;
}
+ xfr->firstsoa = *rdata;
+ if (xfr->firstsoa_data != NULL) {
+ isc_mem_free(xfr->mctx, xfr->firstsoa_data);
+ }
+ xfr->firstsoa_data = isc_mem_allocate(xfr->mctx, rdata->length);
+ memcpy(xfr->firstsoa_data, rdata->data, rdata->length);
+ xfr->firstsoa.data = xfr->firstsoa_data;
xfr->state = XFRST_FIRSTDATA;
break;
@@ -654,6 +664,16 @@ redo:
}
CHECK(axfr_putdata(xfr, DNS_DIFFOP_ADD, name, ttl, rdata));
if (rdata->type == dns_rdatatype_soa) {
+ /*
+ * Use dns_rdata_compare instead of memcmp to
+ * allow for case differences.
+ */
+ if (dns_rdata_compare(rdata, &xfr->firstsoa) != 0) {
+ xfrin_log(xfr, ISC_LOG_ERROR,
+ "start and ending SOA records "
+ "mismatch");
+ FAIL(DNS_R_FORMERR);
+ }
CHECK(axfr_commit(xfr));
xfr->state = XFRST_AXFR_END;
break;
@@ -901,6 +921,8 @@ xfrin_create(isc_mem_t *mctx, dns_zone_t *zone, dns_db_t *db, isc_task_t *task,
xfr->axfr.add = NULL;
xfr->axfr.add_private = NULL;
+ dns_rdata_init(&xfr->firstsoa);
+ xfr->firstsoa_data = NULL;
dns_name_dup(zonename, mctx, &xfr->name);
@@ -1087,7 +1109,6 @@ tuple2msgname(dns_difftuple_t *tuple, dns_message_t *msg, dns_name_t **target) {
CHECK(dns_rdatalist_tordataset(rdl, rds));
CHECK(dns_message_gettempname(msg, &name));
- dns_name_init(name, NULL);
dns_name_clone(&tuple->name, name);
ISC_LIST_APPEND(name->list, rds, link);
@@ -1131,7 +1152,6 @@ xfrin_send_request(dns_xfrin_ctx_t *xfr) {
/* Create a name for the question section. */
CHECK(dns_message_gettempname(msg, &qname));
- dns_name_init(qname, NULL);
dns_name_clone(&xfr->name, qname);
/* Formulate the question and attach it to the question name. */
@@ -1615,6 +1635,10 @@ maybe_free(dns_xfrin_ctx_t *xfr) {
dns_zone_idetach(&xfr->zone);
}
+ if (xfr->firstsoa_data != NULL) {
+ isc_mem_free(xfr->mctx, xfr->firstsoa_data);
+ }
+
isc_mem_putanddetach(&xfr->mctx, xfr, sizeof(*xfr));
}
diff --git a/external/mpl/bind/dist/lib/dns/zone.c b/external/mpl/bind/dist/lib/dns/zone.c
index 6b8136990e0..a4f691bbdd6 100644
--- a/external/mpl/bind/dist/lib/dns/zone.c
+++ b/external/mpl/bind/dist/lib/dns/zone.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zone.c,v 1.14 2021/04/29 17:26:11 christos Exp $ */
+/* $NetBSD: zone.c,v 1.15 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -60,6 +60,7 @@
#include <dns/name.h>
#include <dns/nsec.h>
#include <dns/nsec3.h>
+#include <dns/opcode.h>
#include <dns/peer.h>
#include <dns/private.h>
#include <dns/rcode.h>
@@ -95,6 +96,9 @@
#define NOTIFY_MAGIC ISC_MAGIC('N', 't', 'f', 'y')
#define DNS_NOTIFY_VALID(notify) ISC_MAGIC_VALID(notify, NOTIFY_MAGIC)
+#define CHECKDS_MAGIC ISC_MAGIC('C', 'h', 'D', 'S')
+#define DNS_CHECKDS_VALID(checkds) ISC_MAGIC_VALID(checkds, CHECKDS_MAGIC)
+
#define STUB_MAGIC ISC_MAGIC('S', 't', 'u', 'b')
#define DNS_STUB_VALID(stub) ISC_MAGIC_VALID(stub, STUB_MAGIC)
@@ -110,6 +114,9 @@
#define IO_MAGIC ISC_MAGIC('Z', 'm', 'I', 'O')
#define DNS_IO_VALID(load) ISC_MAGIC_VALID(load, IO_MAGIC)
+#define KEYMGMT_MAGIC ISC_MAGIC('M', 'g', 'm', 't')
+#define DNS_KEYMGMT_VALID(load) ISC_MAGIC_VALID(load, KEYMGMT_MAGIC)
+
/*%
* Ensure 'a' is at least 'min' but not more than 'max'.
*/
@@ -125,6 +132,19 @@
#define ID(x) dst_key_id(x)
#define ALG(x) dst_key_alg(x)
+/*%
+ * KASP flags
+ */
+#define KASP_LOCK(k) \
+ if ((k) != NULL) { \
+ LOCK((&((k)->lock))); \
+ }
+
+#define KASP_UNLOCK(k) \
+ if ((k) != NULL) { \
+ UNLOCK((&((k)->lock))); \
+ }
+
/*
* Default values.
*/
@@ -142,12 +162,14 @@
#endif /* ifndef DNS_DUMP_DELAY */
typedef struct dns_notify dns_notify_t;
+typedef struct dns_checkds dns_checkds_t;
typedef struct dns_stub dns_stub_t;
typedef struct dns_load dns_load_t;
typedef struct dns_forward dns_forward_t;
typedef ISC_LIST(dns_forward_t) dns_forwardlist_t;
typedef struct dns_io dns_io_t;
typedef ISC_LIST(dns_io_t) dns_iolist_t;
+typedef struct dns_keymgmt dns_keymgmt_t;
typedef struct dns_signing dns_signing_t;
typedef ISC_LIST(dns_signing_t) dns_signinglist_t;
typedef struct dns_nsec3chain dns_nsec3chain_t;
@@ -269,6 +291,14 @@ struct dns_zone {
unsigned int masterscnt;
unsigned int curmaster;
isc_sockaddr_t masteraddr;
+
+ isc_sockaddr_t *parentals;
+ isc_dscp_t *parentaldscps;
+ dns_name_t **parentalkeynames;
+ dns_dnsseckeylist_t checkds_ok;
+ unsigned int parentalscnt;
+ isc_sockaddr_t parentaladdr;
+
dns_notifytype_t notifytype;
isc_sockaddr_t *notify;
dns_name_t **notifykeynames;
@@ -279,6 +309,8 @@ struct dns_zone {
isc_task_t *loadtask;
isc_sockaddr_t notifysrc4;
isc_sockaddr_t notifysrc6;
+ isc_sockaddr_t parentalsrc4;
+ isc_sockaddr_t parentalsrc6;
isc_sockaddr_t xfrsource4;
isc_sockaddr_t xfrsource6;
isc_sockaddr_t altxfrsource4;
@@ -286,6 +318,8 @@ struct dns_zone {
isc_sockaddr_t sourceaddr;
isc_dscp_t notifysrc4dscp;
isc_dscp_t notifysrc6dscp;
+ isc_dscp_t parentalsrc4dscp;
+ isc_dscp_t parentalsrc6dscp;
isc_dscp_t xfrsource4dscp;
isc_dscp_t xfrsource6dscp;
isc_dscp_t altxfrsource4dscp;
@@ -303,6 +337,7 @@ struct dns_zone {
bool zero_no_soa_ttl;
dns_severity_t check_names;
ISC_LIST(dns_notify_t) notifies;
+ ISC_LIST(dns_checkds_t) checkds_requests;
dns_request_t *request;
dns_loadctx_t *lctx;
dns_io_t *readio;
@@ -437,8 +472,9 @@ struct dns_zone {
uint32_t sourceserial;
/*%
- * maximum zone ttl
+ * soa and maximum zone ttl
*/
+ dns_ttl_t soattl;
dns_ttl_t maxttl;
/*
@@ -567,6 +603,7 @@ struct dns_zonemgr {
isc_taskpool_t *loadtasks;
isc_task_t *task;
isc_pool_t *mctxpool;
+ isc_ratelimiter_t *checkdsrl;
isc_ratelimiter_t *notifyrl;
isc_ratelimiter_t *refreshrl;
isc_ratelimiter_t *startupnotifyrl;
@@ -583,6 +620,7 @@ struct dns_zonemgr {
/* Configuration data. */
uint32_t transfersin;
uint32_t transfersperns;
+ unsigned int checkdsrate;
unsigned int notifyrate;
unsigned int startupnotifyrate;
unsigned int serialqueryrate;
@@ -597,6 +635,8 @@ struct dns_zonemgr {
/* Locked by urlock. */
/* LRU cache */
struct dns_unreachable unreachable[UNREACH_CACHE_SIZE];
+
+ dns_keymgmt_t *keymgmt;
};
/*%
@@ -621,6 +661,22 @@ struct dns_notify {
#define DNS_NOTIFY_STARTUP 0x0002U
/*%
+ * Hold checkds state.
+ */
+struct dns_checkds {
+ unsigned int magic;
+ unsigned int flags;
+ isc_mem_t *mctx;
+ dns_zone_t *zone;
+ dns_request_t *request;
+ isc_sockaddr_t dst;
+ dns_tsigkey_t *key;
+ isc_dscp_t dscp;
+ ISC_LINK(dns_checkds_t) link;
+ isc_event_t *event;
+};
+
+/*%
* dns_stub holds state while performing a 'stub' transfer.
* 'db' is the zone's 'db' or a new one if this is the initial
* transfer.
@@ -703,6 +759,31 @@ struct dns_nsec3chain {
bool save_delete_nsec;
ISC_LINK(dns_nsec3chain_t) link;
};
+
+/*%
+ * Hold key file IO locks.
+ */
+typedef struct dns_keyfileio {
+ struct dns_keyfileio *next;
+ uint32_t hashval;
+ dns_fixedname_t fname;
+ dns_name_t *name;
+ atomic_uint_fast32_t count;
+ isc_mutex_t lock;
+} dns_keyfileio_t;
+
+struct dns_keymgmt {
+ unsigned int magic;
+ isc_rwlock_t lock;
+ isc_mem_t *mctx;
+
+ dns_keyfileio_t **table;
+
+ atomic_uint_fast32_t count;
+
+ uint32_t bits;
+};
+
/*%<
* 'dbiterator' contains a iterator for the database. If we are creating
* a NSEC3 chain only the non-NSEC3 nodes will be iterated. If we are
@@ -839,6 +920,16 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub);
static int
message_count(dns_message_t *msg, dns_section_t section, dns_rdatatype_t type);
static void
+checkds_cancel(dns_zone_t *zone);
+static void
+checkds_send(dns_zone_t *zone);
+static isc_result_t
+checkds_createmessage(dns_zone_t *zone, dns_message_t **messagep);
+static void
+checkds_done(isc_task_t *task, isc_event_t *event);
+static void
+checkds_send_toaddr(isc_task_t *task, isc_event_t *event);
+static void
notify_cancel(dns_zone_t *zone);
static void
notify_find_address(dns_notify_t *notify);
@@ -873,9 +964,9 @@ rss_post(dns_zone_t *, isc_event_t *);
static isc_result_t
zone_get_from_db(dns_zone_t *zone, dns_db_t *db, unsigned int *nscount,
- unsigned int *soacount, uint32_t *serial, uint32_t *refresh,
- uint32_t *retry, uint32_t *expire, uint32_t *minimum,
- unsigned int *errors);
+ unsigned int *soacount, uint32_t *soattl, uint32_t *serial,
+ uint32_t *refresh, uint32_t *retry, uint32_t *expire,
+ uint32_t *minimum, unsigned int *errors);
static void
zone_freedbargs(dns_zone_t *zone);
@@ -899,6 +990,8 @@ static void
zone_rekey(dns_zone_t *zone);
static isc_result_t
zone_send_securedb(dns_zone_t *zone, dns_db_t *db);
+static dns_ttl_t
+zone_nsecttl(dns_zone_t *zone);
static void
setrl(isc_ratelimiter_t *rl, unsigned int *rate, unsigned int value);
static void
@@ -944,10 +1037,13 @@ static const char *dbargv_default[] = { "rbt" };
typedef struct nsec3param nsec3param_t;
struct nsec3param {
+ dns_rdata_nsec3param_t rdata;
unsigned char data[DNS_NSEC3PARAM_BUFFERSIZE + 1];
unsigned int length;
bool nsec;
bool replace;
+ bool resalt;
+ bool lookup;
ISC_LINK(nsec3param_t) link;
};
typedef ISC_LIST(nsec3param_t) nsec3paramlist_t;
@@ -994,14 +1090,53 @@ inc_stats(dns_zone_t *zone, isc_statscounter_t counter) {
isc_result_t
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
isc_result_t result;
- dns_zone_t *zone;
isc_time_t now;
+ dns_zone_t *zone = NULL;
+ dns_zone_t z = { .masterformat = dns_masterformat_none,
+ .journalsize = -1,
+ .rdclass = dns_rdataclass_none,
+ .type = dns_zone_none,
+ .refresh = DNS_ZONE_DEFAULTREFRESH,
+ .retry = DNS_ZONE_DEFAULTRETRY,
+ .maxrefresh = DNS_ZONE_MAXREFRESH,
+ .minrefresh = DNS_ZONE_MINREFRESH,
+ .maxretry = DNS_ZONE_MAXRETRY,
+ .minretry = DNS_ZONE_MINRETRY,
+ .notifytype = dns_notifytype_yes,
+ .zero_no_soa_ttl = true,
+ .check_names = dns_severity_ignore,
+ .idlein = DNS_DEFAULT_IDLEIN,
+ .idleout = DNS_DEFAULT_IDLEOUT,
+ .notifysrc4dscp = -1,
+ .notifysrc6dscp = -1,
+ .parentalsrc4dscp = -1,
+ .parentalsrc6dscp = -1,
+ .xfrsource4dscp = -1,
+ .xfrsource6dscp = -1,
+ .altxfrsource4dscp = -1,
+ .altxfrsource6dscp = -1,
+ .maxxfrin = MAX_XFER_TIME,
+ .maxxfrout = MAX_XFER_TIME,
+ .sigvalidityinterval = 30 * 24 * 3600,
+ .sigresigninginterval = 7 * 24 * 3600,
+ .statlevel = dns_zonestat_none,
+ .notifydelay = 5,
+ .signatures = 10,
+ .nodes = 100,
+ .privatetype = (dns_rdatatype_t)0xffffU,
+ .rpz_num = DNS_RPZ_INVALID_NUM,
+ .requestixfr = true,
+ .ixfr_ratio = 100,
+ .requestexpire = true,
+ .updatemethod = dns_updatemethod_increment,
+ .magic = ZONE_MAGIC };
REQUIRE(zonep != NULL && *zonep == NULL);
REQUIRE(mctx != NULL);
TIME_NOW(&now);
zone = isc_mem_get(mctx, sizeof(*zone));
+ *zone = z;
zone->mctx = NULL;
isc_mem_attach(mctx, &zone->mctx);
@@ -1011,158 +1146,45 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
#ifdef DNS_ZONE_CHECKLOCK
zone->locked = false;
#endif /* ifdef DNS_ZONE_CHECKLOCK */
- zone->db = NULL;
- zone->zmgr = NULL;
+
+ zone->notifytime = now;
+
ISC_LINK_INIT(zone, link);
isc_refcount_init(&zone->erefs, 1);
isc_refcount_init(&zone->irefs, 0);
dns_name_init(&zone->origin, NULL);
- zone->strnamerd = NULL;
- zone->strname = NULL;
- zone->strrdclass = NULL;
- zone->strviewname = NULL;
- zone->masterfile = NULL;
ISC_LIST_INIT(zone->includes);
ISC_LIST_INIT(zone->newincludes);
- zone->nincludes = 0;
- zone->masterformat = dns_masterformat_none;
- zone->masterstyle = NULL;
- zone->keydirectory = NULL;
- zone->journalsize = -1;
- zone->journal = NULL;
- zone->rdclass = dns_rdataclass_none;
- zone->type = dns_zone_none;
atomic_init(&zone->flags, 0);
atomic_init(&zone->options, 0);
atomic_init(&zone->keyopts, 0);
- zone->db_argc = 0;
- zone->db_argv = NULL;
isc_time_settoepoch(&zone->expiretime);
isc_time_settoepoch(&zone->refreshtime);
isc_time_settoepoch(&zone->dumptime);
isc_time_settoepoch(&zone->loadtime);
- zone->notifytime = now;
isc_time_settoepoch(&zone->resigntime);
isc_time_settoepoch(&zone->keywarntime);
isc_time_settoepoch(&zone->signingtime);
isc_time_settoepoch(&zone->nsec3chaintime);
isc_time_settoepoch(&zone->refreshkeytime);
- zone->refreshkeyinterval = 0;
- zone->refreshkeycount = 0;
- zone->refresh = DNS_ZONE_DEFAULTREFRESH;
- zone->retry = DNS_ZONE_DEFAULTRETRY;
- zone->expire = 0;
- zone->minimum = 0;
- zone->maxrefresh = DNS_ZONE_MAXREFRESH;
- zone->minrefresh = DNS_ZONE_MINREFRESH;
- zone->maxretry = DNS_ZONE_MAXRETRY;
- zone->minretry = DNS_ZONE_MINRETRY;
- zone->masters = NULL;
- zone->masterdscps = NULL;
- zone->masterkeynames = NULL;
- zone->mastersok = NULL;
- zone->masterscnt = 0;
- zone->curmaster = 0;
- zone->maxttl = 0;
- zone->notify = NULL;
- zone->notifykeynames = NULL;
- zone->notifydscp = NULL;
- zone->notifytype = dns_notifytype_yes;
- zone->notifycnt = 0;
- zone->task = NULL;
- zone->loadtask = NULL;
- zone->update_acl = NULL;
- zone->forward_acl = NULL;
- zone->notify_acl = NULL;
- zone->query_acl = NULL;
- zone->queryon_acl = NULL;
- zone->xfr_acl = NULL;
- zone->update_disabled = false;
- zone->zero_no_soa_ttl = true;
- zone->check_names = dns_severity_ignore;
- zone->request = NULL;
- zone->lctx = NULL;
- zone->readio = NULL;
- zone->dctx = NULL;
- zone->writeio = NULL;
- zone->timer = NULL;
- zone->idlein = DNS_DEFAULT_IDLEIN;
- zone->idleout = DNS_DEFAULT_IDLEOUT;
- zone->log_key_expired_timer = 0;
ISC_LIST_INIT(zone->notifies);
+ ISC_LIST_INIT(zone->checkds_requests);
isc_sockaddr_any(&zone->notifysrc4);
isc_sockaddr_any6(&zone->notifysrc6);
+ isc_sockaddr_any(&zone->parentalsrc4);
+ isc_sockaddr_any6(&zone->parentalsrc6);
isc_sockaddr_any(&zone->xfrsource4);
isc_sockaddr_any6(&zone->xfrsource6);
isc_sockaddr_any(&zone->altxfrsource4);
isc_sockaddr_any6(&zone->altxfrsource6);
- zone->notifysrc4dscp = -1;
- zone->notifysrc6dscp = -1;
- zone->xfrsource4dscp = -1;
- zone->xfrsource6dscp = -1;
- zone->altxfrsource4dscp = -1;
- zone->altxfrsource6dscp = -1;
- zone->xfr = NULL;
- zone->tsigkey = NULL;
- zone->maxxfrin = MAX_XFER_TIME;
- zone->maxxfrout = MAX_XFER_TIME;
- zone->ssutable = NULL;
- zone->sigvalidityinterval = 30 * 24 * 3600;
- zone->keyvalidityinterval = 0;
- zone->sigresigninginterval = 7 * 24 * 3600;
- zone->kasp = NULL;
- zone->view = NULL;
- zone->prev_view = NULL;
- zone->checkmx = NULL;
- zone->checksrv = NULL;
- zone->checkns = NULL;
ISC_LINK_INIT(zone, statelink);
- zone->statelist = NULL;
- zone->stats = NULL;
- zone->requeststats_on = false;
- zone->statlevel = dns_zonestat_none;
- zone->requeststats = NULL;
- zone->rcvquerystats = NULL;
- zone->dnssecsignstats = NULL;
- zone->notifydelay = 5;
- zone->isself = NULL;
- zone->isselfarg = NULL;
ISC_LIST_INIT(zone->signing);
ISC_LIST_INIT(zone->nsec3chain);
ISC_LIST_INIT(zone->setnsec3param_queue);
- zone->signatures = 10;
- zone->nodes = 100;
- zone->privatetype = (dns_rdatatype_t)0xffffU;
- zone->added = false;
- zone->automatic = false;
- zone->rpzs = NULL;
- zone->rpz_num = DNS_RPZ_INVALID_NUM;
-
- zone->catzs = NULL;
- zone->parentcatz = NULL;
-
ISC_LIST_INIT(zone->forwards);
- zone->raw = NULL;
- zone->secure = NULL;
- zone->sourceserial = 0;
- zone->sourceserialset = false;
- zone->requestixfr = true;
- zone->ixfr_ratio = 100;
- zone->requestexpire = true;
ISC_LIST_INIT(zone->rss_events);
ISC_LIST_INIT(zone->rss_post);
- zone->rss_db = NULL;
- zone->rss_raw = NULL;
- zone->rss_newver = NULL;
- zone->rss_oldver = NULL;
- zone->rss_event = NULL;
- zone->rss_state = NULL;
- zone->updatemethod = dns_updatemethod_increment;
- zone->maxrecords = 0U;
-
- zone->magic = ZONE_MAGIC;
-
- zone->gluecachestats = NULL;
+
result = isc_stats_create(mctx, &zone->gluecachestats,
dns_gluecachestatscounter_max);
if (result != ISC_R_SUCCESS) {
@@ -1188,6 +1210,16 @@ free_refs:
return (result);
}
+static void
+clear_keylist(dns_dnsseckeylist_t *list, isc_mem_t *mctx) {
+ dns_dnsseckey_t *key;
+ while (!ISC_LIST_EMPTY(*list)) {
+ key = ISC_LIST_HEAD(*list);
+ ISC_LIST_UNLINK(*list, key, link);
+ dns_dnsseckey_destroy(mctx, &key);
+ }
+}
+
/*
* Free a zone. Because we require that there be no more
* outstanding events or references, no locking is necessary.
@@ -1281,6 +1313,10 @@ zone_free(dns_zone_t *zone) {
if (zone->kasp != NULL) {
dns_kasp_detach(&zone->kasp);
}
+ if (!ISC_LIST_EMPTY(zone->checkds_ok)) {
+ clear_keylist(&zone->checkds_ok, zone->mctx);
+ }
+
zone->journalsize = -1;
if (zone->journal != NULL) {
isc_mem_free(zone->mctx, zone->journal);
@@ -1310,6 +1346,9 @@ zone_free(dns_zone_t *zone) {
dns_catz_catzs_detach(&zone->catzs);
}
zone_freedbargs(zone);
+
+ RUNTIME_CHECK(dns_zone_setparentals(zone, NULL, NULL, 0) ==
+ ISC_R_SUCCESS);
RUNTIME_CHECK(dns_zone_setprimarieswithkeys(zone, NULL, NULL, 0) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(dns_zone_setalsonotify(zone, NULL, 0) == ISC_R_SUCCESS);
@@ -1451,7 +1490,7 @@ dns_zone_getserial(dns_zone_t *zone, uint32_t *serialp) {
LOCK_ZONE(zone);
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
if (zone->db != NULL) {
- result = zone_get_from_db(zone, zone->db, NULL, &soacount,
+ result = zone_get_from_db(zone, zone->db, NULL, &soacount, NULL,
serialp, NULL, NULL, NULL, NULL,
NULL);
if (result == ISC_R_SUCCESS && soacount == 0) {
@@ -2533,7 +2572,7 @@ get_raw_serial(dns_zone_t *raw, dns_masterrawheader_t *rawdata) {
LOCK(&raw->lock);
if (raw->db != NULL) {
- result = zone_get_from_db(raw, raw->db, NULL, &soacount,
+ result = zone_get_from_db(raw, raw->db, NULL, &soacount, NULL,
&rawdata->sourceserial, NULL, NULL,
NULL, NULL, NULL);
if (result == ISC_R_SUCCESS && soacount > 0U) {
@@ -2585,7 +2624,7 @@ zone_gotwritehandle(isc_task_t *task, isc_event_t *event) {
} else {
output_style = &dns_master_style_default;
}
- result = dns_master_dumpinc(
+ result = dns_master_dumpasync(
zone->mctx, db, version, output_style, zone->masterfile,
zone->task, dump_done, zone, &zone->dctx,
zone->masterformat, &rawdata);
@@ -3915,13 +3954,12 @@ cleanup:
static isc_result_t
check_nsec3param(dns_zone_t *zone, dns_db_t *db) {
+ bool ok = false;
dns_dbnode_t *node = NULL;
- dns_rdataset_t rdataset;
dns_dbversion_t *version = NULL;
dns_rdata_nsec3param_t nsec3param;
- bool ok = false;
+ dns_rdataset_t rdataset;
isc_result_t result;
- dns_rdata_t rdata = DNS_RDATA_INIT;
bool dynamic = (zone->type == dns_zone_master)
? dns_zone_isdynamic(zone, false)
: false;
@@ -3952,18 +3990,21 @@ check_nsec3param(dns_zone_t *zone, dns_db_t *db) {
goto cleanup;
}
- /*
- * For dynamic zones we must support every algorithm so we can
- * regenerate all the NSEC3 chains.
- * For non-dynamic zones we only need to find a supported algorithm.
- */
for (result = dns_rdataset_first(&rdataset); result == ISC_R_SUCCESS;
result = dns_rdataset_next(&rdataset))
{
+ dns_rdata_t rdata = DNS_RDATA_INIT;
+
dns_rdataset_current(&rdataset, &rdata);
result = dns_rdata_tostruct(&rdata, &nsec3param, NULL);
- dns_rdata_reset(&rdata);
- INSIST(result == ISC_R_SUCCESS);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+
+ /*
+ * For dynamic zones we must support every algorithm so we
+ * can regenerate all the NSEC3 chains.
+ * For non-dynamic zones we only need to find a supported
+ * algorithm.
+ */
if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_NSEC3TESTZONE) &&
nsec3param.hash == DNS_NSEC3_UNKNOWNALG && !dynamic)
{
@@ -3991,6 +4032,16 @@ check_nsec3param(dns_zone_t *zone, dns_db_t *db) {
} else {
ok = true;
}
+
+ /*
+ * Warn if the zone has excessive NSEC3 iterations.
+ */
+ if (nsec3param.iterations > dns_nsec3_maxiterations()) {
+ dnssec_log(zone, ISC_LOG_WARNING,
+ "excessive NSEC3PARAM iterations %u > %u",
+ nsec3param.iterations,
+ dns_nsec3_maxiterations());
+ }
}
if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
@@ -4683,9 +4734,9 @@ maybe_send_secure(dns_zone_t *zone) {
uint32_t serial;
unsigned int soacount;
- result = zone_get_from_db(zone->raw, zone->raw->db,
- NULL, &soacount, &serial,
- NULL, NULL, NULL, NULL, NULL);
+ result = zone_get_from_db(
+ zone->raw, zone->raw->db, NULL, &soacount, NULL,
+ &serial, NULL, NULL, NULL, NULL, NULL);
if (result == ISC_R_SUCCESS && soacount > 0U) {
zone_send_secureserial(zone->raw, serial);
}
@@ -4722,7 +4773,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
unsigned int soacount = 0;
unsigned int nscount = 0;
unsigned int errors = 0;
- uint32_t serial, oldserial, refresh, retry, expire, minimum;
+ uint32_t serial, oldserial, refresh, retry, expire, minimum, soattl;
isc_time_t now;
bool needdump = false;
bool fixjournal = false;
@@ -4827,8 +4878,9 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
* Obtain ns, soa and cname counts for top of zone.
*/
INSIST(db != NULL);
- result = zone_get_from_db(zone, db, &nscount, &soacount, &serial,
- &refresh, &retry, &expire, &minimum, &errors);
+ result = zone_get_from_db(zone, db, &nscount, &soacount, &soattl,
+ &serial, &refresh, &retry, &expire, &minimum,
+ &errors);
if (result != ISC_R_SUCCESS && zone->type != dns_zone_key) {
dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR,
"could not find NS and/or SOA records");
@@ -4975,11 +5027,11 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
* This is checked in zone_replacedb() for slave zones
* as they don't reload from disk.
*/
- result = zone_get_from_db(zone, zone->db, NULL,
- &oldsoacount, &oldserial,
- NULL, NULL, NULL, NULL, NULL);
+ result = zone_get_from_db(
+ zone, zone->db, NULL, &oldsoacount, NULL,
+ &oldserial, NULL, NULL, NULL, NULL, NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
- RUNTIME_CHECK(soacount > 0U);
+ RUNTIME_CHECK(oldsoacount > 0U);
if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IXFRFROMDIFFS) &&
!isc_serial_gt(serial, oldserial))
{
@@ -4995,6 +5047,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
ISC_LOG_INFO,
"ixfr-from-differences: "
"unchanged");
+ zone->loadtime = loadtime;
goto done;
}
@@ -5043,6 +5096,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
zone->retry = RANGE(retry, zone->minretry, zone->maxretry);
zone->expire = RANGE(expire, zone->refresh + zone->retry,
DNS_MAX_EXPIRE);
+ zone->soattl = soattl;
zone->minimum = minimum;
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_HAVETIMERS);
@@ -5466,39 +5520,42 @@ invalidate_rdataset:
return (result);
}
+#define SET_IF_NOT_NULL(obj, val) \
+ if (obj != NULL) { \
+ *obj = val; \
+ }
+
+#define SET_SOA_VALUES(soattl_v, serial_v, refresh_v, retry_v, expire_v, \
+ minimum_v) \
+ { \
+ SET_IF_NOT_NULL(soattl, soattl_v); \
+ SET_IF_NOT_NULL(serial, serial_v); \
+ SET_IF_NOT_NULL(refresh, refresh_v); \
+ SET_IF_NOT_NULL(retry, retry_v); \
+ SET_IF_NOT_NULL(expire, expire_v); \
+ SET_IF_NOT_NULL(minimum, minimum_v); \
+ }
+
+#define CLR_SOA_VALUES() \
+ { \
+ SET_SOA_VALUES(0, 0, 0, 0, 0, 0); \
+ }
+
static isc_result_t
zone_load_soa_rr(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
- unsigned int *soacount, uint32_t *serial, uint32_t *refresh,
- uint32_t *retry, uint32_t *expire, uint32_t *minimum) {
+ unsigned int *soacount, uint32_t *soattl, uint32_t *serial,
+ uint32_t *refresh, uint32_t *retry, uint32_t *expire,
+ uint32_t *minimum) {
isc_result_t result;
- unsigned int count;
+ unsigned int count = 0;
dns_rdataset_t rdataset;
dns_rdata_t rdata = DNS_RDATA_INIT;
- dns_rdata_soa_t soa;
dns_rdataset_init(&rdataset);
result = dns_db_findrdataset(db, node, version, dns_rdatatype_soa,
dns_rdatatype_none, 0, &rdataset, NULL);
if (result == ISC_R_NOTFOUND) {
INSIST(!dns_rdataset_isassociated(&rdataset));
- if (soacount != NULL) {
- *soacount = 0;
- }
- if (serial != NULL) {
- *serial = 0;
- }
- if (refresh != NULL) {
- *refresh = 0;
- }
- if (retry != NULL) {
- *retry = 0;
- }
- if (expire != NULL) {
- *expire = 0;
- }
- if (minimum != NULL) {
- *minimum = 0;
- }
result = ISC_R_SUCCESS;
goto invalidate_rdataset;
}
@@ -5507,14 +5564,16 @@ zone_load_soa_rr(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
goto invalidate_rdataset;
}
- count = 0;
result = dns_rdataset_first(&rdataset);
while (result == ISC_R_SUCCESS) {
dns_rdata_init(&rdata);
dns_rdataset_current(&rdataset, &rdata);
count++;
if (count == 1) {
+ dns_rdata_soa_t soa;
result = dns_rdata_tostruct(&rdata, &soa, NULL);
+ SET_SOA_VALUES(rdataset.ttl, soa.serial, soa.refresh,
+ soa.retry, soa.expire, soa.minimum);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
}
@@ -5523,50 +5582,14 @@ zone_load_soa_rr(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
}
dns_rdataset_disassociate(&rdataset);
- if (soacount != NULL) {
- *soacount = count;
- }
-
- if (count > 0) {
- if (serial != NULL) {
- *serial = soa.serial;
- }
- if (refresh != NULL) {
- *refresh = soa.refresh;
- }
- if (retry != NULL) {
- *retry = soa.retry;
- }
- if (expire != NULL) {
- *expire = soa.expire;
- }
- if (minimum != NULL) {
- *minimum = soa.minimum;
- }
- } else {
- if (soacount != NULL) {
- *soacount = 0;
- }
- if (serial != NULL) {
- *serial = 0;
- }
- if (refresh != NULL) {
- *refresh = 0;
- }
- if (retry != NULL) {
- *retry = 0;
- }
- if (expire != NULL) {
- *expire = 0;
- }
- if (minimum != NULL) {
- *minimum = 0;
- }
- }
-
result = ISC_R_SUCCESS;
invalidate_rdataset:
+ SET_IF_NOT_NULL(soacount, count);
+ if (count == 0) {
+ CLR_SOA_VALUES();
+ }
+
dns_rdataset_invalidate(&rdataset);
return (result);
@@ -5577,9 +5600,9 @@ invalidate_rdataset:
*/
static isc_result_t
zone_get_from_db(dns_zone_t *zone, dns_db_t *db, unsigned int *nscount,
- unsigned int *soacount, uint32_t *serial, uint32_t *refresh,
- uint32_t *retry, uint32_t *expire, uint32_t *minimum,
- unsigned int *errors) {
+ unsigned int *soacount, uint32_t *soattl, uint32_t *serial,
+ uint32_t *refresh, uint32_t *retry, uint32_t *expire,
+ uint32_t *minimum, unsigned int *errors) {
isc_result_t result;
isc_result_t answer = ISC_R_SUCCESS;
dns_dbversion_t *version = NULL;
@@ -5590,27 +5613,10 @@ zone_get_from_db(dns_zone_t *zone, dns_db_t *db, unsigned int *nscount,
dns_db_currentversion(db, &version);
- if (nscount != NULL) {
- *nscount = 0;
- }
- if (soacount != NULL) {
- *soacount = 0;
- }
- if (serial != NULL) {
- *serial = 0;
- }
- if (refresh != NULL) {
- *refresh = 0;
- }
- if (retry != NULL) {
- *retry = 0;
- }
- if (expire != NULL) {
- *expire = 0;
- }
- if (errors != NULL) {
- *errors = 0;
- }
+ SET_IF_NOT_NULL(nscount, 0);
+ SET_IF_NOT_NULL(soacount, 0);
+ SET_IF_NOT_NULL(errors, 0);
+ CLR_SOA_VALUES();
node = NULL;
result = dns_db_findnode(db, &zone->origin, false, &node);
@@ -5627,11 +5633,13 @@ zone_get_from_db(dns_zone_t *zone, dns_db_t *db, unsigned int *nscount,
}
}
- if (soacount != NULL || serial != NULL || refresh != NULL ||
- retry != NULL || expire != NULL || minimum != NULL)
+ if (soacount != NULL || soattl != NULL || serial != NULL ||
+ refresh != NULL || retry != NULL || expire != NULL ||
+ minimum != NULL)
{
- result = zone_load_soa_rr(db, node, version, soacount, serial,
- refresh, retry, expire, minimum);
+ result = zone_load_soa_rr(db, node, version, soacount, soattl,
+ serial, refresh, retry, expire,
+ minimum);
if (result != ISC_R_SUCCESS) {
answer = result;
}
@@ -5783,17 +5791,6 @@ dns_zone_getmgr(dns_zone_t *zone) {
}
void
-dns_zone_setflag(dns_zone_t *zone, unsigned int flags, bool value) {
- REQUIRE(DNS_ZONE_VALID(zone));
-
- if (value) {
- DNS_ZONE_SETFLAG(zone, flags);
- } else {
- DNS_ZONE_CLRFLAG(zone, flags);
- }
-}
-
-void
dns_zone_setkasp(dns_zone_t *zone, dns_kasp_t *kasp) {
REQUIRE(DNS_ZONE_VALID(zone));
@@ -5814,82 +5811,6 @@ dns_zone_getkasp(dns_zone_t *zone) {
return (zone->kasp);
}
-static bool
-statefile_exist(dns_zone_t *zone) {
- isc_result_t ret;
- dns_dnsseckeylist_t keys;
- dns_dnsseckey_t *key = NULL;
- isc_stdtime_t now;
- isc_time_t timenow;
- bool found = false;
-
- TIME_NOW(&timenow);
- now = isc_time_seconds(&timenow);
-
- ISC_LIST_INIT(keys);
-
- ret = dns_dnssec_findmatchingkeys(dns_zone_getorigin(zone),
- dns_zone_getkeydirectory(zone), now,
- dns_zone_getmctx(zone), &keys);
- if (ret == ISC_R_SUCCESS) {
- for (key = ISC_LIST_HEAD(keys); key != NULL;
- key = ISC_LIST_NEXT(key, link)) {
- if (dst_key_haskasp(key->key)) {
- found = true;
- break;
- }
- }
- }
-
- /* Clean up keys */
- while (!ISC_LIST_EMPTY(keys)) {
- key = ISC_LIST_HEAD(keys);
- ISC_LIST_UNLINK(keys, key, link);
- dns_dnsseckey_destroy(dns_zone_getmctx(zone), &key);
- }
-
- return (found);
-}
-
-bool
-dns_zone_secure_to_insecure(dns_zone_t *zone, bool reconfig) {
- REQUIRE(DNS_ZONE_VALID(zone));
-
- /*
- * If checking during reconfig, the zone is not yet updated
- * with the new kasp configuration, so only check the key
- * files.
- */
- if (reconfig) {
- return (statefile_exist(zone));
- }
-
- if (zone->kasp == NULL) {
- return (false);
- }
- if (strcmp(dns_kasp_getname(zone->kasp), "none") != 0) {
- return (false);
- }
- /*
- * "dnssec-policy none", but if there are key state files
- * this zone used to be secure but is transitioning back to
- * insecure.
- */
- return (statefile_exist(zone));
-}
-
-bool
-dns_zone_use_kasp(dns_zone_t *zone) {
- dns_kasp_t *kasp = dns_zone_getkasp(zone);
-
- if (kasp == NULL) {
- return (false);
- } else if (strcmp(dns_kasp_getname(kasp), "none") != 0) {
- return (true);
- }
- return dns_zone_secure_to_insecure(zone, false);
-}
-
void
dns_zone_setoption(dns_zone_t *zone, dns_zoneopt_t option, bool value) {
REQUIRE(DNS_ZONE_VALID(zone));
@@ -6065,6 +5986,74 @@ dns_zone_getaltxfrsource6dscp(dns_zone_t *zone) {
}
isc_result_t
+dns_zone_setparentalsrc4(dns_zone_t *zone, const isc_sockaddr_t *parentalsrc) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ zone->parentalsrc4 = *parentalsrc;
+ UNLOCK_ZONE(zone);
+
+ return (ISC_R_SUCCESS);
+}
+
+isc_sockaddr_t *
+dns_zone_getparentalsrc4(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return (&zone->parentalsrc4);
+}
+
+isc_result_t
+dns_zone_setparentalsrc4dscp(dns_zone_t *zone, isc_dscp_t dscp) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ zone->parentalsrc4dscp = dscp;
+ UNLOCK_ZONE(zone);
+
+ return (ISC_R_SUCCESS);
+}
+
+isc_dscp_t
+dns_zone_getparentalsrc4dscp(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return (zone->parentalsrc4dscp);
+}
+
+isc_result_t
+dns_zone_setparentalsrc6(dns_zone_t *zone, const isc_sockaddr_t *parentalsrc) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ zone->parentalsrc6 = *parentalsrc;
+ UNLOCK_ZONE(zone);
+
+ return (ISC_R_SUCCESS);
+}
+
+isc_sockaddr_t *
+dns_zone_getparentalsrc6(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return (&zone->parentalsrc6);
+}
+
+isc_result_t
+dns_zone_setparentalsrc6dscp(dns_zone_t *zone, isc_dscp_t dscp) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ zone->parentalsrc6dscp = dscp;
+ UNLOCK_ZONE(zone);
+
+ return (ISC_R_SUCCESS);
+}
+
+isc_dscp_t
+dns_zone_getparentalsrc6dscp(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return (zone->parentalsrc6dscp);
+}
+
+isc_result_t
dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc) {
REQUIRE(DNS_ZONE_VALID(zone));
@@ -6115,6 +6104,23 @@ dns_zone_getnotifysrc6(dns_zone_t *zone) {
return (&zone->notifysrc6);
}
+isc_result_t
+dns_zone_setnotifysrc6dscp(dns_zone_t *zone, isc_dscp_t dscp) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ zone->notifysrc6dscp = dscp;
+ UNLOCK_ZONE(zone);
+
+ return (ISC_R_SUCCESS);
+}
+
+isc_dscp_t
+dns_zone_getnotifysrc6dscp(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return (zone->notifysrc6dscp);
+}
+
static bool
same_addrs(isc_sockaddr_t const *oldlist, isc_sockaddr_t const *newlist,
uint32_t count) {
@@ -6154,9 +6160,9 @@ same_keynames(dns_name_t *const *oldlist, dns_name_t *const *newlist,
}
static void
-clear_addresskeylist(isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
- dns_name_t ***keynamesp, unsigned int *countp,
- isc_mem_t *mctx) {
+clear_serverslist(isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
+ dns_name_t ***keynamesp, unsigned int *countp,
+ isc_mem_t *mctx) {
unsigned int count;
isc_sockaddr_t *addrs;
isc_dscp_t *dscps;
@@ -6197,7 +6203,7 @@ clear_addresskeylist(isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
}
static isc_result_t
-set_addrkeylist(unsigned int count, const isc_sockaddr_t *addrs,
+set_serverslist(unsigned int count, const isc_sockaddr_t *addrs,
isc_sockaddr_t **newaddrsp, const isc_dscp_t *dscp,
isc_dscp_t **newdscpp, dns_name_t **names,
dns_name_t ***newnamesp, isc_mem_t *mctx) {
@@ -6244,23 +6250,6 @@ set_addrkeylist(unsigned int count, const isc_sockaddr_t *addrs,
}
isc_result_t
-dns_zone_setnotifysrc6dscp(dns_zone_t *zone, isc_dscp_t dscp) {
- REQUIRE(DNS_ZONE_VALID(zone));
-
- LOCK_ZONE(zone);
- zone->notifysrc6dscp = dscp;
- UNLOCK_ZONE(zone);
-
- return (ISC_R_SUCCESS);
-}
-
-isc_dscp_t
-dns_zone_getnotifysrc6dscp(dns_zone_t *zone) {
- REQUIRE(DNS_ZONE_VALID(zone));
- return (zone->notifysrc6dscp);
-}
-
-isc_result_t
dns_zone_setalsonotify(dns_zone_t *zone, const isc_sockaddr_t *notify,
uint32_t count) {
return (dns_zone_setalsonotifydscpkeys(zone, notify, NULL, NULL,
@@ -6298,9 +6287,8 @@ dns_zone_setalsonotifydscpkeys(dns_zone_t *zone, const isc_sockaddr_t *notify,
goto unlock;
}
- clear_addresskeylist(&zone->notify, &zone->notifydscp,
- &zone->notifykeynames, &zone->notifycnt,
- zone->mctx);
+ clear_serverslist(&zone->notify, &zone->notifydscp,
+ &zone->notifykeynames, &zone->notifycnt, zone->mctx);
if (count == 0) {
goto unlock;
@@ -6309,7 +6297,7 @@ dns_zone_setalsonotifydscpkeys(dns_zone_t *zone, const isc_sockaddr_t *notify,
/*
* Set up the notify and notifykey lists
*/
- result = set_addrkeylist(count, notify, &newaddrs, dscps, &newdscps,
+ result = set_serverslist(count, notify, &newaddrs, dscps, &newdscps,
keynames, &newnames, zone->mctx);
if (result != ISC_R_SUCCESS) {
goto unlock;
@@ -6379,9 +6367,8 @@ dns_zone_setprimarieswithkeys(dns_zone_t *zone, const isc_sockaddr_t *masters,
zone->masterscnt * sizeof(bool));
zone->mastersok = NULL;
}
- clear_addresskeylist(&zone->masters, &zone->masterdscps,
- &zone->masterkeynames, &zone->masterscnt,
- zone->mctx);
+ clear_serverslist(&zone->masters, &zone->masterdscps,
+ &zone->masterkeynames, &zone->masterscnt, zone->mctx);
/*
* If count == 0, don't allocate any space for masters, mastersok or
* keynames so internally, those pointers are NULL if count == 0
@@ -6401,7 +6388,7 @@ dns_zone_setprimarieswithkeys(dns_zone_t *zone, const isc_sockaddr_t *masters,
/*
* Now set up the primaries and primary key lists
*/
- result = set_addrkeylist(count, masters, &newaddrs, NULL, &newdscps,
+ result = set_serverslist(count, masters, &newaddrs, NULL, &newdscps,
keynames, &newnames, zone->mctx);
INSIST(newdscps == NULL);
if (result != ISC_R_SUCCESS) {
@@ -6426,6 +6413,58 @@ unlock:
}
isc_result_t
+dns_zone_setparentals(dns_zone_t *zone, const isc_sockaddr_t *parentals,
+ dns_name_t **keynames, uint32_t count) {
+ isc_result_t result = ISC_R_SUCCESS;
+ isc_sockaddr_t *newaddrs = NULL;
+ isc_dscp_t *newdscps = NULL;
+ dns_name_t **newkeynames = NULL;
+
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(count == 0 || parentals != NULL);
+ if (keynames != NULL) {
+ REQUIRE(count != 0);
+ }
+
+ LOCK_ZONE(zone);
+
+ clear_serverslist(&zone->parentals, &zone->parentaldscps,
+ &zone->parentalkeynames, &zone->parentalscnt,
+ zone->mctx);
+ /*
+ * If count == 0, don't allocate any space for parentals, or keynames
+ * so internally, those pointers are NULL if count == 0
+ */
+ if (count == 0) {
+ goto unlock;
+ }
+
+ /*
+ * Now set up the parentals and parental key lists
+ */
+ result = set_serverslist(count, parentals, &newaddrs, NULL, &newdscps,
+ keynames, &newkeynames, zone->mctx);
+ INSIST(newdscps == NULL);
+ if (result != ISC_R_SUCCESS) {
+ goto unlock;
+ }
+
+ /*
+ * Everything is ok so attach to the zone.
+ */
+ zone->parentals = newaddrs;
+ zone->parentaldscps = newdscps;
+ zone->parentalkeynames = newkeynames;
+ zone->parentalscnt = count;
+
+ dns_zone_log(zone, ISC_LOG_NOTICE, "checkds: set %u parentals", count);
+
+unlock:
+ UNLOCK_ZONE(zone);
+ return (result);
+}
+
+isc_result_t
dns_zone_getdb(dns_zone_t *zone, dns_db_t **dpb) {
isc_result_t result = ISC_R_SUCCESS;
@@ -6500,19 +6539,108 @@ dns__zone_findkeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node));
memset(keys, 0, sizeof(*keys) * maxkeys);
+
+ dns_zone_lock_keyfiles(zone);
+
result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db),
directory, now, mctx, maxkeys, keys,
nkeys);
+
+ dns_zone_unlock_keyfiles(zone);
+
if (result == ISC_R_NOTFOUND) {
result = ISC_R_SUCCESS;
}
+
failure:
+
if (node != NULL) {
dns_db_detachnode(db, &node);
}
return (result);
}
+/*%
+ * Find DNSSEC keys used for signing zone with dnssec-policy. Load these keys
+ * into 'keys'. Requires KASP to be locked.
+ */
+isc_result_t
+dns_zone_getdnsseckeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
+ isc_stdtime_t now, dns_dnsseckeylist_t *keys) {
+ isc_result_t result;
+ const char *dir = dns_zone_getkeydirectory(zone);
+ dns_dbnode_t *node = NULL;
+ dns_dnsseckey_t *key, *key_next;
+ dns_dnsseckeylist_t dnskeys;
+ dns_name_t *origin = dns_zone_getorigin(zone);
+ dns_kasp_t *kasp = dns_zone_getkasp(zone);
+ dns_rdataset_t keyset;
+
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(kasp != NULL);
+
+ ISC_LIST_INIT(dnskeys);
+
+ dns_rdataset_init(&keyset);
+
+ CHECK(dns_db_findnode(db, origin, false, &node));
+
+ /* Get keys from private key files. */
+ dns_zone_lock_keyfiles(zone);
+ result = dns_dnssec_findmatchingkeys(origin, dir, now,
+ dns_zone_getmctx(zone), keys);
+ dns_zone_unlock_keyfiles(zone);
+
+ if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
+ goto failure;
+ }
+
+ /* Get public keys (dnskeys). */
+ dns_rdataset_init(&keyset);
+ result = dns_db_findrdataset(db, node, ver, dns_rdatatype_dnskey,
+ dns_rdatatype_none, 0, &keyset, NULL);
+ if (result == ISC_R_SUCCESS) {
+ CHECK(dns_dnssec_keylistfromrdataset(
+ origin, dir, dns_zone_getmctx(zone), &keyset, NULL,
+ NULL, false, false, &dnskeys));
+ } else if (result != ISC_R_NOTFOUND) {
+ CHECK(result);
+ }
+
+ /* Add new 'dnskeys' to 'keys'. */
+ for (dns_dnsseckey_t *k1 = ISC_LIST_HEAD(dnskeys); k1 != NULL;
+ k1 = key_next) {
+ dns_dnsseckey_t *k2 = NULL;
+ key_next = ISC_LIST_NEXT(k1, link);
+
+ for (k2 = ISC_LIST_HEAD(*keys); k2 != NULL;
+ k2 = ISC_LIST_NEXT(k2, link)) {
+ if (dst_key_compare(k1->key, k2->key)) {
+ break;
+ }
+ }
+ /* No match found, add the new key. */
+ if (k2 == NULL) {
+ ISC_LIST_UNLINK(dnskeys, k1, link);
+ ISC_LIST_APPEND(*keys, k1, link);
+ }
+ }
+
+failure:
+ if (dns_rdataset_isassociated(&keyset)) {
+ dns_rdataset_disassociate(&keyset);
+ }
+ if (node != NULL) {
+ dns_db_detachnode(db, &node);
+ }
+ while (!ISC_LIST_EMPTY(dnskeys)) {
+ key = ISC_LIST_HEAD(dnskeys);
+ ISC_LIST_UNLINK(dnskeys, key, link);
+ dns_dnsseckey_destroy(dns_zone_getmctx(zone), &key);
+ }
+ return (result);
+}
+
static isc_result_t
offline(dns_db_t *db, dns_dbversion_t *ver, dns__zonediff_t *zonediff,
dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata) {
@@ -6539,6 +6667,7 @@ set_key_expiry_warning(dns_zone_t *zone, isc_stdtime_t when,
unsigned int delta;
char timebuf[80];
+ LOCK_ZONE(zone);
zone->key_expiry = when;
if (when <= now) {
dns_zone_log(zone, ISC_LOG_ERROR,
@@ -6562,6 +6691,7 @@ set_key_expiry_warning(dns_zone_t *zone, isc_stdtime_t when,
dns_zone_log(zone, ISC_LOG_NOTICE, "setting keywarntime to %s",
timebuf);
}
+ UNLOCK_ZONE(zone);
}
/*
@@ -6570,7 +6700,7 @@ set_key_expiry_warning(dns_zone_t *zone, isc_stdtime_t when,
*/
static bool
delsig_ok(dns_rdata_rrsig_t *rrsig_ptr, dst_key_t **keys, unsigned int nkeys,
- bool *warn) {
+ bool kasp, bool *warn) {
unsigned int i = 0;
isc_result_t ret;
bool have_ksk = false, have_zsk = false;
@@ -6614,15 +6744,30 @@ delsig_ok(dns_rdata_rrsig_t *rrsig_ptr, dst_key_t **keys, unsigned int nkeys,
*warn = true;
}
+ if (have_pksk && have_pzsk) {
+ return (true);
+ }
+
/*
- * It's okay to delete a signature if there is an active key
- * with the same algorithm to replace it.
+ * Deleting the SOA RRSIG is always okay.
*/
- if (have_pksk || have_pzsk) {
+ if (rrsig_ptr->covered == dns_rdatatype_soa) {
return (true);
}
/*
+ * It's okay to delete a signature if there is an active key with the
+ * same algorithm to replace it, unless that violates the DNSSEC
+ * policy.
+ */
+ if (have_pksk || have_pzsk) {
+ if (kasp && have_pzsk) {
+ return (true);
+ }
+ return (!kasp);
+ }
+
+ /*
* Failing that, it is *not* okay to delete a signature
* if the associated public key is still in the DNSKEY RRset
*/
@@ -6653,6 +6798,7 @@ del_sigs(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name,
dns_rdataset_t rdataset;
unsigned int i;
dns_rdata_rrsig_t rrsig;
+ bool kasp = (dns_zone_getkasp(zone) != NULL);
bool found;
int64_t timewarn = 0, timemaybe = 0;
@@ -6695,7 +6841,7 @@ del_sigs(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name,
type != dns_rdatatype_cdnskey)
{
bool warn = false, deleted = false;
- if (delsig_ok(&rrsig, keys, nkeys, &warn)) {
+ if (delsig_ok(&rrsig, keys, nkeys, kasp, &warn)) {
result = update_one_rr(db, ver, zonediff->diff,
DNS_DIFFOP_DELRESIGN,
name, rdataset.ttl,
@@ -6849,7 +6995,7 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone,
unsigned int i, j;
bool use_kasp = false;
- if (dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) != NULL) {
check_ksk = false;
keyset_kskonly = true;
use_kasp = true;
@@ -6939,6 +7085,8 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone,
isc_stdtime_t when;
bool ksk = false;
bool zsk = false;
+ bool have_ksk = false;
+ bool have_zsk = false;
kresult = dst_key_getbool(keys[i], DST_BOOL_KSK, &ksk);
if (kresult != ISC_R_SUCCESS) {
@@ -6953,6 +7101,56 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone,
}
}
+ have_ksk = ksk;
+ have_zsk = zsk;
+ both = have_ksk && have_zsk;
+
+ for (j = 0; j < nkeys; j++) {
+ if (both) {
+ break;
+ }
+
+ if (j == i || ALG(keys[i]) != ALG(keys[j])) {
+ continue;
+ }
+
+ /*
+ * Don't consider inactive keys or offline keys.
+ */
+ if (!dst_key_isprivate(keys[j])) {
+ continue;
+ }
+ if (dst_key_inactive(keys[j])) {
+ continue;
+ }
+
+ if (REVOKE(keys[j])) {
+ continue;
+ }
+
+ if (!have_ksk) {
+ kresult = dst_key_getbool(keys[j],
+ DST_BOOL_KSK,
+ &have_ksk);
+ if (kresult != ISC_R_SUCCESS) {
+ if (KSK(keys[j])) {
+ have_ksk = true;
+ }
+ }
+ }
+ if (!have_zsk) {
+ kresult = dst_key_getbool(keys[j],
+ DST_BOOL_ZSK,
+ &have_zsk);
+ if (kresult != ISC_R_SUCCESS) {
+ if (!KSK(keys[j])) {
+ have_zsk = true;
+ }
+ }
+ }
+ both = have_ksk && have_zsk;
+ }
+
if (type == dns_rdatatype_dnskey ||
type == dns_rdatatype_cdnskey ||
type == dns_rdatatype_cds)
@@ -6968,7 +7166,13 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone,
/*
* Other RRsets are signed with ZSK.
*/
- continue;
+ if (type != dns_rdatatype_soa &&
+ type != zone->privatetype) {
+ continue;
+ }
+ if (have_zsk) {
+ continue;
+ }
} else if (!dst_key_is_signing(keys[i], DST_BOOL_ZSK,
inception, &when)) {
/*
@@ -7157,8 +7361,10 @@ zone_resigninc(dns_zone_t *zone) {
* recent signature.
*/
/* XXXMPA increase number of RRsets signed pre call */
- if (covers == dns_rdatatype_soa || i++ > zone->signatures ||
- resign > stop) {
+ if ((covers == dns_rdatatype_soa &&
+ dns_name_equal(name, &zone->origin)) ||
+ i++ > zone->signatures || resign > stop)
+ {
break;
}
@@ -7365,12 +7571,12 @@ signed_with_good_key(dns_zone_t *zone, dns_db_t *db, dns_dbnode_t *node,
dns_rdata_reset(&rdata);
}
- if (dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) != NULL) {
dns_kasp_key_t *kkey;
int zsk_count = 0;
bool approved;
- LOCK(&kasp->lock);
+ KASP_LOCK(kasp);
for (kkey = ISC_LIST_HEAD(dns_kasp_keys(kasp)); kkey != NULL;
kkey = ISC_LIST_NEXT(kkey, link))
{
@@ -7381,7 +7587,7 @@ signed_with_good_key(dns_zone_t *zone, dns_db_t *db, dns_dbnode_t *node,
zsk_count++;
}
}
- UNLOCK(&kasp->lock);
+ KASP_UNLOCK(kasp);
if (type == dns_rdatatype_dnskey ||
type == dns_rdatatype_cdnskey || type == dns_rdatatype_cds)
@@ -7478,9 +7684,9 @@ static isc_result_t
sign_a_node(dns_db_t *db, dns_zone_t *zone, dns_name_t *name,
dns_dbnode_t *node, dns_dbversion_t *version, bool build_nsec3,
bool build_nsec, dst_key_t *key, isc_stdtime_t inception,
- isc_stdtime_t expire, unsigned int minimum, bool is_ksk,
- bool is_zsk, bool keyset_kskonly, bool is_bottom_of_zone,
- dns_diff_t *diff, int32_t *signatures, isc_mem_t *mctx) {
+ isc_stdtime_t expire, dns_ttl_t nsecttl, bool is_ksk, bool is_zsk,
+ bool keyset_kskonly, bool is_bottom_of_zone, dns_diff_t *diff,
+ int32_t *signatures, isc_mem_t *mctx) {
isc_result_t result;
dns_rdatasetiter_t *iterator = NULL;
dns_rdataset_t rdataset;
@@ -7531,7 +7737,7 @@ sign_a_node(dns_db_t *db, dns_zone_t *zone, dns_name_t *name,
*/
if (build_nsec3 && !seen_nsec3 && seen_rr) {
bool unsecure = !seen_ds && seen_ns && !seen_soa;
- CHECK(dns_nsec3_addnsec3s(db, version, name, minimum, unsecure,
+ CHECK(dns_nsec3_addnsec3s(db, version, name, nsecttl, unsecure,
diff));
(*signatures)--;
}
@@ -7544,7 +7750,7 @@ sign_a_node(dns_db_t *db, dns_zone_t *zone, dns_name_t *name,
* Build a NSEC record except at the origin.
*/
if (!dns_name_equal(name, dns_db_origin(db))) {
- CHECK(add_nsec(db, version, name, node, minimum,
+ CHECK(add_nsec(db, version, name, node, nsecttl,
is_bottom_of_zone, diff));
/* Count a NSEC generation as a signature generation. */
(*signatures)--;
@@ -7577,7 +7783,7 @@ sign_a_node(dns_db_t *db, dns_zone_t *zone, dns_name_t *name,
} else if (is_zsk && !dst_key_is_signing(key, DST_BOOL_ZSK,
inception, &when)) {
/* Only applies to dnssec-policy. */
- if (dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) != NULL) {
goto next_rdataset;
}
}
@@ -7638,7 +7844,7 @@ failure:
*/
static isc_result_t
updatesecure(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name,
- dns_ttl_t minimum, bool update_only, dns_diff_t *diff) {
+ dns_ttl_t nsecttl, bool update_only, dns_diff_t *diff) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_dbnode_t *node = NULL;
@@ -7660,7 +7866,7 @@ updatesecure(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name,
}
}
CHECK(delete_nsec(db, version, node, name, diff));
- CHECK(add_nsec(db, version, name, node, minimum, false, diff));
+ CHECK(add_nsec(db, version, name, node, nsecttl, false, diff));
success:
result = ISC_R_SUCCESS;
failure:
@@ -7672,7 +7878,7 @@ failure:
static isc_result_t
updatesignwithkey(dns_zone_t *zone, dns_signing_t *signing,
- dns_dbversion_t *version, bool build_nsec3, dns_ttl_t minimum,
+ dns_dbversion_t *version, bool build_nsec3, dns_ttl_t nsecttl,
dns_diff_t *diff) {
isc_result_t result;
dns_dbnode_t *node = NULL;
@@ -7764,9 +7970,9 @@ updatesignwithkey(dns_zone_t *zone, dns_signing_t *signing,
*/
if (build_nsec3) {
CHECK(dns_nsec3_addnsec3s(signing->db, version, origin,
- minimum, false, diff));
+ nsecttl, false, diff));
}
- CHECK(updatesecure(signing->db, version, origin, minimum, true,
+ CHECK(updatesecure(signing->db, version, origin, nsecttl, true,
diff));
}
@@ -8474,7 +8680,7 @@ zone_nsec3chain(dns_zone_t *zone) {
dns_dbiterator_pause(nsec3chain->dbiterator);
result = dns_nsec3_addnsec3(
db, version, name, &nsec3chain->nsec3param,
- zone->minimum, unsecure, &nsec3_diff);
+ zone_nsecttl(zone), unsecure, &nsec3_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
"zone_nsec3chain:"
@@ -8733,8 +8939,9 @@ zone_nsec3chain(dns_zone_t *zone) {
*/
if (!dns_name_equal(name, dns_db_origin(db))) {
dns_dbiterator_pause(nsec3chain->dbiterator);
- CHECK(add_nsec(db, version, name, node, zone->minimum,
- delegation, &nsec_diff));
+ CHECK(add_nsec(db, version, name, node,
+ zone_nsecttl(zone), delegation,
+ &nsec_diff));
signatures--;
}
@@ -8836,7 +9043,8 @@ skip_removals:
}
result = updatesecure(db, version, &zone->origin,
- zone->minimum, true, &nsec_diff);
+ zone_nsecttl(zone), true,
+ &nsec_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
"zone_nsec3chain:updatesecure -> %s",
@@ -8851,8 +9059,8 @@ skip_removals:
}
result = dns_nsec3_addnsec3s(
- db, version, dns_db_origin(db), zone->minimum,
- false, &nsec3_diff);
+ db, version, dns_db_origin(db),
+ zone_nsecttl(zone), false, &nsec3_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
"zone_nsec3chain:"
@@ -8894,8 +9102,8 @@ skip_removals:
}
if (updatensec) {
- result = updatesecure(db, version, &zone->origin, zone->minimum,
- false, &nsec_diff);
+ result = updatesecure(db, version, &zone->origin,
+ zone_nsecttl(zone), false, &nsec_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
"zone_nsec3chain:updatesecure -> %s",
@@ -9314,7 +9522,7 @@ zone_sign(dns_zone_t *zone) {
signing = ISC_LIST_HEAD(zone->signing);
first = true;
- if (dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) != NULL) {
check_ksk = false;
keyset_kskonly = true;
use_kasp = true;
@@ -9561,7 +9769,7 @@ zone_sign(dns_zone_t *zone) {
CHECK(sign_a_node(
db, zone, name, node, version, build_nsec3,
build_nsec, zone_keys[i], inception, expire,
- zone->minimum, is_ksk, is_zsk,
+ zone_nsecttl(zone), is_ksk, is_zsk,
(both && keyset_kskonly), is_bottom_of_zone,
zonediff.diff, &signatures, zone->mctx));
/*
@@ -9602,7 +9810,7 @@ zone_sign(dns_zone_t *zone) {
*/
result = updatesecure(
db, version, &zone->origin,
- zone->minimum, false,
+ zone_nsecttl(zone), false,
&post_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
@@ -9614,7 +9822,7 @@ zone_sign(dns_zone_t *zone) {
}
result = updatesignwithkey(
zone, signing, version, build_nsec3,
- zone->minimum, &post_diff);
+ zone_nsecttl(zone), &post_diff);
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
"updatesignwithkey -> %s",
@@ -10891,6 +11099,7 @@ zone_refreshkeys(dns_zone_t *zone) {
#ifdef ENABLE_AFL
if (!dns_fuzzing_resolver) {
#endif /* ifdef ENABLE_AFL */
+ UNLOCK_ZONE(zone);
result = dns_resolver_createfetch(
zone->view->resolver, kname,
dns_rdatatype_dnskey, NULL, NULL, NULL, NULL, 0,
@@ -10900,6 +11109,7 @@ zone_refreshkeys(dns_zone_t *zone) {
0, NULL, zone->task, keyfetch_done, kfetch,
&kfetch->dnskeyset, &kfetch->dnskeysigset,
&kfetch->fetch);
+ LOCK_ZONE(zone);
#ifdef ENABLE_AFL
} else {
result = ISC_R_FAILURE;
@@ -11210,7 +11420,7 @@ again:
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
if (zone->db != NULL) {
result = zone_get_from_db(
- zone, zone->db, NULL, &soacount,
+ zone, zone->db, NULL, &soacount, NULL,
&serial, NULL, NULL, NULL, NULL, NULL);
} else {
result = DNS_R_NOTLOADED;
@@ -11861,6 +12071,25 @@ notify_cancel(dns_zone_t *zone) {
}
static void
+checkds_cancel(dns_zone_t *zone) {
+ dns_checkds_t *checkds;
+
+ /*
+ * 'zone' locked by caller.
+ */
+
+ REQUIRE(LOCKED_ZONE(zone));
+
+ for (checkds = ISC_LIST_HEAD(zone->checkds_requests); checkds != NULL;
+ checkds = ISC_LIST_NEXT(checkds, link))
+ {
+ if (checkds->request != NULL) {
+ dns_request_cancel(checkds->request);
+ }
+ }
+}
+
+static void
forward_cancel(dns_zone_t *zone) {
dns_forward_t *forward;
@@ -12696,7 +12925,6 @@ create_query(dns_zone_t *zone, dns_rdatatype_t rdtype, dns_name_t *name,
/*
* Make question.
*/
- dns_name_init(qname, NULL);
dns_name_clone(name, qname);
dns_rdataset_makequestion(qrdataset, zone->rdclass, rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
@@ -12770,7 +12998,7 @@ stub_finish_zone_update(dns_stub_t *stub, isc_time_t now) {
if (zone->db == NULL) {
zone_attachdb(zone, stub->db);
}
- result = zone_get_from_db(zone, zone->db, NULL, &soacount, NULL,
+ result = zone_get_from_db(zone, zone->db, NULL, &soacount, NULL, NULL,
&refresh, &retry, &expire, NULL, NULL);
if (result == ISC_R_SUCCESS && soacount > 0U) {
zone->refresh = RANGE(refresh, zone->minrefresh,
@@ -12861,6 +13089,23 @@ stub_glue_response_cb(isc_task_t *task, isc_event_t *event) {
}
/*
+ * Unexpected opcode.
+ */
+ if (msg->opcode != dns_opcode_query) {
+ char opcode[128];
+ isc_buffer_t rb;
+
+ isc_buffer_init(&rb, opcode, sizeof(opcode));
+ (void)dns_opcode_totext(msg->rcode, &rb);
+
+ dns_zone_log(zone, ISC_LOG_INFO,
+ "refreshing stub: "
+ "unexpected opcode (%.*s) from %s (source %s)",
+ (int)rb.used, opcode, master, source);
+ goto cleanup;
+ }
+
+ /*
* Unexpected rcode.
*/
if (msg->rcode != dns_rcode_noerror) {
@@ -13273,6 +13518,23 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
}
/*
+ * Unexpected opcode.
+ */
+ if (msg->opcode != dns_opcode_query) {
+ char opcode[128];
+ isc_buffer_t rb;
+
+ isc_buffer_init(&rb, opcode, sizeof(opcode));
+ (void)dns_opcode_totext(msg->rcode, &rb);
+
+ dns_zone_log(zone, ISC_LOG_INFO,
+ "refreshing stub: "
+ "unexpected opcode (%.*s) from %s (source %s)",
+ (int)rb.used, opcode, master, source);
+ goto next_master;
+ }
+
+ /*
* Unexpected rcode.
*/
if (msg->rcode != dns_rcode_noerror) {
@@ -13662,6 +13924,23 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
}
/*
+ * Unexpected opcode.
+ */
+ if (msg->opcode != dns_opcode_query) {
+ char opcode[128];
+ isc_buffer_t rb;
+
+ isc_buffer_init(&rb, opcode, sizeof(opcode));
+ (void)dns_opcode_totext(msg->rcode, &rb);
+
+ dns_zone_log(zone, ISC_LOG_INFO,
+ "refresh: "
+ "unexpected opcode (%.*s) from %s (source %s)",
+ (int)rb.used, opcode, master, source);
+ goto next_master;
+ }
+
+ /*
* Unexpected rcode.
*/
if (msg->rcode != dns_rcode_noerror) {
@@ -13828,8 +14107,8 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
unsigned int dbsoacount;
result = zone_get_from_db(zone, zone->db, NULL, &dbsoacount,
- &oldserial, NULL, NULL, NULL, NULL,
- NULL);
+ NULL, &oldserial, NULL, NULL, NULL,
+ NULL, NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
RUNTIME_CHECK(dbsoacount > 0U);
zone_debuglog(zone, me, 1, "serial: new %u, old %u", serial,
@@ -14588,6 +14867,8 @@ zone_shutdown(isc_task_t *task, isc_event_t *event) {
}
}
+ checkds_cancel(zone);
+
notify_cancel(zone);
forward_cancel(zone);
@@ -14865,7 +15146,6 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
/*
* Make question.
*/
- dns_name_init(tempname, NULL);
dns_name_clone(&zone->origin, tempname);
dns_rdataset_makequestion(temprdataset, zone->rdclass,
dns_rdatatype_soa);
@@ -14900,7 +15180,6 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
dns_db_attach(zone->db, &zonedb);
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
- dns_name_init(tempname, NULL);
dns_name_clone(&zone->origin, tempname);
dns_db_currentversion(zonedb, &version);
result = dns_db_findnode(zonedb, tempname, false, &node);
@@ -15139,8 +15418,8 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
* lock and succeed in this context.
*/
result = zone_get_from_db(zone, zone->db, NULL,
- &soacount, &oldserial, NULL,
- NULL, NULL, NULL, NULL);
+ &soacount, NULL, &oldserial,
+ NULL, NULL, NULL, NULL, NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
RUNTIME_CHECK(soacount > 0U);
if (isc_serial_le(serial, oldserial)) {
@@ -16006,7 +16285,8 @@ sync_secure_db(dns_zone_t *seczone, dns_zone_t *raw, dns_db_t *secdb,
* If the SOA records are the same except for the serial
* remove them from the diff.
*/
- if (oldsoa.refresh == newsoa.refresh &&
+ if (oldtuple->ttl == newtuple->ttl &&
+ oldsoa.refresh == newsoa.refresh &&
oldsoa.retry == newsoa.retry &&
oldsoa.minimum == newsoa.minimum &&
oldsoa.expire == newsoa.expire &&
@@ -16628,7 +16908,7 @@ copy_non_dnssec_records(dns_zone_t *zone, dns_db_t *db, dns_db_t *version,
* Allow DNSSEC records with dnssec-policy.
* WMM: Perhaps add config option for it.
*/
- if (!dns_zone_use_kasp(zone)) {
+ if (dns_zone_getkasp(zone) == NULL) {
dns_rdataset_disassociate(&rdataset);
continue;
}
@@ -16872,7 +17152,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
}
result = zone_get_from_db(zone, db, &nscount, &soacount, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL);
if (result == ISC_R_SUCCESS) {
if (soacount != 1) {
dns_zone_log(zone, ISC_LOG_ERROR, "has %d SOA records",
@@ -16925,7 +17205,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
/*
* This is checked in zone_postload() for master zones.
*/
- result = zone_get_from_db(zone, zone->db, NULL, &soacount,
+ result = zone_get_from_db(zone, zone->db, NULL, &soacount, NULL,
&oldserial, NULL, NULL, NULL, NULL,
NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
@@ -17061,7 +17341,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
bool again = false;
unsigned int soacount;
unsigned int nscount;
- uint32_t serial, refresh, retry, expire, minimum;
+ uint32_t serial, refresh, retry, expire, minimum, soattl;
isc_result_t xfrresult = result;
bool free_needed;
dns_zone_t *secure = NULL;
@@ -17118,8 +17398,8 @@ again:
soacount = 0;
INSIST(zone->db != NULL);
result = zone_get_from_db(zone, zone->db, &nscount, &soacount,
- &serial, &refresh, &retry, &expire,
- &minimum, NULL);
+ &soattl, &serial, &refresh, &retry,
+ &expire, &minimum, NULL);
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
if (result == ISC_R_SUCCESS) {
if (soacount != 1) {
@@ -17156,6 +17436,7 @@ again:
zone->expire = RANGE(expire,
zone->refresh + zone->retry,
DNS_MAX_EXPIRE);
+ zone->soattl = soattl;
zone->minimum = minimum;
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_HAVETIMERS);
}
@@ -17830,6 +18111,23 @@ forward_callback(isc_task_t *task, isc_event_t *event) {
goto next_master;
}
+ /*
+ * Unexpected opcode.
+ */
+ if (msg->opcode != dns_opcode_update) {
+ char opcode[128];
+ isc_buffer_t rb;
+
+ isc_buffer_init(&rb, opcode, sizeof(opcode));
+ (void)dns_opcode_totext(msg->rcode, &rb);
+
+ dns_zone_log(zone, ISC_LOG_INFO,
+ "forwarding dynamic update: "
+ "unexpected opcode (%.*s) from %s",
+ (int)rb.used, opcode, master);
+ goto next_master;
+ }
+
switch (msg->rcode) {
/*
* Pass these rcodes back to client.
@@ -17985,6 +18283,289 @@ dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first) {
*** Zone manager.
***/
+#define KEYMGMT_OVERCOMMIT 3
+#define KEYMGMT_BITS_MIN 2U
+#define KEYMGMT_BITS_MAX 32U
+
+/*
+ * WMM: Static hash functions copied from lib/dns/rbtdb.c. Should be moved to
+ * lib/isc/hash.c when we refactor the hash table code.
+ */
+#define GOLDEN_RATIO_32 0x61C88647
+#define HASHSIZE(bits) (UINT64_C(1) << (bits))
+
+static inline uint32_t
+hash_index(uint32_t val, uint32_t bits) {
+ return (val * GOLDEN_RATIO_32 >> (32 - bits));
+}
+
+static uint32_t
+hash_bits_grow(uint32_t bits, uint32_t count) {
+ uint32_t newbits = bits;
+ while (count >= HASHSIZE(newbits) && newbits < KEYMGMT_BITS_MAX) {
+ newbits++;
+ }
+ return (newbits);
+}
+
+static uint32_t
+hash_bits_shrink(uint32_t bits, uint32_t count) {
+ uint32_t newbits = bits;
+ while (count <= HASHSIZE(newbits) && newbits > KEYMGMT_BITS_MIN) {
+ newbits--;
+ }
+ return (newbits);
+}
+
+static void
+zonemgr_keymgmt_init(dns_zonemgr_t *zmgr) {
+ dns_keymgmt_t *mgmt = isc_mem_get(zmgr->mctx, sizeof(*mgmt));
+ uint32_t size;
+
+ *mgmt = (dns_keymgmt_t){
+ .bits = KEYMGMT_BITS_MIN,
+ };
+ isc_mem_attach(zmgr->mctx, &mgmt->mctx);
+ isc_rwlock_init(&mgmt->lock, 0, 0);
+
+ size = HASHSIZE(mgmt->bits);
+ mgmt->table = isc_mem_get(mgmt->mctx, sizeof(*mgmt->table) * size);
+ memset(mgmt->table, 0, size * sizeof(mgmt->table[0]));
+
+ atomic_init(&mgmt->count, 0);
+ mgmt->magic = KEYMGMT_MAGIC;
+
+ zmgr->keymgmt = mgmt;
+}
+
+static void
+zonemgr_keymgmt_destroy(dns_zonemgr_t *zmgr) {
+ dns_keymgmt_t *mgmt = zmgr->keymgmt;
+ dns_keyfileio_t *curr, *next;
+ uint32_t size;
+
+ REQUIRE(DNS_KEYMGMT_VALID(mgmt));
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_write);
+ size = HASHSIZE(mgmt->bits);
+ for (unsigned int i = 0;
+ atomic_load_relaxed(&mgmt->count) > 0 && i < size; i++) {
+ for (curr = mgmt->table[i]; curr != NULL; curr = next) {
+ next = curr->next;
+ isc_mutex_destroy(&curr->lock);
+ isc_mem_put(mgmt->mctx, curr, sizeof(*curr));
+ atomic_fetch_sub_relaxed(&mgmt->count, 1);
+ }
+ mgmt->table[i] = NULL;
+ }
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ mgmt->magic = 0;
+ isc_rwlock_destroy(&mgmt->lock);
+ isc_mem_put(mgmt->mctx, mgmt->table, size * sizeof(mgmt->table[0]));
+ isc_mem_putanddetach(&mgmt->mctx, mgmt, sizeof(dns_keymgmt_t));
+}
+
+static void
+zonemgr_keymgmt_resize(dns_zonemgr_t *zmgr) {
+ dns_keyfileio_t **newtable;
+ dns_keymgmt_t *mgmt = zmgr->keymgmt;
+ uint32_t bits, newbits, count, size, newsize;
+ bool grow;
+
+ REQUIRE(DNS_KEYMGMT_VALID(mgmt));
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_read);
+ count = atomic_load_relaxed(&mgmt->count);
+ bits = mgmt->bits;
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_read);
+
+ size = HASHSIZE(bits);
+ INSIST(size > 0);
+
+ if (count >= (size * KEYMGMT_OVERCOMMIT)) {
+ grow = true;
+ } else if (count < (size / 2)) {
+ grow = false;
+ } else {
+ /* No need to resize. */
+ return;
+ }
+
+ if (grow) {
+ newbits = hash_bits_grow(bits, count);
+ } else {
+ newbits = hash_bits_shrink(bits, count);
+ }
+
+ if (newbits == bits) {
+ /*
+ * Bit values may stay the same if maximum or minimum is
+ * reached.
+ */
+ return;
+ }
+
+ newsize = HASHSIZE(newbits);
+ INSIST(newsize > 0);
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ newtable = isc_mem_get(mgmt->mctx, sizeof(dns_keyfileio_t *) * newsize);
+ memset(newtable, 0, sizeof(dns_keyfileio_t *) * newsize);
+
+ for (unsigned int i = 0; i < size; i++) {
+ dns_keyfileio_t *kfio, *next;
+ for (kfio = mgmt->table[i]; kfio != NULL; kfio = next) {
+ uint32_t hash = hash_index(kfio->hashval, newbits);
+ next = kfio->next;
+ kfio->next = newtable[hash];
+ newtable[hash] = kfio;
+ }
+ mgmt->table[i] = NULL;
+ }
+
+ isc_mem_put(mgmt->mctx, mgmt->table, sizeof(*mgmt->table) * size);
+ mgmt->bits = newbits;
+ mgmt->table = newtable;
+
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_write);
+}
+
+static void
+zonemgr_keymgmt_add(dns_zonemgr_t *zmgr, dns_zone_t *zone,
+ dns_keyfileio_t **added) {
+ dns_keymgmt_t *mgmt = zmgr->keymgmt;
+ uint32_t hashval, hash;
+ dns_keyfileio_t *kfio, *next;
+
+ REQUIRE(DNS_KEYMGMT_VALID(mgmt));
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ hashval = dns_name_hash(&zone->origin, false);
+ hash = hash_index(hashval, mgmt->bits);
+
+ for (kfio = mgmt->table[hash]; kfio != NULL; kfio = next) {
+ next = kfio->next;
+ if (dns_name_equal(kfio->name, &zone->origin)) {
+ /* Already in table, increment the counter. */
+ atomic_fetch_add_relaxed(&kfio->count, 1);
+ break;
+ }
+ }
+
+ if (kfio == NULL) {
+ /* No entry found, add it. */
+ kfio = isc_mem_get(mgmt->mctx, sizeof(*kfio));
+ *kfio = (dns_keyfileio_t){ .hashval = hashval,
+ .next = mgmt->table[hash] };
+
+ kfio->name = dns_fixedname_initname(&kfio->fname);
+ dns_name_copynf(&zone->origin, kfio->name);
+
+ atomic_fetch_add_relaxed(&kfio->count, 1);
+ isc_mutex_init(&kfio->lock);
+
+ mgmt->table[hash] = kfio;
+ if (added != NULL) {
+ *added = kfio;
+ }
+
+ atomic_fetch_add_relaxed(&mgmt->count, 1);
+ }
+
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ /*
+ * Call resize, that function will also check if resize is necessary.
+ */
+ zonemgr_keymgmt_resize(zmgr);
+}
+
+static void
+zonemgr_keymgmt_delete(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
+ dns_keymgmt_t *mgmt = zmgr->keymgmt;
+ uint32_t hashval, hash;
+ dns_keyfileio_t *kfio, *prev, *next;
+
+ REQUIRE(DNS_KEYMGMT_VALID(mgmt));
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ hashval = dns_name_hash(&zone->origin, false);
+ hash = hash_index(hashval, mgmt->bits);
+
+ prev = NULL;
+ for (kfio = mgmt->table[hash]; kfio != NULL; kfio = next) {
+ next = kfio->next;
+ if (dns_name_equal(kfio->name, &zone->origin)) {
+ unsigned int count;
+
+ count = atomic_fetch_sub_relaxed(&kfio->count, 1);
+ if (count > 0) {
+ /* Keep the entry. */
+ break;
+ }
+
+ /* Delete the entry. */
+ if (prev == NULL) {
+ mgmt->table[hash] = kfio->next;
+ } else {
+ prev->next = kfio->next;
+ }
+
+ isc_mutex_destroy(&kfio->lock);
+ isc_mem_put(mgmt->mctx, kfio, sizeof(*kfio));
+
+ atomic_fetch_sub_relaxed(&mgmt->count, 1);
+
+ break;
+ }
+
+ prev = kfio;
+ }
+
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_write);
+
+ /*
+ * Call resize, that function will also check if resize is necessary.
+ */
+ zonemgr_keymgmt_resize(zmgr);
+}
+
+static void
+zonemgr_keymgmt_find(dns_zonemgr_t *zmgr, dns_zone_t *zone,
+ dns_keyfileio_t **match) {
+ dns_keymgmt_t *mgmt = zmgr->keymgmt;
+ uint32_t hashval, hash;
+ dns_keyfileio_t *kfio, *next;
+
+ REQUIRE(DNS_KEYMGMT_VALID(mgmt));
+ REQUIRE(match != NULL && *match == NULL);
+
+ RWLOCK(&mgmt->lock, isc_rwlocktype_read);
+
+ if (atomic_load_relaxed(&mgmt->count) == 0) {
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_read);
+ return;
+ }
+
+ hashval = dns_name_hash(&zone->origin, false);
+ hash = hash_index(hashval, mgmt->bits);
+
+ for (kfio = mgmt->table[hash]; kfio != NULL; kfio = next) {
+ next = kfio->next;
+
+ if (dns_name_equal(kfio->name, &zone->origin)) {
+ *match = kfio;
+ break;
+ }
+ }
+
+ RWUNLOCK(&mgmt->lock, isc_rwlocktype_read);
+}
+
isc_result_t
dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr,
@@ -18003,6 +18584,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
zmgr->loadtasks = NULL;
zmgr->mctxpool = NULL;
zmgr->task = NULL;
+ zmgr->checkdsrl = NULL;
zmgr->notifyrl = NULL;
zmgr->refreshrl = NULL;
zmgr->startupnotifyrl = NULL;
@@ -18011,6 +18593,9 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
ISC_LIST_INIT(zmgr->waiting_for_xfrin);
ISC_LIST_INIT(zmgr->xfrin_in_progress);
memset(zmgr->unreachable, 0, sizeof(zmgr->unreachable));
+ for (size_t i = 0; i < UNREACH_CACHE_SIZE; i++) {
+ atomic_init(&zmgr->unreachable[i].expire, 0);
+ }
isc_rwlock_init(&zmgr->rwlock, 0, 0);
zmgr->transfersin = 10;
@@ -18027,12 +18612,18 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_task_setname(zmgr->task, "zmgr", zmgr);
result = isc_ratelimiter_create(mctx, timermgr, zmgr->task,
- &zmgr->notifyrl);
+ &zmgr->checkdsrl);
if (result != ISC_R_SUCCESS) {
goto free_task;
}
result = isc_ratelimiter_create(mctx, timermgr, zmgr->task,
+ &zmgr->notifyrl);
+ if (result != ISC_R_SUCCESS) {
+ goto free_checkdsrl;
+ }
+
+ result = isc_ratelimiter_create(mctx, timermgr, zmgr->task,
&zmgr->refreshrl);
if (result != ISC_R_SUCCESS) {
goto free_notifyrl;
@@ -18050,7 +18641,11 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
goto free_startupnotifyrl;
}
- /* default to 20 refresh queries / notifies per second. */
+ /* Key file I/O locks. */
+ zonemgr_keymgmt_init(zmgr);
+
+ /* Default to 20 refresh queries / notifies / checkds per second. */
+ setrl(zmgr->checkdsrl, &zmgr->checkdsrate, 20);
setrl(zmgr->notifyrl, &zmgr->notifyrate, 20);
setrl(zmgr->startupnotifyrl, &zmgr->startupnotifyrate, 20);
setrl(zmgr->refreshrl, &zmgr->serialqueryrate, 20);
@@ -18080,6 +18675,8 @@ free_refreshrl:
isc_ratelimiter_detach(&zmgr->refreshrl);
free_notifyrl:
isc_ratelimiter_detach(&zmgr->notifyrl);
+free_checkdsrl:
+ isc_ratelimiter_detach(&zmgr->checkdsrl);
free_task:
isc_task_detach(&zmgr->task);
free_urlock:
@@ -18161,6 +18758,8 @@ dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
*/
isc_refcount_increment0(&zone->irefs);
+ zonemgr_keymgmt_add(zmgr, zone, NULL);
+
ISC_LIST_APPEND(zmgr->zones, zone, link);
zone->zmgr = zmgr;
isc_refcount_increment(&zmgr->refs);
@@ -18189,6 +18788,9 @@ dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
LOCK_ZONE(zone);
ISC_LIST_UNLINK(zmgr->zones, zone, link);
+
+ zonemgr_keymgmt_delete(zmgr, zone);
+
zone->zmgr = NULL;
if (isc_refcount_decrement(&zmgr->refs) == 1) {
@@ -18268,6 +18870,7 @@ dns_zonemgr_shutdown(dns_zonemgr_t *zmgr) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
+ isc_ratelimiter_shutdown(zmgr->checkdsrl);
isc_ratelimiter_shutdown(zmgr->notifyrl);
isc_ratelimiter_shutdown(zmgr->refreshrl);
isc_ratelimiter_shutdown(zmgr->startupnotifyrl);
@@ -18348,9 +18951,10 @@ dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones) {
/* Create or resize the zone task pools. */
if (zmgr->zonetasks == NULL) {
result = isc_taskpool_create(zmgr->taskmgr, zmgr->mctx, ntasks,
- 2, &pool);
+ 2, false, &pool);
} else {
- result = isc_taskpool_expand(&zmgr->zonetasks, ntasks, &pool);
+ result = isc_taskpool_expand(&zmgr->zonetasks, ntasks, false,
+ &pool);
}
if (result == ISC_R_SUCCESS) {
@@ -18360,30 +18964,16 @@ dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones) {
pool = NULL;
if (zmgr->loadtasks == NULL) {
result = isc_taskpool_create(zmgr->taskmgr, zmgr->mctx, ntasks,
- 2, &pool);
+ 2, true, &pool);
} else {
- result = isc_taskpool_expand(&zmgr->loadtasks, ntasks, &pool);
+ result = isc_taskpool_expand(&zmgr->loadtasks, ntasks, true,
+ &pool);
}
if (result == ISC_R_SUCCESS) {
zmgr->loadtasks = pool;
}
- /*
- * We always set all tasks in the zone-load task pool to
- * privileged. This prevents other tasks in the system from
- * running while the server task manager is in privileged
- * mode.
- *
- * NOTE: If we start using task privileges for any other
- * part of the system than zone tasks, then this will need to be
- * revisted. In that case we'd want to turn on privileges for
- * zone tasks only when we were loading, and turn them off the
- * rest of the time. For now, however, it's okay to just
- * set it and forget it.
- */
- isc_taskpool_setprivilege(zmgr->loadtasks, true);
-
/* Create or resize the zone memory context pool. */
if (zmgr->mctxpool == NULL) {
result = isc_pool_create(zmgr->mctx, nmctx, mctxfree, mctxinit,
@@ -18409,6 +18999,7 @@ zonemgr_free(dns_zonemgr_t *zmgr) {
isc_refcount_destroy(&zmgr->refs);
isc_mutex_destroy(&zmgr->iolock);
+ isc_ratelimiter_detach(&zmgr->checkdsrl);
isc_ratelimiter_detach(&zmgr->notifyrl);
isc_ratelimiter_detach(&zmgr->refreshrl);
isc_ratelimiter_detach(&zmgr->startupnotifyrl);
@@ -18416,6 +19007,9 @@ zonemgr_free(dns_zonemgr_t *zmgr) {
isc_rwlock_destroy(&zmgr->urlock);
isc_rwlock_destroy(&zmgr->rwlock);
+
+ zonemgr_keymgmt_destroy(zmgr);
+
mctx = zmgr->mctx;
isc_mem_put(zmgr->mctx, zmgr, sizeof(*zmgr));
isc_mem_detach(&mctx);
@@ -18449,6 +19043,13 @@ dns_zonemgr_getttransfersperns(dns_zonemgr_t *zmgr) {
return (zmgr->transfersperns);
}
+isc_taskmgr_t *
+dns_zonemgr_gettaskmgr(dns_zonemgr_t *zmgr) {
+ REQUIRE(DNS_ZONEMGR_VALID(zmgr));
+
+ return (zmgr->taskmgr);
+}
+
/*
* Try to start a new incoming zone transfer to fill a quota
* slot that was just vacated.
@@ -18793,6 +19394,13 @@ setrl(isc_ratelimiter_t *rl, unsigned int *rate, unsigned int value) {
}
void
+dns_zonemgr_setcheckdsrate(dns_zonemgr_t *zmgr, unsigned int value) {
+ REQUIRE(DNS_ZONEMGR_VALID(zmgr));
+
+ setrl(zmgr->checkdsrl, &zmgr->checkdsrate, value);
+}
+
+void
dns_zonemgr_setnotifyrate(dns_zonemgr_t *zmgr, unsigned int value) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
@@ -19004,8 +19612,8 @@ dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats) {
} else if (!zone->requeststats_on && stats != NULL) {
if (zone->requeststats == NULL) {
isc_stats_attach(stats, &zone->requeststats);
- zone->requeststats_on = true;
}
+ zone->requeststats_on = true;
}
UNLOCK_ZONE(zone);
}
@@ -19213,6 +19821,43 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) {
return (count);
}
+static void
+dns__zone_lockunlock_keyfiles(dns_zone_t *zone, bool lock) {
+ dns_keyfileio_t *kfio = NULL;
+
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ if (zone->kasp == NULL) {
+ /* No need to lock, nothing is writing key files. */
+ return;
+ }
+
+ zonemgr_keymgmt_find(zone->zmgr, zone, &kfio);
+ if (kfio == NULL) {
+ /* Should not happen, but if so, add the entry now. */
+ dns_zone_log(zone, ISC_LOG_WARNING,
+ "attempt to lock key files, but no key file lock "
+ "available, abort");
+ return;
+ }
+
+ if (lock) {
+ isc_mutex_lock(&kfio->lock);
+ } else {
+ isc_mutex_unlock(&kfio->lock);
+ }
+}
+
+void
+dns_zone_lock_keyfiles(dns_zone_t *zone) {
+ dns__zone_lockunlock_keyfiles(zone, true);
+}
+
+void
+dns_zone_unlock_keyfiles(dns_zone_t *zone) {
+ dns__zone_lockunlock_keyfiles(zone, false);
+}
+
isc_result_t
dns_zone_checknames(dns_zone_t *zone, const dns_name_t *name,
dns_rdata_t *rdata) {
@@ -19477,16 +20122,6 @@ cleanup:
return (result);
}
-static void
-clear_keylist(dns_dnsseckeylist_t *list, isc_mem_t *mctx) {
- dns_dnsseckey_t *key;
- while (!ISC_LIST_EMPTY(*list)) {
- key = ISC_LIST_HEAD(*list);
- ISC_LIST_UNLINK(*list, key, link);
- dns_dnsseckey_destroy(mctx, &key);
- }
-}
-
/* Called once; *timep should be set to the current time. */
static isc_result_t
next_keyevent(dst_key_t *key, isc_stdtime_t *timep) {
@@ -19878,10 +20513,10 @@ add_chains(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
CHECK(dns_private_chains(db, ver, zone->privatetype, NULL,
&build_nsec3));
if (build_nsec3) {
- CHECK(dns_nsec3_addnsec3sx(db, ver, origin, zone->minimum,
+ CHECK(dns_nsec3_addnsec3sx(db, ver, origin, zone_nsecttl(zone),
false, zone->privatetype, diff));
}
- CHECK(updatesecure(db, ver, origin, zone->minimum, true, diff));
+ CHECK(updatesecure(db, ver, origin, zone_nsecttl(zone), true, diff));
failure:
return (result);
@@ -19897,6 +20532,754 @@ dnssec_report(const char *format, ...) {
}
static void
+checkds_destroy(dns_checkds_t *checkds, bool locked) {
+ isc_mem_t *mctx;
+
+ REQUIRE(DNS_CHECKDS_VALID(checkds));
+
+ dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: destroy DS query");
+
+ if (checkds->zone != NULL) {
+ if (!locked) {
+ LOCK_ZONE(checkds->zone);
+ }
+ REQUIRE(LOCKED_ZONE(checkds->zone));
+ if (ISC_LINK_LINKED(checkds, link)) {
+ ISC_LIST_UNLINK(checkds->zone->checkds_requests,
+ checkds, link);
+ }
+ if (!locked) {
+ UNLOCK_ZONE(checkds->zone);
+ }
+ if (locked) {
+ zone_idetach(&checkds->zone);
+ } else {
+ dns_zone_idetach(&checkds->zone);
+ }
+ }
+ if (checkds->request != NULL) {
+ dns_request_destroy(&checkds->request);
+ }
+ if (checkds->key != NULL) {
+ dns_tsigkey_detach(&checkds->key);
+ }
+ mctx = checkds->mctx;
+ isc_mem_put(checkds->mctx, checkds, sizeof(*checkds));
+ isc_mem_detach(&mctx);
+}
+
+static isc_result_t
+make_dnskey(dst_key_t *key, unsigned char *buf, int bufsize,
+ dns_rdata_t *target) {
+ isc_result_t result;
+ isc_buffer_t b;
+ isc_region_t r;
+
+ isc_buffer_init(&b, buf, bufsize);
+ result = dst_key_todns(key, &b);
+ if (result != ISC_R_SUCCESS) {
+ return (result);
+ }
+
+ dns_rdata_reset(target);
+ isc_buffer_usedregion(&b, &r);
+ dns_rdata_fromregion(target, dst_key_class(key), dns_rdatatype_dnskey,
+ &r);
+ return (ISC_R_SUCCESS);
+}
+
+static bool
+do_checkds(dns_zone_t *zone, dst_key_t *key, isc_stdtime_t now,
+ bool dspublish) {
+ dns_kasp_t *kasp = dns_zone_getkasp(zone);
+ const char *dir = dns_zone_getkeydirectory(zone);
+ isc_result_t result;
+ uint32_t count = 0;
+
+ if (dspublish) {
+ (void)dst_key_getnum(key, DST_NUM_DSPUBCOUNT, &count);
+ count += 1;
+ dst_key_setnum(key, DST_NUM_DSPUBCOUNT, count);
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: %u DS published "
+ "for key %u",
+ count, dst_key_id(key));
+
+ if (count != zone->parentalscnt) {
+ return false;
+ }
+ } else {
+ (void)dst_key_getnum(key, DST_NUM_DSDELCOUNT, &count);
+ count += 1;
+ dst_key_setnum(key, DST_NUM_DSDELCOUNT, count);
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: %u DS withdrawn "
+ "for key %u",
+ count, dst_key_id(key));
+
+ if (count != zone->parentalscnt) {
+ return false;
+ }
+ }
+
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: checkds %s for key "
+ "%u",
+ dspublish ? "published" : "withdrawn", dst_key_id(key));
+
+ dns_zone_lock_keyfiles(zone);
+ result = dns_keymgr_checkds_id(kasp, &zone->checkds_ok, dir, now, now,
+ dspublish, dst_key_id(key),
+ dst_key_alg(key));
+ dns_zone_unlock_keyfiles(zone);
+
+ if (result != ISC_R_SUCCESS) {
+ dns_zone_log(zone, ISC_LOG_WARNING,
+ "checkds: checkds for key %u failed: %s",
+ dst_key_id(key), isc_result_totext(result));
+ return false;
+ }
+
+ return true;
+}
+
+static isc_result_t
+validate_ds(dns_zone_t *zone, dns_message_t *message) {
+ UNUSED(zone);
+ UNUSED(message);
+
+ /* Get closest trust anchor */
+
+ /* Check that trust anchor is (grand)parent of zone. */
+
+ /* Find the DNSKEY signing the message. */
+
+ /* Check that DNSKEY is in chain of trust. */
+
+ /* Validate DS RRset. */
+
+ return (ISC_R_SUCCESS);
+}
+
+static void
+checkds_done(isc_task_t *task, isc_event_t *event) {
+ char addrbuf[ISC_SOCKADDR_FORMATSIZE];
+ char rcode[128];
+ dns_checkds_t *checkds;
+ dns_zone_t *zone;
+ dns_db_t *db = NULL;
+ dns_dbversion_t *version = NULL;
+ dns_dnsseckey_t *key;
+ dns_dnsseckeylist_t keys;
+ dns_kasp_t *kasp = NULL;
+ dns_message_t *message = NULL;
+ dns_rdataset_t *ds_rrset = NULL;
+ dns_requestevent_t *revent = (dns_requestevent_t *)event;
+ isc_buffer_t buf;
+ isc_result_t result;
+ isc_stdtime_t now;
+ isc_time_t timenow;
+ bool rekey = false;
+ bool empty = false;
+
+ UNUSED(task);
+
+ checkds = event->ev_arg;
+ REQUIRE(DNS_CHECKDS_VALID(checkds));
+
+ zone = checkds->zone;
+ INSIST(task == zone->task);
+
+ ISC_LIST_INIT(keys);
+
+ kasp = zone->kasp;
+ INSIST(kasp != NULL);
+
+ isc_buffer_init(&buf, rcode, sizeof(rcode));
+ isc_sockaddr_format(&checkds->dst, addrbuf, sizeof(addrbuf));
+
+ dns_zone_log(zone, ISC_LOG_DEBUG(1), "checkds: DS query to %s: done",
+ addrbuf);
+
+ dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &message);
+ INSIST(message != NULL);
+
+ CHECK(revent->result);
+ CHECK(dns_request_getresponse(revent->request, message,
+ DNS_MESSAGEPARSE_PRESERVEORDER));
+ CHECK(dns_rcode_totext(message->rcode, &buf));
+
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: DS response from %s: %.*s", addrbuf,
+ (int)buf.used, rcode);
+
+ /* Validate response. */
+ CHECK(validate_ds(zone, message));
+
+ if (message->rcode != dns_rcode_noerror) {
+ dns_zone_log(zone, ISC_LOG_NOTICE,
+ "checkds: bad DS response from %s: %.*s", addrbuf,
+ (int)buf.used, rcode);
+ goto failure;
+ }
+
+ /* Lookup DS RRset. */
+ result = dns_message_firstname(message, DNS_SECTION_ANSWER);
+ while (result == ISC_R_SUCCESS) {
+ dns_name_t *name = NULL;
+ dns_rdataset_t *rdataset;
+
+ dns_message_currentname(message, DNS_SECTION_ANSWER, &name);
+ if (dns_name_compare(&zone->origin, name) != 0) {
+ goto next;
+ }
+
+ for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
+ rdataset = ISC_LIST_NEXT(rdataset, link))
+ {
+ if (rdataset->type != dns_rdatatype_ds) {
+ goto next;
+ }
+
+ ds_rrset = rdataset;
+ break;
+ }
+
+ if (ds_rrset != NULL) {
+ break;
+ }
+
+ next:
+ result = dns_message_nextname(message, DNS_SECTION_ANSWER);
+ }
+
+ if (ds_rrset == NULL) {
+ empty = true;
+ dns_zone_log(zone, ISC_LOG_NOTICE,
+ "checkds: empty DS response from %s", addrbuf);
+ }
+
+ TIME_NOW(&timenow);
+ now = isc_time_seconds(&timenow);
+
+ CHECK(dns_zone_getdb(zone, &db));
+ dns_db_currentversion(db, &version);
+
+ KASP_LOCK(kasp);
+ LOCK_ZONE(zone);
+ for (key = ISC_LIST_HEAD(zone->checkds_ok); key != NULL;
+ key = ISC_LIST_NEXT(key, link))
+ {
+ bool alldone = false, found = false;
+ bool checkdspub = false, checkdsdel = false, ksk = false;
+ dst_key_state_t ds_state = DST_KEY_STATE_NA;
+ isc_stdtime_t published = 0, withdrawn = 0;
+ isc_result_t ret = ISC_R_SUCCESS;
+
+ /* Is this key have the KSK role? */
+ (void)dst_key_role(key->key, &ksk, NULL);
+ if (!ksk) {
+ continue;
+ }
+
+ /* Do we need to check the DS RRset for this key? */
+ (void)dst_key_getstate(key->key, DST_KEY_DS, &ds_state);
+ (void)dst_key_gettime(key->key, DST_TIME_DSPUBLISH, &published);
+ (void)dst_key_gettime(key->key, DST_TIME_DSDELETE, &withdrawn);
+
+ if (ds_state == DST_KEY_STATE_RUMOURED && published == 0) {
+ checkdspub = true;
+ } else if (ds_state == DST_KEY_STATE_UNRETENTIVE &&
+ withdrawn == 0) {
+ checkdsdel = true;
+ }
+ if (!checkdspub && !checkdsdel) {
+ continue;
+ }
+
+ if (empty) {
+ goto dswithdrawn;
+ }
+
+ /* Find the appropriate DS record. */
+ ret = dns_rdataset_first(ds_rrset);
+ while (ret == ISC_R_SUCCESS) {
+ dns_rdata_ds_t ds;
+ dns_rdata_t dnskey = DNS_RDATA_INIT;
+ dns_rdata_t dsrdata = DNS_RDATA_INIT;
+ dns_rdata_t rdata = DNS_RDATA_INIT;
+ isc_result_t r;
+ unsigned char dsbuf[DNS_DS_BUFFERSIZE];
+ unsigned char keybuf[DST_KEY_MAXSIZE];
+
+ dns_rdataset_current(ds_rrset, &rdata);
+ r = dns_rdata_tostruct(&rdata, &ds, NULL);
+ if (r != ISC_R_SUCCESS) {
+ goto nextds;
+ }
+ /* Check key tag and algorithm. */
+ if (dst_key_id(key->key) != ds.key_tag) {
+ goto nextds;
+ }
+ if (dst_key_alg(key->key) != ds.algorithm) {
+ goto nextds;
+ }
+ /* Derive DS from DNSKEY, see if the rdata is equal. */
+ make_dnskey(key->key, keybuf, sizeof(keybuf), &dnskey);
+ r = dns_ds_buildrdata(&zone->origin, &dnskey,
+ ds.digest_type, dsbuf, &dsrdata);
+ if (r != ISC_R_SUCCESS) {
+ goto nextds;
+ }
+ if (dns_rdata_compare(&rdata, &dsrdata) == 0) {
+ found = true;
+ if (checkdspub) {
+ /* DS Published. */
+ alldone = do_checkds(zone, key->key,
+ now, true);
+ if (alldone) {
+ rekey = true;
+ }
+ }
+ }
+
+ nextds:
+ ret = dns_rdataset_next(ds_rrset);
+ }
+
+ dswithdrawn:
+ /* DS withdrawn. */
+ if (checkdsdel && !found) {
+ alldone = do_checkds(zone, key->key, now, false);
+ if (alldone) {
+ rekey = true;
+ }
+ }
+ }
+ UNLOCK_ZONE(zone);
+ KASP_UNLOCK(kasp);
+
+ /* Rekey after checkds. */
+ if (rekey) {
+ dns_zone_rekey(zone, false);
+ }
+
+failure:
+ if (result != ISC_R_SUCCESS) {
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: DS request failed: %s",
+ isc_result_totext(result));
+ }
+
+ if (version != NULL) {
+ dns_db_closeversion(db, &version, false);
+ }
+ if (db != NULL) {
+ dns_db_detach(&db);
+ }
+
+ while (!ISC_LIST_EMPTY(keys)) {
+ key = ISC_LIST_HEAD(keys);
+ ISC_LIST_UNLINK(keys, key, link);
+ dns_dnsseckey_destroy(dns_zone_getmctx(zone), &key);
+ }
+
+ isc_event_free(&event);
+ checkds_destroy(checkds, false);
+ dns_message_detach(&message);
+}
+
+static bool
+checkds_isqueued(dns_zone_t *zone, isc_sockaddr_t *addr, dns_tsigkey_t *key) {
+ dns_checkds_t *checkds;
+
+ for (checkds = ISC_LIST_HEAD(zone->checkds_requests); checkds != NULL;
+ checkds = ISC_LIST_NEXT(checkds, link))
+ {
+ if (checkds->request != NULL) {
+ continue;
+ }
+ if (addr != NULL && isc_sockaddr_equal(addr, &checkds->dst) &&
+ checkds->key == key)
+ {
+ return (true);
+ }
+ }
+ return (false);
+}
+
+static isc_result_t
+checkds_create(isc_mem_t *mctx, unsigned int flags, dns_checkds_t **checkdsp) {
+ dns_checkds_t *checkds;
+
+ REQUIRE(checkdsp != NULL && *checkdsp == NULL);
+
+ checkds = isc_mem_get(mctx, sizeof(*checkds));
+ *checkds = (dns_checkds_t){
+ .flags = flags,
+ };
+
+ isc_mem_attach(mctx, &checkds->mctx);
+ isc_sockaddr_any(&checkds->dst);
+ ISC_LINK_INIT(checkds, link);
+ checkds->magic = CHECKDS_MAGIC;
+ *checkdsp = checkds;
+ return (ISC_R_SUCCESS);
+}
+
+static isc_result_t
+checkds_createmessage(dns_zone_t *zone, dns_message_t **messagep) {
+ dns_message_t *message = NULL;
+
+ dns_name_t *tempname = NULL;
+ dns_rdataset_t *temprdataset = NULL;
+
+ isc_result_t result;
+
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(messagep != NULL && *messagep == NULL);
+
+ dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message);
+
+ message->opcode = dns_opcode_query;
+ message->rdclass = zone->rdclass;
+
+ result = dns_message_gettempname(message, &tempname);
+ if (result != ISC_R_SUCCESS) {
+ goto cleanup;
+ }
+
+ result = dns_message_gettemprdataset(message, &temprdataset);
+ if (result != ISC_R_SUCCESS) {
+ goto cleanup;
+ }
+
+ /*
+ * Make question.
+ */
+ dns_name_init(tempname, NULL);
+ dns_name_clone(&zone->origin, tempname);
+ dns_rdataset_makequestion(temprdataset, zone->rdclass,
+ dns_rdatatype_ds);
+ ISC_LIST_APPEND(tempname->list, temprdataset, link);
+ dns_message_addname(message, tempname, DNS_SECTION_QUESTION);
+ tempname = NULL;
+ temprdataset = NULL;
+
+ *messagep = message;
+ return (ISC_R_SUCCESS);
+
+cleanup:
+ if (tempname != NULL) {
+ dns_message_puttempname(message, &tempname);
+ }
+ if (temprdataset != NULL) {
+ dns_message_puttemprdataset(message, &temprdataset);
+ }
+ dns_message_detach(&message);
+ return (result);
+}
+
+static void
+checkds_send_toaddr(isc_task_t *task, isc_event_t *event) {
+ dns_checkds_t *checkds;
+ isc_result_t result;
+ dns_message_t *message = NULL;
+ isc_netaddr_t dstip;
+ dns_tsigkey_t *key = NULL;
+ char addrbuf[ISC_SOCKADDR_FORMATSIZE];
+ isc_sockaddr_t src;
+ unsigned int options, timeout;
+ bool have_checkdssource = false;
+ bool have_checkdsdscp = false;
+ isc_dscp_t dscp = -1;
+
+ checkds = event->ev_arg;
+ REQUIRE(DNS_CHECKDS_VALID(checkds));
+
+ UNUSED(task);
+
+ LOCK_ZONE(checkds->zone);
+
+ checkds->event = NULL;
+
+ if (DNS_ZONE_FLAG(checkds->zone, DNS_ZONEFLG_LOADED) == 0) {
+ result = ISC_R_CANCELED;
+ goto cleanup;
+ }
+
+ if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ||
+ DNS_ZONE_FLAG(checkds->zone, DNS_ZONEFLG_EXITING) ||
+ checkds->zone->view->requestmgr == NULL ||
+ checkds->zone->db == NULL)
+ {
+ result = ISC_R_CANCELED;
+ goto cleanup;
+ }
+
+ /*
+ * The raw IPv4 address should also exist. Don't send to the
+ * mapped form.
+ */
+ if (isc_sockaddr_pf(&checkds->dst) == PF_INET6 &&
+ IN6_IS_ADDR_V4MAPPED(&checkds->dst.type.sin6.sin6_addr))
+ {
+ isc_sockaddr_format(&checkds->dst, addrbuf, sizeof(addrbuf));
+ dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: ignoring IPv6 mapped IPV4 address: %s",
+ addrbuf);
+ result = ISC_R_CANCELED;
+ goto cleanup;
+ }
+
+ result = checkds_createmessage(checkds->zone, &message);
+ if (result != ISC_R_SUCCESS) {
+ goto cleanup;
+ }
+
+ isc_sockaddr_format(&checkds->dst, addrbuf, sizeof(addrbuf));
+ if (checkds->key != NULL) {
+ /* Transfer ownership of key */
+ key = checkds->key;
+ checkds->key = NULL;
+ } else {
+ isc_netaddr_fromsockaddr(&dstip, &checkds->dst);
+ result = dns_view_getpeertsig(checkds->zone->view, &dstip,
+ &key);
+ if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
+ dns_zone_log(checkds->zone, ISC_LOG_ERROR,
+ "checkds: DS query to %s not sent. "
+ "Peer TSIG key lookup failure.",
+ addrbuf);
+ goto cleanup_message;
+ }
+ }
+
+ if (key != NULL) {
+ char namebuf[DNS_NAME_FORMATSIZE];
+
+ dns_name_format(&key->name, namebuf, sizeof(namebuf));
+ dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: sending DS query to %s : TSIG (%s)",
+ addrbuf, namebuf);
+ } else {
+ dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: sending DS query to %s", addrbuf);
+ }
+ options = 0;
+ if (checkds->zone->view->peers != NULL) {
+ dns_peer_t *peer = NULL;
+ bool usetcp = false;
+ result = dns_peerlist_peerbyaddr(checkds->zone->view->peers,
+ &dstip, &peer);
+ if (result == ISC_R_SUCCESS) {
+ result = dns_peer_getquerysource(peer, &src);
+ if (result == ISC_R_SUCCESS) {
+ have_checkdssource = true;
+ }
+ dns_peer_getquerydscp(peer, &dscp);
+ if (dscp != -1) {
+ have_checkdsdscp = true;
+ }
+ result = dns_peer_getforcetcp(peer, &usetcp);
+ if (result == ISC_R_SUCCESS && usetcp) {
+ options |= DNS_FETCHOPT_TCP;
+ }
+ }
+ }
+ switch (isc_sockaddr_pf(&checkds->dst)) {
+ case PF_INET:
+ if (!have_checkdssource) {
+ src = checkds->zone->parentalsrc4;
+ }
+ if (!have_checkdsdscp) {
+ dscp = checkds->zone->parentalsrc4dscp;
+ }
+ break;
+ case PF_INET6:
+ if (!have_checkdssource) {
+ src = checkds->zone->parentalsrc6;
+ }
+ if (!have_checkdsdscp) {
+ dscp = checkds->zone->parentalsrc6dscp;
+ }
+ break;
+ default:
+ result = ISC_R_NOTIMPLEMENTED;
+ goto cleanup_key;
+ }
+
+ dns_zone_log(checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: create request for DS query to %s", addrbuf);
+
+ timeout = 15;
+ options |= DNS_REQUESTOPT_TCP;
+ result = dns_request_createvia(
+ checkds->zone->view->requestmgr, message, &src, &checkds->dst,
+ dscp, options, key, timeout * 3, timeout, 0,
+ checkds->zone->task, checkds_done, checkds, &checkds->request);
+ if (result != ISC_R_SUCCESS) {
+ dns_zone_log(
+ checkds->zone, ISC_LOG_DEBUG(3),
+ "checkds: dns_request_createvia() to %s failed: %s",
+ addrbuf, dns_result_totext(result));
+ }
+
+cleanup_key:
+ if (key != NULL) {
+ dns_tsigkey_detach(&key);
+ }
+cleanup_message:
+ dns_message_detach(&message);
+cleanup:
+ UNLOCK_ZONE(checkds->zone);
+ isc_event_free(&event);
+ if (result != ISC_R_SUCCESS) {
+ checkds_destroy(checkds, false);
+ }
+}
+
+static isc_result_t
+checkds_send_queue(dns_checkds_t *checkds) {
+ isc_event_t *e;
+ isc_result_t result;
+
+ INSIST(checkds->event == NULL);
+ e = isc_event_allocate(checkds->mctx, NULL, DNS_EVENT_CHECKDSSENDTOADDR,
+ checkds_send_toaddr, checkds,
+ sizeof(isc_event_t));
+ e->ev_arg = checkds;
+ e->ev_sender = NULL;
+ result = isc_ratelimiter_enqueue(checkds->zone->zmgr->checkdsrl,
+ checkds->zone->task, &e);
+ if (result != ISC_R_SUCCESS) {
+ isc_event_free(&e);
+ checkds->event = NULL;
+ }
+ return (result);
+}
+
+static void
+checkds_send(dns_zone_t *zone) {
+ dns_view_t *view = dns_zone_getview(zone);
+ isc_result_t result;
+ unsigned int flags = 0;
+
+ /*
+ * Zone lock held by caller.
+ */
+ REQUIRE(LOCKED_ZONE(zone));
+
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: start sending DS queries to %u parentals",
+ zone->parentalscnt);
+
+ if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: abort, named exiting");
+ return;
+ }
+
+ for (unsigned int i = 0; i < zone->parentalscnt; i++) {
+ dns_tsigkey_t *key = NULL;
+ isc_sockaddr_t dst;
+ dns_checkds_t *checkds = NULL;
+
+ if ((zone->parentalkeynames != NULL) &&
+ (zone->parentalkeynames[i] != NULL)) {
+ dns_name_t *keyname = zone->parentalkeynames[i];
+ (void)dns_view_gettsig(view, keyname, &key);
+ }
+
+ dst = zone->parentals[i];
+
+ if (checkds_isqueued(zone, &dst, key)) {
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: DS query to parent "
+ "%d is queued",
+ i);
+ if (key != NULL) {
+ dns_tsigkey_detach(&key);
+ }
+ continue;
+ }
+
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: create DS query for "
+ "parent %d",
+ i);
+
+ result = checkds_create(zone->mctx, flags, &checkds);
+ if (result != ISC_R_SUCCESS) {
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: create DS query for "
+ "parent %d failed",
+ i);
+ continue;
+ }
+ zone_iattach(zone, &checkds->zone);
+ checkds->dst = dst;
+
+ INSIST(checkds->key == NULL);
+ if (key != NULL) {
+ checkds->key = key;
+ key = NULL;
+ }
+
+ ISC_LIST_APPEND(zone->checkds_requests, checkds, link);
+ result = checkds_send_queue(checkds);
+ if (result != ISC_R_SUCCESS) {
+ dns_zone_log(zone, ISC_LOG_DEBUG(3),
+ "checkds: send DS query to "
+ "parent %d failed",
+ i);
+ checkds_destroy(checkds, true);
+ }
+ }
+}
+
+static void
+zone_checkds(dns_zone_t *zone) {
+ bool cdscheck = false;
+
+ for (dns_dnsseckey_t *key = ISC_LIST_HEAD(zone->checkds_ok);
+ key != NULL; key = ISC_LIST_NEXT(key, link))
+ {
+ dst_key_state_t ds_state = DST_KEY_STATE_NA;
+ bool ksk = false;
+ isc_stdtime_t published = 0, withdrawn = 0;
+
+ /* Is this key have the KSK role? */
+ (void)dst_key_role(key->key, &ksk, NULL);
+ if (!ksk) {
+ continue;
+ }
+
+ /* Do we need to check the DS RRset? */
+ (void)dst_key_getstate(key->key, DST_KEY_DS, &ds_state);
+ (void)dst_key_gettime(key->key, DST_TIME_DSPUBLISH, &published);
+ (void)dst_key_gettime(key->key, DST_TIME_DSDELETE, &withdrawn);
+
+ if (ds_state == DST_KEY_STATE_RUMOURED && published == 0) {
+ dst_key_setnum(key->key, DST_NUM_DSPUBCOUNT, 0);
+ cdscheck = true;
+ } else if (ds_state == DST_KEY_STATE_UNRETENTIVE &&
+ withdrawn == 0) {
+ dst_key_setnum(key->key, DST_NUM_DSDELCOUNT, 0);
+ cdscheck = true;
+ }
+ }
+
+ if (cdscheck) {
+ /* Request the DS RRset. */
+ LOCK_ZONE(zone);
+ checkds_send(zone);
+ UNLOCK_ZONE(zone);
+ }
+}
+
+static void
zone_rekey(dns_zone_t *zone) {
isc_result_t result;
dns_db_t *db = NULL;
@@ -19910,7 +21293,7 @@ zone_rekey(dns_zone_t *zone) {
dns__zonediff_t zonediff;
bool commit = false, newactive = false;
bool newalg = false;
- bool fullsign, use_kasp;
+ bool fullsign;
dns_ttl_t ttl = 3600;
const char *dir = NULL;
isc_mem_t *mctx = NULL;
@@ -19943,6 +21326,8 @@ zone_rekey(dns_zone_t *zone) {
TIME_NOW(&timenow);
now = isc_time_seconds(&timenow);
+ kasp = dns_zone_getkasp(zone);
+
dnssec_log(zone, ISC_LOG_INFO, "reconfiguring zone keys");
/* Get the SOA record's TTL */
@@ -19956,9 +21341,18 @@ zone_rekey(dns_zone_t *zone) {
dns_rdatatype_none, 0, &keyset, &keysigs);
if (result == ISC_R_SUCCESS) {
ttl = keyset.ttl;
- CHECK(dns_dnssec_keylistfromrdataset(
+
+ dns_zone_lock_keyfiles(zone);
+
+ result = dns_dnssec_keylistfromrdataset(
&zone->origin, dir, mctx, &keyset, &keysigs, &soasigs,
- false, false, &dnskeys));
+ false, false, &dnskeys);
+
+ dns_zone_unlock_keyfiles(zone);
+
+ if (result != ISC_R_SUCCESS) {
+ goto failure;
+ }
} else if (result != ISC_R_NOTFOUND) {
goto failure;
}
@@ -19983,48 +21377,78 @@ zone_rekey(dns_zone_t *zone) {
*/
fullsign = DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_FULLSIGN);
- kasp = dns_zone_getkasp(zone);
- use_kasp = dns_zone_use_kasp(zone);
- if (kasp != NULL) {
- LOCK(&kasp->lock);
- }
+ KASP_LOCK(kasp);
+ dns_zone_lock_keyfiles(zone);
result = dns_dnssec_findmatchingkeys(&zone->origin, dir, now, mctx,
&keys);
+ dns_zone_unlock_keyfiles(zone);
+
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_DEBUG(1),
"zone_rekey:dns_dnssec_findmatchingkeys failed: %s",
isc_result_totext(result));
}
- if (use_kasp && (result == ISC_R_SUCCESS || result == ISC_R_NOTFOUND)) {
- result = dns_keymgr_run(&zone->origin, zone->rdclass, dir, mctx,
- &keys, kasp, now, &nexttime);
+ if (kasp != NULL) {
+ /*
+ * Check DS at parental agents. Clear ongoing checks.
+ */
+ LOCK_ZONE(zone);
+ checkds_cancel(zone);
+ clear_keylist(&zone->checkds_ok, zone->mctx);
+ ISC_LIST_INIT(zone->checkds_ok);
+ UNLOCK_ZONE(zone);
+
+ result = dns_zone_getdnsseckeys(zone, db, ver, now,
+ &zone->checkds_ok);
+
if (result != ISC_R_SUCCESS) {
dnssec_log(zone, ISC_LOG_ERROR,
- "zone_rekey:dns_dnssec_keymgr failed: %s",
+ "zone_rekey:dns_zone_getdnsseckeys failed: "
+ "%s",
isc_result_totext(result));
- goto failure;
+ } else {
+ zone_checkds(zone);
}
- }
- if (kasp != NULL) {
- UNLOCK(&kasp->lock);
+ if (result == ISC_R_SUCCESS || result == ISC_R_NOTFOUND) {
+ dns_zone_lock_keyfiles(zone);
+ result = dns_keymgr_run(&zone->origin, zone->rdclass,
+ dir, mctx, &keys, &dnskeys,
+ kasp, now, &nexttime);
+ dns_zone_unlock_keyfiles(zone);
+
+ if (result != ISC_R_SUCCESS) {
+ dnssec_log(zone, ISC_LOG_ERROR,
+ "zone_rekey:dns_dnssec_keymgr "
+ "failed: %s",
+ isc_result_totext(result));
+ KASP_UNLOCK(kasp);
+ goto failure;
+ }
+ }
}
+ KASP_UNLOCK(kasp);
+
if (result == ISC_R_SUCCESS) {
+ bool cds_delete = false;
+ isc_stdtime_t when;
+
/*
* Publish CDS/CDNSKEY DELETE records if the zone is
* transitioning from secure to insecure.
*/
- bool cds_delete = dns_zone_secure_to_insecure(zone, false);
- isc_stdtime_t when;
+ if (kasp != NULL &&
+ strcmp(dns_kasp_getname(kasp), "insecure") == 0) {
+ cds_delete = true;
+ }
/*
* Only update DNSKEY TTL if we have a policy.
*/
- if (kasp != NULL && strcmp(dns_kasp_getname(kasp), "none") != 0)
- {
+ if (kasp != NULL) {
ttl = dns_kasp_dnskeyttl(kasp);
}
@@ -20278,7 +21702,7 @@ zone_rekey(dns_zone_t *zone) {
/*
* If keymgr provided a next time, use the calculated next rekey time.
*/
- if (use_kasp) {
+ if (kasp != NULL) {
isc_time_t timenext;
uint32_t nexttime_seconds;
@@ -20360,6 +21784,10 @@ failure:
* Something went wrong; try again in ten minutes or
* after a key refresh interval, whichever is shorter.
*/
+ dnssec_log(zone, ISC_LOG_DEBUG(3),
+ "zone_rekey failure: %s (retry in %u seconds)",
+ isc_result_totext(result),
+ ISC_MIN(zone->refreshkeyinterval, 600));
isc_interval_set(&ival, ISC_MIN(zone->refreshkeyinterval, 600),
0);
isc_time_nowplusinterval(&zone->refreshkeytime, &ival);
@@ -20443,7 +21871,6 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
isc_result_t result;
dns_dbnode_t *node = NULL;
dns_rdataset_t dnskey, cds, cdnskey;
- unsigned char buffer[DNS_DS_BUFFERSIZE];
unsigned char algorithms[256];
unsigned int i;
bool empty = false;
@@ -20528,16 +21955,14 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
result = dns_rdataset_next(&dnskey))
{
dns_rdata_t rdata = DNS_RDATA_INIT;
- dns_rdata_t dsrdata = DNS_RDATA_INIT;
+ dns_rdata_dnskey_t structdnskey;
dns_rdataset_current(&dnskey, &rdata);
- CHECK(dns_ds_buildrdata(&zone->origin, &rdata,
- structcds.digest_type,
- buffer, &dsrdata));
- if (crdata.length == dsrdata.length &&
- memcmp(crdata.data, dsrdata.data,
- dsrdata.length) == 0)
- {
+ CHECK(dns_rdata_tostruct(&rdata, &structdnskey,
+ NULL));
+
+ if (structdnskey.algorithm ==
+ structcds.algorithm) {
algorithms[structcds.algorithm] = found;
}
}
@@ -20602,12 +22027,14 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
result = dns_rdataset_next(&dnskey))
{
dns_rdata_t rdata = DNS_RDATA_INIT;
+ dns_rdata_dnskey_t structdnskey;
dns_rdataset_current(&dnskey, &rdata);
- if (crdata.length == rdata.length &&
- memcmp(crdata.data, rdata.data,
- rdata.length) == 0)
- {
+ CHECK(dns_rdata_tostruct(&rdata, &structdnskey,
+ NULL));
+
+ if (structdnskey.algorithm ==
+ structcdnskey.algorithm) {
algorithms[structcdnskey.algorithm] =
found;
}
@@ -21067,6 +22494,7 @@ static void
setnsec3param(isc_task_t *task, isc_event_t *event) {
const char *me = "setnsec3param";
dns_zone_t *zone = event->ev_arg;
+ bool loadpending;
INSIST(DNS_ZONE_VALID(zone));
@@ -21074,6 +22502,10 @@ setnsec3param(isc_task_t *task, isc_event_t *event) {
ENTER;
+ LOCK_ZONE(zone);
+ loadpending = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING);
+ UNLOCK_ZONE(zone);
+
/*
* If receive_secure_serial is still processing or we have a
* queued event append rss_post queue.
@@ -21084,11 +22516,46 @@ setnsec3param(isc_task_t *task, isc_event_t *event) {
*/
ISC_LIST_APPEND(zone->rss_post, event, ev_link);
} else {
+ bool rescheduled = false;
+ ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
+ /*
+ * The zone is not yet fully loaded. Reschedule the event to
+ * be picked up later. This turns this function into a busy
+ * wait, but it only happens at startup.
+ */
+ if (zone->db == NULL && loadpending) {
+ rescheduled = true;
+ isc_task_send(task, &event);
+ }
+ ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
+ if (rescheduled) {
+ return;
+ }
+
rss_post(zone, event);
}
dns_zone_idetach(&zone);
}
+static void
+salt2text(unsigned char *salt, uint8_t saltlen, unsigned char *text,
+ unsigned int textlen) {
+ isc_region_t r;
+ isc_buffer_t buf;
+ isc_result_t result;
+
+ r.base = salt;
+ r.length = (unsigned int)saltlen;
+
+ isc_buffer_init(&buf, text, textlen);
+ result = isc_hex_totext(&r, 2, "", &buf);
+ if (result == ISC_R_SUCCESS) {
+ text[saltlen * 2] = 0;
+ } else {
+ text[0] = 0;
+ }
+}
+
/*
* Check whether NSEC3 chain addition or removal specified by the private-type
* record passed with the event was already queued (or even fully performed).
@@ -21141,6 +22608,53 @@ rss_post(dns_zone_t *zone, isc_event_t *event) {
CHECK(dns_db_getoriginnode(db, &node));
/*
+ * Do we need to look up the NSEC3 parameters?
+ */
+ if (np->lookup) {
+ dns_rdata_nsec3param_t param;
+ dns_rdata_t nrdata = DNS_RDATA_INIT;
+ dns_rdata_t prdata = DNS_RDATA_INIT;
+ unsigned char nbuf[DNS_NSEC3PARAM_BUFFERSIZE];
+ unsigned char saltbuf[255];
+ isc_buffer_t b;
+
+ param.salt = NULL;
+ result = dns__zone_lookup_nsec3param(zone, &np->rdata, &param,
+ saltbuf, np->resalt);
+ if (result == ISC_R_SUCCESS) {
+ /*
+ * Success because the NSEC3PARAM already exists, but
+ * function returns void, so goto failure to clean up.
+ */
+ goto failure;
+ }
+ if (result != DNS_R_NSEC3RESALT && result != ISC_R_NOTFOUND) {
+ dnssec_log(zone, ISC_LOG_DEBUG(3),
+ "setnsec3param:lookup nsec3param -> %s",
+ isc_result_totext(result));
+ goto failure;
+ }
+
+ INSIST(param.salt != NULL);
+
+ /* Update NSEC3 parameters. */
+ np->rdata.hash = param.hash;
+ np->rdata.flags = param.flags;
+ np->rdata.iterations = param.iterations;
+ np->rdata.salt_length = param.salt_length;
+ np->rdata.salt = param.salt;
+
+ isc_buffer_init(&b, nbuf, sizeof(nbuf));
+ CHECK(dns_rdata_fromstruct(&nrdata, zone->rdclass,
+ dns_rdatatype_nsec3param, &np->rdata,
+ &b));
+ dns_nsec3param_toprivate(&nrdata, &prdata, zone->privatetype,
+ np->data, sizeof(np->data));
+ np->length = prdata.length;
+ np->nsec = false;
+ }
+
+ /*
* Does a private-type record already exist for this chain?
*/
result = dns_db_findrdataset(db, node, newver, zone->privatetype,
@@ -21282,25 +22796,6 @@ failure:
INSIST(newver == NULL);
}
-static void
-salt2text(unsigned char *salt, uint8_t saltlen, unsigned char *text,
- unsigned int textlen) {
- isc_region_t r;
- isc_buffer_t buf;
- isc_result_t result;
-
- r.base = salt;
- r.length = (unsigned int)saltlen;
-
- isc_buffer_init(&buf, text, textlen);
- result = isc_hex_totext(&r, 2, "", &buf);
- if (result == ISC_R_SUCCESS) {
- text[saltlen * 2] = 0;
- } else {
- text[0] = 0;
- }
-}
-
/*
* Check if zone has NSEC3PARAM (and thus a chain) with the right parameters.
*
@@ -21332,14 +22827,17 @@ dns__zone_lookup_nsec3param(dns_zone_t *zone, dns_rdata_nsec3param_t *lookup,
}
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
if (db == NULL) {
+ result = ISC_R_FAILURE;
goto setparam;
}
result = dns_db_findnode(db, &zone->origin, false, &node);
if (result != ISC_R_SUCCESS) {
dns_zone_log(zone, ISC_LOG_ERROR,
- "nsec3param lookup failure: %s",
+ "dns__zone_lookup_nsec3param:"
+ "dns_db_findnode -> %s",
dns_result_totext(result));
+ result = ISC_R_FAILURE;
goto setparam;
}
dns_db_currentversion(db, &version);
@@ -21351,7 +22849,8 @@ dns__zone_lookup_nsec3param(dns_zone_t *zone, dns_rdata_nsec3param_t *lookup,
INSIST(!dns_rdataset_isassociated(&rdataset));
if (result != ISC_R_NOTFOUND) {
dns_zone_log(zone, ISC_LOG_ERROR,
- "nsec3param lookup failure: %s",
+ "dns__zone_lookup_nsec3param:"
+ "dns_db_findrdataset -> %s",
dns_result_totext(result));
}
goto setparam;
@@ -21391,10 +22890,13 @@ dns__zone_lookup_nsec3param(dns_zone_t *zone, dns_rdata_nsec3param_t *lookup,
break;
}
+ if (result == ISC_R_NOMORE) {
+ result = ISC_R_NOTFOUND;
+ }
+
setparam:
if (result != ISC_R_SUCCESS) {
/* Found no match. */
- result = ISC_R_NOTFOUND;
param->hash = lookup->hash;
param->flags = lookup->flags;
param->iterations = lookup->iterations;
@@ -21402,6 +22904,10 @@ setparam:
param->salt = lookup->salt;
}
+ if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS) {
+ goto failure;
+ }
+
if (param->salt_length == 0) {
DE_CONST("-", param->salt);
} else if (resalt || param->salt == NULL) {
@@ -21434,6 +22940,7 @@ setparam:
INSIST(result != ISC_R_SUCCESS);
}
+failure:
if (dns_rdataset_isassociated(&rdataset)) {
dns_rdataset_disassociate(&rdataset);
}
@@ -21485,6 +22992,7 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags,
dns_zone_t *dummy = NULL;
isc_buffer_t b;
isc_event_t *e = NULL;
+ bool do_lookup = false;
REQUIRE(DNS_ZONE_VALID(zone));
@@ -21507,7 +23015,11 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags,
UNLOCK_ZONE(zone);
return (ISC_R_SUCCESS);
}
- INSIST(param.salt != NULL);
+ /*
+ * Schedule lookup if lookup above failed (may happen if zone
+ * db is NULL for example).
+ */
+ do_lookup = (param.salt == NULL) ? true : false;
}
e = isc_event_allocate(zone->mctx, zone, DNS_EVENT_SETNSEC3PARAM,
@@ -21515,8 +23027,9 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags,
npe = (struct np3event *)e;
np = &npe->params;
-
np->replace = replace;
+ np->resalt = resalt;
+ np->lookup = do_lookup;
if (hash == 0) {
np->length = 0;
np->nsec = true;
@@ -21528,22 +23041,32 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags,
param.mctx = NULL;
/* nsec3 specific param set in dns__zone_lookup_nsec3param() */
isc_buffer_init(&b, nbuf, sizeof(nbuf));
- CHECK(dns_rdata_fromstruct(&nrdata, zone->rdclass,
- dns_rdatatype_nsec3param, &param,
- &b));
- dns_nsec3param_toprivate(&nrdata, &prdata, zone->privatetype,
- np->data, sizeof(np->data));
- np->length = prdata.length;
+
+ if (param.salt != NULL) {
+ CHECK(dns_rdata_fromstruct(&nrdata, zone->rdclass,
+ dns_rdatatype_nsec3param,
+ &param, &b));
+ dns_nsec3param_toprivate(&nrdata, &prdata,
+ zone->privatetype, np->data,
+ sizeof(np->data));
+ np->length = prdata.length;
+ }
+
+ np->rdata = param;
np->nsec = false;
if (isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(3))) {
unsigned char salttext[255 * 2 + 1];
- salt2text(param.salt, param.salt_length, salttext,
- sizeof(salttext));
+ if (param.salt != NULL) {
+ salt2text(param.salt, param.salt_length,
+ salttext, sizeof(salttext));
+ }
dnssec_log(zone, ISC_LOG_DEBUG(3),
- "setnsec3param:nsec3 %u %u %u %s",
+ "setnsec3param:nsec3 %u %u %u %u:%s",
param.hash, param.flags, param.iterations,
- salttext);
+ param.salt_length,
+ param.salt == NULL ? "unknown"
+ : (char *)salttext);
}
}
@@ -21876,3 +23399,10 @@ done:
return (result);
}
+
+static inline dns_ttl_t
+zone_nsecttl(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ return (ISC_MIN(zone->minimum, zone->soattl));
+}
diff --git a/external/mpl/bind/dist/lib/dns/zoneverify.c b/external/mpl/bind/dist/lib/dns/zoneverify.c
index 7c5eefe3423..3059b55a458 100644
--- a/external/mpl/bind/dist/lib/dns/zoneverify.c
+++ b/external/mpl/bind/dist/lib/dns/zoneverify.c
@@ -1,4 +1,4 @@
-/* $NetBSD: zoneverify.c,v 1.7 2021/02/19 16:42:16 christos Exp $ */
+/* $NetBSD: zoneverify.c,v 1.8 2021/08/19 11:50:17 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -618,11 +618,11 @@ cleanup:
}
static isc_result_t
-isoptout(const vctx_t *vctx, const dns_rdata_t *nsec3rdata, bool *optout) {
+isoptout(const vctx_t *vctx, const dns_rdata_nsec3param_t *nsec3param,
+ bool *optout) {
dns_rdataset_t rdataset;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_nsec3_t nsec3;
- dns_rdata_nsec3param_t nsec3param;
dns_fixedname_t fixed;
dns_name_t *hashname;
isc_result_t result;
@@ -630,14 +630,11 @@ isoptout(const vctx_t *vctx, const dns_rdata_t *nsec3rdata, bool *optout) {
unsigned char rawhash[NSEC3_MAX_HASH_LENGTH];
size_t rhsize = sizeof(rawhash);
- result = dns_rdata_tostruct(nsec3rdata, &nsec3param, NULL);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
dns_fixedname_init(&fixed);
result = dns_nsec3_hashname(&fixed, rawhash, &rhsize, vctx->origin,
- vctx->origin, nsec3param.hash,
- nsec3param.iterations, nsec3param.salt,
- nsec3param.salt_length);
+ vctx->origin, nsec3param->hash,
+ nsec3param->iterations, nsec3param->salt,
+ nsec3param->salt_length);
if (result != ISC_R_SUCCESS) {
zoneverify_log_error(vctx, "dns_nsec3_hashname(): %s",
isc_result_totext(result));
@@ -710,7 +707,14 @@ verifynsec3(const vctx_t *vctx, const dns_name_t *name,
return (ISC_R_SUCCESS);
}
- result = isoptout(vctx, rdata, &optout);
+ if (nsec3param.iterations > DNS_NSEC3_MAXITERATIONS) {
+ result = DNS_R_NSEC3ITERRANGE;
+ zoneverify_log_error(vctx, "verifynsec3: %s",
+ isc_result_totext(result));
+ return (result);
+ }
+
+ result = isoptout(vctx, &nsec3param, &optout);
if (result != ISC_R_SUCCESS) {
return (result);
}
diff --git a/external/mpl/bind/dist/lib/irs/context.c b/external/mpl/bind/dist/lib/irs/context.c
index d34b1c4cd0c..5f4f9c56919 100644
--- a/external/mpl/bind/dist/lib/irs/context.c
+++ b/external/mpl/bind/dist/lib/irs/context.c
@@ -1,4 +1,4 @@
-/* $NetBSD: context.c,v 1.5 2021/02/19 16:42:18 christos Exp $ */
+/* $NetBSD: context.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,7 +16,9 @@
#include <isc/app.h>
#include <isc/lib.h>
#include <isc/magic.h>
+#include <isc/managers.h>
#include <isc/mem.h>
+#include <isc/netmgr.h>
#include <isc/once.h>
#include <isc/socket.h>
#include <isc/task.h>
@@ -54,6 +56,7 @@ struct irs_context {
unsigned int magic;
isc_mem_t *mctx;
isc_appctx_t *actx;
+ isc_nm_t *netmgr;
isc_taskmgr_t *taskmgr;
isc_task_t *task;
isc_socketmgr_t *socketmgr;
@@ -64,11 +67,11 @@ struct irs_context {
};
static void
-ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- if (taskmgrp != NULL) {
- isc_taskmgr_destroy(taskmgrp);
- }
+ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_nm_t **netmgrp,
+ isc_taskmgr_t **taskmgrp, isc_socketmgr_t **socketmgrp,
+ isc_timermgr_t **timermgrp) {
+ isc_managers_destroy(netmgrp == NULL ? NULL : netmgrp,
+ taskmgrp == NULL ? NULL : taskmgrp);
if (timermgrp != NULL) {
isc_timermgr_destroy(timermgrp);
@@ -88,8 +91,9 @@ ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
}
static isc_result_t
-ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
+ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_nm_t **netmgrp,
+ isc_taskmgr_t **taskmgrp, isc_socketmgr_t **socketmgrp,
+ isc_timermgr_t **timermgrp) {
isc_result_t result;
isc_mem_create(mctxp);
@@ -99,17 +103,17 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
goto fail;
}
- result = isc_taskmgr_createinctx(*mctxp, 1, 0, taskmgrp);
+ result = isc_managers_create(*mctxp, 1, 0, netmgrp, taskmgrp);
if (result != ISC_R_SUCCESS) {
goto fail;
}
- result = isc_socketmgr_createinctx(*mctxp, socketmgrp);
+ result = isc_socketmgr_create(*mctxp, socketmgrp);
if (result != ISC_R_SUCCESS) {
goto fail;
}
- result = isc_timermgr_createinctx(*mctxp, timermgrp);
+ result = isc_timermgr_create(*mctxp, timermgrp);
if (result != ISC_R_SUCCESS) {
goto fail;
}
@@ -117,7 +121,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
return (ISC_R_SUCCESS);
fail:
- ctxs_destroy(mctxp, actxp, taskmgrp, socketmgrp, timermgrp);
+ ctxs_destroy(mctxp, actxp, netmgrp, taskmgrp, socketmgrp, timermgrp);
return (result);
}
@@ -146,6 +150,7 @@ irs_context_create(irs_context_t **contextp) {
irs_context_t *context;
isc_appctx_t *actx = NULL;
isc_mem_t *mctx = NULL;
+ isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
isc_timermgr_t *timermgr = NULL;
@@ -160,14 +165,16 @@ irs_context_create(irs_context_t **contextp) {
return (result);
}
- result = ctxs_init(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
+ result = ctxs_init(&mctx, &actx, &netmgr, &taskmgr, &socketmgr,
+ &timermgr);
if (result != ISC_R_SUCCESS) {
return (result);
}
result = isc_app_ctxstart(actx);
if (result != ISC_R_SUCCESS) {
- ctxs_destroy(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
+ ctxs_destroy(&mctx, &actx, &netmgr, &taskmgr, &socketmgr,
+ &timermgr);
return (result);
}
@@ -187,8 +194,8 @@ irs_context_create(irs_context_t **contextp) {
}
/* Create a DNS client object */
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, 0,
- &client, NULL, NULL);
+ result = dns_client_create(mctx, actx, taskmgr, socketmgr, timermgr, 0,
+ &client, NULL, NULL);
if (result != ISC_R_SUCCESS) {
goto fail;
}
@@ -242,7 +249,7 @@ fail:
if (client != NULL) {
dns_client_destroy(&client);
}
- ctxs_destroy(NULL, &actx, &taskmgr, &socketmgr, &timermgr);
+ ctxs_destroy(NULL, &actx, &netmgr, &taskmgr, &socketmgr, &timermgr);
isc_mem_putanddetach(&mctx, context, sizeof(*context));
return (result);
@@ -262,7 +269,7 @@ irs_context_destroy(irs_context_t **contextp) {
irs_resconf_destroy(&context->resconf);
dns_client_destroy(&context->dnsclient);
- ctxs_destroy(NULL, &context->actx, &context->taskmgr,
+ ctxs_destroy(NULL, &context->actx, &context->netmgr, &context->taskmgr,
&context->socketmgr, &context->timermgr);
context->magic = 0;
diff --git a/external/mpl/bind/dist/lib/irs/getnameinfo.c b/external/mpl/bind/dist/lib/irs/getnameinfo.c
index 32615733fca..f520d7146d7 100644
--- a/external/mpl/bind/dist/lib/irs/getnameinfo.c
+++ b/external/mpl/bind/dist/lib/irs/getnameinfo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getnameinfo.c,v 1.6 2021/04/05 11:27:02 rillig Exp $ */
+/* $NetBSD: getnameinfo.c,v 1.7 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -321,9 +321,8 @@ found:
/* Get the PTR RRset */
ISC_LIST_INIT(answerlist);
- iresult = dns_client_resolve(
- client, ptrname, dns_rdataclass_in, dns_rdatatype_ptr,
- DNS_CLIENTRESOPT_ALLOWRUN, &answerlist);
+ iresult = dns_client_resolve(client, ptrname, dns_rdataclass_in,
+ dns_rdatatype_ptr, 0, &answerlist);
switch (iresult) {
case ISC_R_SUCCESS:
/*
diff --git a/external/mpl/bind/dist/lib/isc/app.c b/external/mpl/bind/dist/lib/isc/app.c
index f532265c03f..4a9a9907a04 100644
--- a/external/mpl/bind/dist/lib/isc/app.c
+++ b/external/mpl/bind/dist/lib/isc/app.c
@@ -1,4 +1,4 @@
-/* $NetBSD: app.c,v 1.5 2021/04/03 22:44:43 christos Exp $ */
+/* $NetBSD: app.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -52,7 +52,7 @@
*/
static isc_thread_t blockedthread;
-static atomic_bool is_running;
+static atomic_bool is_running = ATOMIC_VAR_INIT(0);
#ifdef WIN32
/*
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/app.h b/external/mpl/bind/dist/lib/isc/include/isc/app.h
index d86aa4d99a2..35fbee80bc3 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/app.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/app.h
@@ -1,4 +1,4 @@
-/* $NetBSD: app.h,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: app.h,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -95,17 +95,6 @@ typedef isc_event_t isc_appevent_t;
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
-/*%
- * This structure is actually just the common prefix of an application context
- * implementation's version of an isc_appctx_t.
- * \brief
- * Direct use of this structure by clients is forbidden. app implementations
- * may change the structure. 'magic' must be ISCAPI_APPCTX_MAGIC for any
- * of the isc_app_ routines to work. app implementations must maintain
- * all app context invariants.
- */
-struct isc_appctx;
-
ISC_LANG_BEGINDECLS
isc_result_t
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/barrier.h b/external/mpl/bind/dist/lib/isc/include/isc/barrier.h
index fbc78e41ced..0be3503b82a 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/barrier.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/barrier.h
@@ -1,4 +1,4 @@
-/* $NetBSD: barrier.h,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: barrier.h,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/managers.h b/external/mpl/bind/dist/lib/isc/include/isc/managers.h
index 65d4716a9f5..58988782f99 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/managers.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/managers.h
@@ -1,4 +1,4 @@
-/* $NetBSD: managers.h,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: managers.h,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/mem.h b/external/mpl/bind/dist/lib/isc/include/isc/mem.h
index ee8de552c5c..60542c55473 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/mem.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/mem.h
@@ -1,4 +1,4 @@
-/* $NetBSD: mem.h,v 1.7 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: mem.h,v 1.8 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -175,6 +175,8 @@ typedef struct isc_memmethods {
void *(*memreallocate)(isc_mem_t *mctx, void *ptr,
size_t size _ISC_MEM_FLARG);
char *(*memstrdup)(isc_mem_t *mctx, const char *s _ISC_MEM_FLARG);
+ char *(*memstrndup)(isc_mem_t *mctx, const char *s,
+ size_t size _ISC_MEM_FLARG);
void (*memfree)(isc_mem_t *mctx, void *ptr _ISC_MEM_FLARG);
} isc_memmethods_t;
@@ -229,7 +231,9 @@ struct isc_mempool {
#define isc_mem_reallocate(c, p, s) \
ISCMEMFUNC(reallocate)((c), (p), (s)_ISC_MEM_FILELINE)
#define isc_mem_strdup(c, p) ISCMEMFUNC(strdup)((c), (p)_ISC_MEM_FILELINE)
-#define isc_mempool_get(c) ISCMEMPOOLFUNC(get)((c)_ISC_MEM_FILELINE)
+#define isc_mem_strndup(c, p, s) \
+ ISCMEMFUNC(strndup)((c), (p), (s)_ISC_MEM_FILELINE)
+#define isc_mempool_get(c) ISCMEMPOOLFUNC(get)((c)_ISC_MEM_FILELINE)
#define isc_mem_put(c, p, s) \
do { \
@@ -589,18 +593,51 @@ isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit);
*\li limit > 0
*/
+#if defined(UNIT_TESTING) && defined(malloc)
+/*
+ * cmocka.h redefined malloc as a macro, we #undef it
+ * to avoid replacing ISC_ATTR_MALLOC with garbage.
+ */
+#pragma push_macro("malloc")
+#undef malloc
+#define POP_MALLOC_MACRO 1
+#endif
+
/*
* Pseudo-private functions for use via macros. Do not call directly.
*/
+void ISCMEMFUNC(putanddetach)(isc_mem_t **, void *, size_t _ISC_MEM_FLARG);
+void ISCMEMFUNC(put)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
+void ISCMEMFUNC(free)(isc_mem_t *, void *_ISC_MEM_FLARG);
+
+ISC_ATTR_RETURNS_NONNULL
+ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMFUNC(put), 2)
void *ISCMEMFUNC(get)(isc_mem_t *, size_t _ISC_MEM_FLARG);
-void ISCMEMFUNC(putanddetach)(isc_mem_t **, void *, size_t _ISC_MEM_FLARG);
-void ISCMEMFUNC(put)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
+
+ISC_ATTR_RETURNS_NONNULL
+ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMFUNC(free), 2)
void *ISCMEMFUNC(allocate)(isc_mem_t *, size_t _ISC_MEM_FLARG);
+
+ISC_ATTR_RETURNS_NONNULL
+ISC_ATTR_DEALLOCATOR_IDX(ISCMEMFUNC(free), 2)
void *ISCMEMFUNC(reallocate)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
-void ISCMEMFUNC(free)(isc_mem_t *, void *_ISC_MEM_FLARG);
+
+ISC_ATTR_RETURNS_NONNULL
+ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMFUNC(free), 2)
char *ISCMEMFUNC(strdup)(isc_mem_t *, const char *_ISC_MEM_FLARG);
+char *ISCMEMFUNC(strndup)(isc_mem_t *, const char *, size_t _ISC_MEM_FLARG);
+
+ISC_ATTR_MALLOC_DEALLOCATOR_IDX(ISCMEMPOOLFUNC(put), 2)
void *ISCMEMPOOLFUNC(get)(isc_mempool_t *_ISC_MEM_FLARG);
-void ISCMEMPOOLFUNC(put)(isc_mempool_t *, void *_ISC_MEM_FLARG);
+
+void ISCMEMPOOLFUNC(put)(isc_mempool_t *, void *_ISC_MEM_FLARG);
+
+#ifdef POP_MALLOC_MACRO
+/*
+ * Restore cmocka.h macro for malloc.
+ */
+#pragma pop_macro("malloc")
+#endif
ISC_LANG_ENDDECLS
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/netmgr.h b/external/mpl/bind/dist/lib/isc/include/isc/netmgr.h
index 3dea84d484e..10d811b51cc 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/netmgr.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/netmgr.h
@@ -1,4 +1,4 @@
-/* $NetBSD: netmgr.h,v 1.5 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: netmgr.h,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,7 +16,6 @@
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/result.h>
-#include <isc/tls.h>
#include <isc/types.h>
/*
@@ -70,19 +69,16 @@ typedef void (*isc_nm_opaquecb_t)(void *arg);
* callbacks.
*/
-isc_nm_t *
-isc_nm_start(isc_mem_t *mctx, uint32_t workers);
+typedef void (*isc_nm_workcb_t)(void *arg);
+typedef void (*isc_nm_after_workcb_t)(void *arg, isc_result_t result);
/*%<
- * Creates a new network manager with 'workers' worker threads,
- * and starts it running.
+ * Callback functions for libuv threadpool work (see uv_work_t)
*/
void
isc_nm_attach(isc_nm_t *mgr, isc_nm_t **dst);
void
isc_nm_detach(isc_nm_t **mgr0);
-void
-isc_nm_destroy(isc_nm_t **mgr0);
/*%<
* Attach/detach a network manager. When all references have been
* released, the network manager is shut down, freeing all resources.
@@ -90,15 +86,6 @@ isc_nm_destroy(isc_nm_t **mgr0);
* for all other references to be gone.
*/
-void
-isc_nm_closedown(isc_nm_t *mgr);
-/*%<
- * Close down all active connections, freeing associated resources;
- * prevent new connections from being established. This can optionally
- * be called prior to shutting down the netmgr, to stop all processing
- * before shutting down the task manager.
- */
-
/* Return thread ID of current thread, or ISC_NETMGR_TID_UNKNOWN */
int
isc_nm_tid(void);
@@ -196,7 +183,7 @@ isc_nmhandle_netmgr(isc_nmhandle_t *handle);
*/
isc_result_t
-isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
+isc_nm_listenudp(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nm_recv_cb_t cb,
void *cbarg, size_t extrasize, isc_nmsocket_t **sockp);
/*%<
* Start listening for UDP packets on interface 'iface' using net manager
@@ -212,8 +199,8 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
* can then be freed automatically when the handle is destroyed.
*/
-isc_result_t
-isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_udpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize);
/*%<
@@ -301,7 +288,7 @@ isc_nm_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
*/
isc_result_t
-isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
+isc_nm_listentcp(isc_nm_t *mgr, isc_sockaddr_t *iface,
isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
size_t extrahandlesize, int backlog, isc_quota_t *quota,
isc_nmsocket_t **sockp);
@@ -323,8 +310,8 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
*
*/
-isc_result_t
-isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_tcpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize);
/*%<
@@ -342,7 +329,7 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
*/
isc_result_t
-isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
+isc_nm_listentcpdns(isc_nm_t *mgr, isc_sockaddr_t *iface,
isc_nm_recv_cb_t recv_cb, void *recv_cbarg,
isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
size_t extrahandlesize, int backlog, isc_quota_t *quota,
@@ -370,16 +357,6 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
* 'quota' is passed to isc_nm_listentcp() when opening the raw TCP socket.
*/
-isc_result_t
-isc_nm_listentlsdns(isc_nm_t *mgr, isc_nmiface_t *iface,
- isc_nm_recv_cb_t recv_cb, void *recv_cbarg,
- isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
- size_t extrahandlesize, int backlog, isc_quota_t *quota,
- isc_tlsctx_t *sslctx, isc_nmsocket_t **sockp);
-/*%<
- * Same as isc_nm_listentcpdns but for an SSL (DoT) socket.
- */
-
void
isc_nm_tcpdns_sequential(isc_nmhandle_t *handle);
/*%<
@@ -408,33 +385,6 @@ isc_nm_tcpdns_keepalive(isc_nmhandle_t *handle, bool value);
*/
void
-isc_nm_tlsdns_sequential(isc_nmhandle_t *handle);
-/*%<
- * Disable pipelining on this connection. Each DNS packet will be only
- * processed after the previous completes.
- *
- * The socket must be unpaused after the query is processed. This is done
- * the response is sent, or if we're dropping the query, it will be done
- * when a handle is fully dereferenced by calling the socket's
- * closehandle_cb callback.
- *
- * Note: This can only be run while a message is being processed; if it is
- * run before any messages are read, no messages will be read.
- *
- * Also note: once this has been set, it cannot be reversed for a given
- * connection.
- */
-
-void
-isc_nm_tlsdns_keepalive(isc_nmhandle_t *handle, bool value);
-/*%<
- * Enable/disable keepalive on this connection by setting it to 'value'.
- *
- * When keepalive is active, we switch to using the keepalive timeout
- * to determine when to close a connection, rather than the idle timeout.
- */
-
-void
isc_nm_settimeouts(isc_nm_t *mgr, uint32_t init, uint32_t idle,
uint32_t keepalive, uint32_t advertised);
/*%<
@@ -480,16 +430,12 @@ isc_nm_setstats(isc_nm_t *mgr, isc_stats_t *stats);
* full range of socket-related stats counter numbers.
*/
-isc_result_t
-isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize);
-isc_result_t
-isc_nm_tlsdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
- isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
- size_t extrahandlesize, isc_tlsctx_t *sslctx);
/*%<
- * Establish a DNS client connection via a TCP or TLS connection, bound to
+ * Establish a DNS client connection via a TCP connection, bound to
* the address 'local' and connected to the address 'peer'.
*
* When the connection is complete or has timed out, call 'cb' with
@@ -501,3 +447,36 @@ isc_nm_tlsdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
* The connected socket can only be accessed via the handle passed to
* 'cb'.
*/
+
+void
+isc_nm_task_enqueue(isc_nm_t *mgr, isc_task_t *task, int threadid);
+/*%<
+ * Enqueue the 'task' onto the netmgr ievents queue.
+ *
+ * Requires:
+ * \li 'mgr' is a valid netmgr object
+ * \li 'task' is a valid task
+ * \li 'threadid' is either the preferred netmgr tid or -1, in which case
+ * tid will be picked randomly. The threadid is capped (by modulo) to
+ * maximum number of 'workers' as specifed in isc_nm_start()
+ */
+
+void
+isc_nm_work_offload(isc_nm_t *mgr, isc_nm_workcb_t work_cb,
+ isc_nm_after_workcb_t after_work_cb, void *data);
+/*%<
+ * Schedules a job to be handled by the libuv thread pool (see uv_work_t).
+ * The function specified in `work_cb` will be run by a thread in the
+ * thread pool; when complete, the `after_work_cb` function will run.
+ *
+ * Requires:
+ * \li 'mgr' is a valid netmgr object.
+ * \li We are currently running in a network manager thread.
+ */
+
+void
+isc__nm_force_tid(int tid);
+/*%<
+ * Force the thread ID to 'tid'. This is STRICTLY for use in unit
+ * tests and should not be used in any production code.
+ */
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/result.h b/external/mpl/bind/dist/lib/isc/include/isc/result.h
index ff824d9c7a4..f53189bf808 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/result.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/result.h
@@ -1,4 +1,4 @@
-/* $NetBSD: result.h,v 1.8 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: result.h,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -66,7 +66,7 @@
#define ISC_R_MULTICAST 43 /*%< invalid use of multicast */
#define ISC_R_NOTFILE 44 /*%< not a file */
#define ISC_R_NOTDIRECTORY 45 /*%< not a directory */
-#define ISC_R_QUEUEFULL 46 /*%< queue is full */
+#define ISC_R_EMPTY 46 /*%< queue is empty */
#define ISC_R_FAMILYMISMATCH 47 /*%< address family mismatch */
#define ISC_R_FAMILYNOSUPPORT 48 /*%< AF not supported */
#define ISC_R_BADHEX 49 /*%< bad hex encoding */
@@ -91,9 +91,10 @@
#define ISC_R_DEFAULT 68 /*%< default */
#define ISC_R_IPV4PREFIX 69 /*%< IPv4 prefix */
#define ISC_R_TLSERROR 70 /*%< TLS error */
+#define ISC_R_HTTP2ALPNERROR 71 /*%< ALPN for HTTP/2 failed */
/*% Not a result code: the number of results. */
-#define ISC_R_NRESULTS 71
+#define ISC_R_NRESULTS 72
ISC_LANG_BEGINDECLS
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/socket.h b/external/mpl/bind/dist/lib/isc/include/isc/socket.h
index b1d62a505e1..a7784602c67 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/socket.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/socket.h
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.h,v 1.7 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: socket.h,v 1.8 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -194,45 +194,6 @@ typedef enum {
#define ISC_SOCKFLAG_NORETRY 0x00000002 /*%< drop failed UDP sends */
/*@}*/
-/*%
- * This structure is actually just the common prefix of a socket manager
- * object implementation's version of an isc_socketmgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. socket implementations
- * may change the structure. 'magic' must be ISCAPI_SOCKETMGR_MAGIC for any
- * of the isc_socket_ routines to work. socket implementations must maintain
- * all socket invariants.
- * In effect, this definition is used only for non-BIND9 version ("export")
- * of the library, and the export version does not work for win32. So, to avoid
- * the definition conflict with win32/socket.c, we enable this definition only
- * for non-Win32 (i.e. Unix) platforms.
- */
-#ifndef WIN32
-struct isc_socketmgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-#endif /* ifndef WIN32 */
-
-#define ISCAPI_SOCKETMGR_MAGIC ISC_MAGIC('A', 's', 'm', 'g')
-#define ISCAPI_SOCKETMGR_VALID(m) \
- ((m) != NULL && (m)->magic == ISCAPI_SOCKETMGR_MAGIC)
-
-/*%
- * This is the common prefix of a socket object. The same note as
- * that for the socketmgr structure applies.
- */
-#ifndef WIN32
-struct isc_socket {
- unsigned int impmagic;
- unsigned int magic;
-};
-#endif /* ifndef WIN32 */
-
-#define ISCAPI_SOCKET_MAGIC ISC_MAGIC('A', 's', 'c', 't')
-#define ISCAPI_SOCKET_VALID(s) \
- ((s) != NULL && (s)->magic == ISCAPI_SOCKET_MAGIC)
-
/***
*** Socket and Socket Manager Functions
***
@@ -719,9 +680,6 @@ isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
/*@}*/
isc_result_t
-isc_socketmgr_createinctx(isc_mem_t *mctx, isc_socketmgr_t **managerp);
-
-isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
isc_result_t
@@ -732,8 +690,6 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
* maximum number of sockets that the created manager should handle.
* isc_socketmgr_create() is equivalent of isc_socketmgr_create2() with
* "maxsocks" being zero.
- * isc_socketmgr_createinctx() also associates the new manager with the
- * specified application context.
*
* Notes:
*
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/task.h b/external/mpl/bind/dist/lib/isc/include/isc/task.h
index 7376fbee238..3336d1727e8 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/task.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/task.h
@@ -1,4 +1,4 @@
-/* $NetBSD: task.h,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: task.h,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -11,12 +11,11 @@
* information regarding copyright ownership.
*/
-#ifndef ISC_TASK_H
-#define ISC_TASK_H 1
+#pragma once
/*****
-***** Module Info
-*****/
+ ***** Module Info
+ *****/
/*! \file isc/task.h
* \brief The task system provides a lightweight execution context, which is
@@ -87,8 +86,8 @@
#define ISC_TASKEVENT_LASTEVENT (ISC_EVENTCLASS_TASK + 65535)
/*****
-***** Tasks.
-*****/
+ ***** Tasks.
+ *****/
ISC_LANG_BEGINDECLS
@@ -101,45 +100,14 @@ typedef enum {
isc_taskmgrmode_privileged
} isc_taskmgrmode_t;
-/*%
- * This structure is actually just the common prefix of a task manager
- * object implementation's version of an isc_taskmgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. task implementations
- * may change the structure. 'magic' must be ISCAPI_TASKMGR_MAGIC for any
- * of the isc_task_ routines to work. task implementations must maintain
- * all task invariants.
- */
-struct isc_taskmgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A', 't', 'm', 'g')
-#define ISCAPI_TASKMGR_VALID(m) \
- ((m) != NULL && (m)->magic == ISCAPI_TASKMGR_MAGIC)
-
-/*%
- * This is the common prefix of a task object. The same note as
- * that for the taskmgr structure applies.
- */
-struct isc_task {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TASK_MAGIC ISC_MAGIC('A', 't', 's', 't')
-#define ISCAPI_TASK_VALID(s) ((s) != NULL && (s)->magic == ISCAPI_TASK_MAGIC)
-
isc_result_t
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp);
-
isc_result_t
isc_task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp, int threadid);
/*%<
- * Create a task.
+ * Create a task, optionally bound to a particular threadid.
*
* Notes:
*
@@ -171,6 +139,29 @@ isc_task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
*/
void
+isc_task_ready(isc_task_t *task);
+/*%<
+ * Enqueue the task onto netmgr queue.
+ */
+
+isc_result_t
+isc_task_run(isc_task_t *task);
+/*%<
+ * Run all the queued events for the 'task', returning
+ * when the queue is empty or the number of events executed
+ * exceeds the 'quantum' specified when the task was created.
+ *
+ * Requires:
+ *
+ *\li 'task' is a valid task.
+ *
+ * Returns:
+ *
+ *\li #ISC_R_SUCCESS
+ *\li #ISC_R_QUOTA
+ */
+
+void
isc_task_attach(isc_task_t *source, isc_task_t **targetp);
/*%<
* Attach *targetp to source.
@@ -522,6 +513,9 @@ isc_task_getname(isc_task_t *task);
*
*/
+isc_nm_t *
+isc_task_getnetmgr(isc_task_t *task);
+
void *
isc_task_gettag(isc_task_t *task);
/*%<
@@ -622,15 +616,15 @@ isc_task_setprivilege(isc_task_t *task, bool priv);
* but when the task manager has been set to privileged execution mode via
* isc_taskmgr_setmode(), only tasks with the flag set will be executed,
* and all other tasks will wait until they're done. Once all privileged
- * tasks have finished executing, the task manager will automatically
- * return to normal execution mode and nonprivileged task can resume.
+ * tasks have finished executing, the task manager resumes running
+ * non-privileged tasks.
*
* Requires:
*\li 'task' is a valid task.
*/
bool
-isc_task_privilege(isc_task_t *task);
+isc_task_getprivilege(isc_task_t *task);
/*%<
* Returns the current value of the task's privilege flag.
*
@@ -638,118 +632,47 @@ isc_task_privilege(isc_task_t *task);
*\li 'task' is a valid task.
*/
-/*****
-***** Task Manager.
-*****/
-
-isc_result_t
-isc_taskmgr_createinctx(isc_mem_t *mctx, unsigned int workers,
- unsigned int default_quantum, isc_taskmgr_t **managerp);
-isc_result_t
-isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
- unsigned int default_quantum, isc_nm_t *nm,
- isc_taskmgr_t **managerp);
+bool
+isc_task_privileged(isc_task_t *task);
/*%<
- * Create a new task manager. isc_taskmgr_createinctx() also associates
- * the new manager with the specified application context.
- *
- * Notes:
- *
- *\li 'workers' in the number of worker threads to create. In general,
- * the value should be close to the number of processors in the system.
- * The 'workers' value is advisory only. An attempt will be made to
- * create 'workers' threads, but if at least one thread creation
- * succeeds, isc_taskmgr_create() may return ISC_R_SUCCESS.
- *
- *\li If 'default_quantum' is non-zero, then it will be used as the default
- * quantum value when tasks are created. If zero, then an implementation
- * defined default quantum will be used.
- *
- *\li If 'nm' is set then netmgr is paused when an exclusive task mode
- * is requested.
+ * Returns true if the task's privilege flag is set *and* the task
+ * manager is currently in privileged mode.
*
* Requires:
- *
- *\li 'mctx' is a valid memory context.
- *
- *\li workers > 0
- *
- *\li managerp != NULL && *managerp == NULL
- *
- *\li 'actx' is a valid application context (for createinctx()).
- *
- * Ensures:
- *
- *\li On success, '*managerp' will be attached to the newly created task
- * manager.
- *
- * Returns:
- *
- *\li #ISC_R_SUCCESS
- *\li #ISC_R_NOMEMORY
- *\li #ISC_R_NOTHREADS No threads could be created.
- *\li #ISC_R_UNEXPECTED An unexpected error occurred.
- *\li #ISC_R_SHUTTINGDOWN The non-threaded, shared, task
- * manager shutting down.
+ *\li 'task' is a valid task.
*/
-void
-isc_taskmgr_setprivilegedmode(isc_taskmgr_t *manager);
+/*****
+ ***** Task Manager.
+ *****/
-isc_taskmgrmode_t
-isc_taskmgr_mode(isc_taskmgr_t *manager);
+void
+isc_taskmgr_attach(isc_taskmgr_t *, isc_taskmgr_t **);
+void
+isc_taskmgr_detach(isc_taskmgr_t **);
/*%<
- * Set/get the current operating mode of the task manager. Valid modes are:
- *
- *\li isc_taskmgrmode_normal
- *\li isc_taskmgrmode_privileged
- *
- * In privileged execution mode, only tasks that have had the "privilege"
- * flag set via isc_task_setprivilege() can be executed. When all such
- * tasks are complete, the manager automatically returns to normal mode
- * and proceeds with running non-privileged ready tasks. This means it is
- * necessary to have at least one privileged task waiting on the ready
- * queue *before* setting the manager into privileged execution mode,
- * which in turn means the task which calls this function should be in
- * task-exclusive mode when it does so.
- *
- * Requires:
- *
- *\li 'manager' is a valid task manager.
+ * Attach/detach the task manager.
*/
void
-isc_taskmgr_destroy(isc_taskmgr_t **managerp);
+isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode);
+isc_taskmgrmode_t
+isc_taskmgr_mode(isc_taskmgr_t *manager);
/*%<
- * Destroy '*managerp'.
- *
- * Notes:
+ * Set/get the operating mode of the task manager. Valid modes are:
*
- *\li Calling isc_taskmgr_destroy() will shutdown all tasks managed by
- * *managerp that haven't already been shutdown. The call will block
- * until all tasks have entered the done state.
+ *\li isc_taskmgrmode_normal
+ *\li isc_taskmgrmode_privileged
*
- *\li isc_taskmgr_destroy() must not be called by a task event action,
- * because it would block forever waiting for the event action to
- * complete. An event action that wants to cause task manager shutdown
- * should request some non-event action thread of execution to do the
- * shutdown, e.g. by signaling a condition variable or using
- * isc_app_shutdown().
- *
- *\li Task manager references are not reference counted, so the caller
- * must ensure that no attempt will be made to use the manager after
- * isc_taskmgr_destroy() returns.
+ * In privileged execution mode, only tasks that have had the "privilege"
+ * flag set via isc_task_setprivilege() can be executed. When all such
+ * tasks are complete, non-privileged tasks resume running. The task calling
+ * this function should be in task-exclusive mode; the privileged tasks
+ * will be run after isc_task_endexclusive() is called.
*
* Requires:
*
- *\li '*managerp' is a valid task manager.
- *
- *\li isc_taskmgr_destroy() has not be called previously on '*managerp'.
- *
- * Ensures:
- *
- *\li All resources used by the task manager, and any tasks it managed,
- * have been freed.
+ *\li 'manager' is a valid task manager.
*/
void
@@ -787,5 +710,3 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr, void *tasksobj0);
#endif /* HAVE_JSON_C */
ISC_LANG_ENDDECLS
-
-#endif /* ISC_TASK_H */
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/taskpool.h b/external/mpl/bind/dist/lib/isc/include/isc/taskpool.h
index 7fcaf7fa385..ff39b13e220 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/taskpool.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/taskpool.h
@@ -1,4 +1,4 @@
-/* $NetBSD: taskpool.h,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: taskpool.h,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -53,7 +53,7 @@ typedef struct isc_taskpool isc_taskpool_t;
isc_result_t
isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks,
- unsigned int quantum, isc_taskpool_t **poolp);
+ unsigned int quantum, bool priv, isc_taskpool_t **poolp);
/*%<
* Create a task pool of "ntasks" tasks, each with quantum
* "quantum".
@@ -92,7 +92,7 @@ isc_taskpool_size(isc_taskpool_t *pool);
*/
isc_result_t
-isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size,
+isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size, bool priv,
isc_taskpool_t **targetp);
/*%<
@@ -133,19 +133,6 @@ isc_taskpool_destroy(isc_taskpool_t **poolp);
* \li '*poolp' is a valid task pool.
*/
-void
-isc_taskpool_setprivilege(isc_taskpool_t *pool, bool priv);
-/*%<
- * Set the privilege flag on all tasks in 'pool' to 'priv'. If 'priv' is
- * true, then when the task manager is set into privileged mode, only
- * tasks wihin this pool will be able to execute. (Note: It is important
- * to turn the pool tasks' privilege back off before the last task finishes
- * executing.)
- *
- * Requires:
- * \li 'pool' is a valid task pool.
- */
-
ISC_LANG_ENDDECLS
#endif /* ISC_TASKPOOL_H */
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/timer.h b/external/mpl/bind/dist/lib/isc/include/isc/timer.h
index ddce5f0cb7c..f633777cba6 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/timer.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/timer.h
@@ -1,4 +1,4 @@
-/* $NetBSD: timer.h,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: timer.h,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -99,36 +99,6 @@ typedef struct isc_timerevent {
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
-/*%
- * This structure is actually just the common prefix of a timer manager
- * object implementation's version of an isc_timermgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. timer implementations
- * may change the structure. 'magic' must be ISCAPI_TIMERMGR_MAGIC for any
- * of the isc_timer_ routines to work. timer implementations must maintain
- * all timer invariants.
- */
-struct isc_timermgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A', 't', 'm', 'g')
-#define ISCAPI_TIMERMGR_VALID(m) \
- ((m) != NULL && (m)->magic == ISCAPI_TIMERMGR_MAGIC)
-
-/*%
- * This is the common prefix of a timer object. The same note as
- * that for the timermgr structure applies.
- */
-struct isc_timer {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A', 't', 'm', 'r')
-#define ISCAPI_TIMER_VALID(s) ((s) != NULL && (s)->magic == ISCAPI_TIMER_MAGIC)
-
/***
*** Timer and Timer Manager Functions
***
@@ -309,13 +279,9 @@ isc_timer_gettype(isc_timer_t *timer);
*/
isc_result_t
-isc_timermgr_createinctx(isc_mem_t *mctx, isc_timermgr_t **managerp);
-
-isc_result_t
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
/*%<
- * Create a timer manager. isc_timermgr_createinctx() also associates
- * the new manager with the specified application context.
+ * Create a timer manager.
*
* Notes:
*
@@ -327,8 +293,6 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
*
*\li 'managerp' points to a NULL isc_timermgr_t.
*
- *\li 'actx' is a valid application context (for createinctx()).
- *
* Ensures:
*
*\li '*managerp' is a valid isc_timermgr_t.
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/tls.h b/external/mpl/bind/dist/lib/isc/include/isc/tls.h
deleted file mode 100644
index 2a4359d0abf..00000000000
--- a/external/mpl/bind/dist/lib/isc/include/isc/tls.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: tls.h,v 1.1.1.1 2021/04/29 16:46:32 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#pragma once
-
-#include <isc/mem.h>
-#include <isc/region.h>
-#include <isc/result.h>
-#include <isc/tls.h>
-#include <isc/types.h>
-
-typedef struct ssl_ctx_st isc_tlsctx_t;
-
-void
-isc_tlsctx_free(isc_tlsctx_t **ctpx);
-/*%
- * Free the TLS client/server context.
- *
- * Require:
- *\li 'ctxp' != NULL and '*ctxp' != NULL.
- */
-
-isc_result_t
-isc_tlsctx_createserver(const char *keyfile, const char *certfile,
- isc_tlsctx_t **ctxp);
-/*%
- * Set up TLS server context.
- *
- * Require:
- *\li 'ctxp' != NULL and '*ctxp' == NULL.
- */
-
-isc_result_t
-isc_tlsctx_createclient(isc_tlsctx_t **ctxp);
-/*%
- * Set up TLS client context.
- *
- * Require:
- *\li 'ctxp' != NULL and '*ctxp' == NULL.
- */
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/types.h b/external/mpl/bind/dist/lib/isc/include/isc/types.h
index 95ab7198299..728d7d52553 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/types.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/types.h
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.8 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: types.h,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -70,22 +70,21 @@ typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */
typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */
typedef struct isc_nm isc_nm_t; /*%< Network manager */
typedef struct isc_nmsocket isc_nmsocket_t; /*%< Network manager socket */
-typedef struct isc_nmiface isc_nmiface_t; /*%< Network manager interface. */
-typedef struct isc_nmhandle isc_nmhandle_t; /*%< Network manager handle */
-typedef struct isc_portset isc_portset_t; /*%< Port Set */
-typedef struct isc_quota isc_quota_t; /*%< Quota */
-typedef struct isc_ratelimiter isc_ratelimiter_t; /*%< Rate Limiter */
-typedef struct isc_region isc_region_t; /*%< Region */
-typedef uint64_t isc_resourcevalue_t; /*%< Resource Value */
-typedef unsigned int isc_result_t; /*%< Result */
-typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */
-typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */
-typedef ISC_LIST(isc_sockaddr_t) isc_sockaddrlist_t; /*%< Socket Address List
- * */
-typedef struct isc_socket isc_socket_t; /*%< Socket */
-typedef struct isc_socketevent isc_socketevent_t; /*%< Socket Event */
-typedef struct isc_socketmgr isc_socketmgr_t; /*%< Socket Manager */
-typedef struct isc_stats isc_stats_t; /*%< Statistics */
+typedef struct isc_nmhandle isc_nmhandle_t; /*%< Network manager handle */
+typedef struct isc_portset isc_portset_t; /*%< Port Set */
+typedef struct isc_quota isc_quota_t; /*%< Quota */
+typedef struct isc_ratelimiter isc_ratelimiter_t; /*%< Rate Limiter */
+typedef struct isc_region isc_region_t; /*%< Region */
+typedef uint64_t isc_resourcevalue_t; /*%< Resource Value */
+typedef unsigned int isc_result_t; /*%< Result */
+typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */
+typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */
+typedef ISC_LIST(isc_sockaddr_t) isc_sockaddrlist_t; /*%< Socket Address List
+ * */
+typedef struct isc_socket isc_socket_t; /*%< Socket */
+typedef struct isc_socketevent isc_socketevent_t; /*%< Socket Event */
+typedef struct isc_socketmgr isc_socketmgr_t; /*%< Socket Manager */
+typedef struct isc_stats isc_stats_t; /*%< Statistics */
#if defined(_WIN32) && !defined(_WIN64) || !defined(_LP64)
typedef int_fast32_t isc_statscounter_t; /*%< Statistics Counter */
#else /* if defined(_WIN32) && !defined(_WIN64) */
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/url.h b/external/mpl/bind/dist/lib/isc/include/isc/url.h
index 06bed6bcc6c..ffe056cff99 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/url.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/url.h
@@ -1,4 +1,4 @@
-/* $NetBSD: url.h,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: url.h,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/include/isc/util.h b/external/mpl/bind/dist/lib/isc/include/isc/util.h
index 8f8a34bed99..b6a9cffaced 100644
--- a/external/mpl/bind/dist/lib/isc/include/isc/util.h
+++ b/external/mpl/bind/dist/lib/isc/include/isc/util.h
@@ -1,4 +1,4 @@
-/* $NetBSD: util.h,v 1.12 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: util.h,v 1.13 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -51,11 +51,11 @@
#endif /* __GNUC__ */
#if HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR && HAVE_FUNC_ATTRIBUTE_DESTRUCTOR
-#define ISC_CONSTRUCTOR(priority) __attribute__((constructor(priority)))
-#define ISC_DESTRUCTOR(priority) __attribute__((destructor(priority)))
+#define ISC_CONSTRUCTOR __attribute__((constructor))
+#define ISC_DESTRUCTOR __attribute__((destructor))
#elif WIN32
-#define ISC_CONSTRUCTOR(priority)
-#define ISC_DESTRUCTOR(priority)
+#define ISC_CONSTRUCTOR
+#define ISC_DESTRUCTOR
#endif
/*%
@@ -352,6 +352,69 @@ mock_assert(const int result, const char *const expression,
#define ISC_ALIGN(x, a) (((x) + (a)-1) & ~((uintmax_t)(a)-1))
#endif /* ifdef __GNUC__ */
+#if HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
+#define ISC_ATTR_RETURNS_NONNULL __attribute__((returns_nonnull))
+#else
+#define ISC_ATTR_RETURNS_NONNULL
+#endif
+
+/*
+ * Support for malloc attributes.
+ */
+#ifdef HAVE_FUNC_ATTRIBUTE_MALLOC
+/*
+ * Indicates that a function is malloc-like, i.e., that the
+ * pointer P returned by the function cannot alias any other
+ * pointer valid when the function returns.
+ */
+#define ISC_ATTR_MALLOC __attribute__((malloc))
+#if HAVE_MALLOC_EXT_ATTR
+/*
+ * Associates deallocator as a suitable deallocation function
+ * for pointers returned from the function marked with the attribute.
+ */
+#define ISC_ATTR_DEALLOCATOR(deallocator) __attribute__((malloc(deallocator)))
+/*
+ * Similar to ISC_ATTR_DEALLOCATOR, but allows to speficy an index "idx",
+ * which denotes the positional argument to which when the pointer is passed
+ * in calls to deallocator has the effect of deallocating it.
+ */
+#define ISC_ATTR_DEALLOCATOR_IDX(deallocator, idx) \
+ __attribute__((malloc(deallocator, idx)))
+/*
+ * Combines both ISC_ATTR_MALLOC and ISC_ATTR_DEALLOCATOR attributes.
+ */
+#define ISC_ATTR_MALLOC_DEALLOCATOR(deallocator) \
+ __attribute__((malloc, malloc(deallocator)))
+/*
+ * Similar to ISC_ATTR_MALLOC_DEALLOCATOR, but allows to speficy an index "idx",
+ * which denotes the positional argument to which when the pointer is passed
+ * in calls to deallocator has the effect of deallocating it.
+ */
+#define ISC_ATTR_MALLOC_DEALLOCATOR_IDX(deallocator, idx) \
+ __attribute__((malloc, malloc(deallocator, idx)))
+#else /* #ifdef HAVE_MALLOC_EXT_ATTR */
+/*
+ * There is support for malloc attribute but not for
+ * extended attributes, so macros that combine attribute malloc
+ * with a deallocator will only expand to malloc attribute.
+ */
+#define ISC_ATTR_DEALLOCATOR(deallocator)
+#define ISC_ATTR_DEALLOCATOR_IDX(deallocator, idx)
+#define ISC_ATTR_MALLOC_DEALLOCATOR(deallocator) ISC_ATTR_MALLOC
+#define ISC_ATTR_MALLOC_DEALLOCATOR_IDX(deallocator, idx) ISC_ATTR_MALLOC
+#endif
+#else /* #ifdef HAVE_FUNC_ATTRIBUTE_MALLOC */
+/*
+ * There is no support for malloc attribute.
+ */
+#define ISC_ATTR_MALLOC
+#define ISC_ATTR_DEALLOCATOR(deallocator)
+#define ISC_ATTR_DEALLOCATOR_IDX(deallocator, idx)
+#define ISC_ATTR_MALLOC_DEALLOCATOR(deallocator)
+#define ISC_ATTR_MALLOC_DEALLOCATOR_IDX(deallocator, idx)
+#endif /* HAVE_FUNC_ATTRIBUTE_MALLOC */
+
/*%
* Misc
*/
diff --git a/external/mpl/bind/dist/lib/isc/lib.c b/external/mpl/bind/dist/lib/isc/lib.c
index 4945d03a777..6032fbd1dbe 100644
--- a/external/mpl/bind/dist/lib/isc/lib.c
+++ b/external/mpl/bind/dist/lib/isc/lib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.c,v 1.7 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: lib.c,v 1.8 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,7 +16,6 @@
#include <isc/bind9.h>
#include <isc/lib.h>
#include <isc/mem.h>
-#include <isc/tls.h>
#include <isc/util.h>
#include "config.h"
@@ -38,9 +37,9 @@ isc_lib_register(void) {
}
void
-isc__initialize(void) ISC_CONSTRUCTOR(101);
+isc__initialize(void) ISC_CONSTRUCTOR;
void
-isc__shutdown(void) ISC_DESTRUCTOR(101);
+isc__shutdown(void) ISC_DESTRUCTOR;
void
isc__initialize(void) {
diff --git a/external/mpl/bind/dist/lib/isc/managers.c b/external/mpl/bind/dist/lib/isc/managers.c
index 54952fe1425..e8c63f5eb2f 100644
--- a/external/mpl/bind/dist/lib/isc/managers.c
+++ b/external/mpl/bind/dist/lib/isc/managers.c
@@ -1,4 +1,4 @@
-/* $NetBSD: managers.c,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: managers.c,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/mem.c b/external/mpl/bind/dist/lib/isc/mem.c
index 61703641cbb..2870b0efce3 100644
--- a/external/mpl/bind/dist/lib/isc/mem.c
+++ b/external/mpl/bind/dist/lib/isc/mem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mem.c,v 1.10 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: mem.c,v 1.11 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -248,13 +248,15 @@ static void *
isc___mem_reallocate(isc_mem_t *ctx, void *ptr, size_t size FLARG);
static char *
isc___mem_strdup(isc_mem_t *mctx, const char *s FLARG);
+static char *
+isc___mem_strndup(isc_mem_t *mctx0, const char *s, size_t size FLARG);
static void
isc___mem_free(isc_mem_t *ctx, void *ptr FLARG);
static isc_memmethods_t memmethods = {
isc___mem_get, isc___mem_put, isc___mem_putanddetach,
isc___mem_allocate, isc___mem_reallocate, isc___mem_strdup,
- isc___mem_free,
+ isc___mem_strndup, isc___mem_free,
};
#if ISC_MEM_TRACKLINES
@@ -1463,6 +1465,29 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
return (ns);
}
+char *
+isc___mem_strndup(isc_mem_t *mctx0, const char *s, size_t size FLARG) {
+ REQUIRE(VALID_CONTEXT(mctx0));
+ REQUIRE(s != NULL);
+
+ isc__mem_t *mctx = (isc__mem_t *)mctx0;
+ size_t len;
+ char *ns;
+
+ len = strlen(s) + 1;
+ if (len > size) {
+ len = size;
+ }
+
+ ns = isc__mem_allocate((isc_mem_t *)mctx, len FLARG_PASS);
+
+ if (ns != NULL) {
+ strlcpy(ns, s, len);
+ }
+
+ return (ns);
+}
+
void
isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
REQUIRE(VALID_CONTEXT(ctx0));
@@ -2554,6 +2579,13 @@ isc__mem_strdup(isc_mem_t *mctx, const char *s FLARG) {
return (mctx->methods->memstrdup(mctx, s FLARG_PASS));
}
+char *
+isc__mem_strndup(isc_mem_t *mctx, const char *s, size_t size FLARG) {
+ REQUIRE(ISCAPI_MCTX_VALID(mctx));
+
+ return (mctx->methods->memstrndup(mctx, s, size FLARG_PASS));
+}
+
void
isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h b/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h
index 739e547f04b..207733828b1 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h
+++ b/external/mpl/bind/dist/lib/isc/netmgr/netmgr-int.h
@@ -1,4 +1,4 @@
-/* $NetBSD: netmgr-int.h,v 1.6 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: netmgr-int.h,v 1.7 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -21,6 +21,7 @@
#include <isc/astack.h>
#include <isc/atomic.h>
+#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/magic.h>
@@ -32,6 +33,7 @@
#include <isc/refcount.h>
#include <isc/region.h>
#include <isc/result.h>
+#include <isc/rwlock.h>
#include <isc/sockaddr.h>
#include <isc/stats.h>
#include <isc/thread.h>
@@ -41,7 +43,8 @@
#define ISC_NETMGR_TID_UNKNOWN -1
-#define ISC_NETMGR_TLSBUF_SIZE 65536
+/* Must be different from ISC_NETMGR_TID_UNKNOWN */
+#define ISC_NETMGR_NON_INTERLOCKED -2
#if !defined(WIN32)
/*
@@ -66,7 +69,7 @@
/*%
* Larger buffer for when the regular one isn't enough; this will
* hold two full DNS packets with lengths. netmgr receives 64k at
- * most in TCPDNS or TLSDNS connections, so there's no risk of overrun
+ * most in TCPDNS connections, so there's no risk of overrun
* when using a buffer this size.
*/
#define NM_BIG_BUF (65535 + 2) * 2
@@ -160,6 +163,17 @@ isc__nm_dump_active(isc_nm_t *nm);
#endif
/*
+ * Queue types in the order of processing priority.
+ */
+typedef enum {
+ NETIEVENT_PRIORITY = 0,
+ NETIEVENT_PRIVILEGED = 1,
+ NETIEVENT_TASK = 2,
+ NETIEVENT_NORMAL = 3,
+ NETIEVENT_MAX = 4,
+} netievent_type_t;
+
+/*
* Single network event loop worker.
*/
typedef struct isc__networker {
@@ -169,15 +183,13 @@ typedef struct isc__networker {
uv_async_t async; /* async channel to send
* data to this networker */
isc_mutex_t lock;
- isc_condition_t cond;
bool paused;
bool finished;
isc_thread_t thread;
- isc_queue_t *ievents; /* incoming async events */
- isc_queue_t *ievents_prio; /* priority async events
- * used for listening etc.
- * can be processed while
- * worker is paused */
+ isc_queue_t *ievents[NETIEVENT_MAX];
+ atomic_uint_fast32_t nievents[NETIEVENT_MAX];
+ isc_condition_t cond_prio;
+
isc_refcount_t references;
atomic_int_fast64_t pktcount;
char *recvbuf;
@@ -224,49 +236,28 @@ struct isc_nmhandle {
char extra[];
};
-/*
- * An interface - an address we can listen on.
- */
-struct isc_nmiface {
- isc_sockaddr_t addr;
-};
-
typedef enum isc__netievent_type {
netievent_udpconnect,
+ netievent_udpclose,
netievent_udpsend,
netievent_udpread,
- netievent_udpstop,
netievent_udpcancel,
- netievent_udpclose,
netievent_tcpconnect,
+ netievent_tcpclose,
netievent_tcpsend,
netievent_tcpstartread,
netievent_tcppauseread,
netievent_tcpaccept,
- netievent_tcpstop,
netievent_tcpcancel,
- netievent_tcpclose,
netievent_tcpdnsaccept,
netievent_tcpdnsconnect,
+ netievent_tcpdnsclose,
netievent_tcpdnssend,
netievent_tcpdnsread,
netievent_tcpdnscancel,
- netievent_tcpdnsclose,
- netievent_tcpdnsstop,
- netievent_tlsdnsaccept,
- netievent_tlsdnsconnect,
- netievent_tlsdnssend,
- netievent_tlsdnsread,
- netievent_tlsdnscancel,
- netievent_tlsdnsclose,
- netievent_tlsdnsstop,
- netievent_tlsdnscycle,
- netievent_tlsdnsshutdown,
-
- netievent_close,
netievent_shutdown,
netievent_stop,
netievent_pause,
@@ -275,17 +266,26 @@ typedef enum isc__netievent_type {
netievent_readcb,
netievent_sendcb,
- netievent_prio = 0xff, /* event type values higher than this
- * will be treated as high-priority
- * events, which can be processed
- * while the netmgr is paused.
- */
+ netievent_task,
+ netievent_privilegedtask,
+
+ /*
+ * event type values higher than this will be treated
+ * as high-priority events, which can be processed
+ * while the netmgr is pausing or paused.
+ */
+ netievent_prio = 0xff,
+
netievent_udplisten,
+ netievent_udpstop,
netievent_tcplisten,
+ netievent_tcpstop,
netievent_tcpdnslisten,
- netievent_tlsdnslisten,
+ netievent_tcpdnsstop,
+
netievent_resume,
netievent_detach,
+ netievent_close,
} isc__netievent_type;
typedef union {
@@ -533,20 +533,42 @@ typedef struct isc__netievent__socket_quota {
isc__nm_put_netievent(nm, ievent); \
}
+typedef struct isc__netievent__task {
+ isc__netievent_type type;
+ isc_task_t *task;
+} isc__netievent__task_t;
+
+#define NETIEVENT_TASK_TYPE(type) \
+ typedef isc__netievent__task_t isc__netievent_##type##_t;
+
+#define NETIEVENT_TASK_DECL(type) \
+ isc__netievent_##type##_t *isc__nm_get_netievent_##type( \
+ isc_nm_t *nm, isc_task_t *task); \
+ void isc__nm_put_netievent_##type(isc_nm_t *nm, \
+ isc__netievent_##type##_t *ievent);
+
+#define NETIEVENT_TASK_DEF(type) \
+ isc__netievent_##type##_t *isc__nm_get_netievent_##type( \
+ isc_nm_t *nm, isc_task_t *task) { \
+ isc__netievent_##type##_t *ievent = \
+ isc__nm_get_netievent(nm, netievent_##type); \
+ ievent->task = task; \
+ \
+ return (ievent); \
+ } \
+ \
+ void isc__nm_put_netievent_##type(isc_nm_t *nm, \
+ isc__netievent_##type##_t *ievent) { \
+ ievent->task = NULL; \
+ isc__nm_put_netievent(nm, ievent); \
+ }
+
typedef struct isc__netievent_udpsend {
NETIEVENT__SOCKET;
isc_sockaddr_t peer;
isc__nm_uvreq_t *req;
} isc__netievent_udpsend_t;
-typedef struct isc__netievent_tlsconnect {
- isc__netievent_type type;
- isc_nmsocket_t *sock;
- SSL_CTX *ctx;
- isc_sockaddr_t local; /* local address */
- isc_sockaddr_t peer; /* peer address */
-} isc__netievent_tlsconnect_t;
-
typedef struct isc__netievent {
isc__netievent_type type;
} isc__netievent_t;
@@ -578,10 +600,20 @@ typedef union {
isc__netievent__socket_req_t nisr;
isc__netievent_udpsend_t nius;
isc__netievent__socket_quota_t nisq;
- isc__netievent_tlsconnect_t nitc;
} isc__netievent_storage_t;
/*
+ * Work item for a uv_work threadpool.
+ */
+typedef struct isc__nm_work {
+ isc_nm_t *netmgr;
+ uv_work_t req;
+ isc_nm_workcb_t cb;
+ isc_nm_after_workcb_t after_cb;
+ void *data;
+} isc__nm_work_t;
+
+/*
* Network manager
*/
#define NM_MAGIC ISC_MAGIC('N', 'E', 'T', 'M')
@@ -591,9 +623,10 @@ struct isc_nm {
int magic;
isc_refcount_t references;
isc_mem_t *mctx;
- uint32_t nworkers;
+ int nworkers;
isc_mutex_t lock;
isc_condition_t wkstatecond;
+ isc_condition_t wkpausecond;
isc__networker_t *workers;
isc_stats_t *stats;
@@ -605,9 +638,11 @@ struct isc_nm {
isc_mutex_t evlock;
uint_fast32_t workers_running;
- uint_fast32_t workers_paused;
+ atomic_uint_fast32_t workers_paused;
atomic_uint_fast32_t maxudp;
+ atomic_bool paused;
+
/*
* Active connections are being closed and new connections are
* no longer allowed.
@@ -620,7 +655,7 @@ struct isc_nm {
* or pause, or we'll deadlock. We have to either re-enqueue our
* event or wait for the other one to finish if we want to pause.
*/
- atomic_bool interlocked;
+ atomic_int interlocked;
/*
* Timeout values for TCP connections, corresponding to
@@ -634,6 +669,9 @@ struct isc_nm {
atomic_uint_fast32_t keepalive;
atomic_uint_fast32_t advertised;
+ isc_barrier_t pausing;
+ isc_barrier_t resuming;
+
#ifdef NETMGR_TRACE
ISC_LIST(isc_nmsocket_t) active_sockets;
#endif
@@ -646,8 +684,6 @@ typedef enum isc_nmsocket_type {
isc_nm_tcplistener,
isc_nm_tcpdnslistener,
isc_nm_tcpdnssocket,
- isc_nm_tlsdnslistener,
- isc_nm_tlsdnssocket
} isc_nmsocket_type;
/*%
@@ -686,6 +722,7 @@ struct isc_nmsocket {
int tid;
isc_nmsocket_type type;
isc_nm_t *mgr;
+
/*% Parent socket for multithreaded listeners */
isc_nmsocket_t *parent;
/*% Listener socket this connection was accepted on */
@@ -693,27 +730,8 @@ struct isc_nmsocket {
/*% Self socket */
isc_nmsocket_t *self;
- /*% TLS stuff */
- struct tls {
- SSL *ssl;
- SSL_CTX *ctx;
- BIO *app_rbio;
- BIO *app_wbio;
- BIO *ssl_rbio;
- BIO *ssl_wbio;
- enum {
- TLS_STATE_NONE,
- TLS_STATE_HANDSHAKE,
- TLS_STATE_IO,
- TLS_STATE_ERROR,
- TLS_STATE_CLOSING
- } state;
- uv_buf_t senddata;
- bool cycle;
- isc_result_t pending_error;
- /* List of active send requests. */
- isc__nm_uvreq_t *pending_req;
- } tls;
+ isc_barrier_t startlistening;
+ isc_barrier_t stoplistening;
/*%
* quota is the TCP client, attached when a TCP connection
@@ -734,8 +752,6 @@ struct isc_nmsocket {
* TCP read/connect timeout timers.
*/
uv_timer_t timer;
- bool timer_initialized;
- bool timer_running;
uint64_t read_timeout;
uint64_t connect_timeout;
@@ -748,7 +764,7 @@ struct isc_nmsocket {
/*% Child sockets for multi-socket setups */
isc_nmsocket_t *children;
uint_fast32_t nchildren;
- isc_nmiface_t *iface;
+ isc_sockaddr_t iface;
isc_nmhandle_t *statichandle;
isc_nmhandle_t *outerhandle;
@@ -767,7 +783,7 @@ struct isc_nmsocket {
/* Atomic */
/*% Number of running (e.g. listening) child sockets */
- uint_fast32_t rchildren;
+ atomic_uint_fast32_t rchildren;
/*%
* Socket is active if it's listening, working, etc. If it's
@@ -916,6 +932,7 @@ struct isc_nmsocket {
void *accept_cbarg;
atomic_int_fast32_t active_child_connections;
+
#ifdef NETMGR_TRACE
void *backtrace[TRACE_SIZE];
int backtrace_size;
@@ -989,7 +1006,7 @@ isc___nm_uvreq_put(isc__nm_uvreq_t **req, isc_nmsocket_t *sock FLARG);
void
isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
- isc_nmiface_t *iface FLARG);
+ isc_sockaddr_t *iface FLARG);
/*%<
* Initialize socket 'sock', attach it to 'mgr', and set it to type 'type'
* and its interface to 'iface'.
@@ -1015,6 +1032,13 @@ isc___nmsocket_prep_destroy(isc_nmsocket_t *sock FLARG);
* if there are no remaining references or active handles.
*/
+void
+isc__nmsocket_shutdown(isc_nmsocket_t *sock);
+/*%<
+ * Initiate the socket shutdown which actively calls the active
+ * callbacks.
+ */
+
bool
isc__nmsocket_active(isc_nmsocket_t *sock);
/*%<
@@ -1046,18 +1070,20 @@ void
isc__nmsocket_timer_start(isc_nmsocket_t *sock);
void
isc__nmsocket_timer_restart(isc_nmsocket_t *sock);
+bool
+isc__nmsocket_timer_running(isc_nmsocket_t *sock);
/*%<
- * Start/stop/restart the read timeout on the socket
+ * Start/stop/restart/check the timeout on the socket
*/
void
isc__nm_connectcb(isc_nmsocket_t *sock, isc__nm_uvreq_t *uvreq,
- isc_result_t eresult);
+ isc_result_t eresult, bool async);
+
void
isc__nm_async_connectcb(isc__networker_t *worker, isc__netievent_t *ev0);
/*%<
* Issue a connect callback on the socket, used to call the callback
-
*/
void
@@ -1090,8 +1116,8 @@ isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ev0);
*/
void
-isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
- void *cbarg);
+isc__nm_udp_send(isc_nmhandle_t *handle, const isc_region_t *region,
+ isc_nm_cb_t cb, void *cbarg);
/*%<
* Back-end implementation of isc_nm_send() for UDP handles.
*/
@@ -1152,8 +1178,8 @@ isc__nm_async_udpclose(isc__networker_t *worker, isc__netievent_t *ev0);
*/
void
-isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
- void *cbarg);
+isc__nm_tcp_send(isc_nmhandle_t *handle, const isc_region_t *region,
+ isc_nm_cb_t cb, void *cbarg);
/*%<
* Back-end implementation of isc_nm_send() for TCP handles.
*/
@@ -1300,70 +1326,6 @@ isc__nm_tcpdns_cancelread(isc_nmhandle_t *handle);
* Stop reading on a connected TCPDNS handle.
*/
-void
-isc__nm_async_tlsdnscycle(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsaccept(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsconnect(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnslisten(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_tlsdns_send(isc_nmhandle_t *handle, isc_region_t *region,
- isc_nm_cb_t cb, void *cbarg);
-/*%<
- * Back-end implementation of isc_nm_send() for TLSDNS handles.
- */
-
-void
-isc__nm_tlsdns_shutdown(isc_nmsocket_t *sock);
-
-void
-isc__nm_tlsdns_close(isc_nmsocket_t *sock);
-/*%<
- * Close a TLSDNS socket.
- */
-
-void
-isc__nm_tlsdns_stoplistening(isc_nmsocket_t *sock);
-/*%<
- * Stop listening on 'sock'.
- */
-
-void
-isc__nm_tlsdns_settimeout(isc_nmhandle_t *handle, uint32_t timeout);
-/*%<
- * Set the read timeout and reset the timer for the TLSDNS socket
- * associated with 'handle', and the TCP socket it wraps around.
- */
-
-void
-isc__nm_async_tlsdnslisten(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsaccept(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnscancel(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsclose(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnssend(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsstop(isc__networker_t *worker, isc__netievent_t *ev0);
-void
-isc__nm_async_tlsdnsshutdown(isc__networker_t *worker, isc__netievent_t *ev0);
-
-void
-isc__nm_async_tlsdnsread(isc__networker_t *worker, isc__netievent_t *ev0);
-
-void
-isc__nm_tlsdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg);
-
-void
-isc__nm_tlsdns_cancelread(isc_nmhandle_t *handle);
-/*%<
- * Stop reading on a connected TLSDNS handle.
- */
-
#define isc__nm_uverr2result(x) \
isc___nm_uverr2result(x, true, __FILE__, __LINE__, __func__)
isc_result_t
@@ -1443,9 +1405,10 @@ isc__nm_socket_incoming_cpu(uv_os_sock_t fd);
*/
isc_result_t
-isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family);
+isc__nm_socket_disable_pmtud(uv_os_sock_t fd, sa_family_t sa_family);
/*%<
- * Set the SO_IP_DONTFRAG (or equivalent) socket option of the fd if available
+ * Disable the Path MTU Discovery, either by disabling IP(V6)_DONTFRAG socket
+ * option, or setting the IP(V6)_MTU_DISCOVER socket option to IP_PMTUDISC_OMIT
*/
isc_result_t
@@ -1455,6 +1418,12 @@ isc__nm_socket_connectiontimeout(uv_os_sock_t fd, int timeout_ms);
* the minimum value must be at least 1000 (1 second).
*/
+isc_result_t
+isc__nm_socket_tcp_nodelay(uv_os_sock_t fd);
+/*%<
+ * Disables Nagle's algorithm on a TCP socket (sets TCP_NODELAY).
+ */
+
/*
* typedef all the netievent types
*/
@@ -1479,17 +1448,6 @@ NETIEVENT_SOCKET_REQ_TYPE(tcpdnssend);
NETIEVENT_SOCKET_HANDLE_TYPE(tcpdnscancel);
NETIEVENT_SOCKET_QUOTA_TYPE(tcpdnsaccept);
-NETIEVENT_SOCKET_TYPE(tlsdnsclose);
-NETIEVENT_SOCKET_TYPE(tlsdnsread);
-NETIEVENT_SOCKET_TYPE(tlsdnsstop);
-NETIEVENT_SOCKET_TYPE(tlsdnsshutdown);
-NETIEVENT_SOCKET_TYPE(tlsdnslisten);
-NETIEVENT_SOCKET_REQ_TYPE(tlsdnsconnect);
-NETIEVENT_SOCKET_REQ_TYPE(tlsdnssend);
-NETIEVENT_SOCKET_HANDLE_TYPE(tlsdnscancel);
-NETIEVENT_SOCKET_QUOTA_TYPE(tlsdnsaccept);
-NETIEVENT_SOCKET_TYPE(tlsdnscycle);
-
NETIEVENT_SOCKET_REQ_TYPE(tcpconnect);
NETIEVENT_SOCKET_REQ_TYPE(tcpsend);
NETIEVENT_SOCKET_TYPE(tcpstartread);
@@ -1510,6 +1468,9 @@ NETIEVENT_TYPE(resume);
NETIEVENT_TYPE(shutdown);
NETIEVENT_TYPE(stop);
+NETIEVENT_TASK_TYPE(task);
+NETIEVENT_TASK_TYPE(privilegedtask);
+
/* Now declared the helper functions */
NETIEVENT_SOCKET_DECL(close);
@@ -1533,17 +1494,6 @@ NETIEVENT_SOCKET_REQ_DECL(tcpdnssend);
NETIEVENT_SOCKET_HANDLE_DECL(tcpdnscancel);
NETIEVENT_SOCKET_QUOTA_DECL(tcpdnsaccept);
-NETIEVENT_SOCKET_DECL(tlsdnsclose);
-NETIEVENT_SOCKET_DECL(tlsdnsread);
-NETIEVENT_SOCKET_DECL(tlsdnsstop);
-NETIEVENT_SOCKET_DECL(tlsdnsshutdown);
-NETIEVENT_SOCKET_DECL(tlsdnslisten);
-NETIEVENT_SOCKET_REQ_DECL(tlsdnsconnect);
-NETIEVENT_SOCKET_REQ_DECL(tlsdnssend);
-NETIEVENT_SOCKET_HANDLE_DECL(tlsdnscancel);
-NETIEVENT_SOCKET_QUOTA_DECL(tlsdnsaccept);
-NETIEVENT_SOCKET_DECL(tlsdnscycle);
-
NETIEVENT_SOCKET_REQ_DECL(tcpconnect);
NETIEVENT_SOCKET_REQ_DECL(tcpsend);
NETIEVENT_SOCKET_REQ_DECL(udpconnect);
@@ -1563,19 +1513,18 @@ NETIEVENT_DECL(resume);
NETIEVENT_DECL(shutdown);
NETIEVENT_DECL(stop);
+NETIEVENT_TASK_DECL(task);
+NETIEVENT_TASK_DECL(privilegedtask);
+
void
isc__nm_udp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result);
void
isc__nm_tcp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result);
void
isc__nm_tcpdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result);
-void
-isc__nm_tlsdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result);
isc_result_t
isc__nm_tcpdns_processbuffer(isc_nmsocket_t *sock);
-isc_result_t
-isc__nm_tlsdns_processbuffer(isc_nmsocket_t *sock);
isc__nm_uvreq_t *
isc__nm_get_read_req(isc_nmsocket_t *sock, isc_sockaddr_t *sockaddr);
@@ -1587,9 +1536,9 @@ void
isc__nm_udp_read_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
const struct sockaddr *addr, unsigned flags);
void
-isc__nm_tcpdns_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
+isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
void
-isc__nm_tlsdns_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
+isc__nm_tcpdns_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
void
isc__nm_start_reading(isc_nmsocket_t *sock);
@@ -1600,7 +1549,9 @@ isc__nm_process_sock_buffer(isc_nmsocket_t *sock);
void
isc__nm_resume_processing(void *arg);
bool
-isc__nm_inactive(isc_nmsocket_t *sock);
+isc__nmsocket_closing(isc_nmsocket_t *sock);
+bool
+isc__nm_closing(isc_nmsocket_t *sock);
void
isc__nm_alloc_dnsbuf(isc_nmsocket_t *sock, size_t len);
@@ -1612,8 +1563,11 @@ void
isc__nm_failed_accept_cb(isc_nmsocket_t *sock, isc_result_t eresult);
void
isc__nm_failed_connect_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
- isc_result_t eresult);
+ isc_result_t eresult, bool async);
+void
+isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result, bool async);
+
void
-isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result);
+isc__nmsocket_connecttimeout_cb(uv_timer_t *timer);
#define STREAM_CLIENTS_PER_CONN 23
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/netmgr.c b/external/mpl/bind/dist/lib/isc/netmgr/netmgr.c
index 30bde7d4b93..7b715610e72 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/netmgr.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/netmgr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: netmgr.c,v 1.6 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: netmgr.c,v 1.7 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -14,8 +14,12 @@
#include <inttypes.h>
#include <unistd.h>
#include <uv.h>
+#ifdef HAVE_LIBCTRACE
+#include <execinfo.h>
+#endif /* ifdef HAVE_LIBCTRACE */
#include <isc/atomic.h>
+#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/errno.h>
@@ -32,19 +36,16 @@
#include <isc/sockaddr.h>
#include <isc/stats.h>
#include <isc/strerr.h>
+#include <isc/task.h>
#include <isc/thread.h>
-#include <isc/tls.h>
#include <isc/util.h>
#include "netmgr-int.h"
+#include "netmgr_p.h"
#include "openssl_shim.h"
+#include "trampoline_p.h"
#include "uv-compat.h"
-#ifdef NETMGR_TRACE
-#include <execinfo.h>
-
-#endif
-
/*%
* How many isc_nmhandles and isc_nm_uvreqs will we be
* caching for reuse in a socket.
@@ -128,7 +129,14 @@ static const isc_statscounter_t unixstatsindex[] = {
* request using async_cb.
*/
-ISC_THREAD_LOCAL int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
+#if defined(HAVE_THREAD_LOCAL)
+#include <threads.h>
+static thread_local int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
+#elif defined(HAVE___THREAD)
+static __thread int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
+#elif HAVE___DECLSPEC_THREAD
+__declspec(thread) int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
+#endif /* if defined(HAVE_THREAD_LOCAL) */
static void
nmsocket_maybe_destroy(isc_nmsocket_t *sock FLARG);
@@ -139,13 +147,58 @@ nm_thread(isc_threadarg_t worker0);
static void
async_cb(uv_async_t *handle);
static bool
-process_queue(isc__networker_t *worker, isc_queue_t *queue);
-static bool
-process_priority_queue(isc__networker_t *worker);
-static bool
-process_normal_queue(isc__networker_t *worker);
+process_netievent(isc__networker_t *worker, isc__netievent_t *ievent);
+static isc_result_t
+process_queue(isc__networker_t *worker, netievent_type_t type);
+static void
+wait_for_priority_queue(isc__networker_t *worker);
static void
-process_queues(isc__networker_t *worker);
+drain_queue(isc__networker_t *worker, netievent_type_t type);
+
+#define ENQUEUE_NETIEVENT(worker, queue, event) \
+ isc_queue_enqueue(worker->ievents[queue], (uintptr_t)event)
+#define DEQUEUE_NETIEVENT(worker, queue) \
+ (isc__netievent_t *)isc_queue_dequeue(worker->ievents[queue])
+
+#define ENQUEUE_PRIORITY_NETIEVENT(worker, event) \
+ ENQUEUE_NETIEVENT(worker, NETIEVENT_PRIORITY, event)
+#define ENQUEUE_PRIVILEGED_NETIEVENT(worker, event) \
+ ENQUEUE_NETIEVENT(worker, NETIEVENT_PRIVILEGED, event)
+#define ENQUEUE_TASK_NETIEVENT(worker, event) \
+ ENQUEUE_NETIEVENT(worker, NETIEVENT_TASK, event)
+#define ENQUEUE_NORMAL_NETIEVENT(worker, event) \
+ ENQUEUE_NETIEVENT(worker, NETIEVENT_NORMAL, event)
+
+#define DEQUEUE_PRIORITY_NETIEVENT(worker) \
+ DEQUEUE_NETIEVENT(worker, NETIEVENT_PRIORITY)
+#define DEQUEUE_PRIVILEGED_NETIEVENT(worker) \
+ DEQUEUE_NETIEVENT(worker, NETIEVENT_PRIVILEGED)
+#define DEQUEUE_TASK_NETIEVENT(worker) DEQUEUE_NETIEVENT(worker, NETIEVENT_TASK)
+#define DEQUEUE_NORMAL_NETIEVENT(worker) \
+ DEQUEUE_NETIEVENT(worker, NETIEVENT_NORMAL)
+
+#define INCREMENT_NETIEVENT(worker, queue) \
+ atomic_fetch_add_release(&worker->nievents[queue], 1)
+#define DECREMENT_NETIEVENT(worker, queue) \
+ atomic_fetch_sub_release(&worker->nievents[queue], 1)
+
+#define INCREMENT_PRIORITY_NETIEVENT(worker) \
+ INCREMENT_NETIEVENT(worker, NETIEVENT_PRIORITY)
+#define INCREMENT_PRIVILEGED_NETIEVENT(worker) \
+ INCREMENT_NETIEVENT(worker, NETIEVENT_PRIVILEGED)
+#define INCREMENT_TASK_NETIEVENT(worker) \
+ INCREMENT_NETIEVENT(worker, NETIEVENT_TASK)
+#define INCREMENT_NORMAL_NETIEVENT(worker) \
+ INCREMENT_NETIEVENT(worker, NETIEVENT_NORMAL)
+
+#define DECREMENT_PRIORITY_NETIEVENT(worker) \
+ DECREMENT_NETIEVENT(worker, NETIEVENT_PRIORITY)
+#define DECREMENT_PRIVILEGED_NETIEVENT(worker) \
+ DECREMENT_NETIEVENT(worker, NETIEVENT_PRIVILEGED)
+#define DECREMENT_TASK_NETIEVENT(worker) \
+ DECREMENT_NETIEVENT(worker, NETIEVENT_TASK)
+#define DECREMENT_NORMAL_NETIEVENT(worker) \
+ DECREMENT_NETIEVENT(worker, NETIEVENT_NORMAL)
static void
isc__nm_async_stop(isc__networker_t *worker, isc__netievent_t *ev0);
@@ -157,6 +210,14 @@ static void
isc__nm_async_detach(isc__networker_t *worker, isc__netievent_t *ev0);
static void
isc__nm_async_close(isc__networker_t *worker, isc__netievent_t *ev0);
+
+static void
+isc__nm_threadpool_initialize(uint32_t workers);
+static void
+isc__nm_work_cb(uv_work_t *req);
+static void
+isc__nm_after_work_cb(uv_work_t *req, int status);
+
/*%<
* Issue a 'handle closed' callback on the socket.
*/
@@ -209,24 +270,43 @@ isc__nm_winsock_destroy(void) {
}
#endif /* WIN32 */
-isc_nm_t *
-isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
+static void
+isc__nm_threadpool_initialize(uint32_t workers) {
+ char buf[11];
+ int r = uv_os_getenv("UV_THREADPOOL_SIZE", buf,
+ &(size_t){ sizeof(buf) });
+ if (r == UV_ENOENT) {
+ snprintf(buf, sizeof(buf), "%" PRIu32, workers);
+ uv_os_setenv("UV_THREADPOOL_SIZE", buf);
+ }
+}
+
+void
+isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
char name[32];
+ REQUIRE(workers > 0);
+
#ifdef WIN32
isc__nm_winsock_initialize();
#endif /* WIN32 */
+ isc__nm_threadpool_initialize(workers);
+
mgr = isc_mem_get(mctx, sizeof(*mgr));
*mgr = (isc_nm_t){ .nworkers = workers };
isc_mem_attach(mctx, &mgr->mctx);
isc_mutex_init(&mgr->lock);
isc_condition_init(&mgr->wkstatecond);
+ isc_condition_init(&mgr->wkpausecond);
isc_refcount_init(&mgr->references, 1);
atomic_init(&mgr->maxudp, 0);
- atomic_init(&mgr->interlocked, false);
+ atomic_init(&mgr->interlocked, ISC_NETMGR_NON_INTERLOCKED);
+ atomic_init(&mgr->workers_paused, 0);
+ atomic_init(&mgr->paused, false);
+ atomic_init(&mgr->closing, false);
#ifdef NETMGR_TRACE
ISC_LIST_INIT(mgr->active_sockets);
@@ -256,6 +336,9 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
isc_mempool_associatelock(mgr->evpool, &mgr->evlock);
isc_mempool_setfillcount(mgr->evpool, 32);
+ isc_barrier_init(&mgr->pausing, workers);
+ isc_barrier_init(&mgr->resuming, workers);
+
mgr->workers = isc_mem_get(mctx, workers * sizeof(isc__networker_t));
for (size_t i = 0; i < workers; i++) {
int r;
@@ -274,10 +357,13 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
RUNTIME_CHECK(r == 0);
isc_mutex_init(&worker->lock);
- isc_condition_init(&worker->cond);
+ isc_condition_init(&worker->cond_prio);
+
+ for (size_t type = 0; type < NETIEVENT_MAX; type++) {
+ worker->ievents[type] = isc_queue_new(mgr->mctx, 128);
+ atomic_init(&worker->nievents[type], 0);
+ }
- worker->ievents = isc_queue_new(mgr->mctx, 128);
- worker->ievents_prio = isc_queue_new(mgr->mctx, 128);
worker->recvbuf = isc_mem_get(mctx, ISC_NETMGR_RECVBUF_SIZE);
worker->sendbuf = isc_mem_get(mctx, ISC_NETMGR_SENDBUF_SIZE);
@@ -294,7 +380,7 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
}
mgr->magic = NM_MAGIC;
- return (mgr);
+ *netmgrp = mgr;
}
/*
@@ -312,7 +398,7 @@ nm_destroy(isc_nm_t **mgr0) {
mgr->magic = 0;
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (int i = 0; i < mgr->nworkers; i++) {
isc__networker_t *worker = &mgr->workers[i];
isc__netievent_t *event = isc__nm_get_netievent_stop(mgr);
isc__nm_enqueue_ievent(worker, event);
@@ -324,31 +410,30 @@ nm_destroy(isc_nm_t **mgr0) {
}
UNLOCK(&mgr->lock);
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (int i = 0; i < mgr->nworkers; i++) {
isc__networker_t *worker = &mgr->workers[i];
isc__netievent_t *ievent = NULL;
int r;
/* Empty the async event queues */
- while ((ievent = (isc__netievent_t *)isc_queue_dequeue(
- worker->ievents)) != NULL)
- {
+ while ((ievent = DEQUEUE_PRIORITY_NETIEVENT(worker)) != NULL) {
isc_mempool_put(mgr->evpool, ievent);
}
- while ((ievent = (isc__netievent_t *)isc_queue_dequeue(
- worker->ievents_prio)) != NULL)
- {
+ INSIST(DEQUEUE_PRIVILEGED_NETIEVENT(worker) == NULL);
+ INSIST(DEQUEUE_TASK_NETIEVENT(worker) == NULL);
+
+ while ((ievent = DEQUEUE_PRIORITY_NETIEVENT(worker)) != NULL) {
isc_mempool_put(mgr->evpool, ievent);
}
+ isc_condition_destroy(&worker->cond_prio);
r = uv_loop_close(&worker->loop);
INSIST(r == 0);
- isc_queue_destroy(worker->ievents);
- isc_queue_destroy(worker->ievents_prio);
- isc_mutex_destroy(&worker->lock);
- isc_condition_destroy(&worker->cond);
+ for (size_t type = 0; type < NETIEVENT_MAX; type++) {
+ isc_queue_destroy(worker->ievents[type]);
+ }
isc_mem_put(mgr->mctx, worker->sendbuf,
ISC_NETMGR_SENDBUF_SIZE);
@@ -361,7 +446,11 @@ nm_destroy(isc_nm_t **mgr0) {
isc_stats_detach(&mgr->stats);
}
+ isc_barrier_destroy(&mgr->resuming);
+ isc_barrier_destroy(&mgr->pausing);
+
isc_condition_destroy(&mgr->wkstatecond);
+ isc_condition_destroy(&mgr->wkpausecond);
isc_mutex_destroy(&mgr->lock);
isc_mempool_destroy(&mgr->evpool);
@@ -379,45 +468,107 @@ nm_destroy(isc_nm_t **mgr0) {
#endif /* WIN32 */
}
+static void
+enqueue_pause(isc__networker_t *worker) {
+ isc__netievent_pause_t *event =
+ isc__nm_get_netievent_pause(worker->mgr);
+ isc__nm_enqueue_ievent(worker, (isc__netievent_t *)event);
+}
+
+static void
+isc__nm_async_pause(isc__networker_t *worker, isc__netievent_t *ev0) {
+ UNUSED(ev0);
+ REQUIRE(worker->paused == false);
+
+ worker->paused = true;
+ uv_stop(&worker->loop);
+}
+
void
isc_nm_pause(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
- REQUIRE(!isc__nm_in_netthread());
+ REQUIRE(!atomic_load(&mgr->paused));
isc__nm_acquire_interlocked_force(mgr);
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ if (isc__nm_in_netthread()) {
+ REQUIRE(isc_nm_tid() == 0);
+ }
+
+ for (int i = 0; i < mgr->nworkers; i++) {
isc__networker_t *worker = &mgr->workers[i];
- isc__netievent_resume_t *event =
- isc__nm_get_netievent_pause(mgr);
- isc__nm_enqueue_ievent(worker, (isc__netievent_t *)event);
+ if (i == isc_nm_tid()) {
+ isc__nm_async_pause(worker, NULL);
+ } else {
+ enqueue_pause(worker);
+ }
+ }
+
+ if (isc__nm_in_netthread()) {
+ atomic_fetch_add(&mgr->workers_paused, 1);
+ isc_barrier_wait(&mgr->pausing);
}
LOCK(&mgr->lock);
- while (mgr->workers_paused != mgr->workers_running) {
+ while (atomic_load(&mgr->workers_paused) != mgr->workers_running) {
WAIT(&mgr->wkstatecond, &mgr->lock);
}
UNLOCK(&mgr->lock);
+
+ REQUIRE(atomic_compare_exchange_strong(&mgr->paused, &(bool){ false },
+ true));
+}
+
+static void
+enqueue_resume(isc__networker_t *worker) {
+ isc__netievent_resume_t *event =
+ isc__nm_get_netievent_resume(worker->mgr);
+ isc__nm_enqueue_ievent(worker, (isc__netievent_t *)event);
+}
+
+static void
+isc__nm_async_resume(isc__networker_t *worker, isc__netievent_t *ev0) {
+ UNUSED(ev0);
+ REQUIRE(worker->paused == true);
+
+ worker->paused = false;
}
void
isc_nm_resume(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
- REQUIRE(!isc__nm_in_netthread());
+ REQUIRE(atomic_load(&mgr->paused));
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ if (isc__nm_in_netthread()) {
+ REQUIRE(isc_nm_tid() == 0);
+ drain_queue(&mgr->workers[isc_nm_tid()], NETIEVENT_PRIORITY);
+ }
+
+ for (int i = 0; i < mgr->nworkers; i++) {
isc__networker_t *worker = &mgr->workers[i];
- isc__netievent_resume_t *event =
- isc__nm_get_netievent_resume(mgr);
- isc__nm_enqueue_ievent(worker, (isc__netievent_t *)event);
+ if (i == isc_nm_tid()) {
+ isc__nm_async_resume(worker, NULL);
+ } else {
+ enqueue_resume(worker);
+ }
+ }
+
+ if (isc__nm_in_netthread()) {
+ drain_queue(&mgr->workers[isc_nm_tid()], NETIEVENT_PRIVILEGED);
+
+ atomic_fetch_sub(&mgr->workers_paused, 1);
+ isc_barrier_wait(&mgr->resuming);
}
LOCK(&mgr->lock);
- while (mgr->workers_paused != 0) {
+ while (atomic_load(&mgr->workers_paused) != 0) {
WAIT(&mgr->wkstatecond, &mgr->lock);
}
UNLOCK(&mgr->lock);
+ REQUIRE(atomic_compare_exchange_strong(&mgr->paused, &(bool){ true },
+ false));
+
isc__nm_drop_interlocked(mgr);
}
@@ -447,11 +598,11 @@ isc_nm_detach(isc_nm_t **mgr0) {
}
void
-isc_nm_closedown(isc_nm_t *mgr) {
+isc__netmgr_shutdown(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
atomic_store(&mgr->closing, true);
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (int i = 0; i < mgr->nworkers; i++) {
isc__netievent_t *event = NULL;
event = isc__nm_get_netievent_shutdown(mgr);
isc__nm_enqueue_ievent(&mgr->workers[i], event);
@@ -459,44 +610,45 @@ isc_nm_closedown(isc_nm_t *mgr) {
}
void
-isc_nm_destroy(isc_nm_t **mgr0) {
+isc__netmgr_destroy(isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
int counter = 0;
- uint_fast32_t references;
- REQUIRE(mgr0 != NULL);
- REQUIRE(VALID_NM(*mgr0));
+ REQUIRE(VALID_NM(*netmgrp));
- mgr = *mgr0;
+ mgr = *netmgrp;
/*
* Close active connections.
*/
- isc_nm_closedown(mgr);
+ isc__netmgr_shutdown(mgr);
/*
* Wait for the manager to be dereferenced elsewhere.
*/
- while ((references = isc_refcount_current(&mgr->references)) > 1 &&
- counter++ < 1000)
- {
-#ifdef WIN32
- _sleep(10);
-#else /* ifdef WIN32 */
- usleep(10000);
-#endif /* ifdef WIN32 */
+ while (isc_refcount_current(&mgr->references) > 1 && counter++ < 1000) {
+ uv_sleep(10);
}
#ifdef NETMGR_TRACE
- isc__nm_dump_active(mgr);
+ if (isc_refcount_current(&mgr->references) > 1) {
+ isc__nm_dump_active(mgr);
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
#endif
- INSIST(references == 1);
+ /*
+ * Now just patiently wait
+ */
+ while (isc_refcount_current(&mgr->references) > 1) {
+ uv_sleep(10);
+ }
/*
* Detach final reference.
*/
- isc_nm_detach(mgr0);
+ isc_nm_detach(netmgrp);
}
void
@@ -542,44 +694,73 @@ isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle,
/*
* nm_thread is a single worker thread, that runs uv_run event loop
* until asked to stop.
+ *
+ * There are four queues for asynchronous events:
+ *
+ * 1. priority queue - netievents on the priority queue are run even when
+ * the taskmgr enters exclusive mode and the netmgr is paused. This
+ * is needed to properly start listening on the interfaces, free
+ * resources on shutdown, or resume from a pause.
+ *
+ * 2. privileged task queue - only privileged tasks are queued here and
+ * this is the first queue that gets processed when network manager
+ * is unpaused using isc_nm_resume(). All netmgr workers need to
+ * clean the privileged task queue before they all proceed to normal
+ * operation. Both task queues are processed when the workers are
+ * shutting down.
+ *
+ * 3. task queue - only (traditional) tasks are scheduled here, and this
+ * queue and the privileged task queue are both processed when the
+ * netmgr workers are finishing. This is needed to process the task
+ * shutdown events.
+ *
+ * 4. normal queue - this is the queue with netmgr events, e.g. reading,
+ * sending, callbacks, etc.
*/
+
static isc_threadresult_t
nm_thread(isc_threadarg_t worker0) {
isc__networker_t *worker = (isc__networker_t *)worker0;
isc_nm_t *mgr = worker->mgr;
isc__nm_tid_v = worker->id;
- isc_thread_setaffinity(isc__nm_tid_v);
while (true) {
+ /*
+ * uv_run() runs async_cb() in a loop, which processes
+ * all four event queues until a "pause" or "stop" event
+ * is encountered. On pause, we process only priority and
+ * privileged events until resuming.
+ */
int r = uv_run(&worker->loop, UV_RUN_DEFAULT);
- /* There's always the async handle until we are done */
INSIST(r > 0 || worker->finished);
if (worker->paused) {
- LOCK(&worker->lock);
- /* We need to lock the worker first otherwise
- * isc_nm_resume() might slip in before WAIT() in the
- * while loop starts and the signal never gets delivered
- * and we are forever stuck in the paused loop.
- */
+ INSIST(atomic_load(&mgr->interlocked) != isc_nm_tid());
- LOCK(&mgr->lock);
- mgr->workers_paused++;
- SIGNAL(&mgr->wkstatecond);
- UNLOCK(&mgr->lock);
+ atomic_fetch_add(&mgr->workers_paused, 1);
+ if (isc_barrier_wait(&mgr->pausing) != 0) {
+ LOCK(&mgr->lock);
+ SIGNAL(&mgr->wkstatecond);
+ UNLOCK(&mgr->lock);
+ }
while (worker->paused) {
- WAIT(&worker->cond, &worker->lock);
- (void)process_priority_queue(worker);
+ wait_for_priority_queue(worker);
}
- LOCK(&mgr->lock);
- mgr->workers_paused--;
- SIGNAL(&mgr->wkstatecond);
- UNLOCK(&mgr->lock);
+ /*
+ * All workers must drain the privileged event
+ * queue before we resume from pause.
+ */
+ drain_queue(worker, NETIEVENT_PRIVILEGED);
- UNLOCK(&worker->lock);
+ atomic_fetch_sub(&mgr->workers_paused, 1);
+ if (isc_barrier_wait(&mgr->resuming) != 0) {
+ LOCK(&mgr->lock);
+ SIGNAL(&mgr->wkstatecond);
+ UNLOCK(&mgr->lock);
+ }
}
if (r == 0) {
@@ -588,13 +769,16 @@ nm_thread(isc_threadarg_t worker0) {
}
INSIST(!worker->finished);
-
- /*
- * Empty the async queue.
- */
- process_queues(worker);
}
+ /*
+ * We are shutting down. Process the task queues
+ * (they may include shutdown events) but do not process
+ * the netmgr event queue.
+ */
+ drain_queue(worker, NETIEVENT_PRIVILEGED);
+ drain_queue(worker, NETIEVENT_TASK);
+
LOCK(&mgr->lock);
mgr->workers_running--;
SIGNAL(&mgr->wkstatecond);
@@ -603,16 +787,52 @@ nm_thread(isc_threadarg_t worker0) {
return ((isc_threadresult_t)0);
}
+static bool
+process_all_queues(isc__networker_t *worker) {
+ bool reschedule = false;
+ /*
+ * The queue processing functions will return false when the
+ * system is pausing or stopping and we don't want to process
+ * the other queues in such case, but we need the async event
+ * to be rescheduled in the next uv_run().
+ */
+ for (size_t type = 0; type < NETIEVENT_MAX; type++) {
+ isc_result_t result = process_queue(worker, type);
+ switch (result) {
+ case ISC_R_SUSPEND:
+ return (true);
+ case ISC_R_EMPTY:
+ /* empty queue */
+ break;
+ case ISC_R_SUCCESS:
+ reschedule = true;
+ break;
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
+ }
+
+ return (reschedule);
+}
+
/*
- * async_cb is a universal callback for 'async' events sent to event loop.
+ * async_cb() is a universal callback for 'async' events sent to event loop.
* It's the only way to safely pass data to the libuv event loop. We use a
- * single async event and a lockless queue of 'isc__netievent_t' structures
- * passed from other threads.
+ * single async event and a set of lockless queues of 'isc__netievent_t'
+ * structures passed from other threads.
*/
static void
async_cb(uv_async_t *handle) {
isc__networker_t *worker = (isc__networker_t *)handle->loop->data;
- process_queues(worker);
+
+ if (process_all_queues(worker)) {
+ /*
+ * If we didn't process all the events, we need to enqueue
+ * async_cb to be run in the next iteration of the uv_loop
+ */
+ uv_async_send(handle);
+ }
}
static void
@@ -621,40 +841,89 @@ isc__nm_async_stop(isc__networker_t *worker, isc__netievent_t *ev0) {
worker->finished = true;
/* Close the async handler */
uv_close((uv_handle_t *)&worker->async, NULL);
- /* uv_stop(&worker->loop); */
}
-static void
-isc__nm_async_pause(isc__networker_t *worker, isc__netievent_t *ev0) {
- UNUSED(ev0);
- REQUIRE(worker->paused == false);
- worker->paused = true;
- uv_stop(&worker->loop);
+void
+isc_nm_task_enqueue(isc_nm_t *nm, isc_task_t *task, int threadid) {
+ isc__netievent_t *event = NULL;
+ int tid;
+ isc__networker_t *worker = NULL;
+
+ if (threadid == -1) {
+ tid = (int)isc_random_uniform(nm->nworkers);
+ } else {
+ tid = threadid % nm->nworkers;
+ }
+
+ worker = &nm->workers[tid];
+
+ if (isc_task_privileged(task)) {
+ event = (isc__netievent_t *)
+ isc__nm_get_netievent_privilegedtask(nm, task);
+ } else {
+ event = (isc__netievent_t *)isc__nm_get_netievent_task(nm,
+ task);
+ }
+
+ isc__nm_enqueue_ievent(worker, event);
}
+#define isc__nm_async_privilegedtask(worker, ev0) \
+ isc__nm_async_task(worker, ev0)
+
static void
-isc__nm_async_resume(isc__networker_t *worker, isc__netievent_t *ev0) {
- UNUSED(ev0);
- REQUIRE(worker->paused == true);
- worker->paused = false;
-}
+isc__nm_async_task(isc__networker_t *worker, isc__netievent_t *ev0) {
+ isc__netievent_task_t *ievent = (isc__netievent_task_t *)ev0;
+ isc_result_t result;
-static bool
-process_priority_queue(isc__networker_t *worker) {
- return (process_queue(worker, worker->ievents_prio));
+ UNUSED(worker);
+
+ result = isc_task_run(ievent->task);
+
+ switch (result) {
+ case ISC_R_QUOTA:
+ isc_task_ready(ievent->task);
+ return;
+ case ISC_R_SUCCESS:
+ return;
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
}
-static bool
-process_normal_queue(isc__networker_t *worker) {
- return (process_queue(worker, worker->ievents));
+static void
+wait_for_priority_queue(isc__networker_t *worker) {
+ isc_condition_t *cond = &worker->cond_prio;
+ bool wait_for_work = true;
+
+ while (true) {
+ isc__netievent_t *ievent;
+ LOCK(&worker->lock);
+ ievent = DEQUEUE_PRIORITY_NETIEVENT(worker);
+ if (wait_for_work) {
+ while (ievent == NULL) {
+ WAIT(cond, &worker->lock);
+ ievent = DEQUEUE_PRIORITY_NETIEVENT(worker);
+ }
+ }
+ UNLOCK(&worker->lock);
+ wait_for_work = false;
+
+ if (ievent == NULL) {
+ return;
+ }
+ DECREMENT_PRIORITY_NETIEVENT(worker);
+
+ (void)process_netievent(worker, ievent);
+ }
}
static void
-process_queues(isc__networker_t *worker) {
- if (!process_priority_queue(worker)) {
- return;
+drain_queue(isc__networker_t *worker, netievent_type_t type) {
+ while (process_queue(worker, type) != ISC_R_EMPTY) {
+ ;
}
- (void)process_normal_queue(worker);
}
/*
@@ -687,6 +956,9 @@ process_netievent(isc__networker_t *worker, isc__netievent_t *ievent) {
/* Don't process more ievents when we are stopping */
NETIEVENT_CASE_NOMORE(stop);
+ NETIEVENT_CASE(privilegedtask);
+ NETIEVENT_CASE(task);
+
NETIEVENT_CASE(udpconnect);
NETIEVENT_CASE(udplisten);
NETIEVENT_CASE(udpstop);
@@ -714,17 +986,6 @@ process_netievent(isc__networker_t *worker, isc__netievent_t *ievent) {
NETIEVENT_CASE(tcpdnsread);
NETIEVENT_CASE(tcpdnsstop);
- NETIEVENT_CASE(tlsdnscycle);
- NETIEVENT_CASE(tlsdnsaccept);
- NETIEVENT_CASE(tlsdnslisten);
- NETIEVENT_CASE(tlsdnsconnect);
- NETIEVENT_CASE(tlsdnssend);
- NETIEVENT_CASE(tlsdnscancel);
- NETIEVENT_CASE(tlsdnsclose);
- NETIEVENT_CASE(tlsdnsread);
- NETIEVENT_CASE(tlsdnsstop);
- NETIEVENT_CASE(tlsdnsshutdown);
-
NETIEVENT_CASE(connectcb);
NETIEVENT_CASE(readcb);
NETIEVENT_CASE(sendcb);
@@ -735,7 +996,6 @@ process_netievent(isc__networker_t *worker, isc__netievent_t *ievent) {
NETIEVENT_CASE(shutdown);
NETIEVENT_CASE(resume);
NETIEVENT_CASE_NOMORE(pause);
-
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -743,17 +1003,46 @@ process_netievent(isc__networker_t *worker, isc__netievent_t *ievent) {
return (true);
}
-static bool
-process_queue(isc__networker_t *worker, isc_queue_t *queue) {
- isc__netievent_t *ievent = NULL;
+static isc_result_t
+process_queue(isc__networker_t *worker, netievent_type_t type) {
+ /*
+ * The number of items on the queue is only loosely synchronized with
+ * the items on the queue. But there's a guarantee that if there's an
+ * item on the queue, it will be accounted for. However there's a
+ * possibility that the counter might be higher than the items on the
+ * queue stored.
+ */
+ uint_fast32_t waiting = atomic_load_acquire(&worker->nievents[type]);
+ isc__netievent_t *ievent = DEQUEUE_NETIEVENT(worker, type);
+
+ if (ievent == NULL && waiting == 0) {
+ /* There's nothing scheduled */
+ return (ISC_R_EMPTY);
+ } else if (ievent == NULL) {
+ /* There's at least one item scheduled, but not on the queue yet
+ */
+ return (ISC_R_SUCCESS);
+ }
- while ((ievent = (isc__netievent_t *)isc_queue_dequeue(queue)) != NULL)
- {
- if (!process_netievent(worker, ievent)) {
- return (false);
+ while (ievent != NULL) {
+ DECREMENT_NETIEVENT(worker, type);
+ bool stop = !process_netievent(worker, ievent);
+
+ if (stop) {
+ /* Netievent told us to stop */
+ return (ISC_R_SUSPEND);
+ }
+
+ if (waiting-- == 0) {
+ /* We reached this round "quota" */
+ break;
}
+
+ ievent = DEQUEUE_NETIEVENT(worker, type);
}
- return (true);
+
+ /* We processed at least one */
+ return (ISC_R_SUCCESS);
}
void *
@@ -789,21 +1078,9 @@ NETIEVENT_SOCKET_REQ_DEF(tcpdnssend);
NETIEVENT_SOCKET_HANDLE_DEF(tcpdnscancel);
NETIEVENT_SOCKET_QUOTA_DEF(tcpdnsaccept);
-NETIEVENT_SOCKET_DEF(tlsdnsclose);
-NETIEVENT_SOCKET_DEF(tlsdnsread);
-NETIEVENT_SOCKET_DEF(tlsdnsstop);
-NETIEVENT_SOCKET_DEF(tlsdnslisten);
-NETIEVENT_SOCKET_REQ_DEF(tlsdnsconnect);
-NETIEVENT_SOCKET_REQ_DEF(tlsdnssend);
-NETIEVENT_SOCKET_HANDLE_DEF(tlsdnscancel);
-NETIEVENT_SOCKET_QUOTA_DEF(tlsdnsaccept);
-NETIEVENT_SOCKET_DEF(tlsdnscycle);
-NETIEVENT_SOCKET_DEF(tlsdnsshutdown);
-
NETIEVENT_SOCKET_REQ_DEF(tcpconnect);
NETIEVENT_SOCKET_REQ_DEF(tcpsend);
NETIEVENT_SOCKET_REQ_DEF(udpconnect);
-
NETIEVENT_SOCKET_REQ_RESULT_DEF(connectcb);
NETIEVENT_SOCKET_REQ_RESULT_DEF(readcb);
NETIEVENT_SOCKET_REQ_RESULT_DEF(sendcb);
@@ -820,6 +1097,9 @@ NETIEVENT_DEF(resume);
NETIEVENT_DEF(shutdown);
NETIEVENT_DEF(stop);
+NETIEVENT_TASK_DEF(task);
+NETIEVENT_TASK_DEF(privilegedtask);
+
void
isc__nm_maybe_enqueue_ievent(isc__networker_t *worker,
isc__netievent_t *event) {
@@ -843,11 +1123,19 @@ isc__nm_enqueue_ievent(isc__networker_t *worker, isc__netievent_t *event) {
* the queue will be processed.
*/
LOCK(&worker->lock);
- isc_queue_enqueue(worker->ievents_prio, (uintptr_t)event);
- SIGNAL(&worker->cond);
+ INCREMENT_PRIORITY_NETIEVENT(worker);
+ ENQUEUE_PRIORITY_NETIEVENT(worker, event);
+ SIGNAL(&worker->cond_prio);
UNLOCK(&worker->lock);
+ } else if (event->type == netievent_privilegedtask) {
+ INCREMENT_PRIVILEGED_NETIEVENT(worker);
+ ENQUEUE_PRIVILEGED_NETIEVENT(worker, event);
+ } else if (event->type == netievent_task) {
+ INCREMENT_TASK_NETIEVENT(worker);
+ ENQUEUE_TASK_NETIEVENT(worker, event);
} else {
- isc_queue_enqueue(worker->ievents, (uintptr_t)event);
+ INCREMENT_NORMAL_NETIEVENT(worker);
+ ENQUEUE_NORMAL_NETIEVENT(worker, event);
}
uv_async_send(&worker->async);
}
@@ -889,8 +1177,9 @@ isc___nmsocket_attach(isc_nmsocket_t *sock, isc_nmsocket_t **target FLARG) {
rsock = sock;
}
- NETMGR_TRACE_LOG("isc__nmsocket_attach():%p->references = %lu\n", rsock,
- isc_refcount_current(&rsock->references) + 1);
+ NETMGR_TRACE_LOG("isc__nmsocket_attach():%p->references = %" PRIuFAST32
+ "\n",
+ rsock, isc_refcount_current(&rsock->references) + 1);
isc_refcount_increment0(&rsock->references);
@@ -908,8 +1197,9 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(!isc__nmsocket_active(sock));
- NETMGR_TRACE_LOG("nmsocket_cleanup():%p->references = %lu\n", sock,
- isc_refcount_current(&sock->references));
+ NETMGR_TRACE_LOG("nmsocket_cleanup():%p->references = %" PRIuFAST32
+ "\n",
+ sock, isc_refcount_current(&sock->references));
atomic_store(&sock->destroying, true);
@@ -926,7 +1216,14 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
}
/*
- * This was a parent socket; free the children.
+ * This was a parent socket: destroy the listening
+ * barriers that synchronized the children.
+ */
+ isc_barrier_destroy(&sock->startlistening);
+ isc_barrier_destroy(&sock->stoplistening);
+
+ /*
+ * Now free them.
*/
isc_mem_put(sock->mgr->mctx, sock->children,
sock->nchildren * sizeof(*sock));
@@ -961,15 +1258,6 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
sock->pquota = NULL;
- if (sock->timer_initialized) {
- sock->timer_initialized = false;
- /* We might be in timer callback */
- if (!uv_is_closing((uv_handle_t *)&sock->timer)) {
- uv_timer_stop(&sock->timer);
- uv_close((uv_handle_t *)&sock->timer, NULL);
- }
- }
-
isc_astack_destroy(sock->inactivehandles);
while ((uvreq = isc_astack_pop(sock->inactivereqs)) != NULL) {
@@ -982,7 +1270,6 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
isc_mem_free(sock->mgr->mctx, sock->ah_frees);
isc_mem_free(sock->mgr->mctx, sock->ah_handles);
isc_mutex_destroy(&sock->lock);
- isc_condition_destroy(&sock->cond);
isc_condition_destroy(&sock->scond);
#ifdef NETMGR_TRACE
LOCK(&sock->mgr->lock);
@@ -1003,6 +1290,9 @@ nmsocket_maybe_destroy(isc_nmsocket_t *sock FLARG) {
int active_handles;
bool destroy = false;
+ NETMGR_TRACE_LOG("%s():%p->references = %" PRIuFAST32 "\n", __func__,
+ sock, isc_refcount_current(&sock->references));
+
if (sock->parent != NULL) {
/*
* This is a child socket and cannot be destroyed except
@@ -1055,7 +1345,8 @@ void
isc___nmsocket_prep_destroy(isc_nmsocket_t *sock FLARG) {
REQUIRE(sock->parent == NULL);
- NETMGR_TRACE_LOG("isc___nmsocket_prep_destroy():%p->references = %lu\n",
+ NETMGR_TRACE_LOG("isc___nmsocket_prep_destroy():%p->references = "
+ "%" PRIuFAST32 "\n",
sock, isc_refcount_current(&sock->references));
/*
@@ -1092,9 +1383,6 @@ isc___nmsocket_prep_destroy(isc_nmsocket_t *sock FLARG) {
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_close(sock);
return;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_close(sock);
- return;
default:
break;
}
@@ -1122,8 +1410,9 @@ isc___nmsocket_detach(isc_nmsocket_t **sockp FLARG) {
rsock = sock;
}
- NETMGR_TRACE_LOG("isc__nmsocket_detach():%p->references = %lu\n", rsock,
- isc_refcount_current(&rsock->references) - 1);
+ NETMGR_TRACE_LOG("isc__nmsocket_detach():%p->references = %" PRIuFAST32
+ "\n",
+ rsock, isc_refcount_current(&rsock->references) - 1);
if (isc_refcount_decrement(&rsock->references) == 1) {
isc___nmsocket_prep_destroy(rsock FLARG_PASS);
@@ -1136,25 +1425,24 @@ isc_nmsocket_close(isc_nmsocket_t **sockp) {
REQUIRE(VALID_NMSOCK(*sockp));
REQUIRE((*sockp)->type == isc_nm_udplistener ||
(*sockp)->type == isc_nm_tcplistener ||
- (*sockp)->type == isc_nm_tcpdnslistener ||
- (*sockp)->type == isc_nm_tlsdnslistener);
+ (*sockp)->type == isc_nm_tcpdnslistener);
isc__nmsocket_detach(sockp);
}
void
isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
- isc_nmiface_t *iface FLARG) {
+ isc_sockaddr_t *iface FLARG) {
uint16_t family;
REQUIRE(sock != NULL);
REQUIRE(mgr != NULL);
REQUIRE(iface != NULL);
- family = iface->addr.type.sa.sa_family;
+ family = iface->type.sa.sa_family;
*sock = (isc_nmsocket_t){ .type = type,
- .iface = iface,
+ .iface = *iface,
.fd = -1,
.ah_size = 32,
.inactivehandles = isc_astack_new(
@@ -1162,7 +1450,7 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
.inactivereqs = isc_astack_new(
mgr->mctx, ISC_NM_REQS_STACK_SIZE) };
-#ifdef NETMGR_TRACE
+#if NETMGR_TRACE
sock->backtrace_size = backtrace(sock->backtrace, TRACE_SIZE);
ISC_LINK_INIT(sock, active_link);
ISC_LIST_INIT(sock->active_handles);
@@ -1198,8 +1486,6 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
case isc_nm_tcplistener:
case isc_nm_tcpdnssocket:
case isc_nm_tcpdnslistener:
- case isc_nm_tlsdnssocket:
- case isc_nm_tlsdnslistener:
if (family == AF_INET) {
sock->statsindex = tcp4statsindex;
} else {
@@ -1216,15 +1502,24 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
isc_condition_init(&sock->scond);
isc_refcount_init(&sock->references, 1);
- NETMGR_TRACE_LOG("isc__nmsocket_init():%p->references = %lu\n", sock,
- isc_refcount_current(&sock->references));
+ NETMGR_TRACE_LOG("isc__nmsocket_init():%p->references = %" PRIuFAST32
+ "\n",
+ sock, isc_refcount_current(&sock->references));
atomic_init(&sock->active, true);
atomic_init(&sock->sequential, false);
atomic_init(&sock->readpaused, false);
atomic_init(&sock->closing, false);
+ atomic_init(&sock->listening, 0);
+ atomic_init(&sock->closed, 0);
+ atomic_init(&sock->destroying, 0);
+ atomic_init(&sock->ah, 0);
+ atomic_init(&sock->client, 0);
+ atomic_init(&sock->connecting, false);
+ atomic_init(&sock->keepalive, false);
+ atomic_init(&sock->connected, false);
- atomic_store(&sock->active_child_connections, 0);
+ atomic_init(&sock->active_child_connections, 0);
sock->magic = NMSOCK_MAGIC;
}
@@ -1297,29 +1592,26 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
INSIST(VALID_NMHANDLE(handle));
}
- NETMGR_TRACE_LOG("isc__nmhandle_get():handle %p->references = %lu\n",
- handle, isc_refcount_current(&handle->references));
+ NETMGR_TRACE_LOG(
+ "isc__nmhandle_get():handle %p->references = %" PRIuFAST32 "\n",
+ handle, isc_refcount_current(&handle->references));
isc___nmsocket_attach(sock, &handle->sock FLARG_PASS);
-#ifdef NETMGR_TRACE
+#if NETMGR_TRACE
handle->backtrace_size = backtrace(handle->backtrace, TRACE_SIZE);
#endif
if (peer != NULL) {
- memmove(&handle->peer, peer, sizeof(isc_sockaddr_t));
+ handle->peer = *peer;
} else {
- memmove(&handle->peer, &sock->peer, sizeof(isc_sockaddr_t));
+ handle->peer = sock->peer;
}
if (local != NULL) {
- memmove(&handle->local, local, sizeof(isc_sockaddr_t));
- } else if (sock->iface != NULL) {
- memmove(&handle->local, &sock->iface->addr,
- sizeof(isc_sockaddr_t));
+ handle->local = *local;
} else {
- INSIST(0);
- ISC_UNREACHABLE();
+ handle->local = sock->iface;
}
LOCK(&sock->lock);
@@ -1351,11 +1643,14 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
#endif
UNLOCK(&sock->lock);
- if (sock->type == isc_nm_tcpsocket ||
- (sock->type == isc_nm_udpsocket && atomic_load(&sock->client)) ||
- (sock->type == isc_nm_tcpdnssocket && atomic_load(&sock->client)) ||
- (sock->type == isc_nm_tlsdnssocket && atomic_load(&sock->client)))
- {
+ switch (sock->type) {
+ case isc_nm_udpsocket:
+ case isc_nm_tcpdnssocket:
+ if (!atomic_load(&sock->client)) {
+ break;
+ }
+ /* fallthrough */
+ case isc_nm_tcpsocket:
INSIST(sock->statichandle == NULL);
/*
@@ -1365,6 +1660,9 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
* handle and socket would never be freed.
*/
sock->statichandle = handle;
+ break;
+ default:
+ break;
}
return (handle);
@@ -1375,7 +1673,8 @@ isc__nmhandle_attach(isc_nmhandle_t *handle, isc_nmhandle_t **handlep FLARG) {
REQUIRE(VALID_NMHANDLE(handle));
REQUIRE(handlep != NULL && *handlep == NULL);
- NETMGR_TRACE_LOG("isc__nmhandle_attach():handle %p->references = %lu\n",
+ NETMGR_TRACE_LOG("isc__nmhandle_attach():handle %p->references = "
+ "%" PRIuFAST32 "\n",
handle, isc_refcount_current(&handle->references) + 1);
isc_refcount_increment(&handle->references);
@@ -1387,8 +1686,7 @@ isc_nmhandle_is_stream(isc_nmhandle_t *handle) {
REQUIRE(VALID_NMHANDLE(handle));
return (handle->sock->type == isc_nm_tcpsocket ||
- handle->sock->type == isc_nm_tcpdnssocket ||
- handle->sock->type == isc_nm_tlsdnssocket);
+ handle->sock->type == isc_nm_tcpdnssocket);
}
static void
@@ -1467,6 +1765,9 @@ isc__nmhandle_detach(isc_nmhandle_t **handlep FLARG) {
}
}
+void
+isc__nmsocket_shutdown(isc_nmsocket_t *sock);
+
static void
nmhandle_detach_cb(isc_nmhandle_t **handlep FLARG) {
isc_nmsocket_t *sock = NULL;
@@ -1478,7 +1779,8 @@ nmhandle_detach_cb(isc_nmhandle_t **handlep FLARG) {
handle = *handlep;
*handlep = NULL;
- NETMGR_TRACE_LOG("isc__nmhandle_detach():%p->references = %lu\n",
+ NETMGR_TRACE_LOG("isc__nmhandle_detach():%p->references = %" PRIuFAST32
+ "\n",
handle, isc_refcount_current(&handle->references) - 1);
if (isc_refcount_decrement(&handle->references) > 1) {
@@ -1607,25 +1909,29 @@ isc__nm_failed_accept_cb(isc_nmsocket_t *sock, isc_result_t eresult) {
void
isc__nm_failed_connect_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
- isc_result_t eresult) {
+ isc_result_t eresult, bool async) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(VALID_UVREQ(req));
REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->connecting));
REQUIRE(req->cb.connect != NULL);
- atomic_store(&sock->connecting, false);
+ isc__nmsocket_timer_stop(sock);
+ uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
- isc__nmsocket_clearcb(sock);
+ INSIST(atomic_compare_exchange_strong(&sock->connecting,
+ &(bool){ true }, false));
- isc__nm_connectcb(sock, req, eresult);
+ isc__nmsocket_clearcb(sock);
+ isc__nm_connectcb(sock, req, eresult, async);
isc__nmsocket_prep_destroy(sock);
}
void
-isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
+isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result, bool async) {
REQUIRE(VALID_NMSOCK(sock));
+ UNUSED(async);
+
switch (sock->type) {
case isc_nm_udpsocket:
isc__nm_udp_failed_read_cb(sock, result);
@@ -1636,15 +1942,40 @@ isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_failed_read_cb(sock, result);
return;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_failed_read_cb(sock, result);
- return;
default:
INSIST(0);
ISC_UNREACHABLE();
}
}
+void
+isc__nmsocket_connecttimeout_cb(uv_timer_t *timer) {
+ uv_connect_t *uvreq = uv_handle_get_data((uv_handle_t *)timer);
+ isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
+ isc__nm_uvreq_t *req = uv_handle_get_data((uv_handle_t *)uvreq);
+
+ REQUIRE(VALID_NMSOCK(sock));
+ REQUIRE(sock->tid == isc_nm_tid());
+ REQUIRE(atomic_load(&sock->connecting));
+ REQUIRE(VALID_UVREQ(req));
+ REQUIRE(VALID_NMHANDLE(req->handle));
+
+ isc__nmsocket_timer_stop(sock);
+
+ /* Call the connect callback directly */
+
+ req->cb.connect(req->handle, ISC_R_TIMEDOUT, req->cbarg);
+
+ /* Timer is not running, cleanup and shutdown everything */
+ if (!isc__nmsocket_timer_running(sock)) {
+ INSIST(atomic_compare_exchange_strong(&sock->connecting,
+ &(bool){ true }, false));
+ isc__nm_uvreq_put(&req, sock);
+ isc__nmsocket_clearcb(sock);
+ isc__nmsocket_shutdown(sock);
+ }
+}
+
static void
isc__nmsocket_readtimeout_cb(uv_timer_t *timer) {
isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)timer);
@@ -1653,27 +1984,62 @@ isc__nmsocket_readtimeout_cb(uv_timer_t *timer) {
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->reading);
- isc__nm_failed_read_cb(sock, ISC_R_TIMEDOUT);
+ if (atomic_load(&sock->client)) {
+ uv_timer_stop(timer);
+
+ if (sock->recv_cb != NULL) {
+ isc__nm_uvreq_t *req = isc__nm_get_read_req(sock, NULL);
+ isc__nm_readcb(sock, req, ISC_R_TIMEDOUT);
+ }
+
+ if (!isc__nmsocket_timer_running(sock)) {
+ isc__nmsocket_clearcb(sock);
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
+ }
+ } else {
+ isc__nm_failed_read_cb(sock, ISC_R_TIMEDOUT, false);
+ }
}
void
isc__nmsocket_timer_restart(isc_nmsocket_t *sock) {
+ int r = 0;
+
REQUIRE(VALID_NMSOCK(sock));
- if (sock->read_timeout == 0) {
- return;
+ if (atomic_load(&sock->connecting)) {
+ if (sock->connect_timeout == 0) {
+ return;
+ }
+
+ r = uv_timer_start(&sock->timer,
+ isc__nmsocket_connecttimeout_cb,
+ sock->connect_timeout + 10, 0);
+
+ } else {
+ if (sock->read_timeout == 0) {
+ return;
+ }
+
+ r = uv_timer_start(&sock->timer, isc__nmsocket_readtimeout_cb,
+ sock->read_timeout, 0);
}
- int r = uv_timer_start(&sock->timer, isc__nmsocket_readtimeout_cb,
- sock->read_timeout, 0);
RUNTIME_CHECK(r == 0);
}
+bool
+isc__nmsocket_timer_running(isc_nmsocket_t *sock) {
+ REQUIRE(VALID_NMSOCK(sock));
+
+ return (uv_is_active((uv_handle_t *)&sock->timer));
+}
+
void
isc__nmsocket_timer_start(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
- if (uv_is_active((uv_handle_t *)&sock->timer)) {
+ if (isc__nmsocket_timer_running(sock)) {
return;
}
@@ -1684,9 +2050,7 @@ void
isc__nmsocket_timer_stop(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
- if (!uv_is_active((uv_handle_t *)&sock->timer)) {
- return;
- }
+ /* uv_timer_stop() is idempotent, no need to check if running */
int r = uv_timer_stop(&sock->timer);
RUNTIME_CHECK(r == 0);
@@ -1700,13 +2064,20 @@ isc__nm_get_read_req(isc_nmsocket_t *sock, isc_sockaddr_t *sockaddr) {
req->cb.recv = sock->recv_cb;
req->cbarg = sock->recv_cbarg;
- if (atomic_load(&sock->client)) {
+ switch (sock->type) {
+ case isc_nm_tcpsocket:
isc_nmhandle_attach(sock->statichandle, &req->handle);
- } else {
- req->handle = isc__nmhandle_get(sock, sockaddr, NULL);
+ break;
+ default:
+ if (atomic_load(&sock->client)) {
+ isc_nmhandle_attach(sock->statichandle, &req->handle);
+ } else {
+ req->handle = isc__nmhandle_get(sock, sockaddr, NULL);
+ }
+ break;
}
- return req;
+ return (req);
}
/*%<
@@ -1728,25 +2099,16 @@ isc__nm_alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) {
REQUIRE(size <= ISC_NETMGR_RECVBUF_SIZE);
size = ISC_NETMGR_RECVBUF_SIZE;
break;
+ case isc_nm_tcpsocket:
case isc_nm_tcpdnssocket:
break;
- case isc_nm_tlsdnssocket:
- /*
- * We need to limit the individual chunks to be read, so the
- * BIO_write() will always succeed and the consumed before the
- * next readcb is called.
- */
- if (size >= ISC_NETMGR_TLSBUF_SIZE) {
- size = ISC_NETMGR_TLSBUF_SIZE;
- }
- break;
default:
INSIST(0);
ISC_UNREACHABLE();
}
worker = &sock->mgr->workers[sock->tid];
- INSIST(!worker->recvbuf_inuse);
+ INSIST(!worker->recvbuf_inuse || sock->type == isc_nm_udpsocket);
buf->base = worker->recvbuf;
buf->len = size;
@@ -1766,13 +2128,13 @@ isc__nm_start_reading(isc_nmsocket_t *sock) {
r = uv_udp_recv_start(&sock->uv_handle.udp, isc__nm_alloc_cb,
isc__nm_udp_read_cb);
break;
- case isc_nm_tcpdnssocket:
+ case isc_nm_tcpsocket:
r = uv_read_start(&sock->uv_handle.stream, isc__nm_alloc_cb,
- isc__nm_tcpdns_read_cb);
+ isc__nm_tcp_read_cb);
break;
- case isc_nm_tlsdnssocket:
+ case isc_nm_tcpdnssocket:
r = uv_read_start(&sock->uv_handle.stream, isc__nm_alloc_cb,
- isc__nm_tlsdns_read_cb);
+ isc__nm_tcpdns_read_cb);
break;
default:
INSIST(0);
@@ -1794,8 +2156,8 @@ isc__nm_stop_reading(isc_nmsocket_t *sock) {
case isc_nm_udpsocket:
r = uv_udp_recv_stop(&sock->uv_handle.udp);
break;
+ case isc_nm_tcpsocket:
case isc_nm_tcpdnssocket:
- case isc_nm_tlsdnssocket:
r = uv_read_stop(&sock->uv_handle.stream);
break;
default:
@@ -1807,7 +2169,12 @@ isc__nm_stop_reading(isc_nmsocket_t *sock) {
}
bool
-isc__nm_inactive(isc_nmsocket_t *sock) {
+isc__nm_closing(isc_nmsocket_t *sock) {
+ return (atomic_load(&sock->mgr->closing));
+}
+
+bool
+isc__nmsocket_closing(isc_nmsocket_t *sock) {
return (!isc__nmsocket_active(sock) || atomic_load(&sock->closing) ||
atomic_load(&sock->mgr->closing) ||
(sock->server != NULL && !isc__nmsocket_active(sock->server)));
@@ -1818,8 +2185,6 @@ processbuffer(isc_nmsocket_t *sock) {
switch (sock->type) {
case isc_nm_tcpdnssocket:
return (isc__nm_tcpdns_processbuffer(sock));
- case isc_nm_tlsdnssocket:
- return (isc__nm_tcpdns_processbuffer(sock));
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -1894,7 +2259,7 @@ isc__nm_resume_processing(void *arg) {
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(!atomic_load(&sock->client));
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
return;
}
@@ -1924,9 +2289,7 @@ isc_nmhandle_settimeout(isc_nmhandle_t *handle, uint32_t timeout) {
switch (handle->sock->type) {
default:
handle->sock->read_timeout = timeout;
- if (uv_is_active((uv_handle_t *)&handle->sock->timer)) {
- isc__nmsocket_timer_restart(handle->sock);
- }
+ isc__nmsocket_timer_restart(handle->sock);
}
}
@@ -2034,9 +2397,6 @@ isc_nm_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_send(handle, region, cb, cbarg);
break;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_send(handle, region, cb, cbarg);
- break;
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -2064,9 +2424,6 @@ isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_read(handle, cb, cbarg);
break;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_read(handle, cb, cbarg);
- break;
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -2087,9 +2444,6 @@ isc_nm_cancelread(isc_nmhandle_t *handle) {
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_cancelread(handle);
break;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_cancelread(handle);
- break;
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -2142,9 +2496,6 @@ isc_nm_stoplistening(isc_nmsocket_t *sock) {
case isc_nm_tcplistener:
isc__nm_tcp_stoplistening(sock);
break;
- case isc_nm_tlsdnslistener:
- isc__nm_tlsdns_stoplistening(sock);
- break;
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -2153,12 +2504,12 @@ isc_nm_stoplistening(isc_nmsocket_t *sock) {
void
isc__nm_connectcb(isc_nmsocket_t *sock, isc__nm_uvreq_t *uvreq,
- isc_result_t eresult) {
+ isc_result_t eresult, bool async) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(VALID_UVREQ(uvreq));
REQUIRE(VALID_NMHANDLE(uvreq->handle));
- if (eresult == ISC_R_SUCCESS) {
+ if (!async) {
isc__netievent_connectcb_t ievent = { .sock = sock,
.req = uvreq,
.result = eresult };
@@ -2199,7 +2550,7 @@ isc__nm_readcb(isc_nmsocket_t *sock, isc__nm_uvreq_t *uvreq,
REQUIRE(VALID_UVREQ(uvreq));
REQUIRE(VALID_NMHANDLE(uvreq->handle));
- if (eresult == ISC_R_SUCCESS) {
+ if (eresult == ISC_R_SUCCESS || eresult == ISC_R_TIMEDOUT) {
isc__netievent_readcb_t ievent = { .sock = sock,
.req = uvreq,
.result = eresult };
@@ -2302,23 +2653,8 @@ isc__nm_async_detach(isc__networker_t *worker, isc__netievent_t *ev0) {
nmhandle_detach_cb(&ievent->handle FLARG_PASS);
}
-static void
-shutdown_walk_cb(uv_handle_t *handle, void *arg) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
- UNUSED(arg);
-
- if (uv_is_closing(handle)) {
- return;
- }
-
- switch (handle->type) {
- case UV_UDP:
- case UV_TCP:
- break;
- default:
- return;
- }
-
+void
+isc__nmsocket_shutdown(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
switch (sock->type) {
case isc_nm_udpsocket:
@@ -2330,13 +2666,9 @@ shutdown_walk_cb(uv_handle_t *handle, void *arg) {
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_shutdown(sock);
break;
- case isc_nm_tlsdnssocket:
- isc__nm_tlsdns_shutdown(sock);
- break;
case isc_nm_udplistener:
case isc_nm_tcplistener:
case isc_nm_tcpdnslistener:
- case isc_nm_tlsdnslistener:
return;
default:
INSIST(0);
@@ -2344,6 +2676,26 @@ shutdown_walk_cb(uv_handle_t *handle, void *arg) {
}
}
+static void
+shutdown_walk_cb(uv_handle_t *handle, void *arg) {
+ isc_nmsocket_t *sock = uv_handle_get_data(handle);
+ UNUSED(arg);
+
+ if (uv_is_closing(handle)) {
+ return;
+ }
+
+ switch (handle->type) {
+ case UV_UDP:
+ case UV_TCP:
+ break;
+ default:
+ return;
+ }
+
+ isc__nmsocket_shutdown(sock);
+}
+
void
isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ev0) {
UNUSED(ev0);
@@ -2352,28 +2704,43 @@ isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ev0) {
bool
isc__nm_acquire_interlocked(isc_nm_t *mgr) {
+ if (!isc__nm_in_netthread()) {
+ return (false);
+ }
+
LOCK(&mgr->lock);
- bool success = atomic_compare_exchange_strong(&mgr->interlocked,
- &(bool){ false }, true);
+ bool success = atomic_compare_exchange_strong(
+ &mgr->interlocked, &(int){ ISC_NETMGR_NON_INTERLOCKED },
+ isc_nm_tid());
+
UNLOCK(&mgr->lock);
return (success);
}
void
isc__nm_drop_interlocked(isc_nm_t *mgr) {
+ if (!isc__nm_in_netthread()) {
+ return;
+ }
+
LOCK(&mgr->lock);
- bool success = atomic_compare_exchange_strong(&mgr->interlocked,
- &(bool){ true }, false);
- INSIST(success);
+ int tid = atomic_exchange(&mgr->interlocked,
+ ISC_NETMGR_NON_INTERLOCKED);
+ INSIST(tid != ISC_NETMGR_NON_INTERLOCKED);
BROADCAST(&mgr->wkstatecond);
UNLOCK(&mgr->lock);
}
void
isc__nm_acquire_interlocked_force(isc_nm_t *mgr) {
+ if (!isc__nm_in_netthread()) {
+ return;
+ }
+
LOCK(&mgr->lock);
- while (!atomic_compare_exchange_strong(&mgr->interlocked,
- &(bool){ false }, true))
+ while (!atomic_compare_exchange_strong(
+ &mgr->interlocked, &(int){ ISC_NETMGR_NON_INTERLOCKED },
+ isc_nm_tid()))
{
WAIT(&mgr->wkstatecond, &mgr->lock);
}
@@ -2458,7 +2825,7 @@ isc__nm_closesocket(uv_os_sock_t sock) {
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
#define setsockopt_off(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
+ setsockopt(socket, level, name, &(int){ 0 }, sizeof(int))
isc_result_t
isc__nm_socket_freebind(uv_os_sock_t fd, sa_family_t sa_family) {
@@ -2579,9 +2946,9 @@ isc__nm_socket_incoming_cpu(uv_os_sock_t fd) {
}
isc_result_t
-isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) {
+isc__nm_socket_disable_pmtud(uv_os_sock_t fd, sa_family_t sa_family) {
/*
- * Set the Don't Fragment flag on IP packets
+ * Disable the Path MTU Discovery on IP packets
*/
if (sa_family == AF_INET6) {
#if defined(IPV6_DONTFRAG)
@@ -2598,14 +2965,6 @@ isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) {
} else {
return (ISC_R_SUCCESS);
}
-#elif defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
- if (setsockopt(fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
- &(int){ IP_PMTUDISC_DONT }, sizeof(int)) == -1)
- {
- return (ISC_R_FAILURE);
- } else {
- return (ISC_R_SUCCESS);
- }
#else
UNUSED(fd);
#endif
@@ -2624,14 +2983,6 @@ isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) {
} else {
return (ISC_R_SUCCESS);
}
-#elif defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
- if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER,
- &(int){ IP_PMTUDISC_DONT }, sizeof(int)) == -1)
- {
- return (ISC_R_FAILURE);
- } else {
- return (ISC_R_SUCCESS);
- }
#else
UNUSED(fd);
#endif
@@ -2688,6 +3039,87 @@ isc__nm_socket_connectiontimeout(uv_os_sock_t fd, int timeout_ms) {
#endif
}
+isc_result_t
+isc__nm_socket_tcp_nodelay(uv_os_sock_t fd) {
+#ifdef TCP_NODELAY
+ if (setsockopt_on(fd, IPPROTO_TCP, TCP_NODELAY) == -1) {
+ return (ISC_R_FAILURE);
+ } else {
+ return (ISC_R_SUCCESS);
+ }
+#else
+ UNUSED(fd);
+ return (ISC_R_SUCCESS);
+#endif
+}
+
+static isc_threadresult_t
+isc__nm_work_run(isc_threadarg_t arg) {
+ isc__nm_work_t *work = (isc__nm_work_t *)arg;
+
+ work->cb(work->data);
+
+ return ((isc_threadresult_t)0);
+}
+
+static void
+isc__nm_work_cb(uv_work_t *req) {
+ isc__nm_work_t *work = uv_req_get_data((uv_req_t *)req);
+
+ if (isc_tid_v == SIZE_MAX) {
+ isc__trampoline_t *trampoline_arg =
+ isc__trampoline_get(isc__nm_work_run, work);
+ (void)isc__trampoline_run(trampoline_arg);
+ } else {
+ (void)isc__nm_work_run((isc_threadarg_t)work);
+ }
+}
+
+static void
+isc__nm_after_work_cb(uv_work_t *req, int status) {
+ isc_result_t result = ISC_R_SUCCESS;
+ isc__nm_work_t *work = uv_req_get_data((uv_req_t *)req);
+ isc_nm_t *netmgr = work->netmgr;
+
+ if (status != 0) {
+ result = isc__nm_uverr2result(status);
+ }
+
+ work->after_cb(work->data, result);
+
+ isc_mem_put(netmgr->mctx, work, sizeof(*work));
+
+ isc_nm_detach(&netmgr);
+}
+
+void
+isc_nm_work_offload(isc_nm_t *netmgr, isc_nm_workcb_t work_cb,
+ isc_nm_after_workcb_t after_work_cb, void *data) {
+ isc__networker_t *worker = NULL;
+ isc__nm_work_t *work = NULL;
+ int r;
+
+ REQUIRE(isc__nm_in_netthread());
+ REQUIRE(VALID_NM(netmgr));
+
+ worker = &netmgr->workers[isc_nm_tid()];
+
+ work = isc_mem_get(netmgr->mctx, sizeof(*work));
+ *work = (isc__nm_work_t){
+ .cb = work_cb,
+ .after_cb = after_work_cb,
+ .data = data,
+ };
+
+ isc_nm_attach(netmgr, &work->netmgr);
+
+ uv_req_set_data((uv_req_t *)&work->req, work);
+
+ r = uv_queue_work(&worker->loop, &work->req, isc__nm_work_cb,
+ isc__nm_after_work_cb);
+ RUNTIME_CHECK(r == 0);
+}
+
#ifdef NETMGR_TRACE
/*
* Dump all active sockets in netmgr. We output to stderr
@@ -2709,10 +3141,6 @@ nmsocket_type_totext(isc_nmsocket_type type) {
return ("isc_nm_tcpdnslistener");
case isc_nm_tcpdnssocket:
return ("isc_nm_tcpdnssocket");
- case isc_nm_tlsdnslistener:
- return ("isc_nm_tlsdnslistener");
- case isc_nm_tlsdnssocket:
- return ("isc_nm_tlsdnssocket");
default:
INSIST(0);
ISC_UNREACHABLE();
@@ -2721,7 +3149,7 @@ nmsocket_type_totext(isc_nmsocket_type type) {
static void
nmhandle_dump(isc_nmhandle_t *handle) {
- fprintf(stderr, "Active handle %p, refs %lu\n", handle,
+ fprintf(stderr, "Active handle %p, refs %" PRIuFAST32 "\n", handle,
isc_refcount_current(&handle->references));
fprintf(stderr, "Created by:\n");
backtrace_symbols_fd(handle->backtrace, handle->backtrace_size,
@@ -2735,17 +3163,19 @@ nmsocket_dump(isc_nmsocket_t *sock) {
LOCK(&sock->lock);
fprintf(stderr, "\n=================\n");
- fprintf(stderr, "Active %s socket %p, type %s, refs %lu\n",
- sock->client ? "client" : "server", sock,
+ fprintf(stderr, "Active %s socket %p, type %s, refs %" PRIuFAST32 "\n",
+ atomic_load(&sock->client) ? "client" : "server", sock,
nmsocket_type_totext(sock->type),
isc_refcount_current(&sock->references));
fprintf(stderr,
- "Parent %p, listener %p, server %p, statichandle = %p\n",
+ "Parent %p, listener %p, server %p, statichandle = "
+ "%p\n",
sock->parent, sock->listener, sock->server, sock->statichandle);
- fprintf(stderr, "Flags:%s%s%s%s%s\n", sock->active ? " active" : "",
- sock->closing ? " closing" : "",
- sock->destroying ? " destroying" : "",
- sock->connecting ? " connecting" : "",
+ fprintf(stderr, "Flags:%s%s%s%s%s\n",
+ atomic_load(&sock->active) ? " active" : "",
+ atomic_load(&sock->closing) ? " closing" : "",
+ atomic_load(&sock->destroying) ? " destroying" : "",
+ atomic_load(&sock->connecting) ? " connecting" : "",
sock->accepting ? " accepting" : "");
fprintf(stderr, "Created by:\n");
backtrace_symbols_fd(sock->backtrace, sock->backtrace_size,
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/tcp.c b/external/mpl/bind/dist/lib/isc/netmgr/tcp.c
index 42cdac4d34c..d30147aa528 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/tcp.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/tcp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp.c,v 1.5 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: tcp.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,6 +16,7 @@
#include <uv.h>
#include <isc/atomic.h>
+#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/errno.h>
@@ -66,9 +67,6 @@ static void
tcp_connection_cb(uv_stream_t *server, int status);
static void
-read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
-
-static void
tcp_close_cb(uv_handle_t *uvhandle);
static isc_result_t
@@ -89,25 +87,6 @@ static void
stop_tcp_child(isc_nmsocket_t *sock);
static void
-start_reading(isc_nmsocket_t *sock);
-
-static void
-stop_reading(isc_nmsocket_t *sock);
-
-static isc__nm_uvreq_t *
-get_read_req(isc_nmsocket_t *sock);
-
-static void
-tcp_alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf);
-
-static bool
-inactive(isc_nmsocket_t *sock) {
- return (!isc__nmsocket_active(sock) || atomic_load(&sock->closing) ||
- atomic_load(&sock->mgr->closing) ||
- (sock->server != NULL && !isc__nmsocket_active(sock->server)));
-}
-
-static void
failed_accept_cb(isc_nmsocket_t *sock, isc_result_t eresult) {
REQUIRE(sock->accepting);
REQUIRE(sock->server);
@@ -137,27 +116,10 @@ failed_accept_cb(isc_nmsocket_t *sock, isc_result_t eresult) {
}
}
-static void
-failed_connect_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
- isc_result_t eresult) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(VALID_UVREQ(req));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->connecting));
- REQUIRE(req->cb.connect != NULL);
-
- atomic_store(&sock->connecting, false);
-
- isc__nmsocket_clearcb(sock);
- isc__nm_connectcb(sock, req, eresult);
-
- isc__nmsocket_prep_destroy(sock);
-}
-
static isc_result_t
tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
isc__networker_t *worker = NULL;
- isc_result_t result = ISC_R_DEFAULT;
+ isc_result_t result = ISC_R_UNSET;
int r;
REQUIRE(VALID_NMSOCK(sock));
@@ -170,13 +132,16 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
atomic_store(&sock->connecting, true);
+ /* 2 minute timeout */
+ result = isc__nm_socket_connectiontimeout(sock->fd, 120 * 1000);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+
r = uv_tcp_init(&worker->loop, &sock->uv_handle.tcp);
RUNTIME_CHECK(r == 0);
uv_handle_set_data(&sock->uv_handle.handle, sock);
r = uv_timer_init(&worker->loop, &sock->timer);
RUNTIME_CHECK(r == 0);
- uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
r = uv_tcp_open(&sock->uv_handle.tcp, sock->fd);
if (r != 0) {
@@ -205,11 +170,13 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
}
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
+ uv_handle_set_data((uv_handle_t *)&sock->timer, &req->uv_req.connect);
+ isc__nmsocket_timer_start(sock);
+
atomic_store(&sock->connected, true);
done:
result = isc__nm_uverr2result(r);
-
LOCK(&sock->lock);
sock->result = result;
SIGNAL(&sock->cond);
@@ -234,15 +201,16 @@ isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpsocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent == NULL);
REQUIRE(sock->tid == isc_nm_tid());
result = tcp_connect_direct(sock, req);
if (result != ISC_R_SUCCESS) {
atomic_store(&sock->active, false);
- isc__nm_tcp_close(sock);
- isc__nm_uvreq_put(&req, sock);
+ if (sock->fd != (uv_os_sock_t)(-1)) {
+ isc__nm_tcp_close(sock);
+ }
+ isc__nm_connectcb(sock, req, result, true);
}
/*
@@ -261,20 +229,35 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->connecting));
+
+ isc__nmsocket_timer_stop(sock);
+ uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
+
+ if (!atomic_load(&sock->connecting)) {
+ return;
+ }
req = uv_handle_get_data((uv_handle_t *)uvreq);
REQUIRE(VALID_UVREQ(req));
REQUIRE(VALID_NMHANDLE(req->handle));
- /* Socket was closed midflight by isc__nm_tcp_shutdown() */
- if (!isc__nmsocket_active(sock)) {
+ if (!atomic_load(&sock->connecting)) {
+ /*
+ * The connect was cancelled from timeout; just clean up
+ * the req.
+ */
+ isc__nm_uvreq_put(&req, sock);
+ return;
+ } else if (isc__nmsocket_closing(sock)) {
+ /* Socket was closed midflight by isc__nm_tcp_shutdown() */
result = ISC_R_CANCELED;
goto error;
- }
-
- if (status != 0) {
+ } else if (status == UV_ETIMEDOUT) {
+ /* Timeout status code here indicates hard error */
+ result = ISC_R_TIMEDOUT;
+ goto error;
+ } else if (status != 0) {
result = isc__nm_uverr2result(status);
goto error;
}
@@ -292,16 +275,16 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
result = isc_sockaddr_fromsockaddr(&sock->peer, (struct sockaddr *)&ss);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
- isc__nm_connectcb(sock, req, ISC_R_SUCCESS);
+ isc__nm_connectcb(sock, req, ISC_R_SUCCESS, false);
return;
error:
- failed_connect_cb(sock, req, result);
+ isc__nm_failed_connect_cb(sock, req, result, false);
}
-isc_result_t
-isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_tcpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize) {
isc_result_t result = ISC_R_SUCCESS;
@@ -309,41 +292,44 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
isc__netievent_tcpconnect_t *ievent = NULL;
isc__nm_uvreq_t *req = NULL;
sa_family_t sa_family;
- uv_os_sock_t fd;
REQUIRE(VALID_NM(mgr));
REQUIRE(local != NULL);
REQUIRE(peer != NULL);
- sa_family = peer->addr.type.sa.sa_family;
-
- /*
- * The socket() call can fail spuriously on FreeBSD 12, so we need to
- * handle the failure early and gracefully.
- */
- result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &fd);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ sa_family = peer->type.sa.sa_family;
sock = isc_mem_get(mgr->mctx, sizeof(*sock));
isc__nmsocket_init(sock, mgr, isc_nm_tcpsocket, local);
sock->extrahandlesize = extrahandlesize;
sock->connect_timeout = timeout;
- sock->result = ISC_R_DEFAULT;
- sock->fd = fd;
+ sock->result = ISC_R_UNSET;
+ sock->fd = (uv_os_sock_t)-1;
atomic_init(&sock->client, true);
- result = isc__nm_socket_connectiontimeout(fd, timeout);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
req = isc__nm_uvreq_get(mgr, sock);
req->cb.connect = cb;
req->cbarg = cbarg;
- req->peer = peer->addr;
- req->local = local->addr;
- req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface->addr);
+ req->peer = *peer;
+ req->local = *local;
+ req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface);
+
+ result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &sock->fd);
+ if (result != ISC_R_SUCCESS) {
+ if (isc__nm_in_netthread()) {
+ sock->tid = isc_nm_tid();
+ isc__nmsocket_clearcb(sock);
+ isc__nm_connectcb(sock, req, result, false);
+ } else {
+ isc__nmsocket_clearcb(sock);
+ sock->tid = isc_random_uniform(mgr->nworkers);
+ isc__nm_connectcb(sock, req, result, true);
+ }
+ atomic_store(&sock->closed, true);
+ isc__nmsocket_detach(&sock);
+ return;
+ }
ievent = isc__nm_get_netievent_tcpconnect(mgr, sock, req);
@@ -360,17 +346,12 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
(isc__netievent_t *)ievent);
}
LOCK(&sock->lock);
- result = sock->result;
- while (result == ISC_R_DEFAULT) {
+ while (sock->result == ISC_R_UNSET) {
WAIT(&sock->cond, &sock->lock);
- result = sock->result;
}
atomic_store(&sock->active, true);
BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
-
- return (result);
}
static uv_os_sock_t
@@ -396,25 +377,63 @@ isc__nm_tcp_lb_socket(sa_family_t sa_family) {
return (sock);
}
+static void
+start_tcp_child(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nmsocket_t *sock,
+ uv_os_sock_t fd, int tid) {
+ isc__netievent_tcplisten_t *ievent = NULL;
+ isc_nmsocket_t *csock = &sock->children[tid];
+
+ isc__nmsocket_init(csock, mgr, isc_nm_tcpsocket, iface);
+ csock->parent = sock;
+ csock->accept_cb = sock->accept_cb;
+ csock->accept_cbarg = sock->accept_cbarg;
+ csock->extrahandlesize = sock->extrahandlesize;
+ csock->backlog = sock->backlog;
+ csock->tid = tid;
+ /*
+ * We don't attach to quota, just assign - to avoid
+ * increasing quota unnecessarily.
+ */
+ csock->pquota = sock->pquota;
+ isc_quota_cb_init(&csock->quotacb, quota_accept_cb, csock);
+
+#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
+ UNUSED(fd);
+ csock->fd = isc__nm_tcp_lb_socket(iface->type.sa.sa_family);
+#else
+ csock->fd = dup(fd);
+#endif
+ REQUIRE(csock->fd >= 0);
+
+ ievent = isc__nm_get_netievent_tcplisten(mgr, csock);
+ isc__nm_maybe_enqueue_ievent(&mgr->workers[tid],
+ (isc__netievent_t *)ievent);
+}
+
+static void
+enqueue_stoplistening(isc_nmsocket_t *sock) {
+ isc__netievent_tcpstop_t *ievent =
+ isc__nm_get_netievent_tcpstop(sock->mgr, sock);
+ isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
+}
+
isc_result_t
-isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
+isc_nm_listentcp(isc_nm_t *mgr, isc_sockaddr_t *iface,
isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
size_t extrahandlesize, int backlog, isc_quota_t *quota,
isc_nmsocket_t **sockp) {
isc_result_t result = ISC_R_SUCCESS;
isc_nmsocket_t *sock = NULL;
- sa_family_t sa_family = iface->addr.type.sa.sa_family;
size_t children_size = 0;
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
uv_os_sock_t fd = -1;
-#endif
REQUIRE(VALID_NM(mgr));
sock = isc_mem_get(mgr->mctx, sizeof(*sock));
isc__nmsocket_init(sock, mgr, isc_nm_tcplistener, iface);
- sock->rchildren = 0;
+ atomic_init(&sock->rchildren, 0);
#if defined(WIN32)
sock->nchildren = 1;
#else
@@ -424,42 +443,32 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
sock->children = isc_mem_get(mgr->mctx, children_size);
memset(sock->children, 0, children_size);
- sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(sock->nchildren);
+ sock->result = ISC_R_UNSET;
+
+ sock->accept_cb = accept_cb;
+ sock->accept_cbarg = accept_cbarg;
+ sock->extrahandlesize = extrahandlesize;
+ sock->backlog = backlog;
+ sock->pquota = quota;
+
+ sock->tid = 0;
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- fd = isc__nm_tcp_lb_socket(sa_family);
+ fd = isc__nm_tcp_lb_socket(iface->type.sa.sa_family);
#endif
- for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tcplisten_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
-
- isc__nmsocket_init(csock, mgr, isc_nm_tcpsocket, iface);
- csock->parent = sock;
- csock->accept_cb = accept_cb;
- csock->accept_cbarg = accept_cbarg;
- csock->extrahandlesize = extrahandlesize;
- csock->backlog = backlog;
- csock->tid = i;
- /*
- * We don't attach to quota, just assign - to avoid
- * increasing quota unnecessarily.
- */
- csock->pquota = quota;
- isc_quota_cb_init(&csock->quotacb, quota_accept_cb, csock);
+ isc_barrier_init(&sock->startlistening, sock->nchildren);
-#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- csock->fd = isc__nm_tcp_lb_socket(sa_family);
-#else
- csock->fd = dup(fd);
-#endif
- REQUIRE(csock->fd >= 0);
+ for (size_t i = 0; i < sock->nchildren; i++) {
+ if ((int)i == isc_nm_tid()) {
+ continue;
+ }
+ start_tcp_child(mgr, iface, sock, fd, i);
+ }
- ievent = isc__nm_get_netievent_tcplisten(mgr, csock);
- isc__nm_enqueue_ievent(&mgr->workers[i],
- (isc__netievent_t *)ievent);
+ if (isc__nm_in_netthread()) {
+ start_tcp_child(mgr, iface, sock, fd, isc_nm_tid());
}
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
@@ -467,21 +476,21 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
#endif
LOCK(&sock->lock);
- while (sock->rchildren != sock->nchildren) {
+ while (atomic_load(&sock->rchildren) != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
atomic_store(&sock->active, true);
- BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
+
+ INSIST(result != ISC_R_UNSET);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == sock->nchildren);
+ REQUIRE(atomic_load(&sock->rchildren) == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
- isc__nm_tcp_stoplistening(sock);
+ enqueue_stoplistening(sock);
isc_nmsocket_close(&sock);
}
@@ -491,7 +500,6 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface,
void
isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_tcplisten_t *ievent = (isc__netievent_tcplisten_t *)ev0;
- isc_nmiface_t *iface = NULL;
sa_family_t sa_family;
int r;
int flags = 0;
@@ -503,11 +511,9 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(ievent->sock->parent));
sock = ievent->sock;
- iface = sock->iface;
- sa_family = iface->addr.type.sa.sa_family;
+ sa_family = sock->iface.type.sa.sa_family;
REQUIRE(sock->type == isc_nm_tcpsocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent != NULL);
REQUIRE(sock->tid == isc_nm_tid());
@@ -540,8 +546,8 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
}
#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
+ r = isc_uv_tcp_freebind(&sock->uv_handle.tcp, &sock->iface.type.sa,
+ flags);
if (r < 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
goto done;
@@ -549,7 +555,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
#else
if (sock->parent->fd == -1) {
r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
+ &sock->iface.type.sa, flags);
if (r < 0) {
isc__nm_incstats(sock->mgr,
sock->statsindex[STATID_BINDFAIL]);
@@ -586,16 +592,14 @@ done:
sock->pquota = NULL;
}
- sock->parent->rchildren += 1;
- if (sock->parent->result == ISC_R_DEFAULT) {
+ atomic_fetch_add(&sock->parent->rchildren, 1);
+ if (sock->parent->result == ISC_R_UNSET) {
sock->parent->result = result;
}
SIGNAL(&sock->parent->cond);
- if (!atomic_load(&sock->parent->active)) {
- WAIT(&sock->parent->scond, &sock->parent->lock);
- }
- INSIST(atomic_load(&sock->parent->active));
UNLOCK(&sock->parent->lock);
+
+ isc_barrier_wait(&sock->parent->startlistening);
}
static void
@@ -612,7 +616,7 @@ tcp_connection_cb(uv_stream_t *server, int status) {
REQUIRE(VALID_NMSOCK(ssock));
REQUIRE(ssock->tid == isc_nm_tid());
- if (inactive(ssock)) {
+ if (isc__nmsocket_closing(ssock)) {
result = ISC_R_CANCELED;
goto done;
}
@@ -640,14 +644,6 @@ done:
}
}
-static void
-enqueue_stoplistening(isc_nmsocket_t *sock) {
- isc__netievent_tcpstop_t *ievent =
- isc__nm_get_netievent_tcpstop(sock->mgr, sock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
void
isc__nm_tcp_stoplistening(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
@@ -658,7 +654,12 @@ isc__nm_tcp_stoplistening(isc_nmsocket_t *sock) {
INSIST(0);
ISC_UNREACHABLE();
}
- enqueue_stoplistening(sock);
+
+ if (!isc__nm_in_netthread()) {
+ enqueue_stoplistening(sock);
+ } else {
+ stop_tcp_parent(sock);
+ }
}
void
@@ -676,23 +677,16 @@ isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0) {
return;
}
- /*
- * If network manager is interlocked, re-enqueue the event for later.
- */
- if (!isc__nm_acquire_interlocked(sock->mgr)) {
- enqueue_stoplistening(sock);
- } else {
- stop_tcp_parent(sock);
- isc__nm_drop_interlocked(sock->mgr);
- }
+ stop_tcp_parent(sock);
}
-static void
-failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
+void
+isc__nm_tcp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->statichandle != NULL);
+ REQUIRE(result != ISC_R_SUCCESS);
- stop_reading(sock);
+ isc__nmsocket_timer_stop(sock);
+ isc__nm_stop_reading(sock);
if (!sock->recv_read) {
goto destroy;
@@ -700,7 +694,7 @@ failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
sock->recv_read = false;
if (sock->recv_cb != NULL) {
- isc__nm_uvreq_t *req = get_read_req(sock);
+ isc__nm_uvreq_t *req = isc__nm_get_read_req(sock, NULL);
isc__nmsocket_clearcb(sock);
isc__nm_readcb(sock, req, result);
}
@@ -708,18 +702,15 @@ failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
destroy:
isc__nmsocket_prep_destroy(sock);
- /* We need to detach from quota after the read callback function had a
- * chance to be executed. */
- if (sock->quota) {
+ /*
+ * We need to detach from quota after the read callback function had a
+ * chance to be executed.
+ */
+ if (sock->quota != NULL) {
isc_quota_detach(&sock->quota);
}
}
-void
-isc__nm_tcp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
- failed_read_cb(sock, result);
-}
-
static void
failed_send_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
isc_result_t eresult) {
@@ -733,42 +724,6 @@ failed_send_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
}
}
-static isc__nm_uvreq_t *
-get_read_req(isc_nmsocket_t *sock) {
- isc__nm_uvreq_t *req = NULL;
-
- req = isc__nm_uvreq_get(sock->mgr, sock);
- req->cb.recv = sock->recv_cb;
- req->cbarg = sock->recv_cbarg;
- isc_nmhandle_attach(sock->statichandle, &req->handle);
-
- return req;
-}
-
-static void
-start_reading(isc_nmsocket_t *sock) {
- if (sock->reading) {
- return;
- }
-
- int r = uv_read_start(&sock->uv_handle.stream, tcp_alloc_cb, read_cb);
- REQUIRE(r == 0);
- sock->reading = true;
-}
-
-static void
-stop_reading(isc_nmsocket_t *sock) {
- if (!sock->reading) {
- return;
- }
-
- int r = uv_read_stop(&sock->uv_handle.stream);
- REQUIRE(r == 0);
- sock->reading = false;
-
- isc__nmsocket_timer_stop(sock);
-}
-
void
isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
REQUIRE(VALID_NMHANDLE(handle));
@@ -806,32 +761,6 @@ isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
return;
}
-/*%<
- * Allocator for TCP read operations. Limited to size 2^16.
- *
- * Note this doesn't actually allocate anything, it just assigns the
- * worker's receive buffer to a socket, and marks it as "in use".
- */
-static void
-tcp_alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
- isc__networker_t *worker = NULL;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tcpsocket);
- REQUIRE(isc__nm_in_netthread());
- if (size > 65536) {
- size = 65536;
- }
-
- worker = &sock->mgr->workers[sock->tid];
- INSIST(!worker->recvbuf_inuse);
-
- buf->base = worker->recvbuf;
- buf->len = size;
- worker->recvbuf_inuse = true;
-}
-
void
isc__nm_async_tcpstartread(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_tcpstartread_t *ievent =
@@ -842,23 +771,24 @@ isc__nm_async_tcpstartread(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(sock->tid == isc_nm_tid());
UNUSED(worker);
- if (inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
sock->reading = true;
- failed_read_cb(sock, ISC_R_CANCELED);
+ isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED);
return;
}
- start_reading(sock);
+ isc__nm_start_reading(sock);
isc__nmsocket_timer_start(sock);
}
void
isc__nm_tcp_pauseread(isc_nmhandle_t *handle) {
+ isc__netievent_tcppauseread_t *ievent = NULL;
+ isc_nmsocket_t *sock = NULL;
+
REQUIRE(VALID_NMHANDLE(handle));
- REQUIRE(VALID_NMSOCK(handle->sock));
- isc__netievent_tcppauseread_t *ievent = NULL;
- isc_nmsocket_t *sock = handle->sock;
+ sock = handle->sock;
REQUIRE(VALID_NMSOCK(sock));
@@ -885,7 +815,8 @@ isc__nm_async_tcppauseread(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(sock->tid == isc_nm_tid());
UNUSED(worker);
- stop_reading(sock);
+ isc__nmsocket_timer_stop(sock);
+ isc__nm_stop_reading(sock);
}
void
@@ -905,7 +836,7 @@ isc__nm_tcp_resumeread(isc_nmhandle_t *handle) {
if (!isc__nmsocket_active(sock)) {
sock->reading = true;
- failed_read_cb(sock, ISC_R_CANCELED);
+ isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED);
return;
}
@@ -920,8 +851,8 @@ isc__nm_tcp_resumeread(isc_nmhandle_t *handle) {
(isc__netievent_t *)ievent);
}
-static void
-read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
+void
+isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)stream);
isc__nm_uvreq_t *req = NULL;
@@ -930,8 +861,8 @@ read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
REQUIRE(sock->reading);
REQUIRE(buf != NULL);
- if (inactive(sock)) {
- failed_read_cb(sock, ISC_R_CANCELED);
+ if (isc__nmsocket_closing(sock)) {
+ isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED);
goto free;
}
@@ -941,12 +872,12 @@ read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
sock->statsindex[STATID_RECVFAIL]);
}
- failed_read_cb(sock, isc__nm_uverr2result(nread));
+ isc__nm_tcp_failed_read_cb(sock, isc__nm_uverr2result(nread));
goto free;
}
- req = get_read_req(sock);
+ req = isc__nm_get_read_req(sock, NULL);
/*
* The callback will be called synchronously because the
@@ -1029,7 +960,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
REQUIRE(VALID_NMSOCK(ssock));
REQUIRE(ssock->tid == isc_nm_tid());
- if (inactive(ssock)) {
+ if (isc__nmsocket_closing(ssock)) {
if (quota != NULL) {
isc_quota_detach(&quota);
}
@@ -1037,7 +968,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
}
csock = isc_mem_get(ssock->mgr->mctx, sizeof(isc_nmsocket_t));
- isc__nmsocket_init(csock, ssock->mgr, isc_nm_tcpsocket, ssock->iface);
+ isc__nmsocket_init(csock, ssock->mgr, isc_nm_tcpsocket, &ssock->iface);
csock->tid = ssock->tid;
csock->extrahandlesize = ssock->extrahandlesize;
isc__nmsocket_attach(ssock, &csock->server);
@@ -1129,8 +1060,8 @@ failure:
}
void
-isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
- void *cbarg) {
+isc__nm_tcp_send(isc_nmhandle_t *handle, const isc_region_t *region,
+ isc_nm_cb_t cb, void *cbarg) {
REQUIRE(VALID_NMHANDLE(handle));
REQUIRE(VALID_NMSOCK(handle->sock));
@@ -1159,11 +1090,11 @@ isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
static void
tcp_send_cb(uv_write_t *req, int status) {
isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
- isc_nmsocket_t *sock = uvreq->sock;
-
REQUIRE(VALID_UVREQ(uvreq));
REQUIRE(VALID_NMHANDLE(uvreq->handle));
+ isc_nmsocket_t *sock = uvreq->sock;
+
if (status < 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_SENDFAIL]);
failed_send_cb(sock, uvreq, isc__nm_uverr2result(status));
@@ -1203,7 +1134,7 @@ tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
int r;
- if (inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
return (ISC_R_CANCELED);
}
@@ -1239,10 +1170,7 @@ tcp_stop_cb(uv_handle_t *handle) {
}
static void
-tcp_close_cb(uv_handle_t *handle) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
- uv_handle_set_data(handle, NULL);
-
+tcp_close_sock(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(atomic_load(&sock->closing));
@@ -1265,12 +1193,22 @@ tcp_close_cb(uv_handle_t *handle) {
}
static void
+tcp_close_cb(uv_handle_t *handle) {
+ isc_nmsocket_t *sock = uv_handle_get_data(handle);
+ uv_handle_set_data(handle, NULL);
+
+ tcp_close_sock(sock);
+}
+
+static void
timer_close_cb(uv_handle_t *handle) {
isc_nmsocket_t *sock = uv_handle_get_data(handle);
uv_handle_set_data(handle, NULL);
if (sock->parent) {
uv_close(&sock->uv_handle.handle, tcp_stop_cb);
+ } else if (uv_is_closing(&sock->uv_handle.handle)) {
+ tcp_close_sock(sock);
} else {
uv_close(&sock->uv_handle.handle, tcp_close_cb);
}
@@ -1288,41 +1226,41 @@ stop_tcp_child(isc_nmsocket_t *sock) {
tcp_close_direct(sock);
- LOCK(&sock->parent->lock);
- sock->parent->rchildren -= 1;
- UNLOCK(&sock->parent->lock);
- BROADCAST(&sock->parent->cond);
+ atomic_fetch_sub(&sock->parent->rchildren, 1);
+
+ isc_barrier_wait(&sock->parent->stoplistening);
}
static void
stop_tcp_parent(isc_nmsocket_t *sock) {
+ isc_nmsocket_t *csock = NULL;
+
REQUIRE(VALID_NMSOCK(sock));
+ REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->type == isc_nm_tcplistener);
+ isc_barrier_init(&sock->stoplistening, sock->nchildren);
+
for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tcpstop_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
+ csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
- atomic_store(&csock->active, false);
-
- if (csock->tid == isc_nm_tid()) {
- stop_tcp_child(csock);
+ if ((int)i == isc_nm_tid()) {
+ /*
+ * We need to schedule closing the other sockets first
+ */
continue;
}
- ievent = isc__nm_get_netievent_tcpstop(sock->mgr, csock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[csock->tid],
- (isc__netievent_t *)ievent);
+ atomic_store(&csock->active, false);
+ enqueue_stoplistening(csock);
}
- LOCK(&sock->lock);
- while (sock->rchildren > 0) {
- WAIT(&sock->cond, &sock->lock);
- }
- atomic_store(&sock->closed, true);
- UNLOCK(&sock->lock);
+ csock = &sock->children[isc_nm_tid()];
+ atomic_store(&csock->active, false);
+ stop_tcp_child(csock);
+ atomic_store(&sock->closed, true);
isc__nmsocket_prep_destroy(sock);
}
@@ -1346,7 +1284,10 @@ tcp_close_direct(isc_nmsocket_t *sock) {
isc_quota_detach(&sock->quota);
}
- stop_reading(sock);
+ isc__nmsocket_timer_stop(sock);
+ isc__nm_stop_reading(sock);
+
+ uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
uv_close((uv_handle_t *)&sock->timer, timer_close_cb);
}
@@ -1388,6 +1329,19 @@ isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0) {
tcp_close_direct(sock);
}
+static void
+tcp_close_connect_cb(uv_handle_t *handle) {
+ isc_nmsocket_t *sock = uv_handle_get_data(handle);
+
+ REQUIRE(VALID_NMSOCK(sock));
+
+ REQUIRE(isc__nm_in_netthread());
+ REQUIRE(sock->tid == isc_nm_tid());
+
+ isc__nmsocket_prep_destroy(sock);
+ isc__nmsocket_detach(&sock);
+}
+
void
isc__nm_tcp_shutdown(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
@@ -1402,12 +1356,19 @@ isc__nm_tcp_shutdown(isc_nmsocket_t *sock) {
return;
}
- if (atomic_load(&sock->connecting) || sock->accepting) {
+ if (sock->accepting) {
+ return;
+ }
+
+ if (atomic_load(&sock->connecting)) {
+ isc_nmsocket_t *tsock = NULL;
+ isc__nmsocket_attach(sock, &tsock);
+ uv_close(&sock->uv_handle.handle, tcp_close_connect_cb);
return;
}
- if (sock->statichandle) {
- failed_read_cb(sock, ISC_R_CANCELED);
+ if (sock->statichandle != NULL) {
+ isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED);
return;
}
@@ -1447,7 +1408,7 @@ isc__nm_async_tcpcancel(isc__networker_t *worker, isc__netievent_t *ev0) {
uv_timer_stop(&sock->timer);
- failed_read_cb(sock, ISC_R_EOF);
+ isc__nm_tcp_failed_read_cb(sock, ISC_R_EOF);
}
int_fast32_t
@@ -1458,5 +1419,5 @@ isc__nm_tcp_listener_nactive(isc_nmsocket_t *listener) {
nactive = atomic_load(&listener->active_child_connections);
INSIST(nactive >= 0);
- return nactive;
+ return (nactive);
}
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/tcpdns.c b/external/mpl/bind/dist/lib/isc/netmgr/tcpdns.c
index 45ad6b5d58d..1ad944dbe18 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/tcpdns.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/tcpdns.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcpdns.c,v 1.5 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: tcpdns.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -16,6 +16,7 @@
#include <uv.h>
#include <isc/atomic.h>
+#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/errno.h>
@@ -87,7 +88,7 @@ stop_tcpdns_child(isc_nmsocket_t *sock);
static isc_result_t
tcpdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
isc__networker_t *worker = NULL;
- isc_result_t result = ISC_R_DEFAULT;
+ isc_result_t result = ISC_R_UNSET;
int r;
REQUIRE(VALID_NMSOCK(sock));
@@ -106,7 +107,11 @@ tcpdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
r = uv_timer_init(&worker->loop, &sock->timer);
RUNTIME_CHECK(r == 0);
- uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
+
+ if (isc__nm_closing(sock)) {
+ result = ISC_R_CANCELED;
+ goto error;
+ }
r = uv_tcp_open(&sock->uv_handle.tcp, sock->fd);
if (r != 0) {
@@ -139,11 +144,14 @@ tcpdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
}
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
+ uv_handle_set_data((uv_handle_t *)&sock->timer, &req->uv_req.connect);
+ isc__nmsocket_timer_start(sock);
+
atomic_store(&sock->connected, true);
done:
result = isc__nm_uverr2result(r);
-
+error:
LOCK(&sock->lock);
sock->result = result;
SIGNAL(&sock->cond);
@@ -168,15 +176,15 @@ isc__nm_async_tcpdnsconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpdnssocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent == NULL);
REQUIRE(sock->tid == isc_nm_tid());
result = tcpdns_connect_direct(sock, req);
if (result != ISC_R_SUCCESS) {
+ isc__nmsocket_clearcb(sock);
+ isc__nm_connectcb(sock, req, result, true);
atomic_store(&sock->active, false);
isc__nm_tcpdns_close(sock);
- isc__nm_uvreq_put(&req, sock);
}
/*
@@ -195,20 +203,28 @@ tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->connecting));
+
+ isc__nmsocket_timer_stop(sock);
+ uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
+
+ if (!atomic_load(&sock->connecting)) {
+ return;
+ }
req = uv_handle_get_data((uv_handle_t *)uvreq);
REQUIRE(VALID_UVREQ(req));
REQUIRE(VALID_NMHANDLE(req->handle));
- /* Socket was closed midflight by isc__nm_tcpdns_shutdown() */
- if (!isc__nmsocket_active(sock)) {
+ if (isc__nmsocket_closing(sock)) {
+ /* Socket was closed midflight by isc__nm_tcpdns_shutdown() */
result = ISC_R_CANCELED;
goto error;
- }
-
- if (status != 0) {
+ } else if (status == UV_ETIMEDOUT) {
+ /* Timeout status code here indicates hard error */
+ result = ISC_R_CANCELED;
+ goto error;
+ } else if (status != 0) {
result = isc__nm_uverr2result(status);
goto error;
}
@@ -226,16 +242,16 @@ tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
result = isc_sockaddr_fromsockaddr(&sock->peer, (struct sockaddr *)&ss);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
- isc__nm_connectcb(sock, req, ISC_R_SUCCESS);
+ isc__nm_connectcb(sock, req, ISC_R_SUCCESS, false);
return;
error:
- isc__nm_failed_connect_cb(sock, req, result);
+ isc__nm_failed_connect_cb(sock, req, result, false);
}
-isc_result_t
-isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize) {
isc_result_t result = ISC_R_SUCCESS;
@@ -243,41 +259,43 @@ isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
isc__netievent_tcpdnsconnect_t *ievent = NULL;
isc__nm_uvreq_t *req = NULL;
sa_family_t sa_family;
- uv_os_sock_t fd;
REQUIRE(VALID_NM(mgr));
REQUIRE(local != NULL);
REQUIRE(peer != NULL);
- sa_family = peer->addr.type.sa.sa_family;
-
- /*
- * The socket() call can fail spuriously on FreeBSD 12, so we need to
- * handle the failure early and gracefully.
- */
- result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &fd);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ sa_family = peer->type.sa.sa_family;
sock = isc_mem_get(mgr->mctx, sizeof(*sock));
isc__nmsocket_init(sock, mgr, isc_nm_tcpdnssocket, local);
sock->extrahandlesize = extrahandlesize;
sock->connect_timeout = timeout;
- sock->result = ISC_R_DEFAULT;
- sock->fd = fd;
+ sock->result = ISC_R_UNSET;
atomic_init(&sock->client, true);
- result = isc__nm_socket_connectiontimeout(fd, timeout);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
req = isc__nm_uvreq_get(mgr, sock);
req->cb.connect = cb;
req->cbarg = cbarg;
- req->peer = peer->addr;
- req->local = local->addr;
- req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface->addr);
+ req->peer = *peer;
+ req->local = *local;
+ req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface);
+
+ result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &sock->fd);
+ if (result != ISC_R_SUCCESS) {
+ if (isc__nm_in_netthread()) {
+ sock->tid = isc_nm_tid();
+ }
+ isc__nmsocket_clearcb(sock);
+ isc__nm_connectcb(sock, req, result, true);
+ atomic_store(&sock->closed, true);
+ isc__nmsocket_detach(&sock);
+ return;
+ }
+
+ /* 2 minute timeout */
+ result = isc__nm_socket_connectiontimeout(sock->fd, 120 * 1000);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
ievent = isc__nm_get_netievent_tcpdnsconnect(mgr, sock, req);
@@ -293,18 +311,14 @@ isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
isc__nm_enqueue_ievent(&mgr->workers[sock->tid],
(isc__netievent_t *)ievent);
}
+
LOCK(&sock->lock);
- result = sock->result;
- while (result == ISC_R_DEFAULT) {
+ while (sock->result == ISC_R_UNSET) {
WAIT(&sock->cond, &sock->lock);
- result = sock->result;
}
atomic_store(&sock->active, true);
BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
-
- return (result);
}
static uv_os_sock_t
@@ -330,26 +344,65 @@ isc__nm_tcpdns_lb_socket(sa_family_t sa_family) {
return (sock);
}
+static void
+enqueue_stoplistening(isc_nmsocket_t *sock) {
+ isc__netievent_tcpdnsstop_t *ievent =
+ isc__nm_get_netievent_tcpdnsstop(sock->mgr, sock);
+ isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
+}
+
+static void
+start_tcpdns_child(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nmsocket_t *sock,
+ uv_os_sock_t fd, int tid) {
+ isc__netievent_tcpdnslisten_t *ievent = NULL;
+ isc_nmsocket_t *csock = &sock->children[tid];
+
+ isc__nmsocket_init(csock, mgr, isc_nm_tcpdnssocket, iface);
+ csock->parent = sock;
+ csock->accept_cb = sock->accept_cb;
+ csock->accept_cbarg = sock->accept_cbarg;
+ csock->recv_cb = sock->recv_cb;
+ csock->recv_cbarg = sock->recv_cbarg;
+ csock->extrahandlesize = sock->extrahandlesize;
+ csock->backlog = sock->backlog;
+ csock->tid = tid;
+ /*
+ * We don't attach to quota, just assign - to avoid
+ * increasing quota unnecessarily.
+ */
+ csock->pquota = sock->pquota;
+ isc_quota_cb_init(&csock->quotacb, quota_accept_cb, csock);
+
+#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
+ UNUSED(fd);
+ csock->fd = isc__nm_tcpdns_lb_socket(iface->type.sa.sa_family);
+#else
+ csock->fd = dup(fd);
+#endif
+ REQUIRE(csock->fd >= 0);
+
+ ievent = isc__nm_get_netievent_tcpdnslisten(mgr, csock);
+ isc__nm_maybe_enqueue_ievent(&mgr->workers[tid],
+ (isc__netievent_t *)ievent);
+}
isc_result_t
-isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
+isc_nm_listentcpdns(isc_nm_t *mgr, isc_sockaddr_t *iface,
isc_nm_recv_cb_t recv_cb, void *recv_cbarg,
isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
size_t extrahandlesize, int backlog, isc_quota_t *quota,
isc_nmsocket_t **sockp) {
isc_result_t result = ISC_R_SUCCESS;
isc_nmsocket_t *sock = NULL;
- sa_family_t sa_family = iface->addr.type.sa.sa_family;
size_t children_size = 0;
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
uv_os_sock_t fd = -1;
-#endif
REQUIRE(VALID_NM(mgr));
sock = isc_mem_get(mgr->mctx, sizeof(*sock));
isc__nmsocket_init(sock, mgr, isc_nm_tcpdnslistener, iface);
- sock->rchildren = 0;
+ atomic_init(&sock->rchildren, 0);
#if defined(WIN32)
sock->nchildren = 1;
#else
@@ -359,44 +412,33 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
sock->children = isc_mem_get(mgr->mctx, children_size);
memset(sock->children, 0, children_size);
- sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(sock->nchildren);
+ sock->result = ISC_R_UNSET;
+ sock->accept_cb = accept_cb;
+ sock->accept_cbarg = accept_cbarg;
+ sock->recv_cb = recv_cb;
+ sock->recv_cbarg = recv_cbarg;
+ sock->extrahandlesize = extrahandlesize;
+ sock->backlog = backlog;
+ sock->pquota = quota;
+
+ sock->tid = 0;
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- fd = isc__nm_tcpdns_lb_socket(sa_family);
+ fd = isc__nm_tcpdns_lb_socket(iface->type.sa.sa_family);
#endif
- for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tcpdnslisten_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
-
- isc__nmsocket_init(csock, mgr, isc_nm_tcpdnssocket, iface);
- csock->parent = sock;
- csock->accept_cb = accept_cb;
- csock->accept_cbarg = accept_cbarg;
- csock->recv_cb = recv_cb;
- csock->recv_cbarg = recv_cbarg;
- csock->extrahandlesize = extrahandlesize;
- csock->backlog = backlog;
- csock->tid = i;
- /*
- * We don't attach to quota, just assign - to avoid
- * increasing quota unnecessarily.
- */
- csock->pquota = quota;
- isc_quota_cb_init(&csock->quotacb, quota_accept_cb, csock);
+ isc_barrier_init(&sock->startlistening, sock->nchildren);
-#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- csock->fd = isc__nm_tcpdns_lb_socket(sa_family);
-#else
- csock->fd = dup(fd);
-#endif
- REQUIRE(csock->fd >= 0);
+ for (size_t i = 0; i < sock->nchildren; i++) {
+ if ((int)i == isc_nm_tid()) {
+ continue;
+ }
+ start_tcpdns_child(mgr, iface, sock, fd, i);
+ }
- ievent = isc__nm_get_netievent_tcpdnslisten(mgr, csock);
- isc__nm_enqueue_ievent(&mgr->workers[i],
- (isc__netievent_t *)ievent);
+ if (isc__nm_in_netthread()) {
+ start_tcpdns_child(mgr, iface, sock, fd, isc_nm_tid());
}
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
@@ -404,21 +446,21 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
#endif
LOCK(&sock->lock);
- while (sock->rchildren != sock->nchildren) {
+ while (atomic_load(&sock->rchildren) != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
atomic_store(&sock->active, true);
- BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
+
+ INSIST(result != ISC_R_UNSET);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == sock->nchildren);
+ REQUIRE(atomic_load(&sock->rchildren) == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
- isc__nm_tcpdns_stoplistening(sock);
+ enqueue_stoplistening(sock);
isc_nmsocket_close(&sock);
}
@@ -429,23 +471,20 @@ void
isc__nm_async_tcpdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_tcpdnslisten_t *ievent =
(isc__netievent_tcpdnslisten_t *)ev0;
- isc_nmiface_t *iface = NULL;
sa_family_t sa_family;
int r;
int flags = 0;
isc_nmsocket_t *sock = NULL;
- isc_result_t result = ISC_R_DEFAULT;
+ isc_result_t result = ISC_R_UNSET;
REQUIRE(VALID_NMSOCK(ievent->sock));
REQUIRE(ievent->sock->tid == isc_nm_tid());
REQUIRE(VALID_NMSOCK(ievent->sock->parent));
sock = ievent->sock;
- iface = sock->iface;
- sa_family = iface->addr.type.sa.sa_family;
+ sa_family = sock->iface.type.sa.sa_family;
REQUIRE(sock->type == isc_nm_tcpdnssocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent != NULL);
REQUIRE(sock->tid == isc_nm_tid());
@@ -476,8 +515,8 @@ isc__nm_async_tcpdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
}
#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
+ r = isc_uv_tcp_freebind(&sock->uv_handle.tcp, &sock->iface.type.sa,
+ flags);
if (r < 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
goto done;
@@ -485,7 +524,7 @@ isc__nm_async_tcpdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
#else
if (sock->parent->fd == -1) {
r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
+ &sock->iface.type.sa, flags);
if (r < 0) {
isc__nm_incstats(sock->mgr,
sock->statsindex[STATID_BINDFAIL]);
@@ -522,16 +561,14 @@ done:
sock->pquota = NULL;
}
- sock->parent->rchildren += 1;
- if (sock->parent->result == ISC_R_DEFAULT) {
+ atomic_fetch_add(&sock->parent->rchildren, 1);
+ if (sock->parent->result == ISC_R_UNSET) {
sock->parent->result = result;
}
SIGNAL(&sock->parent->cond);
- if (!atomic_load(&sock->parent->active)) {
- WAIT(&sock->parent->scond, &sock->parent->lock);
- }
- INSIST(atomic_load(&sock->parent->active));
UNLOCK(&sock->parent->lock);
+
+ isc_barrier_wait(&sock->parent->startlistening);
}
static void
@@ -548,7 +585,7 @@ tcpdns_connection_cb(uv_stream_t *server, int status) {
REQUIRE(VALID_NMSOCK(ssock));
REQUIRE(ssock->tid == isc_nm_tid());
- if (isc__nm_inactive(ssock)) {
+ if (isc__nmsocket_closing(ssock)) {
result = ISC_R_CANCELED;
goto done;
}
@@ -577,14 +614,6 @@ done:
}
}
-static void
-enqueue_stoplistening(isc_nmsocket_t *sock) {
- isc__netievent_tcpdnsstop_t *ievent =
- isc__nm_get_netievent_tcpdnsstop(sock->mgr, sock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
void
isc__nm_tcpdns_stoplistening(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
@@ -595,7 +624,12 @@ isc__nm_tcpdns_stoplistening(isc_nmsocket_t *sock) {
INSIST(0);
ISC_UNREACHABLE();
}
- enqueue_stoplistening(sock);
+
+ if (!isc__nm_in_netthread()) {
+ enqueue_stoplistening(sock);
+ } else {
+ stop_tcpdns_parent(sock);
+ }
}
void
@@ -614,15 +648,7 @@ isc__nm_async_tcpdnsstop(isc__networker_t *worker, isc__netievent_t *ev0) {
return;
}
- /*
- * If network manager is interlocked, re-enqueue the event for later.
- */
- if (!isc__nm_acquire_interlocked(sock->mgr)) {
- enqueue_stoplistening(sock);
- } else {
- stop_tcpdns_parent(sock);
- isc__nm_drop_interlocked(sock->mgr);
- }
+ stop_tcpdns_parent(sock);
}
void
@@ -647,9 +673,11 @@ isc__nm_tcpdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
destroy:
isc__nmsocket_prep_destroy(sock);
- /* We need to detach from quota after the read callback function had a
- * chance to be executed. */
- if (sock->quota) {
+ /*
+ * We need to detach from quota after the read callback function had a
+ * chance to be executed.
+ */
+ if (sock->quota != NULL) {
isc_quota_detach(&sock->quota);
}
}
@@ -702,9 +730,9 @@ isc__nm_async_tcpdnsread(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
sock->reading = true;
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
return;
}
@@ -729,7 +757,7 @@ isc__nm_tcpdns_processbuffer(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
return (ISC_R_CANCELED);
}
@@ -806,8 +834,8 @@ isc__nm_tcpdns_read_cb(uv_stream_t *stream, ssize_t nread,
REQUIRE(sock->reading);
REQUIRE(buf != NULL);
- if (isc__nm_inactive(sock)) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ if (isc__nmsocket_closing(sock)) {
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, true);
goto free;
}
@@ -817,7 +845,7 @@ isc__nm_tcpdns_read_cb(uv_stream_t *stream, ssize_t nread,
sock->statsindex[STATID_RECVFAIL]);
}
- isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nread));
+ isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nread), true);
goto free;
}
@@ -905,7 +933,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
REQUIRE(VALID_NMSOCK(ssock));
REQUIRE(ssock->tid == isc_nm_tid());
- if (isc__nm_inactive(ssock)) {
+ if (isc__nmsocket_closing(ssock)) {
if (quota != NULL) {
isc_quota_detach(&quota);
}
@@ -916,7 +944,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
csock = isc_mem_get(ssock->mgr->mctx, sizeof(isc_nmsocket_t));
isc__nmsocket_init(csock, ssock->mgr, isc_nm_tcpdnssocket,
- ssock->iface);
+ &ssock->iface);
csock->tid = ssock->tid;
csock->extrahandlesize = ssock->extrahandlesize;
isc__nmsocket_attach(ssock, &csock->server);
@@ -1059,11 +1087,13 @@ isc__nm_tcpdns_send(isc_nmhandle_t *handle, isc_region_t *region,
static void
tcpdns_send_cb(uv_write_t *req, int status) {
isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
- isc_nmsocket_t *sock = uvreq->sock;
+ isc_nmsocket_t *sock = NULL;
REQUIRE(VALID_UVREQ(uvreq));
REQUIRE(VALID_NMHANDLE(uvreq->handle));
+ sock = uvreq->sock;
+
if (status < 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_SENDFAIL]);
isc__nm_failed_send_cb(sock, uvreq,
@@ -1099,7 +1129,7 @@ isc__nm_async_tcpdnssend(isc__networker_t *worker, isc__netievent_t *ev0) {
UNUSED(worker);
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
result = ISC_R_CANCELED;
goto fail;
}
@@ -1169,11 +1199,7 @@ tcpdns_stop_cb(uv_handle_t *handle) {
}
static void
-tcpdns_close_cb(uv_handle_t *handle) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
-
- uv_handle_set_data(handle, NULL);
-
+tcpdns_close_sock(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(atomic_load(&sock->closing));
@@ -1196,12 +1222,25 @@ tcpdns_close_cb(uv_handle_t *handle) {
}
static void
-timer_close_cb(uv_handle_t *handle) {
+tcpdns_close_cb(uv_handle_t *handle) {
isc_nmsocket_t *sock = uv_handle_get_data(handle);
+
uv_handle_set_data(handle, NULL);
+ tcpdns_close_sock(sock);
+}
+
+static void
+timer_close_cb(uv_handle_t *timer) {
+ isc_nmsocket_t *sock = uv_handle_get_data(timer);
+ uv_handle_set_data(timer, NULL);
+
+ REQUIRE(VALID_NMSOCK(sock));
+
if (sock->parent) {
uv_close(&sock->uv_handle.handle, tcpdns_stop_cb);
+ } else if (uv_is_closing(&sock->uv_handle.handle)) {
+ tcpdns_close_sock(sock);
} else {
uv_close(&sock->uv_handle.handle, tcpdns_close_cb);
}
@@ -1219,41 +1258,41 @@ stop_tcpdns_child(isc_nmsocket_t *sock) {
tcpdns_close_direct(sock);
- LOCK(&sock->parent->lock);
- sock->parent->rchildren -= 1;
- UNLOCK(&sock->parent->lock);
- BROADCAST(&sock->parent->cond);
+ atomic_fetch_sub(&sock->parent->rchildren, 1);
+
+ isc_barrier_wait(&sock->parent->stoplistening);
}
static void
stop_tcpdns_parent(isc_nmsocket_t *sock) {
+ isc_nmsocket_t *csock = NULL;
+
REQUIRE(VALID_NMSOCK(sock));
+ REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->type == isc_nm_tcpdnslistener);
+ isc_barrier_init(&sock->stoplistening, sock->nchildren);
+
for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tcpdnsstop_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
+ csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
- atomic_store(&csock->active, false);
-
- if (csock->tid == isc_nm_tid()) {
- stop_tcpdns_child(csock);
+ if ((int)i == isc_nm_tid()) {
+ /*
+ * We need to schedule closing the other sockets first
+ */
continue;
}
- ievent = isc__nm_get_netievent_tcpdnsstop(sock->mgr, csock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[csock->tid],
- (isc__netievent_t *)ievent);
+ atomic_store(&csock->active, false);
+ enqueue_stoplistening(csock);
}
- LOCK(&sock->lock);
- while (sock->rchildren > 0) {
- WAIT(&sock->cond, &sock->lock);
- }
- atomic_store(&sock->closed, true);
- UNLOCK(&sock->lock);
+ csock = &sock->children[isc_nm_tid()];
+ atomic_store(&csock->active, false);
+ stop_tcpdns_child(csock);
+ atomic_store(&sock->closed, true);
isc__nmsocket_prep_destroy(sock);
}
@@ -1273,6 +1312,8 @@ tcpdns_close_direct(isc_nmsocket_t *sock) {
isc__nmsocket_timer_stop(sock);
isc__nm_stop_reading(sock);
+
+ uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
uv_close((uv_handle_t *)&sock->timer, timer_close_cb);
}
@@ -1315,6 +1356,19 @@ isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ev0) {
tcpdns_close_direct(sock);
}
+static void
+tcpdns_close_connect_cb(uv_handle_t *handle) {
+ isc_nmsocket_t *sock = uv_handle_get_data(handle);
+
+ REQUIRE(VALID_NMSOCK(sock));
+
+ REQUIRE(isc__nm_in_netthread());
+ REQUIRE(sock->tid == isc_nm_tid());
+
+ isc__nmsocket_prep_destroy(sock);
+ isc__nmsocket_detach(&sock);
+}
+
void
isc__nm_tcpdns_shutdown(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
@@ -1329,12 +1383,19 @@ isc__nm_tcpdns_shutdown(isc_nmsocket_t *sock) {
return;
}
- if (atomic_load(&sock->connecting) || sock->accepting) {
+ if (sock->accepting) {
+ return;
+ }
+
+ if (atomic_load(&sock->connecting)) {
+ isc_nmsocket_t *tsock = NULL;
+ isc__nmsocket_attach(sock, &tsock);
+ uv_close(&sock->uv_handle.handle, tcpdns_close_connect_cb);
return;
}
- if (sock->statichandle) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ if (sock->statichandle != NULL) {
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
return;
}
@@ -1374,7 +1435,7 @@ isc__nm_async_tcpdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- isc__nm_failed_read_cb(sock, ISC_R_EOF);
+ isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
}
void
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/tlsdns.c b/external/mpl/bind/dist/lib/isc/netmgr/tlsdns.c
deleted file mode 100644
index 7ab77bd4c45..00000000000
--- a/external/mpl/bind/dist/lib/isc/netmgr/tlsdns.c
+++ /dev/null
@@ -1,1938 +0,0 @@
-/* $NetBSD: tlsdns.c,v 1.3 2021/04/29 17:26:12 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#include <libgen.h>
-#include <unistd.h>
-#include <uv.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/errno.h>
-#include <isc/log.h>
-#include <isc/magic.h>
-#include <isc/mem.h>
-#include <isc/netmgr.h>
-#include <isc/quota.h>
-#include <isc/random.h>
-#include <isc/refcount.h>
-#include <isc/region.h>
-#include <isc/result.h>
-#include <isc/sockaddr.h>
-#include <isc/stdtime.h>
-#include <isc/thread.h>
-#include <isc/util.h>
-
-#include "netmgr-int.h"
-#include "openssl_shim.h"
-#include "uv-compat.h"
-
-/*%<
- *
- * Maximum number of simultaneous handles in flight supported for a single
- * connected TLSDNS socket. This value was chosen arbitrarily, and may be
- * changed in the future.
- */
-
-static atomic_uint_fast32_t last_tlsdnsquota_log = ATOMIC_VAR_INIT(0);
-
-static void
-tls_error(isc_nmsocket_t *sock, isc_result_t result);
-
-static isc_result_t
-tlsdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
-
-static void
-tlsdns_close_direct(isc_nmsocket_t *sock);
-
-static isc_result_t
-tlsdns_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
-static void
-tlsdns_connect_cb(uv_connect_t *uvreq, int status);
-
-static void
-tlsdns_connection_cb(uv_stream_t *server, int status);
-
-static void
-tlsdns_close_cb(uv_handle_t *uvhandle);
-
-static isc_result_t
-accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota);
-
-static void
-quota_accept_cb(isc_quota_t *quota, void *sock0);
-
-static void
-stop_tlsdns_parent(isc_nmsocket_t *sock);
-static void
-stop_tlsdns_child(isc_nmsocket_t *sock);
-
-static void
-async_tlsdns_cycle(isc_nmsocket_t *sock) __attribute__((unused));
-
-static isc_result_t
-tls_cycle(isc_nmsocket_t *sock);
-
-static bool
-can_log_tlsdns_quota(void) {
- isc_stdtime_t now, last;
-
- isc_stdtime_get(&now);
- last = atomic_exchange_relaxed(&last_tlsdnsquota_log, now);
- if (now != last) {
- return (true);
- }
-
- return (false);
-}
-
-static isc_result_t
-tlsdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
- isc__networker_t *worker = NULL;
- isc_result_t result = ISC_R_DEFAULT;
- int r;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(VALID_UVREQ(req));
-
- REQUIRE(isc__nm_in_netthread());
- REQUIRE(sock->tid == isc_nm_tid());
-
- worker = &sock->mgr->workers[sock->tid];
-
- atomic_store(&sock->connecting, true);
-
- r = uv_tcp_init(&worker->loop, &sock->uv_handle.tcp);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data(&sock->uv_handle.handle, sock);
-
- r = uv_timer_init(&worker->loop, &sock->timer);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
-
- r = uv_tcp_open(&sock->uv_handle.tcp, sock->fd);
- if (r != 0) {
- isc__nm_closesocket(sock->fd);
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPENFAIL]);
- goto done;
- }
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPEN]);
-
- if (req->local.length != 0) {
- r = uv_tcp_bind(&sock->uv_handle.tcp, &req->local.type.sa, 0);
- /*
- * In case of shared socket UV_EINVAL will be returned and needs
- * to be ignored
- */
- if (r != 0 && r != UV_EINVAL) {
- isc__nm_incstats(sock->mgr,
- sock->statsindex[STATID_BINDFAIL]);
- goto done;
- }
- }
-
- uv_handle_set_data(&req->uv_req.handle, req);
- r = uv_tcp_connect(&req->uv_req.connect, &sock->uv_handle.tcp,
- &req->peer.type.sa, tlsdns_connect_cb);
- if (r != 0) {
- isc__nm_incstats(sock->mgr,
- sock->statsindex[STATID_CONNECTFAIL]);
- goto done;
- }
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
-
- atomic_store(&sock->connected, true);
-
-done:
- result = isc__nm_uverr2result(r);
-
- LOCK(&sock->lock);
- sock->result = result;
- SIGNAL(&sock->cond);
- if (!atomic_load(&sock->active)) {
- WAIT(&sock->scond, &sock->lock);
- }
- INSIST(atomic_load(&sock->active));
- UNLOCK(&sock->lock);
-
- return (result);
-}
-
-void
-isc__nm_async_tlsdnsconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsconnect_t *ievent =
- (isc__netievent_tlsdnsconnect_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
- isc__nm_uvreq_t *req = ievent->req;
- isc_result_t result = ISC_R_SUCCESS;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(sock->iface != NULL);
- REQUIRE(sock->parent == NULL);
- REQUIRE(sock->tid == isc_nm_tid());
-
- result = tlsdns_connect_direct(sock, req);
- if (result != ISC_R_SUCCESS) {
- atomic_store(&sock->active, false);
- isc__nm_tlsdns_close(sock);
- isc__nm_uvreq_put(&req, sock);
- }
-
- /*
- * The sock is now attached to the handle.
- */
- isc__nmsocket_detach(&sock);
-}
-
-static void
-tlsdns_connect_cb(uv_connect_t *uvreq, int status) {
- isc_result_t result;
- isc__nm_uvreq_t *req = NULL;
- isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
- struct sockaddr_storage ss;
- int r;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->connecting));
-
- req = uv_handle_get_data((uv_handle_t *)uvreq);
-
- REQUIRE(VALID_UVREQ(req));
- REQUIRE(VALID_NMHANDLE(req->handle));
-
- /* Socket was closed midflight by isc__nm_tlsdns_shutdown() */
- if (!isc__nmsocket_active(sock)) {
- result = ISC_R_CANCELED;
- goto error;
- }
-
- if (status != 0) {
- result = isc__nm_uverr2result(status);
- goto error;
- }
-
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
- r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
- &(int){ sizeof(ss) });
- if (r != 0) {
- result = isc__nm_uverr2result(r);
- goto error;
- }
-
- sock->tls.state = TLS_STATE_NONE;
- sock->tls.ssl = SSL_new(sock->tls.ctx);
- RUNTIME_CHECK(sock->tls.ssl != NULL);
-
- /*
- *
- */
- r = BIO_new_bio_pair(&sock->tls.ssl_wbio, ISC_NETMGR_TLSBUF_SIZE,
- &sock->tls.app_rbio, ISC_NETMGR_TLSBUF_SIZE);
- RUNTIME_CHECK(r == 1);
-
- r = BIO_new_bio_pair(&sock->tls.ssl_rbio, ISC_NETMGR_TLSBUF_SIZE,
- &sock->tls.app_wbio, ISC_NETMGR_TLSBUF_SIZE);
- RUNTIME_CHECK(r == 1);
-
-#if HAVE_SSL_SET0_RBIO && HAVE_SSL_SET0_WBIO
- /*
- * Note that if the rbio and wbio are the same then SSL_set0_rbio() and
- * SSL_set0_wbio() each take ownership of one reference. Therefore it
- * may be necessary to increment the number of references available
- * using BIO_up_ref(3) before calling the set0 functions.
- */
- SSL_set0_rbio(sock->tls.ssl, sock->tls.ssl_rbio);
- SSL_set0_wbio(sock->tls.ssl, sock->tls.ssl_wbio);
-#else
- SSL_set_bio(sock->tls.ssl, sock->tls.ssl_rbio, sock->tls.ssl_wbio);
-#endif
-
- SSL_set_connect_state(sock->tls.ssl);
-
- result = isc_sockaddr_fromsockaddr(&sock->peer, (struct sockaddr *)&ss);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
- sock->tls.pending_req = req;
-
- isc__nm_process_sock_buffer(sock);
-
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- goto error;
- }
-
- return;
-
-error:
- isc__nm_failed_connect_cb(sock, req, result);
-}
-
-isc_result_t
-isc_nm_tlsdnsconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
- isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
- size_t extrahandlesize, isc_tlsctx_t *sslctx) {
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *sock = NULL;
- isc__netievent_tlsdnsconnect_t *ievent = NULL;
- isc__nm_uvreq_t *req = NULL;
- sa_family_t sa_family;
- uv_os_sock_t fd;
-
- REQUIRE(VALID_NM(mgr));
- REQUIRE(local != NULL);
- REQUIRE(peer != NULL);
- REQUIRE(sslctx != NULL);
-
- sa_family = peer->addr.type.sa.sa_family;
-
- /*
- * The socket() call can fail spuriously on FreeBSD 12, so we need to
- * handle the failure early and gracefully.
- */
- result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &fd);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- sock = isc_mem_get(mgr->mctx, sizeof(*sock));
- isc__nmsocket_init(sock, mgr, isc_nm_tlsdnssocket, local);
-
- sock->extrahandlesize = extrahandlesize;
- sock->connect_timeout = timeout;
- sock->result = ISC_R_DEFAULT;
- sock->fd = fd;
- sock->tls.ctx = sslctx;
-
- atomic_init(&sock->client, true);
-
- result = isc__nm_socket_connectiontimeout(fd, timeout);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
- req = isc__nm_uvreq_get(mgr, sock);
- req->cb.connect = cb;
- req->cbarg = cbarg;
- req->peer = peer->addr;
- req->local = local->addr;
- req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface->addr);
-
- ievent = isc__nm_get_netievent_tlsdnsconnect(mgr, sock, req);
-
- if (isc__nm_in_netthread()) {
- atomic_store(&sock->active, true);
- sock->tid = isc_nm_tid();
- isc__nm_async_tlsdnsconnect(&mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
- isc__nm_put_netievent_tlsdnsconnect(mgr, ievent);
- } else {
- atomic_init(&sock->active, false);
- sock->tid = isc_random_uniform(mgr->nworkers);
- isc__nm_enqueue_ievent(&mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
- }
- LOCK(&sock->lock);
- result = sock->result;
- while (result == ISC_R_DEFAULT) {
- WAIT(&sock->cond, &sock->lock);
- result = sock->result;
- }
- atomic_store(&sock->active, true);
- BROADCAST(&sock->scond);
- UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
-
- return (result);
-}
-
-static uv_os_sock_t
-isc__nm_tlsdns_lb_socket(sa_family_t sa_family) {
- isc_result_t result;
- uv_os_sock_t sock;
-
- result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &sock);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
- (void)isc__nm_socket_incoming_cpu(sock);
-
- /* FIXME: set mss */
-
- result = isc__nm_socket_reuse(sock);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-
-#if HAVE_SO_REUSEPORT_LB
- result = isc__nm_socket_reuse_lb(sock);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
-#endif
-
- return (sock);
-}
-
-isc_result_t
-isc_nm_listentlsdns(isc_nm_t *mgr, isc_nmiface_t *iface,
- isc_nm_recv_cb_t recv_cb, void *recv_cbarg,
- isc_nm_accept_cb_t accept_cb, void *accept_cbarg,
- size_t extrahandlesize, int backlog, isc_quota_t *quota,
- isc_tlsctx_t *sslctx, isc_nmsocket_t **sockp) {
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *sock = NULL;
- sa_family_t sa_family = iface->addr.type.sa.sa_family;
- size_t children_size = 0;
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- uv_os_sock_t fd = -1;
-#endif
-
- REQUIRE(VALID_NM(mgr));
-
- sock = isc_mem_get(mgr->mctx, sizeof(*sock));
- isc__nmsocket_init(sock, mgr, isc_nm_tlsdnslistener, iface);
-
- sock->rchildren = 0;
-#if defined(WIN32)
- sock->nchildren = 1;
-#else
- sock->nchildren = mgr->nworkers;
-#endif
- children_size = sock->nchildren * sizeof(sock->children[0]);
- sock->children = isc_mem_get(mgr->mctx, children_size);
- memset(sock->children, 0, children_size);
-
- sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(sock->nchildren);
- sock->fd = -1;
- sock->tls.ctx = sslctx;
-
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- fd = isc__nm_tlsdns_lb_socket(sa_family);
-#endif
-
- for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tlsdnslisten_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
-
- isc__nmsocket_init(csock, mgr, isc_nm_tlsdnssocket, iface);
- csock->parent = sock;
- csock->accept_cb = accept_cb;
- csock->accept_cbarg = accept_cbarg;
- csock->recv_cb = recv_cb;
- csock->recv_cbarg = recv_cbarg;
- csock->extrahandlesize = extrahandlesize;
- csock->backlog = backlog;
- csock->tid = i;
- csock->tls.ctx = sslctx;
-
- /*
- * We don't attach to quota, just assign - to avoid
- * increasing quota unnecessarily.
- */
- csock->pquota = quota;
- isc_quota_cb_init(&csock->quotacb, quota_accept_cb, csock);
-
-#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- csock->fd = isc__nm_tlsdns_lb_socket(sa_family);
-#else
- csock->fd = dup(fd);
-#endif
- REQUIRE(csock->fd >= 0);
-
- ievent = isc__nm_get_netievent_tlsdnslisten(mgr, csock);
- isc__nm_enqueue_ievent(&mgr->workers[i],
- (isc__netievent_t *)ievent);
- }
-
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- isc__nm_closesocket(fd);
-#endif
-
- LOCK(&sock->lock);
- while (sock->rchildren != sock->nchildren) {
- WAIT(&sock->cond, &sock->lock);
- }
- result = sock->result;
- atomic_store(&sock->active, true);
- BROADCAST(&sock->scond);
- UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
-
- if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == sock->nchildren);
- *sockp = sock;
- } else {
- atomic_store(&sock->active, false);
- isc__nm_tlsdns_stoplistening(sock);
- isc_nmsocket_close(&sock);
- }
-
- return (result);
-}
-
-void
-isc__nm_async_tlsdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnslisten_t *ievent =
- (isc__netievent_tlsdnslisten_t *)ev0;
- isc_nmiface_t *iface = NULL;
- sa_family_t sa_family;
- int r;
- int flags = 0;
- isc_nmsocket_t *sock = NULL;
- isc_result_t result = ISC_R_DEFAULT;
-
- REQUIRE(VALID_NMSOCK(ievent->sock));
- REQUIRE(ievent->sock->tid == isc_nm_tid());
- REQUIRE(VALID_NMSOCK(ievent->sock->parent));
-
- sock = ievent->sock;
- iface = sock->iface;
- sa_family = iface->addr.type.sa.sa_family;
-
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(sock->iface != NULL);
- REQUIRE(sock->parent != NULL);
- REQUIRE(sock->tid == isc_nm_tid());
-
- /* TODO: set min mss */
-
- r = uv_tcp_init(&worker->loop, &sock->uv_handle.tcp);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data(&sock->uv_handle.handle, sock);
- /* This keeps the socket alive after everything else is gone */
- isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
-
- r = uv_timer_init(&worker->loop, &sock->timer);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data((uv_handle_t *)&sock->timer, sock);
-
- LOCK(&sock->parent->lock);
-
- r = uv_tcp_open(&sock->uv_handle.tcp, sock->fd);
- if (r < 0) {
- isc__nm_closesocket(sock->fd);
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPENFAIL]);
- goto done;
- }
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPEN]);
-
- if (sa_family == AF_INET6) {
- flags = UV_TCP_IPV6ONLY;
- }
-
-#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
- if (r < 0) {
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
- goto done;
- }
-#else
- if (sock->parent->fd == -1) {
- r = isc_uv_tcp_freebind(&sock->uv_handle.tcp,
- &sock->iface->addr.type.sa, flags);
- if (r < 0) {
- isc__nm_incstats(sock->mgr,
- sock->statsindex[STATID_BINDFAIL]);
- goto done;
- }
- sock->parent->uv_handle.tcp.flags = sock->uv_handle.tcp.flags;
- sock->parent->fd = sock->fd;
- } else {
- /* The socket is already bound, just copy the flags */
- sock->uv_handle.tcp.flags = sock->parent->uv_handle.tcp.flags;
- }
-#endif
-
- /*
- * The callback will run in the same thread uv_listen() was called
- * from, so a race with tlsdns_connection_cb() isn't possible.
- */
- r = uv_listen((uv_stream_t *)&sock->uv_handle.tcp, sock->backlog,
- tlsdns_connection_cb);
- if (r != 0) {
- isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
- ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
- "uv_listen failed: %s",
- isc_result_totext(isc__nm_uverr2result(r)));
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
- goto done;
- }
-
- atomic_store(&sock->listening, true);
-
-done:
- result = isc__nm_uverr2result(r);
- if (result != ISC_R_SUCCESS) {
- sock->pquota = NULL;
- }
-
- sock->parent->rchildren += 1;
- if (sock->parent->result == ISC_R_DEFAULT) {
- sock->parent->result = result;
- }
- SIGNAL(&sock->parent->cond);
- if (!atomic_load(&sock->parent->active)) {
- WAIT(&sock->parent->scond, &sock->parent->lock);
- }
- INSIST(atomic_load(&sock->parent->active));
- UNLOCK(&sock->parent->lock);
-}
-
-static void
-tlsdns_connection_cb(uv_stream_t *server, int status) {
- isc_nmsocket_t *ssock = uv_handle_get_data((uv_handle_t *)server);
- isc_result_t result;
- isc_quota_t *quota = NULL;
-
- if (status != 0) {
- result = isc__nm_uverr2result(status);
- goto done;
- }
-
- REQUIRE(VALID_NMSOCK(ssock));
- REQUIRE(ssock->tid == isc_nm_tid());
-
- if (isc__nm_inactive(ssock)) {
- result = ISC_R_CANCELED;
- goto done;
- }
-
- if (ssock->pquota != NULL) {
- result = isc_quota_attach_cb(ssock->pquota, &quota,
- &ssock->quotacb);
- if (result == ISC_R_QUOTA) {
- isc__nm_incstats(ssock->mgr,
- ssock->statsindex[STATID_ACCEPTFAIL]);
- return;
- }
- }
-
- result = accept_connection(ssock, quota);
-done:
- if (result != ISC_R_SUCCESS && result != ISC_R_NOCONN) {
- if ((result != ISC_R_QUOTA && result != ISC_R_SOFTQUOTA) ||
- can_log_tlsdns_quota())
- {
- isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
- ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
- "TCP connection failed: %s",
- isc_result_totext(result));
- }
- }
-}
-
-static void
-enqueue_stoplistening(isc_nmsocket_t *sock) {
- isc__netievent_tlsdnsstop_t *ievent =
- isc__nm_get_netievent_tlsdnsstop(sock->mgr, sock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-void
-isc__nm_tlsdns_stoplistening(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tlsdnslistener);
-
- if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false },
- true)) {
- INSIST(0);
- ISC_UNREACHABLE();
- }
- enqueue_stoplistening(sock);
-}
-
-static void
-tls_shutdown(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
-
- isc__netievent_tlsdnsshutdown_t *ievent =
- isc__nm_get_netievent_tlsdnsshutdown(sock->mgr, sock);
- isc__nm_maybe_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-void
-isc__nm_async_tlsdnsshutdown(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsshutdown_t *ievent =
- (isc__netievent_tlsdnsshutdown_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
- int rv;
- int err;
- isc_result_t result;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(ievent->sock));
-
- if (sock->tls.state != TLS_STATE_IO) {
- /* Nothing to do */
- return;
- }
-
- rv = SSL_shutdown(sock->tls.ssl);
-
- if (rv == 1) {
- sock->tls.state = TLS_STATE_NONE;
- /* FIXME: continue closing the socket */
- return;
- }
-
- if (rv == 0) {
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- tls_error(sock, result);
- return;
- }
-
- /* Reschedule closing the socket */
- tls_shutdown(sock);
- return;
- }
-
- err = SSL_get_error(sock->tls.ssl, rv);
-
- switch (err) {
- case SSL_ERROR_WANT_READ:
- case SSL_ERROR_WANT_WRITE:
- case SSL_ERROR_WANT_X509_LOOKUP:
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- tls_error(sock, result);
- return;
- }
-
- /* Reschedule closing the socket */
- tls_shutdown(sock);
- return;
- case 0:
- INSIST(0);
- ISC_UNREACHABLE();
- case SSL_ERROR_ZERO_RETURN:
- tls_error(sock, ISC_R_EOF);
- break;
- default:
- tls_error(sock, ISC_R_TLSERROR);
- }
- return;
-}
-
-void
-isc__nm_async_tlsdnsstop(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsstop_t *ievent =
- (isc__netievent_tlsdnsstop_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
-
- if (sock->parent != NULL) {
- stop_tlsdns_child(sock);
- return;
- }
-
- /*
- * If network manager is interlocked, re-enqueue the event for later.
- */
- if (!isc__nm_acquire_interlocked(sock->mgr)) {
- enqueue_stoplistening(sock);
- } else {
- stop_tlsdns_parent(sock);
- isc__nm_drop_interlocked(sock->mgr);
- }
-}
-
-void
-isc__nm_tlsdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(result != ISC_R_SUCCESS);
-
- isc__nmsocket_timer_stop(sock);
- isc__nm_stop_reading(sock);
-
- if (sock->tls.pending_req) {
- isc__nm_uvreq_t *req = sock->tls.pending_req;
- sock->tls.pending_req = NULL;
- isc__nm_failed_connect_cb(sock, req, ISC_R_CANCELED);
- }
-
- if (!sock->recv_read) {
- goto destroy;
- }
- sock->recv_read = false;
-
- if (sock->recv_cb != NULL) {
- isc__nm_uvreq_t *req = isc__nm_get_read_req(sock, NULL);
- isc__nmsocket_clearcb(sock);
- isc__nm_readcb(sock, req, result);
- }
-
-destroy:
- isc__nmsocket_prep_destroy(sock);
-
- /* We need to detach from quota after the read callback function had a
- * chance to be executed. */
- if (sock->quota) {
- isc_quota_detach(&sock->quota);
- }
-}
-
-void
-isc__nm_tlsdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
- REQUIRE(VALID_NMHANDLE(handle));
- REQUIRE(VALID_NMSOCK(handle->sock));
-
- isc_nmsocket_t *sock = handle->sock;
- isc__netievent_tlsdnsread_t *ievent = NULL;
-
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(sock->statichandle == handle);
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(!sock->recv_read);
-
- sock->recv_cb = cb;
- sock->recv_cbarg = cbarg;
- sock->recv_read = true;
- if (sock->read_timeout == 0) {
- sock->read_timeout =
- (atomic_load(&sock->keepalive)
- ? atomic_load(&sock->mgr->keepalive)
- : atomic_load(&sock->mgr->idle));
- }
-
- ievent = isc__nm_get_netievent_tlsdnsread(sock->mgr, sock);
-
- /*
- * This MUST be done asynchronously, no matter which thread we're
- * in. The callback function for isc_nm_read() often calls
- * isc_nm_read() again; if we tried to do that synchronously
- * we'd clash in processbuffer() and grow the stack indefinitely.
- */
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-
- return;
-}
-
-void
-isc__nm_async_tlsdnsread(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsread_t *ievent =
- (isc__netievent_tlsdnsread_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
- isc_result_t result = ISC_R_SUCCESS;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
-
- if (isc__nm_inactive(sock)) {
- sock->reading = true;
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
- return;
- }
-
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- isc__nm_failed_read_cb(sock, result);
- }
-}
-
-/*
- * Process a single packet from the incoming buffer.
- *
- * Return ISC_R_SUCCESS and attach 'handlep' to a handle if something
- * was processed; return ISC_R_NOMORE if there isn't a full message
- * to be processed.
- *
- * The caller will need to unreference the handle.
- */
-isc_result_t
-isc__nm_tlsdns_processbuffer(isc_nmsocket_t *sock) {
- size_t len;
- isc__nm_uvreq_t *req = NULL;
- isc_nmhandle_t *handle = NULL;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
-
- if (isc__nm_inactive(sock)) {
- return (ISC_R_CANCELED);
- }
-
- /*
- * If we don't even have the length yet, we can't do
- * anything.
- */
- if (sock->buf_len < 2) {
- return (ISC_R_NOMORE);
- }
-
- /*
- * Process the first packet from the buffer, leaving
- * the rest (if any) for later.
- */
- len = ntohs(*(uint16_t *)sock->buf);
- if (len > sock->buf_len - 2) {
- return (ISC_R_NOMORE);
- }
-
- req = isc__nm_get_read_req(sock, NULL);
- REQUIRE(VALID_UVREQ(req));
-
- /*
- * We need to launch the resume_processing after the buffer has
- * been consumed, thus we need to delay the detaching the handle.
- */
- isc_nmhandle_attach(req->handle, &handle);
-
- /*
- * The callback will be called synchronously because the
- * result is ISC_R_SUCCESS, so we don't need to have
- * the buffer on the heap
- */
- req->uvbuf.base = (char *)sock->buf + 2;
- req->uvbuf.len = len;
-
- /*
- * If isc__nm_tlsdns_read() was called, it will be satisfied by single
- * DNS message in the next call.
- */
- sock->recv_read = false;
-
- /*
- * The assertion failure here means that there's a errnoneous extra
- * nmhandle detach happening in the callback and resume_processing gets
- * called while we are still processing the buffer.
- */
- REQUIRE(sock->processing == false);
- sock->processing = true;
- isc__nm_readcb(sock, req, ISC_R_SUCCESS);
- sock->processing = false;
-
- len += 2;
- sock->buf_len -= len;
- if (sock->buf_len > 0) {
- memmove(sock->buf, sock->buf + len, sock->buf_len);
- }
-
- isc_nmhandle_detach(&handle);
-
- return (ISC_R_SUCCESS);
-}
-
-static isc_result_t
-tls_cycle_input(isc_nmsocket_t *sock) {
- isc_result_t result = ISC_R_SUCCESS;
- int err = 0;
- int rv = 1;
-
- if (sock->tls.state == TLS_STATE_IO) {
- size_t len;
-
- for (;;) {
- (void)SSL_peek(sock->tls.ssl, &(char){ '\0' }, 0);
-
- int pending = SSL_pending(sock->tls.ssl);
- if (pending > ISC_NETMGR_TLSBUF_SIZE) {
- pending = ISC_NETMGR_TLSBUF_SIZE;
- }
-
- if ((sock->buf_len + pending) > sock->buf_size) {
- isc__nm_alloc_dnsbuf(sock,
- sock->buf_len + pending);
- }
-
- len = 0;
- rv = SSL_read_ex(sock->tls.ssl,
- sock->buf + sock->buf_len,
- sock->buf_size - sock->buf_len, &len);
- if (rv != 1) {
- /* Process what's in the buffer so far */
- isc__nm_process_sock_buffer(sock);
-
- /* FIXME: Should we call failed_read_cb()? */
- break;
- }
-
- REQUIRE((size_t)pending == len);
-
- sock->buf_len += len;
-
- isc__nm_process_sock_buffer(sock);
- }
- } else if (!SSL_is_init_finished(sock->tls.ssl)) {
- if (SSL_is_server(sock->tls.ssl)) {
- rv = SSL_accept(sock->tls.ssl);
- } else {
- rv = SSL_connect(sock->tls.ssl);
- }
-
- } else {
- rv = 1;
- }
-
- if (rv <= 0) {
- err = SSL_get_error(sock->tls.ssl, rv);
- }
-
- switch (err) {
- case SSL_ERROR_WANT_READ:
- if (sock->tls.state == TLS_STATE_NONE &&
- !SSL_is_init_finished(sock->tls.ssl)) {
- sock->tls.state = TLS_STATE_HANDSHAKE;
- isc__nm_process_sock_buffer(sock);
- }
- /* else continue reading */
- break;
- case SSL_ERROR_WANT_WRITE:
- async_tlsdns_cycle(sock);
- break;
- case SSL_ERROR_WANT_X509_LOOKUP:
- /* Continue reading/writing */
- break;
- case 0:
- /* Everything is ok, continue */
- break;
- case SSL_ERROR_ZERO_RETURN:
- return (ISC_R_EOF);
- default:
- return (ISC_R_TLSERROR);
- }
-
- /* Stop state after handshake */
- if (sock->tls.state == TLS_STATE_HANDSHAKE &&
- SSL_is_init_finished(sock->tls.ssl))
- {
- sock->tls.state = TLS_STATE_IO;
-
- if (SSL_is_server(sock->tls.ssl)) {
- REQUIRE(sock->recv_handle != NULL);
- result = sock->accept_cb(sock->recv_handle,
- ISC_R_SUCCESS,
- sock->accept_cbarg);
-
- if (result != ISC_R_SUCCESS) {
- isc_nmhandle_detach(&sock->recv_handle);
- goto failure;
- }
- } else {
- isc__nm_uvreq_t *req = sock->tls.pending_req;
- sock->tls.pending_req = NULL;
-
- atomic_store(&sock->connecting, false);
-
- isc__nm_connectcb(sock, req, ISC_R_SUCCESS);
- }
- async_tlsdns_cycle(sock);
- }
-failure:
- return (result);
-}
-
-static void
-tls_error(isc_nmsocket_t *sock, isc_result_t result) {
- switch (sock->tls.state) {
- case TLS_STATE_HANDSHAKE:
- case TLS_STATE_IO:
- isc__nmsocket_timer_stop(sock);
- isc__nm_stop_reading(sock);
- break;
- case TLS_STATE_ERROR:
- return;
- default:
- break;
- }
-
- sock->tls.state = TLS_STATE_ERROR;
- sock->tls.pending_error = result;
-
- /* tlsdns_close_direct(sock); */
-}
-
-static void
-free_senddata(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tls.senddata.base != NULL);
- REQUIRE(sock->tls.senddata.len > 0);
-
- isc_mem_put(sock->mgr->mctx, sock->tls.senddata.base,
- sock->tls.senddata.len);
- sock->tls.senddata.base = NULL;
- sock->tls.senddata.len = 0;
-}
-
-static void
-tls_write_cb(uv_write_t *req, int status) {
- isc_result_t result;
- isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
- isc_nmsocket_t *sock = uvreq->sock;
-
- free_senddata(sock);
-
- if (status != 0) {
- tls_error(sock, isc__nm_uverr2result(status));
- return;
- }
-
- isc__nm_uvreq_put(&uvreq, sock);
-
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- tls_error(sock, result);
- return;
- }
-}
-
-static isc_result_t
-tls_cycle_output(isc_nmsocket_t *sock) {
- isc_result_t result = ISC_R_SUCCESS;
- int pending;
-
- while ((pending = BIO_pending(sock->tls.app_rbio)) > 0) {
- isc__nm_uvreq_t *req = NULL;
- size_t bytes;
- int rv;
- int err;
-
- if (sock->tls.senddata.base != NULL ||
- sock->tls.senddata.len > 0) {
- break;
- }
-
- if (pending > ISC_NETMGR_TLSBUF_SIZE) {
- pending = ISC_NETMGR_TLSBUF_SIZE;
- }
-
- sock->tls.senddata.base = isc_mem_get(sock->mgr->mctx, pending);
- sock->tls.senddata.len = pending;
-
- rv = BIO_read_ex(sock->tls.app_rbio, sock->tls.senddata.base,
- pending, &bytes);
-
- RUNTIME_CHECK(rv == 1);
- INSIST((size_t)pending == bytes);
-
- err = uv_try_write(&sock->uv_handle.stream, &sock->tls.senddata,
- 1);
-
- if (err == pending) {
- /* Wrote everything, restart */
- free_senddata(sock);
- continue;
- }
-
- if (err > 0) {
- /* Partial write, send rest asynchronously */
- memmove(sock->tls.senddata.base,
- sock->tls.senddata.base + err, pending - err);
- sock->tls.senddata.len = pending - err;
- } else if (err == UV_ENOSYS || err == UV_EAGAIN) {
- /* uv_try_write is not supported, send asynchronously */
- } else {
- result = isc__nm_uverr2result(err);
- free_senddata(sock);
- break;
- }
-
- req = isc__nm_uvreq_get(sock->mgr, sock);
- req->uvbuf.base = (char *)sock->tls.senddata.base;
- req->uvbuf.len = sock->tls.senddata.len;
-
- err = uv_write(&req->uv_req.write, &sock->uv_handle.stream,
- &sock->tls.senddata, 1, tls_write_cb);
-
- INSIST(err == 0);
-
- break;
- }
-
- return (result);
-}
-
-static isc_result_t
-tls_pop_error(isc_nmsocket_t *sock) {
- isc_result_t result;
-
- if (sock->tls.state != TLS_STATE_ERROR) {
- return (ISC_R_SUCCESS);
- }
-
- if (sock->tls.pending_error == ISC_R_SUCCESS) {
- return (ISC_R_TLSERROR);
- }
-
- result = sock->tls.pending_error;
- sock->tls.pending_error = ISC_R_SUCCESS;
-
- return (result);
-}
-
-static isc_result_t
-tls_cycle(isc_nmsocket_t *sock) {
- isc_result_t result;
-
- result = tls_pop_error(sock);
- if (result != ISC_R_SUCCESS) {
- goto done;
- }
-
- if (sock->tls.cycle) {
- return (ISC_R_SUCCESS);
- }
-
- sock->tls.cycle = true;
- result = tls_cycle_input(sock);
- if (result != ISC_R_SUCCESS) {
- goto done;
- }
-
- result = tls_cycle_output(sock);
- if (result != ISC_R_SUCCESS) {
- goto done;
- }
-done:
- sock->tls.cycle = false;
-
- return (result);
-}
-
-static void
-async_tlsdns_cycle(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
-
- /* Socket was closed midflight by isc__nm_tlsdns_shutdown() */
- if (!isc__nmsocket_active(sock)) {
- return;
- }
-
- isc__netievent_tlsdnscycle_t *ievent =
- isc__nm_get_netievent_tlsdnscycle(sock->mgr, sock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-void
-isc__nm_async_tlsdnscycle(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnscycle_t *ievent =
- (isc__netievent_tlsdnscycle_t *)ev0;
- isc_result_t result;
- isc_nmsocket_t *sock;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(ievent->sock));
- REQUIRE(ievent->sock->tid == isc_nm_tid());
-
- sock = ievent->sock;
-
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- tls_error(sock, result);
- }
-}
-
-void
-isc__nm_tlsdns_read_cb(uv_stream_t *stream, ssize_t nread,
- const uv_buf_t *buf) {
- isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)stream);
- size_t len;
- isc_result_t result;
- int rv;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(sock->reading);
- REQUIRE(buf != NULL);
-
- if (isc__nm_inactive(sock)) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
- goto free;
- }
-
- if (nread < 0) {
- if (nread != UV_EOF) {
- isc__nm_incstats(sock->mgr,
- sock->statsindex[STATID_RECVFAIL]);
- }
-
- isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nread));
-
- goto free;
- }
-
- if (!atomic_load(&sock->client)) {
- sock->read_timeout = atomic_load(&sock->mgr->idle);
- }
-
- /*
- * The input has to be fed into BIO
- */
- rv = BIO_write_ex(sock->tls.app_wbio, buf->base, (size_t)nread, &len);
-
- if (rv <= 0 || (size_t)nread != len) {
- isc__nm_failed_read_cb(sock, ISC_R_TLSERROR);
- goto free;
- }
-
- result = tls_cycle(sock);
- if (result != ISC_R_SUCCESS) {
- isc__nm_failed_read_cb(sock, result);
- }
-free:
- async_tlsdns_cycle(sock);
- isc__nm_free_uvbuf(sock, buf);
-}
-
-static void
-quota_accept_cb(isc_quota_t *quota, void *sock0) {
- isc_nmsocket_t *sock = (isc_nmsocket_t *)sock0;
-
- REQUIRE(VALID_NMSOCK(sock));
-
- /*
- * Create a tlsdnsaccept event and pass it using the async channel.
- */
-
- isc__netievent_tlsdnsaccept_t *ievent =
- isc__nm_get_netievent_tlsdnsaccept(sock->mgr, sock, quota);
- isc__nm_maybe_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-/*
- * This is called after we get a quota_accept_cb() callback.
- */
-void
-isc__nm_async_tlsdnsaccept(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsaccept_t *ievent =
- (isc__netievent_tlsdnsaccept_t *)ev0;
- isc_result_t result;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(ievent->sock));
- REQUIRE(ievent->sock->tid == isc_nm_tid());
-
- result = accept_connection(ievent->sock, ievent->quota);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOCONN) {
- if ((result != ISC_R_QUOTA && result != ISC_R_SOFTQUOTA) ||
- can_log_tlsdns_quota())
- {
- isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
- ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
- "TCP connection failed: %s",
- isc_result_totext(result));
- }
- }
-}
-
-static isc_result_t
-accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
- isc_nmsocket_t *csock = NULL;
- isc__networker_t *worker = NULL;
- int r;
- isc_result_t result;
- struct sockaddr_storage peer_ss;
- struct sockaddr_storage local_ss;
- isc_sockaddr_t local;
- isc_nmhandle_t *handle = NULL;
-
- REQUIRE(VALID_NMSOCK(ssock));
- REQUIRE(ssock->tid == isc_nm_tid());
-
- if (isc__nm_inactive(ssock)) {
- if (quota != NULL) {
- isc_quota_detach(&quota);
- }
- return (ISC_R_CANCELED);
- }
-
- REQUIRE(ssock->accept_cb != NULL);
-
- csock = isc_mem_get(ssock->mgr->mctx, sizeof(isc_nmsocket_t));
- isc__nmsocket_init(csock, ssock->mgr, isc_nm_tlsdnssocket,
- ssock->iface);
- csock->tid = ssock->tid;
- csock->extrahandlesize = ssock->extrahandlesize;
- isc__nmsocket_attach(ssock, &csock->server);
- csock->accept_cb = ssock->accept_cb;
- csock->accept_cbarg = ssock->accept_cbarg;
- csock->recv_cb = ssock->recv_cb;
- csock->recv_cbarg = ssock->recv_cbarg;
- csock->quota = quota;
- csock->accepting = true;
-
- worker = &csock->mgr->workers[csock->tid];
-
- r = uv_tcp_init(&worker->loop, &csock->uv_handle.tcp);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data(&csock->uv_handle.handle, csock);
-
- r = uv_timer_init(&worker->loop, &csock->timer);
- RUNTIME_CHECK(r == 0);
- uv_handle_set_data((uv_handle_t *)&csock->timer, csock);
-
- r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
- if (r != 0) {
- result = isc__nm_uverr2result(r);
- goto failure;
- }
-
- r = uv_tcp_getpeername(&csock->uv_handle.tcp,
- (struct sockaddr *)&peer_ss,
- &(int){ sizeof(peer_ss) });
- if (r != 0) {
- result = isc__nm_uverr2result(r);
- goto failure;
- }
-
- result = isc_sockaddr_fromsockaddr(&csock->peer,
- (struct sockaddr *)&peer_ss);
- if (result != ISC_R_SUCCESS) {
- goto failure;
- }
-
- r = uv_tcp_getsockname(&csock->uv_handle.tcp,
- (struct sockaddr *)&local_ss,
- &(int){ sizeof(local_ss) });
- if (r != 0) {
- result = isc__nm_uverr2result(r);
- goto failure;
- }
-
- result = isc_sockaddr_fromsockaddr(&local,
- (struct sockaddr *)&local_ss);
- if (result != ISC_R_SUCCESS) {
- goto failure;
- }
-
- /*
- * The handle will be either detached on acceptcb failure or in the
- * readcb.
- */
- handle = isc__nmhandle_get(csock, NULL, &local);
-
- result = ssock->accept_cb(handle, ISC_R_SUCCESS, ssock->accept_cbarg);
- if (result != ISC_R_SUCCESS) {
- isc_nmhandle_detach(&handle);
- goto failure;
- }
-
- csock->tls.state = TLS_STATE_NONE;
-
- csock->tls.ssl = SSL_new(ssock->tls.ctx);
-
- if (csock->tls.ssl == NULL) {
- char errbuf[256];
- unsigned long err = ERR_get_error();
-
- ERR_error_string_n(err, errbuf, sizeof(errbuf));
- fprintf(stderr, "%s:SSL_new(%p) -> %s\n", __func__,
- ssock->tls.ctx, errbuf);
- }
-
- RUNTIME_CHECK(csock->tls.ssl != NULL);
-
- r = BIO_new_bio_pair(&csock->tls.ssl_wbio, ISC_NETMGR_TLSBUF_SIZE,
- &csock->tls.app_rbio, ISC_NETMGR_TLSBUF_SIZE);
- RUNTIME_CHECK(r == 1);
-
- r = BIO_new_bio_pair(&csock->tls.ssl_rbio, ISC_NETMGR_TLSBUF_SIZE,
- &csock->tls.app_wbio, ISC_NETMGR_TLSBUF_SIZE);
- RUNTIME_CHECK(r == 1);
-
-#if HAVE_SSL_SET0_RBIO && HAVE_SSL_SET0_WBIO
- /*
- * Note that if the rbio and wbio are the same then SSL_set0_rbio() and
- * SSL_set0_wbio() each take ownership of one reference. Therefore it
- * may be necessary to increment the number of references available
- * using BIO_up_ref(3) before calling the set0 functions.
- */
- SSL_set0_rbio(csock->tls.ssl, csock->tls.ssl_rbio);
- SSL_set0_wbio(csock->tls.ssl, csock->tls.ssl_wbio);
-#else
- SSL_set_bio(csock->tls.ssl, csock->tls.ssl_rbio, csock->tls.ssl_wbio);
-#endif
-
- SSL_set_accept_state(csock->tls.ssl);
-
- /* FIXME: Set SSL_MODE_RELEASE_BUFFERS */
-
- csock->accepting = false;
-
- isc__nm_incstats(csock->mgr, csock->statsindex[STATID_ACCEPT]);
-
- csock->read_timeout = atomic_load(&csock->mgr->init);
-
- csock->closehandle_cb = isc__nm_resume_processing;
-
- /*
- * We need to keep the handle alive until we fail to read or connection
- * is closed by the other side, it will be detached via
- * prep_destroy()->tlsdns_close_direct().
- */
- isc_nmhandle_attach(handle, &csock->recv_handle);
-
- /*
- * The initial timer has been set, update the read timeout for the next
- * reads.
- */
- csock->read_timeout = (atomic_load(&csock->keepalive)
- ? atomic_load(&csock->mgr->keepalive)
- : atomic_load(&csock->mgr->idle));
-
- isc_nmhandle_detach(&handle);
-
- isc__nm_process_sock_buffer(csock);
-
- /*
- * sock is now attached to the handle.
- */
- isc__nmsocket_detach(&csock);
-
- return (ISC_R_SUCCESS);
-
-failure:
- atomic_store(&csock->active, false);
-
- isc__nm_failed_accept_cb(csock, result);
-
- isc__nmsocket_prep_destroy(csock);
-
- isc__nmsocket_detach(&csock);
-
- return (result);
-}
-
-void
-isc__nm_tlsdns_send(isc_nmhandle_t *handle, isc_region_t *region,
- isc_nm_cb_t cb, void *cbarg) {
- REQUIRE(VALID_NMHANDLE(handle));
- REQUIRE(VALID_NMSOCK(handle->sock));
-
- isc_nmsocket_t *sock = handle->sock;
- isc__netievent_tlsdnssend_t *ievent = NULL;
- isc__nm_uvreq_t *uvreq = NULL;
-
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
-
- uvreq = isc__nm_uvreq_get(sock->mgr, sock);
- *(uint16_t *)uvreq->tcplen = htons(region->length);
- uvreq->uvbuf.base = (char *)region->base;
- uvreq->uvbuf.len = region->length;
-
- isc_nmhandle_attach(handle, &uvreq->handle);
-
- uvreq->cb.send = cb;
- uvreq->cbarg = cbarg;
-
- ievent = isc__nm_get_netievent_tlsdnssend(sock->mgr, sock, uvreq);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
- return;
-}
-
-/*
- * Handle 'tcpsend' async event - send a packet on the socket
- */
-void
-isc__nm_async_tlsdnssend(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc_result_t result;
- isc__netievent_tlsdnssend_t *ievent =
- (isc__netievent_tlsdnssend_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
- isc__nm_uvreq_t *uvreq = ievent->req;
-
- UNUSED(worker);
-
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(sock->tid == isc_nm_tid());
-
- result = tlsdns_send_direct(sock, uvreq);
- if (result != ISC_R_SUCCESS) {
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_SENDFAIL]);
- isc__nm_failed_send_cb(sock, uvreq, result);
- }
-}
-
-static void
-tlsdns_send_enqueue(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
- isc__netievent_tlsdnssend_t *ievent =
- isc__nm_get_netievent_tlsdnssend(sock->mgr, sock, req);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-static isc_result_t
-tlsdns_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
- isc_result_t result;
- int err = 0;
- int rv;
- size_t bytes = 0;
- size_t sendlen;
- isc__networker_t *worker = NULL;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(VALID_UVREQ(req));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
-
- result = tls_pop_error(sock);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- if (isc__nm_inactive(sock)) {
- return (ISC_R_CANCELED);
- }
-
- /* Writes won't succeed until handshake end */
- if (!SSL_is_init_finished(sock->tls.ssl)) {
- goto requeue;
- }
-
- /*
- * There's no SSL_writev(), so we need to use a local buffer to assemble
- * the whole message
- */
- worker = &sock->mgr->workers[sock->tid];
- sendlen = req->uvbuf.len + sizeof(uint16_t);
- memmove(worker->sendbuf, req->tcplen, sizeof(uint16_t));
- memmove(worker->sendbuf + sizeof(uint16_t), req->uvbuf.base,
- req->uvbuf.len);
-
- rv = SSL_write_ex(sock->tls.ssl, worker->sendbuf, sendlen, &bytes);
- if (rv > 0) {
- /* SSL_write_ex() doesn't do partial writes */
- INSIST(sendlen == bytes);
-
- isc__nm_sendcb(sock, req, ISC_R_SUCCESS, true);
- async_tlsdns_cycle(sock);
- return (ISC_R_SUCCESS);
- }
-
- /* Nothing was written, maybe enqueue? */
- err = SSL_get_error(sock->tls.ssl, rv);
-
- switch (err) {
- case SSL_ERROR_WANT_WRITE:
- case SSL_ERROR_WANT_READ:
- break;
- case 0:
- INSIST(0);
- ISC_UNREACHABLE();
- default:
- return (ISC_R_TLSERROR);
- }
-
- result = tls_cycle(sock);
-
-requeue:
-
- tlsdns_send_enqueue(sock, req);
-
- return (result);
-}
-
-static void
-tlsdns_stop_cb(uv_handle_t *handle) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->closing));
-
- uv_handle_set_data(handle, NULL);
-
- if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false },
- true)) {
- INSIST(0);
- ISC_UNREACHABLE();
- }
-
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CLOSE]);
-
- atomic_store(&sock->listening, false);
-
- BIO_free_all(sock->tls.app_rbio);
- BIO_free_all(sock->tls.app_wbio);
-
- sock->tls.ctx = NULL;
-
- isc__nmsocket_detach(&sock);
-}
-
-static void
-tlsdns_close_cb(uv_handle_t *handle) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
- uv_handle_set_data(handle, NULL);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->closing));
-
- if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false },
- true)) {
- INSIST(0);
- ISC_UNREACHABLE();
- }
-
- isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CLOSE]);
-
- if (sock->server != NULL) {
- isc__nmsocket_detach(&sock->server);
- }
-
- atomic_store(&sock->connected, false);
-
- if (sock->tls.ssl) {
- SSL_free(sock->tls.ssl);
- sock->tls.ssl = NULL;
- }
-
- BIO_free_all(sock->tls.app_rbio);
- BIO_free_all(sock->tls.app_wbio);
-
- sock->tls.ctx = NULL;
-
- isc__nmsocket_prep_destroy(sock);
-}
-
-static void
-timer_close_cb(uv_handle_t *handle) {
- isc_nmsocket_t *sock = uv_handle_get_data(handle);
-
- uv_handle_set_data(handle, NULL);
-
- if (sock->parent) {
- uv_close(&sock->uv_handle.handle, tlsdns_stop_cb);
- } else {
- uv_close(&sock->uv_handle.handle, tlsdns_close_cb);
- }
-}
-
-static void
-stop_tlsdns_child(isc_nmsocket_t *sock) {
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(sock->tid == isc_nm_tid());
-
- if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false },
- true)) {
- return;
- }
-
- tlsdns_close_direct(sock);
-
- LOCK(&sock->parent->lock);
- sock->parent->rchildren -= 1;
- UNLOCK(&sock->parent->lock);
- BROADCAST(&sock->parent->cond);
-}
-
-static void
-stop_tlsdns_parent(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tlsdnslistener);
-
- for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_tlsdnsstop_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
-
- REQUIRE(VALID_NMSOCK(csock));
-
- atomic_store(&csock->active, false);
-
- if (csock->tid == isc_nm_tid()) {
- stop_tlsdns_child(csock);
- continue;
- }
-
- ievent = isc__nm_get_netievent_tlsdnsstop(sock->mgr, csock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[csock->tid],
- (isc__netievent_t *)ievent);
- }
-
- LOCK(&sock->lock);
- while (sock->rchildren > 0) {
- WAIT(&sock->cond, &sock->lock);
- }
- atomic_store(&sock->closed, true);
- UNLOCK(&sock->lock);
-
- isc__nmsocket_prep_destroy(sock);
-}
-
-static void
-tlsdns_close_direct(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(atomic_load(&sock->closing));
-
- if (sock->quota != NULL) {
- isc_quota_detach(&sock->quota);
- }
-
- if (sock->recv_handle != NULL) {
- isc_nmhandle_detach(&sock->recv_handle);
- }
-
- isc__nmsocket_timer_stop(sock);
- isc__nm_stop_reading(sock);
- uv_close((uv_handle_t *)&sock->timer, timer_close_cb);
-}
-
-void
-isc__nm_tlsdns_close(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
- REQUIRE(!isc__nmsocket_active(sock));
-
- if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false },
- true)) {
- return;
- }
-
- if (sock->tid == isc_nm_tid()) {
- tlsdns_close_direct(sock);
- } else {
- /*
- * We need to create an event and pass it using async channel
- */
- isc__netievent_tlsdnsclose_t *ievent =
- isc__nm_get_netievent_tlsdnsclose(sock->mgr, sock);
-
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
- }
-}
-
-void
-isc__nm_async_tlsdnsclose(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnsclose_t *ievent =
- (isc__netievent_tlsdnsclose_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
-
- tlsdns_close_direct(sock);
-}
-
-void
-isc__nm_tlsdns_shutdown(isc_nmsocket_t *sock) {
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
-
- /*
- * If the socket is active, mark it inactive and
- * continue. If it isn't active, stop now.
- */
- if (!isc__nmsocket_deactivate(sock)) {
- return;
- }
-
- if (atomic_load(&sock->connecting) || sock->accepting) {
- return;
- }
-
- if (sock->tls.pending_req) {
- isc__nm_uvreq_t *req = sock->tls.pending_req;
- sock->tls.pending_req = NULL;
- isc__nm_failed_connect_cb(sock, req, ISC_R_CANCELED);
- }
-
- if (sock->statichandle) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
- return;
- }
-
- /*
- * Otherwise, we just send the socket to abyss...
- */
- if (sock->parent == NULL) {
- isc__nmsocket_prep_destroy(sock);
- }
-}
-
-void
-isc__nm_tlsdns_cancelread(isc_nmhandle_t *handle) {
- isc_nmsocket_t *sock = NULL;
- isc__netievent_tlsdnscancel_t *ievent = NULL;
-
- REQUIRE(VALID_NMHANDLE(handle));
-
- sock = handle->sock;
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->type == isc_nm_tlsdnssocket);
-
- ievent = isc__nm_get_netievent_tlsdnscancel(sock->mgr, sock, handle);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
-}
-
-void
-isc__nm_async_tlsdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_tlsdnscancel_t *ievent =
- (isc__netievent_tlsdnscancel_t *)ev0;
- isc_nmsocket_t *sock = ievent->sock;
-
- UNUSED(worker);
-
- REQUIRE(VALID_NMSOCK(sock));
- REQUIRE(sock->tid == isc_nm_tid());
-
- isc__nm_failed_read_cb(sock, ISC_R_EOF);
-}
-
-void
-isc_nm_tlsdns_sequential(isc_nmhandle_t *handle) {
- isc_nmsocket_t *sock = NULL;
-
- REQUIRE(VALID_NMHANDLE(handle));
- REQUIRE(VALID_NMSOCK(handle->sock));
- REQUIRE(handle->sock->type == isc_nm_tlsdnssocket);
-
- sock = handle->sock;
-
- /*
- * We don't want pipelining on this connection. That means
- * that we need to pause after reading each request, and
- * resume only after the request has been processed. This
- * is done in resume_processing(), which is the socket's
- * closehandle_cb callback, called whenever a handle
- * is released.
- */
-
- isc__nmsocket_timer_stop(sock);
- isc__nm_stop_reading(sock);
- atomic_store(&sock->sequential, true);
-}
-
-void
-isc_nm_tlsdns_keepalive(isc_nmhandle_t *handle, bool value) {
- isc_nmsocket_t *sock = NULL;
-
- REQUIRE(VALID_NMHANDLE(handle));
- REQUIRE(VALID_NMSOCK(handle->sock));
- REQUIRE(handle->sock->type != isc_nm_tlsdnssocket);
-
- sock = handle->sock;
-
- atomic_store(&sock->keepalive, value);
-}
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/udp.c b/external/mpl/bind/dist/lib/isc/netmgr/udp.c
index 4189284f7e6..b3e7bee9c34 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/udp.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/udp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udp.c,v 1.8 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: udp.c,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,6 +15,7 @@
#include <uv.h>
#include <isc/atomic.h>
+#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/errno.h>
@@ -66,7 +67,7 @@ isc__nm_udp_lb_socket(sa_family_t sa_family) {
RUNTIME_CHECK(result == ISC_R_SUCCESS);
(void)isc__nm_socket_incoming_cpu(sock);
- (void)isc__nm_socket_dontfrag(sock, sa_family);
+ (void)isc__nm_socket_disable_pmtud(sock, sa_family);
result = isc__nm_socket_reuse(sock);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
@@ -79,18 +80,52 @@ isc__nm_udp_lb_socket(sa_family_t sa_family) {
return (sock);
}
+static void
+start_udp_child(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nmsocket_t *sock,
+ uv_os_sock_t fd, int tid) {
+ isc_nmsocket_t *csock;
+ isc__netievent_udplisten_t *ievent = NULL;
+
+ csock = &sock->children[tid];
+
+ isc__nmsocket_init(csock, mgr, isc_nm_udpsocket, iface);
+ csock->parent = sock;
+ csock->iface = sock->iface;
+ csock->reading = true;
+ csock->recv_cb = sock->recv_cb;
+ csock->recv_cbarg = sock->recv_cbarg;
+ csock->extrahandlesize = sock->extrahandlesize;
+ csock->tid = tid;
+
+#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
+ UNUSED(fd);
+ csock->fd = isc__nm_udp_lb_socket(iface->type.sa.sa_family);
+#else
+ csock->fd = dup(fd);
+#endif
+ REQUIRE(csock->fd >= 0);
+
+ ievent = isc__nm_get_netievent_udplisten(mgr, csock);
+ isc__nm_maybe_enqueue_ievent(&mgr->workers[tid],
+ (isc__netievent_t *)ievent);
+}
+
+static void
+enqueue_stoplistening(isc_nmsocket_t *sock) {
+ isc__netievent_udpstop_t *ievent =
+ isc__nm_get_netievent_udpstop(sock->mgr, sock);
+ isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
+}
+
isc_result_t
-isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
+isc_nm_listenudp(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nm_recv_cb_t cb,
void *cbarg, size_t extrahandlesize, isc_nmsocket_t **sockp) {
isc_result_t result = ISC_R_SUCCESS;
isc_nmsocket_t *sock = NULL;
- sa_family_t sa_family = iface->addr.type.sa.sa_family;
size_t children_size = 0;
-#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- uv_os_sock_t fd = -1;
-#endif
-
REQUIRE(VALID_NM(mgr));
+ uv_os_sock_t fd = -1;
/*
* We are creating mgr->nworkers duplicated sockets, one
@@ -99,7 +134,7 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
sock = isc_mem_get(mgr->mctx, sizeof(isc_nmsocket_t));
isc__nmsocket_init(sock, mgr, isc_nm_udplistener, iface);
- sock->rchildren = 0;
+ atomic_init(&sock->rchildren, 0);
#if defined(WIN32)
sock->nchildren = 1;
#else
@@ -113,37 +148,26 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
sock->recv_cb = cb;
sock->recv_cbarg = cbarg;
sock->extrahandlesize = extrahandlesize;
- sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(sock->nchildren);
+ sock->result = ISC_R_UNSET;
+
+ sock->tid = 0;
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
- fd = isc__nm_udp_lb_socket(sa_family);
+ fd = isc__nm_udp_lb_socket(iface->type.sa.sa_family);
#endif
- for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_udplisten_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
-
- isc__nmsocket_init(csock, mgr, isc_nm_udpsocket, iface);
- csock->parent = sock;
- csock->iface = sock->iface;
- csock->reading = true;
- csock->recv_cb = cb;
- csock->recv_cbarg = cbarg;
- csock->extrahandlesize = sock->extrahandlesize;
- csock->tid = i;
+ isc_barrier_init(&sock->startlistening, sock->nchildren);
-#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
- csock->fd = isc__nm_udp_lb_socket(sa_family);
-#else
- csock->fd = dup(fd);
-#endif
- REQUIRE(csock->fd >= 0);
+ for (size_t i = 0; i < sock->nchildren; i++) {
+ if ((int)i == isc_nm_tid()) {
+ continue;
+ }
+ start_udp_child(mgr, iface, sock, fd, i);
+ }
- ievent = isc__nm_get_netievent_udplisten(mgr, csock);
- isc__nm_enqueue_ievent(&mgr->workers[i],
- (isc__netievent_t *)ievent);
+ if (isc__nm_in_netthread()) {
+ start_udp_child(mgr, iface, sock, fd, isc_nm_tid());
}
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
@@ -151,21 +175,21 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
#endif
LOCK(&sock->lock);
- while (sock->rchildren != sock->nchildren) {
+ while (atomic_load(&sock->rchildren) != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
atomic_store(&sock->active, true);
- BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- INSIST(result != ISC_R_DEFAULT);
+
+ INSIST(result != ISC_R_UNSET);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == sock->nchildren);
+ REQUIRE(atomic_load(&sock->rchildren) == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
- isc__nm_udp_stoplistening(sock);
+ enqueue_stoplistening(sock);
isc_nmsocket_close(&sock);
}
@@ -178,23 +202,20 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
void
isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_udplisten_t *ievent = (isc__netievent_udplisten_t *)ev0;
- isc_nmiface_t *iface = NULL;
isc_nmsocket_t *sock = NULL;
int r, uv_bind_flags = 0;
int uv_init_flags = 0;
sa_family_t sa_family;
- isc_result_t result = ISC_R_DEFAULT;
+ isc_result_t result = ISC_R_UNSET;
REQUIRE(VALID_NMSOCK(ievent->sock));
REQUIRE(ievent->sock->tid == isc_nm_tid());
REQUIRE(VALID_NMSOCK(ievent->sock->parent));
sock = ievent->sock;
- iface = sock->iface;
- sa_family = iface->addr.type.sa.sa_family;
+ sa_family = sock->iface.type.sa.sa_family;
REQUIRE(sock->type == isc_nm_udpsocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent != NULL);
REQUIRE(sock->tid == isc_nm_tid());
@@ -227,8 +248,7 @@ isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
#if HAVE_SO_REUSEPORT_LB || defined(WIN32)
r = isc_uv_udp_freebind(&sock->uv_handle.udp,
- &sock->parent->iface->addr.type.sa,
- uv_bind_flags);
+ &sock->parent->iface.type.sa, uv_bind_flags);
if (r < 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
goto done;
@@ -237,7 +257,7 @@ isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
if (sock->parent->fd == -1) {
/* This thread is first, bind the socket */
r = isc_uv_udp_freebind(&sock->uv_handle.udp,
- &sock->parent->iface->addr.type.sa,
+ &sock->parent->iface.type.sa,
uv_bind_flags);
if (r < 0) {
isc__nm_incstats(sock->mgr,
@@ -271,24 +291,14 @@ isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
done:
result = isc__nm_uverr2result(r);
- sock->parent->rchildren += 1;
- if (sock->parent->result == ISC_R_DEFAULT) {
+ atomic_fetch_add(&sock->parent->rchildren, 1);
+ if (sock->parent->result == ISC_R_UNSET) {
sock->parent->result = result;
}
SIGNAL(&sock->parent->cond);
- if (!atomic_load(&sock->parent->active)) {
- WAIT(&sock->parent->scond, &sock->parent->lock);
- }
- INSIST(atomic_load(&sock->parent->active));
UNLOCK(&sock->parent->lock);
-}
-static void
-enqueue_stoplistening(isc_nmsocket_t *sock) {
- isc__netievent_udpstop_t *ievent =
- isc__nm_get_netievent_udpstop(sock->mgr, sock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
+ isc_barrier_wait(&sock->parent->startlistening);
}
void
@@ -302,7 +312,11 @@ isc__nm_udp_stoplistening(isc_nmsocket_t *sock) {
ISC_UNREACHABLE();
}
- enqueue_stoplistening(sock);
+ if (!isc__nm_in_netthread()) {
+ enqueue_stoplistening(sock);
+ } else {
+ stop_udp_parent(sock);
+ }
}
/*
@@ -323,15 +337,7 @@ isc__nm_async_udpstop(isc__networker_t *worker, isc__netievent_t *ev0) {
return;
}
- /*
- * If network manager is paused, re-enqueue the event for later.
- */
- if (!isc__nm_acquire_interlocked(sock->mgr)) {
- enqueue_stoplistening(sock);
- } else {
- stop_udp_parent(sock);
- isc__nm_drop_interlocked(sock->mgr);
- }
+ stop_udp_parent(sock);
}
/*
@@ -385,7 +391,7 @@ udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
* we can free the buffer and bail.
*/
if (addr == NULL) {
- isc__nm_failed_read_cb(sock, ISC_R_EOF);
+ isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
goto free;
}
@@ -393,12 +399,13 @@ udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
* - If the socket is no longer active.
*/
if (!isc__nmsocket_active(sock)) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
goto free;
}
if (nrecv < 0) {
- isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nrecv));
+ isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nrecv),
+ false);
goto free;
}
@@ -433,23 +440,16 @@ free:
* another thread.
*/
void
-isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
- void *cbarg) {
+isc__nm_udp_send(isc_nmhandle_t *handle, const isc_region_t *region,
+ isc_nm_cb_t cb, void *cbarg) {
isc_nmsocket_t *sock = handle->sock;
- isc_nmsocket_t *psock = NULL, *rsock = sock;
+ isc_nmsocket_t *rsock = NULL;
isc_sockaddr_t *peer = &handle->peer;
isc__nm_uvreq_t *uvreq = NULL;
uint32_t maxudp = atomic_load(&sock->mgr->maxudp);
int ntid;
- uvreq = isc__nm_uvreq_get(sock->mgr, sock);
- uvreq->uvbuf.base = (char *)region->base;
- uvreq->uvbuf.len = region->length;
-
- isc_nmhandle_attach(handle, &uvreq->handle);
-
- uvreq->cb.send = cb;
- uvreq->cbarg = cbarg;
+ INSIST(sock->type == isc_nm_udpsocket);
/*
* We're simulating a firewall blocking UDP packets bigger than
@@ -460,41 +460,50 @@ isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
* we need to do so here.
*/
if (maxudp != 0 && region->length > maxudp) {
- isc__nm_uvreq_put(&uvreq, sock);
- isc_nmhandle_detach(&handle); /* FIXME? */
+ isc_nmhandle_detach(&handle);
return;
}
- if (sock->type == isc_nm_udpsocket && !atomic_load(&sock->client)) {
+ if (atomic_load(&sock->client)) {
+ /*
+ * When we are sending from the client socket, we directly use
+ * the socket provided.
+ */
+ rsock = sock;
+ goto send;
+ } else {
+ /*
+ * When we are sending from the server socket, we either use the
+ * socket associated with the network thread we are in, or we
+ * use the thread from the socket associated with the handle.
+ */
INSIST(sock->parent != NULL);
- psock = sock->parent;
- } else if (sock->type == isc_nm_udplistener) {
- psock = sock;
- } else if (!atomic_load(&sock->client)) {
- INSIST(0);
- ISC_UNREACHABLE();
- }
- /*
- * If we're in the network thread, we can send directly. If the
- * handle is associated with a UDP socket, we can reuse its
- * thread (assuming CPU affinity). Otherwise, pick a thread at
- * random.
- */
- if (isc__nm_in_netthread()) {
- ntid = isc_nm_tid();
- } else if (sock->type == isc_nm_udpsocket &&
- !atomic_load(&sock->client)) {
- ntid = sock->tid;
- } else {
- ntid = (int)isc_random_uniform(sock->nchildren);
+#if defined(WIN32)
+ /* On Windows, we have only a single listening listener */
+ rsock = sock;
+#else
+ if (isc__nm_in_netthread()) {
+ ntid = isc_nm_tid();
+ } else {
+ ntid = sock->tid;
+ }
+ rsock = &sock->parent->children[ntid];
+#endif
}
- if (psock != NULL) {
- rsock = &psock->children[ntid];
- }
+send:
+ uvreq = isc__nm_uvreq_get(rsock->mgr, rsock);
+ uvreq->uvbuf.base = (char *)region->base;
+ uvreq->uvbuf.len = region->length;
+
+ isc_nmhandle_attach(handle, &uvreq->handle);
+
+ uvreq->cb.send = cb;
+ uvreq->cbarg = cbarg;
if (isc_nm_tid() == rsock->tid) {
+ REQUIRE(rsock->tid == isc_nm_tid());
isc__netievent_udpsend_t ievent = { .sock = rsock,
.req = uvreq,
.peer = *peer };
@@ -525,7 +534,7 @@ isc__nm_async_udpsend(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(sock->tid == isc_nm_tid());
UNUSED(worker);
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
isc__nm_failed_send_cb(sock, uvreq, ISC_R_CANCELED);
return;
}
@@ -541,11 +550,15 @@ static void
udp_send_cb(uv_udp_send_t *req, int status) {
isc_result_t result = ISC_R_SUCCESS;
isc__nm_uvreq_t *uvreq = uv_handle_get_data((uv_handle_t *)req);
- isc_nmsocket_t *sock = uvreq->sock;
+ isc_nmsocket_t *sock = NULL;
REQUIRE(VALID_UVREQ(uvreq));
REQUIRE(VALID_NMHANDLE(uvreq->handle));
+ sock = uvreq->sock;
+
+ REQUIRE(sock->tid == isc_nm_tid());
+
if (status < 0) {
result = isc__nm_uverr2result(status);
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_SENDFAIL]);
@@ -569,11 +582,11 @@ udp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->type == isc_nm_udpsocket);
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
return (ISC_R_CANCELED);
}
-#ifdef HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
/*
* If we used uv_udp_connect() (and not the shim version for
* older versions of libuv), then the peer address has to be
@@ -598,7 +611,8 @@ static isc_result_t
udp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
isc__networker_t *worker = NULL;
int uv_bind_flags = UV_UDP_REUSEADDR;
- isc_result_t result = ISC_R_DEFAULT;
+ isc_result_t result = ISC_R_UNSET;
+ int tries = 3;
int r;
REQUIRE(isc__nm_in_netthread());
@@ -618,17 +632,16 @@ udp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
r = uv_udp_open(&sock->uv_handle.udp, sock->fd);
if (r != 0) {
- isc__nm_closesocket(sock->fd);
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPENFAIL]);
goto done;
}
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPEN]);
- if (sock->iface->addr.type.sa.sa_family == AF_INET6) {
+ if (sock->iface.type.sa.sa_family == AF_INET6) {
uv_bind_flags |= UV_UDP_IPV6ONLY;
}
- r = uv_udp_bind(&sock->uv_handle.udp, &sock->iface->addr.type.sa,
+ r = uv_udp_bind(&sock->uv_handle.udp, &sock->iface.type.sa,
uv_bind_flags);
if (r != 0) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]);
@@ -644,7 +657,15 @@ udp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
&(int){ ISC_SEND_BUFFER_SIZE });
#endif
- r = isc_uv_udp_connect(&sock->uv_handle.udp, &req->peer.type.sa);
+ /*
+ * On FreeBSD the UDP connect() call sometimes results in a
+ * spurious transient EADDRINUSE. Try a few more times before
+ * giving up.
+ */
+ do {
+ r = isc_uv_udp_connect(&sock->uv_handle.udp,
+ &req->peer.type.sa);
+ } while (r == UV_EADDRINUSE && --tries > 0);
if (r != 0) {
isc__nm_incstats(sock->mgr,
sock->statsindex[STATID_CONNECTFAIL]);
@@ -686,22 +707,20 @@ isc__nm_async_udpconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_udpsocket);
- REQUIRE(sock->iface != NULL);
REQUIRE(sock->parent == NULL);
REQUIRE(sock->tid == isc_nm_tid());
- req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface->addr);
result = udp_connect_direct(sock, req);
if (result != ISC_R_SUCCESS) {
atomic_store(&sock->active, false);
isc__nm_udp_close(sock);
- isc__nm_uvreq_put(&req, sock);
+ isc__nm_connectcb(sock, req, result, true);
} else {
/*
* The callback has to be called after the socket has been
* initialized
*/
- isc__nm_connectcb(sock, req, ISC_R_SUCCESS);
+ isc__nm_connectcb(sock, req, ISC_R_SUCCESS, true);
}
/*
@@ -710,8 +729,8 @@ isc__nm_async_udpconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__nmsocket_detach(&sock);
}
-isc_result_t
-isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
+void
+isc_nm_udpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t cb, void *cbarg, unsigned int timeout,
size_t extrahandlesize) {
isc_result_t result = ISC_R_SUCCESS;
@@ -719,22 +738,12 @@ isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
isc__netievent_udpconnect_t *event = NULL;
isc__nm_uvreq_t *req = NULL;
sa_family_t sa_family;
- uv_os_sock_t fd;
REQUIRE(VALID_NM(mgr));
REQUIRE(local != NULL);
REQUIRE(peer != NULL);
- sa_family = peer->addr.type.sa.sa_family;
-
- /*
- * The socket() call can fail spuriously on FreeBSD 12, so we
- * need to handle the failure early and gracefully.
- */
- result = isc__nm_socket(sa_family, SOCK_DGRAM, 0, &fd);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ sa_family = peer->type.sa.sa_family;
sock = isc_mem_get(mgr->mctx, sizeof(isc_nmsocket_t));
isc__nmsocket_init(sock, mgr, isc_nm_udpsocket, local);
@@ -743,11 +752,29 @@ isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
sock->connect_cbarg = cbarg;
sock->read_timeout = timeout;
sock->extrahandlesize = extrahandlesize;
- sock->peer = peer->addr;
- sock->fd = fd;
- sock->result = ISC_R_DEFAULT;
+ sock->peer = *peer;
+ sock->result = ISC_R_UNSET;
atomic_init(&sock->client, true);
+ req = isc__nm_uvreq_get(mgr, sock);
+ req->cb.connect = cb;
+ req->cbarg = cbarg;
+ req->peer = *peer;
+ req->local = *local;
+ req->handle = isc__nmhandle_get(sock, &req->peer, &sock->iface);
+
+ result = isc__nm_socket(sa_family, SOCK_DGRAM, 0, &sock->fd);
+ if (result != ISC_R_SUCCESS) {
+ if (isc__nm_in_netthread()) {
+ sock->tid = isc_nm_tid();
+ }
+ isc__nmsocket_clearcb(sock);
+ isc__nm_connectcb(sock, req, result, true);
+ atomic_store(&sock->closed, true);
+ isc__nmsocket_detach(&sock);
+ return;
+ }
+
result = isc__nm_socket_reuse(sock->fd);
RUNTIME_CHECK(result == ISC_R_SUCCESS ||
result == ISC_R_NOTIMPLEMENTED);
@@ -758,13 +785,7 @@ isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
(void)isc__nm_socket_incoming_cpu(sock->fd);
- (void)isc__nm_socket_dontfrag(sock->fd, sa_family);
-
- req = isc__nm_uvreq_get(mgr, sock);
- req->cb.connect = cb;
- req->cbarg = cbarg;
- req->peer = peer->addr;
- req->local = local->addr;
+ (void)isc__nm_socket_disable_pmtud(sock->fd, sa_family);
event = isc__nm_get_netievent_udpconnect(mgr, sock, req);
@@ -781,17 +802,12 @@ isc_nm_udpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer,
(isc__netievent_t *)event);
}
LOCK(&sock->lock);
- result = sock->result;
- while (sock->result == ISC_R_DEFAULT) {
+ while (sock->result == ISC_R_UNSET) {
WAIT(&sock->cond, &sock->lock);
- result = sock->result;
}
atomic_store(&sock->active, true);
BROADCAST(&sock->scond);
UNLOCK(&sock->lock);
- ENSURE(result != ISC_R_DEFAULT);
-
- return (result);
}
void
@@ -819,6 +835,7 @@ isc__nm_udp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
REQUIRE(result != ISC_R_SUCCESS);
if (atomic_load(&sock->client)) {
+ isc__nmsocket_timer_stop(sock);
isc__nm_stop_reading(sock);
if (!sock->recv_read) {
@@ -870,9 +887,9 @@ isc__nm_async_udpread(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
- if (isc__nm_inactive(sock)) {
+ if (isc__nmsocket_closing(sock)) {
sock->reading = true;
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
return;
}
@@ -980,41 +997,41 @@ stop_udp_child(isc_nmsocket_t *sock) {
udp_close_direct(sock);
- LOCK(&sock->parent->lock);
- sock->parent->rchildren -= 1;
- UNLOCK(&sock->parent->lock);
- BROADCAST(&sock->parent->cond);
+ atomic_fetch_sub(&sock->parent->rchildren, 1);
+
+ isc_barrier_wait(&sock->parent->stoplistening);
}
static void
stop_udp_parent(isc_nmsocket_t *sock) {
+ isc_nmsocket_t *csock = NULL;
+
REQUIRE(VALID_NMSOCK(sock));
+ REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->type == isc_nm_udplistener);
+ isc_barrier_init(&sock->stoplistening, sock->nchildren);
+
for (size_t i = 0; i < sock->nchildren; i++) {
- isc__netievent_udpstop_t *ievent = NULL;
- isc_nmsocket_t *csock = &sock->children[i];
+ csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
- atomic_store(&csock->active, false);
-
- if (csock->tid == isc_nm_tid()) {
- stop_udp_child(csock);
+ if ((int)i == isc_nm_tid()) {
+ /*
+ * We need to schedule closing the other sockets first
+ */
continue;
}
- ievent = isc__nm_get_netievent_udpstop(sock->mgr, csock);
- isc__nm_enqueue_ievent(&sock->mgr->workers[i],
- (isc__netievent_t *)ievent);
+ atomic_store(&csock->active, false);
+ enqueue_stoplistening(csock);
}
- LOCK(&sock->lock);
- while (sock->rchildren > 0) {
- WAIT(&sock->cond, &sock->lock);
- }
- atomic_store(&sock->closed, true);
- UNLOCK(&sock->lock);
+ csock = &sock->children[isc_nm_tid()];
+ atomic_store(&csock->active, false);
+ stop_udp_child(csock);
+ atomic_store(&sock->closed, true);
isc__nmsocket_prep_destroy(sock);
}
@@ -1086,8 +1103,8 @@ isc__nm_udp_shutdown(isc_nmsocket_t *sock) {
* sock->statichandle would be NULL, in that case, nobody is
* interested in the callback.
*/
- if (sock->statichandle) {
- isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
+ if (sock->statichandle != NULL) {
+ isc__nm_failed_read_cb(sock, ISC_R_CANCELED, false);
return;
}
@@ -1131,5 +1148,5 @@ isc__nm_async_udpcancel(isc__networker_t *worker, isc__netievent_t *ev0) {
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(atomic_load(&sock->client));
- isc__nm_failed_read_cb(sock, ISC_R_EOF);
+ isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
}
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.c b/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.c
index 20099a9c53d..f6094f96ac8 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uv-compat.c,v 1.4 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: uv-compat.c,v 1.5 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -18,7 +18,7 @@
#include "netmgr-int.h"
-#ifndef HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
int
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
int err = 0;
@@ -38,17 +38,17 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
#ifdef WIN32
return (uv_translate_sys_error(err));
#else /* WIN32 */
-#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
+#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
return (uv_translate_sys_error(errno));
#else
return (-errno);
-#endif /* HAVE_UV_TRANSLATE_SYS_ERROR */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
#endif /* WIN32 */
}
return (0);
}
-#endif /* ifndef HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
int
isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.h b/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.h
index 3dabcea21a2..8b98f131790 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.h
+++ b/external/mpl/bind/dist/lib/isc/netmgr/uv-compat.h
@@ -1,4 +1,4 @@
-/* $NetBSD: uv-compat.h,v 1.3 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: uv-compat.h,v 1.4 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -21,24 +21,35 @@
* library version.
*/
-#ifndef HAVE_UV_HANDLE_GET_DATA
+#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
+
+#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
static inline void *
uv_handle_get_data(const uv_handle_t *handle) {
return (handle->data);
}
-#endif /* ifndef HAVE_UV_HANDLE_GET_DATA */
-#ifndef HAVE_UV_HANDLE_SET_DATA
static inline void
uv_handle_set_data(uv_handle_t *handle, void *data) {
handle->data = data;
}
-#endif /* ifndef HAVE_UV_HANDLE_SET_DATA */
-#ifdef HAVE_UV_UDP_CONNECT
-#define isc_uv_udp_connect uv_udp_connect
-#else
+static inline void *
+uv_req_get_data(const uv_req_t *req) {
+ return (req->data);
+}
+
+static inline void
+uv_req_set_data(uv_req_t *req, void *data) {
+ req->data = data;
+}
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 19, 0) */
+
+#if UV_VERSION_HEX < UV_VERSION(1, 34, 0)
+#define uv_sleep(msec) usleep(msec * 1000)
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 34, 0) */
+#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
int
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
/*%<
@@ -48,8 +59,37 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
* NOTE: This is just a limited shim for uv_udp_connect() as it requires the
* handle to be bound.
*/
+#else /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
+#define isc_uv_udp_connect uv_udp_connect
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
+
+#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
+#include <stdlib.h>
+#include <string.h>
+
+static inline int
+uv_os_getenv(const char *name, char *buffer, size_t *size) {
+ size_t len;
+ char *buf = getenv(name);
+
+ if (buf == NULL) {
+ return (UV_ENOENT);
+ }
+
+ len = strlen(buf) + 1;
+ if (len > *size) {
+ *size = len;
+ return (UV_ENOBUFS);
+ }
+
+ *size = len;
+ memmove(buffer, buf, len);
+
+ return (0);
+}
-#endif
+#define uv_os_setenv(name, value) setenv(name, value, 0)
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 12, 0) */
int
isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
diff --git a/external/mpl/bind/dist/lib/isc/netmgr/uverr2result.c b/external/mpl/bind/dist/lib/isc/netmgr/uverr2result.c
index 845b510f75d..84cc0acfcfd 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr/uverr2result.c
+++ b/external/mpl/bind/dist/lib/isc/netmgr/uverr2result.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uverr2result.c,v 1.3 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: uverr2result.c,v 1.4 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -87,6 +87,8 @@ isc___nm_uverr2result(int uverr, bool dolog, const char *file,
return (ISC_R_CANCELED);
case UV_EOF:
return (ISC_R_EOF);
+ case UV_EMSGSIZE:
+ return (ISC_R_MAXSIZE);
default:
if (dolog) {
UNEXPECTED_ERROR(
diff --git a/external/mpl/bind/dist/lib/isc/netmgr_p.h b/external/mpl/bind/dist/lib/isc/netmgr_p.h
index e2c18c5b0ca..ec555dac3bf 100644
--- a/external/mpl/bind/dist/lib/isc/netmgr_p.h
+++ b/external/mpl/bind/dist/lib/isc/netmgr_p.h
@@ -1,4 +1,4 @@
-/* $NetBSD: netmgr_p.h,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: netmgr_p.h,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/result.c b/external/mpl/bind/dist/lib/isc/result.c
index 66b955657aa..1320641e1ad 100644
--- a/external/mpl/bind/dist/lib/isc/result.c
+++ b/external/mpl/bind/dist/lib/isc/result.c
@@ -1,4 +1,4 @@
-/* $NetBSD: result.c,v 1.8 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: result.c,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -79,7 +79,7 @@ static const char *description[ISC_R_NRESULTS] = {
"invalid use of multicast address", /*%< 43 */
"not a file", /*%< 44 */
"not a directory", /*%< 45 */
- "queue is full", /*%< 46 */
+ "queue is empty", /*%< 46 */
"address family mismatch", /*%< 47 */
"address family not supported", /*%< 48 */
"bad hex encoding", /*%< 49 */
@@ -104,81 +104,81 @@ static const char *description[ISC_R_NRESULTS] = {
"default", /*%< 68 */
"IPv4 prefix", /*%< 69 */
"TLS error", /*%< 70 */
+ "ALPN for HTTP/2 failed" /*%< 71 */
};
-static const char *identifier[ISC_R_NRESULTS] = {
- "ISC_R_SUCCESS",
- "ISC_R_NOMEMORY",
- "ISC_R_TIMEDOUT",
- "ISC_R_NOTHREADS",
- "ISC_R_ADDRNOTAVAIL",
- "ISC_R_ADDRINUSE",
- "ISC_R_NOPERM",
- "ISC_R_NOCONN",
- "ISC_R_NETUNREACH",
- "ISC_R_HOSTUNREACH",
- "ISC_R_NETDOWN",
- "ISC_R_HOSTDOWN",
- "ISC_R_CONNREFUSED",
- "ISC_R_NORESOURCES",
- "ISC_R_EOF",
- "ISC_R_BOUND",
- "ISC_R_RELOAD",
- "ISC_R_LOCKBUSY",
- "ISC_R_EXISTS",
- "ISC_R_NOSPACE",
- "ISC_R_CANCELED",
- "ISC_R_NOTBOUND",
- "ISC_R_SHUTTINGDOWN",
- "ISC_R_NOTFOUND",
- "ISC_R_UNEXPECTEDEND",
- "ISC_R_FAILURE",
- "ISC_R_IOERROR",
- "ISC_R_NOTIMPLEMENTED",
- "ISC_R_UNBALANCED",
- "ISC_R_NOMORE",
- "ISC_R_INVALIDFILE",
- "ISC_R_BADBASE64",
- "ISC_R_UNEXPECTEDTOKEN",
- "ISC_R_QUOTA",
- "ISC_R_UNEXPECTED",
- "ISC_R_ALREADYRUNNING",
- "ISC_R_IGNORE",
- "ISC_R_MASKNONCONTIG",
- "ISC_R_FILENOTFOUND",
- "ISC_R_FILEEXISTS",
- "ISC_R_NOTCONNECTED",
- "ISC_R_RANGE",
- "ISC_R_NOENTROPY",
- "ISC_R_MULTICAST",
- "ISC_R_NOTFILE",
- "ISC_R_NOTDIRECTORY",
- "ISC_R_QUEUEFULL",
- "ISC_R_FAMILYMISMATCH",
- "ISC_R_FAMILYNOSUPPORT",
- "ISC_R_BADHEX",
- "ISC_R_TOOMANYOPENFILES",
- "ISC_R_NOTBLOCKING",
- "ISC_R_UNBALANCEDQUOTES",
- "ISC_R_INPROGRESS",
- "ISC_R_CONNECTIONRESET",
- "ISC_R_SOFTQUOTA",
- "ISC_R_BADNUMBER",
- "ISC_R_DISABLED",
- "ISC_R_MAXSIZE",
- "ISC_R_BADADDRESSFORM",
- "ISC_R_BADBASE32",
- "ISC_R_UNSET",
- "ISC_R_MULTIPLE",
- "ISC_R_WOULDBLOCK",
- "ISC_R_COMPLETE",
- "ISC_R_CRYPTOFAILURE",
- "ISC_R_DISCQUOTA",
- "ISC_R_DISCFULL",
- "ISC_R_DEFAULT",
- "ISC_R_IPV4PREFIX",
- "ISC_R_TLSERROR",
-};
+static const char *identifier[ISC_R_NRESULTS] = { "ISC_R_SUCCESS",
+ "ISC_R_NOMEMORY",
+ "ISC_R_TIMEDOUT",
+ "ISC_R_NOTHREADS",
+ "ISC_R_ADDRNOTAVAIL",
+ "ISC_R_ADDRINUSE",
+ "ISC_R_NOPERM",
+ "ISC_R_NOCONN",
+ "ISC_R_NETUNREACH",
+ "ISC_R_HOSTUNREACH",
+ "ISC_R_NETDOWN",
+ "ISC_R_HOSTDOWN",
+ "ISC_R_CONNREFUSED",
+ "ISC_R_NORESOURCES",
+ "ISC_R_EOF",
+ "ISC_R_BOUND",
+ "ISC_R_RELOAD",
+ "ISC_R_LOCKBUSY",
+ "ISC_R_EXISTS",
+ "ISC_R_NOSPACE",
+ "ISC_R_CANCELED",
+ "ISC_R_NOTBOUND",
+ "ISC_R_SHUTTINGDOWN",
+ "ISC_R_NOTFOUND",
+ "ISC_R_UNEXPECTEDEND",
+ "ISC_R_FAILURE",
+ "ISC_R_IOERROR",
+ "ISC_R_NOTIMPLEMENTED",
+ "ISC_R_UNBALANCED",
+ "ISC_R_NOMORE",
+ "ISC_R_INVALIDFILE",
+ "ISC_R_BADBASE64",
+ "ISC_R_UNEXPECTEDTOKEN",
+ "ISC_R_QUOTA",
+ "ISC_R_UNEXPECTED",
+ "ISC_R_ALREADYRUNNING",
+ "ISC_R_IGNORE",
+ "ISC_R_MASKNONCONTIG",
+ "ISC_R_FILENOTFOUND",
+ "ISC_R_FILEEXISTS",
+ "ISC_R_NOTCONNECTED",
+ "ISC_R_RANGE",
+ "ISC_R_NOENTROPY",
+ "ISC_R_MULTICAST",
+ "ISC_R_NOTFILE",
+ "ISC_R_NOTDIRECTORY",
+ "ISC_R_EMPTY",
+ "ISC_R_FAMILYMISMATCH",
+ "ISC_R_FAMILYNOSUPPORT",
+ "ISC_R_BADHEX",
+ "ISC_R_TOOMANYOPENFILES",
+ "ISC_R_NOTBLOCKING",
+ "ISC_R_UNBALANCEDQUOTES",
+ "ISC_R_INPROGRESS",
+ "ISC_R_CONNECTIONRESET",
+ "ISC_R_SOFTQUOTA",
+ "ISC_R_BADNUMBER",
+ "ISC_R_DISABLED",
+ "ISC_R_MAXSIZE",
+ "ISC_R_BADADDRESSFORM",
+ "ISC_R_BADBASE32",
+ "ISC_R_UNSET",
+ "ISC_R_MULTIPLE",
+ "ISC_R_WOULDBLOCK",
+ "ISC_R_COMPLETE",
+ "ISC_R_CRYPTOFAILURE",
+ "ISC_R_DISCQUOTA",
+ "ISC_R_DISCFULL",
+ "ISC_R_DEFAULT",
+ "ISC_R_IPV4PREFIX",
+ "ISC_R_TLSERROR",
+ "ISC_R_HTTP2ALPNERROR" };
#define ISC_RESULT_RESULTSET 2
#define ISC_RESULT_UNAVAILABLESET 3
diff --git a/external/mpl/bind/dist/lib/isc/rwlock.c b/external/mpl/bind/dist/lib/isc/rwlock.c
index ce8cb4c27bc..02d1084e0ab 100644
--- a/external/mpl/bind/dist/lib/isc/rwlock.c
+++ b/external/mpl/bind/dist/lib/isc/rwlock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rwlock.c,v 1.10 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: rwlock.c,v 1.11 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -115,9 +115,12 @@ isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
void
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
+ isc_result_t result;
atomic_store_release(&rwl->downgrade, true);
- isc_rwlock_unlock(rwl, isc_rwlocktype_write);
- isc_rwlock_lock(rwl, isc_rwlocktype_read);
+ result = isc_rwlock_unlock(rwl, isc_rwlocktype_write);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
+ result = isc_rwlock_lock(rwl, isc_rwlocktype_read);
+ RUNTIME_CHECK(result == ISC_R_SUCCESS);
atomic_store_release(&rwl->downgrade, false);
}
diff --git a/external/mpl/bind/dist/lib/isc/stats.c b/external/mpl/bind/dist/lib/isc/stats.c
index 38bfff87ec1..aed9f974480 100644
--- a/external/mpl/bind/dist/lib/isc/stats.c
+++ b/external/mpl/bind/dist/lib/isc/stats.c
@@ -1,4 +1,4 @@
-/* $NetBSD: stats.c,v 1.8 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: stats.c,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -54,7 +54,9 @@ create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) {
counters_alloc_size = sizeof(isc__atomic_statcounter_t) * ncounters;
stats->counters = isc_mem_get(mctx, counters_alloc_size);
isc_refcount_init(&stats->references, 1);
- memset(stats->counters, 0, counters_alloc_size);
+ for (int i = 0; i < ncounters; i++) {
+ atomic_init(&stats->counters[i], 0);
+ }
stats->mctx = NULL;
isc_mem_attach(mctx, &stats->mctx);
stats->ncounters = ncounters;
diff --git a/external/mpl/bind/dist/lib/isc/task.c b/external/mpl/bind/dist/lib/isc/task.c
index 5851d213c6a..d233112a880 100644
--- a/external/mpl/bind/dist/lib/isc/task.c
+++ b/external/mpl/bind/dist/lib/isc/task.c
@@ -1,4 +1,4 @@
-/* $NetBSD: task.c,v 1.14 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: task.c,v 1.15 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -19,6 +19,7 @@
*/
#include <stdbool.h>
+#include <unistd.h>
#include <isc/app.h>
#include <isc/atomic.h>
@@ -46,9 +47,7 @@
#include <json_object.h>
#endif /* HAVE_JSON_C */
-#ifdef OPENSSL_LEAKS
-#include <openssl/err.h>
-#endif /* ifdef OPENSSL_LEAKS */
+#include "task_p.h"
/*
* Task manager is built around 'as little locking as possible' concept.
@@ -63,14 +62,11 @@
*/
#ifdef ISC_TASK_TRACE
-#define XTRACE(m) \
- fprintf(stderr, "task %p thread %" PRIuPTR ": %s\n", task, \
- isc_thread_self(), (m))
-#define XTTRACE(t, m) \
- fprintf(stderr, "task %p thread %" PRIuPTR ": %s\n", (t), \
- isc_thread_self(), (m))
-#define XTHREADTRACE(m) \
- fprintf(stderr, "thread %" PRIuPTR ": %s\n", isc_thread_self(), (m))
+#define XTRACE(m) \
+ fprintf(stderr, "task %p thread %zu: %s\n", task, isc_tid_v, (m))
+#define XTTRACE(t, m) \
+ fprintf(stderr, "task %p thread %zu: %s\n", (t), isc_tid_v, (m))
+#define XTHREADTRACE(m) fprintf(stderr, "thread %zu: %s\n", isc_tid_v, (m))
#else /* ifdef ISC_TASK_TRACE */
#define XTRACE(m)
#define XTTRACE(t, m)
@@ -99,19 +95,17 @@ static const char *statenames[] = {
#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
-typedef struct isc__task isc__task_t;
-typedef struct isc__taskmgr isc__taskmgr_t;
-typedef struct isc__taskqueue isc__taskqueue_t;
-
-struct isc__task {
+struct isc_task {
/* Not locked. */
- isc_task_t common;
- isc__taskmgr_t *manager;
+ unsigned int magic;
+ isc_taskmgr_t *manager;
isc_mutex_t lock;
/* Locked by task lock. */
+ int threadid;
task_state_t state;
int pause_cnt;
isc_refcount_t references;
+ isc_refcount_t running;
isc_eventlist_t events;
isc_eventlist_t on_shutdown;
unsigned int nevents;
@@ -120,87 +114,46 @@ struct isc__task {
isc_time_t tnow;
char name[16];
void *tag;
- unsigned int threadid;
bool bound;
/* Protected by atomics */
- atomic_uint_fast32_t flags;
+ atomic_bool shuttingdown;
+ atomic_bool privileged;
/* Locked by task manager lock. */
- LINK(isc__task_t) link;
- LINK(isc__task_t) ready_link;
- LINK(isc__task_t) ready_priority_link;
+ LINK(isc_task_t) link;
};
-#define TASK_F_SHUTTINGDOWN 0x01
-#define TASK_F_PRIVILEGED 0x02
-
-#define TASK_SHUTTINGDOWN(t) \
- ((atomic_load_acquire(&(t)->flags) & TASK_F_SHUTTINGDOWN) != 0)
-#define TASK_PRIVILEGED(t) \
- ((atomic_load_acquire(&(t)->flags) & TASK_F_PRIVILEGED) != 0)
-
-#define TASK_FLAG_SET(t, f) atomic_fetch_or_release(&(t)->flags, (f))
-#define TASK_FLAG_CLR(t, f) atomic_fetch_and_release(&(t)->flags, ~(f))
+#define TASK_SHUTTINGDOWN(t) (atomic_load_acquire(&(t)->shuttingdown))
+#define TASK_PRIVILEGED(t) (atomic_load_acquire(&(t)->privileged))
#define TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M')
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC)
-typedef ISC_LIST(isc__task_t) isc__tasklist_t;
-
-struct isc__taskqueue {
- /* Everything locked by lock */
- isc_mutex_t lock;
- isc__tasklist_t ready_tasks;
- isc__tasklist_t ready_priority_tasks;
- isc_condition_t work_available;
- isc_thread_t thread;
- unsigned int threadid;
- isc__taskmgr_t *manager;
-};
-
-struct isc__taskmgr {
+struct isc_taskmgr {
/* Not locked. */
- isc_taskmgr_t common;
+ unsigned int magic;
+ isc_refcount_t references;
isc_mem_t *mctx;
isc_mutex_t lock;
- isc_mutex_t halt_lock;
- isc_condition_t halt_cond;
- unsigned int workers;
- atomic_uint_fast32_t tasks_running;
- atomic_uint_fast32_t tasks_ready;
- atomic_uint_fast32_t curq;
atomic_uint_fast32_t tasks_count;
- isc__taskqueue_t *queues;
- isc_nm_t *nm;
+ isc_nm_t *netmgr;
/* Locked by task manager lock. */
unsigned int default_quantum;
- LIST(isc__task_t) tasks;
+ LIST(isc_task_t) tasks;
atomic_uint_fast32_t mode;
- atomic_bool pause_req;
atomic_bool exclusive_req;
atomic_bool exiting;
- /* Locked by halt_lock */
- unsigned int halted;
-
/*
* Multiple threads can read/write 'excl' at the same time, so we need
* to protect the access. We can't use 'lock' since isc_task_detach()
* will try to acquire it.
*/
isc_mutex_t excl_lock;
- isc__task_t *excl;
+ isc_task_t *excl;
};
-void
-isc__taskmgr_pause(isc_taskmgr_t *manager0);
-void
-isc__taskmgr_resume(isc_taskmgr_t *manager0);
-
#define DEFAULT_DEFAULT_QUANTUM 25
-#define FINISHED(m) \
- (atomic_load_relaxed(&((m)->exiting)) && \
- atomic_load(&(m)->tasks_count) == 0)
/*%
* The following are intended for internal use (indicated by "isc__"
@@ -209,39 +162,20 @@ isc__taskmgr_resume(isc_taskmgr_t *manager0);
*/
bool
-isc_task_purgeevent(isc_task_t *task0, isc_event_t *event);
+isc_task_purgeevent(isc_task_t *task, isc_event_t *event);
void
-isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0);
+isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task);
isc_result_t
-isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp);
-static inline bool
-empty_readyq(isc__taskmgr_t *manager, int c);
-
-static inline isc__task_t *
-pop_readyq(isc__taskmgr_t *manager, int c);
-
-static inline void
-push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c);
-
-static inline void
-wake_all_queues(isc__taskmgr_t *manager);
+isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp);
/***
*** Tasks.
***/
-static inline void
-wake_all_queues(isc__taskmgr_t *manager) {
- for (unsigned int i = 0; i < manager->workers; i++) {
- LOCK(&manager->queues[i].lock);
- BROADCAST(&manager->queues[i].work_available);
- UNLOCK(&manager->queues[i].lock);
- }
-}
-
static void
-task_finished(isc__task_t *task) {
- isc__taskmgr_t *manager = task->manager;
+task_finished(isc_task_t *task) {
+ isc_taskmgr_t *manager = task->manager;
+ isc_mem_t *mctx = manager->mctx;
REQUIRE(EMPTY(task->events));
REQUIRE(task->nevents == 0);
REQUIRE(EMPTY(task->on_shutdown));
@@ -249,46 +183,42 @@ task_finished(isc__task_t *task) {
XTRACE("task_finished");
+ isc_refcount_destroy(&task->running);
isc_refcount_destroy(&task->references);
LOCK(&manager->lock);
UNLINK(manager->tasks, task, link);
atomic_fetch_sub(&manager->tasks_count, 1);
UNLOCK(&manager->lock);
- if (FINISHED(manager)) {
- /*
- * All tasks have completed and the
- * task manager is exiting. Wake up
- * any idle worker threads so they
- * can exit.
- */
- wake_all_queues(manager);
- }
+
isc_mutex_destroy(&task->lock);
- task->common.impmagic = 0;
- task->common.magic = 0;
- isc_mem_put(manager->mctx, task, sizeof(*task));
+ task->magic = 0;
+ isc_mem_put(mctx, task, sizeof(*task));
+
+ isc_taskmgr_detach(&manager);
}
isc_result_t
-isc_task_create(isc_taskmgr_t *manager0, unsigned int quantum,
+isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp) {
- return (isc_task_create_bound(manager0, quantum, taskp, -1));
+ return (isc_task_create_bound(manager, quantum, taskp, -1));
}
isc_result_t
-isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
+isc_task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp, int threadid) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- isc__task_t *task;
+ isc_task_t *task;
bool exiting;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
- task = isc_mem_get(manager->mctx, sizeof(*task));
XTRACE("isc_task_create");
- task->manager = manager;
+
+ task = isc_mem_get(manager->mctx, sizeof(*task));
+ *task = (isc_task_t){ 0 };
+
+ isc_taskmgr_attach(manager, &task->manager);
if (threadid == -1) {
/*
@@ -297,14 +227,14 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
* randomly or specified by isc_task_sendto.
*/
task->bound = false;
- task->threadid = 0;
+ task->threadid = -1;
} else {
/*
* Task is pinned to a queue, it'll always be run
* by a specific thread.
*/
task->bound = true;
- task->threadid = threadid % manager->workers;
+ task->threadid = threadid;
}
isc_mutex_init(&task->lock);
@@ -312,18 +242,19 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
task->pause_cnt = 0;
isc_refcount_init(&task->references, 1);
+ isc_refcount_init(&task->running, 0);
INIT_LIST(task->events);
INIT_LIST(task->on_shutdown);
task->nevents = 0;
task->quantum = (quantum > 0) ? quantum : manager->default_quantum;
- atomic_init(&task->flags, 0);
+ atomic_init(&task->shuttingdown, false);
+ atomic_init(&task->privileged, false);
task->now = 0;
isc_time_settoepoch(&task->tnow);
memset(task->name, 0, sizeof(task->name));
task->tag = NULL;
INIT_LINK(task, link);
- INIT_LINK(task, ready_link);
- INIT_LINK(task, ready_priority_link);
+ task->magic = TASK_MAGIC;
exiting = false;
LOCK(&manager->lock);
@@ -336,22 +267,22 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
UNLOCK(&manager->lock);
if (exiting) {
+ isc_refcount_destroy(&task->running);
+ isc_refcount_decrement(&task->references);
+ isc_refcount_destroy(&task->references);
isc_mutex_destroy(&task->lock);
+ isc_taskmgr_detach(&task->manager);
isc_mem_put(manager->mctx, task, sizeof(*task));
return (ISC_R_SHUTTINGDOWN);
}
- task->common.magic = ISCAPI_TASK_MAGIC;
- task->common.impmagic = TASK_MAGIC;
- *taskp = (isc_task_t *)task;
+ *taskp = task;
return (ISC_R_SUCCESS);
}
void
-isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
- isc__task_t *source = (isc__task_t *)source0;
-
+isc_task_attach(isc_task_t *source, isc_task_t **targetp) {
/*
* Attach *targetp to source.
*/
@@ -363,11 +294,11 @@ isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
isc_refcount_increment(&source->references);
- *targetp = (isc_task_t *)source;
+ *targetp = source;
}
static inline bool
-task_shutdown(isc__task_t *task) {
+task_shutdown(isc_task_t *task) {
bool was_idle = false;
isc_event_t *event, *prev;
@@ -377,9 +308,9 @@ task_shutdown(isc__task_t *task) {
XTRACE("task_shutdown");
- if (!TASK_SHUTTINGDOWN(task)) {
+ if (atomic_compare_exchange_strong(&task->shuttingdown,
+ &(bool){ false }, true)) {
XTRACE("shutting down");
- TASK_FLAG_SET(task, TASK_F_SHUTTINGDOWN);
if (task->state == task_state_idle) {
INSIST(EMPTY(task->events));
task->state = task_state_ready;
@@ -411,24 +342,25 @@ task_shutdown(isc__task_t *task) {
* Caller must NOT hold queue lock.
*/
static inline void
-task_ready(isc__task_t *task) {
- isc__taskmgr_t *manager = task->manager;
- bool has_privilege = isc_task_privilege((isc_task_t *)task);
-
+task_ready(isc_task_t *task) {
+ isc_taskmgr_t *manager = task->manager;
REQUIRE(VALID_MANAGER(manager));
XTRACE("task_ready");
- LOCK(&manager->queues[task->threadid].lock);
- push_readyq(manager, task, task->threadid);
- if (atomic_load(&manager->mode) == isc_taskmgrmode_normal ||
- has_privilege) {
- SIGNAL(&manager->queues[task->threadid].work_available);
- }
- UNLOCK(&manager->queues[task->threadid].lock);
+
+ isc_refcount_increment0(&task->running);
+ LOCK(&task->lock);
+ isc_nm_task_enqueue(manager->netmgr, task, task->threadid);
+ UNLOCK(&task->lock);
+}
+
+void
+isc_task_ready(isc_task_t *task) {
+ task_ready(task);
}
static inline bool
-task_detach(isc__task_t *task) {
+task_detach(isc_task_t *task) {
/*
* Caller must be holding the task lock.
*/
@@ -456,7 +388,7 @@ task_detach(isc__task_t *task) {
void
isc_task_detach(isc_task_t **taskp) {
- isc__task_t *task;
+ isc_task_t *task;
bool was_idle;
/*
@@ -464,7 +396,7 @@ isc_task_detach(isc_task_t **taskp) {
*/
REQUIRE(taskp != NULL);
- task = (isc__task_t *)*taskp;
+ task = *taskp;
REQUIRE(VALID_TASK(task));
XTRACE("isc_task_detach");
@@ -481,7 +413,7 @@ isc_task_detach(isc_task_t **taskp) {
}
static inline bool
-task_send(isc__task_t *task, isc_event_t **eventp, int c) {
+task_send(isc_task_t *task, isc_event_t **eventp, int c) {
bool was_idle = false;
isc_event_t *event;
@@ -499,6 +431,12 @@ task_send(isc__task_t *task, isc_event_t **eventp, int c) {
XTRACE("task_send");
+ if (task->bound) {
+ c = task->threadid;
+ } else if (c < 0) {
+ c = -1;
+ }
+
if (task->state == task_state_idle) {
was_idle = true;
task->threadid = c;
@@ -516,8 +454,8 @@ task_send(isc__task_t *task, isc_event_t **eventp, int c) {
}
void
-isc_task_send(isc_task_t *task0, isc_event_t **eventp) {
- isc_task_sendto(task0, eventp, -1);
+isc_task_send(isc_task_t *task, isc_event_t **eventp) {
+ isc_task_sendto(task, eventp, -1);
}
void
@@ -526,8 +464,7 @@ isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
}
void
-isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int c) {
bool was_idle;
/*
@@ -543,14 +480,6 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
* some processing is deferred until after the lock is released.
*/
LOCK(&task->lock);
- /* If task is bound ignore provided cpu. */
- if (task->bound) {
- c = task->threadid;
- } else if (c < 0) {
- c = atomic_fetch_add_explicit(&task->manager->curq, 1,
- memory_order_relaxed);
- }
- c %= task->manager->workers;
was_idle = task_send(task, eventp, c);
UNLOCK(&task->lock);
@@ -577,7 +506,7 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
void
isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
bool idle1, idle2;
- isc__task_t *task;
+ isc_task_t *task;
/*
* Send '*event' to '*taskp' and then detach '*taskp' from its
@@ -585,18 +514,11 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
*/
REQUIRE(taskp != NULL);
- task = (isc__task_t *)*taskp;
+ task = *taskp;
REQUIRE(VALID_TASK(task));
XTRACE("isc_task_sendanddetach");
LOCK(&task->lock);
- if (task->bound) {
- c = task->threadid;
- } else if (c < 0) {
- c = atomic_fetch_add_explicit(&task->manager->curq, 1,
- memory_order_relaxed);
- }
- c %= task->manager->workers;
idle1 = task_send(task, eventp, c);
idle2 = task_detach(task);
UNLOCK(&task->lock);
@@ -618,7 +540,7 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
#define PURGE_OK(event) (((event)->ev_attributes & ISC_EVENTATTR_NOPURGE) == 0)
static unsigned int
-dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
+dequeue_events(isc_task_t *task, void *sender, isc_eventtype_t first,
isc_eventtype_t last, void *tag, isc_eventlist_t *events,
bool purging) {
isc_event_t *event, *next_event;
@@ -659,9 +581,8 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
}
unsigned int
-isc_task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
+isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
isc_eventtype_t last, void *tag) {
- isc__task_t *task = (isc__task_t *)task0;
unsigned int count;
isc_eventlist_t events;
isc_event_t *event, *next_event;
@@ -704,8 +625,7 @@ isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
}
bool
-isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_purgeevent(isc_task_t *task, isc_event_t *event) {
isc_event_t *curr_event, *next_event;
/*
@@ -758,8 +678,7 @@ isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
XTRACE("isc_task_unsendrange");
- return (dequeue_events((isc__task_t *)task, sender, first, last, tag,
- events, false));
+ return (dequeue_events(task, sender, first, last, tag, events, false));
}
unsigned int
@@ -771,13 +690,11 @@ isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag,
XTRACE("isc_task_unsend");
- return (dequeue_events((isc__task_t *)task, sender, type, type, tag,
- events, false));
+ return (dequeue_events(task, sender, type, type, tag, events, false));
}
isc_result_t
-isc_task_onshutdown(isc_task_t *task0, isc_taskaction_t action, void *arg) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action, void *arg) {
bool disallowed = false;
isc_result_t result = ISC_R_SUCCESS;
isc_event_t *event;
@@ -811,8 +728,7 @@ isc_task_onshutdown(isc_task_t *task0, isc_taskaction_t action, void *arg) {
}
void
-isc_task_shutdown(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_shutdown(isc_task_t *task) {
bool was_idle;
/*
@@ -843,9 +759,7 @@ isc_task_destroy(isc_task_t **taskp) {
}
void
-isc_task_setname(isc_task_t *task0, const char *name, void *tag) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_setname(isc_task_t *task, const char *name, void *tag) {
/*
* Name 'task'.
*/
@@ -859,27 +773,21 @@ isc_task_setname(isc_task_t *task0, const char *name, void *tag) {
}
const char *
-isc_task_getname(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_getname(isc_task_t *task) {
REQUIRE(VALID_TASK(task));
return (task->name);
}
void *
-isc_task_gettag(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_gettag(isc_task_t *task) {
REQUIRE(VALID_TASK(task));
return (task->tag);
}
void
-isc_task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t) {
REQUIRE(VALID_TASK(task));
REQUIRE(t != NULL);
@@ -889,9 +797,7 @@ isc_task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
}
void
-isc_task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_getcurrenttimex(isc_task_t *task, isc_time_t *t) {
REQUIRE(VALID_TASK(task));
REQUIRE(t != NULL);
@@ -900,571 +806,235 @@ isc_task_getcurrenttimex(isc_task_t *task0, isc_time_t *t) {
UNLOCK(&task->lock);
}
-/***
- *** Task Manager.
- ***/
-
-/*
- * Return true if the current ready list for the manager, which is
- * either ready_tasks or the ready_priority_tasks, depending on whether
- * the manager is currently in normal or privileged execution mode.
- *
- * Caller must hold the task manager lock.
- */
-static inline bool
-empty_readyq(isc__taskmgr_t *manager, int c) {
- isc__tasklist_t queue;
-
- if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) {
- queue = manager->queues[c].ready_tasks;
- } else {
- queue = manager->queues[c].ready_priority_tasks;
- }
- return (EMPTY(queue));
-}
-
-/*
- * Dequeue and return a pointer to the first task on the current ready
- * list for the manager.
- * If the task is privileged, dequeue it from the other ready list
- * as well.
- *
- * Caller must hold the task manager lock.
- */
-static inline isc__task_t *
-pop_readyq(isc__taskmgr_t *manager, int c) {
- isc__task_t *task;
-
- if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) {
- task = HEAD(manager->queues[c].ready_tasks);
- } else {
- task = HEAD(manager->queues[c].ready_priority_tasks);
- }
-
- if (task != NULL) {
- DEQUEUE(manager->queues[c].ready_tasks, task, ready_link);
- if (ISC_LINK_LINKED(task, ready_priority_link)) {
- DEQUEUE(manager->queues[c].ready_priority_tasks, task,
- ready_priority_link);
- }
- }
-
- return (task);
-}
+isc_nm_t *
+isc_task_getnetmgr(isc_task_t *task) {
+ REQUIRE(VALID_TASK(task));
-/*
- * Push 'task' onto the ready_tasks queue. If 'task' has the privilege
- * flag set, then also push it onto the ready_priority_tasks queue.
- *
- * Caller must hold the task queue lock.
- */
-static inline void
-push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
- if (ISC_LINK_LINKED(task, ready_link)) {
- return;
- }
- ENQUEUE(manager->queues[c].ready_tasks, task, ready_link);
- if (TASK_PRIVILEGED(task)) {
- ENQUEUE(manager->queues[c].ready_priority_tasks, task,
- ready_priority_link);
- }
- atomic_fetch_add_explicit(&manager->tasks_ready, 1,
- memory_order_acquire);
+ return (task->manager->netmgr);
}
-static void
-dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
- isc__task_t *task;
+/***
+ *** Task Manager.
+ ***/
- REQUIRE(VALID_MANAGER(manager));
+static isc_result_t
+task_run(isc_task_t *task) {
+ unsigned int dispatch_count = 0;
+ bool finished = false;
+ isc_event_t *event = NULL;
+ isc_result_t result = ISC_R_SUCCESS;
- /* Wait for everything to initialize */
- LOCK(&manager->lock);
- UNLOCK(&manager->lock);
+ REQUIRE(VALID_TASK(task));
+ LOCK(&task->lock);
/*
- * Again we're trying to hold the lock for as short a time as possible
- * and to do as little locking and unlocking as possible.
- *
- * In both while loops, the appropriate lock must be held before the
- * while body starts. Code which acquired the lock at the top of
- * the loop would be more readable, but would result in a lot of
- * extra locking. Compare:
- *
- * Straightforward:
- *
- * LOCK();
- * ...
- * UNLOCK();
- * while (expression) {
- * LOCK();
- * ...
- * UNLOCK();
- *
- * Unlocked part here...
- *
- * LOCK();
- * ...
- * UNLOCK();
- * }
- *
- * Note how if the loop continues we unlock and then immediately lock.
- * For N iterations of the loop, this code does 2N+1 locks and 2N+1
- * unlocks. Also note that the lock is not held when the while
- * condition is tested, which may or may not be important, depending
- * on the expression.
- *
- * As written:
- *
- * LOCK();
- * while (expression) {
- * ...
- * UNLOCK();
- *
- * Unlocked part here...
- *
- * LOCK();
- * ...
- * }
- * UNLOCK();
- *
- * For N iterations of the loop, this code does N+1 locks and N+1
- * unlocks. The while expression is always protected by the lock.
+ * It is possible because that we have a paused task in the queue - it
+ * might have been paused in the meantime and we never hold both queue
+ * and task lock to avoid deadlocks, just bail then.
*/
- LOCK(&manager->queues[threadid].lock);
+ if (task->state != task_state_ready) {
+ goto done;
+ }
- while (!FINISHED(manager)) {
- /*
- * For reasons similar to those given in the comment in
- * isc_task_send() above, it is safe for us to dequeue
- * the task while only holding the manager lock, and then
- * change the task to running state while only holding the
- * task lock.
- *
- * If a pause has been requested, don't do any work
- * until it's been released.
- */
- while ((empty_readyq(manager, threadid) &&
- !atomic_load_relaxed(&manager->pause_req) &&
- !atomic_load_relaxed(&manager->exclusive_req)) &&
- !FINISHED(manager))
- {
- XTHREADTRACE("wait");
- XTHREADTRACE(atomic_load_relaxed(&manager->pause_req)
- ? "paused"
- : "notpaused");
- XTHREADTRACE(
- atomic_load_relaxed(&manager->exclusive_req)
- ? "excreq"
- : "notexcreq");
- WAIT(&manager->queues[threadid].work_available,
- &manager->queues[threadid].lock);
- XTHREADTRACE("awake");
- }
- XTHREADTRACE("working");
+ INSIST(task->state == task_state_ready);
+ task->state = task_state_running;
+ XTRACE("running");
+ XTRACE(task->name);
+ TIME_NOW(&task->tnow);
+ task->now = isc_time_seconds(&task->tnow);
- if (atomic_load_relaxed(&manager->pause_req) ||
- atomic_load_relaxed(&manager->exclusive_req))
- {
- UNLOCK(&manager->queues[threadid].lock);
- XTHREADTRACE("halting");
+ while (true) {
+ if (!EMPTY(task->events)) {
+ event = HEAD(task->events);
+ DEQUEUE(task->events, event, ev_link);
+ task->nevents--;
/*
- * Switching to exclusive mode is done as a
- * 2-phase-lock, checking if we have to switch is
- * done without any locks on pause_req and
- * exclusive_req to save time - the worst
- * thing that can happen is that we'll launch one
- * task more and exclusive task will be postponed a
- * bit.
- *
- * Broadcasting on halt_cond seems suboptimal, but
- * exclusive tasks are rare enough that we don't
- * care.
+ * Execute the event action.
*/
- LOCK(&manager->halt_lock);
- manager->halted++;
- BROADCAST(&manager->halt_cond);
- while (atomic_load_relaxed(&manager->pause_req) ||
- atomic_load_relaxed(&manager->exclusive_req))
- {
- WAIT(&manager->halt_cond, &manager->halt_lock);
+ XTRACE("execute action");
+ XTRACE(task->name);
+ if (event->ev_action != NULL) {
+ UNLOCK(&task->lock);
+ (event->ev_action)(task, event);
+ LOCK(&task->lock);
}
- manager->halted--;
- SIGNAL(&manager->halt_cond);
- UNLOCK(&manager->halt_lock);
-
- LOCK(&manager->queues[threadid].lock);
- /* Restart the loop after */
- continue;
+ XTRACE("execution complete");
+ dispatch_count++;
}
- task = pop_readyq(manager, threadid);
- if (task != NULL) {
- unsigned int dispatch_count = 0;
- bool done = false;
- bool requeue = false;
- bool finished = false;
- isc_event_t *event;
-
- INSIST(VALID_TASK(task));
-
+ if (isc_refcount_current(&task->references) == 0 &&
+ EMPTY(task->events) && !TASK_SHUTTINGDOWN(task))
+ {
/*
- * Note we only unlock the queue lock if we actually
- * have a task to do. We must reacquire the queue
- * lock before exiting the 'if (task != NULL)' block.
+ * There are no references and no pending events for
+ * this task, which means it will not become runnable
+ * again via an external action (such as sending an
+ * event or detaching).
+ *
+ * We initiate shutdown to prevent it from becoming a
+ * zombie.
+ *
+ * We do this here instead of in the "if
+ * EMPTY(task->events)" block below because:
+ *
+ * If we post no shutdown events, we want the task
+ * to finish.
+ *
+ * If we did post shutdown events, will still want
+ * the task's quantum to be applied.
*/
- UNLOCK(&manager->queues[threadid].lock);
- RUNTIME_CHECK(atomic_fetch_sub_explicit(
- &manager->tasks_ready, 1,
- memory_order_release) > 0);
- atomic_fetch_add_explicit(&manager->tasks_running, 1,
- memory_order_acquire);
-
- LOCK(&task->lock);
+ INSIST(!task_shutdown(task));
+ }
+
+ if (EMPTY(task->events)) {
/*
- * It is possible because that we have a paused task
- * in the queue - it might have been paused in the
- * meantime and we never hold both queue and task lock
- * to avoid deadlocks, just bail then.
+ * Nothing else to do for this task right now.
*/
- if (task->state != task_state_ready) {
- UNLOCK(&task->lock);
- LOCK(&manager->queues[threadid].lock);
- continue;
- }
- INSIST(task->state == task_state_ready);
- task->state = task_state_running;
- XTRACE("running");
- XTRACE(task->name);
- TIME_NOW(&task->tnow);
- task->now = isc_time_seconds(&task->tnow);
- do {
- if (!EMPTY(task->events)) {
- event = HEAD(task->events);
- DEQUEUE(task->events, event, ev_link);
- task->nevents--;
-
- /*
- * Execute the event action.
- */
- XTRACE("execute action");
- XTRACE(task->name);
- if (event->ev_action != NULL) {
- UNLOCK(&task->lock);
- (event->ev_action)(
- (isc_task_t *)task,
- event);
- LOCK(&task->lock);
- }
- XTRACE("execution complete");
- dispatch_count++;
- }
-
- if (isc_refcount_current(&task->references) ==
- 0 &&
- EMPTY(task->events) &&
- !TASK_SHUTTINGDOWN(task))
- {
- bool was_idle;
-
- /*
- * There are no references and no
- * pending events for this task,
- * which means it will not become
- * runnable again via an external
- * action (such as sending an event
- * or detaching).
- *
- * We initiate shutdown to prevent
- * it from becoming a zombie.
- *
- * We do this here instead of in
- * the "if EMPTY(task->events)" block
- * below because:
- *
- * If we post no shutdown events,
- * we want the task to finish.
- *
- * If we did post shutdown events,
- * will still want the task's
- * quantum to be applied.
- */
- was_idle = task_shutdown(task);
- INSIST(!was_idle);
- }
-
- if (EMPTY(task->events)) {
- /*
- * Nothing else to do for this task
- * right now.
- */
- XTRACE("empty");
- if (isc_refcount_current(
- &task->references) == 0 &&
- TASK_SHUTTINGDOWN(task)) {
- /*
- * The task is done.
- */
- XTRACE("done");
- finished = true;
- task->state = task_state_done;
- } else {
- if (task->state ==
- task_state_running) {
- task->state =
- task_state_idle;
- } else if (task->state ==
- task_state_pausing) {
- task->state =
- task_state_paused;
- }
- }
- done = true;
+ XTRACE("empty");
+ if (isc_refcount_current(&task->references) == 0 &&
+ TASK_SHUTTINGDOWN(task)) {
+ /*
+ * The task is done.
+ */
+ XTRACE("done");
+ task->state = task_state_done;
+ } else {
+ if (task->state == task_state_running) {
+ XTRACE("idling");
+ task->state = task_state_idle;
} else if (task->state == task_state_pausing) {
- /*
- * We got a pause request on this task,
- * stop working on it and switch the
- * state to paused.
- */
XTRACE("pausing");
task->state = task_state_paused;
- done = true;
- } else if (dispatch_count >= task->quantum) {
- /*
- * Our quantum has expired, but
- * there is more work to be done.
- * We'll requeue it to the ready
- * queue later.
- *
- * We don't check quantum until
- * dispatching at least one event,
- * so the minimum quantum is one.
- */
- XTRACE("quantum");
- task->state = task_state_ready;
- requeue = true;
- done = true;
}
- } while (!done);
- UNLOCK(&task->lock);
-
- if (finished) {
- task_finished(task);
- }
-
- RUNTIME_CHECK(atomic_fetch_sub_explicit(
- &manager->tasks_running, 1,
- memory_order_release) > 0);
- LOCK(&manager->queues[threadid].lock);
- if (requeue) {
- /*
- * We know we're awake, so we don't have
- * to wakeup any sleeping threads if the
- * ready queue is empty before we requeue.
- *
- * A possible optimization if the queue is
- * empty is to 'goto' the 'if (task != NULL)'
- * block, avoiding the ENQUEUE of the task
- * and the subsequent immediate DEQUEUE
- * (since it is the only executable task).
- * We don't do this because then we'd be
- * skipping the exit_requested check. The
- * cost of ENQUEUE is low anyway, especially
- * when you consider that we'd have to do
- * an extra EMPTY check to see if we could
- * do the optimization. If the ready queue
- * were usually nonempty, the 'optimization'
- * might even hurt rather than help.
- */
- push_readyq(manager, task, threadid);
}
- }
-
- /*
- * If we are in privileged execution mode and there are no
- * tasks remaining on the current ready queue, then
- * we're stuck. Automatically drop privileges at that
- * point and continue with the regular ready queue.
- */
- if (atomic_load_relaxed(&manager->mode) !=
- isc_taskmgrmode_normal &&
- atomic_load_explicit(&manager->tasks_running,
- memory_order_acquire) == 0)
- {
- UNLOCK(&manager->queues[threadid].lock);
- LOCK(&manager->lock);
+ break;
+ } else if (task->state == task_state_pausing) {
/*
- * Check once again, under lock. Mode can only
- * change from privileged to normal anyway, and
- * if we enter this loop twice at the same time
- * we'll end up in a deadlock over queue locks.
+ * We got a pause request on this task, stop working on
+ * it and switch the state to paused.
+ */
+ XTRACE("pausing");
+ task->state = task_state_paused;
+ break;
+ } else if (dispatch_count >= task->quantum) {
+ /*
+ * Our quantum has expired, but there is more work to be
+ * done. We'll requeue it to the ready queue later.
*
+ * We don't check quantum until dispatching at least one
+ * event, so the minimum quantum is one.
*/
- if (atomic_load(&manager->mode) !=
- isc_taskmgrmode_normal &&
- atomic_load_explicit(&manager->tasks_running,
- memory_order_acquire) == 0)
- {
- bool empty = true;
- unsigned int i;
- for (i = 0; i < manager->workers && empty; i++)
- {
- LOCK(&manager->queues[i].lock);
- empty &= empty_readyq(manager, i);
- UNLOCK(&manager->queues[i].lock);
- }
- if (empty) {
- atomic_store(&manager->mode,
- isc_taskmgrmode_normal);
- wake_all_queues(manager);
- }
- }
- UNLOCK(&manager->lock);
- LOCK(&manager->queues[threadid].lock);
+ XTRACE("quantum");
+ task->state = task_state_ready;
+ result = ISC_R_QUOTA;
+ break;
}
}
- UNLOCK(&manager->queues[threadid].lock);
- /*
- * There might be other dispatchers waiting on empty tasks,
- * wake them up.
- */
- wake_all_queues(manager);
-}
-
-static isc_threadresult_t
-#ifdef _WIN32
- WINAPI
-#endif /* ifdef _WIN32 */
- run(void *queuep) {
- isc__taskqueue_t *tq = queuep;
- isc__taskmgr_t *manager = tq->manager;
- int threadid = tq->threadid;
- isc_thread_setaffinity(threadid);
-
- XTHREADTRACE("starting");
- dispatch(manager, threadid);
+done:
+ if (isc_refcount_decrement(&task->running) == 1 &&
+ task->state == task_state_done)
+ {
+ finished = true;
+ }
+ UNLOCK(&task->lock);
- XTHREADTRACE("exiting");
+ if (finished) {
+ task_finished(task);
+ }
-#ifdef OPENSSL_LEAKS
- ERR_remove_state(0);
-#endif /* ifdef OPENSSL_LEAKS */
+ return (result);
+}
- return ((isc_threadresult_t)0);
+isc_result_t
+isc_task_run(isc_task_t *task) {
+ return (task_run(task));
}
static void
-manager_free(isc__taskmgr_t *manager) {
- for (unsigned int i = 0; i < manager->workers; i++) {
- isc_mutex_destroy(&manager->queues[i].lock);
- isc_condition_destroy(&manager->queues[i].work_available);
- }
+manager_free(isc_taskmgr_t *manager) {
+ isc_refcount_destroy(&manager->references);
+ isc_nm_detach(&manager->netmgr);
+
isc_mutex_destroy(&manager->lock);
isc_mutex_destroy(&manager->excl_lock);
- isc_mutex_destroy(&manager->halt_lock);
- isc_condition_destroy(&manager->halt_cond);
- isc_mem_put(manager->mctx, manager->queues,
- manager->workers * sizeof(isc__taskqueue_t));
- manager->common.impmagic = 0;
- manager->common.magic = 0;
+ manager->magic = 0;
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
}
+void
+isc_taskmgr_attach(isc_taskmgr_t *source, isc_taskmgr_t **targetp) {
+ REQUIRE(VALID_MANAGER(source));
+ REQUIRE(targetp != NULL && *targetp == NULL);
+
+ isc_refcount_increment(&source->references);
+
+ *targetp = source;
+}
+
+void
+isc_taskmgr_detach(isc_taskmgr_t **managerp) {
+ REQUIRE(managerp != NULL);
+ REQUIRE(VALID_MANAGER(*managerp));
+
+ isc_taskmgr_t *manager = *managerp;
+ *managerp = NULL;
+
+ if (isc_refcount_decrement(&manager->references) == 1) {
+ manager_free(manager);
+ }
+}
+
isc_result_t
-isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
- unsigned int default_quantum, isc_nm_t *nm,
- isc_taskmgr_t **managerp) {
- unsigned int i;
- isc__taskmgr_t *manager;
+isc__taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
+ isc_taskmgr_t **managerp) {
+ isc_taskmgr_t *manager;
/*
* Create a new task manager.
*/
- REQUIRE(workers > 0);
REQUIRE(managerp != NULL && *managerp == NULL);
+ REQUIRE(nm != NULL);
manager = isc_mem_get(mctx, sizeof(*manager));
- *manager = (isc__taskmgr_t){ .common.impmagic = TASK_MANAGER_MAGIC,
- .common.magic = ISCAPI_TASKMGR_MAGIC };
+ *manager = (isc_taskmgr_t){ .magic = TASK_MANAGER_MAGIC };
- atomic_store(&manager->mode, isc_taskmgrmode_normal);
isc_mutex_init(&manager->lock);
isc_mutex_init(&manager->excl_lock);
- isc_mutex_init(&manager->halt_lock);
- isc_condition_init(&manager->halt_cond);
-
- manager->workers = workers;
-
if (default_quantum == 0) {
default_quantum = DEFAULT_DEFAULT_QUANTUM;
}
manager->default_quantum = default_quantum;
if (nm != NULL) {
- isc_nm_attach(nm, &manager->nm);
+ isc_nm_attach(nm, &manager->netmgr);
}
INIT_LIST(manager->tasks);
- atomic_store(&manager->tasks_count, 0);
- manager->queues = isc_mem_get(mctx, workers * sizeof(isc__taskqueue_t));
- RUNTIME_CHECK(manager->queues != NULL);
-
- atomic_init(&manager->tasks_running, 0);
- atomic_init(&manager->tasks_ready, 0);
- atomic_init(&manager->curq, 0);
atomic_init(&manager->exiting, false);
- atomic_store_relaxed(&manager->exclusive_req, false);
- atomic_store_relaxed(&manager->pause_req, false);
+ atomic_init(&manager->mode, isc_taskmgrmode_normal);
+ atomic_init(&manager->exclusive_req, false);
+ atomic_init(&manager->tasks_count, 0);
isc_mem_attach(mctx, &manager->mctx);
- LOCK(&manager->lock);
- /*
- * Start workers.
- */
- for (i = 0; i < workers; i++) {
- INIT_LIST(manager->queues[i].ready_tasks);
- INIT_LIST(manager->queues[i].ready_priority_tasks);
- isc_mutex_init(&manager->queues[i].lock);
- isc_condition_init(&manager->queues[i].work_available);
-
- manager->queues[i].manager = manager;
- manager->queues[i].threadid = i;
- isc_thread_create(run, &manager->queues[i],
- &manager->queues[i].thread);
- char name[21];
- snprintf(name, sizeof(name), "work-%u", i);
- isc_thread_setname(manager->queues[i].thread, name);
- }
- UNLOCK(&manager->lock);
-
- isc_thread_setconcurrency(workers);
+ isc_refcount_init(&manager->references, 1);
- *managerp = (isc_taskmgr_t *)manager;
+ *managerp = manager;
return (ISC_R_SUCCESS);
}
void
-isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
- isc__taskmgr_t *manager;
- isc__task_t *task;
- unsigned int i;
- bool exiting;
+isc__taskmgr_shutdown(isc_taskmgr_t *manager) {
+ isc_task_t *task;
- /*
- * Destroy '*managerp'.
- */
-
- REQUIRE(managerp != NULL);
- manager = (isc__taskmgr_t *)*managerp;
REQUIRE(VALID_MANAGER(manager));
- XTHREADTRACE("isc_taskmgr_destroy");
+ XTHREADTRACE("isc_taskmgr_shutdown");
/*
* Only one non-worker thread may ever call this routine.
* If a worker thread wants to initiate shutdown of the
@@ -1496,126 +1066,72 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
/*
* Make sure we only get called once.
*/
- exiting = false;
-
- INSIST(!!atomic_compare_exchange_strong(&manager->exiting, &exiting,
- true));
-
- /*
- * If privileged mode was on, turn it off.
- */
- atomic_store(&manager->mode, isc_taskmgrmode_normal);
+ INSIST(atomic_compare_exchange_strong(&manager->exiting,
+ &(bool){ false }, true));
/*
* Post shutdown event(s) to every task (if they haven't already been
- * posted). To make things easier post idle tasks to worker 0.
+ * posted).
*/
- LOCK(&manager->queues[0].lock);
for (task = HEAD(manager->tasks); task != NULL; task = NEXT(task, link))
{
+ bool was_idle;
+
LOCK(&task->lock);
- if (task_shutdown(task)) {
+ was_idle = task_shutdown(task);
+ if (was_idle) {
task->threadid = 0;
- push_readyq(manager, task, 0);
}
UNLOCK(&task->lock);
- }
- UNLOCK(&manager->queues[0].lock);
- /*
- * Wake up any sleeping workers. This ensures we get work done if
- * there's work left to do, and if there are already no tasks left
- * it will cause the workers to see manager->exiting.
- */
- wake_all_queues(manager);
- UNLOCK(&manager->lock);
-
- /*
- * Wait for all the worker threads to exit.
- */
- for (i = 0; i < manager->workers; i++) {
- isc_thread_join(manager->queues[i].thread, NULL);
- }
-
- /*
- * Detach from the network manager if it was set.
- */
- if (manager->nm != NULL) {
- isc_nm_detach(&manager->nm);
+ if (was_idle) {
+ task_ready(task);
+ }
}
- manager_free(manager);
-
- *managerp = NULL;
-}
-
-void
-isc_taskmgr_setprivilegedmode(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
-
- atomic_store(&manager->mode, isc_taskmgrmode_privileged);
-}
-
-isc_taskmgrmode_t
-isc_taskmgr_mode(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- return (atomic_load(&manager->mode));
+ UNLOCK(&manager->lock);
}
void
-isc__taskmgr_pause(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
+isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
+ REQUIRE(managerp != NULL && VALID_MANAGER(*managerp));
+ XTHREADTRACE("isc_taskmgr_destroy");
- LOCK(&manager->halt_lock);
- while (atomic_load_relaxed(&manager->exclusive_req) ||
- atomic_load_relaxed(&manager->pause_req))
- {
- UNLOCK(&manager->halt_lock);
- /* This is ugly but pause is used EXCLUSIVELY in tests */
- isc_thread_yield();
- LOCK(&manager->halt_lock);
+#ifdef ISC_TASK_TRACE
+ int counter = 0;
+ while (isc_refcount_current(&(*managerp)->references) > 1 &&
+ counter++ < 1000) {
+ usleep(10 * 1000);
}
-
- atomic_store_relaxed(&manager->pause_req, true);
- while (manager->halted < manager->workers) {
- wake_all_queues(manager);
- WAIT(&manager->halt_cond, &manager->halt_lock);
+ INSIST(counter < 1000);
+#else
+ while (isc_refcount_current(&(*managerp)->references) > 1) {
+ usleep(10 * 1000);
}
- UNLOCK(&manager->halt_lock);
-}
+#endif
-void
-isc__taskmgr_resume(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- LOCK(&manager->halt_lock);
- if (atomic_load(&manager->pause_req)) {
- atomic_store(&manager->pause_req, false);
- while (manager->halted > 0) {
- BROADCAST(&manager->halt_cond);
- WAIT(&manager->halt_cond, &manager->halt_lock);
- }
- }
- UNLOCK(&manager->halt_lock);
+ isc_taskmgr_detach(managerp);
}
void
-isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
- isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task) {
REQUIRE(VALID_MANAGER(mgr));
REQUIRE(VALID_TASK(task));
+
+ LOCK(&task->lock);
+ REQUIRE(task->threadid == 0);
+ UNLOCK(&task->lock);
+
LOCK(&mgr->excl_lock);
if (mgr->excl != NULL) {
- isc_task_detach((isc_task_t **)&mgr->excl);
+ isc_task_detach(&mgr->excl);
}
- isc_task_attach(task0, (isc_task_t **)&mgr->excl);
+ isc_task_attach(task, &mgr->excl);
UNLOCK(&mgr->excl_lock);
}
isc_result_t
-isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
- isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
+isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(VALID_MANAGER(mgr));
@@ -1623,7 +1139,7 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
LOCK(&mgr->excl_lock);
if (mgr->excl != NULL) {
- isc_task_attach((isc_task_t *)mgr->excl, taskp);
+ isc_task_attach(mgr->excl, taskp);
} else {
result = ISC_R_NOTFOUND;
}
@@ -1633,9 +1149,8 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
}
isc_result_t
-isc_task_beginexclusive(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
- isc__taskmgr_t *manager;
+isc_task_beginexclusive(isc_task_t *task) {
+ isc_taskmgr_t *manager;
REQUIRE(VALID_TASK(task));
@@ -1649,59 +1164,39 @@ isc_task_beginexclusive(isc_task_t *task0) {
task->manager->excl == NULL));
UNLOCK(&manager->excl_lock);
- if (atomic_load_relaxed(&manager->exclusive_req) ||
- atomic_load_relaxed(&manager->pause_req))
+ if (!atomic_compare_exchange_strong(&manager->exclusive_req,
+ &(bool){ false }, true))
{
return (ISC_R_LOCKBUSY);
}
- LOCK(&manager->halt_lock);
- INSIST(!atomic_load_relaxed(&manager->exclusive_req) &&
- !atomic_load_relaxed(&manager->pause_req));
- atomic_store_relaxed(&manager->exclusive_req, true);
- while (manager->halted + 1 < manager->workers) {
- wake_all_queues(manager);
- WAIT(&manager->halt_cond, &manager->halt_lock);
- }
- UNLOCK(&manager->halt_lock);
- if (manager->nm != NULL) {
- isc_nm_pause(manager->nm);
- }
+ isc_nm_pause(manager->netmgr);
+
return (ISC_R_SUCCESS);
}
void
-isc_task_endexclusive(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
- isc__taskmgr_t *manager;
+isc_task_endexclusive(isc_task_t *task) {
+ isc_taskmgr_t *manager;
REQUIRE(VALID_TASK(task));
REQUIRE(task->state == task_state_running);
manager = task->manager;
- if (manager->nm != NULL) {
- isc_nm_resume(manager->nm);
- }
- LOCK(&manager->halt_lock);
- REQUIRE(atomic_load_relaxed(&manager->exclusive_req));
- atomic_store_relaxed(&manager->exclusive_req, false);
- while (manager->halted > 0) {
- BROADCAST(&manager->halt_cond);
- WAIT(&manager->halt_cond, &manager->halt_lock);
- }
- UNLOCK(&manager->halt_lock);
+ isc_nm_resume(manager->netmgr);
+ REQUIRE(atomic_compare_exchange_strong(&manager->exclusive_req,
+ &(bool){ true }, false));
}
void
-isc_task_pause(isc_task_t *task0) {
- REQUIRE(ISCAPI_TASK_VALID(task0));
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_pause(isc_task_t *task) {
+ REQUIRE(VALID_TASK(task));
LOCK(&task->lock);
task->pause_cnt++;
if (task->pause_cnt > 1) {
/*
- * Someone already paused this thread, just increase
+ * Someone already paused this task, just increase
* the number of pausing clients.
*/
UNLOCK(&task->lock);
@@ -1720,11 +1215,10 @@ isc_task_pause(isc_task_t *task0) {
}
void
-isc_task_unpause(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_unpause(isc_task_t *task) {
bool was_idle = false;
- REQUIRE(ISCAPI_TASK_VALID(task0));
+ REQUIRE(VALID_TASK(task));
LOCK(&task->lock);
task->pause_cnt--;
@@ -1754,47 +1248,38 @@ isc_task_unpause(isc_task_t *task0) {
}
void
-isc_task_setprivilege(isc_task_t *task0, bool priv) {
- REQUIRE(ISCAPI_TASK_VALID(task0));
- isc__task_t *task = (isc__task_t *)task0;
- isc__taskmgr_t *manager = task->manager;
- uint_fast32_t oldflags, newflags;
-
- oldflags = atomic_load_acquire(&task->flags);
- do {
- if (priv) {
- newflags = oldflags | TASK_F_PRIVILEGED;
- } else {
- newflags = oldflags & ~TASK_F_PRIVILEGED;
- }
- if (newflags == oldflags) {
- return;
- }
- } while (!atomic_compare_exchange_weak_acq_rel(&task->flags, &oldflags,
- newflags));
-
- LOCK(&manager->queues[task->threadid].lock);
- if (priv && ISC_LINK_LINKED(task, ready_link)) {
- ENQUEUE(manager->queues[task->threadid].ready_priority_tasks,
- task, ready_priority_link);
- } else if (!priv && ISC_LINK_LINKED(task, ready_priority_link)) {
- DEQUEUE(manager->queues[task->threadid].ready_priority_tasks,
- task, ready_priority_link);
- }
- UNLOCK(&manager->queues[task->threadid].lock);
+isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) {
+ atomic_store(&manager->mode, mode);
+}
+
+isc_taskmgrmode_t
+isc_taskmgr_mode(isc_taskmgr_t *manager) {
+ return (atomic_load(&manager->mode));
+}
+
+void
+isc_task_setprivilege(isc_task_t *task, bool priv) {
+ REQUIRE(VALID_TASK(task));
+
+ atomic_store_release(&task->privileged, priv);
}
bool
-isc_task_privilege(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_getprivilege(isc_task_t *task) {
REQUIRE(VALID_TASK(task));
return (TASK_PRIVILEGED(task));
}
bool
-isc_task_exiting(isc_task_t *t) {
- isc__task_t *task = (isc__task_t *)t;
+isc_task_privileged(isc_task_t *task) {
+ REQUIRE(VALID_TASK(task));
+
+ return (isc_taskmgr_mode(task->manager) && TASK_PRIVILEGED(task));
+}
+
+bool
+isc_task_exiting(isc_task_t *task) {
REQUIRE(VALID_TASK(task));
return (TASK_SHUTTINGDOWN(task));
@@ -1808,9 +1293,8 @@ isc_task_exiting(isc_task_t *t) {
goto error; \
} while (0)
int
-isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, void *writer0) {
- isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
- isc__task_t *task = NULL;
+isc_taskmgr_renderxml(isc_taskmgr_t *mgr, void *writer0) {
+ isc_task_t *task = NULL;
int xmlrc;
xmlTextWriterPtr writer = (xmlTextWriterPtr)writer0;
@@ -1825,30 +1309,11 @@ isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, void *writer0) {
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "threaded"));
TRY0(xmlTextWriterEndElement(writer)); /* type */
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "worker-threads"));
- TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->workers));
- TRY0(xmlTextWriterEndElement(writer)); /* worker-threads */
-
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "default-quantum"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
mgr->default_quantum));
TRY0(xmlTextWriterEndElement(writer)); /* default-quantum */
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-count"));
- TRY0(xmlTextWriterWriteFormatString(
- writer, "%d", (int)atomic_load_relaxed(&mgr->tasks_count)));
- TRY0(xmlTextWriterEndElement(writer)); /* tasks-count */
-
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-running"));
- TRY0(xmlTextWriterWriteFormatString(
- writer, "%d", (int)atomic_load_relaxed(&mgr->tasks_running)));
- TRY0(xmlTextWriterEndElement(writer)); /* tasks-running */
-
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-ready"));
- TRY0(xmlTextWriterWriteFormatString(
- writer, "%d", (int)atomic_load_relaxed(&mgr->tasks_ready)));
- TRY0(xmlTextWriterEndElement(writer)); /* tasks-ready */
-
TRY0(xmlTextWriterEndElement(writer)); /* thread-model */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks"));
@@ -1918,10 +1383,9 @@ error:
} while (0)
isc_result_t
-isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, void *tasks0) {
+isc_taskmgr_renderjson(isc_taskmgr_t *mgr, void *tasks0) {
isc_result_t result = ISC_R_SUCCESS;
- isc__taskmgr_t *mgr = (isc__taskmgr_t *)mgr0;
- isc__task_t *task = NULL;
+ isc_task_t *task = NULL;
json_object *obj = NULL, *array = NULL, *taskobj = NULL;
json_object *tasks = (json_object *)tasks0;
@@ -1935,26 +1399,10 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, void *tasks0) {
CHECKMEM(obj);
json_object_object_add(tasks, "thread-model", obj);
- obj = json_object_new_int(mgr->workers);
- CHECKMEM(obj);
- json_object_object_add(tasks, "worker-threads", obj);
-
obj = json_object_new_int(mgr->default_quantum);
CHECKMEM(obj);
json_object_object_add(tasks, "default-quantum", obj);
- obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_count));
- CHECKMEM(obj);
- json_object_object_add(tasks, "tasks-count", obj);
-
- obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_running));
- CHECKMEM(obj);
- json_object_object_add(tasks, "tasks-running", obj);
-
- obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_ready));
- CHECKMEM(obj);
- json_object_object_add(tasks, "tasks-ready", obj);
-
array = json_object_new_array();
CHECKMEM(array);
@@ -2017,15 +1465,3 @@ error:
return (result);
}
#endif /* ifdef HAVE_JSON_C */
-
-isc_result_t
-isc_taskmgr_createinctx(isc_mem_t *mctx, unsigned int workers,
- unsigned int default_quantum,
- isc_taskmgr_t **managerp) {
- isc_result_t result;
-
- result = isc_taskmgr_create(mctx, workers, default_quantum, NULL,
- managerp);
-
- return (result);
-}
diff --git a/external/mpl/bind/dist/lib/isc/task_p.h b/external/mpl/bind/dist/lib/isc/task_p.h
index aa547af0328..645eaa21597 100644
--- a/external/mpl/bind/dist/lib/isc/task_p.h
+++ b/external/mpl/bind/dist/lib/isc/task_p.h
@@ -1,4 +1,4 @@
-/* $NetBSD: task_p.h,v 1.4 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: task_p.h,v 1.5 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -11,18 +11,96 @@
* information regarding copyright ownership.
*/
-#ifndef ISC_TASK_P_H
-#define ISC_TASK_P_H
+#pragma once
-/*! \file */
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/task.h>
-/*%
- * These functions allow unit tests to manipulate the processing
- * of the task queue. They are not intended as part of the public API.
+isc_result_t
+isc__taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
+ isc_taskmgr_t **managerp);
+/*%<
+ * Create a new task manager.
+ *
+ * Notes:
+ *
+ *\li If 'default_quantum' is non-zero, then it will be used as the default
+ * quantum value when tasks are created. If zero, then an implementation
+ * defined default quantum will be used.
+ *
+ *\li If 'nm' is set then netmgr is paused when an exclusive task mode
+ * is requested.
+ *
+ * Requires:
+ *
+ *\li 'mctx' is a valid memory context.
+ *
+ *\li managerp != NULL && *managerp == NULL
+ *
+ * Ensures:
+ *
+ *\li On success, '*managerp' will be attached to the newly created task
+ * manager.
+ *
+ * Returns:
+ *
+ *\li #ISC_R_SUCCESS
+ *\li #ISC_R_NOMEMORY
+ *\li #ISC_R_NOTHREADS No threads could be created.
+ *\li #ISC_R_UNEXPECTED An unexpected error occurred.
+ *\li #ISC_R_SHUTTINGDOWN The non-threaded, shared, task
+ * manager shutting down.
*/
+
void
-isc__taskmgr_pause(isc_taskmgr_t *taskmgr);
-void
-isc__taskmgr_resume(isc_taskmgr_t *taskmgr);
+isc__taskmgr_destroy(isc_taskmgr_t **managerp);
+/*%<
+ * Destroy '*managerp'.
+ *
+ * Notes:
+ *
+ *\li Calling isc_taskmgr_destroy() will shutdown all tasks managed by
+ * *managerp that haven't already been shutdown. The call will block
+ * until all tasks have entered the done state.
+ *
+ *\li isc_taskmgr_destroy() must not be called by a task event action,
+ * because it would block forever waiting for the event action to
+ * complete. An event action that wants to cause task manager shutdown
+ * should request some non-event action thread of execution to do the
+ * shutdown, e.g. by signaling a condition variable or using
+ * isc_app_shutdown().
+ *
+ *\li Task manager references are not reference counted, so the caller
+ * must ensure that no attempt will be made to use the manager after
+ * isc_taskmgr_destroy() returns.
+ *
+ * Requires:
+ *
+ *\li '*managerp' is a valid task manager.
+ *
+ *\li 'isc__taskmgr_shutdown()' and isc__netmgr_shutdown() have been
+ * called.
+ */
-#endif /* ISC_TASK_P_H */
+void
+isc__taskmgr_shutdown(isc_taskmgr_t *manager);
+/*%>
+ * Shutdown 'manager'.
+ *
+ * Notes:
+ *
+ *\li Calling isc__taskmgr_shutdown() will shut down all tasks managed by
+ * *managerp that haven't already been shut down.
+ *
+ * Requires:
+ *
+ *\li 'manager' is a valid task manager.
+ *
+ *\li isc_taskmgr_destroy() has not be called previously on '*managerp'.
+ *
+ * Ensures:
+ *
+ *\li All resources used by the task manager, and any tasks it managed,
+ * have been freed.
+ */
diff --git a/external/mpl/bind/dist/lib/isc/taskpool.c b/external/mpl/bind/dist/lib/isc/taskpool.c
index 9b60349bdca..6a0c2a8a2a7 100644
--- a/external/mpl/bind/dist/lib/isc/taskpool.c
+++ b/external/mpl/bind/dist/lib/isc/taskpool.c
@@ -1,4 +1,4 @@
-/* $NetBSD: taskpool.c,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: taskpool.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -59,10 +59,9 @@ alloc_pool(isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks,
isc_result_t
isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks,
- unsigned int quantum, isc_taskpool_t **poolp) {
+ unsigned int quantum, bool priv, isc_taskpool_t **poolp) {
unsigned int i;
isc_taskpool_t *pool = NULL;
- isc_result_t result;
INSIST(ntasks > 0);
@@ -71,11 +70,13 @@ isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, unsigned int ntasks,
/* Create the tasks */
for (i = 0; i < ntasks; i++) {
- result = isc_task_create(tmgr, quantum, &pool->tasks[i]);
+ isc_result_t result = isc_task_create_bound(tmgr, quantum,
+ &pool->tasks[i], i);
if (result != ISC_R_SUCCESS) {
isc_taskpool_destroy(&pool);
return (result);
}
+ isc_task_setprivilege(pool->tasks[i], priv);
isc_task_setname(pool->tasks[i], "taskpool", NULL);
}
@@ -95,9 +96,8 @@ isc_taskpool_size(isc_taskpool_t *pool) {
}
isc_result_t
-isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size,
+isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size, bool priv,
isc_taskpool_t **targetp) {
- isc_result_t result;
isc_taskpool_t *pool;
REQUIRE(sourcep != NULL && *sourcep != NULL);
@@ -121,13 +121,15 @@ isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size,
/* Create new tasks */
for (i = pool->ntasks; i < size; i++) {
- result = isc_task_create(pool->tmgr, pool->quantum,
- &newpool->tasks[i]);
+ isc_result_t result =
+ isc_task_create_bound(pool->tmgr, pool->quantum,
+ &newpool->tasks[i], i);
if (result != ISC_R_SUCCESS) {
*sourcep = pool;
isc_taskpool_destroy(&newpool);
return (result);
}
+ isc_task_setprivilege(newpool->tasks[i], priv);
isc_task_setname(newpool->tasks[i], "taskpool", NULL);
}
@@ -153,16 +155,3 @@ isc_taskpool_destroy(isc_taskpool_t **poolp) {
pool->ntasks * sizeof(isc_task_t *));
isc_mem_putanddetach(&pool->mctx, pool, sizeof(*pool));
}
-
-void
-isc_taskpool_setprivilege(isc_taskpool_t *pool, bool priv) {
- unsigned int i;
-
- REQUIRE(pool != NULL);
-
- for (i = 0; i < pool->ntasks; i++) {
- if (pool->tasks[i] != NULL) {
- isc_task_setprivilege(pool->tasks[i], priv);
- }
- }
-}
diff --git a/external/mpl/bind/dist/lib/isc/tests/isctest.c b/external/mpl/bind/dist/lib/isc/tests/isctest.c
index c69b8b47853..1ada165349a 100644
--- a/external/mpl/bind/dist/lib/isc/tests/isctest.c
+++ b/external/mpl/bind/dist/lib/isc/tests/isctest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: isctest.c,v 1.5 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: isctest.c,v 1.6 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -21,6 +21,7 @@
#include <isc/buffer.h>
#include <isc/hash.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/socket.h>
@@ -59,18 +60,16 @@ cleanup_managers(void) {
isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
}
+
+ isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
+ taskmgr == NULL ? NULL : &taskmgr);
+
if (socketmgr != NULL) {
isc_socketmgr_destroy(&socketmgr);
}
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
}
- if (netmgr != NULL) {
- isc_nm_detach(&netmgr);
- }
}
static isc_result_t
@@ -87,9 +86,8 @@ create_managers(unsigned int workers) {
workers = atoi(p);
}
- netmgr = isc_nm_start(test_mctx, workers);
- CHECK(isc_taskmgr_create(test_mctx, workers, 0, netmgr, &taskmgr));
- CHECK(isc_task_create(taskmgr, 0, &maintask));
+ CHECK(isc_managers_create(test_mctx, workers, 0, &netmgr, &taskmgr));
+ CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);
CHECK(isc_timermgr_create(test_mctx, &timermgr));
@@ -149,9 +147,6 @@ isc_test_end(void) {
if (maintask != NULL) {
isc_task_detach(&maintask);
}
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
cleanup_managers();
@@ -170,19 +165,9 @@ isc_test_end(void) {
*/
void
isc_test_nap(uint32_t usec) {
-#ifdef HAVE_NANOSLEEP
struct timespec ts;
ts.tv_sec = usec / 1000000;
ts.tv_nsec = (usec % 1000000) * 1000;
nanosleep(&ts, NULL);
-#elif HAVE_USLEEP
- usleep(usec);
-#else /* ifdef HAVE_NANOSLEEP */
- /*
- * No fractional-second sleep function is available, so we
- * round up to the nearest second and sleep instead
- */
- sleep((usec / 1000000) + 1);
-#endif /* ifdef HAVE_NANOSLEEP */
}
diff --git a/external/mpl/bind/dist/lib/isc/tests/netmgr_test.c b/external/mpl/bind/dist/lib/isc/tests/netmgr_test.c
index f36b819545b..ca8bded86d1 100644
--- a/external/mpl/bind/dist/lib/isc/tests/netmgr_test.c
+++ b/external/mpl/bind/dist/lib/isc/tests/netmgr_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: netmgr_test.c,v 1.1.1.1 2021/08/19 11:45:28 christos Exp $ */
+/* $NetBSD: netmgr_test.c,v 1.2 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/tests/quota_test.c b/external/mpl/bind/dist/lib/isc/tests/quota_test.c
index d2ebc445e77..ac0aaa53db6 100644
--- a/external/mpl/bind/dist/lib/isc/tests/quota_test.c
+++ b/external/mpl/bind/dist/lib/isc/tests/quota_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: quota_test.c,v 1.4 2021/04/29 17:26:12 christos Exp $ */
+/* $NetBSD: quota_test.c,v 1.5 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -30,6 +30,8 @@
#include <isc/thread.h>
#include <isc/util.h>
+#include "isctest.h"
+
static void
isc_quota_get_set_test(void **state) {
UNUSED(state);
@@ -258,7 +260,7 @@ isc_thread_t g_threads[10 * 100];
static void *
quota_detach(void *quotap) {
isc_quota_t *quota = (isc_quota_t *)quotap;
- usleep(10000);
+ isc_test_nap(10000);
isc_quota_detach(&quota);
return ((isc_threadresult_t)0);
}
diff --git a/external/mpl/bind/dist/lib/isc/tests/task_test.c b/external/mpl/bind/dist/lib/isc/tests/task_test.c
index d6c5929ed6c..a6ea63fd953 100644
--- a/external/mpl/bind/dist/lib/isc/tests/task_test.c
+++ b/external/mpl/bind/dist/lib/isc/tests/task_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: task_test.c,v 1.8 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: task_test.c,v 1.9 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -31,6 +31,7 @@
#include <isc/cmocka.h>
#include <isc/commandline.h>
#include <isc/condition.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/platform.h>
#include <isc/print.h>
@@ -39,7 +40,6 @@
#include <isc/timer.h>
#include <isc/util.h>
-#include "../task_p.h"
#include "isctest.h"
/* Set to true (or use -v option) for verbose output */
@@ -122,6 +122,8 @@ set(isc_task_t *task, isc_event_t *event) {
atomic_store(value, atomic_fetch_add(&counter, 1));
}
+#include <isc/thread.h>
+
static void
set_and_drop(isc_task_t *task, isc_event_t *event) {
atomic_int_fast32_t *value = (atomic_int_fast32_t *)event->ev_arg;
@@ -130,8 +132,7 @@ set_and_drop(isc_task_t *task, isc_event_t *event) {
isc_event_free(&event);
LOCK(&lock);
- atomic_store(value, (int)isc_taskmgr_mode(taskmgr));
- atomic_fetch_add(&counter, 1);
+ atomic_store(value, atomic_fetch_add(&counter, 1));
UNLOCK(&lock);
}
@@ -206,36 +207,37 @@ privileged_events(void **state) {
UNUSED(state);
atomic_init(&counter, 1);
- atomic_init(&a, 0);
- atomic_init(&b, 0);
- atomic_init(&c, 0);
- atomic_init(&d, 0);
- atomic_init(&e, 0);
+ atomic_init(&a, -1);
+ atomic_init(&b, -1);
+ atomic_init(&c, -1);
+ atomic_init(&d, -1);
+ atomic_init(&e, -1);
/*
- * Pause the task manager so we can fill up the work queue
- * without things happening while we do it.
+ * Pause the net/task manager so we can fill up the work
+ * queue without things happening while we do it.
*/
- isc__taskmgr_pause(taskmgr);
+ isc_nm_pause(netmgr);
+ isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
result = isc_task_create(taskmgr, 0, &task1);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_setname(task1, "privileged", NULL);
- assert_false(isc_task_privilege(task1));
+ assert_false(isc_task_getprivilege(task1));
isc_task_setprivilege(task1, true);
- assert_true(isc_task_privilege(task1));
+ assert_true(isc_task_getprivilege(task1));
result = isc_task_create(taskmgr, 0, &task2);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_setname(task2, "normal", NULL);
- assert_false(isc_task_privilege(task2));
+ assert_false(isc_task_getprivilege(task2));
/* First event: privileged */
event = isc_event_allocate(test_mctx, task1, ISC_TASKEVENT_TEST, set,
&a, sizeof(isc_event_t));
assert_non_null(event);
- assert_int_equal(atomic_load(&a), 0);
+ assert_int_equal(atomic_load(&a), -1);
isc_task_send(task1, &event);
/* Second event: not privileged */
@@ -243,7 +245,7 @@ privileged_events(void **state) {
&b, sizeof(isc_event_t));
assert_non_null(event);
- assert_int_equal(atomic_load(&b), 0);
+ assert_int_equal(atomic_load(&b), -1);
isc_task_send(task2, &event);
/* Third event: privileged */
@@ -251,7 +253,7 @@ privileged_events(void **state) {
&c, sizeof(isc_event_t));
assert_non_null(event);
- assert_int_equal(atomic_load(&c), 0);
+ assert_int_equal(atomic_load(&c), -1);
isc_task_send(task1, &event);
/* Fourth event: privileged */
@@ -259,7 +261,7 @@ privileged_events(void **state) {
&d, sizeof(isc_event_t));
assert_non_null(event);
- assert_int_equal(atomic_load(&d), 0);
+ assert_int_equal(atomic_load(&d), -1);
isc_task_send(task1, &event);
/* Fifth event: not privileged */
@@ -267,19 +269,15 @@ privileged_events(void **state) {
&e, sizeof(isc_event_t));
assert_non_null(event);
- assert_int_equal(atomic_load(&e), 0);
+ assert_int_equal(atomic_load(&e), -1);
isc_task_send(task2, &event);
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
- isc_taskmgr_setprivilegedmode(taskmgr);
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_privileged);
-
- isc__taskmgr_resume(taskmgr);
+ isc_nm_resume(netmgr);
/* We're waiting for *all* variables to be set */
- while ((atomic_load(&a) == 0 || atomic_load(&b) == 0 ||
- atomic_load(&c) == 0 || atomic_load(&d) == 0 ||
- atomic_load(&e) == 0) &&
+ while ((atomic_load(&a) < 0 || atomic_load(&b) < 0 ||
+ atomic_load(&c) < 0 || atomic_load(&d) < 0 ||
+ atomic_load(&e) < 0) &&
i++ < 5000)
{
isc_test_nap(1000);
@@ -295,15 +293,13 @@ privileged_events(void **state) {
assert_true(atomic_load(&d) <= 3);
/* ...and the non-privileged tasks that set b and e, last */
- assert_true(atomic_load(&b) >= 4);
- assert_true(atomic_load(&e) >= 4);
+ assert_true(atomic_load(&b) > 3);
+ assert_true(atomic_load(&e) > 3);
assert_int_equal(atomic_load(&counter), 6);
isc_task_setprivilege(task1, false);
- assert_false(isc_task_privilege(task1));
-
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
+ assert_false(isc_task_getprivilege(task1));
isc_task_destroy(&task1);
assert_null(task1);
@@ -333,22 +329,23 @@ privilege_drop(void **state) {
atomic_init(&e, -1);
/*
- * Pause the task manager so we can fill up the work queue
+ * Pause the net/task manager so we can fill up the work queue
* without things happening while we do it.
*/
- isc__taskmgr_pause(taskmgr);
+ isc_nm_pause(netmgr);
+ isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
result = isc_task_create(taskmgr, 0, &task1);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_setname(task1, "privileged", NULL);
- assert_false(isc_task_privilege(task1));
+ assert_false(isc_task_getprivilege(task1));
isc_task_setprivilege(task1, true);
- assert_true(isc_task_privilege(task1));
+ assert_true(isc_task_getprivilege(task1));
result = isc_task_create(taskmgr, 0, &task2);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_setname(task2, "normal", NULL);
- assert_false(isc_task_privilege(task2));
+ assert_false(isc_task_getprivilege(task2));
/* First event: privileged */
event = isc_event_allocate(test_mctx, task1, ISC_TASKEVENT_TEST,
@@ -390,11 +387,7 @@ privilege_drop(void **state) {
assert_int_equal(atomic_load(&e), -1);
isc_task_send(task2, &event);
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
- isc_taskmgr_setprivilegedmode(taskmgr);
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_privileged);
-
- isc__taskmgr_resume(taskmgr);
+ isc_nm_resume(netmgr);
/* We're waiting for all variables to be set. */
while ((atomic_load(&a) == -1 || atomic_load(&b) == -1 ||
@@ -409,19 +402,17 @@ privilege_drop(void **state) {
* We need to check that all privilege mode events were fired
* in privileged mode, and non privileged in non-privileged.
*/
- assert_true(atomic_load(&a) == isc_taskmgrmode_privileged ||
- atomic_load(&c) == isc_taskmgrmode_privileged ||
- atomic_load(&d) == isc_taskmgrmode_privileged);
+ assert_true(atomic_load(&a) <= 3);
+ assert_true(atomic_load(&c) <= 3);
+ assert_true(atomic_load(&d) <= 3);
/* ...and neither of the non-privileged tasks did... */
- assert_true(atomic_load(&b) == isc_taskmgrmode_normal ||
- atomic_load(&e) == isc_taskmgrmode_normal);
+ assert_true(atomic_load(&b) > 3);
+ assert_true(atomic_load(&e) > 3);
/* ...but all five of them did run. */
assert_int_equal(atomic_load(&counter), 6);
- assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
-
isc_task_destroy(&task1);
assert_null(task1);
isc_task_destroy(&task2);
@@ -697,6 +688,7 @@ exclusive_cb(isc_task_t *task, isc_event_t *event) {
if (atomic_load(&done)) {
isc_mem_put(event->ev_destroy_arg, event->ev_arg, sizeof(int));
isc_event_free(&event);
+ atomic_fetch_sub(&counter, 1);
} else {
isc_task_send(task, &event);
}
@@ -710,18 +702,24 @@ task_exclusive(void **state) {
UNUSED(state);
+ atomic_init(&counter, 0);
+
for (i = 0; i < 10; i++) {
isc_event_t *event = NULL;
int *v;
tasks[i] = NULL;
- result = isc_task_create(taskmgr, 0, &tasks[i]);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- /* task chosen from the middle of the range */
if (i == 6) {
+ /* task chosen from the middle of the range */
+ result = isc_task_create_bound(taskmgr, 0, &tasks[i],
+ 0);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
isc_taskmgr_setexcltask(taskmgr, tasks[6]);
+ } else {
+ result = isc_task_create(taskmgr, 0, &tasks[i]);
+ assert_int_equal(result, ISC_R_SUCCESS);
}
v = isc_mem_get(test_mctx, sizeof *v);
@@ -734,11 +732,16 @@ task_exclusive(void **state) {
assert_non_null(event);
isc_task_send(tasks[i], &event);
+ atomic_fetch_add(&counter, 1);
}
for (i = 0; i < 10; i++) {
isc_task_detach(&tasks[i]);
}
+
+ while (atomic_load(&counter) > 0) {
+ isc_test_nap(1000);
+ }
}
/*
@@ -790,7 +793,6 @@ maxtask_cb(isc_task_t *task, isc_event_t *event) {
static void
manytasks(void **state) {
isc_mem_t *mctx = NULL;
- isc_result_t result;
isc_event_t *event = NULL;
uintptr_t ntasks = 10000;
@@ -807,8 +809,7 @@ manytasks(void **state) {
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
- result = isc_taskmgr_create(mctx, 4, 0, NULL, &taskmgr);
- assert_int_equal(result, ISC_R_SUCCESS);
+ isc_managers_create(mctx, 4, 0, &netmgr, &taskmgr);
atomic_init(&done, false);
@@ -823,7 +824,8 @@ manytasks(void **state) {
}
UNLOCK(&lock);
- isc_taskmgr_destroy(&taskmgr);
+ isc_managers_destroy(&netmgr, &taskmgr);
+
isc_mem_destroy(&mctx);
isc_condition_destroy(&cv);
isc_mutex_destroy(&lock);
@@ -903,7 +905,7 @@ sd_event2(isc_task_t *task, isc_event_t *event) {
}
static void
-shutdown(void **state) {
+task_shutdown(void **state) {
isc_result_t result;
isc_eventtype_t event_type;
isc_event_t *event = NULL;
@@ -1549,7 +1551,8 @@ main(int argc, char **argv) {
cmocka_unit_test_setup_teardown(purgeevent_notpurge, _setup,
_teardown),
cmocka_unit_test_setup_teardown(purgerange, _setup, _teardown),
- cmocka_unit_test_setup_teardown(shutdown, _setup4, _teardown),
+ cmocka_unit_test_setup_teardown(task_shutdown, _setup4,
+ _teardown),
cmocka_unit_test_setup_teardown(task_exclusive, _setup4,
_teardown),
};
diff --git a/external/mpl/bind/dist/lib/isc/tests/taskpool_test.c b/external/mpl/bind/dist/lib/isc/tests/taskpool_test.c
index 9dbe26c5272..931649a0730 100644
--- a/external/mpl/bind/dist/lib/isc/tests/taskpool_test.c
+++ b/external/mpl/bind/dist/lib/isc/tests/taskpool_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: taskpool_test.c,v 1.8 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: taskpool_test.c,v 1.9 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -30,6 +30,9 @@
#include "isctest.h"
+#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
+#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
+
static int
_setup(void **state) {
isc_result_t result;
@@ -59,7 +62,7 @@ create_pool(void **state) {
UNUSED(state);
- result = isc_taskpool_create(taskmgr, test_mctx, 8, 2, &pool);
+ result = isc_taskpool_create(taskmgr, test_mctx, 8, 2, false, &pool);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool), 8);
@@ -75,13 +78,13 @@ expand_pool(void **state) {
UNUSED(state);
- result = isc_taskpool_create(taskmgr, test_mctx, 10, 2, &pool1);
+ result = isc_taskpool_create(taskmgr, test_mctx, 10, 2, false, &pool1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool1), 10);
/* resizing to a smaller size should have no effect */
hold = pool1;
- result = isc_taskpool_expand(&pool1, 5, &pool2);
+ result = isc_taskpool_expand(&pool1, 5, false, &pool2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool2), 10);
assert_ptr_equal(pool2, hold);
@@ -91,7 +94,7 @@ expand_pool(void **state) {
/* resizing to the same size should have no effect */
hold = pool1;
- result = isc_taskpool_expand(&pool1, 10, &pool2);
+ result = isc_taskpool_expand(&pool1, 10, false, &pool2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool2), 10);
assert_ptr_equal(pool2, hold);
@@ -101,7 +104,7 @@ expand_pool(void **state) {
/* resizing to larger size should make a new pool */
hold = pool1;
- result = isc_taskpool_expand(&pool1, 20, &pool2);
+ result = isc_taskpool_expand(&pool1, 20, false, &pool2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool2), 20);
assert_ptr_not_equal(pool2, hold);
@@ -120,19 +123,19 @@ get_tasks(void **state) {
UNUSED(state);
- result = isc_taskpool_create(taskmgr, test_mctx, 2, 2, &pool);
+ result = isc_taskpool_create(taskmgr, test_mctx, 2, 2, false, &pool);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool), 2);
/* two tasks in pool; make sure we can access them more than twice */
isc_taskpool_gettask(pool, &task1);
- assert_true(ISCAPI_TASK_VALID(task1));
+ assert_true(VALID_TASK(task1));
isc_taskpool_gettask(pool, &task2);
- assert_true(ISCAPI_TASK_VALID(task2));
+ assert_true(VALID_TASK(task2));
isc_taskpool_gettask(pool, &task3);
- assert_true(ISCAPI_TASK_VALID(task3));
+ assert_true(VALID_TASK(task3));
isc_task_destroy(&task1);
isc_task_destroy(&task2);
@@ -151,29 +154,21 @@ set_privilege(void **state) {
UNUSED(state);
- result = isc_taskpool_create(taskmgr, test_mctx, 2, 2, &pool);
+ result = isc_taskpool_create(taskmgr, test_mctx, 2, 2, true, &pool);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(isc_taskpool_size(pool), 2);
- isc_taskpool_setprivilege(pool, true);
-
isc_taskpool_gettask(pool, &task1);
isc_taskpool_gettask(pool, &task2);
isc_taskpool_gettask(pool, &task3);
- assert_true(ISCAPI_TASK_VALID(task1));
- assert_true(ISCAPI_TASK_VALID(task2));
- assert_true(ISCAPI_TASK_VALID(task3));
-
- assert_true(isc_task_privilege(task1));
- assert_true(isc_task_privilege(task2));
- assert_true(isc_task_privilege(task3));
-
- isc_taskpool_setprivilege(pool, false);
+ assert_true(VALID_TASK(task1));
+ assert_true(VALID_TASK(task2));
+ assert_true(VALID_TASK(task3));
- assert_false(isc_task_privilege(task1));
- assert_false(isc_task_privilege(task2));
- assert_false(isc_task_privilege(task3));
+ assert_true(isc_task_getprivilege(task1));
+ assert_true(isc_task_getprivilege(task2));
+ assert_true(isc_task_getprivilege(task3));
isc_task_destroy(&task1);
isc_task_destroy(&task2);
diff --git a/external/mpl/bind/dist/lib/isc/tests/tcp_quota_test.c b/external/mpl/bind/dist/lib/isc/tests/tcp_quota_test.c
deleted file mode 100644
index f1fb6267558..00000000000
--- a/external/mpl/bind/dist/lib/isc/tests/tcp_quota_test.c
+++ /dev/null
@@ -1,738 +0,0 @@
-/* $NetBSD: tcp_quota_test.c,v 1.3 2021/04/29 17:26:13 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-#include <sched.h> /* IWYU pragma: keep */
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <uv.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/mutex.h>
-#include <isc/netmgr.h>
-#include <isc/nonce.h>
-#include <isc/os.h>
-#include <isc/refcount.h>
-#include <isc/sockaddr.h>
-#include <isc/thread.h>
-
-#include "../netmgr/netmgr-int.h"
-#include "isctest.h"
-
-#define MAX_NM 2
-
-static isc_sockaddr_t tcp_listen_addr;
-
-static uint64_t send_magic = 0;
-static uint64_t stop_magic = 0;
-
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
- .len = sizeof(send_magic) };
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static atomic_uint_fast64_t nsends;
-
-static atomic_uint_fast64_t ssends;
-static atomic_uint_fast64_t sreads;
-
-static atomic_uint_fast64_t saccepts;
-
-static atomic_uint_fast64_t cconnects;
-static atomic_uint_fast64_t csends;
-static atomic_uint_fast64_t creads;
-static atomic_uint_fast64_t ctimeouts;
-
-static unsigned int workers = 2;
-
-static isc_quota_t listener_quota;
-static atomic_bool check_listener_quota;
-
-#define NSENDS 100
-#define NWRITES 10
-
-/* Enable this to print values while running tests */
-#undef PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v))
-#define P(v) fprintf(stderr, #v " = %" PRIu64 "\n", v)
-#else
-#define X(v)
-#define P(v)
-#endif
-
-static int
-setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
- isc_result_t result;
- socklen_t addrlen = sizeof(*addr);
- int fd;
- int r;
-
- isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
-
- fd = socket(AF_INET6, family, 0);
- if (fd < 0) {
- perror("setup_ephemeral_port: socket()");
- return (-1);
- }
-
- r = bind(fd, (const struct sockaddr *)&addr->type.sa,
- sizeof(addr->type.sin6));
- if (r != 0) {
- perror("setup_ephemeral_port: bind()");
- close(fd);
- return (r);
- }
-
- r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
- if (r != 0) {
- perror("setup_ephemeral_port: getsockname()");
- close(fd);
- return (r);
- }
-
- result = isc__nm_socket_reuse(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
- result = isc__nm_socket_reuse_lb(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
-#if IPV6_RECVERR
-#define setsockopt_on(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
-
- r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
- if (r != 0) {
- perror("setup_ephemeral_port");
- close(fd);
- return (r);
- }
-#endif
-
- return (fd);
-}
-
-static int
-_setup(void **state) {
- UNUSED(state);
-
- /* workers = isc_os_ncpus(); */
-
- if (isc_test_begin(NULL, true, workers) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- signal(SIGPIPE, SIG_IGN);
-
- return (0);
-}
-
-static int
-_teardown(void **state) {
- UNUSED(state);
-
- isc_test_end();
-
- return (0);
-}
-
-/* Generic */
-
-ISC_THREAD_LOCAL uint8_t tcp_buffer_storage[4096];
-ISC_THREAD_LOCAL size_t tcp_buffer_length = 0;
-
-static int
-nm_setup(void **state) {
- size_t nworkers = ISC_MAX(ISC_MIN(workers, 32), 1);
- int tcp_listen_sock = -1;
- isc_nm_t **nm = NULL;
-
- tcp_listen_addr = (isc_sockaddr_t){ .length = 0 };
- tcp_listen_sock = setup_ephemeral_port(&tcp_listen_addr, SOCK_STREAM);
- if (tcp_listen_sock < 0) {
- return (-1);
- }
- close(tcp_listen_sock);
- tcp_listen_sock = -1;
- UNUSED(tcp_listen_sock);
-
- atomic_store(&nsends, NSENDS * NWRITES);
-
- atomic_store(&csends, 0);
- atomic_store(&creads, 0);
- atomic_store(&sreads, 0);
- atomic_store(&ssends, 0);
- atomic_store(&saccepts, 0);
- atomic_store(&ctimeouts, 0);
- atomic_store(&cconnects, 0);
-
- isc_nonce_buf(&send_magic, sizeof(send_magic));
- isc_nonce_buf(&stop_magic, sizeof(stop_magic));
- if (send_magic == stop_magic) {
- return (-1);
- }
-
- nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
- for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
- assert_non_null(nm[i]);
- }
-
- *state = nm;
-
- isc_quota_init(&listener_quota, 0);
- atomic_store(&check_listener_quota, false);
- return (0);
-}
-
-static int
-nm_teardown(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
-
- for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
- assert_null(nm[i]);
- }
- isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
-
- isc_quota_destroy(&listener_quota);
- return (0);
-}
-
-/* TCP Connect */
-
-static void
-tcp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg);
-
-static void
-tcp_connect_send(isc_nmhandle_t *handle);
-
-static void
-tcp_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- memmove(tcp_buffer_storage + tcp_buffer_length, region->base,
- region->length);
- tcp_buffer_length += region->length;
-
- if (tcp_buffer_length >= sizeof(magic)) {
- isc_nm_pauseread(handle);
-
- atomic_fetch_add(&creads, 1);
-
- memmove(&magic, tcp_buffer_storage, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- tcp_buffer_length -= sizeof(magic);
- memmove(tcp_buffer_storage, tcp_buffer_storage + sizeof(magic),
- tcp_buffer_length);
-
- if (magic == send_magic) {
- tcp_connect_send(handle);
- return;
- } else if (magic == stop_magic) {
- /* We are done, so we don't send anything back */
- /* There should be no more packets in the buffer */
- assert_int_equal(tcp_buffer_length, 0);
- }
- }
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static void
-tcp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- assert_non_null(handle);
- UNUSED(cbarg);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- isc_nm_resumeread(handle);
- } else {
- /* Send failed, we need to stop reading too */
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcp_connect_shutdown(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- } else {
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcp_connect_send(isc_nmhandle_t *handle) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends, sends - 1)) {
- sends--;
- break;
- }
- }
-
- if (sends == 0) {
- isc_nm_send(handle, (isc_region_t *)&stop_msg,
- tcp_connect_shutdown, NULL);
- } else {
- isc_nm_send(handle, (isc_region_t *)&send_msg,
- tcp_connect_send_cb, NULL);
- }
-}
-
-static void
-tcp_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
-
- UNUSED(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* We failed to connect; try again */
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends,
- sends - 1)) {
- sends--;
- break;
- }
- }
- return;
- }
-
- atomic_fetch_add(&cconnects, 1);
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tcp_connect_read_cb, NULL);
-
- tcp_connect_send(handle);
-}
-
-static isc_result_t
-tcp_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg);
-
-static isc_threadresult_t
-tcp_connect_thread(isc_threadarg_t arg) {
- isc_nm_t *connect_nm = (isc_nm_t *)arg;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- while (atomic_load(&nsends) > 0) {
- (void)isc_nm_tcpconnect(connect_nm,
- (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- tcp_connect_connect_cb, NULL, 1000, 0);
- }
-
- return ((isc_threadresult_t)0);
-}
-
-static isc_quota_t *
-tcp_listener_init_quota(size_t nthreads) {
- isc_quota_t *quotap = NULL;
- if (atomic_load(&check_listener_quota)) {
- unsigned max_quota = ISC_MAX(nthreads / 2, 1);
- isc_quota_max(&listener_quota, max_quota);
- quotap = &listener_quota;
- }
- return quotap;
-}
-
-static void
-tcp_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_nmsocket_t *listen_sock = NULL;
- isc_thread_t threads[32] = { 0 };
- isc_quota_t *quotap = tcp_listener_init_quota(nthreads);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, quotap,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
- X(saccepts);
-
- /* assert_true(atomic_load(&csends) >= atomic_load(&sreads)); */
- assert_true(atomic_load(&sreads) >= atomic_load(&ssends));
- /* assert_true(atomic_load(&ssends) >= atomic_load(&creads)); */
- assert_true(atomic_load(&creads) <= atomic_load(&csends));
- assert_true(atomic_load(&creads) >= atomic_load(&ctimeouts));
-}
-
-static void
-tcp_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_nmsocket_t *listen_sock = NULL;
- isc_thread_t threads[32] = { 0 };
- isc_quota_t *quotap = tcp_listener_init_quota(nthreads);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, quotap,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
- X(saccepts);
-
- /* assert_true(atomic_load(&csends) >= atomic_load(&sreads)); */
- assert_true(atomic_load(&sreads) >= atomic_load(&ssends));
- /* assert_true(atomic_load(&ssends) >= atomic_load(&creads)); */
- assert_true(atomic_load(&creads) <= atomic_load(&csends));
- assert_true(atomic_load(&creads) >= atomic_load(&ctimeouts));
-}
-
-static void
-tcp_half_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_nmsocket_t *listen_sock = NULL;
- isc_thread_t threads[32] = { 0 };
- isc_quota_t *quotap = tcp_listener_init_quota(nthreads);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, quotap,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
- X(saccepts);
-
- /* assert_true(atomic_load(&csends) >= atomic_load(&sreads)); */
- assert_true(atomic_load(&sreads) >= atomic_load(&ssends));
- /* assert_true(atomic_load(&ssends) >= atomic_load(&creads)); */
- assert_true(atomic_load(&creads) <= atomic_load(&csends));
- assert_true(atomic_load(&creads) >= atomic_load(&ctimeouts));
-}
-
-static void
-tcp_half_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_nmsocket_t *listen_sock = NULL;
- isc_thread_t threads[32] = { 0 };
- isc_quota_t *quotap = tcp_listener_init_quota(nthreads);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, quotap,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
- X(saccepts);
-
- /* assert_true(atomic_load(&csends) >= atomic_load(&sreads)); */
- assert_true(atomic_load(&sreads) >= atomic_load(&ssends));
- /* assert_true(atomic_load(&ssends) >= atomic_load(&creads)); */
- assert_true(atomic_load(&creads) <= atomic_load(&csends));
- assert_true(atomic_load(&creads) >= atomic_load(&ctimeouts));
-}
-
-static void
-tcp_recv_send_quota(void **state) {
- atomic_store(&check_listener_quota, true);
- tcp_recv_send(state);
-}
-
-static void
-tcp_recv_half_send_quota(void **state) {
- atomic_store(&check_listener_quota, true);
- tcp_recv_half_send(state);
-}
-
-static void
-tcp_half_recv_send_quota(void **state) {
- atomic_store(&check_listener_quota, true);
- tcp_half_recv_send(state);
-}
-
-static void
-tcp_half_recv_half_send_quota(void **state) {
- atomic_store(&check_listener_quota, true);
- tcp_half_recv_half_send(state);
-}
-
-/* TCP Listener */
-
-/*
- * TODO:
- * 1. write a timeout test
- */
-
-static void
-tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg);
-
-static void
-tcp_listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- UNUSED(eresult);
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&ssends, 1);
- isc_nm_resumeread(handle);
- }
-}
-
-static void
-tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- atomic_fetch_add(&sreads, 1);
-
- memmove(tcp_buffer_storage + tcp_buffer_length, region->base,
- region->length);
- tcp_buffer_length += region->length;
-
- if (tcp_buffer_length >= sizeof(magic)) {
- isc_nm_pauseread(handle);
-
- memmove(&magic, tcp_buffer_storage, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- tcp_buffer_length -= sizeof(magic);
- memmove(tcp_buffer_storage, tcp_buffer_storage + sizeof(magic),
- tcp_buffer_length);
-
- if (magic == send_magic) {
- isc_nm_send(handle, region, tcp_listen_send_cb, NULL);
- return;
- } else if (magic == stop_magic) {
- /* We are done, so we don't send anything back */
- /* There should be no more packets in the buffer */
- assert_int_equal(tcp_buffer_length, 0);
- if (atomic_load(&check_listener_quota)) {
- int_fast32_t concurrent =
- isc__nm_tcp_listener_nactive(
- handle->sock->server->parent);
- assert_true(concurrent >= 0);
- assert_true((uint_fast32_t)concurrent <=
- isc_quota_getmax(&listener_quota));
- P(concurrent);
- }
- }
- }
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static isc_result_t
-tcp_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
-
- UNUSED(cbarg);
-
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- tcp_buffer_length = 0;
-
- atomic_fetch_add(&saccepts, 1);
-
- if (atomic_load(&check_listener_quota)) {
- int_fast32_t concurrent = isc__nm_tcp_listener_nactive(
- handle->sock->server->parent);
- assert_true(concurrent >= 0);
- assert_true((uint_fast32_t)concurrent <=
- isc_quota_getmax(&listener_quota));
- P(concurrent);
- }
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tcp_listen_read_cb, NULL);
-
- return (ISC_R_SUCCESS);
-}
-
-int
-main(void) {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(tcp_recv_send_quota, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_recv_half_send_quota,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_half_recv_send_quota,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_half_recv_half_send_quota,
- nm_setup, nm_teardown)
- };
-
- return (cmocka_run_group_tests(tests, _setup, _teardown));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
- printf("1..0 # Skipped: cmocka not available\n");
- return (SKIPPED_TEST_EXIT_CODE);
-}
-
-#endif /* if HAVE_CMOCKA */
diff --git a/external/mpl/bind/dist/lib/isc/tests/tcp_test.c b/external/mpl/bind/dist/lib/isc/tests/tcp_test.c
deleted file mode 100644
index 232bc9d7b9b..00000000000
--- a/external/mpl/bind/dist/lib/isc/tests/tcp_test.c
+++ /dev/null
@@ -1,1050 +0,0 @@
-/* $NetBSD: tcp_test.c,v 1.3 2021/04/29 17:26:13 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-#include <sched.h> /* IWYU pragma: keep */
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <uv.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/mutex.h>
-#include <isc/netmgr.h>
-#include <isc/nonce.h>
-#include <isc/os.h>
-#include <isc/refcount.h>
-#include <isc/sockaddr.h>
-#include <isc/thread.h>
-
-#include "uv_wrap.h"
-#define KEEP_BEFORE
-
-#include "../netmgr/netmgr-int.h"
-#include "../netmgr/tcp.c"
-#include "../netmgr/uv-compat.c"
-#include "../netmgr/uv-compat.h"
-#include "isctest.h"
-
-#define MAX_NM 2
-
-static isc_sockaddr_t tcp_listen_addr;
-
-static uint64_t send_magic = 0;
-static uint64_t stop_magic = 0;
-
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
- .len = sizeof(send_magic) };
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static atomic_uint_fast64_t nsends;
-
-static atomic_uint_fast64_t ssends;
-static atomic_uint_fast64_t sreads;
-
-static atomic_uint_fast64_t cconnects;
-static atomic_uint_fast64_t csends;
-static atomic_uint_fast64_t creads;
-static atomic_uint_fast64_t ctimeouts;
-
-static unsigned int workers = 3;
-
-static bool reuse_supported = true;
-
-#define NSENDS 100
-#define NWRITES 10
-
-#define CHECK_RANGE_FULL(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > NSENDS * NWRITES * 10 / 100); \
- assert_true(__v <= NSENDS * NWRITES * 110 / 100); \
- }
-
-#define CHECK_RANGE_HALF(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > NSENDS * NWRITES * 5 / 100); \
- assert_true(__v <= NSENDS * NWRITES * 110 / 100); \
- }
-
-/* Enable this to print values while running tests */
-#undef PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v))
-#else
-#define X(v)
-#endif
-
-static int
-setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
- isc_result_t result;
- socklen_t addrlen = sizeof(*addr);
- int fd;
- int r;
-
- isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
-
- fd = socket(AF_INET6, family, 0);
- if (fd < 0) {
- perror("setup_ephemeral_port: socket()");
- return (-1);
- }
-
- r = bind(fd, (const struct sockaddr *)&addr->type.sa,
- sizeof(addr->type.sin6));
- if (r != 0) {
- perror("setup_ephemeral_port: bind()");
- close(fd);
- return (r);
- }
-
- r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
- if (r != 0) {
- perror("setup_ephemeral_port: getsockname()");
- close(fd);
- return (r);
- }
-
- result = isc__nm_socket_reuse(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
- result = isc__nm_socket_reuse_lb(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
- if (result == ISC_R_NOTIMPLEMENTED) {
- reuse_supported = false;
- }
-
-#if IPV6_RECVERR
-#define setsockopt_on(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
-
- r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
- if (r != 0) {
- perror("setup_ephemeral_port");
- close(fd);
- return (r);
- }
-#endif
-
- return (fd);
-}
-
-static int
-_setup(void **state) {
- UNUSED(state);
-
- /* workers = isc_os_ncpus(); */
-
- if (isc_test_begin(NULL, true, workers) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- signal(SIGPIPE, SIG_IGN);
-
- return (0);
-}
-
-static int
-_teardown(void **state) {
- UNUSED(state);
-
- isc_test_end();
-
- return (0);
-}
-
-/* Generic */
-
-static unsigned int
-noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-
- return (0);
-}
-
-static void
-noop_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-}
-
-ISC_THREAD_LOCAL uint8_t tcp_buffer_storage[4096];
-ISC_THREAD_LOCAL size_t tcp_buffer_length = 0;
-
-static int
-nm_setup(void **state) {
- size_t nworkers = ISC_MAX(ISC_MIN(workers, 32), 1);
- int tcp_listen_sock = -1;
- isc_nm_t **nm = NULL;
-
- tcp_listen_addr = (isc_sockaddr_t){ .length = 0 };
- tcp_listen_sock = setup_ephemeral_port(&tcp_listen_addr, SOCK_STREAM);
- if (tcp_listen_sock < 0) {
- return (-1);
- }
- close(tcp_listen_sock);
- tcp_listen_sock = -1;
- /* silence scan-build */
- UNUSED(tcp_listen_sock);
-
- atomic_store(&nsends, NSENDS * NWRITES);
-
- atomic_store(&csends, 0);
- atomic_store(&creads, 0);
- atomic_store(&sreads, 0);
- atomic_store(&ssends, 0);
- atomic_store(&ctimeouts, 0);
- atomic_store(&cconnects, 0);
-
- isc_nonce_buf(&send_magic, sizeof(send_magic));
- isc_nonce_buf(&stop_magic, sizeof(stop_magic));
- if (send_magic == stop_magic) {
- return (-1);
- }
-
- nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
- for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
- assert_non_null(nm[i]);
- }
-
- *state = nm;
-
- return (0);
-}
-
-static int
-nm_teardown(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
-
- for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
- assert_null(nm[i]);
- }
- isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
-
- return (0);
-}
-
-/* TCP Connect */
-
-static void
-tcp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg);
-
-static void
-tcp_connect_send(isc_nmhandle_t *handle);
-
-static void
-tcp_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- memmove(tcp_buffer_storage + tcp_buffer_length, region->base,
- region->length);
- tcp_buffer_length += region->length;
-
- while (tcp_buffer_length >= sizeof(magic)) {
- atomic_fetch_add(&creads, 1);
-
- memmove(&magic, tcp_buffer_storage, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- tcp_buffer_length -= sizeof(magic);
- memmove(tcp_buffer_storage, tcp_buffer_storage + sizeof(magic),
- tcp_buffer_length);
-
- if (magic == send_magic) {
- tcp_connect_send(handle);
- return;
- } else if (magic == stop_magic) {
- /* We are done, so we don't send anything back */
- /* There should be no more packets in the buffer */
- assert_int_equal(tcp_buffer_length, 0);
- }
- }
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static void
-tcp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- assert_non_null(handle);
- UNUSED(cbarg);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- isc_nm_resumeread(handle);
- } else {
- /* Send failed, we need to stop reading too */
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcp_connect_shutdown(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- } else {
- /* Send failed, we need to stop reading too */
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcp_connect_send(isc_nmhandle_t *handle) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends, sends - 1)) {
- sends--;
- break;
- }
- }
-
- if (sends == 0) {
- isc_nm_send(handle, (isc_region_t *)&stop_msg,
- tcp_connect_shutdown, NULL);
- } else {
- isc_nm_send(handle, (isc_region_t *)&send_msg,
- tcp_connect_send_cb, NULL);
- }
-}
-
-static void
-tcp_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
-
- UNUSED(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* We failed to connect; try again */
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends,
- sends - 1)) {
- sends--;
- break;
- }
- }
- return;
- }
-
- atomic_fetch_add(&cconnects, 1);
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tcp_connect_read_cb, NULL);
-
- tcp_connect_send(handle);
-}
-
-static void
-mock_listentcp_uv_tcp_bind(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_tcp_bind, UV_EADDRINUSE);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_listentcp_uv_fileno(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_fileno, UV_EADDRINUSE);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_listentcp_uv_tcp_getsockname(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_tcp_getsockname, UV_EADDRINUSE);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_listentcp_uv_listen(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_listen, UV_EADDRINUSE);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_tcpconnect_uv_tcp_bind(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_tcp_bind, UV_ENOMEM);
-
- result = isc_nm_tcpconnect(connect_nm,
- (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_not_equal(result, ISC_R_SUCCESS);
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-static void
-mock_tcpconnect_uv_tcp_connect(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_tcp_connect, UV_ENOMEM);
-
- result = isc_nm_tcpconnect(
- connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr, noop_connect_cb, NULL, 1, 0);
- assert_int_not_equal(result, ISC_R_SUCCESS);
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-static void
-tcp_noop(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- (void)isc_nm_tcpconnect(connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- noop_connect_cb, NULL, 1, 0);
-
- isc_nm_closedown(connect_nm);
-
- assert_int_equal(0, atomic_load(&cconnects));
- assert_int_equal(0, atomic_load(&csends));
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-tcp_noresponse(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- noop_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tcpconnect(connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- tcp_connect_connect_cb, NULL, 1, 0);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-}
-
-static isc_result_t
-tcp_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg);
-
-static isc_threadresult_t
-tcp_connect_thread(isc_threadarg_t arg) {
- isc_nm_t *connect_nm = (isc_nm_t *)arg;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- while (atomic_load(&nsends) > 0) {
- (void)isc_nm_tcpconnect(connect_nm,
- (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- tcp_connect_connect_cb, NULL, 1, 0);
- }
-
- return ((isc_threadresult_t)0);
-}
-
-static void
-tcp_recv_one(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 1);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tcpconnect(connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- tcp_connect_connect_cb, NULL, 1000, 0);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&cconnects) != 1 || atomic_load(&ssends) != 0 ||
- atomic_load(&sreads) != 1 || atomic_load(&creads) != 0 ||
- atomic_load(&csends) != 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 1);
- assert_int_equal(atomic_load(&csends), 1);
- assert_int_equal(atomic_load(&creads), 0);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_int_equal(atomic_load(&sreads), 1);
- assert_int_equal(atomic_load(&ssends), 0);
-}
-
-static void
-tcp_recv_two(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcp_connect_addr;
-
- tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 2);
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- result = isc_nm_tcpconnect(connect_nm,
- (isc_nmiface_t *)&tcp_connect_addr,
- (isc_nmiface_t *)&tcp_listen_addr,
- tcp_connect_connect_cb, NULL, 1000, 0);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&sreads) < 2 || atomic_load(&ssends) < 1 ||
- atomic_load(&csends) < 2 || atomic_load(&creads) < 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 1);
- assert_true(atomic_load(&csends) >= 2);
- assert_int_equal(atomic_load(&creads), 1);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_true(atomic_load(&sreads) >= 2);
- assert_int_equal(atomic_load(&ssends), 1);
-}
-
-static void
-tcp_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_FULL(creads);
- CHECK_RANGE_FULL(sreads);
- CHECK_RANGE_FULL(ssends);
-}
-
-static void
-tcp_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tcp_half_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tcp_half_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcp(listen_nm, (isc_nmiface_t *)&tcp_listen_addr,
- tcp_listen_accept_cb, NULL, 0, 0, NULL,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-/* TCP Listener */
-
-/*
- * TODO:
- * 1. write a timeout test
- * 2. write a test with quota
- */
-
-static void
-tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg);
-
-static void
-tcp_listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- UNUSED(eresult);
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&ssends, 1);
- isc_nm_resumeread(handle);
- } else {
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- atomic_fetch_add(&sreads, 1);
-
- memmove(tcp_buffer_storage + tcp_buffer_length, region->base,
- region->length);
- tcp_buffer_length += region->length;
-
- while (tcp_buffer_length >= sizeof(magic)) {
- memmove(&magic, tcp_buffer_storage, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- tcp_buffer_length -= sizeof(magic);
- memmove(tcp_buffer_storage, tcp_buffer_storage + sizeof(magic),
- tcp_buffer_length);
-
- if (magic == send_magic) {
- isc_nm_send(handle, region, tcp_listen_send_cb, NULL);
- return;
- } else if (magic == stop_magic) {
- /* We are done, so we don't send anything back */
- /* There should be no more packets in the buffer */
- assert_int_equal(tcp_buffer_length, 0);
- }
- }
-
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static isc_result_t
-tcp_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
-
- UNUSED(cbarg);
-
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- tcp_buffer_length = 0;
-
- /* atomic_fetch_add(&saccept, 1); */
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tcp_listen_read_cb, NULL);
-
- return (ISC_R_SUCCESS);
-}
-
-int
-main(void) {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(mock_listentcp_uv_tcp_bind,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(mock_listentcp_uv_fileno,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(
- mock_listentcp_uv_tcp_getsockname, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(mock_listentcp_uv_listen,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(mock_tcpconnect_uv_tcp_bind,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(mock_tcpconnect_uv_tcp_connect,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_noop, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_noresponse, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_recv_one, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_recv_two, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_recv_half_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_half_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcp_half_recv_half_send,
- nm_setup, nm_teardown),
- };
-
- return (cmocka_run_group_tests(tests, _setup, _teardown));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
- printf("1..0 # Skipped: cmocka not available\n");
- return (SKIPPED_TEST_EXIT_CODE);
-}
-
-#endif /* if HAVE_CMOCKA */
diff --git a/external/mpl/bind/dist/lib/isc/tests/tcpdns_test.c b/external/mpl/bind/dist/lib/isc/tests/tcpdns_test.c
deleted file mode 100644
index 6e563947f27..00000000000
--- a/external/mpl/bind/dist/lib/isc/tests/tcpdns_test.c
+++ /dev/null
@@ -1,877 +0,0 @@
-/* $NetBSD: tcpdns_test.c,v 1.3 2021/04/29 17:26:13 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-#include <sched.h> /* IWYU pragma: keep */
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <uv.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/mutex.h>
-#include <isc/netmgr.h>
-#include <isc/nonce.h>
-#include <isc/os.h>
-#include <isc/refcount.h>
-#include <isc/sockaddr.h>
-#include <isc/thread.h>
-
-#include "../netmgr/netmgr-int.h"
-#include "isctest.h"
-
-#define MAX_NM 2
-
-static isc_sockaddr_t tcpdns_listen_addr;
-
-static uint64_t send_magic = 0;
-static uint64_t stop_magic = 0;
-
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
- .len = sizeof(send_magic) };
-
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static atomic_uint_fast64_t nsends;
-
-static atomic_uint_fast64_t ssends;
-static atomic_uint_fast64_t sreads;
-
-static atomic_uint_fast64_t cconnects;
-static atomic_uint_fast64_t csends;
-static atomic_uint_fast64_t creads;
-static atomic_uint_fast64_t ctimeouts;
-
-static unsigned int workers = 3;
-
-static bool reuse_supported = true;
-
-#define NSENDS 100
-#define NWRITES 10
-
-#define CHECK_RANGE_FULL(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > NSENDS * NWRITES * 10 / 100); \
- assert_true(__v <= NSENDS * NWRITES * 110 / 100); \
- }
-
-#define CHECK_RANGE_HALF(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > NSENDS * NWRITES * 5 / 100); \
- assert_true(__v <= NSENDS * NWRITES * 60 / 100); \
- }
-
-/* Enable this to print values while running tests */
-#undef PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v))
-#else
-#define X(v)
-#endif
-
-static int
-setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
- isc_result_t result;
- socklen_t addrlen = sizeof(*addr);
- int fd;
- int r;
-
- isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
-
- fd = socket(AF_INET6, family, 0);
- if (fd < 0) {
- perror("setup_ephemeral_port: socket()");
- return (-1);
- }
-
- r = bind(fd, (const struct sockaddr *)&addr->type.sa,
- sizeof(addr->type.sin6));
- if (r != 0) {
- perror("setup_ephemeral_port: bind()");
- close(fd);
- return (r);
- }
-
- r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
- if (r != 0) {
- perror("setup_ephemeral_port: getsockname()");
- close(fd);
- return (r);
- }
-
- result = isc__nm_socket_reuse(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
- result = isc__nm_socket_reuse_lb(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
- if (result == ISC_R_NOTIMPLEMENTED) {
- reuse_supported = false;
- }
-
-#if IPV6_RECVERR
-#define setsockopt_on(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
-
- r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
- if (r != 0) {
- perror("setup_ephemeral_port");
- close(fd);
- return (r);
- }
-#endif
-
- return (fd);
-}
-
-static int
-_setup(void **state) {
- UNUSED(state);
-
- /* workers = isc_os_ncpus(); */
-
- if (isc_test_begin(NULL, true, workers) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- signal(SIGPIPE, SIG_IGN);
-
- return (0);
-}
-
-static int
-_teardown(void **state) {
- UNUSED(state);
-
- isc_test_end();
-
- return (0);
-}
-
-/* Generic */
-
-static void
-noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
- void *cbarg) {
- UNUSED(handle);
- UNUSED(eresult);
- UNUSED(region);
- UNUSED(cbarg);
-}
-
-static unsigned int
-noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-
- return (0);
-}
-
-static void
-noop_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-}
-
-static int
-nm_setup(void **state) {
- size_t nworkers = ISC_MAX(ISC_MIN(workers, 32), 1);
- int tcpdns_listen_sock = -1;
- isc_nm_t **nm = NULL;
-
- tcpdns_listen_addr = (isc_sockaddr_t){ .length = 0 };
- tcpdns_listen_sock = setup_ephemeral_port(&tcpdns_listen_addr,
- SOCK_STREAM);
- if (tcpdns_listen_sock < 0) {
- return (-1);
- }
- close(tcpdns_listen_sock);
- tcpdns_listen_sock = -1;
- /* silence scan-build */
- UNUSED(tcpdns_listen_sock);
-
- atomic_store(&nsends, NSENDS * NWRITES);
-
- atomic_store(&csends, 0);
- atomic_store(&creads, 0);
- atomic_store(&sreads, 0);
- atomic_store(&ssends, 0);
- atomic_store(&ctimeouts, 0);
- atomic_store(&cconnects, 0);
-
- isc_nonce_buf(&send_magic, sizeof(send_magic));
- isc_nonce_buf(&stop_magic, sizeof(stop_magic));
- if (send_magic == stop_magic) {
- return (-1);
- }
-
- nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
- for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
- assert_non_null(nm[i]);
- }
-
- *state = nm;
-
- return (0);
-}
-
-static int
-nm_teardown(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
-
- for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
- assert_null(nm[i]);
- }
- isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
-
- return (0);
-}
-
-/* TCPDNS */
-
-static void
-tcpdns_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg);
-
-static void
-tcpdns_connect_send(isc_nmhandle_t *handle);
-
-static void
-tcpdns_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- assert_non_null(handle);
-
- UNUSED(cbarg);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- } else {
- /* Send failed, we need to stop reading too */
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tcpdns_connect_send(isc_nmhandle_t *handle) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* Continue until we subtract or we are sent them all */
- while (sends > 0) {
- if (atomic_compare_exchange_weak(&nsends, &sends, sends - 1)) {
- sends--;
- break;
- }
- }
-
- if (sends == 0) {
- isc_nm_send(handle, (isc_region_t *)&stop_msg,
- tcpdns_connect_send_cb, NULL);
- } else {
- isc_nm_send(handle, (isc_region_t *)&send_msg,
- tcpdns_connect_send_cb, NULL);
- }
-}
-
-static void
-tcpdns_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- assert_int_equal(region->length, sizeof(magic));
-
- atomic_fetch_add(&creads, 1);
-
- memmove(&magic, region->base, sizeof(magic));
-
- assert_true(magic == stop_magic || magic == send_magic);
-
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static void
-tcpdns_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
- UNUSED(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* We failed to connect; try again */
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends,
- sends - 1)) {
- sends--;
- break;
- }
- }
- return;
- }
-
- atomic_fetch_add(&cconnects, 1);
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tcpdns_connect_read_cb, NULL);
-
- tcpdns_connect_send(handle);
-}
-
-static void
-tcpdns_noop(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcpdns_connect_addr;
-
- tcpdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcpdns_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr, noop_recv_cb,
- NULL, noop_accept_cb, NULL, 0, 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- (void)isc_nm_tcpdnsconnect(connect_nm,
- (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- isc_nm_closedown(connect_nm);
-
- assert_int_equal(0, atomic_load(&cconnects));
- assert_int_equal(0, atomic_load(&csends));
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-tcpdns_noresponse(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcpdns_connect_addr;
-
- tcpdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcpdns_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr, noop_recv_cb,
- NULL, noop_accept_cb, NULL, 0, 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tcpdnsconnect(connect_nm,
- (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_connect_connect_cb, NULL, 1000, 0);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) <= 1);
- assert_true(atomic_load(&csends) <= 1);
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-tcpdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg);
-
-static void
-tcpdns_listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(cbarg);
- UNUSED(eresult);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- return;
- }
-
- atomic_fetch_add(&ssends, 1);
-}
-
-static void
-tcpdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- return;
- }
-
- atomic_fetch_add(&sreads, 1);
-
- assert_int_equal(region->length, sizeof(magic));
-
- memmove(&magic, region->base, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- if (magic == send_magic) {
- isc_nm_send(handle, region, tcpdns_listen_send_cb, NULL);
- return;
- } else if (magic == stop_magic) {
- /* We are done, we don't send anything back */
- }
-}
-
-static isc_result_t
-tcpdns_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(handle);
- UNUSED(cbarg);
-
- return (eresult);
-}
-
-static isc_threadresult_t
-tcpdns_connect_thread(isc_threadarg_t arg) {
- isc_nm_t *connect_nm = (isc_nm_t *)arg;
- isc_sockaddr_t tcpdns_connect_addr;
-
- tcpdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcpdns_connect_addr, &in6addr_loopback, 0);
-
- while (atomic_load(&nsends) > 0) {
- (void)isc_nm_tcpdnsconnect(
- connect_nm, (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_connect_connect_cb, NULL, 1000, 0);
- }
-
- return ((isc_threadresult_t)0);
-}
-
-static void
-tcpdns_recv_one(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcpdns_connect_addr;
-
- tcpdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcpdns_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 1);
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tcpdnsconnect(connect_nm,
- (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_connect_connect_cb, NULL, 1000, 0);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&cconnects) != 1 || atomic_load(&ssends) != 0 ||
- atomic_load(&sreads) != 1 || atomic_load(&creads) != 0 ||
- atomic_load(&csends) != 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 1);
- assert_int_equal(atomic_load(&csends), 1);
- assert_int_equal(atomic_load(&creads), 0);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_int_equal(atomic_load(&sreads), 1);
- assert_int_equal(atomic_load(&ssends), 0);
-}
-
-static void
-tcpdns_recv_two(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tcpdns_connect_addr;
-
- tcpdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tcpdns_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 2);
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- result = isc_nm_tcpdnsconnect(connect_nm,
- (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_connect_connect_cb, NULL, 1000, 0);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_settimeouts(connect_nm, 1000, 1000, 1000, 1000);
-
- result = isc_nm_tcpdnsconnect(connect_nm,
- (isc_nmiface_t *)&tcpdns_connect_addr,
- (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_connect_connect_cb, NULL, 1000, 0);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&sreads) != 2 || atomic_load(&ssends) != 1 ||
- atomic_load(&csends) != 2 || atomic_load(&creads) != 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 2);
- assert_int_equal(atomic_load(&csends), 2);
- assert_int_equal(atomic_load(&creads), 1);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_int_equal(atomic_load(&sreads), 2);
- assert_int_equal(atomic_load(&ssends), 1);
-}
-
-static void
-tcpdns_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcpdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_FULL(creads);
- CHECK_RANGE_FULL(sreads);
- CHECK_RANGE_FULL(ssends);
-}
-
-static void
-tcpdns_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcpdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tcpdns_half_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcpdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tcpdns_half_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentcpdns(
- listen_nm, (isc_nmiface_t *)&tcpdns_listen_addr,
- tcpdns_listen_read_cb, NULL, tcpdns_listen_accept_cb, NULL, 0,
- 0, NULL, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tcpdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-int
-main(void) {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(tcpdns_recv_one, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_recv_two, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_noop, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_noresponse, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_recv_half_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_half_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tcpdns_half_recv_half_send,
- nm_setup, nm_teardown),
- };
-
- return (cmocka_run_group_tests(tests, _setup, _teardown));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
- printf("1..0 # Skipped: cmocka not available\n");
- return (SKIPPED_TEST_EXIT_CODE);
-}
-
-#endif /* if HAVE_CMOCKA */
diff --git a/external/mpl/bind/dist/lib/isc/tests/timer_test.c b/external/mpl/bind/dist/lib/isc/tests/timer_test.c
index f14ebb2faf7..9da7148c106 100644
--- a/external/mpl/bind/dist/lib/isc/tests/timer_test.c
+++ b/external/mpl/bind/dist/lib/isc/tests/timer_test.c
@@ -1,4 +1,4 @@
-/* $NetBSD: timer_test.c,v 1.7 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: timer_test.c,v 1.8 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -116,6 +116,8 @@ setup_test(isc_timertype_t timertype, isc_time_t *expires,
isc_condition_init(&cv);
+ atomic_store(&errcnt, ISC_R_SUCCESS);
+
LOCK(&mx);
result = isc_task_create(taskmgr, 0, &task);
@@ -157,25 +159,38 @@ set_global_error(isc_result_t result) {
}
static void
-subthread_assert_true(bool expected) {
+subthread_assert_true(bool expected, const char *file, unsigned int line) {
if (!expected) {
+ printf("# %s:%u subthread_assert_true\n", file, line);
set_global_error(ISC_R_UNEXPECTED);
}
}
+#define subthread_assert_true(expected) \
+ subthread_assert_true(expected, __FILE__, __LINE__)
static void
-subthread_assert_int_equal(int observed, int expected) {
+subthread_assert_int_equal(int observed, int expected, const char *file,
+ unsigned int line) {
if (observed != expected) {
+ printf("# %s:%u subthread_assert_int_equal(%d != %d)\n", file,
+ line, observed, expected);
set_global_error(ISC_R_UNEXPECTED);
}
}
+#define subthread_assert_int_equal(observed, expected) \
+ subthread_assert_int_equal(observed, expected, __FILE__, __LINE__)
static void
-subthread_assert_result_equal(isc_result_t result, isc_result_t expected) {
+subthread_assert_result_equal(isc_result_t result, isc_result_t expected,
+ const char *file, unsigned int line) {
if (result != expected) {
+ printf("# %s:%u subthread_assert_result_equal(%u != %u)\n",
+ file, line, result, expected);
set_global_error(result);
}
}
+#define subthread_assert_result_equal(observed, expected) \
+ subthread_assert_result_equal(observed, expected, __FILE__, __LINE__)
static void
ticktock(isc_task_t *task, isc_event_t *event) {
@@ -437,8 +452,8 @@ reset(void **state) {
setup_test(isc_timertype_ticker, &expires, &interval, test_reset);
}
-static int startflag;
-static int shutdownflag;
+static atomic_bool startflag;
+static atomic_bool shutdownflag;
static isc_timer_t *tickertimer = NULL;
static isc_timer_t *oncetimer = NULL;
static isc_task_t *task1 = NULL;
@@ -450,23 +465,6 @@ static isc_task_t *task2 = NULL;
*/
static void
-start_event(isc_task_t *task, isc_event_t *event) {
- UNUSED(task);
-
- if (verbose) {
- print_message("# start_event\n");
- }
-
- LOCK(&mx);
- while (!startflag) {
- (void)isc_condition_wait(&cv, &mx);
- }
- UNLOCK(&mx);
-
- isc_event_free(&event);
-}
-
-static void
tick_event(isc_task_t *task, isc_event_t *event) {
isc_result_t result;
isc_time_t expires;
@@ -474,6 +472,14 @@ tick_event(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
+ if (!atomic_load(&startflag)) {
+ if (verbose) {
+ print_message("# tick_event %d\n", -1);
+ }
+ isc_event_free(&event);
+ return;
+ }
+
int tick = atomic_fetch_add(&eventcnt, 1);
if (verbose) {
print_message("# tick_event %d\n", tick);
@@ -498,8 +504,6 @@ tick_event(isc_task_t *task, isc_event_t *event) {
static void
once_event(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
-
if (verbose) {
print_message("# once_event\n");
}
@@ -507,12 +511,7 @@ once_event(isc_task_t *task, isc_event_t *event) {
/*
* Allow task1 to start processing events.
*/
- LOCK(&mx);
- startflag = 1;
-
- result = isc_condition_broadcast(&cv);
- subthread_assert_result_equal(result, ISC_R_SUCCESS);
- UNLOCK(&mx);
+ atomic_store(&startflag, true);
isc_event_free(&event);
isc_task_shutdown(task);
@@ -520,8 +519,6 @@ once_event(isc_task_t *task, isc_event_t *event) {
static void
shutdown_purge(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
-
UNUSED(task);
UNUSED(event);
@@ -532,12 +529,7 @@ shutdown_purge(isc_task_t *task, isc_event_t *event) {
/*
* Signal shutdown processing complete.
*/
- LOCK(&mx);
- shutdownflag = 1;
-
- result = isc_condition_signal(&cv);
- subthread_assert_result_equal(result, ISC_R_SUCCESS);
- UNLOCK(&mx);
+ atomic_store(&shutdownflag, 1);
isc_event_free(&event);
}
@@ -546,22 +538,17 @@ shutdown_purge(isc_task_t *task, isc_event_t *event) {
static void
purge(void **state) {
isc_result_t result;
- isc_event_t *event = NULL;
isc_time_t expires;
isc_interval_t interval;
UNUSED(state);
- startflag = 0;
- shutdownflag = 0;
+ atomic_init(&startflag, 0);
+ atomic_init(&shutdownflag, 0);
atomic_init(&eventcnt, 0);
seconds = 1;
nanoseconds = 0;
- isc_mutex_init(&mx);
-
- isc_condition_init(&cv);
-
result = isc_task_create(taskmgr, 0, &task1);
assert_int_equal(result, ISC_R_SUCCESS);
@@ -571,13 +558,6 @@ purge(void **state) {
result = isc_task_create(taskmgr, 0, &task2);
assert_int_equal(result, ISC_R_SUCCESS);
- LOCK(&mx);
-
- event = isc_event_allocate(test_mctx, (void *)1, (isc_eventtype_t)1,
- start_event, NULL, sizeof(*event));
- assert_non_null(event);
- isc_task_send(task1, &event);
-
isc_time_settoepoch(&expires);
isc_interval_set(&interval, seconds, 0);
@@ -602,13 +582,10 @@ purge(void **state) {
/*
* Wait for shutdown processing to complete.
*/
- while (!shutdownflag) {
- result = isc_condition_wait(&cv, &mx);
- assert_int_equal(result, ISC_R_SUCCESS);
+ while (!atomic_load(&shutdownflag)) {
+ isc_test_nap(1000);
}
- UNLOCK(&mx);
-
assert_int_equal(atomic_load(&errcnt), ISC_R_SUCCESS);
assert_int_equal(atomic_load(&eventcnt), 1);
@@ -617,7 +594,6 @@ purge(void **state) {
isc_timer_detach(&oncetimer);
isc_task_destroy(&task1);
isc_task_destroy(&task2);
- isc_mutex_destroy(&mx);
}
int
diff --git a/external/mpl/bind/dist/lib/isc/tests/tlsdns_test.c b/external/mpl/bind/dist/lib/isc/tests/tlsdns_test.c
deleted file mode 100644
index 5ce44b33d29..00000000000
--- a/external/mpl/bind/dist/lib/isc/tests/tlsdns_test.c
+++ /dev/null
@@ -1,899 +0,0 @@
-/* $NetBSD: tlsdns_test.c,v 1.1.1.1 2021/04/29 16:46:33 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-#include <sched.h> /* IWYU pragma: keep */
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <uv.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/mutex.h>
-#include <isc/netmgr.h>
-#include <isc/nonce.h>
-#include <isc/os.h>
-#include <isc/refcount.h>
-#include <isc/sockaddr.h>
-#include <isc/thread.h>
-
-#include "../netmgr/netmgr-int.h"
-#include "isctest.h"
-
-#define MAX_NM 2
-
-static isc_sockaddr_t tlsdns_listen_addr;
-static isc_tlsctx_t *tlsdns_listen_ctx = NULL;
-static isc_tlsctx_t *tlsdns_connect_ctx = NULL;
-
-static uint64_t send_magic = 0;
-static uint64_t stop_magic = 0;
-
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
- .len = sizeof(send_magic) };
-
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static atomic_uint_fast64_t nsends;
-
-static atomic_uint_fast64_t ssends;
-static atomic_uint_fast64_t sreads;
-
-static atomic_uint_fast64_t cconnects;
-static atomic_uint_fast64_t csends;
-static atomic_uint_fast64_t creads;
-static atomic_uint_fast64_t ctimeouts;
-
-static unsigned int workers = 1;
-
-static bool reuse_supported = true;
-
-#define NSENDS 100
-#define NWRITES 10
-
-#define CHECK_RANGE_FULL(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > 1); \
- assert_true(__v <= NSENDS * NWRITES * 110 / 100); \
- }
-
-#define CHECK_RANGE_HALF(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(__v > 1); \
- assert_true(__v <= NSENDS * NWRITES * 60 / 100); \
- }
-
-/* Enable this to print values while running tests */
-#undef PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v))
-#else
-#define X(v)
-#endif
-
-static int
-setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
- isc_result_t result;
- socklen_t addrlen = sizeof(*addr);
- int fd;
- int r;
-
- isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
-
- fd = socket(AF_INET6, family, 0);
- if (fd < 0) {
- perror("setup_ephemeral_port: socket()");
- return (-1);
- }
-
- r = bind(fd, (const struct sockaddr *)&addr->type.sa,
- sizeof(addr->type.sin6));
- if (r != 0) {
- perror("setup_ephemeral_port: bind()");
- close(fd);
- return (r);
- }
-
- r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
- if (r != 0) {
- perror("setup_ephemeral_port: getsockname()");
- close(fd);
- return (r);
- }
-
- result = isc__nm_socket_reuse(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
- result = isc__nm_socket_reuse_lb(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
- if (result == ISC_R_NOTIMPLEMENTED) {
- reuse_supported = false;
- }
-
-#if IPV6_RECVERR
-#define setsockopt_on(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
-
- r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
- if (r != 0) {
- perror("setup_ephemeral_port");
- close(fd);
- return (r);
- }
-#endif
-
- return (fd);
-}
-
-static int
-_setup(void **state) {
- UNUSED(state);
-
- /* workers = isc_os_ncpus(); */
-
- if (isc_test_begin(NULL, true, workers) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- signal(SIGPIPE, SIG_IGN);
-
- return (0);
-}
-
-static int
-_teardown(void **state) {
- UNUSED(state);
-
- isc_test_end();
-
- return (0);
-}
-
-/* Generic */
-
-static void
-noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
- void *cbarg) {
- UNUSED(handle);
- UNUSED(eresult);
- UNUSED(region);
- UNUSED(cbarg);
-}
-
-static unsigned int
-noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-
- return (0);
-}
-
-static void
-noop_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-}
-
-static int
-nm_setup(void **state) {
- size_t nworkers = ISC_MAX(ISC_MIN(workers, 32), 1);
- int tlsdns_listen_sock = -1;
- isc_nm_t **nm = NULL;
-
- if (isc_tlsctx_createserver(NULL, NULL, &tlsdns_listen_ctx) !=
- ISC_R_SUCCESS) {
- return (-1);
- }
- if (isc_tlsctx_createclient(&tlsdns_connect_ctx) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- tlsdns_listen_addr = (isc_sockaddr_t){ .length = 0 };
- tlsdns_listen_sock = setup_ephemeral_port(&tlsdns_listen_addr,
- SOCK_STREAM);
- if (tlsdns_listen_sock < 0) {
- return (-1);
- }
- close(tlsdns_listen_sock);
-
- atomic_store(&nsends, NSENDS * NWRITES);
-
- atomic_store(&csends, 0);
- atomic_store(&creads, 0);
- atomic_store(&sreads, 0);
- atomic_store(&ssends, 0);
- atomic_store(&ctimeouts, 0);
- atomic_store(&cconnects, 0);
-
- isc_nonce_buf(&send_magic, sizeof(send_magic));
- isc_nonce_buf(&stop_magic, sizeof(stop_magic));
- if (send_magic == stop_magic) {
- return (-1);
- }
-
- nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
- for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
- assert_non_null(nm[i]);
- }
-
- *state = nm;
-
- return (0);
-}
-
-static int
-nm_teardown(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
-
- for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
- assert_null(nm[i]);
- }
- isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
-
- isc_tlsctx_free(&tlsdns_connect_ctx);
- isc_tlsctx_free(&tlsdns_listen_ctx);
-
- return (0);
-}
-
-/* TLSDNS */
-
-static void
-tlsdns_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg);
-
-static void
-tlsdns_connect_send(isc_nmhandle_t *handle);
-
-static void
-tlsdns_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- assert_non_null(handle);
-
- UNUSED(cbarg);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&csends, 1);
- } else {
- /* Send failed, we need to stop reading too */
- isc_nm_cancelread(handle);
- }
-}
-
-static void
-tlsdns_connect_send(isc_nmhandle_t *handle) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* Continue until we subtract or we are sent them all */
- while (sends > 0) {
- if (atomic_compare_exchange_weak(&nsends, &sends, sends - 1)) {
- sends--;
- break;
- }
- }
-
- if (sends == 0) {
- isc_nm_send(handle, (isc_region_t *)&stop_msg,
- tlsdns_connect_send_cb, NULL);
- } else {
- isc_nm_send(handle, (isc_region_t *)&send_msg,
- tlsdns_connect_send_cb, NULL);
- }
-}
-
-static void
-tlsdns_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- assert_int_equal(region->length, sizeof(magic));
-
- atomic_fetch_add(&creads, 1);
-
- memmove(&magic, region->base, sizeof(magic));
-
- assert_true(magic == stop_magic || magic == send_magic);
-
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static void
-tlsdns_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
- UNUSED(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* We failed to connect; try again */
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends,
- sends - 1)) {
- sends--;
- break;
- }
- }
- return;
- }
-
- atomic_fetch_add(&cconnects, 1);
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, tlsdns_connect_read_cb, NULL);
-
- tlsdns_connect_send(handle);
-}
-
-static void
-tlsdns_noop(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tlsdns_connect_addr;
-
- tlsdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tlsdns_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr, noop_recv_cb,
- NULL, noop_accept_cb, NULL, 0, 0, NULL, tlsdns_listen_ctx,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- (void)isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr, noop_connect_cb, NULL,
- 1000, 0, tlsdns_connect_ctx);
- isc_nm_closedown(connect_nm);
-
- assert_int_equal(0, atomic_load(&cconnects));
- assert_int_equal(0, atomic_load(&csends));
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-tlsdns_noresponse(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tlsdns_connect_addr;
-
- tlsdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tlsdns_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr, noop_recv_cb,
- NULL, noop_accept_cb, NULL, 0, 0, NULL, tlsdns_listen_ctx,
- &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr, tlsdns_connect_connect_cb,
- NULL, 1000, 0, tlsdns_connect_ctx);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) <= 1);
- assert_true(atomic_load(&csends) <= 1);
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-tlsdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg);
-
-static void
-tlsdns_listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(cbarg);
- UNUSED(eresult);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- return;
- }
-
- atomic_fetch_add(&ssends, 1);
-}
-
-static void
-tlsdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- return;
- }
-
- atomic_fetch_add(&sreads, 1);
-
- assert_int_equal(region->length, sizeof(magic));
-
- memmove(&magic, region->base, sizeof(magic));
- assert_true(magic == stop_magic || magic == send_magic);
-
- if (magic == send_magic) {
- isc_nm_send(handle, region, tlsdns_listen_send_cb, NULL);
- return;
- } else if (magic == stop_magic) {
- /* We are done, we don't send anything back */
- }
-}
-
-static isc_result_t
-tlsdns_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- UNUSED(handle);
- UNUSED(cbarg);
-
- return (eresult);
-}
-
-static isc_threadresult_t
-tlsdns_connect_thread(isc_threadarg_t arg) {
- isc_nm_t *connect_nm = (isc_nm_t *)arg;
- isc_sockaddr_t tlsdns_connect_addr;
-
- tlsdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tlsdns_connect_addr, &in6addr_loopback, 0);
-
- while (atomic_load(&nsends) > 0) {
- (void)isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_connect_connect_cb, NULL, 1000, 0,
- tlsdns_connect_ctx);
- }
-
- return ((isc_threadresult_t)0);
-}
-
-static void
-tlsdns_recv_one(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tlsdns_connect_addr;
-
- tlsdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tlsdns_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 1);
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr, tlsdns_connect_connect_cb,
- NULL, 1000, 0, tlsdns_connect_ctx);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&cconnects) != 1 || atomic_load(&ssends) != 0 ||
- atomic_load(&sreads) != 1 || atomic_load(&creads) != 0 ||
- atomic_load(&csends) != 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 1);
- assert_int_equal(atomic_load(&csends), 1);
- assert_int_equal(atomic_load(&creads), 0);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_int_equal(atomic_load(&sreads), 1);
- assert_int_equal(atomic_load(&ssends), 0);
-}
-
-static void
-tlsdns_recv_two(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t tlsdns_connect_addr;
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- tlsdns_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&tlsdns_connect_addr, &in6addr_loopback, 0);
-
- atomic_store(&nsends, 2);
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- result = isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr, tlsdns_connect_connect_cb,
- NULL, 1000, 0, tlsdns_connect_ctx);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_settimeouts(connect_nm, 1000, 1000, 1000, 1000);
-
- result = isc_nm_tlsdnsconnect(
- connect_nm, (isc_nmiface_t *)&tlsdns_connect_addr,
- (isc_nmiface_t *)&tlsdns_listen_addr, tlsdns_connect_connect_cb,
- NULL, 1000, 0, tlsdns_connect_ctx);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- while (atomic_load(&nsends) > 0) {
- isc_thread_yield();
- }
-
- while (atomic_load(&sreads) != 2 || atomic_load(&ssends) != 1 ||
- atomic_load(&csends) != 2 || atomic_load(&creads) != 1)
- {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(atomic_load(&cconnects), 2);
- assert_int_equal(atomic_load(&csends), 2);
- assert_int_equal(atomic_load(&creads), 1);
- assert_int_equal(atomic_load(&ctimeouts), 0);
- assert_int_equal(atomic_load(&sreads), 2);
- assert_int_equal(atomic_load(&ssends), 1);
-}
-
-static void
-tlsdns_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tlsdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_FULL(creads);
- CHECK_RANGE_FULL(sreads);
- CHECK_RANGE_FULL(ssends);
-}
-
-#if 0
-static void
-tlsdns_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tlsdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tlsdns_half_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tlsdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-tlsdns_half_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- if (!reuse_supported) {
- skip();
- return;
- }
-
- result = isc_nm_listentlsdns(
- listen_nm, (isc_nmiface_t *)&tlsdns_listen_addr,
- tlsdns_listen_read_cb, NULL, tlsdns_listen_accept_cb, NULL, 0,
- 0, NULL, tlsdns_listen_ctx, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(tlsdns_connect_thread, connect_nm,
- &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- CHECK_RANGE_HALF(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-#endif
-
-int
-main(void) {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(tlsdns_recv_one, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_recv_two, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_noop, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_noresponse, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_recv_send, nm_setup,
- nm_teardown),
-#if 0
- cmocka_unit_test_setup_teardown(tlsdns_recv_half_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_half_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(tlsdns_half_recv_half_send,
- nm_setup, nm_teardown),
-#endif
- };
-
- return (cmocka_run_group_tests(tests, _setup, _teardown));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
- printf("1..0 # Skipped: cmocka not available\n");
- return (0);
-}
-
-#endif /* if HAVE_CMOCKA */
diff --git a/external/mpl/bind/dist/lib/isc/tests/udp_test.c b/external/mpl/bind/dist/lib/isc/tests/udp_test.c
deleted file mode 100644
index 30e9824c8d0..00000000000
--- a/external/mpl/bind/dist/lib/isc/tests/udp_test.c
+++ /dev/null
@@ -1,894 +0,0 @@
-/* $NetBSD: udp_test.c,v 1.3 2021/04/29 17:26:13 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-#include <sched.h> /* IWYU pragma: keep */
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <uv.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/atomic.h>
-#include <isc/buffer.h>
-#include <isc/condition.h>
-#include <isc/mutex.h>
-#include <isc/netmgr.h>
-#include <isc/nonce.h>
-#include <isc/os.h>
-#include <isc/refcount.h>
-#include <isc/sockaddr.h>
-#include <isc/thread.h>
-
-#include "uv_wrap.h"
-#define KEEP_BEFORE
-
-#include "../netmgr/netmgr-int.h"
-#include "../netmgr/udp.c"
-#include "../netmgr/uv-compat.c"
-#include "../netmgr/uv-compat.h"
-#include "isctest.h"
-
-#define MAX_NM 2
-
-static isc_sockaddr_t udp_listen_addr;
-
-static uint64_t send_magic = 0;
-static uint64_t stop_magic = 0;
-
-static uv_buf_t send_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
- .len = sizeof(stop_magic) };
-
-static atomic_uint_fast64_t nsends;
-
-static atomic_uint_fast64_t ssends;
-static atomic_uint_fast64_t sreads;
-
-static atomic_uint_fast64_t cconnects;
-static atomic_uint_fast64_t csends;
-static atomic_uint_fast64_t creads;
-static atomic_uint_fast64_t ctimeouts;
-
-static unsigned int workers = 3;
-
-#define NSENDS 100
-#define NWRITES 10
-
-/*
- * The UDP protocol doesn't protect against packet duplication, but instead of
- * inventing de-duplication, we just ignore the upper bound.
- */
-
-#define CHECK_RANGE_FULL(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(NSENDS *NWRITES * 20 / 100 <= __v); \
- /* assert_true(__v <= NSENDS * NWRITES * 110 / 100); */ \
- }
-
-#define CHECK_RANGE_HALF(v) \
- { \
- int __v = atomic_load(&v); \
- assert_true(NSENDS *NWRITES * 10 / 100 <= __v); \
- /* assert_true(__v <= NSENDS * NWRITES * 60 / 100); */ \
- }
-
-/* Enable this to print values while running tests */
-#undef PRINT_DEBUG
-#ifdef PRINT_DEBUG
-#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v))
-#else
-#define X(v)
-#endif
-
-/* MOCK */
-
-static int
-setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
- isc_result_t result;
- socklen_t addrlen = sizeof(*addr);
- int fd;
- int r;
-
- isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
-
- fd = socket(AF_INET6, family, 0);
- if (fd < 0) {
- perror("setup_ephemeral_port: socket()");
- return (-1);
- }
-
- r = bind(fd, (const struct sockaddr *)&addr->type.sa,
- sizeof(addr->type.sin6));
- if (r != 0) {
- perror("setup_ephemeral_port: bind()");
- close(fd);
- return (r);
- }
-
- r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
- if (r != 0) {
- perror("setup_ephemeral_port: getsockname()");
- close(fd);
- return (r);
- }
-
- result = isc__nm_socket_reuse(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
- result = isc__nm_socket_reuse_lb(fd);
- if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
- fprintf(stderr,
- "setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s",
- isc_result_totext(result));
- close(fd);
- return (-1);
- }
-
-#if IPV6_RECVERR
-#define setsockopt_on(socket, level, name) \
- setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
-
- r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
- if (r != 0) {
- perror("setup_ephemeral_port");
- close(fd);
- return (r);
- }
-#endif
-
- return (fd);
-}
-
-static int
-_setup(void **state) {
- UNUSED(state);
-
- /* workers = isc_os_ncpus(); */
-
- if (isc_test_begin(NULL, true, workers) != ISC_R_SUCCESS) {
- return (-1);
- }
-
- signal(SIGPIPE, SIG_IGN);
-
- return (0);
-}
-
-static int
-_teardown(void **state) {
- UNUSED(state);
-
- isc_test_end();
-
- return (0);
-}
-
-/* Generic */
-
-static void
-noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
- void *cbarg) {
- UNUSED(handle);
- UNUSED(eresult);
- UNUSED(region);
- UNUSED(cbarg);
-}
-
-static void
-noop_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
- UNUSED(handle);
- UNUSED(result);
- UNUSED(cbarg);
-}
-
-static int
-nm_setup(void **state) {
- size_t nworkers = ISC_MAX(ISC_MIN(workers, 32), 1);
- int udp_listen_sock = -1;
- isc_nm_t **nm = NULL;
-
- udp_listen_addr = (isc_sockaddr_t){ .length = 0 };
- udp_listen_sock = setup_ephemeral_port(&udp_listen_addr, SOCK_DGRAM);
- if (udp_listen_sock < 0) {
- return (-1);
- }
- close(udp_listen_sock);
- udp_listen_sock = -1;
- /* silence scan-build */
- UNUSED(udp_listen_sock);
-
- atomic_store(&nsends, NSENDS * NWRITES);
-
- atomic_store(&csends, 0);
- atomic_store(&creads, 0);
- atomic_store(&sreads, 0);
- atomic_store(&ssends, 0);
- atomic_store(&ctimeouts, 0);
- atomic_store(&cconnects, 0);
-
- isc_nonce_buf(&send_magic, sizeof(send_magic));
- isc_nonce_buf(&stop_magic, sizeof(stop_magic));
- if (send_magic == stop_magic) {
- return (-1);
- }
-
- nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
- for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
- assert_non_null(nm[i]);
- }
-
- *state = nm;
-
- return (0);
-}
-
-static int
-nm_teardown(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
-
- for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
- assert_null(nm[i]);
- }
- isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
-
- return (0);
-}
-
-/* UDP */
-
-static void
-udp_listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- assert_non_null(handle);
- UNUSED(cbarg);
-
- if (eresult == ISC_R_SUCCESS) {
- atomic_fetch_add(&ssends, 1);
- }
-}
-
-static void
-udp_listen_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- assert_null(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- return;
- }
-
- assert_int_equal(region->length, sizeof(send_magic));
- atomic_fetch_add(&sreads, 1);
- memmove(&magic, region->base, sizeof(magic));
-
- assert_true(magic == stop_magic || magic == send_magic);
- isc_nm_send(handle, region, udp_listen_send_cb, NULL);
-}
-
-static void
-mock_listenudp_uv_udp_open(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_open, UV_ENOMEM);
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- noop_recv_cb, NULL, 0, &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_listenudp_uv_udp_bind(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_bind, UV_EADDRINUSE);
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- noop_recv_cb, NULL, 0, &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_listenudp_uv_udp_recv_start(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_recv_start, UV_EADDRINUSE);
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- noop_recv_cb, NULL, 0, &listen_sock);
- assert_int_not_equal(result, ISC_R_SUCCESS);
- assert_null(listen_sock);
-
- RESET_RETURN;
-}
-
-static void
-mock_udpconnect_uv_udp_open(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_open, UV_ENOMEM);
-
- result = isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_not_equal(result, ISC_R_SUCCESS);
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-static void
-mock_udpconnect_uv_udp_bind(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_bind, UV_ENOMEM);
-
- result = isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_not_equal(result, ISC_R_SUCCESS);
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-#if HAVE_UV_UDP_CONNECT
-static void
-mock_udpconnect_uv_udp_connect(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_udp_connect, UV_ENOMEM);
-
- result = isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_not_equal(result, ISC_R_SUCCESS);
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-#endif
-
-static void
-mock_udpconnect_uv_recv_buffer_size(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_recv_buffer_size, UV_ENOMEM);
-
- result = isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_equal(result, ISC_R_SUCCESS); /* FIXME: should fail */
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-static void
-mock_udpconnect_uv_send_buffer_size(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- WILL_RETURN(uv_send_buffer_size, UV_ENOMEM);
-
- result = isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
- assert_int_equal(result, ISC_R_SUCCESS); /* FIXME: should fail */
-
- isc_nm_closedown(connect_nm);
-
- RESET_RETURN;
-}
-
-static void
-udp_noop(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- noop_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- (void)isc_nm_udpconnect(connect_nm, (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- noop_connect_cb, NULL, 1000, 0);
-
- isc_nm_closedown(connect_nm);
-
- assert_int_equal(0, atomic_load(&cconnects));
- assert_int_equal(0, atomic_load(&csends));
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-udp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg);
-static void
-udp_connect_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg);
-
-static void
-udp_connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
- assert_non_null(handle);
-
- UNUSED(eresult);
- UNUSED(cbarg);
-
- atomic_fetch_add(&csends, 1);
-}
-
-static void
-udp_connect_send(isc_nmhandle_t *handle, isc_region_t *region) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends, sends - 1)) {
- break;
- }
- }
-
- isc_nm_send(handle, region, udp_connect_send_cb, NULL);
-}
-
-static void
-udp_connect_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- isc_region_t *region, void *cbarg) {
- uint64_t magic = 0;
-
- UNUSED(cbarg);
-
- assert_non_null(handle);
-
- if (eresult != ISC_R_SUCCESS) {
- goto unref;
- }
-
- assert_int_equal(region->length, sizeof(magic));
-
- atomic_fetch_add(&creads, 1);
-
- memmove(&magic, region->base, sizeof(magic));
-
- assert_true(magic == stop_magic || magic == send_magic);
-
- if (magic == stop_magic) {
- goto unref;
- }
-
- if (isc_random_uniform(NWRITES) == 0) {
- udp_connect_send(handle, (isc_region_t *)&stop_msg);
- } else {
- udp_connect_send(handle, (isc_region_t *)&send_msg);
- }
-unref:
- isc_nmhandle_detach(&handle);
-}
-
-static void
-udp_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
- void *cbarg) {
- isc_nmhandle_t *readhandle = NULL;
-
- UNUSED(cbarg);
-
- if (eresult != ISC_R_SUCCESS) {
- uint_fast64_t sends = atomic_load(&nsends);
-
- /* We failed to connect; try again */
- while (sends > 0) {
- /* Continue until we subtract or we are done */
- if (atomic_compare_exchange_weak(&nsends, &sends,
- sends - 1)) {
- break;
- }
- }
- return;
- }
-
- atomic_fetch_add(&cconnects, 1);
-
- isc_nmhandle_attach(handle, &readhandle);
- isc_nm_read(handle, udp_connect_recv_cb, NULL);
-
- udp_connect_send(handle, (isc_region_t *)&send_msg);
-}
-
-static isc_threadresult_t
-udp_connect_thread(isc_threadarg_t arg) {
- isc_nm_t *connect_nm = (isc_nm_t *)arg;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- while (atomic_load(&nsends) > 0) {
- (void)isc_nm_udpconnect(connect_nm,
- (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- udp_connect_connect_cb, NULL, 1000, 0);
- }
- return ((isc_threadresult_t)0);
-}
-
-static void
-udp_noresponse(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- isc_sockaddr_t udp_connect_addr;
-
- udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
- isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- noop_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- (void)isc_nm_udpconnect(connect_nm, (isc_nmiface_t *)&udp_connect_addr,
- (isc_nmiface_t *)&udp_listen_addr,
- udp_connect_connect_cb, NULL, 1000, 0);
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
- isc_nm_closedown(connect_nm);
-
- while (atomic_load(&cconnects) != 1) {
- isc_thread_yield();
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_int_equal(1, atomic_load(&cconnects));
- assert_true(atomic_load(&csends) <= 1);
- assert_int_equal(0, atomic_load(&creads));
- assert_int_equal(0, atomic_load(&ctimeouts));
- assert_int_equal(0, atomic_load(&sreads));
- assert_int_equal(0, atomic_load(&ssends));
-}
-
-static void
-udp_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- udp_listen_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(udp_connect_thread, connect_nm, &threads[i]);
- }
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) >= (NSENDS - 1) * NWRITES);
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_FULL(creads);
- CHECK_RANGE_FULL(sreads);
- CHECK_RANGE_FULL(ssends);
-}
-
-static void
-udp_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- udp_listen_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(udp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) >= (NSENDS - 1) * NWRITES);
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-udp_half_recv_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- udp_listen_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(udp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- isc_nm_closedown(connect_nm);
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) >= (NSENDS - 1) * NWRITES);
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-static void
-udp_half_recv_half_send(void **state) {
- isc_nm_t **nm = (isc_nm_t **)*state;
- isc_nm_t *listen_nm = nm[0];
- isc_nm_t *connect_nm = nm[1];
- isc_result_t result = ISC_R_SUCCESS;
- isc_nmsocket_t *listen_sock = NULL;
- size_t nthreads = ISC_MAX(ISC_MIN(workers, 32), 1);
- isc_thread_t threads[32] = { 0 };
-
- result = isc_nm_listenudp(listen_nm, (isc_nmiface_t *)&udp_listen_addr,
- udp_listen_recv_cb, NULL, 0, &listen_sock);
- assert_int_equal(result, ISC_R_SUCCESS);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_create(udp_connect_thread, connect_nm, &threads[i]);
- }
-
- while (atomic_load(&nsends) >= (NSENDS * NWRITES) / 2) {
- isc_thread_yield();
- }
-
- isc_nm_closedown(connect_nm);
- isc_nm_stoplistening(listen_sock);
- isc_nmsocket_close(&listen_sock);
- assert_null(listen_sock);
-
- for (size_t i = 0; i < nthreads; i++) {
- isc_thread_join(threads[i], NULL);
- }
-
- X(cconnects);
- X(csends);
- X(creads);
- X(ctimeouts);
- X(sreads);
- X(ssends);
-
- assert_true(atomic_load(&cconnects) >= (NSENDS - 1) * NWRITES);
- CHECK_RANGE_FULL(csends);
- CHECK_RANGE_HALF(creads);
- CHECK_RANGE_HALF(sreads);
- CHECK_RANGE_HALF(ssends);
-}
-
-int
-main(void) {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(mock_listenudp_uv_udp_open,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(mock_listenudp_uv_udp_bind,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(
- mock_listenudp_uv_udp_recv_start, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_open,
- nm_setup, nm_teardown),
- cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_bind,
- nm_setup, nm_teardown),
-#if HAVE_UV_UDP_CONNECT
- cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_connect,
- nm_setup, nm_teardown),
-#endif
- cmocka_unit_test_setup_teardown(
- mock_udpconnect_uv_recv_buffer_size, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(
- mock_udpconnect_uv_send_buffer_size, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_noop, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_noresponse, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_recv_half_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_half_recv_send, nm_setup,
- nm_teardown),
- cmocka_unit_test_setup_teardown(udp_half_recv_half_send,
- nm_setup, nm_teardown),
- };
-
- return (cmocka_run_group_tests(tests, _setup, _teardown));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
- printf("1..0 # Skipped: cmocka not available\n");
- return (SKIPPED_TEST_EXIT_CODE);
-}
-
-#endif /* if HAVE_CMOCKA */
diff --git a/external/mpl/bind/dist/lib/isc/tests/uv_wrap.h b/external/mpl/bind/dist/lib/isc/tests/uv_wrap.h
index 82a6bd17e3c..ac103e30c18 100644
--- a/external/mpl/bind/dist/lib/isc/tests/uv_wrap.h
+++ b/external/mpl/bind/dist/lib/isc/tests/uv_wrap.h
@@ -1,4 +1,4 @@
-/* $NetBSD: uv_wrap.h,v 1.2 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: uv_wrap.h,v 1.3 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -28,6 +28,8 @@
#define UNIT_TESTING
#include <cmocka.h>
+#include "../netmgr/uv-compat.h"
+
/* uv_udp_t */
int
@@ -35,13 +37,13 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock);
int
__wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
unsigned int flags);
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
int
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
int *namelen);
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
int
__wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name,
int *namelen);
@@ -114,7 +116,7 @@ __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
}
static atomic_int __state_uv_udp_connect = ATOMIC_VAR_INIT(0);
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
if (atomic_load(&__state_uv_udp_connect) == 0) {
@@ -122,10 +124,10 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
}
return (atomic_load(&__state_uv_udp_connect));
}
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
static atomic_int __state_uv_udp_getpeername = ATOMIC_VAR_INIT(0);
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
int *namelen) {
@@ -134,7 +136,7 @@ __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
}
return (atomic_load(&__state_uv_udp_getpeername));
}
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
static atomic_int __state_uv_udp_getsockname = ATOMIC_VAR_INIT(0);
int
@@ -272,10 +274,10 @@ __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd) {
#define uv_udp_open(...) __wrap_uv_udp_open(__VA_ARGS__)
#define uv_udp_bind(...) __wrap_uv_udp_bind(__VA_ARGS__)
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
#define uv_udp_connect(...) __wrap_uv_udp_connect(__VA_ARGS__)
#define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__VA_ARGS__)
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
#define uv_udp_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__)
#define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__)
#define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)
diff --git a/external/mpl/bind/dist/lib/isc/timer.c b/external/mpl/bind/dist/lib/isc/timer.c
index 6b31b493088..87822604d9a 100644
--- a/external/mpl/bind/dist/lib/isc/timer.c
+++ b/external/mpl/bind/dist/lib/isc/timer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: timer.c,v 1.8 2021/04/03 22:20:26 christos Exp $ */
+/* $NetBSD: timer.c,v 1.9 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -57,13 +57,10 @@
#define TIMER_MAGIC ISC_MAGIC('T', 'I', 'M', 'R')
#define VALID_TIMER(t) ISC_MAGIC_VALID(t, TIMER_MAGIC)
-typedef struct isc__timer isc__timer_t;
-typedef struct isc__timermgr isc__timermgr_t;
-
-struct isc__timer {
+struct isc_timer {
/*! Not locked. */
- isc_timer_t common;
- isc__timermgr_t *manager;
+ unsigned int magic;
+ isc_timermgr_t *manager;
isc_mutex_t lock;
isc_refcount_t references;
/*! Locked by timer lock. */
@@ -77,20 +74,20 @@ struct isc__timer {
void *arg;
unsigned int index;
isc_time_t due;
- LINK(isc__timer_t) link;
+ LINK(isc_timer_t) link;
};
#define TIMER_MANAGER_MAGIC ISC_MAGIC('T', 'I', 'M', 'M')
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TIMER_MANAGER_MAGIC)
-struct isc__timermgr {
+struct isc_timermgr {
/* Not locked. */
- isc_timermgr_t common;
+ unsigned int magic;
isc_mem_t *mctx;
isc_mutex_t lock;
/* Locked by manager lock. */
bool done;
- LIST(isc__timer_t) timers;
+ LIST(isc_timer_t) timers;
unsigned int nscheduled;
isc_time_t due;
isc_condition_t wakeup;
@@ -102,9 +99,9 @@ void
isc_timermgr_poke(isc_timermgr_t *manager0);
static inline isc_result_t
-schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
+schedule(isc_timer_t *timer, isc_time_t *now, bool signal_ok) {
isc_result_t result;
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
isc_time_t due;
int cmp;
@@ -191,9 +188,9 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
}
static inline void
-deschedule(isc__timer_t *timer) {
+deschedule(isc_timer_t *timer) {
bool need_wakeup = false;
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
/*
* The caller must ensure locking.
@@ -216,8 +213,8 @@ deschedule(isc__timer_t *timer) {
}
static void
-destroy(isc__timer_t *timer) {
- isc__timermgr_t *manager = timer->manager;
+destroy(isc_timer_t *timer) {
+ isc_timermgr_t *manager = timer->manager;
/*
* The caller must ensure it is safe to destroy the timer.
@@ -234,22 +231,20 @@ destroy(isc__timer_t *timer) {
isc_task_detach(&timer->task);
isc_mutex_destroy(&timer->lock);
- timer->common.impmagic = 0;
- timer->common.magic = 0;
+ timer->magic = 0;
isc_mem_put(manager->mctx, timer, sizeof(*timer));
}
isc_result_t
-isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
+isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp) {
- REQUIRE(VALID_MANAGER(manager0));
+ REQUIRE(VALID_MANAGER(manager));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
- isc__timermgr_t *manager;
- isc__timer_t *timer;
+ isc_timer_t *timer;
isc_result_t result;
isc_time_t now;
@@ -260,7 +255,6 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
* called with 'arg' as the arg value. The new timer is returned
* in 'timerp'.
*/
- manager = (isc__timermgr_t *)manager0;
if (expires == NULL) {
expires = isc_time_epoch;
}
@@ -322,8 +316,7 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
timer->index = 0;
isc_mutex_init(&timer->lock);
ISC_LINK_INIT(timer, link);
- timer->common.impmagic = TIMER_MAGIC;
- timer->common.magic = ISCAPI_TIMER_MAGIC;
+ timer->magic = TIMER_MAGIC;
LOCK(&manager->lock);
@@ -338,15 +331,14 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
result = ISC_R_SUCCESS;
}
if (result == ISC_R_SUCCESS) {
- *timerp = (isc_timer_t *)timer;
+ *timerp = timer;
APPEND(manager->timers, timer, link);
}
UNLOCK(&manager->lock);
if (result != ISC_R_SUCCESS) {
- timer->common.impmagic = 0;
- timer->common.magic = 0;
+ timer->magic = 0;
isc_mutex_destroy(&timer->lock);
isc_task_detach(&timer->task);
isc_mem_put(manager->mctx, timer, sizeof(*timer));
@@ -357,12 +349,11 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
}
isc_result_t
-isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
+isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
bool purge) {
- isc__timer_t *timer;
isc_time_t now;
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
isc_result_t result;
/*
@@ -371,8 +362,7 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
* are purged from its task's event queue.
*/
- REQUIRE(VALID_TIMER(timer0));
- timer = (isc__timer_t *)timer0;
+ REQUIRE(VALID_TIMER(timer));
manager = timer->manager;
REQUIRE(VALID_MANAGER(manager));
@@ -435,12 +425,10 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
}
isc_timertype_t
-isc_timer_gettype(isc_timer_t *timer0) {
- isc__timer_t *timer;
+isc_timer_gettype(isc_timer_t *timer) {
isc_timertype_t t;
- REQUIRE(VALID_TIMER(timer0));
- timer = (isc__timer_t *)timer0;
+ REQUIRE(VALID_TIMER(timer));
LOCK(&timer->lock);
t = timer->type;
@@ -450,8 +438,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
}
isc_result_t
-isc_timer_touch(isc_timer_t *timer0) {
- isc__timer_t *timer;
+isc_timer_touch(isc_timer_t *timer) {
isc_result_t result;
isc_time_t now;
@@ -459,8 +446,7 @@ isc_timer_touch(isc_timer_t *timer0) {
* Set the last-touched time of 'timer' to the current time.
*/
- REQUIRE(VALID_TIMER(timer0));
- timer = (isc__timer_t *)timer0;
+ REQUIRE(VALID_TIMER(timer));
LOCK(&timer->lock);
@@ -482,31 +468,28 @@ isc_timer_touch(isc_timer_t *timer0) {
}
void
-isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
- isc__timer_t *timer;
-
+isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) {
/*
* Attach *timerp to timer.
*/
- REQUIRE(VALID_TIMER(timer0));
- timer = (isc__timer_t *)timer0;
+ REQUIRE(VALID_TIMER(timer));
REQUIRE(timerp != NULL && *timerp == NULL);
isc_refcount_increment(&timer->references);
- *timerp = (isc_timer_t *)timer;
+ *timerp = timer;
}
void
isc_timer_detach(isc_timer_t **timerp) {
- isc__timer_t *timer;
+ isc_timer_t *timer;
/*
* Detach *timerp from its timer.
*/
REQUIRE(timerp != NULL);
- timer = (isc__timer_t *)*timerp;
+ timer = *timerp;
REQUIRE(VALID_TIMER(timer));
if (isc_refcount_decrement(&timer->references) == 1) {
@@ -517,11 +500,11 @@ isc_timer_detach(isc_timer_t **timerp) {
}
static void
-dispatch(isc__timermgr_t *manager, isc_time_t *now) {
+dispatch(isc_timermgr_t *manager, isc_time_t *now) {
bool done = false, post_event, need_schedule;
isc_timerevent_t *event;
isc_eventtype_t type = 0;
- isc__timer_t *timer;
+ isc_timer_t *timer;
isc_result_t result;
bool idle;
@@ -627,7 +610,7 @@ static isc_threadresult_t
WINAPI
#endif /* ifdef _WIN32 */
run(void *uap) {
- isc__timermgr_t *manager = uap;
+ isc_timermgr_t *manager = uap;
isc_time_t now;
isc_result_t result;
@@ -662,7 +645,7 @@ static isc_threadresult_t
static bool
sooner(void *v1, void *v2) {
- isc__timer_t *t1, *t2;
+ isc_timer_t *t1, *t2;
t1 = v1;
t2 = v2;
@@ -677,7 +660,7 @@ sooner(void *v1, void *v2) {
static void
set_index(void *what, unsigned int index) {
- isc__timer_t *timer;
+ isc_timer_t *timer;
REQUIRE(VALID_TIMER(what));
timer = what;
@@ -687,7 +670,7 @@ set_index(void *what, unsigned int index) {
isc_result_t
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
isc_result_t result;
/*
@@ -698,8 +681,7 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
manager = isc_mem_get(mctx, sizeof(*manager));
- manager->common.impmagic = TIMER_MANAGER_MAGIC;
- manager->common.magic = ISCAPI_TIMERMGR_MAGIC;
+ manager->magic = TIMER_MANAGER_MAGIC;
manager->mctx = NULL;
manager->done = false;
INIT_LIST(manager->timers);
@@ -718,31 +700,28 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc_thread_create(run, manager, &manager->thread);
isc_thread_setname(manager->thread, "timer");
- *managerp = (isc_timermgr_t *)manager;
+ *managerp = manager;
return (ISC_R_SUCCESS);
}
void
-isc_timermgr_poke(isc_timermgr_t *manager0) {
- isc__timermgr_t *manager;
-
- REQUIRE(VALID_MANAGER(manager0));
- manager = (isc__timermgr_t *)manager0;
+isc_timermgr_poke(isc_timermgr_t *manager) {
+ REQUIRE(VALID_MANAGER(manager));
SIGNAL(&manager->wakeup);
}
void
isc_timermgr_destroy(isc_timermgr_t **managerp) {
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
/*
* Destroy a timer manager.
*/
REQUIRE(managerp != NULL);
- manager = (isc__timermgr_t *)*managerp;
+ manager = *managerp;
REQUIRE(VALID_MANAGER(manager));
LOCK(&manager->lock);
@@ -766,18 +745,8 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) {
(void)isc_condition_destroy(&manager->wakeup);
isc_mutex_destroy(&manager->lock);
isc_heap_destroy(&manager->heap);
- manager->common.impmagic = 0;
- manager->common.magic = 0;
+ manager->magic = 0;
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
*managerp = NULL;
}
-
-isc_result_t
-isc_timermgr_createinctx(isc_mem_t *mctx, isc_timermgr_t **managerp) {
- isc_result_t result;
-
- result = isc_timermgr_create(mctx, managerp);
-
- return (result);
-}
diff --git a/external/mpl/bind/dist/lib/isc/tls.c b/external/mpl/bind/dist/lib/isc/tls.c
index c257047f331..dcfba4af734 100644
--- a/external/mpl/bind/dist/lib/isc/tls.c
+++ b/external/mpl/bind/dist/lib/isc/tls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.1.1.2 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: tls.c,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/tm.c b/external/mpl/bind/dist/lib/isc/tm.c
index e2b07e2bdb9..f1fab07130c 100644
--- a/external/mpl/bind/dist/lib/isc/tm.c
+++ b/external/mpl/bind/dist/lib/isc/tm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tm.c,v 1.5 2021/02/19 16:42:19 christos Exp $ */
+/* $NetBSD: tm.c,v 1.6 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -91,7 +91,7 @@ conv_num(const char **buf, int *dest, int llim, int ulim) {
/* The limit also determines the number of valid digits. */
int rulim = ulim;
- if (**buf < '0' || **buf > '9') {
+ if (!isdigit((unsigned char)**buf)) {
return (0);
}
diff --git a/external/mpl/bind/dist/lib/isc/trampoline_p.h b/external/mpl/bind/dist/lib/isc/trampoline_p.h
index e61c3bef6c5..a466b39ddb8 100644
--- a/external/mpl/bind/dist/lib/isc/trampoline_p.h
+++ b/external/mpl/bind/dist/lib/isc/trampoline_p.h
@@ -1,4 +1,4 @@
-/* $NetBSD: trampoline_p.h,v 1.1.1.2 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: trampoline_p.h,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/unix/dir.c b/external/mpl/bind/dist/lib/isc/unix/dir.c
index fbed271aef0..6b2d2d21dd3 100644
--- a/external/mpl/bind/dist/lib/isc/unix/dir.c
+++ b/external/mpl/bind/dist/lib/isc/unix/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.4 2021/02/19 16:42:20 christos Exp $ */
+/* $NetBSD: dir.c,v 1.5 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -232,7 +232,7 @@ isc_dir_createunique(char *templet) {
*/
p = x;
while (*p != '\0') {
- if (isdigit(*p & 0xff)) {
+ if (isdigit((unsigned char)*p)) {
*p = 'a';
} else if (*p != 'z') {
++*p;
diff --git a/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h b/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h
index 1ab2c2ffff0..8b1fbff9fb4 100644
--- a/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h
+++ b/external/mpl/bind/dist/lib/isc/unix/include/isc/stdatomic.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdatomic.h,v 1.4 2021/03/27 00:06:27 rillig Exp $ */
+/* $NetBSD: stdatomic.h,v 1.5 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -187,10 +187,10 @@ typedef uintmax_t atomic_uintmax_t;
fail) \
({ \
__typeof__(obj) __v; \
- _Bool __r; \
+ _Bool __r; \
__v = (__typeof__(obj))__sync_val_compare_and_swap( \
obj, *(expected), desired); \
- __r = ((__typeof__(obj)) * (expected) == __v); \
+ __r = ((__typeof__(obj))*(expected) == __v); \
*(expected) = __v; \
__r; \
})
diff --git a/external/mpl/bind/dist/lib/isc/unix/socket.c b/external/mpl/bind/dist/lib/isc/unix/socket.c
index bd3a44ac9dc..e2d2619372e 100644
--- a/external/mpl/bind/dist/lib/isc/unix/socket.c
+++ b/external/mpl/bind/dist/lib/isc/unix/socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.c,v 1.22 2021/04/05 11:27:03 rillig Exp $ */
+/* $NetBSD: socket.c,v 1.23 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -323,23 +323,21 @@ typedef isc_event_t intev_t;
*/
#define NRETRIES 10
-typedef struct isc__socket isc__socket_t;
-typedef struct isc__socketmgr isc__socketmgr_t;
typedef struct isc__socketthread isc__socketthread_t;
-#define NEWCONNSOCK(ev) ((isc__socket_t *)(ev)->newsocket)
+#define NEWCONNSOCK(ev) ((ev)->newsocket)
-struct isc__socket {
+struct isc_socket {
/* Not locked. */
- isc_socket_t common;
- isc__socketmgr_t *manager;
+ unsigned int magic;
+ isc_socketmgr_t *manager;
isc_mutex_t lock;
isc_sockettype_t type;
const isc_statscounter_t *statsindex;
isc_refcount_t references;
/* Locked by socket lock. */
- ISC_LINK(isc__socket_t) link;
+ ISC_LINK(isc_socket_t) link;
int fd;
int pf;
int threadid;
@@ -374,9 +372,9 @@ struct isc__socket {
#define SOCKET_MANAGER_MAGIC ISC_MAGIC('I', 'O', 'm', 'g')
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, SOCKET_MANAGER_MAGIC)
-struct isc__socketmgr {
+struct isc_socketmgr {
/* Not locked. */
- isc_socketmgr_t common;
+ unsigned int magic;
isc_mem_t *mctx;
isc_mutex_t lock;
isc_stats_t *stats;
@@ -384,20 +382,20 @@ struct isc__socketmgr {
isc__socketthread_t *threads;
unsigned int maxsocks;
/* Locked by manager lock. */
- ISC_LIST(isc__socket_t) socklist;
+ ISC_LIST(isc_socket_t) socklist;
int reserved; /* unlocked */
isc_condition_t shutdown_ok;
size_t maxudp;
};
struct isc__socketthread {
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
int threadid;
isc_thread_t thread;
int pipe_fds[2];
isc_mutex_t *fdlock;
/* Locked by fdlock. */
- isc__socket_t **fds;
+ isc_socket_t **fds;
int *fdstate;
#ifdef USE_KQUEUE
int kqueue_fd;
@@ -446,45 +444,45 @@ static isc_result_t
socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
isc_socket_t **socketp, isc_socket_t *dup_socket);
static void
-send_recvdone_event(isc__socket_t *, isc_socketevent_t **);
+send_recvdone_event(isc_socket_t *, isc_socketevent_t **);
static void
-send_senddone_event(isc__socket_t *, isc_socketevent_t **);
+send_senddone_event(isc_socket_t *, isc_socketevent_t **);
static void
-send_connectdone_event(isc__socket_t *, isc_socket_connev_t **);
+send_connectdone_event(isc_socket_t *, isc_socket_connev_t **);
static void
-free_socket(isc__socket_t **);
+free_socket(isc_socket_t **);
static isc_result_t
-allocate_socket(isc__socketmgr_t *, isc_sockettype_t, isc__socket_t **);
+allocate_socket(isc_socketmgr_t *, isc_sockettype_t, isc_socket_t **);
static void
-destroy(isc__socket_t **);
+destroy(isc_socket_t **);
static void
-internal_accept(isc__socket_t *);
+internal_accept(isc_socket_t *);
static void
-internal_connect(isc__socket_t *);
+internal_connect(isc_socket_t *);
static void
-internal_recv(isc__socket_t *);
+internal_recv(isc_socket_t *);
static void
-internal_send(isc__socket_t *);
+internal_send(isc_socket_t *);
static void
-process_cmsg(isc__socket_t *, struct msghdr *, isc_socketevent_t *);
+process_cmsg(isc_socket_t *, struct msghdr *, isc_socketevent_t *);
static void
-build_msghdr_send(isc__socket_t *, char *, isc_socketevent_t *, struct msghdr *,
+build_msghdr_send(isc_socket_t *, char *, isc_socketevent_t *, struct msghdr *,
struct iovec *, size_t *);
static void
-build_msghdr_recv(isc__socket_t *, char *, isc_socketevent_t *, struct msghdr *,
+build_msghdr_recv(isc_socket_t *, char *, isc_socketevent_t *, struct msghdr *,
struct iovec *, size_t *);
static bool
process_ctlfd(isc__socketthread_t *thread);
static void
-setdscp(isc__socket_t *sock, isc_dscp_t dscp);
+setdscp(isc_socket_t *sock, isc_dscp_t dscp);
static void
-dispatch_recv(isc__socket_t *sock);
+dispatch_recv(isc_socket_t *sock);
static void
-dispatch_send(isc__socket_t *sock);
+dispatch_send(isc_socket_t *sock);
static void
-internal_fdwatch_read(isc__socket_t *sock);
+internal_fdwatch_read(isc_socket_t *sock);
static void
-internal_fdwatch_write(isc__socket_t *sock);
+internal_fdwatch_write(isc_socket_t *sock);
#define SELECT_POKE_SHUTDOWN (-1)
#define SELECT_POKE_NOTHING (-2)
@@ -575,19 +573,19 @@ static const isc_statscounter_t rawstatsindex[] = {
};
static int
-gen_threadid(isc__socket_t *sock);
+gen_threadid(isc_socket_t *sock);
static int
-gen_threadid(isc__socket_t *sock) {
+gen_threadid(isc_socket_t *sock) {
return (sock->fd % sock->manager->nthreads);
}
static void
-manager_log(isc__socketmgr_t *sockmgr, isc_logcategory_t *category,
+manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category,
isc_logmodule_t *module, int level, const char *fmt, ...)
ISC_FORMAT_PRINTF(5, 6);
static void
-manager_log(isc__socketmgr_t *sockmgr, isc_logcategory_t *category,
+manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category,
isc_logmodule_t *module, int level, const char *fmt, ...) {
char msgbuf[2048];
va_list ap;
@@ -628,11 +626,11 @@ thread_log(isc__socketthread_t *thread, isc_logcategory_t *category,
}
static void
-socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
+socket_log(isc_socket_t *sock, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...) ISC_FORMAT_PRINTF(6, 7);
static void
-socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
+socket_log(isc_socket_t *sock, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...) {
char msgbuf[2048];
@@ -939,7 +937,7 @@ wakeup_socket(isc__socketthread_t *thread, int fd, int msg) {
* will not get partial writes.
*/
static void
-select_poke(isc__socketmgr_t *mgr, int threadid, int fd, int msg) {
+select_poke(isc_socketmgr_t *mgr, int threadid, int fd, int msg) {
int cc;
int buf[2];
char strbuf[ISC_STRERRORSIZE];
@@ -1093,7 +1091,7 @@ cmsg_space(socklen_t len) {
* Process control messages received on a socket.
*/
static void
-process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
+process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
#ifdef USE_CMSG
struct cmsghdr *cmsgp;
struct in6_pktinfo *pktinfop;
@@ -1211,7 +1209,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
* this transaction can send.
*/
static void
-build_msghdr_send(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
+build_msghdr_send(isc_socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
struct msghdr *msg, struct iovec *iov, size_t *write_countp) {
unsigned int iovcount;
size_t write_count;
@@ -1375,7 +1373,7 @@ build_msghdr_send(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
* this transaction can receive.
*/
static void
-build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
+build_msghdr_recv(isc_socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
struct msghdr *msg, struct iovec *iov, size_t *read_countp) {
unsigned int iovcount;
size_t read_count;
@@ -1427,7 +1425,7 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
}
static void
-set_dev_address(const isc_sockaddr_t *address, isc__socket_t *sock,
+set_dev_address(const isc_sockaddr_t *address, isc_socket_t *sock,
isc_socketevent_t *dev) {
if (sock->type == isc_sockettype_udp) {
if (address != NULL) {
@@ -1492,7 +1490,7 @@ dump_msg(struct msghdr *msg) {
#define DOIO_EOF 3 /* EOF, no event sent */
static int
-doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
+doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
int cc;
struct iovec iov[MAXSCATTERGATHER_RECV];
size_t read_count;
@@ -1668,7 +1666,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
* No other return values are possible.
*/
static int
-doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
+doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
int cc;
struct iovec iov[MAXSCATTERGATHER_SEND];
size_t write_count;
@@ -1790,7 +1788,7 @@ resend:
* references exist.
*/
static void
-socketclose(isc__socketthread_t *thread, isc__socket_t *sock, int fd) {
+socketclose(isc__socketthread_t *thread, isc_socket_t *sock, int fd) {
int lockid = FDLOCK_ID(fd);
/*
* No one has this socket open, so the watcher doesn't have to be
@@ -1860,10 +1858,10 @@ socketclose(isc__socketthread_t *thread, isc__socket_t *sock, int fd) {
}
static void
-destroy(isc__socket_t **sockp) {
+destroy(isc_socket_t **sockp) {
int fd = 0;
- isc__socket_t *sock = *sockp;
- isc__socketmgr_t *manager = sock->manager;
+ isc_socket_t *sock = *sockp;
+ isc_socketmgr_t *manager = sock->manager;
isc__socketthread_t *thread = NULL;
socket_log(sock, NULL, CREATION, "destroying");
@@ -1904,14 +1902,13 @@ destroy(isc__socket_t **sockp) {
}
static isc_result_t
-allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
- isc__socket_t **socketp) {
- isc__socket_t *sock;
+allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
+ isc_socket_t **socketp) {
+ isc_socket_t *sock;
sock = isc_mem_get(manager->mctx, sizeof(*sock));
- sock->common.magic = 0;
- sock->common.impmagic = 0;
+ sock->magic = 0;
isc_refcount_init(&sock->references, 0);
sock->manager = manager;
@@ -1947,8 +1944,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
*/
isc_mutex_init(&sock->lock);
- sock->common.magic = ISCAPI_SOCKET_MAGIC;
- sock->common.impmagic = SOCKET_MAGIC;
+ sock->magic = SOCKET_MAGIC;
*socketp = sock;
return (ISC_R_SUCCESS);
@@ -1962,8 +1958,8 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
* also close the socket.
*/
static void
-free_socket(isc__socket_t **socketp) {
- isc__socket_t *sock = *socketp;
+free_socket(isc_socket_t **socketp) {
+ isc_socket_t *sock = *socketp;
*socketp = NULL;
INSIST(VALID_SOCKET(sock));
@@ -1977,8 +1973,7 @@ free_socket(isc__socket_t **socketp) {
INSIST(!ISC_LINK_LINKED(sock, link));
UNLOCK(&sock->lock);
- sock->common.magic = 0;
- sock->common.impmagic = 0;
+ sock->magic = 0;
isc_mutex_destroy(&sock->lock);
@@ -2102,7 +2097,7 @@ cleanup:
#endif /* ifdef SO_SNDBUF */
static void
-use_min_mtu(isc__socket_t *sock) {
+use_min_mtu(isc_socket_t *sock) {
#if !defined(IPV6_USE_MIN_MTU) && !defined(IPV6_MTU)
UNUSED(sock);
#endif /* if !defined(IPV6_USE_MIN_MTU) && !defined(IPV6_MTU) */
@@ -2127,7 +2122,7 @@ use_min_mtu(isc__socket_t *sock) {
}
static void
-set_tcp_maxseg(isc__socket_t *sock, int size) {
+set_tcp_maxseg(isc_socket_t *sock, int size) {
#ifdef TCP_MAXSEG
if (sock->type == isc_sockettype_tcp) {
(void)setsockopt(sock->fd, IPPROTO_TCP, TCP_MAXSEG,
@@ -2136,9 +2131,35 @@ set_tcp_maxseg(isc__socket_t *sock, int size) {
#endif /* ifdef TCP_MAXSEG */
}
+static void
+set_ip_disable_pmtud(isc_socket_t *sock) {
+ /*
+ * Disable Path MTU Discover on IP packets
+ */
+ if (sock->pf == AF_INET6) {
+#if defined(IPV6_DONTFRAG)
+ (void)setsockopt(sock->fd, IPPROTO_IPV6, IPV6_DONTFRAG,
+ &(int){ 0 }, sizeof(int));
+#endif
+#if defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_OMIT)
+ (void)setsockopt(sock->fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
+ &(int){ IP_PMTUDISC_OMIT }, sizeof(int));
+#endif
+ } else if (sock->pf == AF_INET) {
+#if defined(IP_DONTFRAG)
+ (void)setsockopt(sock->fd, IPPROTO_IP, IP_DONTFRAG, &(int){ 0 },
+ sizeof(int));
+#endif
+#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_OMIT)
+ (void)setsockopt(sock->fd, IPPROTO_IP, IP_MTU_DISCOVER,
+ &(int){ IP_PMTUDISC_OMIT }, sizeof(int));
+#endif
+ }
+}
+
static isc_result_t
-opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
- isc__socket_t *dup_socket) {
+opensocket(isc_socketmgr_t *manager, isc_socket_t *sock,
+ isc_socket_t *dup_socket) {
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
const char *err = "socket";
@@ -2361,53 +2382,8 @@ again:
sock->fd, strbuf);
}
#endif /* IPV6_RECVPKTINFO */
-#if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DONT)
- /*
- * Turn off Path MTU discovery on IPv6/UDP sockets.
- */
- if (sock->pf == AF_INET6) {
- int action = IPV6_PMTUDISC_DONT;
- (void)setsockopt(sock->fd, IPPROTO_IPV6,
- IPV6_MTU_DISCOVER, &action,
- sizeof(action));
- }
-#endif /* if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DONT) */
#endif /* defined(USE_CMSG) */
-#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
- /*
- * Turn off Path MTU discovery on IPv4/UDP sockets.
- * Prefer IP_PMTUDISC_OMIT over IP_PMTUDISC_DONT
- * if it available.
- */
- if (sock->pf == AF_INET) {
- int action;
-#if defined(IP_PMTUDISC_OMIT)
- action = IP_PMTUDISC_OMIT;
- if (setsockopt(sock->fd, IPPROTO_IP, IP_MTU_DISCOVER,
- &action, sizeof(action)) < 0)
- {
-#endif /* if defined(IP_PMTUDISC_OMIT) */
- action = IP_PMTUDISC_DONT;
- (void)setsockopt(sock->fd, IPPROTO_IP,
- IP_MTU_DISCOVER, &action,
- sizeof(action));
-#if defined(IP_PMTUDISC_OMIT)
- }
-#endif /* if defined(IP_PMTUDISC_OMIT) */
- }
-#endif /* if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) */
-#if defined(IP_DONTFRAG)
- /*
- * Turn off Path MTU discovery on IPv4/UDP sockets.
- */
- if (sock->pf == AF_INET) {
- int off = 0;
- (void)setsockopt(sock->fd, IPPROTO_IP, IP_DONTFRAG,
- &off, sizeof(off));
- }
-#endif /* if defined(IP_DONTFRAG) */
-
#if defined(SET_RCVBUF)
optlen = sizeof(size);
if (getsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF, (void *)&size,
@@ -2474,6 +2450,8 @@ again:
#endif /* ifdef IP_RECVTOS */
#endif /* defined(USE_CMSG) || defined(SET_RCVBUF) || defined(SET_SNDBUF) */
+ set_ip_disable_pmtud(sock);
+
setup_done:
inc_stats(manager->stats, sock->statsindex[STATID_OPEN]);
if (sock->active == 0) {
@@ -2491,10 +2469,9 @@ setup_done:
* socket is returned in 'socketp'.
*/
static isc_result_t
-socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
+socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc_socket_t **socketp, isc_socket_t *dup_socket) {
- isc__socket_t *sock = NULL;
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
+ isc_socket_t *sock = NULL;
isc__socketthread_t *thread;
isc_result_t result;
int lockid;
@@ -2532,7 +2509,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
sock->pf = pf;
- result = opensocket(manager, sock, (isc__socket_t *)dup_socket);
+ result = opensocket(manager, sock, dup_socket);
if (result != ISC_R_SUCCESS) {
free_socket(&sock);
return (result);
@@ -2544,7 +2521,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
sock->threadid = gen_threadid(sock);
isc_refcount_increment0(&sock->references);
thread = &manager->threads[sock->threadid];
- *socketp = (isc_socket_t *)sock;
+ *socketp = sock;
/*
* Note we don't have to lock the socket like we normally would because
@@ -2596,20 +2573,17 @@ isc_socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
* in 'socketp'.
*/
isc_result_t
-isc_socket_dup(isc_socket_t *sock0, isc_socket_t **socketp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
- return (socket_create((isc_socketmgr_t *)sock->manager, sock->pf,
- sock->type, socketp, sock0));
+ return (socket_create(sock->manager, sock->pf, sock->type, socketp,
+ sock));
}
isc_result_t
-isc_socket_open(isc_socket_t *sock0) {
+isc_socket_open(isc_socket_t *sock) {
isc_result_t result;
- isc__socket_t *sock = (isc__socket_t *)sock0;
isc__socketthread_t *thread;
REQUIRE(VALID_SOCKET(sock));
@@ -2660,16 +2634,14 @@ isc_socket_open(isc_socket_t *sock0) {
* Attach to a socket. Caller must explicitly detach when it is done.
*/
void
-isc_socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
int old_refs = isc_refcount_increment(&sock->references);
REQUIRE(old_refs > 0);
- *socketp = (isc_socket_t *)sock;
+ *socketp = sock;
}
/*
@@ -2678,10 +2650,10 @@ isc_socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
*/
void
isc_socket_detach(isc_socket_t **socketp) {
- isc__socket_t *sock;
+ isc_socket_t *sock;
REQUIRE(socketp != NULL);
- sock = (isc__socket_t *)*socketp;
+ sock = *socketp;
REQUIRE(VALID_SOCKET(sock));
if (isc_refcount_decrement(&sock->references) == 1) {
destroy(&sock);
@@ -2691,10 +2663,9 @@ isc_socket_detach(isc_socket_t **socketp) {
}
isc_result_t
-isc_socket_close(isc_socket_t *sock0) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_close(isc_socket_t *sock) {
int fd;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
isc__socketthread_t *thread;
fflush(stdout);
REQUIRE(VALID_SOCKET(sock));
@@ -2733,7 +2704,7 @@ isc_socket_close(isc_socket_t *sock0) {
}
static void
-dispatch_recv(isc__socket_t *sock) {
+dispatch_recv(isc_socket_t *sock) {
if (sock->type != isc_sockettype_fdwatch) {
internal_recv(sock);
} else {
@@ -2742,7 +2713,7 @@ dispatch_recv(isc__socket_t *sock) {
}
static void
-dispatch_send(isc__socket_t *sock) {
+dispatch_send(isc_socket_t *sock) {
if (sock->type != isc_sockettype_fdwatch) {
internal_send(sock);
} else {
@@ -2761,7 +2732,7 @@ dispatch_send(isc__socket_t *sock) {
* Caller must have the socket locked if the event is attached to the socket.
*/
static void
-send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
+send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
isc_task_t *task;
task = (*dev)->ev_sender;
@@ -2786,7 +2757,7 @@ send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
* Caller must have the socket locked if the event is attached to the socket.
*/
static void
-send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
+send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
isc_task_t *task;
INSIST(dev != NULL && *dev != NULL);
@@ -2812,7 +2783,7 @@ send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
* Caller must have the socket locked if the event is attached to the socket.
*/
static void
-send_connectdone_event(isc__socket_t *sock, isc_socket_connev_t **dev) {
+send_connectdone_event(isc_socket_t *sock, isc_socket_connev_t **dev) {
isc_task_t *task;
INSIST(dev != NULL && *dev != NULL);
@@ -2839,8 +2810,8 @@ send_connectdone_event(isc__socket_t *sock, isc_socket_connev_t **dev) {
* so just unlock and return.
*/
static void
-internal_accept(isc__socket_t *sock) {
- isc__socketmgr_t *manager;
+internal_accept(isc_socket_t *sock) {
+ isc_socketmgr_t *manager;
isc__socketthread_t *thread, *nthread;
isc_socket_newconnev_t *dev;
isc_task_t *task;
@@ -3077,7 +3048,7 @@ internal_accept(isc__socket_t *sock) {
} else {
inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]);
isc_refcount_decrementz(&NEWCONNSOCK(dev)->references);
- free_socket((isc__socket_t **)&dev->newsocket);
+ free_socket((isc_socket_t **)&dev->newsocket);
}
/*
@@ -3099,7 +3070,7 @@ soft_error:
}
static void
-internal_recv(isc__socket_t *sock) {
+internal_recv(isc_socket_t *sock) {
isc_socketevent_t *dev;
INSIST(VALID_SOCKET(sock));
@@ -3152,7 +3123,7 @@ finish:
}
static void
-internal_send(isc__socket_t *sock) {
+internal_send(isc_socket_t *sock) {
isc_socketevent_t *dev;
INSIST(VALID_SOCKET(sock));
@@ -3191,7 +3162,7 @@ finish:
}
static void
-internal_fdwatch_write(isc__socket_t *sock)
+internal_fdwatch_write(isc_socket_t *sock)
{
int more_data;
@@ -3217,7 +3188,7 @@ internal_fdwatch_write(isc__socket_t *sock)
}
static void
-internal_fdwatch_read(isc__socket_t *sock)
+internal_fdwatch_read(isc_socket_t *sock)
{
int more_data;
@@ -3248,7 +3219,7 @@ internal_fdwatch_read(isc__socket_t *sock)
*/
static void
process_fd(isc__socketthread_t *thread, int fd, bool readable, bool writeable) {
- isc__socket_t *sock;
+ isc_socket_t *sock;
int lockid = FDLOCK_ID(fd);
/*
@@ -3495,13 +3466,10 @@ process_ctlfd(isc__socketthread_t *thread) {
static isc_threadresult_t
netthread(void *uap) {
isc__socketthread_t *thread = uap;
- isc__socketmgr_t *manager = thread->manager;
+ isc_socketmgr_t *manager = thread->manager;
(void)manager;
bool done;
int cc;
- if (manager->nthreads > 1) {
- isc_thread_setaffinity(thread->threadid);
- }
#ifdef USE_KQUEUE
const char *fnname = "kevent()";
#elif defined(USE_EPOLL)
@@ -3653,18 +3621,14 @@ netthread(void *uap) {
}
void
-isc_socketmgr_setreserved(isc_socketmgr_t *manager0, uint32_t reserved) {
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
-
+isc_socketmgr_setreserved(isc_socketmgr_t *manager, uint32_t reserved) {
REQUIRE(VALID_MANAGER(manager));
manager->reserved = reserved;
}
void
-isc_socketmgr_maxudp(isc_socketmgr_t *manager0, unsigned int maxudp) {
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
-
+isc_socketmgr_maxudp(isc_socketmgr_t *manager, unsigned int maxudp) {
REQUIRE(VALID_MANAGER(manager));
manager->maxudp = maxudp;
@@ -3685,9 +3649,9 @@ setup_thread(isc__socketthread_t *thread) {
REQUIRE(thread->threadid >= 0 &&
thread->threadid < thread->manager->nthreads);
- thread->fds = isc_mem_get(thread->manager->mctx,
- thread->manager->maxsocks *
- sizeof(isc__socket_t *));
+ thread->fds =
+ isc_mem_get(thread->manager->mctx,
+ thread->manager->maxsocks * sizeof(isc_socket_t *));
memset(thread->fds, 0,
thread->manager->maxsocks * sizeof(isc_socket_t *));
@@ -3887,7 +3851,7 @@ cleanup_thread(isc_mem_t *mctx, isc__socketthread_t *thread) {
thread->manager->maxsocks * sizeof(uint32_t));
#endif /* if defined(USE_EPOLL) */
isc_mem_put(thread->manager->mctx, thread->fds,
- thread->manager->maxsocks * sizeof(isc__socket_t *));
+ thread->manager->maxsocks * sizeof(isc_socket_t *));
isc_mem_put(thread->manager->mctx, thread->fdstate,
thread->manager->maxsocks * sizeof(int));
@@ -3907,7 +3871,7 @@ isc_result_t
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks, int nthreads) {
int i;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
REQUIRE(managerp != NULL && *managerp == NULL);
@@ -3925,8 +3889,7 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
manager->nthreads = nthreads;
manager->stats = NULL;
- manager->common.magic = ISCAPI_SOCKETMGR_MAGIC;
- manager->common.impmagic = SOCKET_MANAGER_MAGIC;
+ manager->magic = SOCKET_MANAGER_MAGIC;
manager->mctx = NULL;
ISC_LIST_INIT(manager->socklist);
isc_mutex_init(&manager->lock);
@@ -3950,14 +3913,13 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
isc_thread_setname(manager->threads[i].thread, tname);
}
- *managerp = (isc_socketmgr_t *)manager;
+ *managerp = manager;
return (ISC_R_SUCCESS);
}
isc_result_t
-isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp) {
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
+isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp) {
REQUIRE(VALID_MANAGER(manager));
REQUIRE(nsockp != NULL);
@@ -3967,9 +3929,7 @@ isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp) {
}
void
-isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats) {
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
-
+isc_socketmgr_setstats(isc_socketmgr_t *manager, isc_stats_t *stats) {
REQUIRE(VALID_MANAGER(manager));
REQUIRE(ISC_LIST_EMPTY(manager->socklist));
REQUIRE(manager->stats == NULL);
@@ -3980,14 +3940,14 @@ isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats) {
void
isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
/*
* Destroy a socket manager.
*/
REQUIRE(managerp != NULL);
- manager = (isc__socketmgr_t *)*managerp;
+ manager = *managerp;
REQUIRE(VALID_MANAGER(manager));
LOCK(&manager->lock);
@@ -4029,15 +3989,14 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
isc_stats_detach(&manager->stats);
}
isc_mutex_destroy(&manager->lock);
- manager->common.magic = 0;
- manager->common.impmagic = 0;
+ manager->magic = 0;
isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager));
*managerp = NULL;
}
static isc_result_t
-socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
+socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
unsigned int flags) {
int io_state;
bool have_lock = false;
@@ -4114,11 +4073,10 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
}
isc_result_t
-isc_socket_recv(isc_socket_t *sock0, isc_region_t *region, unsigned int minimum,
+isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
isc_task_t *task, isc_taskaction_t action, void *arg) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
isc_socketevent_t *dev;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
REQUIRE(VALID_SOCKET(sock));
REQUIRE(action != NULL);
@@ -4134,15 +4092,13 @@ isc_socket_recv(isc_socket_t *sock0, isc_region_t *region, unsigned int minimum,
return (ISC_R_NOMEMORY);
}
- return (isc_socket_recv2(sock0, region, minimum, task, dev, 0));
+ return (isc_socket_recv2(sock, region, minimum, task, dev, 0));
}
isc_result_t
-isc_socket_recv2(isc_socket_t *sock0, isc_region_t *region,
- unsigned int minimum, isc_task_t *task,
- isc_socketevent_t *event, unsigned int flags) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_recv2(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
+ isc_task_t *task, isc_socketevent_t *event,
+ unsigned int flags) {
event->ev_sender = sock;
event->result = ISC_R_UNSET;
event->region = *region;
@@ -4167,7 +4123,7 @@ isc_socket_recv2(isc_socket_t *sock0, isc_region_t *region,
}
static isc_result_t
-socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
+socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
unsigned int flags) {
int io_state;
@@ -4278,12 +4234,11 @@ isc_socket_send(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
}
isc_result_t
-isc_socket_sendto(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
+isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
isc_socketevent_t *dev;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
REQUIRE(VALID_SOCKET(sock));
REQUIRE(region != NULL);
@@ -4307,11 +4262,9 @@ isc_socket_sendto(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
}
isc_result_t
-isc_socket_sendto2(isc_socket_t *sock0, isc_region_t *region, isc_task_t *task,
+isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
isc_socketevent_t *event, unsigned int flags) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
REQUIRE(VALID_SOCKET(sock));
REQUIRE((flags & ~(ISC_SOCKFLAG_IMMEDIATE | ISC_SOCKFLAG_NORETRY)) ==
0);
@@ -4504,9 +4457,8 @@ isc_socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
}
isc_result_t
-isc_socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr,
+isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
isc_socket_options_t options) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
char strbuf[ISC_STRERRORSIZE];
int on = 1;
@@ -4594,8 +4546,7 @@ bind_socket:
#undef ENABLE_ACCEPTFILTER
isc_result_t
-isc_socket_filter(isc_socket_t *sock0, const char *filter) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_filter(isc_socket_t *sock, const char *filter) {
#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER)
char strbuf[ISC_STRERRORSIZE];
struct accept_filter_arg afa;
@@ -4626,7 +4577,7 @@ isc_socket_filter(isc_socket_t *sock0, const char *filter) {
* Try enabling TCP Fast Open for a given socket if the OS supports it.
*/
static void
-set_tcp_fastopen(isc__socket_t *sock, unsigned int backlog) {
+set_tcp_fastopen(isc_socket_t *sock, unsigned int backlog) {
#if defined(ENABLE_TCP_FASTOPEN) && defined(TCP_FASTOPEN)
char strbuf[ISC_STRERRORSIZE];
@@ -4698,8 +4649,7 @@ set_tcp_fastopen(isc__socket_t *sock, unsigned int backlog) {
* as well keep things simple rather than having to track them.
*/
isc_result_t
-isc_socket_listen(isc_socket_t *sock0, unsigned int backlog) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
char strbuf[ISC_STRERRORSIZE];
REQUIRE(VALID_SOCKET(sock));
@@ -4736,13 +4686,12 @@ isc_socket_listen(isc_socket_t *sock0, unsigned int backlog) {
* This should try to do aggressive accept() XXXMLG
*/
isc_result_t
-isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
- isc_taskaction_t action, void *arg) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_accept(isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action,
+ void *arg) {
isc_socket_newconnev_t *dev;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
isc_task_t *ntask = NULL;
- isc__socket_t *nsock;
+ isc_socket_t *nsock;
isc_result_t result;
bool do_poke = false;
@@ -4786,7 +4735,7 @@ isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
nsock->statsindex = sock->statsindex;
dev->ev_sender = ntask;
- dev->newsocket = (isc_socket_t *)nsock;
+ dev->newsocket = nsock;
/*
* Poke watcher here. We still have the socket locked, so there
@@ -4804,12 +4753,11 @@ isc_socket_accept(isc_socket_t *sock0, isc_task_t *task,
}
isc_result_t
-isc_socket_connect(isc_socket_t *sock0, const isc_sockaddr_t *addr,
+isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action, void *arg) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
isc_socket_connev_t *dev;
isc_task_t *ntask = NULL;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
int cc;
char strbuf[ISC_STRERRORSIZE];
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
@@ -4967,7 +4915,7 @@ queue:
* Called when a socket with a pending connect() finishes.
*/
static void
-internal_connect(isc__socket_t *sock) {
+internal_connect(isc_socket_t *sock) {
isc_socket_connev_t *dev;
int cc;
isc_result_t result;
@@ -5068,8 +5016,7 @@ finish:
}
isc_result_t
-isc_socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_result_t result;
REQUIRE(VALID_SOCKET(sock));
@@ -5090,8 +5037,7 @@ isc_socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
}
isc_result_t
-isc_socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
socklen_t len;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
@@ -5128,9 +5074,7 @@ out:
* queued for task "task" of type "how". "how" is a bitmask.
*/
void
-isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
REQUIRE(VALID_SOCKET(sock));
/*
@@ -5210,7 +5154,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
isc_refcount_decrementz(
&NEWCONNSOCK(dev)->references);
- free_socket((isc__socket_t **)&dev->newsocket);
+ free_socket((isc_socket_t **)&dev->newsocket);
dev->result = ISC_R_CANCELED;
dev->ev_sender = sock;
@@ -5251,17 +5195,14 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
}
isc_sockettype_t
-isc_socket_gettype(isc_socket_t *sock0) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_gettype(isc_socket_t *sock) {
REQUIRE(VALID_SOCKET(sock));
return (sock->type);
}
void
-isc_socket_ipv6only(isc_socket_t *sock0, bool yes) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_ipv6only(isc_socket_t *sock, bool yes) {
#if defined(IPV6_V6ONLY)
int onoff = yes ? 1 : 0;
#else /* if defined(IPV6_V6ONLY) */
@@ -5289,7 +5230,7 @@ isc_socket_ipv6only(isc_socket_t *sock0, bool yes) {
}
static void
-setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
+setdscp(isc_socket_t *sock, isc_dscp_t dscp) {
#if defined(IP_TOS) || defined(IPV6_TCLASS)
int value = dscp << 2;
#endif /* if defined(IP_TOS) || defined(IPV6_TCLASS) */
@@ -5326,9 +5267,7 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) {
}
void
-isc_socket_dscp(isc_socket_t *sock0, isc_dscp_t dscp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
+isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(dscp < 0x40);
@@ -5359,9 +5298,7 @@ isc_socket_socketevent(isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype,
}
void
-isc_socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
- isc__socket_t *sock = (isc__socket_t *)socket0;
-
+isc_socket_setname(isc_socket_t *sock, const char *name, void *tag) {
/*
* Name 'sock'.
*/
@@ -5375,23 +5312,17 @@ isc_socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
}
const char *
-isc_socket_getname(isc_socket_t *socket0) {
- isc__socket_t *sock = (isc__socket_t *)socket0;
-
+isc_socket_getname(isc_socket_t *sock) {
return (sock->name);
}
void *
-isc_socket_gettag(isc_socket_t *socket0) {
- isc__socket_t *sock = (isc__socket_t *)socket0;
-
+isc_socket_gettag(isc_socket_t *sock) {
return (sock->tag);
}
int
-isc_socket_getfd(isc_socket_t *socket0) {
- isc__socket_t *sock = (isc__socket_t *)socket0;
-
+isc_socket_getfd(isc_socket_t *sock) {
return ((short)sock->fd);
}
@@ -5469,9 +5400,8 @@ _socktype(isc_sockettype_t type) {
goto error; \
} while (0)
int
-isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, void *writer0) {
- isc__socketmgr_t *mgr = (isc__socketmgr_t *)mgr0;
- isc__socket_t *sock = NULL;
+isc_socketmgr_renderxml(isc_socketmgr_t *mgr, void *writer0) {
+ isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
socklen_t len;
@@ -5577,10 +5507,9 @@ error:
} while (0)
isc_result_t
-isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, void *stats0) {
+isc_socketmgr_renderjson(isc_socketmgr_t *mgr, void *stats0) {
isc_result_t result = ISC_R_SUCCESS;
- isc__socketmgr_t *mgr = (isc__socketmgr_t *)mgr0;
- isc__socket_t *sock = NULL;
+ isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
socklen_t len;
@@ -5688,15 +5617,6 @@ error:
}
#endif /* HAVE_JSON_C */
-isc_result_t
-isc_socketmgr_createinctx(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
- isc_result_t result;
-
- result = isc_socketmgr_create(mctx, managerp);
-
- return (result);
-}
-
/*
* Create a new 'type' socket managed by 'manager'. Events
* will be posted to 'task' and when dispatched 'action' will be
@@ -5704,12 +5624,11 @@ isc_socketmgr_createinctx(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
* in 'socketp'.
*/
isc_result_t
-isc_socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags,
+isc_socket_fdwatchcreate(isc_socketmgr_t *manager, int fd, int flags,
isc_sockfdwatch_t callback, void *cbarg,
isc_task_t *task, isc_socket_t **socketp)
{
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
- isc__socket_t *sock = NULL;
+ isc_socket_t *sock = NULL;
isc__socketthread_t *thread;
isc_result_t result;
int lockid;
@@ -5783,10 +5702,8 @@ isc_socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags,
*/
isc_result_t
-isc_socket_fdwatchpoke(isc_socket_t *sock0, int flags)
+isc_socket_fdwatchpoke(isc_socket_t *sock, int flags)
{
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
REQUIRE(VALID_SOCKET(sock));
/*
diff --git a/external/mpl/bind/dist/lib/isc/url.c b/external/mpl/bind/dist/lib/isc/url.c
index 330bbc4626f..27df94e604b 100644
--- a/external/mpl/bind/dist/lib/isc/url.c
+++ b/external/mpl/bind/dist/lib/isc/url.c
@@ -1,4 +1,4 @@
-/* $NetBSD: url.c,v 1.1.1.1 2021/08/19 11:45:27 christos Exp $ */
+/* $NetBSD: url.c,v 1.2 2021/08/19 11:50:18 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
diff --git a/external/mpl/bind/dist/lib/isc/win32/DLLMain.c b/external/mpl/bind/dist/lib/isc/win32/DLLMain.c
index 76bf287b16c..cbf3e304f1f 100644
--- a/external/mpl/bind/dist/lib/isc/win32/DLLMain.c
+++ b/external/mpl/bind/dist/lib/isc/win32/DLLMain.c
@@ -1,4 +1,4 @@
-/* $NetBSD: DLLMain.c,v 1.6 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: DLLMain.c,v 1.7 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -15,7 +15,6 @@
#include <windows.h>
#include <isc/mem.h>
-#include <isc/tls.h>
#include <isc/util.h>
#include "lib_p.h"
diff --git a/external/mpl/bind/dist/lib/isc/win32/dir.c b/external/mpl/bind/dist/lib/isc/win32/dir.c
index 10110d5feff..f5579e55e03 100644
--- a/external/mpl/bind/dist/lib/isc/win32/dir.c
+++ b/external/mpl/bind/dist/lib/isc/win32/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.5 2021/02/19 16:42:21 christos Exp $ */
+/* $NetBSD: dir.c,v 1.6 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -275,7 +275,7 @@ isc_dir_createunique(char *templet) {
*/
p = x;
while (*p != '\0') {
- if (isdigit(*p & 0xff)) {
+ if (isdigit((unsigned char)*p)) {
*p = 'a';
} else if (*p != 'z') {
++*p;
diff --git a/external/mpl/bind/dist/lib/isc/win32/file.c b/external/mpl/bind/dist/lib/isc/win32/file.c
index 9f4519d4778..66cdee100dd 100644
--- a/external/mpl/bind/dist/lib/isc/win32/file.c
+++ b/external/mpl/bind/dist/lib/isc/win32/file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: file.c,v 1.6 2021/02/19 16:42:21 christos Exp $ */
+/* $NetBSD: file.c,v 1.7 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -104,7 +104,7 @@ gettemp(char *path, bool binary, int *doopen) {
if (*trv == 'z') {
*trv++ = 'a';
} else {
- if (isdigit(*trv)) {
+ if (isdigit((unsigned char)*trv)) {
*trv = 'a';
} else {
++*trv;
diff --git a/external/mpl/bind/dist/lib/isc/win32/include/isc/time.h b/external/mpl/bind/dist/lib/isc/win32/include/isc/time.h
index 626318b3123..74ead199d8a 100644
--- a/external/mpl/bind/dist/lib/isc/win32/include/isc/time.h
+++ b/external/mpl/bind/dist/lib/isc/win32/include/isc/time.h
@@ -1,4 +1,4 @@
-/* $NetBSD: time.h,v 1.6 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: time.h,v 1.7 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -27,25 +27,19 @@
*** POSIX Shims
***/
-inline struct tm *
-gmtime_r(const time_t *clock, struct tm *result) {
- errno_t ret = gmtime_s(result, clock);
- if (ret != 0) {
- errno = ret;
- return (NULL);
- }
- return (result);
-}
-
-inline struct tm *
-localtime_r(const time_t *clock, struct tm *result) {
- errno_t ret = localtime_s(result, clock);
- if (ret != 0) {
- errno = ret;
- return (NULL);
- }
- return (result);
-}
+struct tm *
+gmtime_r(const time_t *clock, struct tm *result);
+
+struct tm *
+localtime_r(const time_t *clock, struct tm *result);
+
+int
+nanosleep(const struct timespec *req, struct timespec *rem);
+
+typedef uint32_t useconds_t;
+
+int
+usleep(useconds_t usec);
/***
*** Intervals
diff --git a/external/mpl/bind/dist/lib/isc/win32/socket.c b/external/mpl/bind/dist/lib/isc/win32/socket.c
index 5627d77a601..fdb9ffd0802 100644
--- a/external/mpl/bind/dist/lib/isc/win32/socket.c
+++ b/external/mpl/bind/dist/lib/isc/win32/socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.c,v 1.10 2021/04/05 11:27:03 rillig Exp $ */
+/* $NetBSD: socket.c,v 1.11 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -339,7 +339,6 @@ struct isc_socketmgr {
HANDLE hIoCompletionPort;
int maxIOCPThreads;
HANDLE hIOCPThreads[MAX_IOCPTHREADS];
- DWORD dwIOCPThreadIds[MAX_IOCPTHREADS];
size_t maxudp;
/*
@@ -502,15 +501,8 @@ iocompletionport_createthreads(int total_threads, isc_socketmgr_t *manager) {
* We need at least one
*/
for (i = 0; i < total_threads; i++) {
- manager->hIOCPThreads[i] =
- CreateThread(NULL, 0, SocketIoThread, manager, 0,
- &manager->dwIOCPThreadIds[i]);
- if (manager->hIOCPThreads[i] == NULL) {
- errval = GetLastError();
- strerror_r(errval, strbuf, sizeof(strbuf));
- FATAL_ERROR(__FILE__, __LINE__,
- "Can't create IOCP thread: %s", strbuf);
- }
+ isc_thread_create(SocketIoThread, manager,
+ &manager->hIOCPThreads[i]);
}
}
@@ -3957,15 +3949,6 @@ error:
}
#endif /* HAVE_JSON_C */
-isc_result_t
-isc_socketmgr_createinctx(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
- isc_result_t result;
-
- result = isc_socketmgr_create(mctx, managerp);
-
- return (result);
-}
-
void
isc_socketmgr_maxudp(isc_socketmgr_t *manager, unsigned int maxudp) {
REQUIRE(VALID_MANAGER(manager));
diff --git a/external/mpl/bind/dist/lib/isc/win32/time.c b/external/mpl/bind/dist/lib/isc/win32/time.c
index 43c9c618753..77986371efd 100644
--- a/external/mpl/bind/dist/lib/isc/win32/time.c
+++ b/external/mpl/bind/dist/lib/isc/win32/time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: time.c,v 1.7 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: time.c,v 1.8 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -22,6 +22,7 @@
#include <windows.h>
#include <isc/assertions.h>
+#include <isc/once.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/tm.h>
@@ -545,3 +546,106 @@ isc_time_formatshorttimestamp(const isc_time_t *t, char *buf,
buf[0] = 0;
}
}
+
+/*
+ * POSIX Shims
+ */
+
+struct tm *
+gmtime_r(const time_t *clock, struct tm *result) {
+ errno_t ret = gmtime_s(result, clock);
+ if (ret != 0) {
+ errno = ret;
+ return (NULL);
+ }
+ return (result);
+}
+
+struct tm *
+localtime_r(const time_t *clock, struct tm *result) {
+ errno_t ret = localtime_s(result, clock);
+ if (ret != 0) {
+ errno = ret;
+ return (NULL);
+ }
+ return (result);
+}
+
+#define BILLION 1000000000
+
+static isc_once_t nsec_ticks_once = ISC_ONCE_INIT;
+static double nsec_ticks = 0;
+
+static void
+nsec_ticks_init(void) {
+ LARGE_INTEGER ticks;
+ RUNTIME_CHECK(QueryPerformanceFrequency(&ticks) != 0);
+ nsec_ticks = (double)ticks.QuadPart / 1000000000.0;
+ RUNTIME_CHECK(nsec_ticks != 0.0);
+}
+
+int
+nanosleep(const struct timespec *req, struct timespec *rem) {
+ int_fast64_t sleep_msec;
+ uint_fast64_t ticks, until;
+ LARGE_INTEGER before, after;
+
+ RUNTIME_CHECK(isc_once_do(&nsec_ticks_once, nsec_ticks_init) ==
+ ISC_R_SUCCESS);
+
+ if (req->tv_nsec < 0 || BILLION <= req->tv_nsec) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ /* Sleep() is not interruptible; there is no remaining delay ever */
+ if (rem != NULL) {
+ rem->tv_sec = 0;
+ rem->tv_nsec = 0;
+ }
+
+ if (req->tv_sec >= 0) {
+ /*
+ * For requested delays of one second or more, 15ms resolution
+ * granularity is sufficient.
+ */
+ Sleep(req->tv_sec * 1000 + req->tv_nsec / 1000000);
+
+ return (0);
+ }
+
+ /* Sleep has <-8,8> ms precision, so substract 10 milliseconds */
+ sleep_msec = (int64_t)req->tv_nsec / 1000000 - 10;
+ ticks = req->tv_nsec * nsec_ticks;
+
+ RUNTIME_CHECK(QueryPerformanceCounter(&before) != 0);
+
+ until = before.QuadPart + ticks;
+
+ if (sleep_msec > 0) {
+ Sleep(sleep_msec);
+ }
+
+ while (true) {
+ LARGE_INTEGER after;
+ RUNTIME_CHECK(QueryPerformanceCounter(&after) != 0);
+ if (after.QuadPart >= until) {
+ break;
+ }
+ }
+
+done:
+ return (0);
+}
+
+int
+usleep(useconds_t useconds) {
+ struct timespec req;
+
+ req.tv_sec = useconds / 1000000;
+ req.tv_nsec = (useconds * 1000) % 1000000000;
+
+ nanosleep(&req, NULL);
+
+ return (0);
+}
diff --git a/external/mpl/bind/dist/lib/isccfg/kaspconf.c b/external/mpl/bind/dist/lib/isccfg/kaspconf.c
index 29a8bb696c6..3b7af5b39da 100644
--- a/external/mpl/bind/dist/lib/isccfg/kaspconf.c
+++ b/external/mpl/bind/dist/lib/isccfg/kaspconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kaspconf.c,v 1.4 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: kaspconf.c,v 1.5 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,6 +24,7 @@
#include <dns/kasp.h>
#include <dns/keyvalues.h>
#include <dns/log.h>
+#include <dns/nsec3.h>
#include <dns/result.h>
#include <dns/secalg.h>
@@ -215,12 +216,7 @@ cfg_nsec3param_fromconfig(const cfg_obj_t *config, dns_kasp_t *kasp,
return (DNS_R_NSEC3BADALG);
}
- /* See RFC 5155 Section 10.3 for iteration limits. */
- if (min_keysize <= 1024 && iter > 150) {
- ret = DNS_R_NSEC3ITERRANGE;
- } else if (min_keysize <= 2048 && iter > 500) {
- ret = DNS_R_NSEC3ITERRANGE;
- } else if (min_keysize <= 4096 && iter > 2500) {
+ if (iter > dns_nsec3_maxiterations()) {
ret = DNS_R_NSEC3ITERRANGE;
}
@@ -332,9 +328,9 @@ cfg_kasp_fromconfig(const cfg_obj_t *config, const char *name, isc_mem_t *mctx,
}
}
INSIST(!(dns_kasp_keylist_empty(kasp)));
- } else if (strcmp(kaspname, "none") == 0) {
- /* "dnssec-policy none": key list must be empty */
- INSIST(strcmp(kaspname, "none") == 0);
+ } else if (strcmp(kaspname, "insecure") == 0) {
+ /* "dnssec-policy insecure": key list must be empty */
+ INSIST(strcmp(kaspname, "insecure") == 0);
INSIST(dns_kasp_keylist_empty(kasp));
} else {
/* No keys clause configured, use the "default". */
diff --git a/external/mpl/bind/dist/lib/isccfg/namedconf.c b/external/mpl/bind/dist/lib/isccfg/namedconf.c
index e6f0b8b6e08..541b0756993 100644
--- a/external/mpl/bind/dist/lib/isccfg/namedconf.c
+++ b/external/mpl/bind/dist/lib/isccfg/namedconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: namedconf.c,v 1.11 2021/04/29 17:26:13 christos Exp $ */
+/* $NetBSD: namedconf.c,v 1.12 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -101,7 +101,7 @@ static cfg_type_t cfg_type_logging;
static cfg_type_t cfg_type_logseverity;
static cfg_type_t cfg_type_logsuffix;
static cfg_type_t cfg_type_logversions;
-static cfg_type_t cfg_type_primarieselement;
+static cfg_type_t cfg_type_remoteselement;
static cfg_type_t cfg_type_maxduration;
static cfg_type_t cfg_type_minimal;
static cfg_type_t cfg_type_nameportiplist;
@@ -169,8 +169,8 @@ static cfg_type_t cfg_type_acl = { "acl", cfg_parse_tuple,
cfg_print_tuple, cfg_doc_tuple,
&cfg_rep_tuple, acl_fields };
-/*% primaries */
-static cfg_tuplefielddef_t primaries_fields[] = {
+/*% remote servers, used for primaries and parental agents */
+static cfg_tuplefielddef_t remotes_fields[] = {
{ "name", &cfg_type_astring, 0 },
{ "port", &cfg_type_optional_port, 0 },
{ "dscp", &cfg_type_optional_dscp, 0 },
@@ -178,19 +178,19 @@ static cfg_tuplefielddef_t primaries_fields[] = {
{ NULL, NULL, 0 }
};
-static cfg_type_t cfg_type_primaries = { "primaries", cfg_parse_tuple,
- cfg_print_tuple, cfg_doc_tuple,
- &cfg_rep_tuple, primaries_fields };
+static cfg_type_t cfg_type_remoteservers = { "remote-servers", cfg_parse_tuple,
+ cfg_print_tuple, cfg_doc_tuple,
+ &cfg_rep_tuple, remotes_fields };
/*%
* "sockaddrkeylist", a list of socket addresses with optional keys
- * and an optional default port, as used in the primaries option.
+ * and an optional default port, as used in the remote-servers option.
* E.g.,
- * "port 1234 { myprimaries; 10.0.0.1 key foo; 1::2 port 69; }"
+ * "port 1234 { myservers; 10.0.0.1 key foo; 1::2 port 69; }"
*/
static cfg_tuplefielddef_t namesockaddrkey_fields[] = {
- { "primarieselement", &cfg_type_primarieselement, 0 },
+ { "remoteselement", &cfg_type_remoteselement, 0 },
{ "key", &cfg_type_optional_keyref, 0 },
{ NULL, NULL, 0 },
};
@@ -1103,9 +1103,10 @@ static cfg_clausedef_t namedconf_clauses[] = {
{ "logging", &cfg_type_logging, 0 },
{ "lwres", &cfg_type_bracketed_text,
CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE },
- { "masters", &cfg_type_primaries, CFG_CLAUSEFLAG_MULTI },
+ { "masters", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
{ "options", &cfg_type_options, 0 },
- { "primaries", &cfg_type_primaries, CFG_CLAUSEFLAG_MULTI },
+ { "parental-agents", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
+ { "primaries", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
{ "statistics-channels", &cfg_type_statschannels,
CFG_CLAUSEFLAG_MULTI },
{ "view", &cfg_type_view, CFG_CLAUSEFLAG_MULTI },
@@ -2219,8 +2220,6 @@ static cfg_clausedef_t zone_clauses[] = {
{ "forwarders", &cfg_type_portiplist,
CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_STUB |
CFG_ZONE_STATICSTUB | CFG_ZONE_FORWARD },
- { "inline-signing", &cfg_type_boolean,
- CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "key-directory", &cfg_type_qstring,
CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "maintain-ixfr-base", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT },
@@ -2270,6 +2269,10 @@ static cfg_clausedef_t zone_clauses[] = {
CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "nsec3-test-zone", &cfg_type_boolean,
CFG_CLAUSEFLAG_TESTONLY | CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
+ { "parental-source", &cfg_type_sockaddr4wild,
+ CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
+ { "parental-source-v6", &cfg_type_sockaddr6wild,
+ CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "request-expire", &cfg_type_boolean,
CFG_ZONE_SLAVE | CFG_ZONE_MIRROR },
{ "request-ixfr", &cfg_type_boolean, CFG_ZONE_SLAVE | CFG_ZONE_MIRROR },
@@ -2330,6 +2333,8 @@ static cfg_clausedef_t zone_only_clauses[] = {
CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR | CFG_ZONE_STUB |
CFG_ZONE_HINT | CFG_ZONE_REDIRECT },
{ "in-view", &cfg_type_astring, CFG_ZONE_INVIEW },
+ { "inline-signing", &cfg_type_boolean,
+ CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "ixfr-base", &cfg_type_qstring, CFG_CLAUSEFLAG_ANCIENT },
{ "ixfr-from-differences", &cfg_type_boolean,
CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR },
@@ -2339,6 +2344,8 @@ static cfg_clausedef_t zone_only_clauses[] = {
{ "masters", &cfg_type_namesockaddrkeylist,
CFG_ZONE_SLAVE | CFG_ZONE_MIRROR | CFG_ZONE_STUB |
CFG_ZONE_REDIRECT },
+ { "parental-agents", &cfg_type_namesockaddrkeylist,
+ CFG_ZONE_MASTER | CFG_ZONE_SLAVE },
{ "primaries", &cfg_type_namesockaddrkeylist,
CFG_ZONE_SLAVE | CFG_ZONE_MIRROR | CFG_ZONE_STUB |
CFG_ZONE_REDIRECT },
@@ -3693,10 +3700,10 @@ static cfg_type_t cfg_type_nameportiplist = {
*/
static void
-doc_primarieselement(cfg_printer_t *pctx, const cfg_type_t *type) {
+doc_remoteselement(cfg_printer_t *pctx, const cfg_type_t *type) {
UNUSED(type);
cfg_print_cstr(pctx, "( ");
- cfg_print_cstr(pctx, "<primaries>");
+ cfg_print_cstr(pctx, "<remote-servers>");
cfg_print_cstr(pctx, " | ");
cfg_print_cstr(pctx, "<ipv4_address>");
cfg_print_cstr(pctx, " ");
@@ -3709,8 +3716,8 @@ doc_primarieselement(cfg_printer_t *pctx, const cfg_type_t *type) {
}
static isc_result_t
-parse_primarieselement(cfg_parser_t *pctx, const cfg_type_t *type,
- cfg_obj_t **ret) {
+parse_remoteselement(cfg_parser_t *pctx, const cfg_type_t *type,
+ cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
UNUSED(type);
@@ -3728,7 +3735,8 @@ parse_primarieselement(cfg_parser_t *pctx, const cfg_type_t *type,
}
} else {
cfg_parser_error(pctx, CFG_LOG_NEAR,
- "expected IP address or primaries list name");
+ "expected IP address or remote servers list "
+ "name");
return (ISC_R_UNEXPECTEDTOKEN);
}
cleanup:
@@ -3736,12 +3744,12 @@ cleanup:
return (result);
}
-static cfg_type_t cfg_type_primarieselement = { "primaries_element",
- parse_primarieselement,
- NULL,
- doc_primarieselement,
- NULL,
- NULL };
+static cfg_type_t cfg_type_remoteselement = { "remotes_element",
+ parse_remoteselement,
+ NULL,
+ doc_remoteselement,
+ NULL,
+ NULL };
static int
cmp_clause(const void *ap, const void *bp) {
diff --git a/external/mpl/bind/dist/lib/ns/client.c b/external/mpl/bind/dist/lib/ns/client.c
index 6edb15e38c9..8632c5104a0 100644
--- a/external/mpl/bind/dist/lib/ns/client.c
+++ b/external/mpl/bind/dist/lib/ns/client.c
@@ -1,4 +1,4 @@
-/* $NetBSD: client.c,v 1.15 2021/04/29 17:26:14 christos Exp $ */
+/* $NetBSD: client.c,v 1.16 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -128,10 +128,12 @@
* Number of tasks to be used by clients - those are used only when recursing
*/
-#if (defined(_WIN32) && !defined(_WIN64)) || !defined(_LP64)
-LIBNS_EXTERNAL_DATA atomic_uint_fast32_t ns_client_requests;
+#if defined(_WIN32) && !defined(_WIN64) || !defined(_LP64)
+LIBNS_EXTERNAL_DATA atomic_uint_fast32_t ns_client_requests =
+ ATOMIC_VAR_INIT(0);
#else /* if defined(_WIN32) && !defined(_WIN64) */
-LIBNS_EXTERNAL_DATA atomic_uint_fast64_t ns_client_requests;
+LIBNS_EXTERNAL_DATA atomic_uint_fast64_t ns_client_requests =
+ ATOMIC_VAR_INIT(0);
#endif /* if defined(_WIN32) && !defined(_WIN64) */
static void
@@ -279,13 +281,33 @@ client_senddone(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
REQUIRE(client->sendhandle == handle);
CTRACE("senddone");
+
+ /*
+ * Set sendhandle to NULL, but don't detach it immediately, in
+ * case we need to retry the send. If we do resend, then
+ * sendhandle will be reattached. Whether or not we resend,
+ * we will then detach the handle from *this* send by detaching
+ * 'handle' directly below.
+ */
+ client->sendhandle = NULL;
+
if (result != ISC_R_SUCCESS) {
- ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
- NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
- "send failed: %s", isc_result_totext(result));
+ if (!TCP_CLIENT(client) && result == ISC_R_MAXSIZE) {
+ ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
+ NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
+ "send exceeded maximum size: truncating");
+ client->query.attributes &= ~NS_QUERYATTR_ANSWERED;
+ client->rcode_override = dns_rcode_noerror;
+ ns_client_error(client, ISC_R_MAXSIZE);
+ } else {
+ ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
+ NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
+ "send failed: %s",
+ isc_result_totext(result));
+ }
}
- isc_nmhandle_detach(&client->sendhandle);
+ isc_nmhandle_detach(&handle);
}
static void
@@ -721,8 +743,9 @@ ns_client_dropport(in_port_t port) {
void
ns_client_error(ns_client_t *client, isc_result_t result) {
+ dns_message_t *message = NULL;
dns_rcode_t rcode;
- dns_message_t *message;
+ bool trunc = false;
REQUIRE(NS_CLIENT_VALID(client));
@@ -736,6 +759,10 @@ ns_client_error(ns_client_t *client, isc_result_t result) {
rcode = (dns_rcode_t)(client->rcode_override & 0xfff);
}
+ if (result == ISC_R_MAXSIZE) {
+ trunc = true;
+ }
+
#if NS_CLIENT_DROPPORT
/*
* Don't send FORMERR to ports on the drop port list.
@@ -769,8 +796,6 @@ ns_client_error(ns_client_t *client, isc_result_t result) {
dns_rrl_result_t rrl_result;
int loglevel;
- INSIST(rcode != dns_rcode_noerror &&
- rcode != dns_rcode_nxdomain);
if ((client->sctx->options & NS_SERVER_LOGQUERIES) != 0) {
loglevel = DNS_RRL_LOG_DROP;
} else {
@@ -832,7 +857,11 @@ ns_client_error(ns_client_t *client, isc_result_t result) {
return;
}
}
+
message->rcode = rcode;
+ if (trunc) {
+ message->flags |= DNS_MESSAGEFLAG_TC;
+ }
if (rcode == dns_rcode_formerr) {
/*
@@ -1624,15 +1653,13 @@ ns__client_put_cb(void *client0) {
void
ns__client_request(isc_nmhandle_t *handle, isc_result_t eresult,
isc_region_t *region, void *arg) {
- ns_client_t *client;
- ns_clientmgr_t *mgr;
- ns_interface_t *ifp;
+ ns_client_t *client = NULL;
isc_result_t result;
isc_result_t sigresult = ISC_R_SUCCESS;
- isc_buffer_t *buffer;
+ isc_buffer_t *buffer = NULL;
isc_buffer_t tbuffer;
- dns_rdataset_t *opt;
- const dns_name_t *signame;
+ dns_rdataset_t *opt = NULL;
+ const dns_name_t *signame = NULL;
bool ra; /* Recursion available. */
isc_netaddr_t netaddr;
int match;
@@ -1640,29 +1667,24 @@ ns__client_request(isc_nmhandle_t *handle, isc_result_t eresult,
unsigned int flags;
bool notimp;
size_t reqsize;
- dns_aclenv_t *env;
+ dns_aclenv_t *env = NULL;
#ifdef HAVE_DNSTAP
dns_dtmsgtype_t dtmsgtype;
#endif /* ifdef HAVE_DNSTAP */
- ifp = (ns_interface_t *)arg;
if (eresult != ISC_R_SUCCESS) {
return;
}
- mgr = ifp->clientmgr;
- if (mgr == NULL) {
- /* The interface was shut down in the meantime, just bail */
- return;
- }
-
- REQUIRE(VALID_MANAGER(mgr));
-
client = isc_nmhandle_getdata(handle);
if (client == NULL) {
+ ns_interface_t *ifp = (ns_interface_t *)arg;
+
+ INSIST(VALID_MANAGER(ifp->clientmgr));
+
client = isc_nmhandle_getextra(handle);
- result = ns__client_setup(client, mgr, true);
+ result = ns__client_setup(client, ifp->clientmgr, true);
if (result != ISC_R_SUCCESS) {
return;
}
@@ -2880,11 +2902,10 @@ ns_client_putrdataset(ns_client_t *client, dns_rdataset_t **rdatasetp) {
isc_result_t
ns_client_newnamebuf(ns_client_t *client) {
- isc_buffer_t *dbuf;
+ isc_buffer_t *dbuf = NULL;
CTRACE("ns_client_newnamebuf");
- dbuf = NULL;
isc_buffer_allocate(client->mctx, &dbuf, 1024);
ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
@@ -2894,7 +2915,7 @@ ns_client_newnamebuf(ns_client_t *client) {
dns_name_t *
ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
- dns_name_t *name;
+ dns_name_t *name = NULL;
isc_region_t r;
isc_result_t result;
@@ -2902,7 +2923,6 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
CTRACE("ns_client_newname");
- name = NULL;
result = dns_message_gettempname(client->message, &name);
if (result != ISC_R_SUCCESS) {
CTRACE("ns_client_newname: "
@@ -2911,7 +2931,7 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
}
isc_buffer_availableregion(dbuf, &r);
isc_buffer_init(nbuf, r.base, r.length);
- dns_name_init(name, NULL);
+ dns_name_setbuffer(name, NULL);
dns_name_setbuffer(name, nbuf);
client->query.attributes |= NS_QUERYATTR_NAMEBUFUSED;
@@ -2922,7 +2942,6 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
isc_buffer_t *
ns_client_getnamebuf(ns_client_t *client) {
isc_buffer_t *dbuf;
- isc_result_t result;
isc_region_t r;
CTRACE("ns_client_getnamebuf");
@@ -2932,24 +2951,14 @@ ns_client_getnamebuf(ns_client_t *client) {
* a new one if necessary.
*/
if (ISC_LIST_EMPTY(client->query.namebufs)) {
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- CTRACE("ns_client_getnamebuf: "
- "ns_client_newnamebuf failed: done");
- return (NULL);
- }
+ ns_client_newnamebuf(client);
}
dbuf = ISC_LIST_TAIL(client->query.namebufs);
INSIST(dbuf != NULL);
isc_buffer_availableregion(dbuf, &r);
if (r.length < DNS_NAME_MAXWIRE) {
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- CTRACE("ns_client_getnamebuf: "
- "ns_client_newnamebuf failed: done");
- return (NULL);
- }
+ ns_client_newnamebuf(client);
dbuf = ISC_LIST_TAIL(client->query.namebufs);
isc_buffer_availableregion(dbuf, &r);
INSIST(r.length >= 255);
@@ -2978,8 +2987,6 @@ ns_client_keepname(ns_client_t *client, dns_name_t *name, isc_buffer_t *dbuf) {
void
ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
- dns_name_t *name = *namep;
-
/*%
* 'name' is no longer needed. Return it to our pool of temporary
* names. If it is using a name buffer, relinquish its exclusive
@@ -2987,11 +2994,7 @@ ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
*/
CTRACE("ns_client_releasename");
- if (dns_name_hasbuffer(name)) {
- INSIST((client->query.attributes & NS_QUERYATTR_NAMEBUFUSED) !=
- 0);
- client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
- }
+ client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
dns_message_puttempname(client->message, namep);
CTRACE("ns_client_releasename: done");
}
@@ -2999,16 +3002,13 @@ ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
isc_result_t
ns_client_newdbversion(ns_client_t *client, unsigned int n) {
unsigned int i;
- ns_dbversion_t *dbversion;
+ ns_dbversion_t *dbversion = NULL;
for (i = 0; i < n; i++) {
dbversion = isc_mem_get(client->mctx, sizeof(*dbversion));
- {
- dbversion->db = NULL;
- dbversion->version = NULL;
- ISC_LIST_INITANDAPPEND(client->query.freeversions,
- dbversion, link);
- }
+ *dbversion = (ns_dbversion_t){ 0 };
+ ISC_LIST_INITANDAPPEND(client->query.freeversions, dbversion,
+ link);
}
return (ISC_R_SUCCESS);
@@ -3016,14 +3016,10 @@ ns_client_newdbversion(ns_client_t *client, unsigned int n) {
static inline ns_dbversion_t *
client_getdbversion(ns_client_t *client) {
- isc_result_t result;
- ns_dbversion_t *dbversion;
+ ns_dbversion_t *dbversion = NULL;
if (ISC_LIST_EMPTY(client->query.freeversions)) {
- result = ns_client_newdbversion(client, 1);
- if (result != ISC_R_SUCCESS) {
- return (NULL);
- }
+ ns_client_newdbversion(client, 1);
}
dbversion = ISC_LIST_HEAD(client->query.freeversions);
INSIST(dbversion != NULL);
diff --git a/external/mpl/bind/dist/lib/ns/include/ns/query.h b/external/mpl/bind/dist/lib/ns/include/ns/query.h
index c9b5d32fddf..3c6b06bcd10 100644
--- a/external/mpl/bind/dist/lib/ns/include/ns/query.h
+++ b/external/mpl/bind/dist/lib/ns/include/ns/query.h
@@ -1,4 +1,4 @@
-/* $NetBSD: query.h,v 1.5 2021/02/19 16:42:22 christos Exp $ */
+/* $NetBSD: query.h,v 1.6 2021/08/19 11:50:20 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -100,25 +100,26 @@ struct ns_query {
bool root_key_sentinel_not_ta;
};
-#define NS_QUERYATTR_RECURSIONOK 0x00001
-#define NS_QUERYATTR_CACHEOK 0x00002
-#define NS_QUERYATTR_PARTIALANSWER 0x00004
-#define NS_QUERYATTR_NAMEBUFUSED 0x00008
-#define NS_QUERYATTR_RECURSING 0x00010
-#define NS_QUERYATTR_QUERYOKVALID 0x00040
-#define NS_QUERYATTR_QUERYOK 0x00080
-#define NS_QUERYATTR_WANTRECURSION 0x00100
-#define NS_QUERYATTR_SECURE 0x00200
-#define NS_QUERYATTR_NOAUTHORITY 0x00400
-#define NS_QUERYATTR_NOADDITIONAL 0x00800
-#define NS_QUERYATTR_CACHEACLOKVALID 0x01000
-#define NS_QUERYATTR_CACHEACLOK 0x02000
-#define NS_QUERYATTR_DNS64 0x04000
-#define NS_QUERYATTR_DNS64EXCLUDE 0x08000
-#define NS_QUERYATTR_RRL_CHECKED 0x10000
-#define NS_QUERYATTR_REDIRECT 0x20000
-#define NS_QUERYATTR_ANSWERED 0x40000
-#define NS_QUERYATTR_STALEOK 0x80000
+#define NS_QUERYATTR_RECURSIONOK 0x000001
+#define NS_QUERYATTR_CACHEOK 0x000002
+#define NS_QUERYATTR_PARTIALANSWER 0x000004
+#define NS_QUERYATTR_NAMEBUFUSED 0x000008
+#define NS_QUERYATTR_RECURSING 0x000010
+#define NS_QUERYATTR_QUERYOKVALID 0x000040
+#define NS_QUERYATTR_QUERYOK 0x000080
+#define NS_QUERYATTR_WANTRECURSION 0x000100
+#define NS_QUERYATTR_SECURE 0x000200
+#define NS_QUERYATTR_NOAUTHORITY 0x000400
+#define NS_QUERYATTR_NOADDITIONAL 0x000800
+#define NS_QUERYATTR_CACHEACLOKVALID 0x001000
+#define NS_QUERYATTR_CACHEACLOK 0x002000
+#define NS_QUERYATTR_DNS64 0x004000
+#define NS_QUERYATTR_DNS64EXCLUDE 0x008000
+#define NS_QUERYATTR_RRL_CHECKED 0x010000
+#define NS_QUERYATTR_REDIRECT 0x020000
+#define NS_QUERYATTR_ANSWERED 0x040000
+#define NS_QUERYATTR_STALEOK 0x080000
+#define NS_QUERYATTR_STALEPENDING 0x100000
typedef struct query_ctx query_ctx_t;
diff --git a/external/mpl/bind/dist/lib/ns/interfacemgr.c b/external/mpl/bind/dist/lib/ns/interfacemgr.c
index 13457571599..a963136a4fc 100644
--- a/external/mpl/bind/dist/lib/ns/interfacemgr.c
+++ b/external/mpl/bind/dist/lib/ns/interfacemgr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: interfacemgr.c,v 1.12 2021/04/29 17:26:14 christos Exp $ */
+/* $NetBSD: interfacemgr.c,v 1.13 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -457,8 +457,8 @@ ns_interface_listenudp(ns_interface_t *ifp) {
isc_result_t result;
/* Reserve space for an ns_client_t with the netmgr handle */
- result = isc_nm_listenudp(ifp->mgr->nm, (isc_nmiface_t *)&ifp->addr,
- ns__client_request, ifp, sizeof(ns_client_t),
+ result = isc_nm_listenudp(ifp->mgr->nm, &ifp->addr, ns__client_request,
+ ifp, sizeof(ns_client_t),
&ifp->udplistensocket);
return (result);
}
@@ -468,10 +468,9 @@ ns_interface_listentcp(ns_interface_t *ifp) {
isc_result_t result;
result = isc_nm_listentcpdns(
- ifp->mgr->nm, (isc_nmiface_t *)&ifp->addr, ns__client_request,
- ifp, ns__client_tcpconn, ifp, sizeof(ns_client_t),
- ifp->mgr->backlog, &ifp->mgr->sctx->tcpquota,
- &ifp->tcplistensocket);
+ ifp->mgr->nm, &ifp->addr, ns__client_request, ifp,
+ ns__client_tcpconn, ifp, sizeof(ns_client_t), ifp->mgr->backlog,
+ &ifp->mgr->sctx->tcpquota, &ifp->tcplistensocket);
if (result != ISC_R_SUCCESS) {
isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_ERROR,
"creating TCP socket: %s",
diff --git a/external/mpl/bind/dist/lib/ns/query.c b/external/mpl/bind/dist/lib/ns/query.c
index 2c8e72bc976..ad9db5fbdfd 100644
--- a/external/mpl/bind/dist/lib/ns/query.c
+++ b/external/mpl/bind/dist/lib/ns/query.c
@@ -1,4 +1,4 @@
-/* $NetBSD: query.c,v 1.13 2021/04/29 17:26:14 christos Exp $ */
+/* $NetBSD: query.c,v 1.14 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -13,6 +13,7 @@
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
@@ -136,9 +137,13 @@
#define REDIRECT(c) (((c)->query.attributes & NS_QUERYATTR_REDIRECT) != 0)
-/*% Was the query already answered due to stale-answer-client-timeout? */
+/*% Was the client already sent a response? */
#define QUERY_ANSWERED(q) (((q)->attributes & NS_QUERYATTR_ANSWERED) != 0)
+/*% Have we already processed an answer via stale-answer-client-timeout? */
+#define QUERY_STALEPENDING(q) \
+ (((q)->attributes & NS_QUERYATTR_STALEPENDING) != 0)
+
/*% Does the query allow stale data in the response? */
#define QUERY_STALEOK(q) (((q)->attributes & NS_QUERYATTR_STALEOK) != 0)
@@ -779,7 +784,7 @@ ns_query_free(ns_client_t *client) {
isc_result_t
ns_query_init(ns_client_t *client) {
- isc_result_t result;
+ isc_result_t result = ISC_R_SUCCESS;
REQUIRE(NS_CLIENT_VALID(client));
@@ -818,16 +823,8 @@ ns_query_init(ns_client_t *client) {
client->query.redirect.fname =
dns_fixedname_initname(&client->query.redirect.fixed);
query_reset(client, false);
- result = ns_client_newdbversion(client, 3);
- if (result != ISC_R_SUCCESS) {
- isc_mutex_destroy(&client->query.fetchlock);
- return (result);
- }
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- query_freefreeversions(client, true);
- isc_mutex_destroy(&client->query.fetchlock);
- }
+ ns_client_newdbversion(client, 3);
+ ns_client_newnamebuf(client);
return (result);
}
@@ -5294,7 +5291,7 @@ get_root_key_sentinel_id(query_ctx_t *qctx, const char *ndata) {
int i;
for (i = 0; i < 5; i++) {
- if (ndata[i] < '0' || ndata[i] > '9') {
+ if (!isdigit((unsigned char)ndata[i])) {
return (false);
}
v *= 10;
@@ -5821,6 +5818,7 @@ query_lookup(query_ctx_t *qctx) {
{
qctx->rdataset->ttl = qctx->view->staleanswerttl;
stale_found = true;
+ inc_stats(qctx->client, ns_statscounter_usedstale);
} else {
stale_found = false;
}
@@ -5859,9 +5857,6 @@ query_lookup(query_ctx_t *qctx) {
return (ns_query_done(qctx));
}
} else if (stale_timeout) {
- qctx->client->query.attributes |= NS_QUERYATTR_STALEOK;
- qctx->rdataset->attributes |= DNS_RDATASETATTR_STALE_ADDED;
-
if ((qctx->options & DNS_GETDB_STALEFIRST) != 0) {
if (!stale_found) {
/*
@@ -5879,7 +5874,7 @@ query_lookup(query_ctx_t *qctx) {
dns_resolver_destroyfetch(
&qctx->client->query.fetch);
}
- return query_lookup(qctx);
+ return (query_lookup(qctx));
} else {
/*
* Immediately return the stale answer, start a
@@ -5908,6 +5903,13 @@ query_lookup(query_ctx_t *qctx) {
if (!stale_found) {
return (result);
}
+
+ /*
+ * There still might be real answer later. Mark the
+ * query so we'll know we can skip answering.
+ */
+ qctx->client->query.attributes |=
+ NS_QUERYATTR_STALEPENDING;
}
}
@@ -5920,6 +5922,7 @@ query_lookup(query_ctx_t *qctx) {
qctx->client->query.attributes |= NS_QUERYATTR_STALEOK;
qctx->rdataset->attributes |= DNS_RDATASETATTR_STALE_ADDED;
}
+
result = query_gotanswer(qctx, result);
if (refresh_rrset) {
@@ -6025,10 +6028,12 @@ static void
fetch_callback(isc_task_t *task, isc_event_t *event) {
dns_fetchevent_t *devent = (dns_fetchevent_t *)event;
dns_fetch_t *fetch = NULL;
- ns_client_t *client;
- bool fetch_canceled, client_shuttingdown;
- isc_result_t result;
+ ns_client_t *client = NULL;
+ bool fetch_canceled = false;
+ bool fetch_answered = false;
+ bool client_shuttingdown = false;
isc_logcategory_t *logcategory = NS_LOGCATEGORY_QUERY_ERRORS;
+ isc_result_t result;
int errorloglevel;
query_ctx_t qctx;
@@ -6036,7 +6041,9 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
REQUIRE(event->ev_type == DNS_EVENT_FETCHDONE ||
event->ev_type == DNS_EVENT_TRYSTALE);
+
client = devent->ev_arg;
+
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->task);
REQUIRE(RECURSING(client));
@@ -6048,7 +6055,6 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
isc_event_free(ISC_EVENT_PTR(&event));
return;
}
-
/*
* We are resuming from recursion. Reset any attributes, options
* that a lookup due to stale-answer-client-timeout may have set.
@@ -6056,17 +6062,28 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
if (client->view->cachedb != NULL && client->view->recursion) {
client->query.attributes |= NS_QUERYATTR_RECURSIONOK;
}
+ client->query.fetchoptions &= ~DNS_FETCHOPT_TRYSTALE_ONTIMEOUT;
client->query.dboptions &= ~DNS_DBFIND_STALETIMEOUT;
client->nodetach = false;
LOCK(&client->query.fetchlock);
- if (client->query.fetch != NULL) {
+ INSIST(client->query.fetch == devent->fetch ||
+ client->query.fetch == NULL);
+ if (QUERY_STALEPENDING(&client->query)) {
+ /*
+ * We've gotten an authoritative answer to a query that
+ * was left pending after a stale timeout. We don't need
+ * to do anything with it; free all the data and go home.
+ */
+ client->query.fetch = NULL;
+ fetch_answered = true;
+ } else if (client->query.fetch != NULL) {
/*
* This is the fetch we've been waiting for.
*/
INSIST(devent->fetch == client->query.fetch);
client->query.fetch = NULL;
- fetch_canceled = false;
+
/*
* Update client->now.
*/
@@ -6079,7 +6096,6 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
fetch_canceled = true;
}
UNLOCK(&client->query.fetchlock);
- INSIST(client->query.fetch == NULL);
SAVE(fetch, devent->fetch);
@@ -6122,7 +6138,7 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
qctx_init(client, &devent, 0, &qctx);
client_shuttingdown = ns_client_shuttingdown(client);
- if (fetch_canceled || client_shuttingdown) {
+ if (fetch_canceled || fetch_answered || client_shuttingdown) {
/*
* We've timed out or are shutting down. We can now
* free the event and other resources held by qctx, but
@@ -7749,7 +7765,7 @@ query_addanswer(query_ctx_t *qctx) {
* We can clear the attribute to prevent redundant clearing
* in subsequent lookups.
*/
- qctx->client->query.attributes &= ~DNS_RDATASETATTR_STALE_ADDED;
+ qctx->client->query.attributes &= ~NS_QUERYATTR_STALEOK;
}
if (qctx->dns64) {
@@ -8404,7 +8420,7 @@ query_prepare_delegation_response(query_ctx_t *qctx) {
}
/*
- * Add a DS if needed.
+ * Add DS/NSEC(3) record(s) if needed.
*/
query_addds(qctx);
@@ -8662,7 +8678,7 @@ cleanup:
}
/*%
- * Add a DS record if needed.
+ * Add DS/NSEC(3) record(s) if needed.
*/
static void
query_addds(query_ctx_t *qctx) {
@@ -8719,26 +8735,40 @@ query_addds(query_ctx_t *qctx) {
/*
* We've already added the NS record, so if the name's not there,
- * we have other problems. Use this name rather than calling
- * query_addrrset().
+ * we have other problems.
*/
result = dns_message_firstname(client->message, DNS_SECTION_AUTHORITY);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- rname = NULL;
- dns_message_currentname(client->message, DNS_SECTION_AUTHORITY, &rname);
- result = dns_message_findtype(rname, dns_rdatatype_ns, 0, NULL);
+ /*
+ * Find the delegation in the response message - it is not necessarily
+ * the first name in the AUTHORITY section when wildcard processing is
+ * involved.
+ */
+ while (result == ISC_R_SUCCESS) {
+ rname = NULL;
+ dns_message_currentname(client->message, DNS_SECTION_AUTHORITY,
+ &rname);
+ result = dns_message_findtype(rname, dns_rdatatype_ns, 0, NULL);
+ if (result == ISC_R_SUCCESS) {
+ break;
+ }
+ result = dns_message_nextname(client->message,
+ DNS_SECTION_AUTHORITY);
+ }
+
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- ISC_LIST_APPEND(rname->list, rdataset, link);
- ISC_LIST_APPEND(rname->list, sigrdataset, link);
- rdataset = NULL;
- sigrdataset = NULL;
- return;
+ /*
+ * Add the relevant RRset (DS or NSEC) to the delegation.
+ */
+ query_addrrset(qctx, &rname, &rdataset, &sigrdataset, NULL,
+ DNS_SECTION_AUTHORITY);
+ goto cleanup;
addnsec3:
if (!dns_db_iszone(qctx->db)) {
@@ -9529,8 +9559,7 @@ query_synthcnamewildcard(query_ctx_t *qctx, dns_rdataset_t *rdataset,
RUNTIME_CHECK(result == ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
- dns_name_init(tname, NULL);
- dns_name_dup(&cname.cname, qctx->client->mctx, tname);
+ dns_name_copynf(&cname.cname, tname);
dns_rdata_freestruct(&cname);
ns_client_qnamereplace(qctx->client, tname);
@@ -10062,9 +10091,9 @@ cleanup:
*/
static isc_result_t
query_cname(query_ctx_t *qctx) {
- isc_result_t result;
- dns_name_t *tname;
- dns_rdataset_t *trdataset;
+ isc_result_t result = ISC_R_UNSET;
+ dns_name_t *tname = NULL;
+ dns_rdataset_t *trdataset = NULL;
dns_rdataset_t **sigrdatasetp = NULL;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_cname_t cname;
@@ -10126,7 +10155,6 @@ query_cname(query_ctx_t *qctx) {
* Reset qname to be the target name of the CNAME and restart
* the query.
*/
- tname = NULL;
result = dns_message_gettempname(qctx->client->message, &tname);
if (result != ISC_R_SUCCESS) {
return (ns_query_done(qctx));
@@ -10143,8 +10171,7 @@ query_cname(query_ctx_t *qctx) {
RUNTIME_CHECK(result == ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
- dns_name_init(tname, NULL);
- dns_name_dup(&cname.cname, qctx->client->mctx, tname);
+ dns_name_copynf(&cname.cname, tname);
dns_rdata_freestruct(&cname);
ns_client_qnamereplace(qctx->client, tname);
@@ -10246,7 +10273,7 @@ query_dname(query_ctx_t *qctx) {
RUNTIME_CHECK(result == ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
- dns_name_clone(&dname.dname, tname);
+ dns_name_copynf(&dname.dname, tname);
dns_rdata_freestruct(&dname);
/*
@@ -10344,7 +10371,8 @@ query_addcname(query_ctx_t *qctx, dns_trust_t trust, dns_ttl_t ttl) {
if (result != ISC_R_SUCCESS) {
return (result);
}
- dns_name_dup(client->query.qname, client->mctx, aname);
+
+ dns_name_copynf(client->query.qname, aname);
result = dns_message_gettemprdatalist(client->message, &rdatalist);
if (result != ISC_R_SUCCESS) {
@@ -10479,8 +10507,13 @@ query_addsoa(query_ctx_t *qctx, unsigned int override_ttl,
if (result != ISC_R_SUCCESS) {
return (result);
}
- dns_name_init(name, NULL);
+
+ /*
+ * We'll be releasing 'name' before returning, so it's safe to
+ * use clone instead of copying here.
+ */
dns_name_clone(dns_db_origin(qctx->db), name);
+
rdataset = ns_client_newrdataset(client);
if (rdataset == NULL) {
CTRACE(ISC_LOG_ERROR, "unable to allocate rdataset");
@@ -10616,7 +10649,6 @@ query_addns(query_ctx_t *qctx) {
"failed: done");
return (result);
}
- dns_name_init(name, NULL);
dns_name_clone(dns_db_origin(qctx->db), name);
rdataset = ns_client_newrdataset(client);
if (rdataset == NULL) {
diff --git a/external/mpl/bind/dist/lib/ns/tests/nstest.c b/external/mpl/bind/dist/lib/ns/tests/nstest.c
index db36b995c9b..632ec934d8a 100644
--- a/external/mpl/bind/dist/lib/ns/tests/nstest.c
+++ b/external/mpl/bind/dist/lib/ns/tests/nstest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nstest.c,v 1.5 2021/02/19 16:42:22 christos Exp $ */
+/* $NetBSD: nstest.c,v 1.6 2021/08/19 11:50:20 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -24,6 +24,7 @@
#include <isc/buffer.h>
#include <isc/file.h>
#include <isc/hash.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
#include <isc/os.h>
@@ -57,7 +58,7 @@ isc_taskmgr_t *taskmgr = NULL;
isc_task_t *maintask = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
-isc_nm_t *nm = NULL;
+isc_nm_t *netmgr = NULL;
dns_zonemgr_t *zonemgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
ns_clientmgr_t *clientmgr = NULL;
@@ -217,19 +218,10 @@ cleanup_managers(void) {
if (socketmgr != NULL) {
isc_socketmgr_destroy(&socketmgr);
}
- ns_test_nap(500000);
- if (nm != NULL) {
- /*
- * Force something in the workqueue as a workaround
- * for libuv bug - not sending uv_close callback.
- */
- isc_nm_pause(nm);
- isc_nm_resume(nm);
- isc_nm_detach(&nm);
- }
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
+
+ isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
+ taskmgr == NULL ? NULL : &taskmgr);
+
if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
}
@@ -254,8 +246,8 @@ create_managers(void) {
isc_event_t *event = NULL;
ncpus = isc_os_ncpus();
- CHECK(isc_taskmgr_create(mctx, ncpus, 0, NULL, &taskmgr));
- CHECK(isc_task_create(taskmgr, 0, &maintask));
+ CHECK(isc_managers_create(mctx, ncpus, 0, &netmgr, &taskmgr));
+ CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);
CHECK(isc_task_onshutdown(maintask, shutdown_managers, NULL));
@@ -263,14 +255,12 @@ create_managers(void) {
CHECK(isc_socketmgr_create(mctx, &socketmgr));
- nm = isc_nm_start(mctx, ncpus);
-
CHECK(ns_server_create(mctx, matchview, &sctx));
CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
CHECK(ns_interfacemgr_create(mctx, sctx, taskmgr, timermgr, socketmgr,
- nm, dispatchmgr, maintask, ncpus, NULL,
+ netmgr, dispatchmgr, maintask, ncpus, NULL,
ncpus, &interfacemgr));
CHECK(ns_listenlist_default(mctx, port, -1, true, &listenon));
@@ -905,21 +895,11 @@ ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp) {
*/
void
ns_test_nap(uint32_t usec) {
-#ifdef HAVE_NANOSLEEP
struct timespec ts;
ts.tv_sec = usec / 1000000;
ts.tv_nsec = (usec % 1000000) * 1000;
nanosleep(&ts, NULL);
-#elif HAVE_USLEEP
- usleep(usec);
-#else /* ifdef HAVE_NANOSLEEP */
- /*
- * No fractional-second sleep function is available, so we
- * round up to the nearest second and sleep instead
- */
- sleep((usec / 1000000) + 1);
-#endif /* ifdef HAVE_NANOSLEEP */
}
isc_result_t
diff --git a/external/mpl/bind/dist/lib/ns/update.c b/external/mpl/bind/dist/lib/ns/update.c
index e529bf308a9..2468a2341f3 100644
--- a/external/mpl/bind/dist/lib/ns/update.c
+++ b/external/mpl/bind/dist/lib/ns/update.c
@@ -1,4 +1,4 @@
-/* $NetBSD: update.c,v 1.10 2021/04/05 11:27:04 rillig Exp $ */
+/* $NetBSD: update.c,v 1.11 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -2001,7 +2001,7 @@ check_dnssec(ns_client_t *client, dns_zone_t *zone, dns_db_t *db,
dns_difftuple_t *tuple;
bool nseconly = false, nsec3 = false;
isc_result_t result;
- unsigned int iterations = 0, max;
+ unsigned int iterations = 0;
dns_rdatatype_t privatetype = dns_zone_getprivatetype(zone);
/* Scan the tuples for an NSEC-only DNSKEY or an NSEC3PARAM */
@@ -2056,12 +2056,9 @@ check_dnssec(ns_client_t *client, dns_zone_t *zone, dns_db_t *db,
/* Verify NSEC3 params */
CHECK(get_iterations(db, ver, privatetype, &iterations));
- CHECK(dns_nsec3_maxiterations(db, ver, client->mctx, &max));
- if (max != 0 && iterations > max) {
+ if (iterations > dns_nsec3_maxiterations()) {
update_log(client, zone, ISC_LOG_ERROR,
- "too many NSEC3 iterations (%u) for "
- "weakest DNSKEY (%u)",
- iterations, max);
+ "too many NSEC3 iterations (%u)", iterations);
result = DNS_R_REFUSED;
goto failure;
}
diff --git a/external/mpl/bind/dist/lib/ns/xfrout.c b/external/mpl/bind/dist/lib/ns/xfrout.c
index cb4efc32197..05f48a2add7 100644
--- a/external/mpl/bind/dist/lib/ns/xfrout.c
+++ b/external/mpl/bind/dist/lib/ns/xfrout.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xfrout.c,v 1.10 2021/04/05 11:27:04 rillig Exp $ */
+/* $NetBSD: xfrout.c,v 1.11 2021/08/19 11:50:19 christos Exp $ */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -1425,7 +1425,6 @@ sendstream(xfrout_ctx_t *xfr) {
if (result != ISC_R_SUCCESS) {
goto failure;
}
- dns_name_init(qname, NULL);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= xfr->qname->length);
r.length = xfr->qname->length;
@@ -1499,7 +1498,6 @@ sendstream(xfrout_ctx_t *xfr) {
if (result != ISC_R_SUCCESS) {
goto failure;
}
- dns_name_init(msgname, NULL);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= name->length);
r.length = name->length;
diff --git a/external/mpl/bind/dist/lib/samples/Makefile-postinstall.in b/external/mpl/bind/dist/lib/samples/Makefile-postinstall.in
deleted file mode 100644
index f31d7759658..00000000000
--- a/external/mpl/bind/dist/lib/samples/Makefile-postinstall.in
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-srcdir = @srcdir@
-#prefix = @prefix@
-#exec_prefix = @exec_prefix@
-
-CDEFINES =
-CWARNINGS =
-
-DNSLIBS = -ldns @DNS_CRYPTO_LIBS@
-ISCLIBS = -lisc @OPENSSL_LIBS@ @LIBXML2_LIBS@
-ISCCFGLIBS = -lisccfg
-IRSLIBS = -lirs
-
-LIBS = ${DNSLIBS} ${ISCCFGLIBS} ${ISCLIBS} @LIBS@
-
-SUBDIRS =
-
-TARGETS = sample@EXEEXT@ sample-async@EXEEXT@ sample-gai@EXEEXT@ \
- sample-update@EXEEXT@ sample-request@EXEEXT@ nsprobe@EXEEXT@
-
-OBJS = sample.@O@ sample-async.@O@ sample-gai.@O@ sample-update.@O@ \
- sample-request.@O@ nsprobe.@O@
-
-SRCS = sample.c sample-async.c sample-gai.c sample-update.c \
- sample-request.c nsprobe.c
-
-@BIND9_MAKE_RULES@
-
-# The following two may depend on BIND9_MAKE_RULES
-CINCLUDES = -I@export_includedir@
-LDFLAGS = -L@export_libdir@
-
-sample@EXEEXT@: sample.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample.@O@ ${LIBS}
-
-sample-async@EXEEXT@: sample-async.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-async.@O@ ${LIBS}
-
-sample-gai@EXEEXT@: sample-gai.@O@ ${IRSDEPLIBS} ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-gai.@O@ ${IRSLIBS} ${LIBS}
-
-sample-update@EXEEXT@: sample-update.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-update.@O@ ${LIBS}
-
-sample-request@EXEEXT@: sample-request.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-request.@O@ ${LIBS}
-
-nsprobe@EXEEXT@: nsprobe.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- nsprobe.@O@ ${LIBS}
-
-clean distclean maintainer-clean::
- rm -f ${TARGETS}
diff --git a/external/mpl/bind/dist/lib/samples/Makefile.in b/external/mpl/bind/dist/lib/samples/Makefile.in
deleted file mode 100644
index 17f75839212..00000000000
--- a/external/mpl/bind/dist/lib/samples/Makefile.in
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-top_srcdir = @top_srcdir@
-
-VERSION=@BIND9_VERSION@
-
-@BIND9_MAKE_INCLUDES@
-
-CINCLUDES = -I${srcdir}/include -I../dns/include \
- ${DNS_INCLUDES} ${ISC_INCLUDES} \
- -I${top_srcdir}/lib/irs/include \
- -I../../lib/irs/include \
- ${OPENSSL_CFLAGS}
-
-CDEFINES = -DVERSION=\"${VERSION}\" \
- -DSYSCONFDIR=\"${sysconfdir}\"
-CWARNINGS =
-
-ISCLIBS = ../isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
-DNSLIBS = ../dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
-ISCCFGLIBS = ../isccfg/libisccfg.@A@
-IRSLIBS = ../irs/libirs.@A@
-
-ISCDEPLIBS = ../isc/libisc.@A@
-DNSDEPLIBS = ../dns/libdns.@A@
-ISCCFGDEPLIBS = ../isccfg/libisccfg.@A@
-IRSDEPLIBS = ../irs/libirs.@A@
-
-DEPLIBS = ${DNSDEPLIBS} ${ISCCFGDEPLIBS} ${ISCDEPLIBS}
-
-LIBS = ${DNSLIBS} ${ISCCFGLIBS} ${ISCLIBS} @LIBS@
-
-SUBDIRS =
-
-TARGETS = resolve@EXEEXT@ \
- sample-async@EXEEXT@ sample-gai@EXEEXT@ \
- sample-update@EXEEXT@ sample-request@EXEEXT@ nsprobe@EXEEXT@
-
-OBJS = resolve.@O@ \
- sample-async.@O@ sample-gai.@O@ sample-update.@O@ \
- sample-request.@O@ nsprobe.@O@
-
-UOBJS =
-
-SRCS = resolve.c \
- sample-async.c sample-gai.c sample-update.c \
- sample-request.c nsprobe.c
-
-@BIND9_MAKE_RULES@
-
-resolve@EXEEXT@: resolve.@O@ ${IRSDEPLIBS} ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- resolve.@O@ ${IRSLIBS} ${LIBS}
-
-sample-async@EXEEXT@: sample-async.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-async.@O@ ${LIBS}
-
-sample-gai@EXEEXT@: sample-gai.@O@ ${IRSDEPLIBS} ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-gai.@O@ ${IRSLIBS} ${LIBS}
-
-sample-update@EXEEXT@: sample-update.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-update.@O@ ${LIBS}
-
-sample-request@EXEEXT@: sample-request.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- sample-request.@O@ ${LIBS}
-
-nsprobe@EXEEXT@: nsprobe.@O@ ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- nsprobe.@O@ ${LIBS}
-
-clean distclean maintainer-clean::
- rm -f ${TARGETS}
- rm -f sample.key
diff --git a/external/mpl/bind/dist/lib/samples/nsprobe.c b/external/mpl/bind/dist/lib/samples/nsprobe.c
deleted file mode 100644
index 5ded13548c9..00000000000
--- a/external/mpl/bind/dist/lib/samples/nsprobe.c
+++ /dev/null
@@ -1,1235 +0,0 @@
-/* $NetBSD: nsprobe.c,v 1.7 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif /* ifndef WIN32 */
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/app.h>
-#include <isc/buffer.h>
-#include <isc/commandline.h>
-#include <isc/lib.h>
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/sockaddr.h>
-#include <isc/socket.h>
-#include <isc/string.h>
-#include <isc/task.h>
-#include <isc/timer.h>
-#include <isc/util.h>
-
-#include <dns/client.h>
-#include <dns/fixedname.h>
-#include <dns/lib.h>
-#include <dns/message.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rdataset.h>
-#include <dns/rdatastruct.h>
-#include <dns/rdatatype.h>
-#include <dns/result.h>
-
-#define MAX_PROBES 1000
-
-static dns_client_t *client = NULL;
-static isc_task_t *probe_task = NULL;
-static isc_appctx_t *actx = NULL;
-static isc_mem_t *mctx = NULL;
-static unsigned int outstanding_probes = 0;
-const char *cacheserver = "127.0.0.1";
-static FILE *input;
-
-typedef enum {
- none,
- exist,
- nxdomain,
- othererr,
- multiplesoa,
- multiplecname,
- brokenanswer,
- lame,
- timedout,
- notype,
- unexpected
-} query_result_t;
-
-struct server {
- ISC_LINK(struct server) link;
-
- isc_sockaddr_t address;
- query_result_t result_a;
- query_result_t result_aaaa;
-};
-
-struct probe_ns {
- ISC_LINK(struct probe_ns) link;
-
- dns_fixedname_t fixedname;
- dns_name_t *name;
- struct server *current_server;
- ISC_LIST(struct server) servers;
-};
-
-struct probe_trans {
- bool inuse;
- char *domain;
- dns_fixedname_t fixedname;
- dns_name_t *qname;
- const char **qlabel;
- bool qname_found;
- dns_clientrestrans_t *resid;
- dns_message_t *qmessage;
- dns_message_t *rmessage;
- dns_clientreqtrans_t *reqid;
-
- /* NS list */
- struct probe_ns *current_ns;
- ISC_LIST(struct probe_ns) nslist;
-};
-
-struct lcl_stat {
- unsigned long valid;
- unsigned long ignore;
- unsigned long nxdomain;
- unsigned long othererr;
- unsigned long multiplesoa;
- unsigned long multiplecname;
- unsigned long brokenanswer;
- unsigned long lame;
- unsigned long unknown;
-} server_stat, domain_stat;
-
-static unsigned long number_of_domains = 0;
-static unsigned long number_of_servers = 0;
-static unsigned long multiple_error_domains = 0;
-static bool debug_mode = false;
-static int verbose_level = 0;
-static const char *qlabels[] = { "www.", "ftp.", NULL };
-static struct probe_trans probes[MAX_PROBES];
-
-static isc_result_t
-probe_domain(struct probe_trans *trans);
-static void
-reset_probe(struct probe_trans *trans);
-static isc_result_t
-fetch_nsaddress(struct probe_trans *trans);
-static isc_result_t
-probe_name(struct probe_trans *trans, dns_rdatatype_t type);
-
-/* Dump an rdataset for debug */
-static isc_result_t
-print_rdataset(dns_rdataset_t *rdataset, dns_name_t *owner) {
- isc_buffer_t target;
- isc_result_t result;
- isc_region_t r;
- char t[4096];
-
- if (!debug_mode) {
- return (ISC_R_SUCCESS);
- }
-
- isc_buffer_init(&target, t, sizeof(t));
-
- if (!dns_rdataset_isassociated(rdataset)) {
- return (ISC_R_SUCCESS);
- }
- result = dns_rdataset_totext(rdataset, owner, false, false, &target);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_usedregion(&target, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
-
- return (ISC_R_SUCCESS);
-}
-
-static isc_result_t
-print_name(dns_name_t *name) {
- isc_result_t result;
- isc_buffer_t target;
- isc_region_t r;
- char t[4096];
-
- isc_buffer_init(&target, t, sizeof(t));
- result = dns_name_totext(name, true, &target);
- if (result == ISC_R_SUCCESS) {
- isc_buffer_usedregion(&target, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
- } else {
- printf("(invalid name)");
- }
-
- return (result);
-}
-
-static isc_result_t
-print_address(FILE *fp, isc_sockaddr_t *addr) {
- char buf[NI_MAXHOST];
-
- if (getnameinfo(&addr->type.sa, addr->length, buf, sizeof(buf), NULL, 0,
- NI_NUMERICHOST) == 0)
- {
- fprintf(fp, "%s", buf);
- } else {
- fprintf(fp, "(invalid address)");
- }
-
- return (ISC_R_SUCCESS);
-}
-
-static void
-ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- if (*taskmgrp != NULL) {
- isc_taskmgr_destroy(taskmgrp);
- }
-
- if (*timermgrp != NULL) {
- isc_timermgr_destroy(timermgrp);
- }
-
- if (*socketmgrp != NULL) {
- isc_socketmgr_destroy(socketmgrp);
- }
-
- if (*actxp != NULL) {
- isc_appctx_destroy(actxp);
- }
-
- if (*mctxp != NULL) {
- isc_mem_destroy(mctxp);
- }
-}
-
-static isc_result_t
-ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- isc_result_t result;
-
- isc_mem_create(mctxp);
-
- result = isc_appctx_create(*mctxp, actxp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_taskmgr_createinctx(*mctxp, 1, 0, taskmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_socketmgr_createinctx(*mctxp, socketmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_timermgr_createinctx(*mctxp, timermgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- return (ISC_R_SUCCESS);
-
-fail:
- ctxs_destroy(mctxp, actxp, taskmgrp, socketmgrp, timermgrp);
-
- return (result);
-}
-
-/*
- * Common routine to make query data
- */
-static isc_result_t
-make_querymessage(dns_message_t *message, dns_name_t *qname0,
- dns_rdatatype_t rdtype) {
- dns_name_t *qname = NULL;
- dns_rdataset_t *qrdataset = NULL;
- isc_result_t result;
-
- message->opcode = dns_opcode_query;
- message->rdclass = dns_rdataclass_in;
-
- result = dns_message_gettempname(message, &qname);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- result = dns_message_gettemprdataset(message, &qrdataset);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- dns_name_init(qname, NULL);
- dns_name_clone(qname0, qname);
- dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
- ISC_LIST_APPEND(qname->list, qrdataset, link);
- dns_message_addname(message, qname, DNS_SECTION_QUESTION);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (qname != NULL) {
- dns_message_puttempname(message, &qname);
- }
- if (qrdataset != NULL) {
- dns_message_puttemprdataset(message, &qrdataset);
- }
- return (result);
-}
-
-/*
- * Update statistics
- */
-static inline void
-increment_entry(unsigned long *entryp) {
- (*entryp)++;
- INSIST(*entryp != 0U); /* check overflow */
-}
-
-static void
-update_stat(struct probe_trans *trans) {
- struct probe_ns *pns;
- struct server *server;
- struct lcl_stat local_stat;
- unsigned int err_count = 0;
- const char *stattype;
-
- increment_entry(&number_of_domains);
- memset(&local_stat, 0, sizeof(local_stat));
-
- /* Update per sever statistics */
- for (pns = ISC_LIST_HEAD(trans->nslist); pns != NULL;
- pns = ISC_LIST_NEXT(pns, link))
- {
- for (server = ISC_LIST_HEAD(pns->servers); server != NULL;
- server = ISC_LIST_NEXT(server, link))
- {
- increment_entry(&number_of_servers);
-
- if (server->result_aaaa == exist ||
- server->result_aaaa == notype) {
- /*
- * Don't care about the result of A query if
- * the answer to AAAA query was expected.
- */
- stattype = "valid";
- increment_entry(&server_stat.valid);
- increment_entry(&local_stat.valid);
- } else if (server->result_a == exist) {
- switch (server->result_aaaa) {
- case exist:
- case notype:
- stattype = "valid";
- increment_entry(&server_stat.valid);
- increment_entry(&local_stat.valid);
- break;
- case timedout:
- stattype = "ignore";
- increment_entry(&server_stat.ignore);
- increment_entry(&local_stat.ignore);
- break;
- case nxdomain:
- stattype = "nxdomain";
- increment_entry(&server_stat.nxdomain);
- increment_entry(&local_stat.nxdomain);
- break;
- case othererr:
- stattype = "othererr";
- increment_entry(&server_stat.othererr);
- increment_entry(&local_stat.othererr);
- break;
- case multiplesoa:
- stattype = "multiplesoa";
- increment_entry(
- &server_stat.multiplesoa);
- increment_entry(
- &local_stat.multiplesoa);
- break;
- case multiplecname:
- stattype = "multiplecname";
- increment_entry(
- &server_stat.multiplecname);
- increment_entry(
- &local_stat.multiplecname);
- break;
- case brokenanswer:
- stattype = "brokenanswer";
- increment_entry(
- &server_stat.brokenanswer);
- increment_entry(
- &local_stat.brokenanswer);
- break;
- case lame:
- stattype = "lame";
- increment_entry(&server_stat.lame);
- increment_entry(&local_stat.lame);
- break;
- default:
- stattype = "unknown";
- increment_entry(&server_stat.unknown);
- increment_entry(&local_stat.unknown);
- break;
- }
- } else {
- stattype = "unknown";
- increment_entry(&server_stat.unknown);
- increment_entry(&local_stat.unknown);
- }
-
- if (verbose_level > 1 ||
- (verbose_level == 1 &&
- strcmp(stattype, "valid") != 0 &&
- strcmp(stattype, "unknown") != 0))
- {
- print_name(pns->name);
- putchar('(');
- print_address(stdout, &server->address);
- printf(") for %s:%s\n", trans->domain,
- stattype);
- }
- }
- }
-
- /* Update per domain statistics */
- if (local_stat.ignore > 0U) {
- if (verbose_level > 0) {
- printf("%s:ignore\n", trans->domain);
- }
- increment_entry(&domain_stat.ignore);
- err_count++;
- }
- if (local_stat.nxdomain > 0U) {
- if (verbose_level > 0) {
- printf("%s:nxdomain\n", trans->domain);
- }
- increment_entry(&domain_stat.nxdomain);
- err_count++;
- }
- if (local_stat.othererr > 0U) {
- if (verbose_level > 0) {
- printf("%s:othererr\n", trans->domain);
- }
- increment_entry(&domain_stat.othererr);
- err_count++;
- }
- if (local_stat.multiplesoa > 0U) {
- if (verbose_level > 0) {
- printf("%s:multiplesoa\n", trans->domain);
- }
- increment_entry(&domain_stat.multiplesoa);
- err_count++;
- }
- if (local_stat.multiplecname > 0U) {
- if (verbose_level > 0) {
- printf("%s:multiplecname\n", trans->domain);
- }
- increment_entry(&domain_stat.multiplecname);
- err_count++;
- }
- if (local_stat.brokenanswer > 0U) {
- if (verbose_level > 0) {
- printf("%s:brokenanswer\n", trans->domain);
- }
- increment_entry(&domain_stat.brokenanswer);
- err_count++;
- }
- if (local_stat.lame > 0U) {
- if (verbose_level > 0) {
- printf("%s:lame\n", trans->domain);
- }
- increment_entry(&domain_stat.lame);
- err_count++;
- }
-
- if (err_count > 1U) {
- increment_entry(&multiple_error_domains);
- }
-
- /*
- * We regard the domain as valid if and only if no authoritative server
- * has a problem and at least one server is known to be valid.
- */
- if (local_stat.valid > 0U && err_count == 0U) {
- if (verbose_level > 1) {
- printf("%s:valid\n", trans->domain);
- }
- increment_entry(&domain_stat.valid);
- }
-
- /*
- * If the domain has no available server or all servers have the
- * 'unknown' result, the domain's result is also regarded as unknown.
- */
- if (local_stat.valid == 0U && err_count == 0U) {
- if (verbose_level > 1) {
- printf("%s:unknown\n", trans->domain);
- }
- increment_entry(&domain_stat.unknown);
- }
-}
-
-/*
- * Search for an existent name with an A RR
- */
-
-static isc_result_t
-set_nextqname(struct probe_trans *trans) {
- isc_result_t result;
- unsigned int domainlen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad-hoc constant, but should be enough */
-
- if (*trans->qlabel == NULL) {
- return (ISC_R_NOMORE);
- }
-
- if (strlcpy(buf, *trans->qlabel, sizeof(buf)) >= sizeof(buf)) {
- return (ISC_R_NOSPACE);
- }
-
- if ((domainlen = strlcat(buf, trans->domain, sizeof(buf))) >=
- sizeof(buf)) {
- return (ISC_R_NOSPACE);
- }
-
- isc_buffer_init(&b, buf, domainlen);
- isc_buffer_add(&b, domainlen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
-
- trans->qlabel++;
-
- return (result);
-}
-
-static void
-request_done(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientreqevent_t *rev = (dns_clientreqevent_t *)event;
- dns_message_t *rmessage;
- struct probe_ns *pns;
- struct server *server;
- isc_result_t result;
- query_result_t *resultp;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- dns_rdatatype_t type;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans != NULL && trans->inuse);
- rmessage = rev->rmessage;
- REQUIRE(rmessage == trans->rmessage);
- INSIST(outstanding_probes > 0);
-
- server = trans->current_ns->current_server;
- INSIST(server != NULL);
-
- if (server->result_a == none) {
- type = dns_rdatatype_a;
- resultp = &server->result_a;
- } else {
- resultp = &server->result_aaaa;
- type = dns_rdatatype_aaaa;
- }
-
- if (rev->result == ISC_R_SUCCESS) {
- if ((rmessage->flags & DNS_MESSAGEFLAG_AA) == 0) {
- *resultp = lame;
- } else if (rmessage->rcode == dns_rcode_nxdomain) {
- *resultp = nxdomain;
- } else if (rmessage->rcode != dns_rcode_noerror) {
- *resultp = othererr;
- } else if (rmessage->counts[DNS_SECTION_ANSWER] == 0) {
- /* no error but empty answer */
- *resultp = notype;
- } else {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_ANSWER);
- while (result == ISC_R_SUCCESS) {
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_ANSWER, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type ==
- dns_rdatatype_cname ||
- rdataset->type ==
- dns_rdatatype_dname)
- {
- /* Should chase the chain? */
- *resultp = exist;
- goto found;
- } else if (rdataset->type == type) {
- *resultp = exist;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_ANSWER);
- }
-
- /*
- * Something unexpected happened: the response
- * contained a non-empty authoritative answer, but we
- * could not find an expected result.
- */
- *resultp = unexpected;
- }
- } else if (rev->result == DNS_R_RECOVERABLE ||
- rev->result == DNS_R_BADLABELTYPE)
- {
- /* Broken response. Try identifying known cases. */
- *resultp = brokenanswer;
-
- if (rmessage->counts[DNS_SECTION_ANSWER] > 0) {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_ANSWER);
- while (result == ISC_R_SUCCESS) {
- /*
- * Check to see if the response has multiple
- * CNAME RRs. Update the result code if so.
- */
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_ANSWER, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (rdataset->type ==
- dns_rdatatype_cname &&
- dns_rdataset_count(rdataset) > 1) {
- *resultp = multiplecname;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_ANSWER);
- }
- }
-
- if (rmessage->counts[DNS_SECTION_AUTHORITY] > 0) {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_AUTHORITY);
- while (result == ISC_R_SUCCESS) {
- /*
- * Check to see if the response has multiple
- * SOA RRs. Update the result code if so.
- */
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_AUTHORITY, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (rdataset->type ==
- dns_rdatatype_soa &&
- dns_rdataset_count(rdataset) > 1) {
- *resultp = multiplesoa;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_AUTHORITY);
- }
- }
- } else if (rev->result == ISC_R_TIMEDOUT) {
- *resultp = timedout;
- } else {
- fprintf(stderr, "unexpected result: %u (domain=%s, server=",
- rev->result, trans->domain);
- print_address(stderr, &server->address);
- fputc('\n', stderr);
- *resultp = unexpected;
- }
-
-found:
- INSIST(*resultp != none);
- if (type == dns_rdatatype_a && *resultp == exist) {
- trans->qname_found = true;
- }
-
- dns_client_destroyreqtrans(&trans->reqid);
- isc_event_free(&event);
- dns_message_reset(trans->rmessage, DNS_MESSAGE_INTENTPARSE);
-
- result = probe_name(trans, type);
- if (result == ISC_R_NOMORE) {
- /* We've tried all addresses of all servers. */
- if (type == dns_rdatatype_a && trans->qname_found) {
- /*
- * If we've explored A RRs and found an existent
- * record, we can move to AAAA.
- */
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- probe_name(trans, dns_rdatatype_aaaa);
- result = ISC_R_SUCCESS;
- } else if (type == dns_rdatatype_a) {
- /*
- * No server provided an existent A RR of this name.
- * Try next label.
- */
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- result = set_nextqname(trans);
- if (result == ISC_R_SUCCESS) {
- trans->current_ns =
- ISC_LIST_HEAD(trans->nslist);
- for (pns = trans->current_ns; pns != NULL;
- pns = ISC_LIST_NEXT(pns, link)) {
- for (server = ISC_LIST_HEAD(
- pns->servers);
- server != NULL;
- server = ISC_LIST_NEXT(server,
- link))
- {
- INSIST(server->result_aaaa ==
- none);
- server->result_a = none;
- }
- }
- result = probe_name(trans, dns_rdatatype_a);
- }
- }
- if (result != ISC_R_SUCCESS) {
- /*
- * We've explored AAAA RRs or failed to find a valid
- * query label. Wrap up the result and move to the
- * next domain.
- */
- reset_probe(trans);
- }
- } else if (result != ISC_R_SUCCESS) {
- reset_probe(trans); /* XXX */
- }
-}
-
-static isc_result_t
-probe_name(struct probe_trans *trans, dns_rdatatype_t type) {
- isc_result_t result;
- struct probe_ns *pns;
- struct server *server;
-
- REQUIRE(trans->reqid == NULL);
- REQUIRE(type == dns_rdatatype_a || type == dns_rdatatype_aaaa);
-
- for (pns = trans->current_ns; pns != NULL;
- pns = ISC_LIST_NEXT(pns, link)) {
- for (server = ISC_LIST_HEAD(pns->servers); server != NULL;
- server = ISC_LIST_NEXT(server, link))
- {
- if ((type == dns_rdatatype_a &&
- server->result_a == none) ||
- (type == dns_rdatatype_aaaa &&
- server->result_aaaa == none))
- {
- pns->current_server = server;
- goto found;
- }
- }
- }
-
-found:
- trans->current_ns = pns;
- if (pns == NULL) {
- return (ISC_R_NOMORE);
- }
-
- INSIST(pns->current_server != NULL);
- dns_message_reset(trans->qmessage, DNS_MESSAGE_INTENTRENDER);
- result = make_querymessage(trans->qmessage, trans->qname, type);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- result = dns_client_startrequest(
- client, trans->qmessage, trans->rmessage,
- &pns->current_server->address, 0, DNS_MESSAGEPARSE_BESTEFFORT,
- NULL, 120, 0, 4, probe_task, request_done, trans,
- &trans->reqid);
-
- return (result);
-}
-
-/*
- * Get IP addresses of NSes
- */
-
-static void
-resolve_nsaddress(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- dns_rdata_t rdata = DNS_RDATA_INIT;
- struct probe_ns *pns = trans->current_ns;
- isc_result_t result;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans->inuse);
- REQUIRE(pns != NULL);
- INSIST(outstanding_probes > 0);
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type != dns_rdatatype_a) {
- continue;
- }
-
- for (result = dns_rdataset_first(rdataset);
- result == ISC_R_SUCCESS;
- result = dns_rdataset_next(rdataset))
- {
- dns_rdata_in_a_t rdata_a;
- struct server *server;
-
- dns_rdataset_current(rdataset, &rdata);
- result = dns_rdata_tostruct(&rdata, &rdata_a,
- NULL);
- if (result != ISC_R_SUCCESS) {
- continue;
- }
-
- server = isc_mem_get(mctx, sizeof(*server));
- isc_sockaddr_fromin(&server->address,
- &rdata_a.in_addr, 53);
- ISC_LINK_INIT(server, link);
- server->result_a = none;
- server->result_aaaa = none;
- ISC_LIST_APPEND(pns->servers, server, link);
- }
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->resid);
- isc_event_free(&event);
-
-next_ns:
- trans->current_ns = ISC_LIST_NEXT(pns, link);
- if (trans->current_ns == NULL) {
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- result = set_nextqname(trans);
- if (result == ISC_R_SUCCESS) {
- result = probe_name(trans, dns_rdatatype_a);
- }
- } else {
- result = fetch_nsaddress(trans);
- if (result != ISC_R_SUCCESS) {
- goto next_ns; /* XXX: this is unlikely to succeed */
- }
- }
-
- if (result != ISC_R_SUCCESS) {
- reset_probe(trans);
- }
-}
-
-static isc_result_t
-fetch_nsaddress(struct probe_trans *trans) {
- struct probe_ns *pns;
-
- pns = trans->current_ns;
- REQUIRE(pns != NULL);
-
- return (dns_client_startresolve(
- client, pns->name, dns_rdataclass_in, dns_rdatatype_a, 0,
- probe_task, resolve_nsaddress, trans, &trans->resid));
-}
-
-/*
- * Get NS RRset for a given domain
- */
-
-static void
-reset_probe(struct probe_trans *trans) {
- struct probe_ns *pns;
- struct server *server;
- isc_result_t result;
-
- REQUIRE(trans->resid == NULL);
- REQUIRE(trans->reqid == NULL);
-
- update_stat(trans);
-
- dns_message_reset(trans->qmessage, DNS_MESSAGE_INTENTRENDER);
- dns_message_reset(trans->rmessage, DNS_MESSAGE_INTENTPARSE);
-
- trans->inuse = false;
- if (trans->domain != NULL) {
- isc_mem_free(mctx, trans->domain);
- }
- trans->domain = NULL;
- if (trans->qname != NULL) {
- dns_fixedname_invalidate(&trans->fixedname);
- }
- trans->qname = NULL;
- trans->qlabel = qlabels;
- trans->qname_found = false;
- trans->current_ns = NULL;
-
- while ((pns = ISC_LIST_HEAD(trans->nslist)) != NULL) {
- ISC_LIST_UNLINK(trans->nslist, pns, link);
- while ((server = ISC_LIST_HEAD(pns->servers)) != NULL) {
- ISC_LIST_UNLINK(pns->servers, server, link);
- isc_mem_put(mctx, server, sizeof(*server));
- }
- isc_mem_put(mctx, pns, sizeof(*pns));
- }
-
- outstanding_probes--;
-
- result = probe_domain(trans);
- if (result == ISC_R_NOMORE && outstanding_probes == 0) {
- isc_app_ctxshutdown(actx);
- }
-}
-
-static void
-resolve_ns(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- isc_result_t result = ISC_R_SUCCESS;
- dns_rdata_t rdata = DNS_RDATA_INIT;
- struct probe_ns *pns;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans->inuse);
- INSIST(outstanding_probes > 0);
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type != dns_rdatatype_ns) {
- continue;
- }
-
- for (result = dns_rdataset_first(rdataset);
- result == ISC_R_SUCCESS;
- result = dns_rdataset_next(rdataset))
- {
- dns_rdata_ns_t ns;
-
- dns_rdataset_current(rdataset, &rdata);
- /*
- * Extract the name from the NS record.
- */
- result = dns_rdata_tostruct(&rdata, &ns, NULL);
- if (result != ISC_R_SUCCESS) {
- continue;
- }
-
- pns = isc_mem_get(mctx, sizeof(*pns));
-
- pns->name =
- dns_fixedname_initname(&pns->fixedname);
- ISC_LINK_INIT(pns, link);
- ISC_LIST_APPEND(trans->nslist, pns, link);
- ISC_LIST_INIT(pns->servers);
-
- dns_name_copynf(&ns.name, pns->name);
- dns_rdata_reset(&rdata);
- dns_rdata_freestruct(&ns);
- }
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->resid);
- isc_event_free(&event);
-
- if (!ISC_LIST_EMPTY(trans->nslist)) {
- /* Go get addresses of NSes */
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- result = fetch_nsaddress(trans);
- } else {
- result = ISC_R_FAILURE;
- }
-
- if (result == ISC_R_SUCCESS) {
- return;
- }
-
- reset_probe(trans);
-}
-
-static isc_result_t
-probe_domain(struct probe_trans *trans) {
- isc_result_t result;
- unsigned int domainlen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad hoc constant, but should be enough */
- char *cp;
-
- REQUIRE(trans != NULL);
- REQUIRE(!trans->inuse);
- REQUIRE(outstanding_probes < MAX_PROBES);
-
- /* Construct domain */
- cp = fgets(buf, sizeof(buf), input);
- if (cp == NULL) {
- return (ISC_R_NOMORE);
- }
- if ((cp = strchr(buf, '\n')) != NULL) { /* zap NL if any */
- *cp = '\0';
- }
- trans->domain = isc_mem_strdup(mctx, buf);
-
- /* Start getting NS for the domain */
- domainlen = strlen(buf);
- isc_buffer_init(&b, buf, domainlen);
- isc_buffer_add(&b, domainlen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = dns_client_startresolve(
- client, trans->qname, dns_rdataclass_in, dns_rdatatype_ns, 0,
- probe_task, resolve_ns, trans, &trans->resid);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- trans->inuse = true;
- outstanding_probes++;
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- isc_mem_free(mctx, trans->domain);
- dns_fixedname_invalidate(&trans->fixedname);
-
- return (result);
-}
-
-ISC_PLATFORM_NORETURN_PRE static void
-usage(void) ISC_PLATFORM_NORETURN_POST;
-
-static void
-usage(void) {
- fprintf(stderr, "usage: nsprobe [-d] [-v [-v...]] [-c cache_address] "
- "[input_file]\n");
-
- exit(1);
-}
-
-int
-main(int argc, char *argv[]) {
- int i, ch, error;
- struct addrinfo hints, *res;
- isc_result_t result;
- isc_sockaddr_t sa;
- isc_sockaddrlist_t servers;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
-
- while ((ch = isc_commandline_parse(argc, argv, "c:dhv")) != -1) {
- switch (ch) {
- case 'c':
- cacheserver = isc_commandline_argument;
- break;
- case 'd':
- debug_mode = true;
- break;
- case 'h':
- usage();
- break;
- case 'v':
- verbose_level++;
- break;
- default:
- usage();
- break;
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
-
- /* Common set up */
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = ctxs_init(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "ctx create failed: %u\n", result);
- exit(1);
- }
-
- isc_app_ctxstart(actx);
-
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, 0,
- &client, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_createx failed: %u\n", result);
- exit(1);
- }
-
- /* Set local cache server */
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- error = getaddrinfo(cacheserver, "53", &hints, &res);
- if (error != 0) {
- fprintf(stderr, "failed to convert server name (%s): %s\n",
- cacheserver, gai_strerror(error));
- exit(1);
- }
-
- if (res->ai_addrlen > sizeof(sa.type)) {
- fprintf(stderr,
- "assumption failure: addrlen is too long: %ld\n",
- (long)res->ai_addrlen);
- exit(1);
- }
- memmove(&sa.type.sa, res->ai_addr, res->ai_addrlen);
- sa.length = (unsigned int)res->ai_addrlen;
- freeaddrinfo(res);
- ISC_LINK_INIT(&sa, link);
- ISC_LIST_INIT(servers);
- ISC_LIST_APPEND(servers, &sa, link);
- result = dns_client_setservers(client, dns_rdataclass_in, NULL,
- &servers);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to set server: %u\n", result);
- exit(1);
- }
-
- /* Create the main task */
- probe_task = NULL;
- result = isc_task_create(taskmgr, 0, &probe_task);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create task: %u\n", result);
- exit(1);
- }
-
- /* Open input file */
- if (argc == 0) {
- input = stdin;
- } else {
- input = fopen(argv[0], "r");
- if (input == NULL) {
- fprintf(stderr, "failed to open input file: %s\n",
- argv[0]);
- exit(1);
- }
- }
-
- /* Set up and start probe */
- for (i = 0; i < MAX_PROBES; i++) {
- probes[i].inuse = false;
- probes[i].domain = NULL;
- dns_fixedname_init(&probes[i].fixedname);
- probes[i].qname = NULL;
- probes[i].qlabel = qlabels;
- probes[i].qname_found = false;
- probes[i].resid = NULL;
- ISC_LIST_INIT(probes[i].nslist);
- probes[i].reqid = NULL;
-
- probes[i].qmessage = NULL;
- dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
- &probes[i].qmessage);
- dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
- &probes[i].rmessage);
- }
- for (i = 0; i < MAX_PROBES; i++) {
- result = probe_domain(&probes[i]);
- if (result == ISC_R_NOMORE) {
- break;
- } else if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to issue an initial probe\n");
- exit(1);
- }
- }
-
- /* Start event loop */
- isc_app_ctxrun(actx);
-
- /* Dump results */
- printf("Per domain results (out of %lu domains):\n", number_of_domains);
- printf(" valid: %lu\n"
- " ignore: %lu\n"
- " nxdomain: %lu\n"
- " othererr: %lu\n"
- " multiplesoa: %lu\n"
- " multiplecname: %lu\n"
- " brokenanswer: %lu\n"
- " lame: %lu\n"
- " unknown: %lu\n"
- " multiple errors: %lu\n",
- domain_stat.valid, domain_stat.ignore, domain_stat.nxdomain,
- domain_stat.othererr, domain_stat.multiplesoa,
- domain_stat.multiplecname, domain_stat.brokenanswer,
- domain_stat.lame, domain_stat.unknown, multiple_error_domains);
- printf("Per server results (out of %lu servers):\n", number_of_servers);
- printf(" valid: %lu\n"
- " ignore: %lu\n"
- " nxdomain: %lu\n"
- " othererr: %lu\n"
- " multiplesoa: %lu\n"
- " multiplecname: %lu\n"
- " brokenanswer: %lu\n"
- " lame: %lu\n"
- " unknown: %lu\n",
- server_stat.valid, server_stat.ignore, server_stat.nxdomain,
- server_stat.othererr, server_stat.multiplesoa,
- server_stat.multiplecname, server_stat.brokenanswer,
- server_stat.lame, server_stat.unknown);
-
- /* Cleanup */
- for (i = 0; i < MAX_PROBES; i++) {
- dns_message_detach(&probes[i].qmessage);
- dns_message_detach(&probes[i].rmessage);
- }
- isc_task_detach(&probe_task);
- dns_client_destroy(&client);
- dns_lib_shutdown();
- isc_app_ctxfinish(actx);
- ctxs_destroy(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
-
- return (0);
-}
diff --git a/external/mpl/bind/dist/lib/samples/resolve.c b/external/mpl/bind/dist/lib/samples/resolve.c
deleted file mode 100644
index 6c773cf166a..00000000000
--- a/external/mpl/bind/dist/lib/samples/resolve.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* $NetBSD: resolve.c,v 1.5 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif /* ifndef WIN32 */
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/app.h>
-#include <isc/base64.h>
-#include <isc/buffer.h>
-#include <isc/commandline.h>
-#include <isc/lib.h>
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/sockaddr.h>
-#include <isc/socket.h>
-#include <isc/task.h>
-#include <isc/timer.h>
-#include <isc/util.h>
-
-#include <dns/client.h>
-#include <dns/fixedname.h>
-#include <dns/keyvalues.h>
-#include <dns/lib.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rdataset.h>
-#include <dns/rdatastruct.h>
-#include <dns/rdatatype.h>
-#include <dns/result.h>
-#include <dns/secalg.h>
-
-#include <dst/dst.h>
-
-#include <irs/netdb.h>
-#include <irs/resconf.h>
-
-static char *algname;
-
-static isc_result_t
-printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
- isc_buffer_t target;
- isc_result_t result;
- isc_region_t r;
- char t[4096];
-
- if (!dns_rdataset_isassociated(rdataset)) {
- printf("[WARN: empty]\n");
- return (ISC_R_SUCCESS);
- }
-
- isc_buffer_init(&target, t, sizeof(t));
-
- result = dns_rdataset_totext(rdataset, owner, false, false, &target);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_usedregion(&target, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
-
- return (ISC_R_SUCCESS);
-}
-
-ISC_PLATFORM_NORETURN_PRE static void
-usage(void) ISC_PLATFORM_NORETURN_POST;
-
-static void
-usage(void) {
- fprintf(stderr, "resolve [-t RRtype] "
- "[[-a algorithm] [-e] -k keyname -K keystring] "
- "[-S domain:serveraddr_for_domain ] [-s server_address]"
- "[-b address[#port]] hostname\n");
-
- exit(1);
-}
-
-static void
-set_key(dns_client_t *client, char *keynamestr, char *keystr, bool is_sep,
- isc_mem_t **mctxp) {
- isc_result_t result;
- dns_fixedname_t fkeyname;
- unsigned int namelen;
- dns_name_t *keyname;
- dns_rdata_dnskey_t keystruct;
- unsigned char keydata[4096];
- isc_buffer_t keydatabuf;
- unsigned char rrdata[4096];
- isc_buffer_t rrdatabuf;
- isc_buffer_t b;
- isc_textregion_t tr;
- isc_region_t r;
- dns_secalg_t alg;
-
- isc_mem_create(mctxp);
-
- if (algname != NULL) {
- tr.base = algname;
- tr.length = strlen(algname);
- result = dns_secalg_fromtext(&alg, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to identify the algorithm\n");
- exit(1);
- }
- } else {
- alg = DNS_KEYALG_RSASHA1;
- }
-
- keystruct.common.rdclass = dns_rdataclass_in;
- keystruct.common.rdtype = dns_rdatatype_dnskey;
- keystruct.flags = DNS_KEYOWNER_ZONE; /* fixed */
- if (is_sep) {
- keystruct.flags |= DNS_KEYFLAG_KSK;
- }
- keystruct.protocol = DNS_KEYPROTO_DNSSEC; /* fixed */
- keystruct.algorithm = alg;
-
- isc_buffer_init(&keydatabuf, keydata, sizeof(keydata));
- isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata));
- result = isc_base64_decodestring(keystr, &keydatabuf);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "base64 decode failed\n");
- exit(1);
- }
- isc_buffer_usedregion(&keydatabuf, &r);
- keystruct.datalen = r.length;
- keystruct.data = r.base;
-
- result = dns_rdata_fromstruct(NULL, keystruct.common.rdclass,
- keystruct.common.rdtype, &keystruct,
- &rrdatabuf);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to construct key rdata\n");
- exit(1);
- }
- namelen = strlen(keynamestr);
- isc_buffer_init(&b, keynamestr, namelen);
- isc_buffer_add(&b, namelen);
- keyname = dns_fixedname_initname(&fkeyname);
- result = dns_name_fromtext(keyname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to construct key name\n");
- exit(1);
- }
- result = dns_client_addtrustedkey(client, dns_rdataclass_in,
- dns_rdatatype_dnskey, keyname,
- &rrdatabuf);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to add key for %s\n", keynamestr);
- exit(1);
- }
-}
-
-static void
-addserver(dns_client_t *client, const char *addrstr, const char *port,
- const char *name_space) {
- struct addrinfo hints, *res;
- int gaierror;
- isc_sockaddr_t sa;
- isc_sockaddrlist_t servers;
- isc_result_t result;
- unsigned int namelen;
- isc_buffer_t b;
- dns_fixedname_t fname;
- dns_name_t *name = NULL;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
- hints.ai_flags = AI_NUMERICHOST;
- gaierror = getaddrinfo(addrstr, port, &hints, &res);
- if (gaierror != 0) {
- fprintf(stderr, "getaddrinfo failed: %s\n",
- gai_strerror(gaierror));
- exit(1);
- }
- INSIST(res->ai_addrlen <= sizeof(sa.type));
- memmove(&sa.type, res->ai_addr, res->ai_addrlen);
- sa.length = (unsigned int)res->ai_addrlen;
- freeaddrinfo(res);
- ISC_LINK_INIT(&sa, link);
- ISC_LIST_INIT(servers);
- ISC_LIST_APPEND(servers, &sa, link);
-
- if (name_space != NULL) {
- namelen = strlen(name_space);
- isc_buffer_constinit(&b, name_space, namelen);
- isc_buffer_add(&b, namelen);
- name = dns_fixedname_initname(&fname);
- result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert qname: %u\n",
- result);
- exit(1);
- }
- }
-
- result = dns_client_setservers(client, dns_rdataclass_in, name,
- &servers);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "set server failed: %u\n", result);
- exit(1);
- }
-}
-
-int
-main(int argc, char *argv[]) {
- int ch;
- isc_textregion_t tr;
- char *server = NULL;
- char *altserver = NULL;
- char *altserveraddr = NULL;
- char *altservername = NULL;
- dns_client_t *client = NULL;
- char *keynamestr = NULL;
- char *keystr = NULL;
- isc_result_t result;
- isc_buffer_t b;
- dns_fixedname_t qname0;
- unsigned int namelen;
- dns_name_t *qname, *name;
- dns_rdatatype_t type = dns_rdatatype_a;
- dns_rdataset_t *rdataset;
- dns_namelist_t namelist;
- isc_mem_t *keymctx = NULL;
- unsigned int clientopt, resopt;
- bool is_sep = false;
- const char *port = "53";
- isc_mem_t *mctx = NULL;
- isc_appctx_t *actx = NULL;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
- struct in_addr in4;
- struct in6_addr in6;
- isc_sockaddr_t a4, a6;
- isc_sockaddr_t *addr4 = NULL, *addr6 = NULL;
-
- while ((ch = isc_commandline_parse(argc, argv, "a:b:es:t:k:K:p:S:")) !=
- -1) {
- switch (ch) {
- case 't':
- tr.base = isc_commandline_argument;
- tr.length = strlen(isc_commandline_argument);
- result = dns_rdatatype_fromtext(&type, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid RRtype: %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- case 'a':
- algname = isc_commandline_argument;
- break;
- case 'b':
- if (inet_pton(AF_INET, isc_commandline_argument,
- &in4) == 1) {
- if (addr4 != NULL) {
- fprintf(stderr, "only one local "
- "address per family "
- "can be specified\n");
- exit(1);
- }
- isc_sockaddr_fromin(&a4, &in4, 0);
- addr4 = &a4;
- } else if (inet_pton(AF_INET6, isc_commandline_argument,
- &in6) == 1) {
- if (addr6 != NULL) {
- fprintf(stderr, "only one local "
- "address per family "
- "can be specified\n");
- exit(1);
- }
- isc_sockaddr_fromin6(&a6, &in6, 0);
- addr6 = &a6;
- } else {
- fprintf(stderr, "invalid address %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- case 'e':
- is_sep = true;
- break;
- case 'S':
- if (altserver != NULL) {
- fprintf(stderr,
- "alternate server "
- "already defined: %s\n",
- altserver);
- exit(1);
- }
- altserver = isc_commandline_argument;
- break;
- case 's':
- if (server != NULL) {
- fprintf(stderr,
- "server "
- "already defined: %s\n",
- server);
- exit(1);
- }
- server = isc_commandline_argument;
- break;
- case 'k':
- keynamestr = isc_commandline_argument;
- break;
- case 'K':
- keystr = isc_commandline_argument;
- break;
- case 'p':
- port = isc_commandline_argument;
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 1) {
- usage();
- }
-
- if (altserver != NULL) {
- char *cp;
-
- cp = strchr(altserver, ':');
- if (cp == NULL) {
- fprintf(stderr, "invalid alternate server: %s\n",
- altserver);
- exit(1);
- }
- *cp = '\0';
- altservername = altserver;
- altserveraddr = cp + 1;
- }
-
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- isc_mem_create(&mctx);
-
- result = isc_appctx_create(mctx, &actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_app_ctxstart(actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_taskmgr_createinctx(mctx, 1, 0, &taskmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_socketmgr_createinctx(mctx, &socketmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_timermgr_createinctx(mctx, &timermgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- clientopt = 0;
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr,
- clientopt, &client, addr4, addr6);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_create failed: %u, %s\n", result,
- isc_result_totext(result));
- exit(1);
- }
-
- /* Set the nameserver */
- if (server == NULL) {
- irs_resconf_t *resconf = NULL;
- isc_sockaddrlist_t *nameservers;
-
- result = irs_resconf_load(mctx, "/etc/resolv.conf", &resconf);
- if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
- fprintf(stderr, "irs_resconf_load failed: %u\n",
- result);
- exit(1);
- }
- nameservers = irs_resconf_getnameservers(resconf);
- result = dns_client_setservers(client, dns_rdataclass_in, NULL,
- nameservers);
- if (result != ISC_R_SUCCESS) {
- irs_resconf_destroy(&resconf);
- fprintf(stderr, "dns_client_setservers failed: %u\n",
- result);
- exit(1);
- }
- irs_resconf_destroy(&resconf);
- } else {
- addserver(client, server, port, NULL);
- }
-
- /* Set the alternate nameserver (when specified) */
- if (altserver != NULL) {
- addserver(client, altserveraddr, port, altservername);
- }
-
- /* Install DNSSEC key (if given) */
- if (keynamestr != NULL) {
- if (keystr == NULL) {
- fprintf(stderr, "key string is missing "
- "while key name is provided\n");
- exit(1);
- }
- set_key(client, keynamestr, keystr, is_sep, &keymctx);
- }
-
- /* Construct qname */
- namelen = strlen(argv[0]);
- isc_buffer_init(&b, argv[0], namelen);
- isc_buffer_add(&b, namelen);
- qname = dns_fixedname_initname(&qname0);
- result = dns_name_fromtext(qname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert qname: %u\n", result);
- }
-
- /* Perform resolution */
- resopt = DNS_CLIENTRESOPT_ALLOWRUN;
- if (keynamestr == NULL) {
- resopt |= DNS_CLIENTRESOPT_NODNSSEC;
- }
- ISC_LIST_INIT(namelist);
- result = dns_client_resolve(client, qname, dns_rdataclass_in, type,
- resopt, &namelist);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "resolution failed: %s\n",
- dns_result_totext(result));
- }
- for (name = ISC_LIST_HEAD(namelist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (printdata(rdataset, name) != ISC_R_SUCCESS) {
- fprintf(stderr, "print data failed\n");
- }
- }
- }
-
- dns_client_freeresanswer(client, &namelist);
-
- /* Cleanup */
-cleanup:
- dns_client_destroy(&client);
-
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- if (actx != NULL) {
- isc_appctx_destroy(&actx);
- }
- isc_mem_detach(&mctx);
-
- if (keynamestr != NULL) {
- isc_mem_destroy(&keymctx);
- }
- dns_lib_shutdown();
-
- return (0);
-}
diff --git a/external/mpl/bind/dist/lib/samples/rootkey.sh b/external/mpl/bind/dist/lib/samples/rootkey.sh
deleted file mode 100644
index 5fddbca141a..00000000000
--- a/external/mpl/bind/dist/lib/samples/rootkey.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-# Fetch a copy of a current root signing key; used for testing
-# DNSSEC validation in 'sample'.
-#
-# After running this script, "sample `cat sample.key` <args>" will
-# perform a lookup as specified in <args> and validate the result
-# using the root key.
-#
-# (This is NOT a secure method of obtaining the root key; it is
-# included here for testing purposes only.)
-dig +noall +answer dnskey . | perl -n -e '
-local ($dn, $ttl, $class, $type, $flags, $proto, $alg, @rest) = split;
-next if ($flags != 257);
-local $key = join("", @rest);
-print "-a $alg -e -k $dn -K $key\n"
-' > sample.key
diff --git a/external/mpl/bind/dist/lib/samples/sample-async.c b/external/mpl/bind/dist/lib/samples/sample-async.c
deleted file mode 100644
index 178e8c97f91..00000000000
--- a/external/mpl/bind/dist/lib/samples/sample-async.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* $NetBSD: sample-async.c,v 1.6 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif /* ifndef WIN32 */
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/app.h>
-#include <isc/buffer.h>
-#include <isc/commandline.h>
-#include <isc/lib.h>
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/sockaddr.h>
-#include <isc/socket.h>
-#include <isc/task.h>
-#include <isc/timer.h>
-#include <isc/util.h>
-
-#include <dns/client.h>
-#include <dns/fixedname.h>
-#include <dns/lib.h>
-#include <dns/name.h>
-#include <dns/rdataset.h>
-#include <dns/rdatatype.h>
-#include <dns/result.h>
-
-#define MAX_SERVERS 10
-#define MAX_QUERIES 100
-
-static dns_client_t *client = NULL;
-static isc_task_t *query_task = NULL;
-static isc_appctx_t *query_actx = NULL;
-static unsigned int outstanding_queries = 0;
-static const char *def_server = "127.0.0.1";
-static FILE *fp;
-
-struct query_trans {
- int id;
- bool inuse;
- dns_rdatatype_t type;
- dns_fixedname_t fixedname;
- dns_name_t *qname;
- dns_namelist_t answerlist;
- dns_clientrestrans_t *xid;
-};
-
-static struct query_trans query_array[MAX_QUERIES];
-
-static isc_result_t
-dispatch_query(struct query_trans *trans);
-
-static void
-ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- if (*taskmgrp != NULL) {
- isc_taskmgr_destroy(taskmgrp);
- }
-
- if (*timermgrp != NULL) {
- isc_timermgr_destroy(timermgrp);
- }
-
- if (*socketmgrp != NULL) {
- isc_socketmgr_destroy(socketmgrp);
- }
-
- if (*actxp != NULL) {
- isc_appctx_destroy(actxp);
- }
-
- if (*mctxp != NULL) {
- isc_mem_destroy(mctxp);
- }
-}
-
-static isc_result_t
-ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- isc_result_t result;
-
- isc_mem_create(mctxp);
-
- result = isc_appctx_create(*mctxp, actxp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_taskmgr_createinctx(*mctxp, 1, 0, taskmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_socketmgr_createinctx(*mctxp, socketmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_timermgr_createinctx(*mctxp, timermgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- return (ISC_R_SUCCESS);
-
-fail:
- ctxs_destroy(mctxp, actxp, taskmgrp, socketmgrp, timermgrp);
-
- return (result);
-}
-
-static isc_result_t
-printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
- isc_buffer_t target;
- isc_result_t result;
- isc_region_t r;
- char t[4096];
-
- isc_buffer_init(&target, t, sizeof(t));
-
- if (!dns_rdataset_isassociated(rdataset)) {
- return (ISC_R_SUCCESS);
- }
- result = dns_rdataset_totext(rdataset, owner, false, false, &target);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_usedregion(&target, &r);
- printf(" %.*s", (int)r.length, (char *)r.base);
-
- return (ISC_R_SUCCESS);
-}
-
-static void
-process_answer(isc_task_t *task, isc_event_t *event) {
- struct query_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- isc_result_t result;
-
- REQUIRE(task == query_task);
- REQUIRE(trans->inuse);
- REQUIRE(outstanding_queries > 0);
-
- printf("answer[%2d]\n", trans->id);
-
- if (rev->result != ISC_R_SUCCESS) {
- printf(" failed: %u(%s)\n", rev->result,
- dns_result_totext(rev->result));
- }
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)printdata(rdataset, name);
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->xid);
-
- isc_event_free(&event);
-
- trans->inuse = false;
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- outstanding_queries--;
-
- result = dispatch_query(trans);
-#if 0 /* for cancel test */
- if (result == ISC_R_SUCCESS) {
- static int count = 0;
-
- if ((++count) % 10 == 0) {
- dns_client_cancelresolve(trans->xid);
- }
- }
-#endif /* if 0 */
- if (result == ISC_R_NOMORE && outstanding_queries == 0) {
- isc_app_ctxshutdown(query_actx);
- }
-}
-
-static isc_result_t
-dispatch_query(struct query_trans *trans) {
- isc_result_t result;
- unsigned int namelen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad hoc constant, but should be enough */
- char *cp;
-
- REQUIRE(trans != NULL);
- REQUIRE(!trans->inuse);
- REQUIRE(ISC_LIST_EMPTY(trans->answerlist));
- REQUIRE(outstanding_queries < MAX_QUERIES);
-
- /* Construct qname */
- cp = fgets(buf, sizeof(buf), fp);
- if (cp == NULL) {
- return (ISC_R_NOMORE);
- }
- /* zap NL if any */
- if ((cp = strchr(buf, '\n')) != NULL) {
- *cp = '\0';
- }
- namelen = strlen(buf);
- isc_buffer_init(&b, buf, namelen);
- isc_buffer_add(&b, namelen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- /* Start resolution */
- result = dns_client_startresolve(
- client, trans->qname, dns_rdataclass_in, trans->type, 0,
- query_task, process_answer, trans, &trans->xid);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- trans->inuse = true;
- outstanding_queries++;
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- dns_fixedname_invalidate(&trans->fixedname);
-
- return (result);
-}
-
-ISC_PLATFORM_NORETURN_PRE static void
-usage(void) ISC_PLATFORM_NORETURN_POST;
-
-static void
-usage(void) {
- fprintf(stderr, "usage: sample-async [-s server_address] [-t RR type] "
- "input_file\n");
-
- exit(1);
-}
-
-int
-main(int argc, char *argv[]) {
- int ch;
- isc_textregion_t tr;
- isc_mem_t *mctx = NULL;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
- int nservers = 0;
- const char *serveraddr[MAX_SERVERS];
- isc_sockaddr_t sa[MAX_SERVERS];
- isc_sockaddrlist_t servers;
- dns_rdatatype_t type = dns_rdatatype_a;
- struct in_addr inaddr;
- isc_result_t result;
- int i;
-
- while ((ch = isc_commandline_parse(argc, argv, "s:t:")) != -1) {
- switch (ch) {
- case 't':
- tr.base = isc_commandline_argument;
- tr.length = strlen(isc_commandline_argument);
- result = dns_rdatatype_fromtext(&type, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid RRtype: %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- case 's':
- if (nservers == MAX_SERVERS) {
- fprintf(stderr, "too many servers (up to %d)\n",
- MAX_SERVERS);
- exit(1);
- }
- serveraddr[nservers++] =
- (const char *)isc_commandline_argument;
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 1) {
- usage();
- }
-
- if (nservers == 0) {
- nservers = 1;
- serveraddr[0] = def_server;
- }
-
- for (i = 0; i < MAX_QUERIES; i++) {
- query_array[i].id = i;
- query_array[i].inuse = false;
- query_array[i].type = type;
- dns_fixedname_init(&query_array[i].fixedname);
- query_array[i].qname = NULL;
- ISC_LIST_INIT(query_array[i].answerlist);
- query_array[i].xid = NULL;
- }
-
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = ctxs_init(&mctx, &query_actx, &taskmgr, &socketmgr, &timermgr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "ctx create failed: %u\n", result);
- exit(1);
- }
-
- isc_app_ctxstart(query_actx);
-
- result = dns_client_createx(mctx, query_actx, taskmgr, socketmgr,
- timermgr, 0, &client, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_createx failed: %u\n", result);
- exit(1);
- }
-
- /* Set nameservers */
- ISC_LIST_INIT(servers);
- for (i = 0; i < nservers; i++) {
- if (inet_pton(AF_INET, serveraddr[i], &inaddr) != 1) {
- fprintf(stderr, "failed to parse IPv4 address %s\n",
- serveraddr[i]);
- exit(1);
- }
- isc_sockaddr_fromin(&sa[i], &inaddr, 53);
- ISC_LIST_APPEND(servers, &sa[i], link);
- }
- result = dns_client_setservers(client, dns_rdataclass_in, NULL,
- &servers);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "set server failed: %u\n", result);
- exit(1);
- }
-
- /* Create the main task */
- query_task = NULL;
- result = isc_task_create(taskmgr, 0, &query_task);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create task: %u\n", result);
- exit(1);
- }
-
- /* Open input file */
- fp = fopen(argv[0], "r");
- if (fp == NULL) {
- fprintf(stderr, "failed to open input file: %s\n", argv[1]);
- exit(1);
- }
-
- /* Dispatch initial queries */
- for (i = 0; i < MAX_QUERIES; i++) {
- result = dispatch_query(&query_array[i]);
- if (result == ISC_R_NOMORE) {
- break;
- }
- }
-
- /* Start event loop */
- isc_app_ctxrun(query_actx);
-
- /* Sanity check */
- for (i = 0; i < MAX_QUERIES; i++) {
- INSIST(!query_array[i].inuse);
- }
-
- /* Cleanup */
- isc_task_detach(&query_task);
- dns_client_destroy(&client);
- dns_lib_shutdown();
- isc_app_ctxfinish(query_actx);
- ctxs_destroy(&mctx, &query_actx, &taskmgr, &socketmgr, &timermgr);
-
- return (0);
-}
diff --git a/external/mpl/bind/dist/lib/samples/sample-gai.c b/external/mpl/bind/dist/lib/samples/sample-gai.c
deleted file mode 100644
index 878954f6783..00000000000
--- a/external/mpl/bind/dist/lib/samples/sample-gai.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* $NetBSD: sample-gai.c,v 1.4 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/net.h>
-#include <isc/print.h>
-
-#include <irs/netdb.h>
-
-static void
-do_gai(int family, char *hostname) {
- struct addrinfo hints, *res, *res0;
- int error;
- char namebuf[1024], addrbuf[1024], servbuf[1024];
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = family;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_CANONNAME;
- error = getaddrinfo(hostname, "http", &hints, &res0);
- if (error) {
- fprintf(stderr, "getaddrinfo failed for %s,family=%d: %s\n",
- hostname, family, gai_strerror(error));
- return;
- }
-
- for (res = res0; res; res = res->ai_next) {
- error = getnameinfo(res->ai_addr, (socklen_t)res->ai_addrlen,
- addrbuf, sizeof(addrbuf), NULL, 0,
- NI_NUMERICHOST);
- if (error == 0) {
- error = getnameinfo(res->ai_addr,
- (socklen_t)res->ai_addrlen, namebuf,
- sizeof(namebuf), servbuf,
- sizeof(servbuf), 0);
- }
- if (error != 0) {
- fprintf(stderr, "getnameinfo failed: %s\n",
- gai_strerror(error));
- } else {
- printf("%s(%s/%s)=%s:%s\n", hostname, res->ai_canonname,
- addrbuf, namebuf, servbuf);
- }
- }
-
- freeaddrinfo(res0);
-}
-
-int
-main(int argc, char *argv[]) {
- if (argc < 2) {
- exit(1);
- }
-
- do_gai(AF_INET, argv[1]);
- do_gai(AF_INET6, argv[1]);
- do_gai(AF_UNSPEC, argv[1]);
-
- return (0);
-}
diff --git a/external/mpl/bind/dist/lib/samples/sample-request.c b/external/mpl/bind/dist/lib/samples/sample-request.c
deleted file mode 100644
index cebecd47f1a..00000000000
--- a/external/mpl/bind/dist/lib/samples/sample-request.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/* $NetBSD: sample-request.c,v 1.4 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif /* ifndef WIN32 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/base64.h>
-#include <isc/buffer.h>
-#include <isc/commandline.h>
-#include <isc/lib.h>
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/sockaddr.h>
-#include <isc/util.h>
-
-#include <dns/client.h>
-#include <dns/fixedname.h>
-#include <dns/keyvalues.h>
-#include <dns/lib.h>
-#include <dns/masterdump.h>
-#include <dns/message.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rdataset.h>
-#include <dns/rdatastruct.h>
-#include <dns/rdatatype.h>
-#include <dns/result.h>
-#include <dns/secalg.h>
-
-#include <dst/dst.h>
-
-static isc_mem_t *mctx;
-static dns_fixedname_t fixedqname;
-
-ISC_PLATFORM_NORETURN_PRE static void
-usage(void) ISC_PLATFORM_NORETURN_POST;
-
-static void
-usage(void) {
- fprintf(stderr, "sample-request [-t RRtype] server_address hostname\n");
-
- exit(1);
-}
-
-static isc_result_t
-make_querymessage(dns_message_t *message, const char *namestr,
- dns_rdatatype_t rdtype) {
- dns_name_t *qname = NULL, *qname0;
- dns_rdataset_t *qrdataset = NULL;
- isc_result_t result;
- isc_buffer_t b;
- unsigned int namelen;
-
- REQUIRE(message != NULL);
- REQUIRE(namestr != NULL);
-
- /* Construct qname */
- namelen = strlen(namestr);
- isc_buffer_constinit(&b, namestr, namelen);
- isc_buffer_add(&b, namelen);
- qname0 = dns_fixedname_initname(&fixedqname);
- result = dns_name_fromtext(qname0, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert qname: %u\n", result);
- return (result);
- }
-
- /* Construct query message */
- message->opcode = dns_opcode_query;
- message->rdclass = dns_rdataclass_in;
-
- result = dns_message_gettempname(message, &qname);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- result = dns_message_gettemprdataset(message, &qrdataset);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- dns_name_init(qname, NULL);
- dns_name_clone(qname0, qname);
- dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
- ISC_LIST_APPEND(qname->list, qrdataset, link);
- dns_message_addname(message, qname, DNS_SECTION_QUESTION);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (qname != NULL) {
- dns_message_puttempname(message, &qname);
- }
- if (qrdataset != NULL) {
- dns_message_puttemprdataset(message, &qrdataset);
- }
- dns_message_detach(&message);
- return (result);
-}
-
-static void
-print_section(dns_message_t *message, int section, isc_buffer_t *buf) {
- isc_result_t result;
- isc_region_t r;
-
- result = dns_message_sectiontotext(message, section,
- &dns_master_style_full, 0, buf);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- isc_buffer_usedregion(buf, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
-
- return;
-
-fail:
- fprintf(stderr, "failed to convert a section\n");
-}
-
-int
-main(int argc, char *argv[]) {
- int ch, i, gaierror;
- struct addrinfo hints, *res;
- isc_textregion_t tr;
- dns_client_t *client = NULL;
- isc_result_t result;
- isc_sockaddr_t sa;
- dns_message_t *qmessage, *rmessage;
- dns_rdatatype_t type = dns_rdatatype_a;
- isc_buffer_t *outputbuf;
-
- while ((ch = isc_commandline_parse(argc, argv, "t:")) != -1) {
- switch (ch) {
- case 't':
- tr.base = isc_commandline_argument;
- tr.length = strlen(isc_commandline_argument);
- result = dns_rdatatype_fromtext(&type, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid RRtype: %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 2) {
- usage();
- }
-
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = dns_client_create(&client, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_create failed: %u\n", result);
- exit(1);
- }
-
- /* Prepare message structures */
- mctx = NULL;
- qmessage = NULL;
- rmessage = NULL;
-
- isc_mem_create(&mctx);
- dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &qmessage);
- dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &rmessage);
-
- /* Initialize the nameserver address */
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
-#ifdef AI_NUMERICHOST
- hints.ai_flags = AI_NUMERICHOST;
-#endif /* ifdef AI_NUMERICHOST */
- gaierror = getaddrinfo(argv[0], "53", &hints, &res);
- if (gaierror != 0) {
- fprintf(stderr, "getaddrinfo failed: %s\n",
- gai_strerror(gaierror));
- exit(1);
- }
- INSIST(res->ai_addrlen <= sizeof(sa.type));
- memmove(&sa.type, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
- sa.length = (unsigned int)res->ai_addrlen;
- ISC_LINK_INIT(&sa, link);
-
- /* Construct qname */
- result = make_querymessage(qmessage, argv[1], type);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create a query\n");
- exit(1);
- }
-
- /* Send request and wait for a response */
- result = dns_client_request(client, qmessage, rmessage, &sa, 0, 0, NULL,
- 60, 0, 3);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to get a response: %s\n",
- dns_result_totext(result));
- }
-
- /* Dump the response */
- outputbuf = NULL;
- isc_buffer_allocate(mctx, &outputbuf, 65535);
- for (i = 0; i < DNS_SECTION_MAX; i++) {
- print_section(rmessage, i, outputbuf);
- isc_buffer_clear(outputbuf);
- }
- isc_buffer_free(&outputbuf);
-
- /* Cleanup */
- dns_message_detach(&qmessage);
- dns_message_detach(&rmessage);
- isc_mem_destroy(&mctx);
- dns_client_destroy(&client);
- dns_lib_shutdown();
-
- return (0);
-}
diff --git a/external/mpl/bind/dist/lib/samples/sample-update.c b/external/mpl/bind/dist/lib/samples/sample-update.c
deleted file mode 100644
index 2cc01806dec..00000000000
--- a/external/mpl/bind/dist/lib/samples/sample-update.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/* $NetBSD: sample-update.c,v 1.5 2021/02/19 16:42:23 christos Exp $ */
-
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif /* ifndef WIN32 */
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <isc/buffer.h>
-#include <isc/commandline.h>
-#include <isc/lex.h>
-#include <isc/lib.h>
-#include <isc/mem.h>
-#include <isc/parseint.h>
-#include <isc/print.h>
-#include <isc/sockaddr.h>
-#include <isc/string.h>
-#include <isc/util.h>
-
-#include <dns/callbacks.h>
-#include <dns/client.h>
-#include <dns/fixedname.h>
-#include <dns/lib.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rdataclass.h>
-#include <dns/rdatalist.h>
-#include <dns/rdataset.h>
-#include <dns/rdatastruct.h>
-#include <dns/rdatatype.h>
-#include <dns/result.h>
-#include <dns/secalg.h>
-#include <dns/tsec.h>
-
-#include <dst/dst.h>
-
-static dns_tsec_t *tsec = NULL;
-static const dns_rdataclass_t default_rdataclass = dns_rdataclass_in;
-static isc_bufferlist_t usedbuffers;
-static ISC_LIST(dns_rdatalist_t) usedrdatalists;
-
-static const char *port = "53";
-
-static void
-setup_tsec(char *keyfile, isc_mem_t *mctx);
-static void
-update_addordelete(isc_mem_t *mctx, char *cmdline, bool isdelete,
- dns_name_t *name);
-static void
-evaluate_prereq(isc_mem_t *mctx, char *cmdline, dns_name_t *name);
-
-ISC_PLATFORM_NORETURN_PRE static void
-usage(void) ISC_PLATFORM_NORETURN_POST;
-
-static void
-usage(void) {
- fprintf(stderr, "sample-update "
- "-s "
- "[-a auth_server] "
- "[-k keyfile] "
- "[-p prerequisite] "
- "[-r recursive_server] "
- "[-z zonename] "
- "(add|delete) \"name TTL RRtype RDATA\"\n");
- exit(1);
-}
-
-#ifdef _WIN32
-static void
-InitSockets(void) {
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- wVersionRequested = MAKEWORD(2, 0);
-
- err = WSAStartup(wVersionRequested, &wsaData);
- if (err != 0) {
- fprintf(stderr, "WSAStartup() failed: %d\n", err);
- exit(1);
- }
-}
-
-static void
-DestroySockets(void) {
- WSACleanup();
-}
-#else /* ifdef _WIN32 */
-#define InitSockets() ((void)0)
-#define DestroySockets() ((void)0)
-#endif /* ifdef _WIN32 */
-
-static bool
-addserver(const char *server, isc_sockaddrlist_t *list,
- isc_sockaddr_t *sockaddr) {
- struct addrinfo hints, *res;
- int gaierror;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
-#ifdef AI_NUMERICHOST
- hints.ai_flags |= AI_NUMERICHOST;
-#endif /* ifdef AI_NUMERICHOST */
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif /* ifdef AI_NUMERICSERV */
- InitSockets();
- gaierror = getaddrinfo(server, port, &hints, &res);
- if (gaierror != 0) {
- fprintf(stderr, "getaddrinfo(%s) failed: %s\n", server,
- gai_strerror(gaierror));
- DestroySockets();
- return (false);
- }
- INSIST(res->ai_addrlen <= sizeof(sockaddr->type));
- memmove(&sockaddr->type, res->ai_addr, res->ai_addrlen);
- sockaddr->length = (unsigned int)res->ai_addrlen;
- ISC_LINK_INIT(sockaddr, link);
- ISC_LIST_APPEND(*list, sockaddr, link);
- freeaddrinfo(res);
- DestroySockets();
- return (true);
-}
-
-int
-main(int argc, char *argv[]) {
- int ch;
- dns_client_t *client = NULL;
- char *zonenamestr = NULL;
- char *keyfilename = NULL;
- char *prereqstr = NULL;
- isc_sockaddr_t sa_auth[10], sa_recursive[10];
- unsigned int nsa_auth = 0, nsa_recursive = 0;
- isc_sockaddrlist_t rec_servers;
- isc_sockaddrlist_t auth_servers, *auth_serversp = &auth_servers;
- isc_result_t result;
- bool isdelete;
- isc_buffer_t b, *buf;
- dns_fixedname_t zname0, pname0, uname0;
- unsigned int namelen;
- dns_name_t *zname = NULL, *uname, *pname;
- dns_rdataset_t *rdataset;
- dns_rdatalist_t *rdatalist;
- dns_rdata_t *rdata;
- dns_namelist_t updatelist, prereqlist, *prereqlistp = NULL;
- isc_mem_t *umctx = NULL;
- bool sendtwice = false;
-
- ISC_LIST_INIT(auth_servers);
- ISC_LIST_INIT(rec_servers);
-
- while ((ch = isc_commandline_parse(argc, argv, "a:k:p:P:r:sz:")) != EOF)
- {
- switch (ch) {
- case 'k':
- keyfilename = isc_commandline_argument;
- break;
- case 'a':
- if (nsa_auth < sizeof(sa_auth) / sizeof(*sa_auth) &&
- addserver(isc_commandline_argument, &auth_servers,
- &sa_auth[nsa_auth]))
- {
- nsa_auth++;
- }
- break;
- case 'p':
- prereqstr = isc_commandline_argument;
- break;
- case 'P':
- port = isc_commandline_argument;
- break;
- case 'r':
- if (nsa_recursive < sizeof(sa_recursive) /
- sizeof(*sa_recursive) &&
- addserver(isc_commandline_argument, &rec_servers,
- &sa_recursive[nsa_recursive]))
- {
- nsa_recursive++;
- }
- break;
- case 's':
- sendtwice = true;
- break;
- case 'z':
- zonenamestr = isc_commandline_argument;
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 2) {
- usage();
- }
-
- /* command line argument validation */
- if (strcmp(argv[0], "delete") == 0) {
- isdelete = true;
- } else if (strcmp(argv[0], "add") == 0) {
- isdelete = false;
- } else {
- fprintf(stderr, "invalid update command: %s\n", argv[0]);
- exit(1);
- }
-
- if (ISC_LIST_HEAD(auth_servers) == NULL &&
- ISC_LIST_HEAD(rec_servers) == NULL) {
- fprintf(stderr, "authoritative or recursive servers "
- "must be specified\n");
- usage();
- }
-
- /* Initialization */
- ISC_LIST_INIT(usedbuffers);
- ISC_LIST_INIT(usedrdatalists);
- ISC_LIST_INIT(prereqlist);
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
- isc_mem_create(&umctx);
-
- result = dns_client_create(&client, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_create failed: %u\n", result);
- exit(1);
- }
-
- /* Construct zone name */
- zname = NULL;
- if (zonenamestr != NULL) {
- namelen = strlen(zonenamestr);
- isc_buffer_init(&b, zonenamestr, namelen);
- isc_buffer_add(&b, namelen);
- zname = dns_fixedname_initname(&zname0);
- result = dns_name_fromtext(zname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert zone name: %u\n",
- result);
- }
- }
-
- /* Construct prerequisite name (if given) */
- if (prereqstr != NULL) {
- pname = dns_fixedname_initname(&pname0);
- evaluate_prereq(umctx, prereqstr, pname);
- ISC_LIST_APPEND(prereqlist, pname, link);
- prereqlistp = &prereqlist;
- }
-
- /* Construct update name */
- ISC_LIST_INIT(updatelist);
- uname = dns_fixedname_initname(&uname0);
- update_addordelete(umctx, argv[1], isdelete, uname);
- ISC_LIST_APPEND(updatelist, uname, link);
-
- /* Set up TSIG/SIG(0) key (if given) */
- if (keyfilename != NULL) {
- setup_tsec(keyfilename, umctx);
- }
-
- if (ISC_LIST_HEAD(auth_servers) == NULL) {
- auth_serversp = NULL;
- }
-
- /* Perform update */
- result = dns_client_update(client, default_rdataclass, /* XXX: fixed */
- zname, prereqlistp, &updatelist,
- auth_serversp, tsec, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "update failed: %s\n",
- dns_result_totext(result));
- } else {
- fprintf(stderr, "update succeeded\n");
- }
-
- if (sendtwice) {
- /* Perform 2nd update */
- result = dns_client_update(client, default_rdataclass, /* XXX:
- * fixed
- */
- zname, prereqlistp, &updatelist,
- auth_serversp, tsec, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "2nd update failed: %s\n",
- dns_result_totext(result));
- } else {
- fprintf(stderr, "2nd update succeeded\n");
- }
- }
-
- /* Cleanup */
- while ((pname = ISC_LIST_HEAD(prereqlist)) != NULL) {
- while ((rdataset = ISC_LIST_HEAD(pname->list)) != NULL) {
- ISC_LIST_UNLINK(pname->list, rdataset, link);
- dns_rdataset_disassociate(rdataset);
- isc_mem_put(umctx, rdataset, sizeof(*rdataset));
- }
- ISC_LIST_UNLINK(prereqlist, pname, link);
- }
- while ((uname = ISC_LIST_HEAD(updatelist)) != NULL) {
- while ((rdataset = ISC_LIST_HEAD(uname->list)) != NULL) {
- ISC_LIST_UNLINK(uname->list, rdataset, link);
- dns_rdataset_disassociate(rdataset);
- isc_mem_put(umctx, rdataset, sizeof(*rdataset));
- }
- ISC_LIST_UNLINK(updatelist, uname, link);
- }
- while ((rdatalist = ISC_LIST_HEAD(usedrdatalists)) != NULL) {
- while ((rdata = ISC_LIST_HEAD(rdatalist->rdata)) != NULL) {
- ISC_LIST_UNLINK(rdatalist->rdata, rdata, link);
- isc_mem_put(umctx, rdata, sizeof(*rdata));
- }
- ISC_LIST_UNLINK(usedrdatalists, rdatalist, link);
- isc_mem_put(umctx, rdatalist, sizeof(*rdatalist));
- }
- while ((buf = ISC_LIST_HEAD(usedbuffers)) != NULL) {
- ISC_LIST_UNLINK(usedbuffers, buf, link);
- isc_buffer_free(&buf);
- }
- if (tsec != NULL) {
- dns_tsec_destroy(&tsec);
- }
- isc_mem_destroy(&umctx);
- dns_client_destroy(&client);
- dns_lib_shutdown();
-
- return (0);
-}
-
-/*
- * Subroutines borrowed from nsupdate.c
- */
-#define MAXWIRE (64 * 1024)
-#define TTL_MAX 2147483647U /* Maximum signed 32 bit integer. */
-
-static char *
-nsu_strsep(char **stringp, const char *delim) {
- char *string = *stringp;
- char *s;
- const char *d;
- char sc, dc;
-
- if (string == NULL) {
- return (NULL);
- }
-
- for (; *string != '\0'; string++) {
- sc = *string;
- for (d = delim; (dc = *d) != '\0'; d++) {
- if (sc == dc) {
- break;
- }
- }
- if (dc == 0) {
- break;
- }
- }
-
- for (s = string; *s != '\0'; s++) {
- sc = *s;
- for (d = delim; (dc = *d) != '\0'; d++) {
- if (sc == dc) {
- *s++ = '\0';
- *stringp = s;
- return (string);
- }
- }
- }
- *stringp = NULL;
- return (string);
-}
-
-static void
-fatal(const char *format, ...) {
- va_list args;
-
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
- exit(1);
-}
-
-static inline void
-check_result(isc_result_t result, const char *msg) {
- if (result != ISC_R_SUCCESS) {
- fatal("%s: %s", msg, isc_result_totext(result));
- }
-}
-
-static void
-parse_name(char **cmdlinep, dns_name_t *name) {
- isc_result_t result;
- char *word;
- isc_buffer_t source;
-
- word = nsu_strsep(cmdlinep, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read owner name\n");
- exit(1);
- }
-
- isc_buffer_init(&source, word, strlen(word));
- isc_buffer_add(&source, strlen(word));
- result = dns_name_fromtext(name, &source, dns_rootname, 0, NULL);
- check_result(result, "dns_name_fromtext");
- isc_buffer_invalidate(&source);
-}
-
-static void
-parse_rdata(isc_mem_t *mctx, char **cmdlinep, dns_rdataclass_t rdataclass,
- dns_rdatatype_t rdatatype, dns_rdata_t *rdata) {
- char *cmdline = *cmdlinep;
- isc_buffer_t source, *buf = NULL, *newbuf = NULL;
- isc_region_t r;
- isc_lex_t *lex = NULL;
- dns_rdatacallbacks_t callbacks;
- isc_result_t result;
-
- while (cmdline != NULL && *cmdline != 0 &&
- isspace((unsigned char)*cmdline)) {
- cmdline++;
- }
-
- if (cmdline != NULL && *cmdline != 0) {
- dns_rdatacallbacks_init(&callbacks);
- result = isc_lex_create(mctx, strlen(cmdline), &lex);
- check_result(result, "isc_lex_create");
- isc_buffer_init(&source, cmdline, strlen(cmdline));
- isc_buffer_add(&source, strlen(cmdline));
- result = isc_lex_openbuffer(lex, &source);
- check_result(result, "isc_lex_openbuffer");
- isc_buffer_allocate(mctx, &buf, MAXWIRE);
- result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex,
- dns_rootname, 0, mctx, buf,
- &callbacks);
- isc_lex_destroy(&lex);
- if (result == ISC_R_SUCCESS) {
- isc_buffer_usedregion(buf, &r);
- isc_buffer_allocate(mctx, &newbuf, r.length);
- isc_buffer_putmem(newbuf, r.base, r.length);
- isc_buffer_usedregion(newbuf, &r);
- dns_rdata_reset(rdata);
- dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
- isc_buffer_free(&buf);
- ISC_LIST_APPEND(usedbuffers, newbuf, link);
- } else {
- fprintf(stderr, "invalid rdata format: %s\n",
- isc_result_totext(result));
- isc_buffer_free(&buf);
- exit(1);
- }
- } else {
- rdata->flags = DNS_RDATA_UPDATE;
- }
- *cmdlinep = cmdline;
-}
-
-static void
-update_addordelete(isc_mem_t *mctx, char *cmdline, bool isdelete,
- dns_name_t *name) {
- isc_result_t result;
- uint32_t ttl;
- char *word;
- dns_rdataclass_t rdataclass;
- dns_rdatatype_t rdatatype;
- dns_rdata_t *rdata = NULL;
- dns_rdatalist_t *rdatalist = NULL;
- dns_rdataset_t *rdataset = NULL;
- isc_textregion_t region;
-
- /*
- * Read the owner name.
- */
- parse_name(&cmdline, name);
-
- rdata = isc_mem_get(mctx, sizeof(*rdata));
- dns_rdata_init(rdata);
-
- /*
- * If this is an add, read the TTL and verify that it's in range.
- * If it's a delete, ignore a TTL if present (for compatibility).
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- if (!isdelete) {
- fprintf(stderr, "could not read owner ttl\n");
- exit(1);
- } else {
- ttl = 0;
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- }
- }
- result = isc_parse_uint32(&ttl, word, 10);
- if (result != ISC_R_SUCCESS) {
- if (isdelete) {
- ttl = 0;
- goto parseclass;
- } else {
- fprintf(stderr, "ttl '%s': %s\n", word,
- isc_result_totext(result));
- exit(1);
- }
- }
-
- if (isdelete) {
- ttl = 0;
- } else if (ttl > TTL_MAX) {
- fprintf(stderr, "ttl '%s' is out of range (0 to %u)\n", word,
- TTL_MAX);
- exit(1);
- }
-
- /*
- * Read the class or type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
-parseclass:
- if (word == NULL || *word == 0) {
- if (isdelete) {
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- } else {
- fprintf(stderr, "could not read class or type\n");
- exit(1);
- }
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdataclass_fromtext(&rdataclass, &region);
- if (result == ISC_R_SUCCESS) {
- /*
- * Now read the type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- if (isdelete) {
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- } else {
- fprintf(stderr, "could not read type\n");
- exit(1);
- }
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdatatype_fromtext(&rdatatype, &region);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "'%s' is not a valid type: %s\n", word,
- isc_result_totext(result));
- exit(1);
- }
- } else {
- rdataclass = default_rdataclass;
- result = dns_rdatatype_fromtext(&rdatatype, &region);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr,
- "'%s' is not a valid class or type: "
- "%s\n",
- word, isc_result_totext(result));
- exit(1);
- }
- }
-
- parse_rdata(mctx, &cmdline, rdataclass, rdatatype, rdata);
-
- if (isdelete) {
- if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
- rdataclass = dns_rdataclass_any;
- } else {
- rdataclass = dns_rdataclass_none;
- }
- } else {
- if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
- fprintf(stderr, "could not read rdata\n");
- exit(1);
- }
- }
-
-doneparsing:
-
- rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
- dns_rdatalist_init(rdatalist);
- rdatalist->type = rdatatype;
- rdatalist->rdclass = rdataclass;
- rdatalist->covers = rdatatype;
- rdatalist->ttl = (dns_ttl_t)ttl;
- ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
- ISC_LIST_APPEND(usedrdatalists, rdatalist, link);
-
- rdataset = isc_mem_get(mctx, sizeof(*rdataset));
- dns_rdataset_init(rdataset);
- dns_rdatalist_tordataset(rdatalist, rdataset);
- dns_rdataset_setownercase(rdataset, name);
- ISC_LIST_INIT(name->list);
- ISC_LIST_APPEND(name->list, rdataset, link);
-}
-
-static void
-make_prereq(isc_mem_t *mctx, char *cmdline, bool ispositive, bool isrrset,
- dns_name_t *name) {
- isc_result_t result;
- char *word;
- isc_textregion_t region;
- dns_rdataset_t *rdataset = NULL;
- dns_rdatalist_t *rdatalist = NULL;
- dns_rdataclass_t rdataclass;
- dns_rdatatype_t rdatatype;
- dns_rdata_t *rdata = NULL;
-
- /*
- * Read the owner name
- */
- parse_name(&cmdline, name);
-
- /*
- * If this is an rrset prereq, read the class or type.
- */
- if (isrrset) {
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read class or type\n");
- exit(1);
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdataclass_fromtext(&rdataclass, &region);
- if (result == ISC_R_SUCCESS) {
- /*
- * Now read the type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read type\n");
- exit(1);
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdatatype_fromtext(&rdatatype, &region);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid type: %s\n", word);
- exit(1);
- }
- } else {
- rdataclass = default_rdataclass;
- result = dns_rdatatype_fromtext(&rdatatype, &region);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid type: %s\n", word);
- exit(1);
- }
- }
- } else {
- rdatatype = dns_rdatatype_any;
- }
-
- rdata = isc_mem_get(mctx, sizeof(*rdata));
- dns_rdata_init(rdata);
-
- if (isrrset && ispositive) {
- parse_rdata(mctx, &cmdline, rdataclass, rdatatype, rdata);
- } else {
- rdata->flags = DNS_RDATA_UPDATE;
- }
-
- rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
- dns_rdatalist_init(rdatalist);
- rdatalist->type = rdatatype;
- if (ispositive) {
- if (isrrset && rdata->data != NULL) {
- rdatalist->rdclass = rdataclass;
- } else {
- rdatalist->rdclass = dns_rdataclass_any;
- }
- } else {
- rdatalist->rdclass = dns_rdataclass_none;
- }
- rdata->rdclass = rdatalist->rdclass;
- rdata->type = rdatatype;
- ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
- ISC_LIST_APPEND(usedrdatalists, rdatalist, link);
-
- rdataset = isc_mem_get(mctx, sizeof(*rdataset));
- dns_rdataset_init(rdataset);
- dns_rdatalist_tordataset(rdatalist, rdataset);
- dns_rdataset_setownercase(rdataset, name);
- ISC_LIST_INIT(name->list);
- ISC_LIST_APPEND(name->list, rdataset, link);
-}
-
-static void
-evaluate_prereq(isc_mem_t *mctx, char *cmdline, dns_name_t *name) {
- char *word;
- bool ispositive, isrrset;
-
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read operation code\n");
- exit(1);
- }
- if (strcasecmp(word, "nxdomain") == 0) {
- ispositive = false;
- isrrset = false;
- } else if (strcasecmp(word, "yxdomain") == 0) {
- ispositive = true;
- isrrset = false;
- } else if (strcasecmp(word, "nxrrset") == 0) {
- ispositive = false;
- isrrset = true;
- } else if (strcasecmp(word, "yxrrset") == 0) {
- ispositive = true;
- isrrset = true;
- } else {
- fprintf(stderr, "incorrect operation code: %s\n", word);
- exit(1);
- }
-
- make_prereq(mctx, cmdline, ispositive, isrrset, name);
-}
-
-static void
-setup_tsec(char *keyfile, isc_mem_t *mctx) {
- dst_key_t *dstkey = NULL;
- isc_result_t result;
- dns_tsectype_t tsectype;
-
- result = dst_key_fromnamedfile(
- keyfile, NULL, DST_TYPE_PRIVATE | DST_TYPE_KEY, mctx, &dstkey);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "could not read key from %s: %s\n", keyfile,
- isc_result_totext(result));
- exit(1);
- }
-
- if (dst_key_alg(dstkey) == DST_ALG_HMACMD5) {
- tsectype = dns_tsectype_tsig;
- } else {
- tsectype = dns_tsectype_sig0;
- }
-
- result = dns_tsec_create(mctx, tsectype, dstkey, &tsec);
- dst_key_free(&dstkey);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "could not create tsec: %s\n",
- isc_result_totext(result));
- exit(1);
- }
-}
diff --git a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.filters.in
deleted file mode 100644
index f425f856c3d..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-async.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.in
deleted file mode 100644
index ac845e1656e..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>async</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-async.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/async.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.filters.in
deleted file mode 100644
index 30b1864f8ac..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-gai.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.in
deleted file mode 100644
index e6e9052f25d..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>gai</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;..\..\irs\win32\include;..\..\irs\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);..\..\irs\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;libirs.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;..\..\irs\win32\include;..\..\irs\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);..\..\irs\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;libirs.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-gai.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/gai.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.filters.in
deleted file mode 100644
index 0c43dfd5992..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\nsprobe.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.in
deleted file mode 100644
index e8d6b7ee0dd..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>nsprobe</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\nsprobe.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/nsprobe.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.filters.in
deleted file mode 100644
index 0ddc9df5598..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-request.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.in
deleted file mode 100644
index fae0a18361d..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{FF440E85-7450-439C-82EE-04C464512D0E}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>request</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-request.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/request.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.filters.in
deleted file mode 100644
index e866b849756..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\resolve.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.in
deleted file mode 100644
index 3f776a7c74e..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{F66D8B7E-721D-4602-99AD-820D19AD1313}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>resolve</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;..\..\irs\win32\include;..\..\irs\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);..\..\irs\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;libirs.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;..\..\irs\win32\include;..\..\irs\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);..\..\irs\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;libirs.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\resolve.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/resolve.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.filters.in b/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.filters.in
deleted file mode 100644
index 02884086527..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-update.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.in b/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.in
deleted file mode 100644
index 8616edd300b..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|@PLATFORM@">
- <Configuration>Debug</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|@PLATFORM@">
- <Configuration>Release</Configuration>
- <Platform>@PLATFORM@</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{05682E12-523F-4DAE-8E6D-ADFDBC308AFD}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>update</RootNamespace>
- @WINDOWS_TARGET_PLATFORM_VERSION@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- @PLATFORM_TOOLSET@
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\Build\$(Configuration)\</OutDir>
- <IntDir>.\$(Configuration)\</IntDir>
- <IntDirSharingDetected>None</IntDirSharingDetected>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <TreatWarningAsError>false</TreatWarningAsError>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <BrowseInformation>true</BrowseInformation>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'">
- <ClCompile>
- <WarningLevel>Level1</WarningLevel>
- <TreatWarningAsError>true</TreatWarningAsError>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <WholeProgramOptimization>false</WholeProgramOptimization>
- <StringPooling>true</StringPooling>
- <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
- <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
- <ObjectFileName>.\$(Configuration)\</ObjectFileName>
- <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
- <AdditionalIncludeDirectories>.\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <CompileAs>CompileAsC</CompileAs>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
- <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
- <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\sample-update.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.user b/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.user
deleted file mode 100644
index 695b5c78b91..00000000000
--- a/external/mpl/bind/dist/lib/samples/win32/update.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-</Project> \ No newline at end of file
diff --git a/external/mpl/bind/dist/win32utils/libuv.diff b/external/mpl/bind/dist/win32utils/libuv.diff
deleted file mode 100644
index 41f3796cccc..00000000000
--- a/external/mpl/bind/dist/win32utils/libuv.diff
+++ /dev/null
@@ -1,27 +0,0 @@
-To make TCP listening properly multithreaded, we need to have the
-uv_export() and uv_import() functions that were removed from libuv.
-The alternative is passing sockets over IPC, which is complicated and
-error prone.
-
-To make it simple, we export two internal functions from libuv; they will
-be used in lib/isc/netmgr/uv-compat.c by our versions of the uv_export()
-and uv_import() functions.
-
-diff --git a/src/win/internal.h b/src/win/internal.h
-index 058ddb8e..a9dc4168 100644
---- a/src/win/internal.h
-+++ b/src/win/internal.h
-@@ -92,11 +92,11 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
- void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp);
- void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle);
-
--int uv__tcp_xfer_export(uv_tcp_t* handle,
-+UV_EXTERN int uv__tcp_xfer_export(uv_tcp_t* handle,
- int pid,
- uv__ipc_socket_xfer_type_t* xfer_type,
- uv__ipc_socket_xfer_info_t* xfer_info);
--int uv__tcp_xfer_import(uv_tcp_t* tcp,
-+UV_EXTERN int uv__tcp_xfer_import(uv_tcp_t* tcp,
- uv__ipc_socket_xfer_type_t xfer_type,
- uv__ipc_socket_xfer_info_t* xfer_info);
-
diff --git a/external/mpl/bind/include/config.h b/external/mpl/bind/include/config.h
index 96261ec5924..565e5c372ed 100644
--- a/external/mpl/bind/include/config.h
+++ b/external/mpl/bind/include/config.h
@@ -157,9 +157,6 @@
/* Define to 1 if you have the `EVP_sha512' function. */
#define HAVE_EVP_SHA512 1
-/* Define to 1 if you have the `explicit_bzero' function. */
-/* #undef HAVE_EXPLICIT_BZERO */
-
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
@@ -178,6 +175,12 @@
/* Define to 1 if the system has the `destructor' function attribute */
#define HAVE_FUNC_ATTRIBUTE_DESTRUCTOR 1
+/* Define to 1 if the system has the `malloc' function attribute */
+#define HAVE_FUNC_ATTRIBUTE_MALLOC 1
+
+/* Define to 1 if the system has the `returns_nonnull' function attribute */
+#define HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL 1
+
/* Build with GeoIP2 support */
/* #undef HAVE_GEOIP2 */
@@ -242,7 +245,7 @@
#define HAVE_KRB5_KRB5_H 1
/* define if system have backtrace function */
-/* #undef HAVE_LIBCTRACE */
+#define HAVE_LIBCTRACE 1
/* Define if libidn2 was found */
/* #undef HAVE_LIBIDN2 */
@@ -271,15 +274,15 @@
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
+/* define if extended attributes for malloc are available */
+/* #undef HAVE_MALLOC_EXT_ATTR */
+
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
#define HAVE_MMAP 1
-/* Define to 1 if you have the `nanosleep' function. */
-#define HAVE_NANOSLEEP 1
-
/* Define to 1 if you have the <net/if6.h> header file. */
/* #undef HAVE_NET_IF6_H */
@@ -505,24 +508,6 @@
/* define if the compiler supports _Unwind_Backtrace() */
#define HAVE_UNWIND_BACKTRACE 1
-/* Define to 1 if you have the `usleep' function. */
-#define HAVE_USLEEP 1
-
-/* Define to 1 if you have the `uv_handle_get_data' function. */
-#define HAVE_UV_HANDLE_GET_DATA 1
-
-/* Define to 1 if you have the `uv_handle_set_data' function. */
-#define HAVE_UV_HANDLE_SET_DATA 1
-
-/* Define to 1 if you have the `uv_import' function. */
-/* #undef HAVE_UV_IMPORT */
-
-/* Define to 1 if you have the `uv_translate_sys_error' function. */
-#define HAVE_UV_TRANSLATE_SYS_ERROR 1
-
-/* Define to 1 if you have the `uv_udp_connect' function. */
-#define HAVE_UV_UDP_CONNECT 1
-
/* Use zlib library */
#define HAVE_ZLIB 1
diff --git a/external/mpl/bind/include/dns/rdatastruct.h b/external/mpl/bind/include/dns/rdatastruct.h
index 36127b3f95f..842f3f6b7b5 100644
--- a/external/mpl/bind/include/dns/rdatastruct.h
+++ b/external/mpl/bind/include/dns/rdatastruct.h
@@ -1807,18 +1807,19 @@ typedef struct dns_rdata_csync {
#ifndef GENERIC_ZONEMD_63_H
#define GENERIC_ZONEMD_63_H 1
-/* Digest type(s). Currently only SHA-384 is defined. */
+/* Known digest type(s). */
#define DNS_ZONEMD_DIGEST_SHA384 (1)
+#define DNS_ZONEMD_DIGEST_SHA512 (2)
/*
- * \brief per draft-wessels-zone-digest-05
+ * \brief per RFC 8976
*/
typedef struct dns_rdata_zonemd {
dns_rdatacommon_t common;
isc_mem_t *mctx;
uint32_t serial;
+ uint8_t scheme;
uint8_t digest_type;
- uint8_t reserved;
unsigned char *digest;
uint16_t length;
} dns_rdata_zonemd_t;
diff --git a/external/mpl/bind/include/irs/netdb.h b/external/mpl/bind/include/irs/netdb.h
index 0b2816b1b6b..bf3dd23843a 100644
--- a/external/mpl/bind/include/irs/netdb.h
+++ b/external/mpl/bind/include/irs/netdb.h
@@ -3,7 +3,7 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
diff --git a/external/mpl/bind/include/isc/stdatomic.h b/external/mpl/bind/include/isc/stdatomic.h
index fb1f6969dda..82df45acd79 100644
--- a/external/mpl/bind/include/isc/stdatomic.h
+++ b/external/mpl/bind/include/isc/stdatomic.h
@@ -142,7 +142,7 @@ typedef uintmax_t atomic_uintmax_t;
__c11_atomic_compare_exchange_weak_explicit(obj, expected, desired, \
succ, fail)
#define atomic_exchange_explicit(obj, desired, order) \
- __c11_atomic_exchange_explicit(obj, desired, order)
+ __c11_atomic_exchange_explicit(obj, expected, order)
#elif defined(__GNUC_ATOMICS) /* __atomic builtins */
#define atomic_init(obj, desired) (*obj = desired)
#define atomic_load_explicit(obj, order) __atomic_load_n(obj, order)
@@ -185,10 +185,10 @@ typedef uintmax_t atomic_uintmax_t;
fail) \
({ \
__typeof__(obj) __v; \
- _Bool __r; \
+ _Bool __r; \
__v = (__typeof__(obj))__sync_val_compare_and_swap( \
obj, *(expected), desired); \
- __r = ((__typeof__(obj)) * (expected) == __v); \
+ __r = ((__typeof__(obj))*(expected) == __v); \
*(expected) = __v; \
__r; \
})
diff --git a/external/mpl/bind/lib/libbind9/shlib_version b/external/mpl/bind/lib/libbind9/shlib_version
index 40d7bdb277f..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libbind9/shlib_version
+++ b/external/mpl/bind/lib/libbind9/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:14 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libdns/shlib_version b/external/mpl/bind/lib/libdns/shlib_version
index 40d7bdb277f..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libdns/shlib_version
+++ b/external/mpl/bind/lib/libdns/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:14 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libirs/shlib_version b/external/mpl/bind/lib/libirs/shlib_version
index 40d7bdb277f..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libirs/shlib_version
+++ b/external/mpl/bind/lib/libirs/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:14 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libisc/Makefile b/external/mpl/bind/lib/libisc/Makefile
index b36c56ad5c9..c305842b14a 100644
--- a/external/mpl/bind/lib/libisc/Makefile
+++ b/external/mpl/bind/lib/libisc/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.16 2021/04/29 17:26:15 christos Exp $
+# $NetBSD: Makefile,v 1.17 2021/08/19 11:50:21 christos Exp $
LIB=isc
#USE_SHLIBDIR= yes
@@ -35,14 +35,14 @@ CRYPTO_SRCS= aes.c
SRCS= app.c assertions.c astack.c base32.c base64.c bind9.c buffer.c \
bufferlist.c commandline.c crc64.c counter.c error.c event.c \
- hash.c heap.c hex.c hmac.c hp.c httpd.c ht.c \
+ hash.c heap.c hex.c hmac.c hp.c httpd.c ht.c managers.c \
iterated_hash.c lex.c lfsr.c lib.c log.c md.c mem.c \
mutexblock.c netaddr.c netscope.c nonce.c parseint.c \
pool.c portset.c queue.c quota.c radix.c random.c \
ratelimiter.c regex.c trampoline.c \
region.c result.c rwlock.c safe.c serial.c siphash.c \
sockaddr.c stats.c string.c symtab.c task.c \
- taskpool.c timer.c tls.c tlsdns.c tm.c utf8.c version.c \
+ taskpool.c timer.c tls.c tm.c utf8.c version.c \
${UNIX_SRCS} ${PTHREAD_SRCS} ${CRYPTO_SRCS} ${NETMGR_SRCS}
diff --git a/external/mpl/bind/lib/libisc/shlib_version b/external/mpl/bind/lib/libisc/shlib_version
index 147d1324b9b..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libisc/shlib_version
+++ b/external/mpl/bind/lib/libisc/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:15 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libisccc/shlib_version b/external/mpl/bind/lib/libisccc/shlib_version
index 147d1324b9b..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libisccc/shlib_version
+++ b/external/mpl/bind/lib/libisccc/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:15 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libisccfg/shlib_version b/external/mpl/bind/lib/libisccfg/shlib_version
index 147d1324b9b..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libisccfg/shlib_version
+++ b/external/mpl/bind/lib/libisccfg/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:15 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0
diff --git a/external/mpl/bind/lib/libns/shlib_version b/external/mpl/bind/lib/libns/shlib_version
index 147d1324b9b..2aef8e0c6a9 100644
--- a/external/mpl/bind/lib/libns/shlib_version
+++ b/external/mpl/bind/lib/libns/shlib_version
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.9 2021/04/29 17:26:15 christos Exp $
+# $NetBSD: shlib_version,v 1.10 2021/08/19 11:50:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
-major=17
+major=18
minor=0