external/bsd/bind/dist/lib/dns/adb.c
author msaitoh <msaitoh@NetBSD.org>
Fri, 26 Dec 2014 03:08:06 +0000
branchnetbsd-6-1
changeset 277066 8f6a14690a1a
parent 256446 593376b3bf23
child 277127 23d5207bb72e
permissions -rw-r--r--
Pull up following revision(s) (requested by spz in ticket #1217): distrib/sets/lists/base/ad.mips64eb patch distrib/sets/lists/base/ad.mips64el patch distrib/sets/lists/base/md.amd64 patch distrib/sets/lists/base/md.sparc64 patch distrib/sets/lists/base/shl.mi patch distrib/sets/lists/comp/ad.mips64eb patch distrib/sets/lists/comp/ad.mips64el patch distrib/sets/lists/comp/md.amd64 patch distrib/sets/lists/comp/md.sparc64 patch distrib/sets/lists/comp/mi patch distrib/sets/lists/comp/shl.mi patch external/bsd/bind/Makefile.inc patch external/bsd/bind/dist/CHANGES patch external/bsd/bind/dist/COPYRIGHT patch external/bsd/bind/dist/FAQ patch external/bsd/bind/dist/FAQ.xml patch external/bsd/bind/dist/HISTORY patch external/bsd/bind/dist/Makefile.in patch external/bsd/bind/dist/README patch external/bsd/bind/dist/REDIRECT-NOTES delete external/bsd/bind/dist/acconfig.h patch external/bsd/bind/dist/aclocal.m4 patch external/bsd/bind/dist/config.guess patch external/bsd/bind/dist/config.h.in patch external/bsd/bind/dist/config.h.win32 patch external/bsd/bind/dist/config.sub patch external/bsd/bind/dist/configure patch external/bsd/bind/dist/configure.in patch external/bsd/bind/dist/isc-config.sh.1 patch external/bsd/bind/dist/isc-config.sh.docbook patch external/bsd/bind/dist/isc-config.sh.html patch external/bsd/bind/dist/isc-config.sh.in patch external/bsd/bind/dist/ltmain.sh patch external/bsd/bind/dist/srcid patch external/bsd/bind/dist/version patch external/bsd/bind/dist/bin/Makefile.in patch external/bsd/bind/dist/bin/check/Makefile.in patch external/bsd/bind/dist/bin/check/check-tool.c patch external/bsd/bind/dist/bin/check/named-checkconf.8 patch external/bsd/bind/dist/bin/check/named-checkconf.c patch external/bsd/bind/dist/bin/check/named-checkconf.docbook patch external/bsd/bind/dist/bin/check/named-checkconf.html patch external/bsd/bind/dist/bin/check/named-checkzone.8 patch external/bsd/bind/dist/bin/check/named-checkzone.c patch external/bsd/bind/dist/bin/check/named-checkzone.docbook patch external/bsd/bind/dist/bin/check/named-checkzone.html patch external/bsd/bind/dist/bin/check/win32/checktool.dsp delete external/bsd/bind/dist/bin/check/win32/namedcheckconf.dsp delete external/bsd/bind/dist/bin/check/win32/namedcheckconf.dsw delete external/bsd/bind/dist/bin/check/win32/namedcheckconf.mak delete external/bsd/bind/dist/bin/check/win32/namedcheckzone.dsp delete external/bsd/bind/dist/bin/check/win32/namedcheckzone.dsw delete external/bsd/bind/dist/bin/check/win32/namedcheckzone.mak delete external/bsd/bind/dist/bin/confgen/ddns-confgen.8 patch external/bsd/bind/dist/bin/confgen/ddns-confgen.c patch external/bsd/bind/dist/bin/confgen/ddns-confgen.docbook patch external/bsd/bind/dist/bin/confgen/ddns-confgen.html patch external/bsd/bind/dist/bin/confgen/keygen.c patch external/bsd/bind/dist/bin/confgen/rndc-confgen.8 patch external/bsd/bind/dist/bin/confgen/rndc-confgen.c patch external/bsd/bind/dist/bin/confgen/rndc-confgen.docbook patch external/bsd/bind/dist/bin/confgen/rndc-confgen.html patch external/bsd/bind/dist/bin/confgen/win32/confgentool.dsp delete external/bsd/bind/dist/bin/confgen/win32/ddnsconfgen.dsp delete external/bsd/bind/dist/bin/confgen/win32/ddnsconfgen.mak delete external/bsd/bind/dist/bin/confgen/win32/rndcconfgen.dsp delete external/bsd/bind/dist/bin/confgen/win32/rndcconfgen.mak delete external/bsd/bind/dist/bin/dig/Makefile.in patch external/bsd/bind/dist/bin/dig/dig.1 patch external/bsd/bind/dist/bin/dig/dig.c patch external/bsd/bind/dist/bin/dig/dig.docbook patch external/bsd/bind/dist/bin/dig/dig.html patch external/bsd/bind/dist/bin/dig/dighost.c patch external/bsd/bind/dist/bin/dig/host.1 patch external/bsd/bind/dist/bin/dig/host.c patch external/bsd/bind/dist/bin/dig/host.docbook patch external/bsd/bind/dist/bin/dig/host.html patch external/bsd/bind/dist/bin/dig/nslookup.1 patch external/bsd/bind/dist/bin/dig/nslookup.c patch external/bsd/bind/dist/bin/dig/nslookup.docbook patch external/bsd/bind/dist/bin/dig/nslookup.html patch external/bsd/bind/dist/bin/dig/include/dig/dig.h patch external/bsd/bind/dist/bin/dig/win32/dig.dsp delete external/bsd/bind/dist/bin/dig/win32/dig.mak delete external/bsd/bind/dist/bin/dig/win32/dighost.dsp delete external/bsd/bind/dist/bin/dig/win32/host.dsp delete external/bsd/bind/dist/bin/dig/win32/host.mak delete external/bsd/bind/dist/bin/dig/win32/nslookup.dsp delete external/bsd/bind/dist/bin/dig/win32/nslookup.mak delete external/bsd/bind/dist/bin/dnssec/Makefile.in patch external/bsd/bind/dist/bin/dnssec/dnssec-dsfromkey.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-dsfromkey.c patch external/bsd/bind/dist/bin/dnssec/dnssec-dsfromkey.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-dsfromkey.html patch external/bsd/bind/dist/bin/dnssec/dnssec-importkey.8 new external/bsd/bind/dist/bin/dnssec/dnssec-importkey.c new external/bsd/bind/dist/bin/dnssec/dnssec-importkey.docbook new external/bsd/bind/dist/bin/dnssec/dnssec-importkey.html new external/bsd/bind/dist/bin/dnssec/dnssec-keyfromlabel.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-keyfromlabel.c patch external/bsd/bind/dist/bin/dnssec/dnssec-keyfromlabel.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-keyfromlabel.html patch external/bsd/bind/dist/bin/dnssec/dnssec-keygen.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-keygen.c patch external/bsd/bind/dist/bin/dnssec/dnssec-keygen.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-keygen.html patch external/bsd/bind/dist/bin/dnssec/dnssec-revoke.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-revoke.c patch external/bsd/bind/dist/bin/dnssec/dnssec-revoke.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-revoke.html patch external/bsd/bind/dist/bin/dnssec/dnssec-settime.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-settime.c patch external/bsd/bind/dist/bin/dnssec/dnssec-settime.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-settime.html patch external/bsd/bind/dist/bin/dnssec/dnssec-signzone.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-signzone.c patch external/bsd/bind/dist/bin/dnssec/dnssec-signzone.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-signzone.html patch external/bsd/bind/dist/bin/dnssec/dnssec-verify.8 patch external/bsd/bind/dist/bin/dnssec/dnssec-verify.c patch external/bsd/bind/dist/bin/dnssec/dnssec-verify.docbook patch external/bsd/bind/dist/bin/dnssec/dnssec-verify.html patch external/bsd/bind/dist/bin/dnssec/dnssectool.c patch external/bsd/bind/dist/bin/dnssec/dnssectool.h patch external/bsd/bind/dist/bin/dnssec/win32/dnssectool.dsp delete external/bsd/bind/dist/bin/dnssec/win32/dsfromkey.dsp delete external/bsd/bind/dist/bin/dnssec/win32/dsfromkey.mak delete external/bsd/bind/dist/bin/dnssec/win32/keyfromlabel.dsp delete external/bsd/bind/dist/bin/dnssec/win32/keyfromlabel.mak delete external/bsd/bind/dist/bin/dnssec/win32/keygen.dsp delete external/bsd/bind/dist/bin/dnssec/win32/keygen.mak delete external/bsd/bind/dist/bin/dnssec/win32/nsupdate.dsp delete external/bsd/bind/dist/bin/dnssec/win32/nsupdate.dsw delete external/bsd/bind/dist/bin/dnssec/win32/revoke.dsp delete external/bsd/bind/dist/bin/dnssec/win32/revoke.mak delete external/bsd/bind/dist/bin/dnssec/win32/settime.dsp delete external/bsd/bind/dist/bin/dnssec/win32/settime.mak delete external/bsd/bind/dist/bin/dnssec/win32/signzone.dsp delete external/bsd/bind/dist/bin/dnssec/win32/signzone.mak delete external/bsd/bind/dist/bin/named/Makefile.in patch external/bsd/bind/dist/bin/named/bind.keys.h patch external/bsd/bind/dist/bin/named/bind9.ver3.xsl new external/bsd/bind/dist/bin/named/bind9.ver3.xsl.h new external/bsd/bind/dist/bin/named/bind9.xsl.h patch external/bsd/bind/dist/bin/named/builtin.c patch external/bsd/bind/dist/bin/named/client.c patch external/bsd/bind/dist/bin/named/config.c patch external/bsd/bind/dist/bin/named/control.c patch external/bsd/bind/dist/bin/named/controlconf.c patch external/bsd/bind/dist/bin/named/interfacemgr.c patch external/bsd/bind/dist/bin/named/log.c patch external/bsd/bind/dist/bin/named/logconf.c patch external/bsd/bind/dist/bin/named/lwaddr.c patch external/bsd/bind/dist/bin/named/lwdgnba.c patch external/bsd/bind/dist/bin/named/lwdgrbn.c patch external/bsd/bind/dist/bin/named/lwresd.8 patch external/bsd/bind/dist/bin/named/lwresd.c patch external/bsd/bind/dist/bin/named/lwresd.docbook patch external/bsd/bind/dist/bin/named/lwresd.html patch external/bsd/bind/dist/bin/named/main.c patch external/bsd/bind/dist/bin/named/named.8 patch external/bsd/bind/dist/bin/named/named.conf.5 patch external/bsd/bind/dist/bin/named/named.conf.docbook patch external/bsd/bind/dist/bin/named/named.conf.html patch external/bsd/bind/dist/bin/named/named.docbook patch external/bsd/bind/dist/bin/named/named.html patch external/bsd/bind/dist/bin/named/query.c patch external/bsd/bind/dist/bin/named/server.c patch external/bsd/bind/dist/bin/named/statschannel.c patch external/bsd/bind/dist/bin/named/tkeyconf.c patch external/bsd/bind/dist/bin/named/tsigconf.c patch external/bsd/bind/dist/bin/named/update.c patch external/bsd/bind/dist/bin/named/xfrout.c patch external/bsd/bind/dist/bin/named/zoneconf.c patch external/bsd/bind/dist/bin/named/include/named/client.h patch external/bsd/bind/dist/bin/named/include/named/globals.h patch external/bsd/bind/dist/bin/named/include/named/main.h patch external/bsd/bind/dist/bin/named/include/named/query.h patch external/bsd/bind/dist/bin/named/include/named/server.h patch external/bsd/bind/dist/bin/named/unix/dlz_dlopen_driver.c patch external/bsd/bind/dist/bin/named/unix/os.c patch external/bsd/bind/dist/bin/named/win32/named.dsp delete external/bsd/bind/dist/bin/named/win32/named.mak delete external/bsd/bind/dist/bin/nsupdate/Makefile.in patch external/bsd/bind/dist/bin/nsupdate/nsupdate.1 patch external/bsd/bind/dist/bin/nsupdate/nsupdate.c patch external/bsd/bind/dist/bin/nsupdate/nsupdate.docbook patch external/bsd/bind/dist/bin/nsupdate/nsupdate.html patch external/bsd/bind/dist/bin/nsupdate/win32/nsupdate.dsp delete external/bsd/bind/dist/bin/nsupdate/win32/nsupdate.mak delete external/bsd/bind/dist/bin/pkcs11/openssl-0.9.8s-patch delete external/bsd/bind/dist/bin/pkcs11/openssl-0.9.8za-patch new external/bsd/bind/dist/bin/pkcs11/openssl-1.0.0f-patch delete external/bsd/bind/dist/bin/pkcs11/openssl-1.0.0m-patch new external/bsd/bind/dist/bin/pkcs11/openssl-1.0.1h-patch new external/bsd/bind/dist/bin/pkcs11/pkcs11-destroy.docbook patch external/bsd/bind/dist/bin/pkcs11/pkcs11-keygen.docbook patch external/bsd/bind/dist/bin/pkcs11/pkcs11-list.docbook patch external/bsd/bind/dist/bin/pkcs11/win32/pk11destroy.dsp delete external/bsd/bind/dist/bin/pkcs11/win32/pk11destroy.mak delete external/bsd/bind/dist/bin/pkcs11/win32/pk11keygen.dsp delete external/bsd/bind/dist/bin/pkcs11/win32/pk11keygen.mak delete external/bsd/bind/dist/bin/pkcs11/win32/pk11list.dsp delete external/bsd/bind/dist/bin/pkcs11/win32/pk11list.mak delete external/bsd/bind/dist/bin/python/Makefile.in patch external/bsd/bind/dist/bin/python/dnssec-checkds.8 patch external/bsd/bind/dist/bin/python/dnssec-checkds.docbook patch external/bsd/bind/dist/bin/python/dnssec-checkds.html patch external/bsd/bind/dist/bin/python/dnssec-checkds.py.in patch external/bsd/bind/dist/bin/python/dnssec-coverage.8 new external/bsd/bind/dist/bin/python/dnssec-coverage.docbook new external/bsd/bind/dist/bin/python/dnssec-coverage.html new external/bsd/bind/dist/bin/python/dnssec-coverage.py.in new external/bsd/bind/dist/bin/rndc/rndc.8 patch external/bsd/bind/dist/bin/rndc/rndc.c patch external/bsd/bind/dist/bin/rndc/rndc.conf.5 patch external/bsd/bind/dist/bin/rndc/rndc.conf.docbook patch external/bsd/bind/dist/bin/rndc/rndc.conf.html patch external/bsd/bind/dist/bin/rndc/rndc.docbook patch external/bsd/bind/dist/bin/rndc/rndc.html patch external/bsd/bind/dist/bin/rndc/win32/rndc.dsp delete external/bsd/bind/dist/bin/rndc/win32/rndc.mak delete external/bsd/bind/dist/bin/rndc/win32/rndcutil.dsp delete external/bsd/bind/dist/bin/tests/Makefile.in patch external/bsd/bind/dist/bin/tests/adb_test.c patch external/bsd/bind/dist/bin/tests/backtrace_test.c patch external/bsd/bind/dist/bin/tests/byaddr_test.c patch external/bsd/bind/dist/bin/tests/byname_test.c patch external/bsd/bind/dist/bin/tests/db_test.c patch external/bsd/bind/dist/bin/tests/fsaccess_test.c patch external/bsd/bind/dist/bin/tests/hash_test.c patch external/bsd/bind/dist/bin/tests/log_test.c patch external/bsd/bind/dist/bin/tests/rdata_test.c patch external/bsd/bind/dist/bin/tests/rwlock_test.c patch external/bsd/bind/dist/bin/tests/shutdown_test.c patch external/bsd/bind/dist/bin/tests/sig0_test.c patch external/bsd/bind/dist/bin/tests/sock_test.c patch external/bsd/bind/dist/bin/tests/task_test.c patch external/bsd/bind/dist/bin/tests/timer_test.c patch external/bsd/bind/dist/bin/tests/zone_test.c patch external/bsd/bind/dist/bin/tests/atomic/t_atomic.c patch external/bsd/bind/dist/bin/tests/db/t_db.c patch external/bsd/bind/dist/bin/tests/dst/Kdh.+002+18602.key delete external/bsd/bind/dist/bin/tests/dst/Kdh.+002+18602.key.in new external/bsd/bind/dist/bin/tests/dst/Kdh.+002+18602.private delete external/bsd/bind/dist/bin/tests/dst/Kdh.+002+18602.private.in new external/bsd/bind/dist/bin/tests/dst/Kdh.+002+48957.key delete external/bsd/bind/dist/bin/tests/dst/Kdh.+002+48957.key.in new external/bsd/bind/dist/bin/tests/dst/Kdh.+002+48957.private delete external/bsd/bind/dist/bin/tests/dst/Kdh.+002+48957.private.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+001+00002.key delete external/bsd/bind/dist/bin/tests/dst/Ktest.+001+00002.key.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+001+54622.key delete external/bsd/bind/dist/bin/tests/dst/Ktest.+001+54622.key.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+001+54622.private delete external/bsd/bind/dist/bin/tests/dst/Ktest.+001+54622.private.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+003+23616.key delete external/bsd/bind/dist/bin/tests/dst/Ktest.+003+23616.key.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+003+23616.private delete external/bsd/bind/dist/bin/tests/dst/Ktest.+003+23616.private.in new external/bsd/bind/dist/bin/tests/dst/Ktest.+003+49667.key delete external/bsd/bind/dist/bin/tests/dst/Ktest.+003+49667.key.in new external/bsd/bind/dist/bin/tests/dst/Makefile.in patch external/bsd/bind/dist/bin/tests/dst/dst_2_data delete external/bsd/bind/dist/bin/tests/dst/dst_2_data.in new external/bsd/bind/dist/bin/tests/dst/dst_test.c patch external/bsd/bind/dist/bin/tests/dst/gsstest.c patch external/bsd/bind/dist/bin/tests/dst/t2_data_1 delete external/bsd/bind/dist/bin/tests/dst/t2_data_1.in new external/bsd/bind/dist/bin/tests/dst/t2_data_2 delete external/bsd/bind/dist/bin/tests/dst/t2_data_2.in new external/bsd/bind/dist/bin/tests/dst/t2_dsasig delete external/bsd/bind/dist/bin/tests/dst/t2_dsasig.in new external/bsd/bind/dist/bin/tests/dst/t2_rsasig delete external/bsd/bind/dist/bin/tests/dst/t2_rsasig.in new external/bsd/bind/dist/bin/tests/dst/t_dst.c patch external/bsd/bind/dist/bin/tests/hashes/t_hashes.c patch external/bsd/bind/dist/bin/tests/master/t_master.c patch external/bsd/bind/dist/bin/tests/mem/t_mem.c patch external/bsd/bind/dist/bin/tests/names/dns_name_hash_data patch external/bsd/bind/dist/bin/tests/names/t_names.c patch external/bsd/bind/dist/bin/tests/rbt/t_rbt.c patch external/bsd/bind/dist/bin/tests/resolver/t_resolver.c patch external/bsd/bind/dist/bin/tests/sockaddr/t_sockaddr.c patch external/bsd/bind/dist/bin/tests/system/Makefile.in patch external/bsd/bind/dist/bin/tests/system/README patch external/bsd/bind/dist/bin/tests/system/ans.pl patch external/bsd/bind/dist/bin/tests/system/cleanall.sh patch external/bsd/bind/dist/bin/tests/system/conf.sh.in patch external/bsd/bind/dist/bin/tests/system/digcomp.pl patch external/bsd/bind/dist/bin/tests/system/genzone.sh patch external/bsd/bind/dist/bin/tests/system/ifconfig.sh patch external/bsd/bind/dist/bin/tests/system/run.sh patch external/bsd/bind/dist/bin/tests/system/runall.sh patch external/bsd/bind/dist/bin/tests/system/setup.sh patch external/bsd/bind/dist/bin/tests/system/start.pl patch external/bsd/bind/dist/bin/tests/system/testcrypto.sh new external/bsd/bind/dist/bin/tests/system/testsock.pl patch external/bsd/bind/dist/bin/tests/system/testsock6.pl patch external/bsd/bind/dist/bin/tests/system/acl/clean.sh patch external/bsd/bind/dist/bin/tests/system/acl/setup.sh patch external/bsd/bind/dist/bin/tests/system/acl/tests.sh patch external/bsd/bind/dist/bin/tests/system/acl/ns2/named5.conf new external/bsd/bind/dist/bin/tests/system/additional/clean.sh new external/bsd/bind/dist/bin/tests/system/additional/setup.sh new external/bsd/bind/dist/bin/tests/system/additional/tests.sh new external/bsd/bind/dist/bin/tests/system/addzone/clean.sh patch external/bsd/bind/dist/bin/tests/system/addzone/setup.sh patch external/bsd/bind/dist/bin/tests/system/addzone/tests.sh patch external/bsd/bind/dist/bin/tests/system/addzone/ns1/inlineslave.db new external/bsd/bind/dist/bin/tests/system/addzone/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/addzone/ns2/added.db patch external/bsd/bind/dist/bin/tests/system/addzone/ns2/inline.db new external/bsd/bind/dist/bin/tests/system/allow_query/tests.sh patch external/bsd/bind/dist/bin/tests/system/allow_query/ns2/named57.conf new external/bsd/bind/dist/bin/tests/system/autosign/clean.sh patch external/bsd/bind/dist/bin/tests/system/autosign/prereq.sh patch external/bsd/bind/dist/bin/tests/system/autosign/setup.sh patch external/bsd/bind/dist/bin/tests/system/autosign/tests.sh patch external/bsd/bind/dist/bin/tests/system/autosign/ns1/keygen.sh patch external/bsd/bind/dist/bin/tests/system/autosign/ns2/keygen.sh patch external/bsd/bind/dist/bin/tests/system/autosign/ns3/keygen.sh patch external/bsd/bind/dist/bin/tests/system/builtin/Makefile.in new external/bsd/bind/dist/bin/tests/system/builtin/clean.sh new external/bsd/bind/dist/bin/tests/system/builtin/gethostname.c new external/bsd/bind/dist/bin/tests/system/builtin/tests.sh patch external/bsd/bind/dist/bin/tests/system/builtin/ns2/named.conf new external/bsd/bind/dist/bin/tests/system/builtin/ns3/named.conf new external/bsd/bind/dist/bin/tests/system/cacheclean/tests.sh patch external/bsd/bind/dist/bin/tests/system/cacheclean/ns1/example.db patch external/bsd/bind/dist/bin/tests/system/case/clean.sh new external/bsd/bind/dist/bin/tests/system/case/tests.sh new external/bsd/bind/dist/bin/tests/system/case/ns1/example.db new external/bsd/bind/dist/bin/tests/system/case/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/case/ns2/named.conf new external/bsd/bind/dist/bin/tests/system/checkconf/altdb.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-also-notify.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-dnssec.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-hint.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-inline-slave.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-many.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-master-request-ixfr.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-noddns.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad-tsig.conf new external/bsd/bind/dist/bin/tests/system/checkconf/bad.conf delete external/bsd/bind/dist/bin/tests/system/checkconf/badtsig.conf delete external/bsd/bind/dist/bin/tests/system/checkconf/check-dup-records-fail.conf new external/bsd/bind/dist/bin/tests/system/checkconf/check-dup-records.db new external/bsd/bind/dist/bin/tests/system/checkconf/check-mx-cname-fail.conf new external/bsd/bind/dist/bin/tests/system/checkconf/check-mx-cname.db new external/bsd/bind/dist/bin/tests/system/checkconf/check-mx-fail.conf new external/bsd/bind/dist/bin/tests/system/checkconf/check-mx.db new external/bsd/bind/dist/bin/tests/system/checkconf/check-names-fail.conf new external/bsd/bind/dist/bin/tests/system/checkconf/check-names.db new external/bsd/bind/dist/bin/tests/system/checkconf/check-srv-cname-fail.conf new external/bsd/bind/dist/bin/tests/system/checkconf/check-srv-cname.db new external/bsd/bind/dist/bin/tests/system/checkconf/clean.sh patch external/bsd/bind/dist/bin/tests/system/checkconf/good.conf patch external/bsd/bind/dist/bin/tests/system/checkconf/hint-nofile.conf new external/bsd/bind/dist/bin/tests/system/checkconf/inline-bad.conf new external/bsd/bind/dist/bin/tests/system/checkconf/inline-good.conf new external/bsd/bind/dist/bin/tests/system/checkconf/inline-no.conf new external/bsd/bind/dist/bin/tests/system/checkconf/notify.conf new external/bsd/bind/dist/bin/tests/system/checkconf/tests.sh patch external/bsd/bind/dist/bin/tests/system/checkconf/warn-keydir.conf new external/bsd/bind/dist/bin/tests/system/checkds/clean.sh patch external/bsd/bind/dist/bin/tests/system/checkds/dig.pl new external/bsd/bind/dist/bin/tests/system/checkds/dig.sh patch external/bsd/bind/dist/bin/tests/system/checkds/missing.example.dlv.example.dlv.db patch external/bsd/bind/dist/bin/tests/system/checkds/setup.sh patch external/bsd/bind/dist/bin/tests/system/checkds/tests.sh patch external/bsd/bind/dist/bin/tests/system/checknames/clean.sh patch external/bsd/bind/dist/bin/tests/system/checknames/setup.sh patch external/bsd/bind/dist/bin/tests/system/checknames/tests.sh patch external/bsd/bind/dist/bin/tests/system/checknames/ns4/master-ignore.update.db.in new external/bsd/bind/dist/bin/tests/system/checknames/ns4/named.conf new external/bsd/bind/dist/bin/tests/system/checknames/ns4/root.hints new external/bsd/bind/dist/bin/tests/system/checkzone/tests.sh patch external/bsd/bind/dist/bin/tests/system/checkzone/zones/bad-nsec3-padded.db new external/bsd/bind/dist/bin/tests/system/checkzone/zones/bad-nsec3owner-padded.dbnew external/bsd/bind/dist/bin/tests/system/checkzone/zones/bad2.db new external/bsd/bind/dist/bin/tests/system/checkzone/zones/good-nsec3-nopadhash.db new external/bsd/bind/dist/bin/tests/system/checkzone/zones/spf.db new external/bsd/bind/dist/bin/tests/system/coverage/clean.sh new external/bsd/bind/dist/bin/tests/system/coverage/prereq.sh new external/bsd/bind/dist/bin/tests/system/coverage/setup.sh new external/bsd/bind/dist/bin/tests/system/coverage/tests.sh new external/bsd/bind/dist/bin/tests/system/coverage/01-ksk-inactive/README new external/bsd/bind/dist/bin/tests/system/coverage/01-ksk-inactive/expect new external/bsd/bind/dist/bin/tests/system/coverage/02-zsk-inactive/README new external/bsd/bind/dist/bin/tests/system/coverage/02-zsk-inactive/expect new external/bsd/bind/dist/bin/tests/system/coverage/03-ksk-unpublished/README new external/bsd/bind/dist/bin/tests/system/coverage/03-ksk-unpublished/expect new external/bsd/bind/dist/bin/tests/system/coverage/04-zsk-unpublished/README new external/bsd/bind/dist/bin/tests/system/coverage/04-zsk-unpublished/expect new external/bsd/bind/dist/bin/tests/system/coverage/05-ksk-unpub-active/README new external/bsd/bind/dist/bin/tests/system/coverage/05-ksk-unpub-active/expect new external/bsd/bind/dist/bin/tests/system/coverage/06-zsk-unpub-active/README new external/bsd/bind/dist/bin/tests/system/coverage/06-zsk-unpub-active/expect new external/bsd/bind/dist/bin/tests/system/coverage/07-ksk-ttl/README new external/bsd/bind/dist/bin/tests/system/coverage/07-ksk-ttl/expect new external/bsd/bind/dist/bin/tests/system/coverage/08-zsk-ttl/README new external/bsd/bind/dist/bin/tests/system/coverage/08-zsk-ttl/expect new external/bsd/bind/dist/bin/tests/system/dlv/clean.sh patch external/bsd/bind/dist/bin/tests/system/dlv/prereq.sh new external/bsd/bind/dist/bin/tests/system/dlv/setup.sh patch external/bsd/bind/dist/bin/tests/system/dlv/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/dlv/ns2/sign.sh patch external/bsd/bind/dist/bin/tests/system/dlv/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/dlv/ns6/sign.sh patch external/bsd/bind/dist/bin/tests/system/dlvauto/clean.sh patch external/bsd/bind/dist/bin/tests/system/dlvauto/prereq.sh new external/bsd/bind/dist/bin/tests/system/dlvauto/setup.sh patch external/bsd/bind/dist/bin/tests/system/dlvauto/tests.sh patch external/bsd/bind/dist/bin/tests/system/dlvauto/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/dlz/tests.sh patch external/bsd/bind/dist/bin/tests/system/dlzexternal/Makefile.in patch external/bsd/bind/dist/bin/tests/system/dlzexternal/clean.sh patch external/bsd/bind/dist/bin/tests/system/dlzexternal/driver.c patch external/bsd/bind/dist/bin/tests/system/dlzexternal/prereq.sh patch external/bsd/bind/dist/bin/tests/system/dlzexternal/setup.sh patch external/bsd/bind/dist/bin/tests/system/dlzexternal/tests.sh patch external/bsd/bind/dist/bin/tests/system/dns64/clean.sh patch external/bsd/bind/dist/bin/tests/system/dns64/prereq.sh new external/bsd/bind/dist/bin/tests/system/dns64/setup.sh patch external/bsd/bind/dist/bin/tests/system/dns64/tests.sh patch external/bsd/bind/dist/bin/tests/system/dns64/ns1/example.db patch external/bsd/bind/dist/bin/tests/system/dns64/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/dns64/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/dns64/ns2/rpz.db new external/bsd/bind/dist/bin/tests/system/dnssec/clean.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/prereq.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/setup.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/tests.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/ns1/root.db.in patch external/bsd/bind/dist/bin/tests/system/dnssec/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/ns2/example.db.in patch external/bsd/bind/dist/bin/tests/system/dnssec/ns2/in-addr.arpa.db.in new external/bsd/bind/dist/bin/tests/system/dnssec/ns2/insecure.secure.example.db patch external/bsd/bind/dist/bin/tests/system/dnssec/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/dnssec/ns2/sign.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/ns3/named.conf patch external/bsd/bind/dist/bin/tests/system/dnssec/ns3/publish-inactive.example.db.in new external/bsd/bind/dist/bin/tests/system/dnssec/ns3/secure.example.db.in patch external/bsd/bind/dist/bin/tests/system/dnssec/ns3/siginterval.example.db.in new external/bsd/bind/dist/bin/tests/system/dnssec/ns3/siginterval1.conf new external/bsd/bind/dist/bin/tests/system/dnssec/ns3/siginterval2.conf new external/bsd/bind/dist/bin/tests/system/dnssec/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/dnssec/ns4/named4.conf new external/bsd/bind/dist/bin/tests/system/dnssec/ns6/named.args new external/bsd/bind/dist/bin/tests/system/dnssec/ns6/named.conf patch external/bsd/bind/dist/bin/tests/system/dnssec/ns6/optout-tld.db.in new external/bsd/bind/dist/bin/tests/system/dnssec/ns6/sign.sh new external/bsd/bind/dist/bin/tests/system/dnssec/ns7/named.conf patch external/bsd/bind/dist/bin/tests/system/dnssec/ns7/sign.sh new external/bsd/bind/dist/bin/tests/system/dnssec/ns7/split-rrsig.db.in new external/bsd/bind/dist/bin/tests/system/dsdigest/prereq.sh new external/bsd/bind/dist/bin/tests/system/ecdsa/clean.sh patch external/bsd/bind/dist/bin/tests/system/ecdsa/prereq.sh new external/bsd/bind/dist/bin/tests/system/ecdsa/prereq.sh.in delete external/bsd/bind/dist/bin/tests/system/ecdsa/setup.sh patch external/bsd/bind/dist/bin/tests/system/ecdsa/tests.sh patch external/bsd/bind/dist/bin/tests/system/ecdsa/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/emptyzones/clean.sh new external/bsd/bind/dist/bin/tests/system/emptyzones/setup.sh new external/bsd/bind/dist/bin/tests/system/emptyzones/tests.sh new external/bsd/bind/dist/bin/tests/system/emptyzones/ns1/empty.db new external/bsd/bind/dist/bin/tests/system/emptyzones/ns1/named1.conf new external/bsd/bind/dist/bin/tests/system/emptyzones/ns1/named2.conf new external/bsd/bind/dist/bin/tests/system/emptyzones/ns1/rfc1918.zones new external/bsd/bind/dist/bin/tests/system/emptyzones/ns1/root.hint new external/bsd/bind/dist/bin/tests/system/filter-aaaa/clean.sh patch external/bsd/bind/dist/bin/tests/system/filter-aaaa/prereq.sh patch external/bsd/bind/dist/bin/tests/system/filter-aaaa/setup.sh patch external/bsd/bind/dist/bin/tests/system/filter-aaaa/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/filter-aaaa/ns1/signed.db.presigned new external/bsd/bind/dist/bin/tests/system/filter-aaaa/ns4/sign.sh patch external/bsd/bind/dist/bin/tests/system/filter-aaaa/ns4/signed.db.presigned new external/bsd/bind/dist/bin/tests/system/filter-aaaa/ns4/unsigned.db patch external/bsd/bind/dist/bin/tests/system/formerr/clean.sh new external/bsd/bind/dist/bin/tests/system/formerr/formerr.pl new external/bsd/bind/dist/bin/tests/system/formerr/nametoolong new external/bsd/bind/dist/bin/tests/system/formerr/noquestions new external/bsd/bind/dist/bin/tests/system/formerr/tests.sh new external/bsd/bind/dist/bin/tests/system/formerr/twoquestions new external/bsd/bind/dist/bin/tests/system/formerr/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/formerr/ns1/root.db new external/bsd/bind/dist/bin/tests/system/forward/tests.sh patch external/bsd/bind/dist/bin/tests/system/forward/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/forward/ns4/named.conf patch external/bsd/bind/dist/bin/tests/system/glue/tests.sh patch external/bsd/bind/dist/bin/tests/system/gost/clean.sh patch external/bsd/bind/dist/bin/tests/system/gost/prereq.sh new external/bsd/bind/dist/bin/tests/system/gost/prereq.sh.in delete external/bsd/bind/dist/bin/tests/system/gost/setup.sh patch external/bsd/bind/dist/bin/tests/system/gost/tests.sh patch external/bsd/bind/dist/bin/tests/system/gost/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/inline/checkdsa.sh.in new external/bsd/bind/dist/bin/tests/system/inline/clean.sh patch external/bsd/bind/dist/bin/tests/system/inline/prereq.sh new external/bsd/bind/dist/bin/tests/system/inline/setup.sh patch external/bsd/bind/dist/bin/tests/system/inline/tests.sh patch external/bsd/bind/dist/bin/tests/system/inline/ns1/root.db.in patch external/bsd/bind/dist/bin/tests/system/inline/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/inline/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/inline/ns3/master3.db.in patch external/bsd/bind/dist/bin/tests/system/inline/ns3/master4.db.in new external/bsd/bind/dist/bin/tests/system/inline/ns3/named.conf patch external/bsd/bind/dist/bin/tests/system/inline/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/ixfr/clean.sh patch external/bsd/bind/dist/bin/tests/system/ixfr/prereq.sh patch external/bsd/bind/dist/bin/tests/system/ixfr/setup.sh patch external/bsd/bind/dist/bin/tests/system/ixfr/tests.sh patch external/bsd/bind/dist/bin/tests/system/ixfr/ns3/named.conf patch external/bsd/bind/dist/bin/tests/system/logfileconfig/setup.sh patch external/bsd/bind/dist/bin/tests/system/logfileconfig/tests.sh patch external/bsd/bind/dist/bin/tests/system/lwresd/clean.sh patch external/bsd/bind/dist/bin/tests/system/lwresd/lwtest.c patch external/bsd/bind/dist/bin/tests/system/lwresd/tests.sh patch external/bsd/bind/dist/bin/tests/system/masterfile/knowngood.dig.out patch external/bsd/bind/dist/bin/tests/system/masterfile/ns1/include.db patch external/bsd/bind/dist/bin/tests/system/masterformat/clean.sh patch external/bsd/bind/dist/bin/tests/system/masterformat/prereq.sh new external/bsd/bind/dist/bin/tests/system/masterformat/setup.sh patch external/bsd/bind/dist/bin/tests/system/masterformat/tests.sh patch external/bsd/bind/dist/bin/tests/system/masterformat/ns1/example.db patch external/bsd/bind/dist/bin/tests/system/metadata/clean.sh patch external/bsd/bind/dist/bin/tests/system/metadata/prereq.sh patch external/bsd/bind/dist/bin/tests/system/metadata/setup.sh patch external/bsd/bind/dist/bin/tests/system/metadata/tests.sh patch external/bsd/bind/dist/bin/tests/system/nslookup/clean.sh new external/bsd/bind/dist/bin/tests/system/nslookup/setup.sh new external/bsd/bind/dist/bin/tests/system/nslookup/tests.sh new external/bsd/bind/dist/bin/tests/system/nslookup/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/nsupdate/clean.sh patch external/bsd/bind/dist/bin/tests/system/nsupdate/prereq.sh new external/bsd/bind/dist/bin/tests/system/nsupdate/setup.sh patch external/bsd/bind/dist/bin/tests/system/nsupdate/tests.sh patch external/bsd/bind/dist/bin/tests/system/nsupdate/update_test.pl patch external/bsd/bind/dist/bin/tests/system/nsupdate/ns1/named.conf patch external/bsd/bind/dist/bin/tests/system/nsupdate/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/pending/clean.sh patch external/bsd/bind/dist/bin/tests/system/pending/prereq.sh patch external/bsd/bind/dist/bin/tests/system/pending/setup.sh patch external/bsd/bind/dist/bin/tests/system/pending/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/pending/ns2/sign.sh patch external/bsd/bind/dist/bin/tests/system/pkcs11/clean.sh patch external/bsd/bind/dist/bin/tests/system/pkcs11/prereq.sh patch external/bsd/bind/dist/bin/tests/system/pkcs11/setup.sh patch external/bsd/bind/dist/bin/tests/system/pkcs11/tests.sh patch external/bsd/bind/dist/bin/tests/system/redirect/clean.sh patch external/bsd/bind/dist/bin/tests/system/redirect/prereq.sh new external/bsd/bind/dist/bin/tests/system/redirect/setup.sh patch external/bsd/bind/dist/bin/tests/system/redirect/tests.sh patch external/bsd/bind/dist/bin/tests/system/redirect/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/redirect/ns2/example.db.in new external/bsd/bind/dist/bin/tests/system/redirect/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/redirect/ns2/redirect.db delete external/bsd/bind/dist/bin/tests/system/redirect/ns2/redirect.db.in new external/bsd/bind/dist/bin/tests/system/resolver/clean.sh patch external/bsd/bind/dist/bin/tests/system/resolver/prereq.sh patch external/bsd/bind/dist/bin/tests/system/resolver/setup.sh patch external/bsd/bind/dist/bin/tests/system/resolver/tests.sh patch external/bsd/bind/dist/bin/tests/system/resolver/ans2/ans.pl patch external/bsd/bind/dist/bin/tests/system/resolver/ans3/ans.pl patch external/bsd/bind/dist/bin/tests/system/resolver/ns1/named.conf patch external/bsd/bind/dist/bin/tests/system/resolver/ns4/broken.db new external/bsd/bind/dist/bin/tests/system/resolver/ns4/named.conf patch external/bsd/bind/dist/bin/tests/system/resolver/ns6/broken.db new external/bsd/bind/dist/bin/tests/system/resolver/ns6/keygen.sh patch external/bsd/bind/dist/bin/tests/system/resolver/ns6/named.conf patch external/bsd/bind/dist/bin/tests/system/resolver/ns7/named.conf delete external/bsd/bind/dist/bin/tests/system/resolver/ns7/named1.conf new external/bsd/bind/dist/bin/tests/system/resolver/ns7/named2.conf new external/bsd/bind/dist/bin/tests/system/rndc/clean.sh patch external/bsd/bind/dist/bin/tests/system/rndc/setup.sh patch external/bsd/bind/dist/bin/tests/system/rndc/tests.sh patch external/bsd/bind/dist/bin/tests/system/rndc/ns3/named.conf new external/bsd/bind/dist/bin/tests/system/rpz/Makefile.in patch external/bsd/bind/dist/bin/tests/system/rpz/clean.sh patch external/bsd/bind/dist/bin/tests/system/rpz/prereq.sh new external/bsd/bind/dist/bin/tests/system/rpz/qperf.sh patch external/bsd/bind/dist/bin/tests/system/rpz/rpz.c patch external/bsd/bind/dist/bin/tests/system/rpz/setup.sh patch external/bsd/bind/dist/bin/tests/system/rpz/test1 patch external/bsd/bind/dist/bin/tests/system/rpz/test2 patch external/bsd/bind/dist/bin/tests/system/rpz/test3 patch external/bsd/bind/dist/bin/tests/system/rpz/test4 patch external/bsd/bind/dist/bin/tests/system/rpz/test4a new external/bsd/bind/dist/bin/tests/system/rpz/test5 patch external/bsd/bind/dist/bin/tests/system/rpz/tests.sh patch external/bsd/bind/dist/bin/tests/system/rpz/ns1/named.conf patch external/bsd/bind/dist/bin/tests/system/rpz/ns1/root.db patch external/bsd/bind/dist/bin/tests/system/rpz/ns2/base-tld2s.db patch external/bsd/bind/dist/bin/tests/system/rpz/ns2/bl.tld2.db.in new external/bsd/bind/dist/bin/tests/system/rpz/ns2/blv2.tld2.db.in new external/bsd/bind/dist/bin/tests/system/rpz/ns2/blv3.tld2.db.in new external/bsd/bind/dist/bin/tests/system/rpz/ns2/hints patch external/bsd/bind/dist/bin/tests/system/rpz/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/rpz/ns2/tld2.db patch external/bsd/bind/dist/bin/tests/system/rpz/ns3/base.db patch external/bsd/bind/dist/bin/tests/system/rpz/ns3/crash1 patch external/bsd/bind/dist/bin/tests/system/rpz/ns3/crash2 patch external/bsd/bind/dist/bin/tests/system/rpz/ns3/hints patch external/bsd/bind/dist/bin/tests/system/rpz/ns3/named.conf patch external/bsd/bind/dist/bin/tests/system/rpz/ns4/hints patch external/bsd/bind/dist/bin/tests/system/rpz/ns4/named.conf patch external/bsd/bind/dist/bin/tests/system/rpz/ns4/tld4.db patch external/bsd/bind/dist/bin/tests/system/rpz/ns5/hints patch external/bsd/bind/dist/bin/tests/system/rpz/ns5/named.args new external/bsd/bind/dist/bin/tests/system/rpz/ns5/named.conf patch external/bsd/bind/dist/bin/tests/system/rpz/ns5/tld5.db new external/bsd/bind/dist/bin/tests/system/rpz/ns6/hints new external/bsd/bind/dist/bin/tests/system/rpz/ns6/named.conf new external/bsd/bind/dist/bin/tests/system/rrl/Makefile.in new external/bsd/bind/dist/bin/tests/system/rrl/clean.sh new external/bsd/bind/dist/bin/tests/system/rrl/prereq.sh new external/bsd/bind/dist/bin/tests/system/rrl/rrl.c new external/bsd/bind/dist/bin/tests/system/rrl/setup.sh new external/bsd/bind/dist/bin/tests/system/rrl/tests.sh new external/bsd/bind/dist/bin/tests/system/rrl/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/rrl/ns1/root.db new external/bsd/bind/dist/bin/tests/system/rrl/ns2/hints new external/bsd/bind/dist/bin/tests/system/rrl/ns2/named.conf new external/bsd/bind/dist/bin/tests/system/rrl/ns2/tld2.db new external/bsd/bind/dist/bin/tests/system/rrl/ns3/hints new external/bsd/bind/dist/bin/tests/system/rrl/ns3/named.conf new external/bsd/bind/dist/bin/tests/system/rrl/ns3/tld3.db new external/bsd/bind/dist/bin/tests/system/rrsetorder/tests.sh patch external/bsd/bind/dist/bin/tests/system/rrsetorder/ns1/named.conf patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/bigkey.c patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/clean.sh patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/prereq.sh patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/setup.sh patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/ns1/sign.sh patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/ns2/Xexample.+005+05896.private patch external/bsd/bind/dist/bin/tests/system/rsabigexponent/ns2/sign.sh patch external/bsd/bind/dist/bin/tests/system/smartsign/clean.sh patch external/bsd/bind/dist/bin/tests/system/smartsign/prereq.sh patch external/bsd/bind/dist/bin/tests/system/smartsign/setup.sh patch external/bsd/bind/dist/bin/tests/system/smartsign/tests.sh patch external/bsd/bind/dist/bin/tests/system/spf/clean.sh new external/bsd/bind/dist/bin/tests/system/spf/tests.sh new external/bsd/bind/dist/bin/tests/system/spf/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/spf/ns1/spf.db new external/bsd/bind/dist/bin/tests/system/staticstub/clean.sh patch external/bsd/bind/dist/bin/tests/system/staticstub/prereq.sh new external/bsd/bind/dist/bin/tests/system/staticstub/setup.sh patch external/bsd/bind/dist/bin/tests/system/staticstub/tests.sh patch external/bsd/bind/dist/bin/tests/system/staticstub/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/staticstub/ns4/sign.sh patch external/bsd/bind/dist/bin/tests/system/stress/tests.sh patch external/bsd/bind/dist/bin/tests/system/tkey/clean.sh patch external/bsd/bind/dist/bin/tests/system/tkey/keycreate.c patch external/bsd/bind/dist/bin/tests/system/tkey/keydelete.c patch external/bsd/bind/dist/bin/tests/system/tkey/prereq.sh patch external/bsd/bind/dist/bin/tests/system/tkey/setup.sh patch external/bsd/bind/dist/bin/tests/system/tkey/tests.sh patch external/bsd/bind/dist/bin/tests/system/tkey/ns1/example.db new external/bsd/bind/dist/bin/tests/system/tkey/ns1/named.conf.in patch external/bsd/bind/dist/bin/tests/system/tkey/ns1/setup.sh patch external/bsd/bind/dist/bin/tests/system/tsig/clean.sh patch external/bsd/bind/dist/bin/tests/system/tsig/tests.sh patch external/bsd/bind/dist/bin/tests/system/tsig/ns1/example.db patch external/bsd/bind/dist/bin/tests/system/tsiggss/clean.sh patch external/bsd/bind/dist/bin/tests/system/tsiggss/prereq.sh patch external/bsd/bind/dist/bin/tests/system/tsiggss/setup.sh patch external/bsd/bind/dist/bin/tests/system/tsiggss/tests.sh patch external/bsd/bind/dist/bin/tests/system/unknown/clean.sh patch external/bsd/bind/dist/bin/tests/system/unknown/large.out patch external/bsd/bind/dist/bin/tests/system/unknown/prereq.sh new external/bsd/bind/dist/bin/tests/system/unknown/setup.sh patch external/bsd/bind/dist/bin/tests/system/unknown/tests.sh patch external/bsd/bind/dist/bin/tests/system/unknown/ns1/example-in.db patch external/bsd/bind/dist/bin/tests/system/unknown/ns3/sign.sh patch external/bsd/bind/dist/bin/tests/system/unknown/zones/nan.bad new external/bsd/bind/dist/bin/tests/system/upforwd/prereq.sh patch external/bsd/bind/dist/bin/tests/system/upforwd/tests.sh patch external/bsd/bind/dist/bin/tests/system/upforwd/ans4/ans.pl patch external/bsd/bind/dist/bin/tests/system/verify/clean.sh patch external/bsd/bind/dist/bin/tests/system/verify/prereq.sh new external/bsd/bind/dist/bin/tests/system/verify/setup.sh patch external/bsd/bind/dist/bin/tests/system/verify/tests.sh patch external/bsd/bind/dist/bin/tests/system/verify/zones/genzones.sh patch external/bsd/bind/dist/bin/tests/system/wildcard/clean.sh new external/bsd/bind/dist/bin/tests/system/wildcard/prereq.sh new external/bsd/bind/dist/bin/tests/system/wildcard/setup.sh new external/bsd/bind/dist/bin/tests/system/wildcard/tests.sh new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/dlv.db.in new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/nsec.db.in new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/nsec3.db.in new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/private.nsec.db.in new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/private.nsec3.db.innew external/bsd/bind/dist/bin/tests/system/wildcard/ns1/root.db.in new external/bsd/bind/dist/bin/tests/system/wildcard/ns1/sign.sh new external/bsd/bind/dist/bin/tests/system/wildcard/ns2/hints new external/bsd/bind/dist/bin/tests/system/wildcard/ns2/named.conf new external/bsd/bind/dist/bin/tests/system/wildcard/ns3/hints new external/bsd/bind/dist/bin/tests/system/wildcard/ns3/named.conf new external/bsd/bind/dist/bin/tests/system/wildcard/ns4/named.conf new external/bsd/bind/dist/bin/tests/system/wildcard/ns5/hints new external/bsd/bind/dist/bin/tests/system/wildcard/ns5/named.conf new external/bsd/bind/dist/bin/tests/system/xfer/clean.sh patch external/bsd/bind/dist/bin/tests/system/xfer/dig1.good patch external/bsd/bind/dist/bin/tests/system/xfer/dig2.good patch external/bsd/bind/dist/bin/tests/system/xfer/prereq.sh patch external/bsd/bind/dist/bin/tests/system/xfer/setup.sh patch external/bsd/bind/dist/bin/tests/system/xfer/tests.sh patch external/bsd/bind/dist/bin/tests/system/xfer/ns2/named.conf patch external/bsd/bind/dist/bin/tests/system/xfer/ns2/slave.db.in new external/bsd/bind/dist/bin/tests/system/zero/clean.sh new external/bsd/bind/dist/bin/tests/system/zero/setup.sh new external/bsd/bind/dist/bin/tests/system/zero/tests.sh new external/bsd/bind/dist/bin/tests/system/zero/ns1/named.conf new external/bsd/bind/dist/bin/tests/system/zero/ns1/root.db new external/bsd/bind/dist/bin/tests/system/zero/ns2/named.conf new external/bsd/bind/dist/bin/tests/system/zero/ns3/named.conf new external/bsd/bind/dist/bin/tests/system/zero/ns3/root.hint new external/bsd/bind/dist/bin/tests/system/zero/ns4/named.conf new external/bsd/bind/dist/bin/tests/system/zonechecks/prereq.sh new external/bsd/bind/dist/bin/tests/system/zonechecks/setup.sh new external/bsd/bind/dist/bin/tests/system/zonechecks/tests.sh patch external/bsd/bind/dist/bin/tests/system/zonechecks/ns1/named.conf new external/bsd/bind/dist/bin/tests/tasks/t_tasks.c patch external/bsd/bind/dist/bin/tests/timers/t_timers.c patch external/bsd/bind/dist/bin/tools/arpaname.1 patch external/bsd/bind/dist/bin/tools/arpaname.docbook patch external/bsd/bind/dist/bin/tools/arpaname.html patch external/bsd/bind/dist/bin/tools/genrandom.8 patch external/bsd/bind/dist/bin/tools/genrandom.c patch external/bsd/bind/dist/bin/tools/genrandom.docbook patch external/bsd/bind/dist/bin/tools/genrandom.html patch external/bsd/bind/dist/bin/tools/isc-hmac-fixup.8 patch external/bsd/bind/dist/bin/tools/isc-hmac-fixup.c patch external/bsd/bind/dist/bin/tools/isc-hmac-fixup.docbook patch external/bsd/bind/dist/bin/tools/isc-hmac-fixup.html patch external/bsd/bind/dist/bin/tools/named-journalprint.8 patch external/bsd/bind/dist/bin/tools/named-journalprint.docbook patch external/bsd/bind/dist/bin/tools/named-journalprint.html patch external/bsd/bind/dist/bin/tools/nsec3hash.8 patch external/bsd/bind/dist/bin/tools/nsec3hash.c patch external/bsd/bind/dist/bin/tools/nsec3hash.docbook patch external/bsd/bind/dist/bin/tools/nsec3hash.html patch external/bsd/bind/dist/bin/tools/win32/arpaname.dsp delete external/bsd/bind/dist/bin/tools/win32/arpaname.mak delete external/bsd/bind/dist/bin/tools/win32/genrandom.dsp delete external/bsd/bind/dist/bin/tools/win32/genrandom.mak delete external/bsd/bind/dist/bin/tools/win32/ischmacfixup.dsp delete external/bsd/bind/dist/bin/tools/win32/ischmacfixup.mak delete external/bsd/bind/dist/bin/tools/win32/journalprint.dsp delete external/bsd/bind/dist/bin/tools/win32/journalprint.mak delete external/bsd/bind/dist/bin/tools/win32/nsec3hash.dsp delete external/bsd/bind/dist/bin/tools/win32/nsec3hash.mak delete external/bsd/bind/dist/bin/win32/BINDInstall/BINDInstall.dsp delete external/bsd/bind/dist/bin/win32/BINDInstall/BINDInstall.mak delete external/bsd/bind/dist/contrib/README new external/bsd/bind/dist/contrib/check5011.pl new external/bsd/bind/dist/contrib/dane/mkdane.sh new external/bsd/bind/dist/contrib/dane/tlsa6698.pem new external/bsd/bind/dist/contrib/dbus/GetForwarders delete external/bsd/bind/dist/contrib/dbus/INSTALL delete external/bsd/bind/dist/contrib/dbus/Makefile.9.3.2b1 delete external/bsd/bind/dist/contrib/dbus/Makefile.9.3.3rc2 delete external/bsd/bind/dist/contrib/dbus/README.DBUS delete external/bsd/bind/dist/contrib/dbus/SetForwarders delete external/bsd/bind/dist/contrib/dbus/bind-9.3.2b1-dbus.patch delete external/bsd/bind/dist/contrib/dbus/bind-9.3.3rc2-dbus.patch delete external/bsd/bind/dist/contrib/dbus/dbus_mgr.c delete external/bsd/bind/dist/contrib/dbus/dbus_mgr.h delete external/bsd/bind/dist/contrib/dbus/dbus_service.c delete external/bsd/bind/dist/contrib/dbus/dbus_service.h delete external/bsd/bind/dist/contrib/dbus/named-dbus-system.conf delete external/bsd/bind/dist/contrib/dbus/named-dbus.service delete external/bsd/bind/dist/contrib/dlz/config.dlz.in patch external/bsd/bind/dist/contrib/dlz/drivers/dlz_filesystem_driver.c patch external/bsd/bind/dist/contrib/dlz/drivers/dlz_ldap_driver.c patch external/bsd/bind/dist/contrib/dlz/drivers/dlz_mysql_driver.c patch external/bsd/bind/dist/contrib/dlz/drivers/dlz_odbc_driver.c patch external/bsd/bind/dist/contrib/dlz/drivers/dlz_postgres_driver.c patch external/bsd/bind/dist/contrib/dlz/drivers/sdlz_helper.c patch external/bsd/bind/dist/contrib/dlz/example/Makefile patch external/bsd/bind/dist/contrib/dlz/example/README patch external/bsd/bind/dist/contrib/dlz/example/dlz_example.c patch external/bsd/bind/dist/contrib/dlz/example/dlz_minimal.h delete external/bsd/bind/dist/contrib/dlz/modules/dlz_minimal.h new external/bsd/bind/dist/contrib/dlz/modules/bdbhpt/Makefile new external/bsd/bind/dist/contrib/dlz/modules/bdbhpt/README.md new external/bsd/bind/dist/contrib/dlz/modules/bdbhpt/dlz_bdbhpt_dynamic.c new external/bsd/bind/dist/contrib/dlz/modules/bdbhpt/testing/bdbhpt-populate.pl new external/bsd/bind/dist/contrib/dlz/modules/bdbhpt/testing/dns-data.txt new external/bsd/bind/dist/contrib/named-bootconf/named-bootconf.sh patch external/bsd/bind/dist/contrib/nslint-2.1a3/strerror.c patch external/bsd/bind/dist/contrib/perftcpdns/Makefile.in new external/bsd/bind/dist/contrib/perftcpdns/configure new external/bsd/bind/dist/contrib/perftcpdns/configure.in new external/bsd/bind/dist/contrib/perftcpdns/perftcpdns.c new external/bsd/bind/dist/contrib/query-loc-0.4.0/loc.c patch external/bsd/bind/dist/contrib/query-loc-0.4.0/loc_ntoa.c patch external/bsd/bind/dist/contrib/queryperf/queryperf.c patch external/bsd/bind/dist/contrib/sdb/bdb/bdb.c patch external/bsd/bind/dist/contrib/sdb/dir/dirdb.c patch external/bsd/bind/dist/contrib/sdb/ldap/ldapdb.c patch external/bsd/bind/dist/contrib/sdb/pgsql/pgsqldb.c patch external/bsd/bind/dist/contrib/sdb/pgsql/zonetodb.c patch external/bsd/bind/dist/contrib/sdb/sqlite/sqlitedb.c patch external/bsd/bind/dist/contrib/sdb/sqlite/zone2sqlite.c patch external/bsd/bind/dist/contrib/sdb/tcl/tcldb.c patch external/bsd/bind/dist/contrib/sdb/time/timedb.c patch external/bsd/bind/dist/contrib/zkt/Makefile.in patch external/bsd/bind/dist/contrib/zkt/dki.c patch external/bsd/bind/dist/contrib/zkt/tags new external/bsd/bind/dist/contrib/zkt/zkt-soaserial.c patch external/bsd/bind/dist/doc/arm/Bv9ARM-book.xml patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch01.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch02.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch03.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch04.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch05.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch06.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch07.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch08.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch09.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.ch10.html patch external/bsd/bind/dist/doc/arm/Bv9ARM.html patch external/bsd/bind/dist/doc/arm/Makefile.in patch external/bsd/bind/dist/doc/arm/libdns.xml patch external/bsd/bind/dist/doc/arm/man.arpaname.html patch external/bsd/bind/dist/doc/arm/man.ddns-confgen.html patch external/bsd/bind/dist/doc/arm/man.dig.html patch external/bsd/bind/dist/doc/arm/man.dnssec-checkds.html new external/bsd/bind/dist/doc/arm/man.dnssec-coverage.html new external/bsd/bind/dist/doc/arm/man.dnssec-dsfromkey.html patch external/bsd/bind/dist/doc/arm/man.dnssec-keyfromlabel.html patch external/bsd/bind/dist/doc/arm/man.dnssec-keygen.html patch external/bsd/bind/dist/doc/arm/man.dnssec-revoke.html patch external/bsd/bind/dist/doc/arm/man.dnssec-settime.html patch external/bsd/bind/dist/doc/arm/man.dnssec-signzone.html patch external/bsd/bind/dist/doc/arm/man.dnssec-verify.html patch external/bsd/bind/dist/doc/arm/man.genrandom.html patch external/bsd/bind/dist/doc/arm/man.host.html patch external/bsd/bind/dist/doc/arm/man.isc-hmac-fixup.html patch external/bsd/bind/dist/doc/arm/man.named-checkconf.html patch external/bsd/bind/dist/doc/arm/man.named-checkzone.html patch external/bsd/bind/dist/doc/arm/man.named-journalprint.html patch external/bsd/bind/dist/doc/arm/man.named.html patch external/bsd/bind/dist/doc/arm/man.nsec3hash.html patch external/bsd/bind/dist/doc/arm/man.nsupdate.html patch external/bsd/bind/dist/doc/arm/man.rndc-confgen.html patch external/bsd/bind/dist/doc/arm/man.rndc.conf.html patch external/bsd/bind/dist/doc/arm/man.rndc.html patch external/bsd/bind/dist/doc/arm/pkcs11.xml patch external/bsd/bind/dist/doc/misc/options patch external/bsd/bind/dist/doc/xsl/isc-docbook-chunk.xsl.in patch external/bsd/bind/dist/doc/xsl/isc-docbook-html.xsl.in patch external/bsd/bind/dist/lib/Atffile patch external/bsd/bind/dist/lib/Makefile.in patch external/bsd/bind/dist/lib/bind9/Makefile.in patch external/bsd/bind/dist/lib/bind9/api patch external/bsd/bind/dist/lib/bind9/check.c patch external/bsd/bind/dist/lib/bind9/getaddresses.c patch external/bsd/bind/dist/lib/bind9/win32/libbind9.dsp delete external/bsd/bind/dist/lib/bind9/win32/libbind9.mak delete external/bsd/bind/dist/lib/dns/Makefile.in patch external/bsd/bind/dist/lib/dns/acache.c patch external/bsd/bind/dist/lib/dns/acl.c patch external/bsd/bind/dist/lib/dns/adb.c patch external/bsd/bind/dist/lib/dns/api patch external/bsd/bind/dist/lib/dns/byaddr.c patch external/bsd/bind/dist/lib/dns/cache.c patch external/bsd/bind/dist/lib/dns/client.c patch external/bsd/bind/dist/lib/dns/db.c patch external/bsd/bind/dist/lib/dns/dbtable.c patch external/bsd/bind/dist/lib/dns/diff.c patch external/bsd/bind/dist/lib/dns/dispatch.c patch external/bsd/bind/dist/lib/dns/dlz.c patch external/bsd/bind/dist/lib/dns/dns64.c patch external/bsd/bind/dist/lib/dns/dnssec.c patch external/bsd/bind/dist/lib/dns/dst_api.c patch external/bsd/bind/dist/lib/dns/dst_internal.h patch external/bsd/bind/dist/lib/dns/dst_openssl.h patch external/bsd/bind/dist/lib/dns/dst_parse.c patch external/bsd/bind/dist/lib/dns/dst_result.c patch external/bsd/bind/dist/lib/dns/ecdb.c patch external/bsd/bind/dist/lib/dns/gen-win32.h patch external/bsd/bind/dist/lib/dns/gen.c patch external/bsd/bind/dist/lib/dns/gssapi_link.c patch external/bsd/bind/dist/lib/dns/gssapictx.c patch external/bsd/bind/dist/lib/dns/hmac_link.c patch external/bsd/bind/dist/lib/dns/iptable.c patch external/bsd/bind/dist/lib/dns/journal.c patch external/bsd/bind/dist/lib/dns/keydata.c patch external/bsd/bind/dist/lib/dns/keytable.c patch external/bsd/bind/dist/lib/dns/log.c patch external/bsd/bind/dist/lib/dns/lookup.c patch external/bsd/bind/dist/lib/dns/master.c patch external/bsd/bind/dist/lib/dns/masterdump.c patch external/bsd/bind/dist/lib/dns/message.c patch external/bsd/bind/dist/lib/dns/name.c patch external/bsd/bind/dist/lib/dns/ncache.c patch external/bsd/bind/dist/lib/dns/nsec.c patch external/bsd/bind/dist/lib/dns/nsec3.c patch external/bsd/bind/dist/lib/dns/openssl_link.c patch external/bsd/bind/dist/lib/dns/openssldh_link.c patch external/bsd/bind/dist/lib/dns/openssldsa_link.c patch external/bsd/bind/dist/lib/dns/opensslecdsa_link.c patch external/bsd/bind/dist/lib/dns/opensslgost_link.c patch external/bsd/bind/dist/lib/dns/opensslrsa_link.c patch external/bsd/bind/dist/lib/dns/peer.c patch external/bsd/bind/dist/lib/dns/portlist.c patch external/bsd/bind/dist/lib/dns/private.c patch external/bsd/bind/dist/lib/dns/rbt.c patch external/bsd/bind/dist/lib/dns/rbtdb.c patch external/bsd/bind/dist/lib/dns/rcode.c patch external/bsd/bind/dist/lib/dns/rdata.c patch external/bsd/bind/dist/lib/dns/rdataslab.c patch external/bsd/bind/dist/lib/dns/request.c patch external/bsd/bind/dist/lib/dns/resolver.c patch external/bsd/bind/dist/lib/dns/result.c patch external/bsd/bind/dist/lib/dns/rootns.c patch external/bsd/bind/dist/lib/dns/rpz.c patch external/bsd/bind/dist/lib/dns/rrl.c new external/bsd/bind/dist/lib/dns/sdb.c patch external/bsd/bind/dist/lib/dns/sdlz.c patch external/bsd/bind/dist/lib/dns/spnego.c patch external/bsd/bind/dist/lib/dns/spnego_asn1.c patch external/bsd/bind/dist/lib/dns/ssu.c patch external/bsd/bind/dist/lib/dns/ssu_external.c patch external/bsd/bind/dist/lib/dns/time.c patch external/bsd/bind/dist/lib/dns/tkey.c patch external/bsd/bind/dist/lib/dns/tsig.c patch external/bsd/bind/dist/lib/dns/ttl.c patch external/bsd/bind/dist/lib/dns/update.c patch external/bsd/bind/dist/lib/dns/validator.c patch external/bsd/bind/dist/lib/dns/view.c patch external/bsd/bind/dist/lib/dns/xfrin.c patch external/bsd/bind/dist/lib/dns/zone.c patch external/bsd/bind/dist/lib/dns/include/dns/Makefile.in patch external/bsd/bind/dist/lib/dns/include/dns/acache.h patch external/bsd/bind/dist/lib/dns/include/dns/adb.h patch external/bsd/bind/dist/lib/dns/include/dns/cache.h patch external/bsd/bind/dist/lib/dns/include/dns/client.h patch external/bsd/bind/dist/lib/dns/include/dns/db.h patch external/bsd/bind/dist/lib/dns/include/dns/dispatch.h patch external/bsd/bind/dist/lib/dns/include/dns/dns64.h patch external/bsd/bind/dist/lib/dns/include/dns/dnssec.h patch external/bsd/bind/dist/lib/dns/include/dns/log.h patch external/bsd/bind/dist/lib/dns/include/dns/master.h patch external/bsd/bind/dist/lib/dns/include/dns/masterdump.h patch external/bsd/bind/dist/lib/dns/include/dns/message.h patch external/bsd/bind/dist/lib/dns/include/dns/name.h patch external/bsd/bind/dist/lib/dns/include/dns/ncache.h patch external/bsd/bind/dist/lib/dns/include/dns/nsec.h patch external/bsd/bind/dist/lib/dns/include/dns/nsec3.h patch external/bsd/bind/dist/lib/dns/include/dns/rbt.h patch external/bsd/bind/dist/lib/dns/include/dns/rdata.h patch external/bsd/bind/dist/lib/dns/include/dns/rdataset.h patch external/bsd/bind/dist/lib/dns/include/dns/resolver.h patch external/bsd/bind/dist/lib/dns/include/dns/result.h patch external/bsd/bind/dist/lib/dns/include/dns/rpz.h patch external/bsd/bind/dist/lib/dns/include/dns/rrl.h new external/bsd/bind/dist/lib/dns/include/dns/types.h patch external/bsd/bind/dist/lib/dns/include/dns/validator.h patch external/bsd/bind/dist/lib/dns/include/dns/view.h patch external/bsd/bind/dist/lib/dns/include/dns/zone.h patch external/bsd/bind/dist/lib/dns/include/dst/dst.h patch external/bsd/bind/dist/lib/dns/include/dst/gssapi.h patch external/bsd/bind/dist/lib/dns/rdata/any_255/tsig_250.c patch external/bsd/bind/dist/lib/dns/rdata/ch_3/a_1.c patch external/bsd/bind/dist/lib/dns/rdata/generic/afsdb_18.c patch external/bsd/bind/dist/lib/dns/rdata/generic/caa_257.c new external/bsd/bind/dist/lib/dns/rdata/generic/caa_257.h new external/bsd/bind/dist/lib/dns/rdata/generic/cdnskey_60.c new external/bsd/bind/dist/lib/dns/rdata/generic/cdnskey_60.h new external/bsd/bind/dist/lib/dns/rdata/generic/cds_59.c new external/bsd/bind/dist/lib/dns/rdata/generic/cds_59.h new external/bsd/bind/dist/lib/dns/rdata/generic/dlv_32769.c patch external/bsd/bind/dist/lib/dns/rdata/generic/dnskey_48.c patch external/bsd/bind/dist/lib/dns/rdata/generic/eui48_108.c new external/bsd/bind/dist/lib/dns/rdata/generic/eui48_108.h new external/bsd/bind/dist/lib/dns/rdata/generic/eui64_109.c new external/bsd/bind/dist/lib/dns/rdata/generic/eui64_109.h new external/bsd/bind/dist/lib/dns/rdata/generic/gpos_27.c patch external/bsd/bind/dist/lib/dns/rdata/generic/hinfo_13.c patch external/bsd/bind/dist/lib/dns/rdata/generic/hip_55.c patch external/bsd/bind/dist/lib/dns/rdata/generic/ipseckey_45.c patch external/bsd/bind/dist/lib/dns/rdata/generic/isdn_20.c patch external/bsd/bind/dist/lib/dns/rdata/generic/key_25.c patch external/bsd/bind/dist/lib/dns/rdata/generic/keydata_65533.c patch external/bsd/bind/dist/lib/dns/rdata/generic/l32_105.c new external/bsd/bind/dist/lib/dns/rdata/generic/l32_105.h new external/bsd/bind/dist/lib/dns/rdata/generic/l64_106.c new external/bsd/bind/dist/lib/dns/rdata/generic/l64_106.h new external/bsd/bind/dist/lib/dns/rdata/generic/lp_107.c new external/bsd/bind/dist/lib/dns/rdata/generic/lp_107.h new external/bsd/bind/dist/lib/dns/rdata/generic/mx_15.c patch external/bsd/bind/dist/lib/dns/rdata/generic/naptr_35.c patch external/bsd/bind/dist/lib/dns/rdata/generic/nid_104.c new external/bsd/bind/dist/lib/dns/rdata/generic/nid_104.h new external/bsd/bind/dist/lib/dns/rdata/generic/nsec3_50.c patch external/bsd/bind/dist/lib/dns/rdata/generic/opt_41.c patch external/bsd/bind/dist/lib/dns/rdata/generic/rrsig_46.c patch external/bsd/bind/dist/lib/dns/rdata/generic/rt_21.c patch external/bsd/bind/dist/lib/dns/rdata/generic/soa_6.c patch external/bsd/bind/dist/lib/dns/rdata/generic/spf_99.c patch external/bsd/bind/dist/lib/dns/rdata/generic/sshfp_44.c patch external/bsd/bind/dist/lib/dns/rdata/generic/tkey_249.c patch external/bsd/bind/dist/lib/dns/rdata/generic/tlsa_52.c patch external/bsd/bind/dist/lib/dns/rdata/generic/tlsa_52.h patch external/bsd/bind/dist/lib/dns/rdata/generic/txt_16.c patch external/bsd/bind/dist/lib/dns/rdata/generic/uri_256.c patch external/bsd/bind/dist/lib/dns/rdata/generic/x25_19.c patch external/bsd/bind/dist/lib/dns/rdata/hs_4/a_1.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/a6_38.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/a_1.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/aaaa_28.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/apl_42.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/nsap_22.c patch external/bsd/bind/dist/lib/dns/rdata/in_1/wks_11.c patch external/bsd/bind/dist/lib/dns/tests/Makefile.in patch external/bsd/bind/dist/lib/dns/tests/db_test.c new external/bsd/bind/dist/lib/dns/tests/dbiterator_test.c patch external/bsd/bind/dist/lib/dns/tests/dbversion_test.c patch external/bsd/bind/dist/lib/dns/tests/dispatch_test.c new external/bsd/bind/dist/lib/dns/tests/dnstest.c patch external/bsd/bind/dist/lib/dns/tests/master_test.c patch external/bsd/bind/dist/lib/dns/tests/nsec3_test.c patch external/bsd/bind/dist/lib/dns/tests/private_test.c patch external/bsd/bind/dist/lib/dns/tests/rdata_test.c patch external/bsd/bind/dist/lib/dns/tests/zonemgr_test.c patch external/bsd/bind/dist/lib/dns/tests/testdata/master/master17.data new external/bsd/bind/dist/lib/dns/win32/gen.dsp delete external/bsd/bind/dist/lib/dns/win32/gen.mak delete external/bsd/bind/dist/lib/dns/win32/libdns.def delete external/bsd/bind/dist/lib/dns/win32/libdns.dsp delete external/bsd/bind/dist/lib/dns/win32/libdns.mak delete external/bsd/bind/dist/lib/export/dns/Makefile.in patch external/bsd/bind/dist/lib/export/irs/Makefile.in patch external/bsd/bind/dist/lib/export/isc/Makefile.in patch external/bsd/bind/dist/lib/export/isc/include/isc/Makefile.in patch external/bsd/bind/dist/lib/export/isc/nls/Makefile.in patch external/bsd/bind/dist/lib/export/isc/nothreads/Makefile.in patch external/bsd/bind/dist/lib/export/isc/pthreads/Makefile.in patch external/bsd/bind/dist/lib/export/isc/unix/Makefile.in patch external/bsd/bind/dist/lib/export/isccfg/Makefile.in patch external/bsd/bind/dist/lib/export/samples/Makefile.in patch external/bsd/bind/dist/lib/export/samples/nsprobe.c patch external/bsd/bind/dist/lib/export/samples/sample-async.c patch external/bsd/bind/dist/lib/export/samples/sample-gai.c patch external/bsd/bind/dist/lib/export/samples/sample-request.c patch external/bsd/bind/dist/lib/export/samples/sample-update.c patch external/bsd/bind/dist/lib/export/samples/sample.c patch external/bsd/bind/dist/lib/irs/Makefile.in patch external/bsd/bind/dist/lib/irs/api patch external/bsd/bind/dist/lib/irs/context.c patch external/bsd/bind/dist/lib/irs/dnsconf.c patch external/bsd/bind/dist/lib/irs/getaddrinfo.c patch external/bsd/bind/dist/lib/irs/getnameinfo.c patch external/bsd/bind/dist/lib/irs/resconf.c patch external/bsd/bind/dist/lib/irs/include/irs/Makefile.in patch external/bsd/bind/dist/lib/irs/include/irs/resconf.h patch external/bsd/bind/dist/lib/isc/Makefile.in patch external/bsd/bind/dist/lib/isc/api patch external/bsd/bind/dist/lib/isc/app_api.c patch external/bsd/bind/dist/lib/isc/backtrace.c patch external/bsd/bind/dist/lib/isc/base32.c patch external/bsd/bind/dist/lib/isc/base64.c patch external/bsd/bind/dist/lib/isc/bind9.c new external/bsd/bind/dist/lib/isc/buffer.c patch external/bsd/bind/dist/lib/isc/commandline.c patch external/bsd/bind/dist/lib/isc/counter.c new external/bsd/bind/dist/lib/isc/event.c patch external/bsd/bind/dist/lib/isc/hash.c patch external/bsd/bind/dist/lib/isc/heap.c patch external/bsd/bind/dist/lib/isc/hex.c patch external/bsd/bind/dist/lib/isc/hmacmd5.c patch external/bsd/bind/dist/lib/isc/hmacsha.c patch external/bsd/bind/dist/lib/isc/httpd.c patch external/bsd/bind/dist/lib/isc/inet_aton.c patch external/bsd/bind/dist/lib/isc/inet_pton.c patch external/bsd/bind/dist/lib/isc/lex.c patch external/bsd/bind/dist/lib/isc/lib.c patch external/bsd/bind/dist/lib/isc/log.c patch external/bsd/bind/dist/lib/isc/md5.c patch external/bsd/bind/dist/lib/isc/mem.c patch external/bsd/bind/dist/lib/isc/mem_api.c patch external/bsd/bind/dist/lib/isc/netaddr.c patch external/bsd/bind/dist/lib/isc/parseint.c patch external/bsd/bind/dist/lib/isc/pool.c new external/bsd/bind/dist/lib/isc/print.c patch external/bsd/bind/dist/lib/isc/radix.c patch external/bsd/bind/dist/lib/isc/random.c patch external/bsd/bind/dist/lib/isc/ratelimiter.c patch external/bsd/bind/dist/lib/isc/regex.c new external/bsd/bind/dist/lib/isc/result.c patch external/bsd/bind/dist/lib/isc/safe.c new external/bsd/bind/dist/lib/isc/sha1.c patch external/bsd/bind/dist/lib/isc/sha2.c patch external/bsd/bind/dist/lib/isc/sockaddr.c patch external/bsd/bind/dist/lib/isc/socket_api.c patch external/bsd/bind/dist/lib/isc/stats.c patch external/bsd/bind/dist/lib/isc/string.c patch external/bsd/bind/dist/lib/isc/strtoul.c patch external/bsd/bind/dist/lib/isc/symtab.c patch external/bsd/bind/dist/lib/isc/task.c patch external/bsd/bind/dist/lib/isc/task_api.c patch external/bsd/bind/dist/lib/isc/taskpool.c patch external/bsd/bind/dist/lib/isc/timer.c patch external/bsd/bind/dist/lib/isc/timer_api.c patch external/bsd/bind/dist/lib/isc/tm.c new external/bsd/bind/dist/lib/isc/include/isc/Makefile.in patch external/bsd/bind/dist/lib/isc/include/isc/app.h patch external/bsd/bind/dist/lib/isc/include/isc/base32.h patch external/bsd/bind/dist/lib/isc/include/isc/bind9.h patch external/bsd/bind/dist/lib/isc/include/isc/buffer.h patch external/bsd/bind/dist/lib/isc/include/isc/counter.h new external/bsd/bind/dist/lib/isc/include/isc/event.h patch external/bsd/bind/dist/lib/isc/include/isc/file.h patch external/bsd/bind/dist/lib/isc/include/isc/hash.h patch external/bsd/bind/dist/lib/isc/include/isc/httpd.h patch external/bsd/bind/dist/lib/isc/include/isc/iterated_hash.h patch external/bsd/bind/dist/lib/isc/include/isc/list.h patch external/bsd/bind/dist/lib/isc/include/isc/mem.h patch external/bsd/bind/dist/lib/isc/include/isc/namespace.h patch external/bsd/bind/dist/lib/isc/include/isc/platform.h.in patch external/bsd/bind/dist/lib/isc/include/isc/pool.h new external/bsd/bind/dist/lib/isc/include/isc/print.h patch external/bsd/bind/dist/lib/isc/include/isc/queue.h patch external/bsd/bind/dist/lib/isc/include/isc/radix.h patch external/bsd/bind/dist/lib/isc/include/isc/regex.h new external/bsd/bind/dist/lib/isc/include/isc/region.h patch external/bsd/bind/dist/lib/isc/include/isc/result.h patch external/bsd/bind/dist/lib/isc/include/isc/safe.h new external/bsd/bind/dist/lib/isc/include/isc/sockaddr.h patch external/bsd/bind/dist/lib/isc/include/isc/socket.h patch external/bsd/bind/dist/lib/isc/include/isc/stdio.h patch external/bsd/bind/dist/lib/isc/include/isc/string.h patch external/bsd/bind/dist/lib/isc/include/isc/task.h patch external/bsd/bind/dist/lib/isc/include/isc/timer.h patch external/bsd/bind/dist/lib/isc/include/isc/tm.h new external/bsd/bind/dist/lib/isc/include/isc/types.h patch external/bsd/bind/dist/lib/isc/nothreads/Makefile.in patch external/bsd/bind/dist/lib/isc/nothreads/include/isc/thread.h patch external/bsd/bind/dist/lib/isc/pthreads/thread.c patch external/bsd/bind/dist/lib/isc/pthreads/include/isc/thread.h patch external/bsd/bind/dist/lib/isc/sparc64/include/isc/atomic.h patch external/bsd/bind/dist/lib/isc/tests/Makefile.in patch external/bsd/bind/dist/lib/isc/tests/counter_test.c new external/bsd/bind/dist/lib/isc/tests/hash_test.c patch external/bsd/bind/dist/lib/isc/tests/isctest.c patch external/bsd/bind/dist/lib/isc/tests/isctest.h patch external/bsd/bind/dist/lib/isc/tests/lex_test.c new external/bsd/bind/dist/lib/isc/tests/parse_test.c new external/bsd/bind/dist/lib/isc/tests/pool_test.c new external/bsd/bind/dist/lib/isc/tests/print_test.c new external/bsd/bind/dist/lib/isc/tests/regex_test.c new external/bsd/bind/dist/lib/isc/tests/safe_test.c new external/bsd/bind/dist/lib/isc/tests/sockaddr_test.c new external/bsd/bind/dist/lib/isc/tests/symtab_test.c patch external/bsd/bind/dist/lib/isc/tests/time_test.c new external/bsd/bind/dist/lib/isc/unix/app.c patch external/bsd/bind/dist/lib/isc/unix/entropy.c patch external/bsd/bind/dist/lib/isc/unix/file.c patch external/bsd/bind/dist/lib/isc/unix/ifiter_getifaddrs.c patch external/bsd/bind/dist/lib/isc/unix/ifiter_ioctl.c patch external/bsd/bind/dist/lib/isc/unix/ifiter_sysctl.c patch external/bsd/bind/dist/lib/isc/unix/interfaceiter.c patch external/bsd/bind/dist/lib/isc/unix/net.c patch external/bsd/bind/dist/lib/isc/unix/socket.c patch external/bsd/bind/dist/lib/isc/unix/stdio.c patch external/bsd/bind/dist/lib/isc/unix/time.c patch external/bsd/bind/dist/lib/isc/unix/include/isc/Makefile.in patch external/bsd/bind/dist/lib/isc/unix/include/isc/net.h patch external/bsd/bind/dist/lib/isc/unix/include/isc/stat.h patch external/bsd/bind/dist/lib/isc/unix/include/isc/time.h patch external/bsd/bind/dist/lib/isc/win32/libisc.def delete external/bsd/bind/dist/lib/isc/win32/libisc.dsp delete external/bsd/bind/dist/lib/isc/win32/libisc.mak delete external/bsd/bind/dist/lib/isc/win32/include/isc/platform.h delete external/bsd/bind/dist/lib/isccc/Makefile.in patch external/bsd/bind/dist/lib/isccc/api patch external/bsd/bind/dist/lib/isccc/base64.c patch external/bsd/bind/dist/lib/isccc/cc.c patch external/bsd/bind/dist/lib/isccc/sexpr.c patch external/bsd/bind/dist/lib/isccc/include/isccc/util.h patch external/bsd/bind/dist/lib/isccc/win32/libisccc.dsp delete external/bsd/bind/dist/lib/isccc/win32/libisccc.mak delete external/bsd/bind/dist/lib/isccfg/Makefile.in patch external/bsd/bind/dist/lib/isccfg/aclconf.c patch external/bsd/bind/dist/lib/isccfg/api patch external/bsd/bind/dist/lib/isccfg/namedconf.c patch external/bsd/bind/dist/lib/isccfg/parser.c patch external/bsd/bind/dist/lib/isccfg/include/isccfg/Makefile.in patch external/bsd/bind/dist/lib/isccfg/include/isccfg/aclconf.h patch external/bsd/bind/dist/lib/isccfg/include/isccfg/cfg.h patch external/bsd/bind/dist/lib/isccfg/include/isccfg/grammar.h patch external/bsd/bind/dist/lib/isccfg/win32/libisccfg.dsp delete external/bsd/bind/dist/lib/isccfg/win32/libisccfg.mak delete external/bsd/bind/dist/lib/lwres/Atffile new external/bsd/bind/dist/lib/lwres/Makefile.in patch external/bsd/bind/dist/lib/lwres/api patch external/bsd/bind/dist/lib/lwres/compat.c new external/bsd/bind/dist/lib/lwres/context.c patch external/bsd/bind/dist/lib/lwres/gai_strerror.c patch external/bsd/bind/dist/lib/lwres/getaddrinfo.c patch external/bsd/bind/dist/lib/lwres/gethost.c patch external/bsd/bind/dist/lib/lwres/getipnode.c patch external/bsd/bind/dist/lib/lwres/getnameinfo.c patch external/bsd/bind/dist/lib/lwres/getrrset.c patch external/bsd/bind/dist/lib/lwres/herror.c patch external/bsd/bind/dist/lib/lwres/lwbuffer.c patch external/bsd/bind/dist/lib/lwres/lwconfig.c patch external/bsd/bind/dist/lib/lwres/lwinetaton.c patch external/bsd/bind/dist/lib/lwres/lwinetpton.c patch external/bsd/bind/dist/lib/lwres/lwres_gabn.c patch external/bsd/bind/dist/lib/lwres/lwres_gnba.c patch external/bsd/bind/dist/lib/lwres/lwres_grbn.c patch external/bsd/bind/dist/lib/lwres/lwres_noop.c patch external/bsd/bind/dist/lib/lwres/lwresutil.c patch external/bsd/bind/dist/lib/lwres/print.c patch external/bsd/bind/dist/lib/lwres/strtoul.c delete external/bsd/bind/dist/lib/lwres/include/lwres/Makefile.in patch external/bsd/bind/dist/lib/lwres/include/lwres/lwres.h patch external/bsd/bind/dist/lib/lwres/include/lwres/netdb.h.in patch external/bsd/bind/dist/lib/lwres/include/lwres/platform.h.in patch external/bsd/bind/dist/lib/lwres/include/lwres/stdlib.h patch external/bsd/bind/dist/lib/lwres/include/lwres/string.h new external/bsd/bind/dist/lib/lwres/man/lwres.3 patch external/bsd/bind/dist/lib/lwres/man/lwres.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres.html patch external/bsd/bind/dist/lib/lwres/man/lwres_buffer.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_buffer.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_buffer.html patch external/bsd/bind/dist/lib/lwres/man/lwres_config.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_config.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_config.html patch external/bsd/bind/dist/lib/lwres/man/lwres_context.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_context.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_context.html patch external/bsd/bind/dist/lib/lwres/man/lwres_gabn.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_gabn.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_gabn.html patch external/bsd/bind/dist/lib/lwres/man/lwres_gai_strerror.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_gai_strerror.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_gai_strerror.html patch external/bsd/bind/dist/lib/lwres/man/lwres_getaddrinfo.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_getaddrinfo.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_getaddrinfo.html patch external/bsd/bind/dist/lib/lwres/man/lwres_gethostent.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_gethostent.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_gethostent.html patch external/bsd/bind/dist/lib/lwres/man/lwres_getipnode.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_getipnode.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_getipnode.html patch external/bsd/bind/dist/lib/lwres/man/lwres_getnameinfo.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_getnameinfo.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_getnameinfo.html patch external/bsd/bind/dist/lib/lwres/man/lwres_getrrsetbyname.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_getrrsetbyname.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_getrrsetbyname.html patch external/bsd/bind/dist/lib/lwres/man/lwres_gnba.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_gnba.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_gnba.html patch external/bsd/bind/dist/lib/lwres/man/lwres_hstrerror.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_hstrerror.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_hstrerror.html patch external/bsd/bind/dist/lib/lwres/man/lwres_inetntop.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_inetntop.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_inetntop.html patch external/bsd/bind/dist/lib/lwres/man/lwres_noop.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_noop.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_noop.html patch external/bsd/bind/dist/lib/lwres/man/lwres_packet.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_packet.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_packet.html patch external/bsd/bind/dist/lib/lwres/man/lwres_resutil.3 patch external/bsd/bind/dist/lib/lwres/man/lwres_resutil.docbook patch external/bsd/bind/dist/lib/lwres/man/lwres_resutil.html patch external/bsd/bind/dist/lib/lwres/tests/Atffile new external/bsd/bind/dist/lib/lwres/tests/Makefile.in new external/bsd/bind/dist/lib/lwres/tests/config_test.c new external/bsd/bind/dist/lib/lwres/tests/testdata/link-local.conf new external/bsd/bind/dist/lib/lwres/win32/liblwres.dsp delete external/bsd/bind/dist/lib/lwres/win32/liblwres.mak delete external/bsd/bind/dist/lib/tests/t_api.c patch external/bsd/bind/dist/lib/tests/include/tests/t_api.h patch external/bsd/bind/dist/lib/win32/bindevt/bindevt.dsp delete external/bsd/bind/dist/lib/win32/bindevt/bindevt.mak delete external/bsd/bind/dist/make/mkdep.in patch external/bsd/bind/dist/make/rules.in patch external/bsd/bind/dist/unit/README patch external/bsd/bind/dist/unit/unittest.sh.in patch external/bsd/bind/dist/unit/atf-src/AUTHORS patch external/bsd/bind/dist/unit/atf-src/Atffile patch external/bsd/bind/dist/unit/atf-src/COPYING patch external/bsd/bind/dist/unit/atf-src/INSTALL patch external/bsd/bind/dist/unit/atf-src/Kyuafile new external/bsd/bind/dist/unit/atf-src/Makefile.am patch external/bsd/bind/dist/unit/atf-src/Makefile.in patch external/bsd/bind/dist/unit/atf-src/NEWS patch external/bsd/bind/dist/unit/atf-src/TODO new external/bsd/bind/dist/unit/atf-src/aclocal.m4 patch external/bsd/bind/dist/unit/atf-src/atf-c++.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c.h patch external/bsd/bind/dist/unit/atf-src/configure patch external/bsd/bind/dist/unit/atf-src/configure.ac patch external/bsd/bind/dist/unit/atf-src/admin/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/admin/check-install.sh delete external/bsd/bind/dist/unit/atf-src/admin/check-style-c.awk patch external/bsd/bind/dist/unit/atf-src/admin/check-style-common.awk patch external/bsd/bind/dist/unit/atf-src/admin/check-style-cpp.awk patch external/bsd/bind/dist/unit/atf-src/admin/check-style-man.awk patch external/bsd/bind/dist/unit/atf-src/admin/check-style-shell.awk patch external/bsd/bind/dist/unit/atf-src/admin/check-style.sh patch external/bsd/bind/dist/unit/atf-src/admin/compile patch external/bsd/bind/dist/unit/atf-src/admin/depcomp patch external/bsd/bind/dist/unit/atf-src/admin/install-sh patch external/bsd/bind/dist/unit/atf-src/admin/ltmain.sh patch external/bsd/bind/dist/unit/atf-src/admin/missing patch external/bsd/bind/dist/unit/atf-src/atf-c/Atffile patch external/bsd/bind/dist/unit/atf-src/atf-c/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-c/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-c/atf-c-api.3 patch external/bsd/bind/dist/unit/atf-src/atf-c/atf-c.m4 new external/bsd/bind/dist/unit/atf-src/atf-c/atf-common.m4 new external/bsd/bind/dist/unit/atf-src/atf-c/atf_c_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/check.c patch external/bsd/bind/dist/unit/atf-src/atf-c/check.h patch external/bsd/bind/dist/unit/atf-src/atf-c/check_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/config.c patch external/bsd/bind/dist/unit/atf-src/atf-c/config_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/defs.h.in patch external/bsd/bind/dist/unit/atf-src/atf-c/error.c patch external/bsd/bind/dist/unit/atf-src/atf-c/error.h patch external/bsd/bind/dist/unit/atf-src/atf-c/error_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/macros.h patch external/bsd/bind/dist/unit/atf-src/atf-c/macros_h_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/macros_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/pkg_config_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-c/tc.c patch external/bsd/bind/dist/unit/atf-src/atf-c/tc.h patch external/bsd/bind/dist/unit/atf-src/atf-c/tc_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/tp.c patch external/bsd/bind/dist/unit/atf-src/atf-c/tp.h patch external/bsd/bind/dist/unit/atf-src/atf-c/tp_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/unused_test.c new external/bsd/bind/dist/unit/atf-src/atf-c/utils.c patch external/bsd/bind/dist/unit/atf-src/atf-c/utils.h patch external/bsd/bind/dist/unit/atf-src/atf-c/utils_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/Atffile patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-c/detail/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/dynstr.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/dynstr.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/dynstr_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/env.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/env_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/fs.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/fs.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/fs_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/list.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/list.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/list_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/map.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/map.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/map_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/process.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/process.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/process_helpers.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/process_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/sanity.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/sanity_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/test_helpers.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/test_helpers.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/test_helpers_test.c delete external/bsd/bind/dist/unit/atf-src/atf-c/detail/text.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/text.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/text_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/tp_main.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/user.c patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/user.h patch external/bsd/bind/dist/unit/atf-src/atf-c/detail/user_test.c patch external/bsd/bind/dist/unit/atf-src/atf-c++/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-c++/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-c++/atf-c++-api.3 patch external/bsd/bind/dist/unit/atf-src/atf-c++/atf-c++.m4 new external/bsd/bind/dist/unit/atf-src/atf-c++/check.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/check.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/check_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/config.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/config.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/config_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/macros.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/macros_hpp_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/macros_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/noncopyable.hpp new external/bsd/bind/dist/unit/atf-src/atf-c++/pkg_config_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-c++/tests.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/tests.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/tests_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/unused_test.cpp new external/bsd/bind/dist/unit/atf-src/atf-c++/utils.cpp new external/bsd/bind/dist/unit/atf-src/atf-c++/utils.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/utils_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/Atffile patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-c++/detail/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/application.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/application.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/application_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/auto_array.hpp new external/bsd/bind/dist/unit/atf-src/atf-c++/detail/auto_array_test.cpp new external/bsd/bind/dist/unit/atf-src/atf-c++/detail/env.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/env.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/env_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/exceptions.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/exceptions.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/exceptions_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/expand.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/expand.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/expand_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/fs.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/fs.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/fs_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/parser.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/parser.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/parser_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/process.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/process.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/process_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/sanity.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/test_helpers.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/test_helpers.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/text.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/text.hpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/text_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/ui.cpp patch external/bsd/bind/dist/unit/atf-src/atf-c++/detail/ui.hpp patch external/bsd/bind/dist/unit/atf-src/atf-config/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-config/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-config/atf-config.1 patch external/bsd/bind/dist/unit/atf-src/atf-config/atf-config.cpp patch external/bsd/bind/dist/unit/atf-src/atf-config/integration_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-report/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-report/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-report/atf-report.1 patch external/bsd/bind/dist/unit/atf-src/atf-report/atf-report.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/fail_helper.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/integration_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-report/misc_helpers.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/pass_helper.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/reader.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/reader.hpp patch external/bsd/bind/dist/unit/atf-src/atf-report/reader_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-report/tests-results.css patch external/bsd/bind/dist/unit/atf-src/atf-report/tests-results.dtd patch external/bsd/bind/dist/unit/atf-src/atf-report/tests-results.xsl patch external/bsd/bind/dist/unit/atf-src/atf-run/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-run/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-run/atf-run.1 patch external/bsd/bind/dist/unit/atf-src/atf-run/atf-run.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/atffile.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/atffile.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/atffile_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/config.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/config_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/fs.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/fs.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/fs_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/integration_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-run/io.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/io.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/io_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/misc_helpers.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/pass_helper.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/requirements.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/requirements_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/several_tcs_helper.c patch external/bsd/bind/dist/unit/atf-src/atf-run/signals.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/signals.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/signals_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/test-program.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/test_program_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/timer.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/timer.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/user.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/user.hpp patch external/bsd/bind/dist/unit/atf-src/atf-run/user_test.cpp patch external/bsd/bind/dist/unit/atf-src/atf-run/zero_tcs_helper.c patch external/bsd/bind/dist/unit/atf-src/atf-run/share/atf-run.hooks patch external/bsd/bind/dist/unit/atf-src/atf-sh/Kyuafile new external/bsd/bind/dist/unit/atf-src/atf-sh/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-check.1 patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-check.cpp patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-check_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-sh-api.3 patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-sh.cpp patch external/bsd/bind/dist/unit/atf-src/atf-sh/atf-sh.m4 new external/bsd/bind/dist/unit/atf-src/atf-sh/atf-sh.pc.in new external/bsd/bind/dist/unit/atf-src/atf-sh/atf_check_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/config_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/libatf-sh.subr patch external/bsd/bind/dist/unit/atf-src/atf-sh/misc_helpers.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/normalize_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/tc_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-sh/tp_test.sh patch external/bsd/bind/dist/unit/atf-src/atf-version/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/atf-version/atf-version.1 patch external/bsd/bind/dist/unit/atf-src/atf-version/atf-version.cpp patch external/bsd/bind/dist/unit/atf-src/atf-version/generate-revision.sh patch external/bsd/bind/dist/unit/atf-src/bootstrap/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/bootstrap/h_app_empty.cpp patch external/bsd/bind/dist/unit/atf-src/bootstrap/h_app_opts_args.cpp patch external/bsd/bind/dist/unit/atf-src/bootstrap/h_tp_atf_check_sh.sh patch external/bsd/bind/dist/unit/atf-src/bootstrap/h_tp_basic_cpp.cpp patch external/bsd/bind/dist/unit/atf-src/bootstrap/h_tp_basic_sh.sh patch external/bsd/bind/dist/unit/atf-src/bootstrap/package.m4 patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_application_help.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_application_opts_args.atpatch external/bsd/bind/dist/unit/atf-src/bootstrap/t_atf_config.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_atf_run.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_subr_atf_check.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_test_program_compare.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_test_program_filter.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_test_program_list.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/t_test_program_run.at patch external/bsd/bind/dist/unit/atf-src/bootstrap/testsuite patch external/bsd/bind/dist/unit/atf-src/bootstrap/testsuite.at patch external/bsd/bind/dist/unit/atf-src/doc/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/doc/atf-formats.5 patch external/bsd/bind/dist/unit/atf-src/doc/atf-test-case.4 patch external/bsd/bind/dist/unit/atf-src/doc/atf-test-program.1 patch external/bsd/bind/dist/unit/atf-src/doc/atf.7.in patch external/bsd/bind/dist/unit/atf-src/m4/compiler-flags.m4 patch external/bsd/bind/dist/unit/atf-src/m4/cxx-std-funcs.m4 patch external/bsd/bind/dist/unit/atf-src/m4/developer-mode.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-application.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-defs.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-env.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-fs.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-sanity.m4 patch external/bsd/bind/dist/unit/atf-src/m4/module-signals.m4 patch external/bsd/bind/dist/unit/atf-src/test-programs/Atffile patch external/bsd/bind/dist/unit/atf-src/test-programs/Kyuafile new external/bsd/bind/dist/unit/atf-src/test-programs/Makefile.am.inc patch external/bsd/bind/dist/unit/atf-src/test-programs/c_helpers.c patch external/bsd/bind/dist/unit/atf-src/test-programs/config_test.sh patch external/bsd/bind/dist/unit/atf-src/test-programs/cpp_helpers.cpp patch external/bsd/bind/dist/unit/atf-src/test-programs/expect_test.sh patch external/bsd/bind/dist/unit/atf-src/test-programs/fork_test.sh delete external/bsd/bind/dist/unit/atf-src/test-programs/meta_data_test.sh patch external/bsd/bind/dist/unit/atf-src/test-programs/result_test.sh patch external/bsd/bind/dist/unit/atf-src/test-programs/sh_helpers.sh patch external/bsd/bind/dist/unit/atf-src/test-programs/srcdir_test.sh patch external/bsd/bind/dist/win32utils/BINDBuild.dsw delete external/bsd/bind/dist/win32utils/BuildAll.bat delete external/bsd/bind/dist/win32utils/BuildPost.bat delete external/bsd/bind/dist/win32utils/BuildSetup.bat delete external/bsd/bind/dist/win32utils/SetupLibs.bat delete external/bsd/bind/dist/win32utils/dnsheadergen.bat delete external/bsd/bind/dist/win32utils/makedefs.pl delete external/bsd/bind/dist/win32utils/makeversion.pl delete external/bsd/bind/dist/win32utils/setpk11provider.pl delete external/bsd/bind/dist/win32utils/updatelibxml2.pl delete external/bsd/bind/dist/win32utils/updateopenssl.pl delete external/bsd/bind/dist/win32utils/win32-build.txt delete external/bsd/bind/include/config.h patch external/bsd/bind/include/dns/code.h patch external/bsd/bind/include/dns/enumclass.h patch external/bsd/bind/include/dns/enumtype.h patch external/bsd/bind/include/dns/rdatastruct.h patch external/bsd/bind/include/irs/netdb.h new external/bsd/bind/include/irs/platform.h new external/bsd/bind/include/isc/platform.h patch external/bsd/bind/include/lwres/netdb.h patch external/bsd/bind/include/lwres/platform.h patch external/bsd/bind/lib/Makefile patch external/bsd/bind/lib/libbind9/Makefile patch external/bsd/bind/lib/libbind9/shlib_version patch external/bsd/bind/lib/libdns/Makefile patch external/bsd/bind/lib/libdns/shlib_version patch external/bsd/bind/lib/libirs/Makefile new external/bsd/bind/lib/libirs/shlib_version new external/bsd/bind/lib/libisc/Makefile patch external/bsd/bind/lib/libisc/shlib_version patch external/bsd/bind/lib/libisccc/Makefile patch external/bsd/bind/lib/libisccc/shlib_version patch external/bsd/bind/lib/libisccfg/Makefile patch external/bsd/bind/lib/libisccfg/shlib_version patch external/bsd/bind/lib/liblwres/shlib_version patch Update bind to 9.9.6-P1. CVE-2014-8500.

/*	$NetBSD: adb.c,v 1.3.4.2.2.1 2014/12/26 03:08:32 msaitoh Exp $	*/

/*
 * Copyright (C) 2004-2014  Internet Systems Consortium, Inc. ("ISC")
 * Copyright (C) 1999-2003  Internet Software Consortium.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

/*! \file
 *
 * \note
 * In finds, if task == NULL, no events will be generated, and no events
 * have been sent.  If task != NULL but taskaction == NULL, an event has been
 * posted but not yet freed.  If neither are NULL, no event was posted.
 *
 */

#include <config.h>

#include <limits.h>

#include <isc/mutexblock.h>
#include <isc/netaddr.h>
#include <isc/random.h>
#include <isc/stats.h>
#include <isc/string.h>         /* Required for HP/UX (and others?) */
#include <isc/task.h>
#include <isc/util.h>

#include <dns/adb.h>
#include <dns/db.h>
#include <dns/events.h>
#include <dns/log.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
#include <dns/resolver.h>
#include <dns/result.h>
#include <dns/stats.h>

#define DNS_ADB_MAGIC             ISC_MAGIC('D', 'a', 'd', 'b')
#define DNS_ADB_VALID(x)          ISC_MAGIC_VALID(x, DNS_ADB_MAGIC)
#define DNS_ADBNAME_MAGIC         ISC_MAGIC('a', 'd', 'b', 'N')
#define DNS_ADBNAME_VALID(x)      ISC_MAGIC_VALID(x, DNS_ADBNAME_MAGIC)
#define DNS_ADBNAMEHOOK_MAGIC     ISC_MAGIC('a', 'd', 'N', 'H')
#define DNS_ADBNAMEHOOK_VALID(x)  ISC_MAGIC_VALID(x, DNS_ADBNAMEHOOK_MAGIC)
#define DNS_ADBLAMEINFO_MAGIC     ISC_MAGIC('a', 'd', 'b', 'Z')
#define DNS_ADBLAMEINFO_VALID(x)  ISC_MAGIC_VALID(x, DNS_ADBLAMEINFO_MAGIC)
#define DNS_ADBENTRY_MAGIC        ISC_MAGIC('a', 'd', 'b', 'E')
#define DNS_ADBENTRY_VALID(x)     ISC_MAGIC_VALID(x, DNS_ADBENTRY_MAGIC)
#define DNS_ADBFETCH_MAGIC        ISC_MAGIC('a', 'd', 'F', '4')
#define DNS_ADBFETCH_VALID(x)     ISC_MAGIC_VALID(x, DNS_ADBFETCH_MAGIC)
#define DNS_ADBFETCH6_MAGIC       ISC_MAGIC('a', 'd', 'F', '6')
#define DNS_ADBFETCH6_VALID(x)    ISC_MAGIC_VALID(x, DNS_ADBFETCH6_MAGIC)

/*!
 * For type 3 negative cache entries, we will remember that the address is
 * broken for this long.  XXXMLG This is also used for actual addresses, too.
 * The intent is to keep us from constantly asking about A/AAAA records
 * if the zone has extremely low TTLs.
 */
#define ADB_CACHE_MINIMUM       10      /*%< seconds */
#define ADB_CACHE_MAXIMUM       86400   /*%< seconds (86400 = 24 hours) */
#define ADB_ENTRY_WINDOW        1800    /*%< seconds */

/*%
 * The period in seconds after which an ADB name entry is regarded as stale
 * and forced to be cleaned up.
 * TODO: This should probably be configurable at run-time.
 */
#ifndef ADB_STALE_MARGIN
#define ADB_STALE_MARGIN        1800
#endif

#define FREE_ITEMS              64      /*%< free count for memory pools */
#define FILL_COUNT              16      /*%< fill count for memory pools */

#define DNS_ADB_INVALIDBUCKET (-1)      /*%< invalid bucket address */

#define DNS_ADB_MINADBSIZE      (1024U*1024U)     /*%< 1 Megabyte */

typedef ISC_LIST(dns_adbname_t) dns_adbnamelist_t;
typedef struct dns_adbnamehook dns_adbnamehook_t;
typedef ISC_LIST(dns_adbnamehook_t) dns_adbnamehooklist_t;
typedef struct dns_adblameinfo dns_adblameinfo_t;
typedef ISC_LIST(dns_adbentry_t) dns_adbentrylist_t;
typedef struct dns_adbfetch dns_adbfetch_t;
typedef struct dns_adbfetch6 dns_adbfetch6_t;

/*% dns adb structure */
struct dns_adb {
	unsigned int                    magic;

	isc_mutex_t                     lock;
	isc_mutex_t                     reflock; /*%< Covers irefcnt, erefcnt */
	isc_mutex_t                     overmemlock; /*%< Covers overmem */
	isc_mem_t                      *mctx;
	dns_view_t                     *view;

	isc_taskmgr_t                  *taskmgr;
	isc_task_t                     *task;
	isc_task_t                     *excl;

	isc_interval_t                  tick_interval;
	int                             next_cleanbucket;

	unsigned int                    irefcnt;
	unsigned int                    erefcnt;

	isc_mutex_t                     mplock;
	isc_mempool_t                  *nmp;    /*%< dns_adbname_t */
	isc_mempool_t                  *nhmp;   /*%< dns_adbnamehook_t */
	isc_mempool_t                  *limp;   /*%< dns_adblameinfo_t */
	isc_mempool_t                  *emp;    /*%< dns_adbentry_t */
	isc_mempool_t                  *ahmp;   /*%< dns_adbfind_t */
	isc_mempool_t                  *aimp;   /*%< dns_adbaddrinfo_t */
	isc_mempool_t                  *afmp;   /*%< dns_adbfetch_t */

	/*!
	 * Bucketized locks and lists for names.
	 *
	 * XXXRTH  Have a per-bucket structure that contains all of these?
	 */
	unsigned int			nnames;
	isc_mutex_t                     namescntlock;
	unsigned int			namescnt;
	dns_adbnamelist_t               *names;
	dns_adbnamelist_t               *deadnames;
	isc_mutex_t                     *namelocks;
	isc_boolean_t                   *name_sd;
	unsigned int                    *name_refcnt;

	/*!
	 * Bucketized locks and lists for entries.
	 *
	 * XXXRTH  Have a per-bucket structure that contains all of these?
	 */
	unsigned int			nentries;
	isc_mutex_t                     entriescntlock;
	unsigned int			entriescnt;
	dns_adbentrylist_t              *entries;
	dns_adbentrylist_t              *deadentries;
	isc_mutex_t                     *entrylocks;
	isc_boolean_t                   *entry_sd; /*%< shutting down */
	unsigned int                    *entry_refcnt;

	isc_event_t                     cevent;
	isc_boolean_t                   cevent_out;
	isc_boolean_t                   shutting_down;
	isc_eventlist_t                 whenshutdown;
	isc_event_t			growentries;
	isc_boolean_t			growentries_sent;
	isc_event_t			grownames;
	isc_boolean_t			grownames_sent;
};

/*
 * XXXMLG  Document these structures.
 */

/*% dns_adbname structure */
struct dns_adbname {
	unsigned int                    magic;
	dns_name_t                      name;
	dns_adb_t                      *adb;
	unsigned int                    partial_result;
	unsigned int                    flags;
	int                             lock_bucket;
	dns_name_t                      target;
	isc_stdtime_t                   expire_target;
	isc_stdtime_t                   expire_v4;
	isc_stdtime_t                   expire_v6;
	unsigned int                    chains;
	dns_adbnamehooklist_t           v4;
	dns_adbnamehooklist_t           v6;
	dns_adbfetch_t                 *fetch_a;
	dns_adbfetch_t                 *fetch_aaaa;
	unsigned int                    fetch_err;
	unsigned int                    fetch6_err;
	dns_adbfindlist_t               finds;
	/* for LRU-based management */
	isc_stdtime_t                   last_used;

	ISC_LINK(dns_adbname_t)         plink;
};

/*% The adbfetch structure */
struct dns_adbfetch {
	unsigned int                    magic;
	dns_fetch_t                    *fetch;
	dns_rdataset_t                  rdataset;
	unsigned int			depth;
};

/*%
 * This is a small widget that dangles off a dns_adbname_t.  It contains a
 * pointer to the address information about this host, and a link to the next
 * namehook that will contain the next address this host has.
 */
struct dns_adbnamehook {
	unsigned int                    magic;
	dns_adbentry_t                 *entry;
	ISC_LINK(dns_adbnamehook_t)     plink;
};

/*%
 * This is a small widget that holds qname-specific information about an
 * address.  Currently limited to lameness, but could just as easily be
 * extended to other types of information about zones.
 */
struct dns_adblameinfo {
	unsigned int                    magic;

	dns_name_t                      qname;
	dns_rdatatype_t                 qtype;
	isc_stdtime_t                   lame_timer;

	ISC_LINK(dns_adblameinfo_t)     plink;
};

/*%
 * An address entry.  It holds quite a bit of information about addresses,
 * including edns state (in "flags"), rtt, and of course the address of
 * the host.
 */
struct dns_adbentry {
	unsigned int                    magic;

	int                             lock_bucket;
	unsigned int                    refcnt;

	unsigned int                    flags;
	unsigned int                    srtt;
	isc_sockaddr_t                  sockaddr;

	isc_stdtime_t                   expires;
	isc_stdtime_t			lastage;
	/*%<
	 * A nonzero 'expires' field indicates that the entry should
	 * persist until that time.  This allows entries found
	 * using dns_adb_findaddrinfo() to persist for a limited time
	 * even though they are not necessarily associated with a
	 * name.
	 */

	ISC_LIST(dns_adblameinfo_t)     lameinfo;
	ISC_LINK(dns_adbentry_t)        plink;

};

/*
 * Internal functions (and prototypes).
 */
static inline dns_adbname_t *new_adbname(dns_adb_t *, dns_name_t *);
static inline void free_adbname(dns_adb_t *, dns_adbname_t **);
static inline dns_adbnamehook_t *new_adbnamehook(dns_adb_t *,
						 dns_adbentry_t *);
static inline void free_adbnamehook(dns_adb_t *, dns_adbnamehook_t **);
static inline dns_adblameinfo_t *new_adblameinfo(dns_adb_t *, dns_name_t *,
						 dns_rdatatype_t);
static inline void free_adblameinfo(dns_adb_t *, dns_adblameinfo_t **);
static inline dns_adbentry_t *new_adbentry(dns_adb_t *);
static inline void free_adbentry(dns_adb_t *, dns_adbentry_t **);
static inline dns_adbfind_t *new_adbfind(dns_adb_t *);
static inline isc_boolean_t free_adbfind(dns_adb_t *, dns_adbfind_t **);
static inline dns_adbaddrinfo_t *new_adbaddrinfo(dns_adb_t *, dns_adbentry_t *,
						 in_port_t);
static inline dns_adbfetch_t *new_adbfetch(dns_adb_t *);
static inline void free_adbfetch(dns_adb_t *, dns_adbfetch_t **);
static inline dns_adbname_t *find_name_and_lock(dns_adb_t *, dns_name_t *,
						unsigned int, int *);
static inline dns_adbentry_t *find_entry_and_lock(dns_adb_t *,
						  isc_sockaddr_t *, int *,
						  isc_stdtime_t);
static void dump_adb(dns_adb_t *, FILE *, isc_boolean_t debug, isc_stdtime_t);
static void print_dns_name(FILE *, dns_name_t *);
static void print_namehook_list(FILE *, const char *legend,
				dns_adbnamehooklist_t *list,
				isc_boolean_t debug,
				isc_stdtime_t now);
static void print_find_list(FILE *, dns_adbname_t *);
static void print_fetch_list(FILE *, dns_adbname_t *);
static inline isc_boolean_t dec_adb_irefcnt(dns_adb_t *);
static inline void inc_adb_irefcnt(dns_adb_t *);
static inline void inc_adb_erefcnt(dns_adb_t *);
static inline void inc_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
				    isc_boolean_t);
static inline isc_boolean_t dec_entry_refcnt(dns_adb_t *, isc_boolean_t,
					     dns_adbentry_t *, isc_boolean_t);
static inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
static isc_boolean_t clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *);
static void clean_target(dns_adb_t *, dns_name_t *);
static void clean_finds_at_name(dns_adbname_t *, isc_eventtype_t, unsigned int);
static isc_boolean_t check_expire_namehooks(dns_adbname_t *, isc_stdtime_t);
static isc_boolean_t check_expire_entry(dns_adb_t *, dns_adbentry_t **,
					isc_stdtime_t);
static void cancel_fetches_at_name(dns_adbname_t *);
static isc_result_t dbfind_name(dns_adbname_t *, isc_stdtime_t,
				dns_rdatatype_t);
static isc_result_t fetch_name(dns_adbname_t *, isc_boolean_t,
			       unsigned int, isc_counter_t *qc,
			       dns_rdatatype_t);
static inline void check_exit(dns_adb_t *);
static void destroy(dns_adb_t *);
static isc_boolean_t shutdown_names(dns_adb_t *);
static isc_boolean_t shutdown_entries(dns_adb_t *);
static inline void link_name(dns_adb_t *, int, dns_adbname_t *);
static inline isc_boolean_t unlink_name(dns_adb_t *, dns_adbname_t *);
static inline void link_entry(dns_adb_t *, int, dns_adbentry_t *);
static inline isc_boolean_t unlink_entry(dns_adb_t *, dns_adbentry_t *);
static isc_boolean_t kill_name(dns_adbname_t **, isc_eventtype_t);
static void water(void *, int);
static void dump_entry(FILE *, dns_adbentry_t *, isc_boolean_t, isc_stdtime_t);
static void adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt,
		       unsigned int factor, isc_stdtime_t now);
static void shutdown_task(isc_task_t *task, isc_event_t *ev);

/*
 * MUST NOT overlap DNS_ADBFIND_* flags!
 */
#define FIND_EVENT_SENT         0x40000000
#define FIND_EVENT_FREED        0x80000000
#define FIND_EVENTSENT(h)       (((h)->flags & FIND_EVENT_SENT) != 0)
#define FIND_EVENTFREED(h)      (((h)->flags & FIND_EVENT_FREED) != 0)

#define NAME_NEEDS_POKE         0x80000000
#define NAME_IS_DEAD            0x40000000
#define NAME_HINT_OK            DNS_ADBFIND_HINTOK
#define NAME_GLUE_OK            DNS_ADBFIND_GLUEOK
#define NAME_STARTATZONE        DNS_ADBFIND_STARTATZONE
#define NAME_DEAD(n)            (((n)->flags & NAME_IS_DEAD) != 0)
#define NAME_NEEDSPOKE(n)       (((n)->flags & NAME_NEEDS_POKE) != 0)
#define NAME_GLUEOK(n)          (((n)->flags & NAME_GLUE_OK) != 0)
#define NAME_HINTOK(n)          (((n)->flags & NAME_HINT_OK) != 0)

/*
 * Private flag(s) for entries.
 * MUST NOT overlap FCTX_ADDRINFO_xxx and DNS_FETCHOPT_NOEDNS0.
 */
#define ENTRY_IS_DEAD		0x00400000

/*
 * To the name, address classes are all that really exist.  If it has a
 * V6 address it doesn't care if it came from a AAAA query.
 */
#define NAME_HAS_V4(n)          (!ISC_LIST_EMPTY((n)->v4))
#define NAME_HAS_V6(n)          (!ISC_LIST_EMPTY((n)->v6))
#define NAME_HAS_ADDRS(n)       (NAME_HAS_V4(n) || NAME_HAS_V6(n))

/*
 * Fetches are broken out into A and AAAA types.  In some cases,
 * however, it makes more sense to test for a particular class of fetches,
 * like V4 or V6 above.
 * Note: since we have removed the support of A6 in adb, FETCH_A and FETCH_AAAA
 * are now equal to FETCH_V4 and FETCH_V6, respectively.
 */
#define NAME_FETCH_A(n)         ((n)->fetch_a != NULL)
#define NAME_FETCH_AAAA(n)      ((n)->fetch_aaaa != NULL)
#define NAME_FETCH_V4(n)        (NAME_FETCH_A(n))
#define NAME_FETCH_V6(n)        (NAME_FETCH_AAAA(n))
#define NAME_FETCH(n)           (NAME_FETCH_V4(n) || NAME_FETCH_V6(n))

/*
 * Find options and tests to see if there are addresses on the list.
 */
#define FIND_WANTEVENT(fn)      (((fn)->options & DNS_ADBFIND_WANTEVENT) != 0)
#define FIND_WANTEMPTYEVENT(fn) (((fn)->options & DNS_ADBFIND_EMPTYEVENT) != 0)
#define FIND_AVOIDFETCHES(fn)   (((fn)->options & DNS_ADBFIND_AVOIDFETCHES) \
				 != 0)
#define FIND_STARTATZONE(fn)    (((fn)->options & DNS_ADBFIND_STARTATZONE) \
				 != 0)
#define FIND_HINTOK(fn)         (((fn)->options & DNS_ADBFIND_HINTOK) != 0)
#define FIND_GLUEOK(fn)         (((fn)->options & DNS_ADBFIND_GLUEOK) != 0)
#define FIND_HAS_ADDRS(fn)      (!ISC_LIST_EMPTY((fn)->list))
#define FIND_RETURNLAME(fn)     (((fn)->options & DNS_ADBFIND_RETURNLAME) != 0)

/*
 * These are currently used on simple unsigned ints, so they are
 * not really associated with any particular type.
 */
#define WANT_INET(x)            (((x) & DNS_ADBFIND_INET) != 0)
#define WANT_INET6(x)           (((x) & DNS_ADBFIND_INET6) != 0)

#define EXPIRE_OK(exp, now)     ((exp == INT_MAX) || (exp < now))

/*
 * Find out if the flags on a name (nf) indicate if it is a hint or
 * glue, and compare this to the appropriate bits set in o, to see if
 * this is ok.
 */
#define GLUE_OK(nf, o) (!NAME_GLUEOK(nf) || (((o) & DNS_ADBFIND_GLUEOK) != 0))
#define HINT_OK(nf, o) (!NAME_HINTOK(nf) || (((o) & DNS_ADBFIND_HINTOK) != 0))
#define GLUEHINT_OK(nf, o) (GLUE_OK(nf, o) || HINT_OK(nf, o))
#define STARTATZONE_MATCHES(nf, o) (((nf)->flags & NAME_STARTATZONE) == \
				    ((o) & DNS_ADBFIND_STARTATZONE))

#define ENTER_LEVEL             ISC_LOG_DEBUG(50)
#define EXIT_LEVEL              ENTER_LEVEL
#define CLEAN_LEVEL             ISC_LOG_DEBUG(100)
#define DEF_LEVEL               ISC_LOG_DEBUG(5)
#define NCACHE_LEVEL            ISC_LOG_DEBUG(20)

#define NCACHE_RESULT(r)        ((r) == DNS_R_NCACHENXDOMAIN || \
				 (r) == DNS_R_NCACHENXRRSET)
#define AUTH_NX(r)              ((r) == DNS_R_NXDOMAIN || \
				 (r) == DNS_R_NXRRSET)
#define NXDOMAIN_RESULT(r)      ((r) == DNS_R_NXDOMAIN || \
				 (r) == DNS_R_NCACHENXDOMAIN)
#define NXRRSET_RESULT(r)       ((r) == DNS_R_NCACHENXRRSET || \
				 (r) == DNS_R_NXRRSET || \
				 (r) == DNS_R_HINTNXRRSET)

/*
 * Error state rankings.
 */

#define FIND_ERR_SUCCESS                0  /* highest rank */
#define FIND_ERR_CANCELED               1
#define FIND_ERR_FAILURE                2
#define FIND_ERR_NXDOMAIN               3
#define FIND_ERR_NXRRSET                4
#define FIND_ERR_UNEXPECTED             5
#define FIND_ERR_NOTFOUND               6
#define FIND_ERR_MAX                    7

static const char *errnames[] = {
	"success",
	"canceled",
	"failure",
	"nxdomain",
	"nxrrset",
	"unexpected",
	"not_found"
};

#define NEWERR(old, new)        (ISC_MIN((old), (new)))

static isc_result_t find_err_map[FIND_ERR_MAX] = {
	ISC_R_SUCCESS,
	ISC_R_CANCELED,
	ISC_R_FAILURE,
	DNS_R_NXDOMAIN,
	DNS_R_NXRRSET,
	ISC_R_UNEXPECTED,
	ISC_R_NOTFOUND          /* not YET found */
};

static void
DP(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);

static void
DP(int level, const char *format, ...) {
	va_list args;

	va_start(args, format);
	isc_log_vwrite(dns_lctx,
		       DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_ADB,
		       level, format, args);
	va_end(args);
}

/*%
 * Increment resolver-related statistics counters.
 */
static inline void
inc_stats(dns_adb_t *adb, isc_statscounter_t counter) {
	if (adb->view->resstats != NULL)
		isc_stats_increment(adb->view->resstats, counter);
}

static inline dns_ttl_t
ttlclamp(dns_ttl_t ttl) {
	if (ttl < ADB_CACHE_MINIMUM)
		ttl = ADB_CACHE_MINIMUM;
	if (ttl > ADB_CACHE_MAXIMUM)
		ttl = ADB_CACHE_MAXIMUM;

	return (ttl);
}

/*
 * Hashing is most efficient if the number of buckets is prime.
 * The sequence below is the closest previous primes to 2^n and
 * 1.5 * 2^n, for values of n from 10 to 28.  (The tables will
 * no longer grow beyond 2^28 entries.)
 */
static const unsigned nbuckets[] = { 1021, 1531, 2039, 3067, 4093, 6143,
				     8191, 12281, 16381, 24571, 32749,
				     49193, 65521, 98299, 131071, 199603,
				     262139, 393209, 524287, 768431, 1048573,
				     1572853, 2097143, 3145721, 4194301,
				     6291449, 8388593, 12582893, 16777213,
				     25165813, 33554393, 50331599, 67108859,
				     100663291, 134217689, 201326557,
				     268535431, 0 };

static void
grow_entries(isc_task_t *task, isc_event_t *ev) {
	dns_adb_t *adb;
	dns_adbentry_t *e;
	dns_adbentrylist_t *newdeadentries = NULL;
	dns_adbentrylist_t *newentries = NULL;
	isc_boolean_t *newentry_sd = NULL;
	isc_mutex_t *newentrylocks = NULL;
	isc_result_t result;
	unsigned int *newentry_refcnt = NULL;
	unsigned int i, n, bucket;

	adb = ev->ev_arg;
	INSIST(DNS_ADB_VALID(adb));

	isc_event_free(&ev);

	result = isc_task_beginexclusive(task);
	if (result != ISC_R_SUCCESS)
		goto check_exit;

	i = 0;
	while (nbuckets[i] != 0 && adb->nentries >= nbuckets[i])
		i++;
	if (nbuckets[i] != 0)
		n = nbuckets[i];
	else
		goto done;

	DP(ISC_LOG_INFO, "adb: grow_entries to %u starting", n);

	/*
	 * Are we shutting down?
	 */
	for (i = 0; i < adb->nentries; i++)
		if (adb->entry_sd[i])
			goto cleanup;

	/*
	 * Grab all the resources we need.
	 */
	newentries = isc_mem_get(adb->mctx, sizeof(*newentries) * n);
	newdeadentries = isc_mem_get(adb->mctx, sizeof(*newdeadentries) * n);
	newentrylocks = isc_mem_get(adb->mctx, sizeof(*newentrylocks) * n);
	newentry_sd = isc_mem_get(adb->mctx, sizeof(*newentry_sd) * n);
	newentry_refcnt = isc_mem_get(adb->mctx, sizeof(*newentry_refcnt) * n);
	if (newentries == NULL || newdeadentries == NULL ||
	    newentrylocks == NULL || newentry_sd == NULL ||
	    newentry_refcnt == NULL)
		goto cleanup;

	/*
	 * Initialise the new resources.
	 */
	result = isc_mutexblock_init(newentrylocks, n);
	if (result != ISC_R_SUCCESS)
		goto cleanup;

	for (i = 0; i < n; i++) {
		ISC_LIST_INIT(newentries[i]);
		ISC_LIST_INIT(newdeadentries[i]);
		newentry_sd[i] = ISC_FALSE;
		newentry_refcnt[i] = 0;
		adb->irefcnt++;
	}

	/*
	 * Move entries to new arrays.
	 */
	for (i = 0; i < adb->nentries; i++) {
		e = ISC_LIST_HEAD(adb->entries[i]);
		while (e != NULL) {
			ISC_LIST_UNLINK(adb->entries[i], e, plink);
			bucket = isc_sockaddr_hash(&e->sockaddr, ISC_TRUE) % n;
			e->lock_bucket = bucket;
			ISC_LIST_APPEND(newentries[bucket], e, plink);
			INSIST(adb->entry_refcnt[i] > 0);
			adb->entry_refcnt[i]--;
			newentry_refcnt[bucket]++;
			e = ISC_LIST_HEAD(adb->entries[i]);
		}
		e = ISC_LIST_HEAD(adb->deadentries[i]);
		while (e != NULL) {
			ISC_LIST_UNLINK(adb->deadentries[i], e, plink);
			bucket = isc_sockaddr_hash(&e->sockaddr, ISC_TRUE) % n;
			e->lock_bucket = bucket;
			ISC_LIST_APPEND(newdeadentries[bucket], e, plink);
			INSIST(adb->entry_refcnt[i] > 0);
			adb->entry_refcnt[i]--;
			newentry_refcnt[bucket]++;
			e = ISC_LIST_HEAD(adb->deadentries[i]);
		}
		INSIST(adb->entry_refcnt[i] == 0);
		adb->irefcnt--;
	}

	/*
	 * Cleanup old resources.
	 */
	DESTROYMUTEXBLOCK(adb->entrylocks, adb->nentries);
	isc_mem_put(adb->mctx, adb->entries,
		    sizeof(*adb->entries) * adb->nentries);
	isc_mem_put(adb->mctx, adb->deadentries,
		    sizeof(*adb->deadentries) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entrylocks,
		    sizeof(*adb->entrylocks) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entry_sd,
		    sizeof(*adb->entry_sd) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entry_refcnt,
		    sizeof(*adb->entry_refcnt) * adb->nentries);

	/*
	 * Install new resources.
	 */
	adb->entries = newentries;
	adb->deadentries = newdeadentries;
	adb->entrylocks = newentrylocks;
	adb->entry_sd = newentry_sd;
	adb->entry_refcnt = newentry_refcnt;
	adb->nentries = n;

	/*
	 * Only on success do we set adb->growentries_sent to ISC_FALSE.
	 * This will prevent us being continuously being called on error.
	 */
	adb->growentries_sent = ISC_FALSE;
	goto done;

 cleanup:
	if (newentries != NULL)
		isc_mem_put(adb->mctx, newentries,
			    sizeof(*newentries) * n);
	if (newdeadentries != NULL)
		isc_mem_put(adb->mctx, newdeadentries,
			    sizeof(*newdeadentries) * n);
	if (newentrylocks != NULL)
		isc_mem_put(adb->mctx, newentrylocks,
			    sizeof(*newentrylocks) * n);
	if (newentry_sd != NULL)
		isc_mem_put(adb->mctx, newentry_sd,
			    sizeof(*newentry_sd) * n);
	if (newentry_refcnt != NULL)
		isc_mem_put(adb->mctx, newentry_refcnt,
			     sizeof(*newentry_refcnt) * n);
 done:
	isc_task_endexclusive(task);

 check_exit:
	LOCK(&adb->lock);
	if (dec_adb_irefcnt(adb))
		check_exit(adb);
	UNLOCK(&adb->lock);
	DP(ISC_LOG_INFO, "adb: grow_entries finished");
}

static void
grow_names(isc_task_t *task, isc_event_t *ev) {
	dns_adb_t *adb;
	dns_adbname_t *name;
	dns_adbnamelist_t *newdeadnames = NULL;
	dns_adbnamelist_t *newnames = NULL;
	isc_boolean_t *newname_sd = NULL;
	isc_mutex_t *newnamelocks = NULL;
	isc_result_t result;
	unsigned int *newname_refcnt = NULL;
	unsigned int i, n, bucket;

	adb = ev->ev_arg;
	INSIST(DNS_ADB_VALID(adb));

	isc_event_free(&ev);

	result = isc_task_beginexclusive(task);
	if (result != ISC_R_SUCCESS)
		goto check_exit;

	i = 0;
	while (nbuckets[i] != 0 && adb->nnames >= nbuckets[i])
		i++;
	if (nbuckets[i] != 0)
		n = nbuckets[i];
	else
		goto done;

	DP(ISC_LOG_INFO, "adb: grow_names to %u starting", n);

	/*
	 * Are we shutting down?
	 */
	for (i = 0; i < adb->nnames; i++)
		if (adb->name_sd[i])
			goto cleanup;

	/*
	 * Grab all the resources we need.
	 */
	newnames = isc_mem_get(adb->mctx, sizeof(*newnames) * n);
	newdeadnames = isc_mem_get(adb->mctx, sizeof(*newdeadnames) * n);
	newnamelocks = isc_mem_get(adb->mctx, sizeof(*newnamelocks) * n);
	newname_sd = isc_mem_get(adb->mctx, sizeof(*newname_sd) * n);
	newname_refcnt = isc_mem_get(adb->mctx, sizeof(*newname_refcnt) * n);
	if (newnames == NULL || newdeadnames == NULL ||
	    newnamelocks == NULL || newname_sd == NULL ||
	    newname_refcnt == NULL)
		goto cleanup;

	/*
	 * Initialise the new resources.
	 */
	result = isc_mutexblock_init(newnamelocks, n);
	if (result != ISC_R_SUCCESS)
		goto cleanup;

	for (i = 0; i < n; i++) {
		ISC_LIST_INIT(newnames[i]);
		ISC_LIST_INIT(newdeadnames[i]);
		newname_sd[i] = ISC_FALSE;
		newname_refcnt[i] = 0;
		adb->irefcnt++;
	}

	/*
	 * Move names to new arrays.
	 */
	for (i = 0; i < adb->nnames; i++) {
		name = ISC_LIST_HEAD(adb->names[i]);
		while (name != NULL) {
			ISC_LIST_UNLINK(adb->names[i], name, plink);
			bucket = dns_name_fullhash(&name->name, ISC_TRUE) % n;
			name->lock_bucket = bucket;
			ISC_LIST_APPEND(newnames[bucket], name, plink);
			INSIST(adb->name_refcnt[i] > 0);
			adb->name_refcnt[i]--;
			newname_refcnt[bucket]++;
			name = ISC_LIST_HEAD(adb->names[i]);
		}
		name = ISC_LIST_HEAD(adb->deadnames[i]);
		while (name != NULL) {
			ISC_LIST_UNLINK(adb->deadnames[i], name, plink);
			bucket = dns_name_fullhash(&name->name, ISC_TRUE) % n;
			name->lock_bucket = bucket;
			ISC_LIST_APPEND(newdeadnames[bucket], name, plink);
			INSIST(adb->name_refcnt[i] > 0);
			adb->name_refcnt[i]--;
			newname_refcnt[bucket]++;
			name = ISC_LIST_HEAD(adb->deadnames[i]);
		}
		INSIST(adb->name_refcnt[i] == 0);
		adb->irefcnt--;
	}

	/*
	 * Cleanup old resources.
	 */
	DESTROYMUTEXBLOCK(adb->namelocks, adb->nnames);
	isc_mem_put(adb->mctx, adb->names,
		    sizeof(*adb->names) * adb->nnames);
	isc_mem_put(adb->mctx, adb->deadnames,
		    sizeof(*adb->deadnames) * adb->nnames);
	isc_mem_put(adb->mctx, adb->namelocks,
		    sizeof(*adb->namelocks) * adb->nnames);
	isc_mem_put(adb->mctx, adb->name_sd,
		    sizeof(*adb->name_sd) * adb->nnames);
	isc_mem_put(adb->mctx, adb->name_refcnt,
		    sizeof(*adb->name_refcnt) * adb->nnames);

	/*
	 * Install new resources.
	 */
	adb->names = newnames;
	adb->deadnames = newdeadnames;
	adb->namelocks = newnamelocks;
	adb->name_sd = newname_sd;
	adb->name_refcnt = newname_refcnt;
	adb->nnames = n;

	/*
	 * Only on success do we set adb->grownames_sent to ISC_FALSE.
	 * This will prevent us being continuously being called on error.
	 */
	adb->grownames_sent = ISC_FALSE;
	goto done;

 cleanup:
	if (newnames != NULL)
		isc_mem_put(adb->mctx, newnames, sizeof(*newnames) * n);
	if (newdeadnames != NULL)
		isc_mem_put(adb->mctx, newdeadnames, sizeof(*newdeadnames) * n);
	if (newnamelocks != NULL)
		isc_mem_put(adb->mctx, newnamelocks, sizeof(*newnamelocks) * n);
	if (newname_sd != NULL)
		isc_mem_put(adb->mctx, newname_sd, sizeof(*newname_sd) * n);
	if (newname_refcnt != NULL)
		isc_mem_put(adb->mctx, newname_refcnt,
			     sizeof(*newname_refcnt) * n);
 done:
	isc_task_endexclusive(task);

 check_exit:
	LOCK(&adb->lock);
	if (dec_adb_irefcnt(adb))
		check_exit(adb);
	UNLOCK(&adb->lock);
	DP(ISC_LOG_INFO, "adb: grow_names finished");
}

/*
 * Requires the adbname bucket be locked and that no entry buckets be locked.
 *
 * This code handles A and AAAA rdatasets only.
 */
static isc_result_t
import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
		isc_stdtime_t now)
{
	isc_result_t result;
	dns_adb_t *adb;
	dns_adbnamehook_t *nh;
	dns_adbnamehook_t *anh;
	dns_rdata_t rdata = DNS_RDATA_INIT;
	struct in_addr ina;
	struct in6_addr in6a;
	isc_sockaddr_t sockaddr;
	dns_adbentry_t *foundentry;  /* NO CLEAN UP! */
	int addr_bucket;
	isc_boolean_t new_addresses_added;
	dns_rdatatype_t rdtype;
	unsigned int findoptions;
	dns_adbnamehooklist_t *hookhead;

	INSIST(DNS_ADBNAME_VALID(adbname));
	adb = adbname->adb;
	INSIST(DNS_ADB_VALID(adb));

	rdtype = rdataset->type;
	INSIST((rdtype == dns_rdatatype_a) || (rdtype == dns_rdatatype_aaaa));
	if (rdtype == dns_rdatatype_a)
		findoptions = DNS_ADBFIND_INET;
	else
		findoptions = DNS_ADBFIND_INET6;

	addr_bucket = DNS_ADB_INVALIDBUCKET;
	new_addresses_added = ISC_FALSE;

	nh = NULL;
	result = dns_rdataset_first(rdataset);
	while (result == ISC_R_SUCCESS) {
		dns_rdata_reset(&rdata);
		dns_rdataset_current(rdataset, &rdata);
		if (rdtype == dns_rdatatype_a) {
			INSIST(rdata.length == 4);
			memmove(&ina.s_addr, rdata.data, 4);
			isc_sockaddr_fromin(&sockaddr, &ina, 0);
			hookhead = &adbname->v4;
		} else {
			INSIST(rdata.length == 16);
			memmove(in6a.s6_addr, rdata.data, 16);
			isc_sockaddr_fromin6(&sockaddr, &in6a, 0);
			hookhead = &adbname->v6;
		}

		INSIST(nh == NULL);
		nh = new_adbnamehook(adb, NULL);
		if (nh == NULL) {
			adbname->partial_result |= findoptions;
			result = ISC_R_NOMEMORY;
			goto fail;
		}

		foundentry = find_entry_and_lock(adb, &sockaddr, &addr_bucket,
						 now);
		if (foundentry == NULL) {
			dns_adbentry_t *entry;

			entry = new_adbentry(adb);
			if (entry == NULL) {
				adbname->partial_result |= findoptions;
				result = ISC_R_NOMEMORY;
				goto fail;
			}

			entry->sockaddr = sockaddr;
			entry->refcnt = 1;

			nh->entry = entry;

			link_entry(adb, addr_bucket, entry);
		} else {
			for (anh = ISC_LIST_HEAD(*hookhead);
			     anh != NULL;
			     anh = ISC_LIST_NEXT(anh, plink))
				if (anh->entry == foundentry)
					break;
			if (anh == NULL) {
				foundentry->refcnt++;
				nh->entry = foundentry;
			} else
				free_adbnamehook(adb, &nh);
		}

		new_addresses_added = ISC_TRUE;
		if (nh != NULL)
			ISC_LIST_APPEND(*hookhead, nh, plink);
		nh = NULL;
		result = dns_rdataset_next(rdataset);
	}

 fail:
	if (nh != NULL)
		free_adbnamehook(adb, &nh);

	if (addr_bucket != DNS_ADB_INVALIDBUCKET)
		UNLOCK(&adb->entrylocks[addr_bucket]);

	if (rdataset->trust == dns_trust_glue ||
	    rdataset->trust == dns_trust_additional)
		rdataset->ttl = ADB_CACHE_MINIMUM;
	else if (rdataset->trust == dns_trust_ultimate)
		rdataset->ttl = 0;
	else
		rdataset->ttl = ttlclamp(rdataset->ttl);

	if (rdtype == dns_rdatatype_a) {
		DP(NCACHE_LEVEL, "expire_v4 set to MIN(%u,%u) import_rdataset",
		   adbname->expire_v4, now + rdataset->ttl);
		adbname->expire_v4 = ISC_MIN(adbname->expire_v4,
					     now + rdataset->ttl);
	} else {
		DP(NCACHE_LEVEL, "expire_v6 set to MIN(%u,%u) import_rdataset",
		   adbname->expire_v6, now + rdataset->ttl);
		adbname->expire_v6 = ISC_MIN(adbname->expire_v6,
					     now + rdataset->ttl);
	}

	if (new_addresses_added) {
		/*
		 * Lie a little here.  This is more or less so code that cares
		 * can find out if any new information was added or not.
		 */
		return (ISC_R_SUCCESS);
	}

	return (result);
}

/*
 * Requires the name's bucket be locked.
 */
static isc_boolean_t
kill_name(dns_adbname_t **n, isc_eventtype_t ev) {
	dns_adbname_t *name;
	isc_boolean_t result = ISC_FALSE;
	isc_boolean_t result4, result6;
	int bucket;
	dns_adb_t *adb;

	INSIST(n != NULL);
	name = *n;
	*n = NULL;
	INSIST(DNS_ADBNAME_VALID(name));
	adb = name->adb;
	INSIST(DNS_ADB_VALID(adb));

	DP(DEF_LEVEL, "killing name %p", name);

	/*
	 * If we're dead already, just check to see if we should go
	 * away now or not.
	 */
	if (NAME_DEAD(name) && !NAME_FETCH(name)) {
		result = unlink_name(adb, name);
		free_adbname(adb, &name);
		if (result)
			result = dec_adb_irefcnt(adb);
		return (result);
	}

	/*
	 * Clean up the name's various lists.  These two are destructive
	 * in that they will always empty the list.
	 */
	clean_finds_at_name(name, ev, DNS_ADBFIND_ADDRESSMASK);
	result4 = clean_namehooks(adb, &name->v4);
	result6 = clean_namehooks(adb, &name->v6);
	clean_target(adb, &name->target);
	result = ISC_TF(result4 || result6);

	/*
	 * If fetches are running, cancel them.  If none are running, we can
	 * just kill the name here.
	 */
	if (!NAME_FETCH(name)) {
		INSIST(result == ISC_FALSE);
		result = unlink_name(adb, name);
		free_adbname(adb, &name);
		if (result)
			result = dec_adb_irefcnt(adb);
	} else {
		cancel_fetches_at_name(name);
		if (!NAME_DEAD(name)) {
			bucket = name->lock_bucket;
			ISC_LIST_UNLINK(adb->names[bucket], name, plink);
			ISC_LIST_APPEND(adb->deadnames[bucket], name, plink);
			name->flags |= NAME_IS_DEAD;
		}
	}
	return (result);
}

/*
 * Requires the name's bucket be locked and no entry buckets be locked.
 */
static isc_boolean_t
check_expire_namehooks(dns_adbname_t *name, isc_stdtime_t now) {
	dns_adb_t *adb;
	isc_boolean_t result4 = ISC_FALSE;
	isc_boolean_t result6 = ISC_FALSE;

	INSIST(DNS_ADBNAME_VALID(name));
	adb = name->adb;
	INSIST(DNS_ADB_VALID(adb));

	/*
	 * Check to see if we need to remove the v4 addresses
	 */
	if (!NAME_FETCH_V4(name) && EXPIRE_OK(name->expire_v4, now)) {
		if (NAME_HAS_V4(name)) {
			DP(DEF_LEVEL, "expiring v4 for name %p", name);
			result4 = clean_namehooks(adb, &name->v4);
			name->partial_result &= ~DNS_ADBFIND_INET;
		}
		name->expire_v4 = INT_MAX;
		name->fetch_err = FIND_ERR_UNEXPECTED;
	}

	/*
	 * Check to see if we need to remove the v6 addresses
	 */
	if (!NAME_FETCH_V6(name) && EXPIRE_OK(name->expire_v6, now)) {
		if (NAME_HAS_V6(name)) {
			DP(DEF_LEVEL, "expiring v6 for name %p", name);
			result6 = clean_namehooks(adb, &name->v6);
			name->partial_result &= ~DNS_ADBFIND_INET6;
		}
		name->expire_v6 = INT_MAX;
		name->fetch6_err = FIND_ERR_UNEXPECTED;
	}

	/*
	 * Check to see if we need to remove the alias target.
	 */
	if (EXPIRE_OK(name->expire_target, now)) {
		clean_target(adb, &name->target);
		name->expire_target = INT_MAX;
	}
	return (ISC_TF(result4 || result6));
}

/*
 * Requires the name's bucket be locked.
 */
static inline void
link_name(dns_adb_t *adb, int bucket, dns_adbname_t *name) {
	INSIST(name->lock_bucket == DNS_ADB_INVALIDBUCKET);

	ISC_LIST_PREPEND(adb->names[bucket], name, plink);
	name->lock_bucket = bucket;
	adb->name_refcnt[bucket]++;
}

/*
 * Requires the name's bucket be locked.
 */
static inline isc_boolean_t
unlink_name(dns_adb_t *adb, dns_adbname_t *name) {
	int bucket;
	isc_boolean_t result = ISC_FALSE;

	bucket = name->lock_bucket;
	INSIST(bucket != DNS_ADB_INVALIDBUCKET);

	if (NAME_DEAD(name))
		ISC_LIST_UNLINK(adb->deadnames[bucket], name, plink);
	else
		ISC_LIST_UNLINK(adb->names[bucket], name, plink);
	name->lock_bucket = DNS_ADB_INVALIDBUCKET;
	INSIST(adb->name_refcnt[bucket] > 0);
	adb->name_refcnt[bucket]--;
	if (adb->name_sd[bucket] && adb->name_refcnt[bucket] == 0)
		result = ISC_TRUE;
	return (result);
}

/*
 * Requires the entry's bucket be locked.
 */
static inline void
link_entry(dns_adb_t *adb, int bucket, dns_adbentry_t *entry) {
	int i;
	dns_adbentry_t *e;

	if (isc_mem_isovermem(adb->mctx)) {
		for (i = 0; i < 2; i++) {
			e = ISC_LIST_TAIL(adb->entries[bucket]);
			if (e == NULL)
				break;
			if (e->refcnt == 0) {
				unlink_entry(adb, e);
				free_adbentry(adb, &e);
				continue;
			}
			INSIST((e->flags & ENTRY_IS_DEAD) == 0);
			e->flags |= ENTRY_IS_DEAD;
			ISC_LIST_UNLINK(adb->entries[bucket], e, plink);
			ISC_LIST_PREPEND(adb->deadentries[bucket], e, plink);
		}
	}

	ISC_LIST_PREPEND(adb->entries[bucket], entry, plink);
	entry->lock_bucket = bucket;
	adb->entry_refcnt[bucket]++;
}

/*
 * Requires the entry's bucket be locked.
 */
static inline isc_boolean_t
unlink_entry(dns_adb_t *adb, dns_adbentry_t *entry) {
	int bucket;
	isc_boolean_t result = ISC_FALSE;

	bucket = entry->lock_bucket;
	INSIST(bucket != DNS_ADB_INVALIDBUCKET);

	if ((entry->flags & ENTRY_IS_DEAD) != 0)
		ISC_LIST_UNLINK(adb->deadentries[bucket], entry, plink);
	else
		ISC_LIST_UNLINK(adb->entries[bucket], entry, plink);
	entry->lock_bucket = DNS_ADB_INVALIDBUCKET;
	INSIST(adb->entry_refcnt[bucket] > 0);
	adb->entry_refcnt[bucket]--;
	if (adb->entry_sd[bucket] && adb->entry_refcnt[bucket] == 0)
		result = ISC_TRUE;
	return (result);
}

static inline void
violate_locking_hierarchy(isc_mutex_t *have, isc_mutex_t *want) {
	if (isc_mutex_trylock(want) != ISC_R_SUCCESS) {
		UNLOCK(have);
		LOCK(want);
		LOCK(have);
	}
}

/*
 * The ADB _MUST_ be locked before calling.  Also, exit conditions must be
 * checked after calling this function.
 */
static isc_boolean_t
shutdown_names(dns_adb_t *adb) {
	unsigned int bucket;
	isc_boolean_t result = ISC_FALSE;
	dns_adbname_t *name;
	dns_adbname_t *next_name;

	for (bucket = 0; bucket < adb->nnames; bucket++) {
		LOCK(&adb->namelocks[bucket]);
		adb->name_sd[bucket] = ISC_TRUE;

		name = ISC_LIST_HEAD(adb->names[bucket]);
		if (name == NULL) {
			/*
			 * This bucket has no names.  We must decrement the
			 * irefcnt ourselves, since it will not be
			 * automatically triggered by a name being unlinked.
			 */
			INSIST(result == ISC_FALSE);
			result = dec_adb_irefcnt(adb);
		} else {
			/*
			 * Run through the list.  For each name, clean up finds
			 * found there, and cancel any fetches running.  When
			 * all the fetches are canceled, the name will destroy
			 * itself.
			 */
			while (name != NULL) {
				next_name = ISC_LIST_NEXT(name, plink);
				INSIST(result == ISC_FALSE);
				result = kill_name(&name,
						   DNS_EVENT_ADBSHUTDOWN);
				name = next_name;
			}
		}

		UNLOCK(&adb->namelocks[bucket]);
	}
	return (result);
}

/*
 * The ADB _MUST_ be locked before calling.  Also, exit conditions must be
 * checked after calling this function.
 */
static isc_boolean_t
shutdown_entries(dns_adb_t *adb) {
	unsigned int bucket;
	isc_boolean_t result = ISC_FALSE;
	dns_adbentry_t *entry;
	dns_adbentry_t *next_entry;

	for (bucket = 0; bucket < adb->nentries; bucket++) {
		LOCK(&adb->entrylocks[bucket]);
		adb->entry_sd[bucket] = ISC_TRUE;

		entry = ISC_LIST_HEAD(adb->entries[bucket]);
		if (adb->entry_refcnt[bucket] == 0) {
			/*
			 * This bucket has no entries.  We must decrement the
			 * irefcnt ourselves, since it will not be
			 * automatically triggered by an entry being unlinked.
			 */
			result = dec_adb_irefcnt(adb);
		} else {
			/*
			 * Run through the list.  Cleanup any entries not
			 * associated with names, and which are not in use.
			 */
			while (entry != NULL) {
				next_entry = ISC_LIST_NEXT(entry, plink);
				if (entry->refcnt == 0 &&
				    entry->expires != 0) {
					result = unlink_entry(adb, entry);
					free_adbentry(adb, &entry);
					if (result)
						result = dec_adb_irefcnt(adb);
				}
				entry = next_entry;
			}
		}

		UNLOCK(&adb->entrylocks[bucket]);
	}
	return (result);
}

/*
 * Name bucket must be locked
 */
static void
cancel_fetches_at_name(dns_adbname_t *name) {
	if (NAME_FETCH_A(name))
	    dns_resolver_cancelfetch(name->fetch_a->fetch);

	if (NAME_FETCH_AAAA(name))
	    dns_resolver_cancelfetch(name->fetch_aaaa->fetch);
}

/*
 * Assumes the name bucket is locked.
 */
static isc_boolean_t
clean_namehooks(dns_adb_t *adb, dns_adbnamehooklist_t *namehooks) {
	dns_adbentry_t *entry;
	dns_adbnamehook_t *namehook;
	int addr_bucket;
	isc_boolean_t result = ISC_FALSE;
	isc_boolean_t overmem = isc_mem_isovermem(adb->mctx);

	addr_bucket = DNS_ADB_INVALIDBUCKET;
	namehook = ISC_LIST_HEAD(*namehooks);
	while (namehook != NULL) {
		INSIST(DNS_ADBNAMEHOOK_VALID(namehook));

		/*
		 * Clean up the entry if needed.
		 */
		entry = namehook->entry;
		if (entry != NULL) {
			INSIST(DNS_ADBENTRY_VALID(entry));

			if (addr_bucket != entry->lock_bucket) {
				if (addr_bucket != DNS_ADB_INVALIDBUCKET)
					UNLOCK(&adb->entrylocks[addr_bucket]);
				addr_bucket = entry->lock_bucket;
				INSIST(addr_bucket != DNS_ADB_INVALIDBUCKET);
				LOCK(&adb->entrylocks[addr_bucket]);
			}

			result = dec_entry_refcnt(adb, overmem, entry,
						  ISC_FALSE);
		}

		/*
		 * Free the namehook
		 */
		namehook->entry = NULL;
		ISC_LIST_UNLINK(*namehooks, namehook, plink);
		free_adbnamehook(adb, &namehook);

		namehook = ISC_LIST_HEAD(*namehooks);
	}

	if (addr_bucket != DNS_ADB_INVALIDBUCKET)
		UNLOCK(&adb->entrylocks[addr_bucket]);
	return (result);
}

static void
clean_target(dns_adb_t *adb, dns_name_t *target) {
	if (dns_name_countlabels(target) > 0) {
		dns_name_free(target, adb->mctx);
		dns_name_init(target, NULL);
	}
}

static isc_result_t
set_target(dns_adb_t *adb, dns_name_t *name, dns_name_t *fname,
	   dns_rdataset_t *rdataset, dns_name_t *target)
{
	isc_result_t result;
	dns_namereln_t namereln;
	unsigned int nlabels;
	int order;
	dns_rdata_t rdata = DNS_RDATA_INIT;
	dns_fixedname_t fixed1, fixed2;
	dns_name_t *prefix, *new_target;

	REQUIRE(dns_name_countlabels(target) == 0);

	if (rdataset->type == dns_rdatatype_cname) {
		dns_rdata_cname_t cname;

		/*
		 * Copy the CNAME's target into the target name.
		 */
		result = dns_rdataset_first(rdataset);
		if (result != ISC_R_SUCCESS)
			return (result);
		dns_rdataset_current(rdataset, &rdata);
		result = dns_rdata_tostruct(&rdata, &cname, NULL);
		if (result != ISC_R_SUCCESS)
			return (result);
		result = dns_name_dup(&cname.cname, adb->mctx, target);
		dns_rdata_freestruct(&cname);
		if (result != ISC_R_SUCCESS)
			return (result);
	} else {
		dns_rdata_dname_t dname;

		INSIST(rdataset->type == dns_rdatatype_dname);
		namereln = dns_name_fullcompare(name, fname, &order, &nlabels);
		INSIST(namereln == dns_namereln_subdomain);
		/*
		 * Get the target name of the DNAME.
		 */
		result = dns_rdataset_first(rdataset);
		if (result != ISC_R_SUCCESS)
			return (result);
		dns_rdataset_current(rdataset, &rdata);
		result = dns_rdata_tostruct(&rdata, &dname, NULL);
		if (result != ISC_R_SUCCESS)
			return (result);
		/*
		 * Construct the new target name.
		 */
		dns_fixedname_init(&fixed1);
		prefix = dns_fixedname_name(&fixed1);
		dns_fixedname_init(&fixed2);
		new_target = dns_fixedname_name(&fixed2);
		dns_name_split(name, nlabels, prefix, NULL);
		result = dns_name_concatenate(prefix, &dname.dname, new_target,
					      NULL);
		dns_rdata_freestruct(&dname);
		if (result != ISC_R_SUCCESS)
			return (result);
		result = dns_name_dup(new_target, adb->mctx, target);
		if (result != ISC_R_SUCCESS)
			return (result);
	}

	return (ISC_R_SUCCESS);
}

/*
 * Assumes nothing is locked, since this is called by the client.
 */
static void
event_free(isc_event_t *event) {
	dns_adbfind_t *find;

	INSIST(event != NULL);
	find = event->ev_destroy_arg;
	INSIST(DNS_ADBFIND_VALID(find));

	LOCK(&find->lock);
	find->flags |= FIND_EVENT_FREED;
	event->ev_destroy_arg = NULL;
	UNLOCK(&find->lock);
}

/*
 * Assumes the name bucket is locked.
 */
static void
clean_finds_at_name(dns_adbname_t *name, isc_eventtype_t evtype,
		    unsigned int addrs)
{
	isc_event_t *ev;
	isc_task_t *task;
	dns_adbfind_t *find;
	dns_adbfind_t *next_find;
	isc_boolean_t process;
	unsigned int wanted, notify;

	DP(ENTER_LEVEL,
	   "ENTER clean_finds_at_name, name %p, evtype %08x, addrs %08x",
	   name, evtype, addrs);

	find = ISC_LIST_HEAD(name->finds);
	while (find != NULL) {
		LOCK(&find->lock);
		next_find = ISC_LIST_NEXT(find, plink);

		process = ISC_FALSE;
		wanted = find->flags & DNS_ADBFIND_ADDRESSMASK;
		notify = wanted & addrs;

		switch (evtype) {
		case DNS_EVENT_ADBMOREADDRESSES:
			DP(ISC_LOG_DEBUG(3), "DNS_EVENT_ADBMOREADDRESSES");
			if ((notify) != 0) {
				find->flags &= ~addrs;
				process = ISC_TRUE;
			}
			break;
		case DNS_EVENT_ADBNOMOREADDRESSES:
			DP(ISC_LOG_DEBUG(3), "DNS_EVENT_ADBNOMOREADDRESSES");
			find->flags &= ~addrs;
			wanted = find->flags & DNS_ADBFIND_ADDRESSMASK;
			if (wanted == 0)
				process = ISC_TRUE;
			break;
		default:
			find->flags &= ~addrs;
			process = ISC_TRUE;
		}

		if (process) {
			DP(DEF_LEVEL, "cfan: processing find %p", find);
			/*
			 * Unlink the find from the name, letting the caller
			 * call dns_adb_destroyfind() on it to clean it up
			 * later.
			 */
			ISC_LIST_UNLINK(name->finds, find, plink);
			find->adbname = NULL;
			find->name_bucket = DNS_ADB_INVALIDBUCKET;

			INSIST(!FIND_EVENTSENT(find));

			ev = &find->event;
			task = ev->ev_sender;
			ev->ev_sender = find;
			find->result_v4 = find_err_map[name->fetch_err];
			find->result_v6 = find_err_map[name->fetch6_err];
			ev->ev_type = evtype;
			ev->ev_destroy = event_free;
			ev->ev_destroy_arg = find;

			DP(DEF_LEVEL,
			   "sending event %p to task %p for find %p",
			   ev, task, find);

			isc_task_sendanddetach(&task, (isc_event_t **)&ev);
		} else {
			DP(DEF_LEVEL, "cfan: skipping find %p", find);
		}

		UNLOCK(&find->lock);
		find = next_find;
	}

	DP(ENTER_LEVEL, "EXIT clean_finds_at_name, name %p", name);
}

static inline void
check_exit(dns_adb_t *adb) {
	isc_event_t *event;
	/*
	 * The caller must be holding the adb lock.
	 */
	if (adb->shutting_down) {
		/*
		 * If there aren't any external references either, we're
		 * done.  Send the control event to initiate shutdown.
		 */
		INSIST(!adb->cevent_out);      /* Sanity check. */
		ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent), 0, NULL,
			       DNS_EVENT_ADBCONTROL, shutdown_task, adb,
			       adb, NULL, NULL);
		event = &adb->cevent;
		isc_task_send(adb->task, &event);
		adb->cevent_out = ISC_TRUE;
	}
}

static inline isc_boolean_t
dec_adb_irefcnt(dns_adb_t *adb) {
	isc_event_t *event;
	isc_task_t *etask;
	isc_boolean_t result = ISC_FALSE;

	LOCK(&adb->reflock);

	INSIST(adb->irefcnt > 0);
	adb->irefcnt--;

	if (adb->irefcnt == 0) {
		event = ISC_LIST_HEAD(adb->whenshutdown);
		while (event != NULL) {
			ISC_LIST_UNLINK(adb->whenshutdown, event, ev_link);
			etask = event->ev_sender;
			event->ev_sender = adb;
			isc_task_sendanddetach(&etask, &event);
			event = ISC_LIST_HEAD(adb->whenshutdown);
		}
	}

	if (adb->irefcnt == 0 && adb->erefcnt == 0)
		result = ISC_TRUE;
	UNLOCK(&adb->reflock);
	return (result);
}

static inline void
inc_adb_irefcnt(dns_adb_t *adb) {
	LOCK(&adb->reflock);
	adb->irefcnt++;
	UNLOCK(&adb->reflock);
}

static inline void
inc_adb_erefcnt(dns_adb_t *adb) {
	LOCK(&adb->reflock);
	adb->erefcnt++;
	UNLOCK(&adb->reflock);
}

static inline void
inc_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock) {
	int bucket;

	bucket = entry->lock_bucket;

	if (lock)
		LOCK(&adb->entrylocks[bucket]);

	entry->refcnt++;

	if (lock)
		UNLOCK(&adb->entrylocks[bucket]);
}

static inline isc_boolean_t
dec_entry_refcnt(dns_adb_t *adb, isc_boolean_t overmem, dns_adbentry_t *entry,
		 isc_boolean_t lock)
{
	int bucket;
	isc_boolean_t destroy_entry;
	isc_boolean_t result = ISC_FALSE;

	bucket = entry->lock_bucket;

	if (lock)
		LOCK(&adb->entrylocks[bucket]);

	INSIST(entry->refcnt > 0);
	entry->refcnt--;

	destroy_entry = ISC_FALSE;
	if (entry->refcnt == 0 &&
	    (adb->entry_sd[bucket] || entry->expires == 0 || overmem ||
	     (entry->flags & ENTRY_IS_DEAD) != 0)) {
		destroy_entry = ISC_TRUE;
		result = unlink_entry(adb, entry);
	}

	if (lock)
		UNLOCK(&adb->entrylocks[bucket]);

	if (!destroy_entry)
		return (result);

	entry->lock_bucket = DNS_ADB_INVALIDBUCKET;

	free_adbentry(adb, &entry);
	if (result)
		result = dec_adb_irefcnt(adb);

	return (result);
}

static inline dns_adbname_t *
new_adbname(dns_adb_t *adb, dns_name_t *dnsname) {
	dns_adbname_t *name;

	name = isc_mempool_get(adb->nmp);
	if (name == NULL)
		return (NULL);

	dns_name_init(&name->name, NULL);
	if (dns_name_dup(dnsname, adb->mctx, &name->name) != ISC_R_SUCCESS) {
		isc_mempool_put(adb->nmp, name);
		return (NULL);
	}
	dns_name_init(&name->target, NULL);
	name->magic = DNS_ADBNAME_MAGIC;
	name->adb = adb;
	name->partial_result = 0;
	name->flags = 0;
	name->expire_v4 = INT_MAX;
	name->expire_v6 = INT_MAX;
	name->expire_target = INT_MAX;
	name->chains = 0;
	name->lock_bucket = DNS_ADB_INVALIDBUCKET;
	ISC_LIST_INIT(name->v4);
	ISC_LIST_INIT(name->v6);
	name->fetch_a = NULL;
	name->fetch_aaaa = NULL;
	name->fetch_err = FIND_ERR_UNEXPECTED;
	name->fetch6_err = FIND_ERR_UNEXPECTED;
	ISC_LIST_INIT(name->finds);
	ISC_LINK_INIT(name, plink);

	LOCK(&adb->namescntlock);
	adb->namescnt++;
	if (!adb->grownames_sent && adb->excl != NULL &&
	    adb->namescnt > (adb->nnames * 8))
	{
		isc_event_t *event = &adb->grownames;
		inc_adb_irefcnt(adb);
		isc_task_send(adb->excl, &event);
		adb->grownames_sent = ISC_TRUE;
	}
	UNLOCK(&adb->namescntlock);

	return (name);
}

static inline void
free_adbname(dns_adb_t *adb, dns_adbname_t **name) {
	dns_adbname_t *n;

	INSIST(name != NULL && DNS_ADBNAME_VALID(*name));
	n = *name;
	*name = NULL;

	INSIST(!NAME_HAS_V4(n));
	INSIST(!NAME_HAS_V6(n));
	INSIST(!NAME_FETCH(n));
	INSIST(ISC_LIST_EMPTY(n->finds));
	INSIST(!ISC_LINK_LINKED(n, plink));
	INSIST(n->lock_bucket == DNS_ADB_INVALIDBUCKET);
	INSIST(n->adb == adb);

	n->magic = 0;
	dns_name_free(&n->name, adb->mctx);

	isc_mempool_put(adb->nmp, n);
	LOCK(&adb->namescntlock);
	adb->namescnt--;
	UNLOCK(&adb->namescntlock);
}

static inline dns_adbnamehook_t *
new_adbnamehook(dns_adb_t *adb, dns_adbentry_t *entry) {
	dns_adbnamehook_t *nh;

	nh = isc_mempool_get(adb->nhmp);
	if (nh == NULL)
		return (NULL);

	nh->magic = DNS_ADBNAMEHOOK_MAGIC;
	nh->entry = entry;
	ISC_LINK_INIT(nh, plink);

	return (nh);
}

static inline void
free_adbnamehook(dns_adb_t *adb, dns_adbnamehook_t **namehook) {
	dns_adbnamehook_t *nh;

	INSIST(namehook != NULL && DNS_ADBNAMEHOOK_VALID(*namehook));
	nh = *namehook;
	*namehook = NULL;

	INSIST(nh->entry == NULL);
	INSIST(!ISC_LINK_LINKED(nh, plink));

	nh->magic = 0;
	isc_mempool_put(adb->nhmp, nh);
}

static inline dns_adblameinfo_t *
new_adblameinfo(dns_adb_t *adb, dns_name_t *qname, dns_rdatatype_t qtype) {
	dns_adblameinfo_t *li;

	li = isc_mempool_get(adb->limp);
	if (li == NULL)
		return (NULL);

	dns_name_init(&li->qname, NULL);
	if (dns_name_dup(qname, adb->mctx, &li->qname) != ISC_R_SUCCESS) {
		isc_mempool_put(adb->limp, li);
		return (NULL);
	}
	li->magic = DNS_ADBLAMEINFO_MAGIC;
	li->lame_timer = 0;
	li->qtype = qtype;
	ISC_LINK_INIT(li, plink);

	return (li);
}

static inline void
free_adblameinfo(dns_adb_t *adb, dns_adblameinfo_t **lameinfo) {
	dns_adblameinfo_t *li;

	INSIST(lameinfo != NULL && DNS_ADBLAMEINFO_VALID(*lameinfo));
	li = *lameinfo;
	*lameinfo = NULL;

	INSIST(!ISC_LINK_LINKED(li, plink));

	dns_name_free(&li->qname, adb->mctx);

	li->magic = 0;

	isc_mempool_put(adb->limp, li);
}

static inline dns_adbentry_t *
new_adbentry(dns_adb_t *adb) {
	dns_adbentry_t *e;
	isc_uint32_t r;

	e = isc_mempool_get(adb->emp);
	if (e == NULL)
		return (NULL);

	e->magic = DNS_ADBENTRY_MAGIC;
	e->lock_bucket = DNS_ADB_INVALIDBUCKET;
	e->refcnt = 0;
	e->flags = 0;
	isc_random_get(&r);
	e->srtt = (r & 0x1f) + 1;
	e->lastage = 0;
	e->expires = 0;
	ISC_LIST_INIT(e->lameinfo);
	ISC_LINK_INIT(e, plink);
	LOCK(&adb->entriescntlock);
	adb->entriescnt++;
	if (!adb->growentries_sent && adb->growentries_sent &&
	    adb->entriescnt > (adb->nentries * 8))
	{
		isc_event_t *event = &adb->growentries;
		inc_adb_irefcnt(adb);
		isc_task_send(adb->task, &event);
		adb->growentries_sent = ISC_TRUE;
	}
	UNLOCK(&adb->entriescntlock);

	return (e);
}

static inline void
free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry) {
	dns_adbentry_t *e;
	dns_adblameinfo_t *li;

	INSIST(entry != NULL && DNS_ADBENTRY_VALID(*entry));
	e = *entry;
	*entry = NULL;

	INSIST(e->lock_bucket == DNS_ADB_INVALIDBUCKET);
	INSIST(e->refcnt == 0);
	INSIST(!ISC_LINK_LINKED(e, plink));

	e->magic = 0;

	li = ISC_LIST_HEAD(e->lameinfo);
	while (li != NULL) {
		ISC_LIST_UNLINK(e->lameinfo, li, plink);
		free_adblameinfo(adb, &li);
		li = ISC_LIST_HEAD(e->lameinfo);
	}

	isc_mempool_put(adb->emp, e);
	LOCK(&adb->entriescntlock);
	adb->entriescnt--;
	UNLOCK(&adb->entriescntlock);
}

static inline dns_adbfind_t *
new_adbfind(dns_adb_t *adb) {
	dns_adbfind_t *h;
	isc_result_t result;

	h = isc_mempool_get(adb->ahmp);
	if (h == NULL)
		return (NULL);

	/*
	 * Public members.
	 */
	h->magic = 0;
	h->adb = adb;
	h->partial_result = 0;
	h->options = 0;
	h->flags = 0;
	h->result_v4 = ISC_R_UNEXPECTED;
	h->result_v6 = ISC_R_UNEXPECTED;
	ISC_LINK_INIT(h, publink);
	ISC_LINK_INIT(h, plink);
	ISC_LIST_INIT(h->list);
	h->adbname = NULL;
	h->name_bucket = DNS_ADB_INVALIDBUCKET;

	/*
	 * private members
	 */
	result = isc_mutex_init(&h->lock);
	if (result != ISC_R_SUCCESS) {
		isc_mempool_put(adb->ahmp, h);
		return (NULL);
	}

	ISC_EVENT_INIT(&h->event, sizeof(isc_event_t), 0, 0, 0, NULL, NULL,
		       NULL, NULL, h);

	inc_adb_irefcnt(adb);
	h->magic = DNS_ADBFIND_MAGIC;
	return (h);
}

static inline dns_adbfetch_t *
new_adbfetch(dns_adb_t *adb) {
	dns_adbfetch_t *f;

	f = isc_mempool_get(adb->afmp);
	if (f == NULL)
		return (NULL);

	f->magic = 0;
	f->fetch = NULL;

	dns_rdataset_init(&f->rdataset);

	f->magic = DNS_ADBFETCH_MAGIC;

	return (f);
}

static inline void
free_adbfetch(dns_adb_t *adb, dns_adbfetch_t **fetch) {
	dns_adbfetch_t *f;

	INSIST(fetch != NULL && DNS_ADBFETCH_VALID(*fetch));
	f = *fetch;
	*fetch = NULL;

	f->magic = 0;

	if (dns_rdataset_isassociated(&f->rdataset))
		dns_rdataset_disassociate(&f->rdataset);

	isc_mempool_put(adb->afmp, f);
}

static inline isc_boolean_t
free_adbfind(dns_adb_t *adb, dns_adbfind_t **findp) {
	dns_adbfind_t *find;

	INSIST(findp != NULL && DNS_ADBFIND_VALID(*findp));
	find = *findp;
	*findp = NULL;

	INSIST(!FIND_HAS_ADDRS(find));
	INSIST(!ISC_LINK_LINKED(find, publink));
	INSIST(!ISC_LINK_LINKED(find, plink));
	INSIST(find->name_bucket == DNS_ADB_INVALIDBUCKET);
	INSIST(find->adbname == NULL);

	find->magic = 0;

	DESTROYLOCK(&find->lock);
	isc_mempool_put(adb->ahmp, find);
	return (dec_adb_irefcnt(adb));
}

/*
 * Copy bits from the entry into the newly allocated addrinfo.  The entry
 * must be locked, and the reference count must be bumped up by one
 * if this function returns a valid pointer.
 */
static inline dns_adbaddrinfo_t *
new_adbaddrinfo(dns_adb_t *adb, dns_adbentry_t *entry, in_port_t port) {
	dns_adbaddrinfo_t *ai;

	ai = isc_mempool_get(adb->aimp);
	if (ai == NULL)
		return (NULL);

	ai->magic = DNS_ADBADDRINFO_MAGIC;
	ai->sockaddr = entry->sockaddr;
	isc_sockaddr_setport(&ai->sockaddr, port);
	ai->srtt = entry->srtt;
	ai->flags = entry->flags;
	ai->entry = entry;
	ISC_LINK_INIT(ai, publink);

	return (ai);
}

static inline void
free_adbaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **ainfo) {
	dns_adbaddrinfo_t *ai;

	INSIST(ainfo != NULL && DNS_ADBADDRINFO_VALID(*ainfo));
	ai = *ainfo;
	*ainfo = NULL;

	INSIST(ai->entry == NULL);
	INSIST(!ISC_LINK_LINKED(ai, publink));

	ai->magic = 0;

	isc_mempool_put(adb->aimp, ai);
}

/*
 * Search for the name.  NOTE:  The bucket is kept locked on both
 * success and failure, so it must always be unlocked by the caller!
 *
 * On the first call to this function, *bucketp must be set to
 * DNS_ADB_INVALIDBUCKET.
 */
static inline dns_adbname_t *
find_name_and_lock(dns_adb_t *adb, dns_name_t *name,
		   unsigned int options, int *bucketp)
{
	dns_adbname_t *adbname;
	int bucket;

	bucket = dns_name_fullhash(name, ISC_FALSE) % adb->nnames;

	if (*bucketp == DNS_ADB_INVALIDBUCKET) {
		LOCK(&adb->namelocks[bucket]);
		*bucketp = bucket;
	} else if (*bucketp != bucket) {
		UNLOCK(&adb->namelocks[*bucketp]);
		LOCK(&adb->namelocks[bucket]);
		*bucketp = bucket;
	}

	adbname = ISC_LIST_HEAD(adb->names[bucket]);
	while (adbname != NULL) {
		if (!NAME_DEAD(adbname)) {
			if (dns_name_equal(name, &adbname->name)
			    && GLUEHINT_OK(adbname, options)
			    && STARTATZONE_MATCHES(adbname, options))
				return (adbname);
		}
		adbname = ISC_LIST_NEXT(adbname, plink);
	}

	return (NULL);
}

/*
 * Search for the address.  NOTE:  The bucket is kept locked on both
 * success and failure, so it must always be unlocked by the caller.
 *
 * On the first call to this function, *bucketp must be set to
 * DNS_ADB_INVALIDBUCKET.  This will cause a lock to occur.  On
 * later calls (within the same "lock path") it can be left alone, so
 * if this function is called multiple times locking is only done if
 * the bucket changes.
 */
static inline dns_adbentry_t *
find_entry_and_lock(dns_adb_t *adb, isc_sockaddr_t *addr, int *bucketp,
	isc_stdtime_t now)
{
	dns_adbentry_t *entry, *entry_next;
	int bucket;

	bucket = isc_sockaddr_hash(addr, ISC_TRUE) % adb->nentries;

	if (*bucketp == DNS_ADB_INVALIDBUCKET) {
		LOCK(&adb->entrylocks[bucket]);
		*bucketp = bucket;
	} else if (*bucketp != bucket) {
		UNLOCK(&adb->entrylocks[*bucketp]);
		LOCK(&adb->entrylocks[bucket]);
		*bucketp = bucket;
	}

	/* Search the list, while cleaning up expired entries. */
	for (entry = ISC_LIST_HEAD(adb->entries[bucket]);
	     entry != NULL;
	     entry = entry_next) {
		entry_next = ISC_LIST_NEXT(entry, plink);
		(void)check_expire_entry(adb, &entry, now);
		if (entry != NULL &&
		    isc_sockaddr_equal(addr, &entry->sockaddr)) {
			ISC_LIST_UNLINK(adb->entries[bucket], entry, plink);
			ISC_LIST_PREPEND(adb->entries[bucket], entry, plink);
			return (entry);
		}
	}

	return (NULL);
}

/*
 * Entry bucket MUST be locked!
 */
static isc_boolean_t
entry_is_lame(dns_adb_t *adb, dns_adbentry_t *entry, dns_name_t *qname,
	      dns_rdatatype_t qtype, isc_stdtime_t now)
{
	dns_adblameinfo_t *li, *next_li;
	isc_boolean_t is_bad;

	is_bad = ISC_FALSE;

	li = ISC_LIST_HEAD(entry->lameinfo);
	if (li == NULL)
		return (ISC_FALSE);
	while (li != NULL) {
		next_li = ISC_LIST_NEXT(li, plink);

		/*
		 * Has the entry expired?
		 */
		if (li->lame_timer < now) {
			ISC_LIST_UNLINK(entry->lameinfo, li, plink);
			free_adblameinfo(adb, &li);
		}

		/*
		 * Order tests from least to most expensive.
		 *
		 * We do not break out of the main loop here as
		 * we use the loop for house keeping.
		 */
		if (li != NULL && !is_bad && li->qtype == qtype &&
		    dns_name_equal(qname, &li->qname))
			is_bad = ISC_TRUE;

		li = next_li;
	}

	return (is_bad);
}

static void
copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname,
		    dns_rdatatype_t qtype, dns_adbname_t *name,
		    isc_stdtime_t now)
{
	dns_adbnamehook_t *namehook;
	dns_adbaddrinfo_t *addrinfo;
	dns_adbentry_t *entry;
	int bucket;

	bucket = DNS_ADB_INVALIDBUCKET;

	if (find->options & DNS_ADBFIND_INET) {
		namehook = ISC_LIST_HEAD(name->v4);
		while (namehook != NULL) {
			entry = namehook->entry;
			bucket = entry->lock_bucket;
			INSIST(bucket != DNS_ADB_INVALIDBUCKET);
			LOCK(&adb->entrylocks[bucket]);

			if (!FIND_RETURNLAME(find)
			    && entry_is_lame(adb, entry, qname, qtype, now)) {
				find->options |= DNS_ADBFIND_LAMEPRUNED;
				goto nextv4;
			}
			addrinfo = new_adbaddrinfo(adb, entry, find->port);
			if (addrinfo == NULL) {
				find->partial_result |= DNS_ADBFIND_INET;
				goto out;
			}
			/*
			 * Found a valid entry.  Add it to the find's list.
			 */
			inc_entry_refcnt(adb, entry, ISC_FALSE);
			ISC_LIST_APPEND(find->list, addrinfo, publink);
			addrinfo = NULL;
		nextv4:
			UNLOCK(&adb->entrylocks[bucket]);
			bucket = DNS_ADB_INVALIDBUCKET;
			namehook = ISC_LIST_NEXT(namehook, plink);
		}
	}

	if (find->options & DNS_ADBFIND_INET6) {
		namehook = ISC_LIST_HEAD(name->v6);
		while (namehook != NULL) {
			entry = namehook->entry;
			bucket = entry->lock_bucket;
			INSIST(bucket != DNS_ADB_INVALIDBUCKET);
			LOCK(&adb->entrylocks[bucket]);

			if (!FIND_RETURNLAME(find)
			    && entry_is_lame(adb, entry, qname, qtype, now)) {
				find->options |= DNS_ADBFIND_LAMEPRUNED;
				goto nextv6;
			}
			addrinfo = new_adbaddrinfo(adb, entry, find->port);
			if (addrinfo == NULL) {
				find->partial_result |= DNS_ADBFIND_INET6;
				goto out;
			}
			/*
			 * Found a valid entry.  Add it to the find's list.
			 */
			inc_entry_refcnt(adb, entry, ISC_FALSE);
			ISC_LIST_APPEND(find->list, addrinfo, publink);
			addrinfo = NULL;
		nextv6:
			UNLOCK(&adb->entrylocks[bucket]);
			bucket = DNS_ADB_INVALIDBUCKET;
			namehook = ISC_LIST_NEXT(namehook, plink);
		}
	}

 out:
	if (bucket != DNS_ADB_INVALIDBUCKET)
		UNLOCK(&adb->entrylocks[bucket]);
}

static void
shutdown_task(isc_task_t *task, isc_event_t *ev) {
	dns_adb_t *adb;

	UNUSED(task);

	adb = ev->ev_arg;
	INSIST(DNS_ADB_VALID(adb));

	isc_event_free(&ev);
	/*
	 * Wait for lock around check_exit() call to be released.
	 */
	LOCK(&adb->lock);
	UNLOCK(&adb->lock);
	destroy(adb);
}

/*
 * Name bucket must be locked; adb may be locked; no other locks held.
 */
static isc_boolean_t
check_expire_name(dns_adbname_t **namep, isc_stdtime_t now) {
	dns_adbname_t *name;
	isc_boolean_t result = ISC_FALSE;

	INSIST(namep != NULL && DNS_ADBNAME_VALID(*namep));
	name = *namep;

	if (NAME_HAS_V4(name) || NAME_HAS_V6(name))
		return (result);
	if (NAME_FETCH(name))
		return (result);
	if (!EXPIRE_OK(name->expire_v4, now))
		return (result);
	if (!EXPIRE_OK(name->expire_v6, now))
		return (result);
	if (!EXPIRE_OK(name->expire_target, now))
		return (result);

	/*
	 * The name is empty.  Delete it.
	 */
	result = kill_name(&name, DNS_EVENT_ADBEXPIRED);
	*namep = NULL;

	/*
	 * Our caller, or one of its callers, will be calling check_exit() at
	 * some point, so we don't need to do it here.
	 */
	return (result);
}

/*%
 * Examine the tail entry of the LRU list to see if it expires or is stale
 * (unused for some period); if so, the name entry will be freed.  If the ADB
 * is in the overmem condition, the tail and the next to tail entries
 * will be unconditionally removed (unless they have an outstanding fetch).
 * We don't care about a race on 'overmem' at the risk of causing some
 * collateral damage or a small delay in starting cleanup, so we don't bother
 * to lock ADB (if it's not locked).
 *
 * Name bucket must be locked; adb may be locked; no other locks held.
 */
static void
check_stale_name(dns_adb_t *adb, int bucket, isc_stdtime_t now) {
	int victims, max_victims;
	dns_adbname_t *victim, *next_victim;
	isc_boolean_t overmem = isc_mem_isovermem(adb->mctx);
	int scans = 0;

	INSIST(bucket != DNS_ADB_INVALIDBUCKET);

	max_victims = overmem ? 2 : 1;

	/*
	 * We limit the number of scanned entries to 10 (arbitrary choice)
	 * in order to avoid examining too many entries when there are many
	 * tail entries that have fetches (this should be rare, but could
	 * happen).
	 */
	victim = ISC_LIST_TAIL(adb->names[bucket]);
	for (victims = 0;
	     victim != NULL && victims < max_victims && scans < 10;
	     victim = next_victim) {
		INSIST(!NAME_DEAD(victim));
		scans++;
		next_victim = ISC_LIST_PREV(victim, plink);
		(void)check_expire_name(&victim, now);
		if (victim == NULL) {
			victims++;
			goto next;
		}

		if (!NAME_FETCH(victim) &&
		    (overmem || victim->last_used + ADB_STALE_MARGIN <= now)) {
			RUNTIME_CHECK(kill_name(&victim,
						DNS_EVENT_ADBCANCELED) ==
				      ISC_FALSE);
			victims++;
		}

	next:
		if (!overmem)
			break;
	}
}

/*
 * Entry bucket must be locked; adb may be locked; no other locks held.
 */
static isc_boolean_t
check_expire_entry(dns_adb_t *adb, dns_adbentry_t **entryp, isc_stdtime_t now)
{
	dns_adbentry_t *entry;
	isc_boolean_t result = ISC_FALSE;

	INSIST(entryp != NULL && DNS_ADBENTRY_VALID(*entryp));
	entry = *entryp;

	if (entry->refcnt != 0)
		return (result);

	if (entry->expires == 0 || entry->expires > now)
		return (result);

	/*
	 * The entry is not in use.  Delete it.
	 */
	DP(DEF_LEVEL, "killing entry %p", entry);
	INSIST(ISC_LINK_LINKED(entry, plink));
	result = unlink_entry(adb, entry);
	free_adbentry(adb, &entry);
	if (result)
		dec_adb_irefcnt(adb);
	*entryp = NULL;
	return (result);
}

/*
 * ADB must be locked, and no other locks held.
 */
static isc_boolean_t
cleanup_names(dns_adb_t *adb, int bucket, isc_stdtime_t now) {
	dns_adbname_t *name;
	dns_adbname_t *next_name;
	isc_boolean_t result = ISC_FALSE;

	DP(CLEAN_LEVEL, "cleaning name bucket %d", bucket);

	LOCK(&adb->namelocks[bucket]);
	if (adb->name_sd[bucket]) {
		UNLOCK(&adb->namelocks[bucket]);
		return (result);
	}

	name = ISC_LIST_HEAD(adb->names[bucket]);
	while (name != NULL) {
		next_name = ISC_LIST_NEXT(name, plink);
		INSIST(result == ISC_FALSE);
		result = check_expire_namehooks(name, now);
		if (!result)
			result = check_expire_name(&name, now);
		name = next_name;
	}
	UNLOCK(&adb->namelocks[bucket]);
	return (result);
}

/*
 * ADB must be locked, and no other locks held.
 */
static isc_boolean_t
cleanup_entries(dns_adb_t *adb, int bucket, isc_stdtime_t now) {
	dns_adbentry_t *entry, *next_entry;
	isc_boolean_t result = ISC_FALSE;

	DP(CLEAN_LEVEL, "cleaning entry bucket %d", bucket);

	LOCK(&adb->entrylocks[bucket]);
	entry = ISC_LIST_HEAD(adb->entries[bucket]);
	while (entry != NULL) {
		next_entry = ISC_LIST_NEXT(entry, plink);
		INSIST(result == ISC_FALSE);
		result = check_expire_entry(adb, &entry, now);
		entry = next_entry;
	}
	UNLOCK(&adb->entrylocks[bucket]);
	return (result);
}

static void
destroy(dns_adb_t *adb) {
	adb->magic = 0;

	isc_task_detach(&adb->task);
	if (adb->excl != NULL)
	isc_task_detach(&adb->excl);

	isc_mempool_destroy(&adb->nmp);
	isc_mempool_destroy(&adb->nhmp);
	isc_mempool_destroy(&adb->limp);
	isc_mempool_destroy(&adb->emp);
	isc_mempool_destroy(&adb->ahmp);
	isc_mempool_destroy(&adb->aimp);
	isc_mempool_destroy(&adb->afmp);

	DESTROYMUTEXBLOCK(adb->entrylocks, adb->nentries);
	isc_mem_put(adb->mctx, adb->entries,
		    sizeof(*adb->entries) * adb->nentries);
	isc_mem_put(adb->mctx, adb->deadentries,
		    sizeof(*adb->deadentries) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entrylocks,
		    sizeof(*adb->entrylocks) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entry_sd,
		    sizeof(*adb->entry_sd) * adb->nentries);
	isc_mem_put(adb->mctx, adb->entry_refcnt,
		    sizeof(*adb->entry_refcnt) * adb->nentries);

	DESTROYMUTEXBLOCK(adb->namelocks, adb->nnames);
	isc_mem_put(adb->mctx, adb->names,
		    sizeof(*adb->names) * adb->nnames);
	isc_mem_put(adb->mctx, adb->deadnames,
		    sizeof(*adb->deadnames) * adb->nnames);
	isc_mem_put(adb->mctx, adb->namelocks,
		    sizeof(*adb->namelocks) * adb->nnames);
	isc_mem_put(adb->mctx, adb->name_sd,
		    sizeof(*adb->name_sd) * adb->nnames);
	isc_mem_put(adb->mctx, adb->name_refcnt,
		    sizeof(*adb->name_refcnt) * adb->nnames);

	DESTROYLOCK(&adb->reflock);
	DESTROYLOCK(&adb->lock);
	DESTROYLOCK(&adb->mplock);
	DESTROYLOCK(&adb->overmemlock);
	DESTROYLOCK(&adb->entriescntlock);
	DESTROYLOCK(&adb->namescntlock);

	isc_mem_putanddetach(&adb->mctx, adb, sizeof(dns_adb_t));
}


/*
 * Public functions.
 */

isc_result_t
dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
	       isc_taskmgr_t *taskmgr, dns_adb_t **newadb)
{
	dns_adb_t *adb;
	isc_result_t result;
	unsigned int i;

	REQUIRE(mem != NULL);
	REQUIRE(view != NULL);
	REQUIRE(timermgr != NULL); /* this is actually unused */
	REQUIRE(taskmgr != NULL);
	REQUIRE(newadb != NULL && *newadb == NULL);

	UNUSED(timermgr);

	adb = isc_mem_get(mem, sizeof(dns_adb_t));
	if (adb == NULL)
		return (ISC_R_NOMEMORY);

	/*
	 * Initialize things here that cannot fail, and especially things
	 * that must be NULL for the error return to work properly.
	 */
	adb->magic = 0;
	adb->erefcnt = 1;
	adb->irefcnt = 0;
	adb->nmp = NULL;
	adb->nhmp = NULL;
	adb->limp = NULL;
	adb->emp = NULL;
	adb->ahmp = NULL;
	adb->aimp = NULL;
	adb->afmp = NULL;
	adb->task = NULL;
	adb->excl = NULL;
	adb->mctx = NULL;
	adb->view = view;
	adb->taskmgr = taskmgr;
	adb->next_cleanbucket = 0;
	ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent),
		       0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
	adb->cevent_out = ISC_FALSE;
	adb->shutting_down = ISC_FALSE;
	ISC_LIST_INIT(adb->whenshutdown);

	adb->nentries = nbuckets[0];
	adb->entriescnt = 0;
	adb->entries = NULL;
	adb->deadentries = NULL;
	adb->entry_sd = NULL;
	adb->entry_refcnt = NULL;
	adb->entrylocks = NULL;
	ISC_EVENT_INIT(&adb->growentries, sizeof(adb->growentries), 0, NULL,
		       DNS_EVENT_ADBGROWENTRIES, grow_entries, adb,
		       adb, NULL, NULL);
	adb->growentries_sent = ISC_FALSE;

	adb->nnames = nbuckets[0];
	adb->namescnt = 0;
	adb->names = NULL;
	adb->deadnames = NULL;
	adb->name_sd = NULL;
	adb->name_refcnt = NULL;
	adb->namelocks = NULL;
	ISC_EVENT_INIT(&adb->grownames, sizeof(adb->grownames), 0, NULL,
		       DNS_EVENT_ADBGROWNAMES, grow_names, adb,
		       adb, NULL, NULL);
	adb->grownames_sent = ISC_FALSE;

	result = isc_taskmgr_excltask(adb->taskmgr, &adb->excl);
	if (result != ISC_R_SUCCESS) {
		DP(ISC_LOG_INFO, "adb: task-exclusive mode unavailable, "
				 "intializing table sizes to %u\n",
				 nbuckets[11]);
		adb->nentries = nbuckets[11];
		adb->nnames= nbuckets[11];

	}

	isc_mem_attach(mem, &adb->mctx);

	result = isc_mutex_init(&adb->lock);
	if (result != ISC_R_SUCCESS)
		goto fail0b;

	result = isc_mutex_init(&adb->mplock);
	if (result != ISC_R_SUCCESS)
		goto fail0c;

	result = isc_mutex_init(&adb->reflock);
	if (result != ISC_R_SUCCESS)
		goto fail0d;

	result = isc_mutex_init(&adb->overmemlock);
	if (result != ISC_R_SUCCESS)
		goto fail0e;

	result = isc_mutex_init(&adb->entriescntlock);
	if (result != ISC_R_SUCCESS)
		goto fail0f;

	result = isc_mutex_init(&adb->namescntlock);
	if (result != ISC_R_SUCCESS)
		goto fail0g;

#define ALLOCENTRY(adb, el) \
	do { \
		(adb)->el = isc_mem_get((adb)->mctx, \
				     sizeof(*(adb)->el) * (adb)->nentries); \
		if ((adb)->el == NULL) { \
			result = ISC_R_NOMEMORY; \
			goto fail1; \
		}\
	} while (/*CONSTCOND*/0)
	ALLOCENTRY(adb, entries);
	ALLOCENTRY(adb, deadentries);
	ALLOCENTRY(adb, entrylocks);
	ALLOCENTRY(adb, entry_sd);
	ALLOCENTRY(adb, entry_refcnt);
#undef ALLOCENTRY

#define ALLOCNAME(adb, el) \
	do { \
		(adb)->el = isc_mem_get((adb)->mctx, \
				     sizeof(*(adb)->el) * (adb)->nnames); \
		if ((adb)->el == NULL) { \
			result = ISC_R_NOMEMORY; \
			goto fail1; \
		}\
	} while (/*CONSTCOND*/0)
	ALLOCNAME(adb, names);
	ALLOCNAME(adb, deadnames);
	ALLOCNAME(adb, namelocks);
	ALLOCNAME(adb, name_sd);
	ALLOCNAME(adb, name_refcnt);
#undef ALLOCNAME

	/*
	 * Initialize the bucket locks for names and elements.
	 * May as well initialize the list heads, too.
	 */
	result = isc_mutexblock_init(adb->namelocks, adb->nnames);
	if (result != ISC_R_SUCCESS)
		goto fail1;
	for (i = 0; i < adb->nnames; i++) {
		ISC_LIST_INIT(adb->names[i]);
		ISC_LIST_INIT(adb->deadnames[i]);
		adb->name_sd[i] = ISC_FALSE;
		adb->name_refcnt[i] = 0;
		adb->irefcnt++;
	}
	for (i = 0; i < adb->nentries; i++) {
		ISC_LIST_INIT(adb->entries[i]);
		ISC_LIST_INIT(adb->deadentries[i]);
		adb->entry_sd[i] = ISC_FALSE;
		adb->entry_refcnt[i] = 0;
		adb->irefcnt++;
	}
	result = isc_mutexblock_init(adb->entrylocks, adb->nentries);
	if (result != ISC_R_SUCCESS)
		goto fail2;

	/*
	 * Memory pools
	 */
#define MPINIT(t, p, n) do { \
	result = isc_mempool_create(mem, sizeof(t), &(p)); \
	if (result != ISC_R_SUCCESS) \
		goto fail3; \
	isc_mempool_setfreemax((p), FREE_ITEMS); \
	isc_mempool_setfillcount((p), FILL_COUNT); \
	isc_mempool_setname((p), n); \
	isc_mempool_associatelock((p), &adb->mplock); \
} while (/*CONSTCOND*/0)

	MPINIT(dns_adbname_t, adb->nmp, "adbname");
	MPINIT(dns_adbnamehook_t, adb->nhmp, "adbnamehook");
	MPINIT(dns_adblameinfo_t, adb->limp, "adblameinfo");
	MPINIT(dns_adbentry_t, adb->emp, "adbentry");
	MPINIT(dns_adbfind_t, adb->ahmp, "adbfind");
	MPINIT(dns_adbaddrinfo_t, adb->aimp, "adbaddrinfo");
	MPINIT(dns_adbfetch_t, adb->afmp, "adbfetch");

#undef MPINIT

	/*
	 * Allocate an internal task.
	 */
	result = isc_task_create(adb->taskmgr, 0, &adb->task);
	if (result != ISC_R_SUCCESS)
		goto fail3;

	isc_task_setname(adb->task, "ADB", adb);

	/*
	 * Normal return.
	 */
	adb->magic = DNS_ADB_MAGIC;
	*newadb = adb;
	return (ISC_R_SUCCESS);

 fail3:
	if (adb->task != NULL)
		isc_task_detach(&adb->task);

	/* clean up entrylocks */
	DESTROYMUTEXBLOCK(adb->entrylocks, adb->nentries);

 fail2: /* clean up namelocks */
	DESTROYMUTEXBLOCK(adb->namelocks, adb->nnames);

 fail1: /* clean up only allocated memory */
	if (adb->entries != NULL)
		isc_mem_put(adb->mctx, adb->entries,
			    sizeof(*adb->entries) * adb->nentries);
	if (adb->deadentries != NULL)
		isc_mem_put(adb->mctx, adb->deadentries,
			    sizeof(*adb->deadentries) * adb->nentries);
	if (adb->entrylocks != NULL)
		isc_mem_put(adb->mctx, adb->entrylocks,
			    sizeof(*adb->entrylocks) * adb->nentries);
	if (adb->entry_sd != NULL)
		isc_mem_put(adb->mctx, adb->entry_sd,
			    sizeof(*adb->entry_sd) * adb->nentries);
	if (adb->entry_refcnt != NULL)
		isc_mem_put(adb->mctx, adb->entry_refcnt,
			    sizeof(*adb->entry_refcnt) * adb->nentries);
	if (adb->names != NULL)
		isc_mem_put(adb->mctx, adb->names,
			    sizeof(*adb->names) * adb->nnames);
	if (adb->deadnames != NULL)
		isc_mem_put(adb->mctx, adb->deadnames,
			    sizeof(*adb->deadnames) * adb->nnames);
	if (adb->namelocks != NULL)
		isc_mem_put(adb->mctx, adb->namelocks,
			    sizeof(*adb->namelocks) * adb->nnames);
	if (adb->name_sd != NULL)
		isc_mem_put(adb->mctx, adb->name_sd,
			    sizeof(*adb->name_sd) * adb->nnames);
	if (adb->name_refcnt != NULL)
		isc_mem_put(adb->mctx, adb->name_refcnt,
			    sizeof(*adb->name_refcnt) * adb->nnames);
	if (adb->nmp != NULL)
		isc_mempool_destroy(&adb->nmp);
	if (adb->nhmp != NULL)
		isc_mempool_destroy(&adb->nhmp);
	if (adb->limp != NULL)
		isc_mempool_destroy(&adb->limp);
	if (adb->emp != NULL)
		isc_mempool_destroy(&adb->emp);
	if (adb->ahmp != NULL)
		isc_mempool_destroy(&adb->ahmp);
	if (adb->aimp != NULL)
		isc_mempool_destroy(&adb->aimp);
	if (adb->afmp != NULL)
		isc_mempool_destroy(&adb->afmp);

	DESTROYLOCK(&adb->namescntlock);
 fail0g:
	DESTROYLOCK(&adb->entriescntlock);
 fail0f:
	DESTROYLOCK(&adb->overmemlock);
 fail0e:
	DESTROYLOCK(&adb->reflock);
 fail0d:
	DESTROYLOCK(&adb->mplock);
 fail0c:
	DESTROYLOCK(&adb->lock);
 fail0b:
	isc_mem_putanddetach(&adb->mctx, adb, sizeof(dns_adb_t));

	return (result);
}

void
dns_adb_attach(dns_adb_t *adb, dns_adb_t **adbx) {

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(adbx != NULL && *adbx == NULL);

	inc_adb_erefcnt(adb);
	*adbx = adb;
}

void
dns_adb_detach(dns_adb_t **adbx) {
	dns_adb_t *adb;
	isc_boolean_t need_exit_check;

	REQUIRE(adbx != NULL && DNS_ADB_VALID(*adbx));

	adb = *adbx;
	*adbx = NULL;

	INSIST(adb->erefcnt > 0);

	LOCK(&adb->reflock);
	adb->erefcnt--;
	need_exit_check = ISC_TF(adb->erefcnt == 0 && adb->irefcnt == 0);
	UNLOCK(&adb->reflock);

	if (need_exit_check) {
		LOCK(&adb->lock);
		INSIST(adb->shutting_down);
		check_exit(adb);
		UNLOCK(&adb->lock);
	}
}

void
dns_adb_whenshutdown(dns_adb_t *adb, isc_task_t *task, isc_event_t **eventp) {
	isc_task_t *clone;
	isc_event_t *event;
	isc_boolean_t zeroirefcnt = ISC_FALSE;

	/*
	 * Send '*eventp' to 'task' when 'adb' has shutdown.
	 */

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(eventp != NULL);

	event = *eventp;
	*eventp = NULL;

	LOCK(&adb->lock);

	LOCK(&adb->reflock);
	zeroirefcnt = ISC_TF(adb->irefcnt == 0);

	if (adb->shutting_down && zeroirefcnt &&
	    isc_mempool_getallocated(adb->ahmp) == 0) {
		/*
		 * We're already shutdown.  Send the event.
		 */
		event->ev_sender = adb;
		isc_task_send(task, &event);
	} else {
		clone = NULL;
		isc_task_attach(task, &clone);
		event->ev_sender = clone;
		ISC_LIST_APPEND(adb->whenshutdown, event, ev_link);
	}

	UNLOCK(&adb->reflock);
	UNLOCK(&adb->lock);
}

static void
shutdown_stage2(isc_task_t *task, isc_event_t *event) {
	dns_adb_t *adb;

	UNUSED(task);

	adb = event->ev_arg;
	INSIST(DNS_ADB_VALID(adb));

	LOCK(&adb->lock);
	INSIST(adb->shutting_down);
	adb->cevent_out = ISC_FALSE;
	(void)shutdown_names(adb);
	(void)shutdown_entries(adb);
	if (dec_adb_irefcnt(adb))
		check_exit(adb);
	UNLOCK(&adb->lock);
}

void
dns_adb_shutdown(dns_adb_t *adb) {
	isc_event_t *event;

	/*
	 * Shutdown 'adb'.
	 */

	LOCK(&adb->lock);

	if (!adb->shutting_down) {
		adb->shutting_down = ISC_TRUE;
		isc_mem_setwater(adb->mctx, water, adb, 0, 0);
		/*
		 * Isolate shutdown_names and shutdown_entries calls.
		 */
		inc_adb_irefcnt(adb);
		ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent), 0, NULL,
			       DNS_EVENT_ADBCONTROL, shutdown_stage2, adb,
			       adb, NULL, NULL);
		adb->cevent_out = ISC_TRUE;
		event = &adb->cevent;
		isc_task_send(adb->task, &event);
	}

	UNLOCK(&adb->lock);
}

isc_result_t
dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
		   void *arg, dns_name_t *name, dns_name_t *qname,
		   dns_rdatatype_t qtype, unsigned int options,
		   isc_stdtime_t now, dns_name_t *target,
		   in_port_t port, dns_adbfind_t **findp)
{
	return (dns_adb_createfind2(adb, task, action, arg, name,
				    qname, qtype, options, now,
				    target, port, 0, NULL, findp));
}

isc_result_t
dns_adb_createfind2(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
		    void *arg, dns_name_t *name, dns_name_t *qname,
		    dns_rdatatype_t qtype, unsigned int options,
		    isc_stdtime_t now, dns_name_t *target,
		    in_port_t port, unsigned int depth, isc_counter_t *qc,
		    dns_adbfind_t **findp)
{
	dns_adbfind_t *find;
	dns_adbname_t *adbname;
	int bucket;
	isc_boolean_t want_event, start_at_zone, alias, have_address;
	isc_result_t result;
	unsigned int wanted_addresses;
	unsigned int wanted_fetches;
	unsigned int query_pending;

	REQUIRE(DNS_ADB_VALID(adb));
	if (task != NULL) {
		REQUIRE(action != NULL);
	}
	REQUIRE(name != NULL);
	REQUIRE(qname != NULL);
	REQUIRE(findp != NULL && *findp == NULL);
	REQUIRE(target == NULL || dns_name_hasbuffer(target));

	REQUIRE((options & DNS_ADBFIND_ADDRESSMASK) != 0);

	result = ISC_R_UNEXPECTED;
	POST(result);
	wanted_addresses = (options & DNS_ADBFIND_ADDRESSMASK);
	wanted_fetches = 0;
	query_pending = 0;
	want_event = ISC_FALSE;
	start_at_zone = ISC_FALSE;
	alias = ISC_FALSE;

	if (now == 0)
		isc_stdtime_get(&now);

	/*
	 * XXXMLG  Move this comment somewhere else!
	 *
	 * Look up the name in our internal database.
	 *
	 * Possibilities:  Note that these are not always exclusive.
	 *
	 *      No name found.  In this case, allocate a new name header and
	 *      an initial namehook or two.  If any of these allocations
	 *      fail, clean up and return ISC_R_NOMEMORY.
	 *
	 *      Name found, valid addresses present.  Allocate one addrinfo
	 *      structure for each found and append it to the linked list
	 *      of addresses for this header.
	 *
	 *      Name found, queries pending.  In this case, if a task was
	 *      passed in, allocate a job id, attach it to the name's job
	 *      list and remember to tell the caller that there will be
	 *      more info coming later.
	 */

	find = new_adbfind(adb);
	if (find == NULL)
		return (ISC_R_NOMEMORY);

	find->port = port;

	/*
	 * Remember what types of addresses we are interested in.
	 */
	find->options = options;
	find->flags |= wanted_addresses;
	if (FIND_WANTEVENT(find)) {
		REQUIRE(task != NULL);
	}

	/*
	 * Try to see if we know anything about this name at all.
	 */
	bucket = DNS_ADB_INVALIDBUCKET;
	adbname = find_name_and_lock(adb, name, find->options, &bucket);
	INSIST(bucket != DNS_ADB_INVALIDBUCKET);
	if (adb->name_sd[bucket]) {
		DP(DEF_LEVEL,
		   "dns_adb_createfind: returning ISC_R_SHUTTINGDOWN");
		RUNTIME_CHECK(free_adbfind(adb, &find) == ISC_FALSE);
		result = ISC_R_SHUTTINGDOWN;
		goto out;
	}

	/*
	 * Nothing found.  Allocate a new adbname structure for this name.
	 */
	if (adbname == NULL) {
		/*
		 * See if there is any stale name at the end of list, and purge
		 * it if so.
		 */
		check_stale_name(adb, bucket, now);

		adbname = new_adbname(adb, name);
		if (adbname == NULL) {
			RUNTIME_CHECK(free_adbfind(adb, &find) == ISC_FALSE);
			result = ISC_R_NOMEMORY;
			goto out;
		}
		link_name(adb, bucket, adbname);
		if (FIND_HINTOK(find))
			adbname->flags |= NAME_HINT_OK;
		if (FIND_GLUEOK(find))
			adbname->flags |= NAME_GLUE_OK;
		if (FIND_STARTATZONE(find))
			adbname->flags |= NAME_STARTATZONE;
	} else {
		/* Move this name forward in the LRU list */
		ISC_LIST_UNLINK(adb->names[bucket], adbname, plink);
		ISC_LIST_PREPEND(adb->names[bucket], adbname, plink);
	}
	adbname->last_used = now;

	/*
	 * Expire old entries, etc.
	 */
	RUNTIME_CHECK(check_expire_namehooks(adbname, now) == ISC_FALSE);

	/*
	 * Do we know that the name is an alias?
	 */
	if (!EXPIRE_OK(adbname->expire_target, now)) {
		/*
		 * Yes, it is.
		 */
		DP(DEF_LEVEL,
		   "dns_adb_createfind: name %p is an alias (cached)",
		   adbname);
		alias = ISC_TRUE;
		goto post_copy;
	}

	/*
	 * Try to populate the name from the database and/or
	 * start fetches.  First try looking for an A record
	 * in the database.
	 */
	if (!NAME_HAS_V4(adbname) && EXPIRE_OK(adbname->expire_v4, now)
	    && WANT_INET(wanted_addresses)) {
		result = dbfind_name(adbname, now, dns_rdatatype_a);
		if (result == ISC_R_SUCCESS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: found A for name %p in db",
			   adbname);
			goto v6;
		}

		/*
		 * Did we get a CNAME or DNAME?
		 */
		if (result == DNS_R_ALIAS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: name %p is an alias",
			   adbname);
			alias = ISC_TRUE;
			goto post_copy;
		}

		/*
		 * If the name doesn't exist at all, don't bother with
		 * v6 queries; they won't work.
		 *
		 * If the name does exist but we didn't get our data, go
		 * ahead and try AAAA.
		 *
		 * If the result is neither of these, try a fetch for A.
		 */
		if (NXDOMAIN_RESULT(result))
			goto fetch;
		else if (NXRRSET_RESULT(result))
			goto v6;

		if (!NAME_FETCH_V4(adbname))
			wanted_fetches |= DNS_ADBFIND_INET;
	}

 v6:
	if (!NAME_HAS_V6(adbname) && EXPIRE_OK(adbname->expire_v6, now)
	    && WANT_INET6(wanted_addresses)) {
		result = dbfind_name(adbname, now, dns_rdatatype_aaaa);
		if (result == ISC_R_SUCCESS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: found AAAA for name %p",
			   adbname);
			goto fetch;
		}

		/*
		 * Did we get a CNAME or DNAME?
		 */
		if (result == DNS_R_ALIAS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: name %p is an alias",
			   adbname);
			alias = ISC_TRUE;
			goto post_copy;
		}

		/*
		 * Listen to negative cache hints, and don't start
		 * another query.
		 */
		if (NCACHE_RESULT(result) || AUTH_NX(result))
			goto fetch;

		if (!NAME_FETCH_V6(adbname))
			wanted_fetches |= DNS_ADBFIND_INET6;
	}

 fetch:
	if ((WANT_INET(wanted_addresses) && NAME_HAS_V4(adbname)) ||
	    (WANT_INET6(wanted_addresses) && NAME_HAS_V6(adbname)))
		have_address = ISC_TRUE;
	else
		have_address = ISC_FALSE;
	if (wanted_fetches != 0 &&
	    ! (FIND_AVOIDFETCHES(find) && have_address)) {
		/*
		 * We're missing at least one address family.  Either the
		 * caller hasn't instructed us to avoid fetches, or we don't
		 * know anything about any of the address families that would
		 * be acceptable so we have to launch fetches.
		 */

		if (FIND_STARTATZONE(find))
			start_at_zone = ISC_TRUE;

		/*
		 * Start V4.
		 */
		if (WANT_INET(wanted_fetches) &&
		    fetch_name(adbname, start_at_zone, depth, qc,
			       dns_rdatatype_a) == ISC_R_SUCCESS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: started A fetch for name %p",
			   adbname);
		}

		/*
		 * Start V6.
		 */
		if (WANT_INET6(wanted_fetches) &&
		    fetch_name(adbname, start_at_zone, depth, qc,
			       dns_rdatatype_aaaa) == ISC_R_SUCCESS) {
			DP(DEF_LEVEL,
			   "dns_adb_createfind: "
			   "started AAAA fetch for name %p",
			   adbname);
		}
	}

	/*
	 * Run through the name and copy out the bits we are
	 * interested in.
	 */
	copy_namehook_lists(adb, find, qname, qtype, adbname, now);

 post_copy:
	if (NAME_FETCH_V4(adbname))
		query_pending |= DNS_ADBFIND_INET;
	if (NAME_FETCH_V6(adbname))
		query_pending |= DNS_ADBFIND_INET6;

	/*
	 * Attach to the name's query list if there are queries
	 * already running, and we have been asked to.
	 */
	want_event = ISC_TRUE;
	if (!FIND_WANTEVENT(find))
		want_event = ISC_FALSE;
	if (FIND_WANTEMPTYEVENT(find) && FIND_HAS_ADDRS(find))
		want_event = ISC_FALSE;
	if ((wanted_addresses & query_pending) == 0)
		want_event = ISC_FALSE;
	if (alias)
		want_event = ISC_FALSE;
	if (want_event) {
		find->adbname = adbname;
		find->name_bucket = bucket;
		ISC_LIST_APPEND(adbname->finds, find, plink);
		find->query_pending = (query_pending & wanted_addresses);
		find->flags &= ~DNS_ADBFIND_ADDRESSMASK;
		find->flags |= (find->query_pending & DNS_ADBFIND_ADDRESSMASK);
		DP(DEF_LEVEL, "createfind: attaching find %p to adbname %p",
		   find, adbname);
	} else {
		/*
		 * Remove the flag so the caller knows there will never
		 * be an event, and set internal flags to fake that
		 * the event was sent and freed, so dns_adb_destroyfind() will
		 * do the right thing.
		 */
		find->query_pending = (query_pending & wanted_addresses);
		find->options &= ~DNS_ADBFIND_WANTEVENT;
		find->flags |= (FIND_EVENT_SENT | FIND_EVENT_FREED);
		find->flags &= ~DNS_ADBFIND_ADDRESSMASK;
	}

	find->partial_result |= (adbname->partial_result & wanted_addresses);
	if (alias) {
		if (target != NULL) {
			result = dns_name_copy(&adbname->target, target, NULL);
			if (result != ISC_R_SUCCESS)
				goto out;
		}
		result = DNS_R_ALIAS;
	} else
		result = ISC_R_SUCCESS;

	/*
	 * Copy out error flags from the name structure into the find.
	 */
	find->result_v4 = find_err_map[adbname->fetch_err];
	find->result_v6 = find_err_map[adbname->fetch6_err];

 out:
	if (find != NULL) {
		*findp = find;

		if (want_event) {
			isc_task_t *taskp;

			INSIST((find->flags & DNS_ADBFIND_ADDRESSMASK) != 0);
			taskp = NULL;
			isc_task_attach(task, &taskp);
			find->event.ev_sender = taskp;
			find->event.ev_action = action;
			find->event.ev_arg = arg;
		}
	}

	UNLOCK(&adb->namelocks[bucket]);

	return (result);
}

void
dns_adb_destroyfind(dns_adbfind_t **findp) {
	dns_adbfind_t *find;
	dns_adbentry_t *entry;
	dns_adbaddrinfo_t *ai;
	int bucket;
	dns_adb_t *adb;
	isc_boolean_t overmem;

	REQUIRE(findp != NULL && DNS_ADBFIND_VALID(*findp));
	find = *findp;
	*findp = NULL;

	LOCK(&find->lock);

	DP(DEF_LEVEL, "dns_adb_destroyfind on find %p", find);

	adb = find->adb;
	REQUIRE(DNS_ADB_VALID(adb));

	REQUIRE(FIND_EVENTFREED(find));

	bucket = find->name_bucket;
	INSIST(bucket == DNS_ADB_INVALIDBUCKET);

	UNLOCK(&find->lock);

	/*
	 * The find doesn't exist on any list, and nothing is locked.
	 * Return the find to the memory pool, and decrement the adb's
	 * reference count.
	 */
	overmem = isc_mem_isovermem(adb->mctx);
	ai = ISC_LIST_HEAD(find->list);
	while (ai != NULL) {
		ISC_LIST_UNLINK(find->list, ai, publink);
		entry = ai->entry;
		ai->entry = NULL;
		INSIST(DNS_ADBENTRY_VALID(entry));
		RUNTIME_CHECK(dec_entry_refcnt(adb, overmem, entry, ISC_TRUE) ==
			      ISC_FALSE);
		free_adbaddrinfo(adb, &ai);
		ai = ISC_LIST_HEAD(find->list);
	}

	/*
	 * WARNING:  The find is freed with the adb locked.  This is done
	 * to avoid a race condition where we free the find, some other
	 * thread tests to see if it should be destroyed, detects it should
	 * be, destroys it, and then we try to lock it for our check, but the
	 * lock is destroyed.
	 */
	LOCK(&adb->lock);
	if (free_adbfind(adb, &find))
		check_exit(adb);
	UNLOCK(&adb->lock);
}

void
dns_adb_cancelfind(dns_adbfind_t *find) {
	isc_event_t *ev;
	isc_task_t *task;
	dns_adb_t *adb;
	int bucket;
	int unlock_bucket;

	LOCK(&find->lock);

	DP(DEF_LEVEL, "dns_adb_cancelfind on find %p", find);

	adb = find->adb;
	REQUIRE(DNS_ADB_VALID(adb));

	REQUIRE(!FIND_EVENTFREED(find));
	REQUIRE(FIND_WANTEVENT(find));

	bucket = find->name_bucket;
	if (bucket == DNS_ADB_INVALIDBUCKET)
		goto cleanup;

	/*
	 * We need to get the adbname's lock to unlink the find.
	 */
	unlock_bucket = bucket;
	violate_locking_hierarchy(&find->lock, &adb->namelocks[unlock_bucket]);
	bucket = find->name_bucket;
	if (bucket != DNS_ADB_INVALIDBUCKET) {
		ISC_LIST_UNLINK(find->adbname->finds, find, plink);
		find->adbname = NULL;
		find->name_bucket = DNS_ADB_INVALIDBUCKET;
	}
	UNLOCK(&adb->namelocks[unlock_bucket]);
	bucket = DNS_ADB_INVALIDBUCKET;
	POST(bucket);

 cleanup:

	if (!FIND_EVENTSENT(find)) {
		ev = &find->event;
		task = ev->ev_sender;
		ev->ev_sender = find;
		ev->ev_type = DNS_EVENT_ADBCANCELED;
		ev->ev_destroy = event_free;
		ev->ev_destroy_arg = find;
		find->result_v4 = ISC_R_CANCELED;
		find->result_v6 = ISC_R_CANCELED;

		DP(DEF_LEVEL, "sending event %p to task %p for find %p",
		   ev, task, find);

		isc_task_sendanddetach(&task, (isc_event_t **)&ev);
	}

	UNLOCK(&find->lock);
}

void
dns_adb_dump(dns_adb_t *adb, FILE *f) {
	unsigned int i;
	isc_stdtime_t now;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(f != NULL);

	/*
	 * Lock the adb itself, lock all the name buckets, then lock all
	 * the entry buckets.  This should put the adb into a state where
	 * nothing can change, so we can iterate through everything and
	 * print at our leisure.
	 */

	LOCK(&adb->lock);
	isc_stdtime_get(&now);

	for (i = 0; i < adb->nnames; i++)
		RUNTIME_CHECK(cleanup_names(adb, i, now) == ISC_FALSE);
	for (i = 0; i < adb->nentries; i++)
		RUNTIME_CHECK(cleanup_entries(adb, i, now) == ISC_FALSE);

	dump_adb(adb, f, ISC_FALSE, now);
	UNLOCK(&adb->lock);
}

static void
dump_ttl(FILE *f, const char *legend, isc_stdtime_t value, isc_stdtime_t now) {
	if (value == INT_MAX)
		return;
	fprintf(f, " [%s TTL %d]", legend, value - now);
}

static void
dump_adb(dns_adb_t *adb, FILE *f, isc_boolean_t debug, isc_stdtime_t now) {
	unsigned int i;
	dns_adbname_t *name;
	dns_adbentry_t *entry;

	fprintf(f, ";\n; Address database dump\n;\n");
	if (debug)
		fprintf(f, "; addr %p, erefcnt %u, irefcnt %u, finds out %u\n",
			adb, adb->erefcnt, adb->irefcnt,
			isc_mempool_getallocated(adb->nhmp));

	for (i = 0; i < adb->nnames; i++)
		LOCK(&adb->namelocks[i]);
	for (i = 0; i < adb->nentries; i++)
		LOCK(&adb->entrylocks[i]);

	/*
	 * Dump the names
	 */
	for (i = 0; i < adb->nnames; i++) {
		name = ISC_LIST_HEAD(adb->names[i]);
		if (name == NULL)
			continue;
		if (debug)
			fprintf(f, "; bucket %d\n", i);
		for (;
		     name != NULL;
		     name = ISC_LIST_NEXT(name, plink))
		{
			if (debug)
				fprintf(f, "; name %p (flags %08x)\n",
					name, name->flags);

			fprintf(f, "; ");
			print_dns_name(f, &name->name);
			if (dns_name_countlabels(&name->target) > 0) {
				fprintf(f, " alias ");
				print_dns_name(f, &name->target);
			}

			dump_ttl(f, "v4", name->expire_v4, now);
			dump_ttl(f, "v6", name->expire_v6, now);
			dump_ttl(f, "target", name->expire_target, now);

			fprintf(f, " [v4 %s] [v6 %s]",
				errnames[name->fetch_err],
				errnames[name->fetch6_err]);

			fprintf(f, "\n");

			print_namehook_list(f, "v4", &name->v4, debug, now);
			print_namehook_list(f, "v6", &name->v6, debug, now);

			if (debug)
				print_fetch_list(f, name);
			if (debug)
				print_find_list(f, name);

		}
	}

	fprintf(f, ";\n; Unassociated entries\n;\n");

	for (i = 0; i < adb->nentries; i++) {
		entry = ISC_LIST_HEAD(adb->entries[i]);
		while (entry != NULL) {
			if (entry->refcnt == 0)
				dump_entry(f, entry, debug, now);
			entry = ISC_LIST_NEXT(entry, plink);
		}
	}

	/*
	 * Unlock everything
	 */
	for (i = 0; i < adb->nentries; i++)
		UNLOCK(&adb->entrylocks[i]);
	for (i = 0; i < adb->nnames; i++)
		UNLOCK(&adb->namelocks[i]);
}

static void
dump_entry(FILE *f, dns_adbentry_t *entry, isc_boolean_t debug,
	   isc_stdtime_t now)
{
	char addrbuf[ISC_NETADDR_FORMATSIZE];
	char typebuf[DNS_RDATATYPE_FORMATSIZE];
	isc_netaddr_t netaddr;
	dns_adblameinfo_t *li;

	isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr);
	isc_netaddr_format(&netaddr, addrbuf, sizeof(addrbuf));

	if (debug)
		fprintf(f, ";\t%p: refcnt %u\n", entry, entry->refcnt);

	fprintf(f, ";\t%s [srtt %u] [flags %08x]",
		addrbuf, entry->srtt, entry->flags);
	if (entry->expires != 0)
		fprintf(f, " [ttl %d]", entry->expires - now);
	fprintf(f, "\n");
	for (li = ISC_LIST_HEAD(entry->lameinfo);
	     li != NULL;
	     li = ISC_LIST_NEXT(li, plink)) {
		fprintf(f, ";\t\t");
		print_dns_name(f, &li->qname);
		dns_rdatatype_format(li->qtype, typebuf, sizeof(typebuf));
		fprintf(f, " %s [lame TTL %d]\n", typebuf,
			li->lame_timer - now);
	}
}

void
dns_adb_dumpfind(dns_adbfind_t *find, FILE *f) {
	char tmp[512];
	const char *tmpp;
	dns_adbaddrinfo_t *ai;
	isc_sockaddr_t *sa;

	/*
	 * Not used currently, in the API Just In Case we
	 * want to dump out the name and/or entries too.
	 */

	LOCK(&find->lock);

	fprintf(f, ";Find %p\n", find);
	fprintf(f, ";\tqpending %08x partial %08x options %08x flags %08x\n",
		find->query_pending, find->partial_result,
		find->options, find->flags);
	fprintf(f, ";\tname_bucket %d, name %p, event sender %p\n",
		find->name_bucket, find->adbname, find->event.ev_sender);

	ai = ISC_LIST_HEAD(find->list);
	if (ai != NULL)
		fprintf(f, "\tAddresses:\n");
	while (ai != NULL) {
		sa = &ai->sockaddr;
		switch (sa->type.sa.sa_family) {
		case AF_INET:
			tmpp = inet_ntop(AF_INET, &sa->type.sin.sin_addr,
					 tmp, sizeof(tmp));
			break;
		case AF_INET6:
			tmpp = inet_ntop(AF_INET6, &sa->type.sin6.sin6_addr,
					 tmp, sizeof(tmp));
			break;
		default:
			tmpp = "UnkFamily";
		}

		if (tmpp == NULL)
			tmpp = "BadAddress";

		fprintf(f, "\t\tentry %p, flags %08x"
			" srtt %u addr %s\n",
			ai->entry, ai->flags, ai->srtt, tmpp);

		ai = ISC_LIST_NEXT(ai, publink);
	}

	UNLOCK(&find->lock);
}

static void
print_dns_name(FILE *f, dns_name_t *name) {
	char buf[DNS_NAME_FORMATSIZE];

	INSIST(f != NULL);

	dns_name_format(name, buf, sizeof(buf));
	fprintf(f, "%s", buf);
}

static void
print_namehook_list(FILE *f, const char *legend, dns_adbnamehooklist_t *list,
		    isc_boolean_t debug, isc_stdtime_t now)
{
	dns_adbnamehook_t *nh;

	for (nh = ISC_LIST_HEAD(*list);
	     nh != NULL;
	     nh = ISC_LIST_NEXT(nh, plink))
	{
		if (debug)
			fprintf(f, ";\tHook(%s) %p\n", legend, nh);
		dump_entry(f, nh->entry, debug, now);
	}
}

static inline void
print_fetch(FILE *f, dns_adbfetch_t *ft, const char *type) {
	fprintf(f, "\t\tFetch(%s): %p -> { fetch %p }\n",
		type, ft, ft->fetch);
}

static void
print_fetch_list(FILE *f, dns_adbname_t *n) {
	if (NAME_FETCH_A(n))
		print_fetch(f, n->fetch_a, "A");
	if (NAME_FETCH_AAAA(n))
		print_fetch(f, n->fetch_aaaa, "AAAA");
}

static void
print_find_list(FILE *f, dns_adbname_t *name) {
	dns_adbfind_t *find;

	find = ISC_LIST_HEAD(name->finds);
	while (find != NULL) {
		dns_adb_dumpfind(find, f);
		find = ISC_LIST_NEXT(find, plink);
	}
}

static isc_result_t
dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype)
{
	isc_result_t result;
	dns_rdataset_t rdataset;
	dns_adb_t *adb;
	dns_fixedname_t foundname;
	dns_name_t *fname;

	INSIST(DNS_ADBNAME_VALID(adbname));
	adb = adbname->adb;
	INSIST(DNS_ADB_VALID(adb));
	INSIST(rdtype == dns_rdatatype_a || rdtype == dns_rdatatype_aaaa);

	dns_fixedname_init(&foundname);
	fname = dns_fixedname_name(&foundname);
	dns_rdataset_init(&rdataset);

	if (rdtype == dns_rdatatype_a)
		adbname->fetch_err = FIND_ERR_UNEXPECTED;
	else
		adbname->fetch6_err = FIND_ERR_UNEXPECTED;

	/*
	 * We need to specify whether to search static-stub zones (if
	 * configured) depending on whether this is a "start at zone" lookup,
	 * i.e., whether it's a "bailiwick" glue.  If it's bailiwick (in which
	 * case NAME_STARTATZONE is set) we need to stop the search at any
	 * matching static-stub zone without looking into the cache to honor
	 * the configuration on which server we should send queries to.
	 */
	result = dns_view_find2(adb->view, &adbname->name, rdtype, now,
				NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0,
				ISC_TF(NAME_HINTOK(adbname)),
				(adbname->flags & NAME_STARTATZONE) != 0 ?
				ISC_TRUE : ISC_FALSE,
				NULL, NULL, fname, &rdataset, NULL);

	/* XXXVIX this switch statement is too sparse to gen a jump table. */
	switch (result) {
	case DNS_R_GLUE:
	case DNS_R_HINT:
	case ISC_R_SUCCESS:
		/*
		 * Found in the database.  Even if we can't copy out
		 * any information, return success, or else a fetch
		 * will be made, which will only make things worse.
		 */
		if (rdtype == dns_rdatatype_a)
			adbname->fetch_err = FIND_ERR_SUCCESS;
		else
			adbname->fetch6_err = FIND_ERR_SUCCESS;
		result = import_rdataset(adbname, &rdataset, now);
		break;
	case DNS_R_NXDOMAIN:
	case DNS_R_NXRRSET:
		/*
		 * We're authoritative and the data doesn't exist.
		 * Make up a negative cache entry so we don't ask again
		 * for a while.
		 *
		 * XXXRTH  What time should we use?  I'm putting in 30 seconds
		 * for now.
		 */
		if (rdtype == dns_rdatatype_a) {
			adbname->expire_v4 = now + 30;
			DP(NCACHE_LEVEL,
			   "adb name %p: Caching auth negative entry for A",
			   adbname);
			if (result == DNS_R_NXDOMAIN)
				adbname->fetch_err = FIND_ERR_NXDOMAIN;
			else
				adbname->fetch_err = FIND_ERR_NXRRSET;
		} else {
			DP(NCACHE_LEVEL,
			   "adb name %p: Caching auth negative entry for AAAA",
			   adbname);
			adbname->expire_v6 = now + 30;
			if (result == DNS_R_NXDOMAIN)
				adbname->fetch6_err = FIND_ERR_NXDOMAIN;
			else
				adbname->fetch6_err = FIND_ERR_NXRRSET;
		}
		break;
	case DNS_R_NCACHENXDOMAIN:
	case DNS_R_NCACHENXRRSET:
		/*
		 * We found a negative cache entry.  Pull the TTL from it
		 * so we won't ask again for a while.
		 */
		rdataset.ttl = ttlclamp(rdataset.ttl);
		if (rdtype == dns_rdatatype_a) {
			adbname->expire_v4 = rdataset.ttl + now;
			if (result == DNS_R_NCACHENXDOMAIN)
				adbname->fetch_err = FIND_ERR_NXDOMAIN;
			else
				adbname->fetch_err = FIND_ERR_NXRRSET;
			DP(NCACHE_LEVEL,
			  "adb name %p: Caching negative entry for A (ttl %u)",
			   adbname, rdataset.ttl);
		} else {
			DP(NCACHE_LEVEL,
		       "adb name %p: Caching negative entry for AAAA (ttl %u)",
			   adbname, rdataset.ttl);
			adbname->expire_v6 = rdataset.ttl + now;
			if (result == DNS_R_NCACHENXDOMAIN)
				adbname->fetch6_err = FIND_ERR_NXDOMAIN;
			else
				adbname->fetch6_err = FIND_ERR_NXRRSET;
		}
		break;
	case DNS_R_CNAME:
	case DNS_R_DNAME:
		/*
		 * Clear the hint and glue flags, so this will match
		 * more often.
		 */
		adbname->flags &= ~(DNS_ADBFIND_GLUEOK | DNS_ADBFIND_HINTOK);

		rdataset.ttl = ttlclamp(rdataset.ttl);
		clean_target(adb, &adbname->target);
		adbname->expire_target = INT_MAX;
		result = set_target(adb, &adbname->name, fname, &rdataset,
				    &adbname->target);
		if (result == ISC_R_SUCCESS) {
			result = DNS_R_ALIAS;
			DP(NCACHE_LEVEL,
			   "adb name %p: caching alias target",
			   adbname);
			adbname->expire_target = rdataset.ttl + now;
		}
		if (rdtype == dns_rdatatype_a)
			adbname->fetch_err = FIND_ERR_SUCCESS;
		else
			adbname->fetch6_err = FIND_ERR_SUCCESS;
		break;
	}

	if (dns_rdataset_isassociated(&rdataset))
		dns_rdataset_disassociate(&rdataset);

	return (result);
}

static void
fetch_callback(isc_task_t *task, isc_event_t *ev) {
	dns_fetchevent_t *dev;
	dns_adbname_t *name;
	dns_adb_t *adb;
	dns_adbfetch_t *fetch;
	int bucket;
	isc_eventtype_t ev_status;
	isc_stdtime_t now;
	isc_result_t result;
	unsigned int address_type;
	isc_boolean_t want_check_exit = ISC_FALSE;

	UNUSED(task);

	INSIST(ev->ev_type == DNS_EVENT_FETCHDONE);
	dev = (dns_fetchevent_t *)ev;
	name = ev->ev_arg;
	INSIST(DNS_ADBNAME_VALID(name));
	adb = name->adb;
	INSIST(DNS_ADB_VALID(adb));

	bucket = name->lock_bucket;
	LOCK(&adb->namelocks[bucket]);

	INSIST(NAME_FETCH_A(name) || NAME_FETCH_AAAA(name));
	address_type = 0;
	if (NAME_FETCH_A(name) && (name->fetch_a->fetch == dev->fetch)) {
		address_type = DNS_ADBFIND_INET;
		fetch = name->fetch_a;
		name->fetch_a = NULL;
	} else if (NAME_FETCH_AAAA(name)
		   && (name->fetch_aaaa->fetch == dev->fetch)) {
		address_type = DNS_ADBFIND_INET6;
		fetch = name->fetch_aaaa;
		name->fetch_aaaa = NULL;
	} else
		fetch = NULL;

	INSIST(address_type != 0 && fetch != NULL);

	dns_resolver_destroyfetch(&fetch->fetch);
	dev->fetch = NULL;

	ev_status = DNS_EVENT_ADBNOMOREADDRESSES;

	/*
	 * Cleanup things we don't care about.
	 */
	if (dev->node != NULL)
		dns_db_detachnode(dev->db, &dev->node);
	if (dev->db != NULL)
		dns_db_detach(&dev->db);

	/*
	 * If this name is marked as dead, clean up, throwing away
	 * potentially good data.
	 */
	if (NAME_DEAD(name)) {
		free_adbfetch(adb, &fetch);
		isc_event_free(&ev);

		want_check_exit = kill_name(&name, DNS_EVENT_ADBCANCELED);

		UNLOCK(&adb->namelocks[bucket]);

		if (want_check_exit) {
			LOCK(&adb->lock);
			check_exit(adb);
			UNLOCK(&adb->lock);
		}

		return;
	}

	isc_stdtime_get(&now);

	/*
	 * If we got a negative cache response, remember it.
	 */
	if (NCACHE_RESULT(dev->result)) {
		dev->rdataset->ttl = ttlclamp(dev->rdataset->ttl);
		if (address_type == DNS_ADBFIND_INET) {
			DP(NCACHE_LEVEL, "adb fetch name %p: "
			   "caching negative entry for A (ttl %u)",
			   name, dev->rdataset->ttl);
			name->expire_v4 = ISC_MIN(name->expire_v4,
						  dev->rdataset->ttl + now);
			if (dev->result == DNS_R_NCACHENXDOMAIN)
				name->fetch_err = FIND_ERR_NXDOMAIN;
			else
				name->fetch_err = FIND_ERR_NXRRSET;
			inc_stats(adb, dns_resstatscounter_gluefetchv4fail);
		} else {
			DP(NCACHE_LEVEL, "adb fetch name %p: "
			   "caching negative entry for AAAA (ttl %u)",
			   name, dev->rdataset->ttl);
			name->expire_v6 = ISC_MIN(name->expire_v6,
						  dev->rdataset->ttl + now);
			if (dev->result == DNS_R_NCACHENXDOMAIN)
				name->fetch6_err = FIND_ERR_NXDOMAIN;
			else
				name->fetch6_err = FIND_ERR_NXRRSET;
			inc_stats(adb, dns_resstatscounter_gluefetchv6fail);
		}
		goto out;
	}

	/*
	 * Handle CNAME/DNAME.
	 */
	if (dev->result == DNS_R_CNAME || dev->result == DNS_R_DNAME) {
		dev->rdataset->ttl = ttlclamp(dev->rdataset->ttl);
		clean_target(adb, &name->target);
		name->expire_target = INT_MAX;
		result = set_target(adb, &name->name,
				    dns_fixedname_name(&dev->foundname),
				    dev->rdataset,
				    &name->target);
		if (result == ISC_R_SUCCESS) {
			DP(NCACHE_LEVEL,
			   "adb fetch name %p: caching alias target",
			   name);
			name->expire_target = dev->rdataset->ttl + now;
		}
		goto check_result;
	}

	/*
	 * Did we get back junk?  If so, and there are no more fetches
	 * sitting out there, tell all the finds about it.
	 */
	if (dev->result != ISC_R_SUCCESS) {
		char buf[DNS_NAME_FORMATSIZE];

		dns_name_format(&name->name, buf, sizeof(buf));
		DP(DEF_LEVEL, "adb: fetch of '%s' %s failed: %s",
		   buf, address_type == DNS_ADBFIND_INET ? "A" : "AAAA",
		   dns_result_totext(dev->result));
		/*
		 * Don't record a failure unless this is the initial
		 * fetch of a chain.
		 */
		if (fetch->depth > 1)
			goto out;
		/* XXXMLG Don't pound on bad servers. */
		if (address_type == DNS_ADBFIND_INET) {
			name->expire_v4 = ISC_MIN(name->expire_v4, now + 300);
			name->fetch_err = FIND_ERR_FAILURE;
			inc_stats(adb, dns_resstatscounter_gluefetchv4fail);
		} else {
			name->expire_v6 = ISC_MIN(name->expire_v6, now + 300);
			name->fetch6_err = FIND_ERR_FAILURE;
			inc_stats(adb, dns_resstatscounter_gluefetchv6fail);
		}
		goto out;
	}

	/*
	 * We got something potentially useful.
	 */
	result = import_rdataset(name, &fetch->rdataset, now);

 check_result:
	if (result == ISC_R_SUCCESS) {
		ev_status = DNS_EVENT_ADBMOREADDRESSES;
		if (address_type == DNS_ADBFIND_INET)
			name->fetch_err = FIND_ERR_SUCCESS;
		else
			name->fetch6_err = FIND_ERR_SUCCESS;
	}

 out:
	free_adbfetch(adb, &fetch);
	isc_event_free(&ev);

	clean_finds_at_name(name, ev_status, address_type);

	UNLOCK(&adb->namelocks[bucket]);
}

static isc_result_t
fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone,
	   unsigned int depth, isc_counter_t *qc, dns_rdatatype_t type)
{
	isc_result_t result;
	dns_adbfetch_t *fetch = NULL;
	dns_adb_t *adb;
	dns_fixedname_t fixed;
	dns_name_t *name;
	dns_rdataset_t rdataset;
	dns_rdataset_t *nameservers;
	unsigned int options;

	INSIST(DNS_ADBNAME_VALID(adbname));
	adb = adbname->adb;
	INSIST(DNS_ADB_VALID(adb));

	INSIST((type == dns_rdatatype_a && !NAME_FETCH_V4(adbname)) ||
	       (type == dns_rdatatype_aaaa && !NAME_FETCH_V6(adbname)));

	adbname->fetch_err = FIND_ERR_NOTFOUND;

	name = NULL;
	nameservers = NULL;
	dns_rdataset_init(&rdataset);

	options = DNS_FETCHOPT_NOVALIDATE;
	if (start_at_zone) {
		DP(ENTER_LEVEL,
		   "fetch_name: starting at zone for name %p",
		   adbname);
		dns_fixedname_init(&fixed);
		name = dns_fixedname_name(&fixed);
		result = dns_view_findzonecut2(adb->view, &adbname->name, name,
					       0, 0, ISC_TRUE, ISC_FALSE,
					       &rdataset, NULL);
		if (result != ISC_R_SUCCESS && result != DNS_R_HINT)
			goto cleanup;
		nameservers = &rdataset;
		options |= DNS_FETCHOPT_UNSHARED;
	}

	fetch = new_adbfetch(adb);
	if (fetch == NULL) {
		result = ISC_R_NOMEMORY;
		goto cleanup;
	}
	fetch->depth = depth;

	result = dns_resolver_createfetch3(adb->view->resolver, &adbname->name,
					  type, name, nameservers, NULL,
					   NULL, 0, options, depth, qc,
					   adb->task, fetch_callback, adbname,
					   &fetch->rdataset, NULL,
					  &fetch->fetch);
	if (result != ISC_R_SUCCESS)
		goto cleanup;

	if (type == dns_rdatatype_a) {
		adbname->fetch_a = fetch;
		inc_stats(adb, dns_resstatscounter_gluefetchv4);
	} else {
		adbname->fetch_aaaa = fetch;
		inc_stats(adb, dns_resstatscounter_gluefetchv6);
	}
	fetch = NULL;  /* Keep us from cleaning this up below. */

 cleanup:
	if (fetch != NULL)
		free_adbfetch(adb, &fetch);
	if (dns_rdataset_isassociated(&rdataset))
		dns_rdataset_disassociate(&rdataset);

	return (result);
}

/*
 * XXXMLG Needs to take a find argument and an address info, no zone or adb,
 * since these can be extracted from the find itself.
 */
isc_result_t
dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *qname,
		 dns_rdatatype_t qtype, isc_stdtime_t expire_time)
{
	dns_adblameinfo_t *li;
	int bucket;
	isc_result_t result = ISC_R_SUCCESS;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(DNS_ADBADDRINFO_VALID(addr));
	REQUIRE(qname != NULL);

	bucket = addr->entry->lock_bucket;
	LOCK(&adb->entrylocks[bucket]);
	li = ISC_LIST_HEAD(addr->entry->lameinfo);
	while (li != NULL &&
	       (li->qtype != qtype || !dns_name_equal(qname, &li->qname)))
		li = ISC_LIST_NEXT(li, plink);
	if (li != NULL) {
		if (expire_time > li->lame_timer)
			li->lame_timer = expire_time;
		goto unlock;
	}
	li = new_adblameinfo(adb, qname, qtype);
	if (li == NULL) {
		result = ISC_R_NOMEMORY;
		goto unlock;
	}

	li->lame_timer = expire_time;

	ISC_LIST_PREPEND(addr->entry->lameinfo, li, plink);
 unlock:
	UNLOCK(&adb->entrylocks[bucket]);

	return (result);
}

void
dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
		   unsigned int rtt, unsigned int factor)
{
	int bucket;
	isc_stdtime_t now = 0;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(DNS_ADBADDRINFO_VALID(addr));
	REQUIRE(factor <= 10);

	bucket = addr->entry->lock_bucket;
	LOCK(&adb->entrylocks[bucket]);

	if (addr->entry->expires == 0 || factor == DNS_ADB_RTTADJAGE)
		isc_stdtime_get(&now);
	adjustsrtt(addr, rtt, factor, now);

	UNLOCK(&adb->entrylocks[bucket]);
}

void
dns_adb_agesrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr, isc_stdtime_t now) {
	int bucket;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(DNS_ADBADDRINFO_VALID(addr));

	bucket = addr->entry->lock_bucket;
	LOCK(&adb->entrylocks[bucket]);

	adjustsrtt(addr, 0, DNS_ADB_RTTADJAGE, now);

	UNLOCK(&adb->entrylocks[bucket]);
}

static void
adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, unsigned int factor,
          isc_stdtime_t now)
{
	isc_uint64_t new_srtt;

	if (factor == DNS_ADB_RTTADJAGE) {
		if (addr->entry->lastage != now) {
			new_srtt = addr->entry->srtt;
			new_srtt <<= 9;
			new_srtt -= addr->entry->srtt;
			new_srtt >>= 9;
			addr->entry->lastage = now;
		} else
			new_srtt = addr->entry->srtt;
	} else
		new_srtt = (addr->entry->srtt / 10 * factor)
			+ (rtt / 10 * (10 - factor));

	new_srtt &= 0xffffffff;
	addr->entry->srtt = (unsigned int) new_srtt;
	addr->srtt = (unsigned int) new_srtt;

	if (addr->entry->expires == 0)
		addr->entry->expires = now + ADB_ENTRY_WINDOW;
}

void
dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
		    unsigned int bits, unsigned int mask)
{
	int bucket;
	isc_stdtime_t now;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(DNS_ADBADDRINFO_VALID(addr));

	REQUIRE((bits & ENTRY_IS_DEAD) == 0);
	REQUIRE((mask & ENTRY_IS_DEAD) == 0);

	bucket = addr->entry->lock_bucket;
	LOCK(&adb->entrylocks[bucket]);

	addr->entry->flags = (addr->entry->flags & ~mask) | (bits & mask);
	if (addr->entry->expires == 0) {
		isc_stdtime_get(&now);
		addr->entry->expires = now + ADB_ENTRY_WINDOW;
	}

	/*
	 * Note that we do not update the other bits in addr->flags with
	 * the most recent values from addr->entry->flags.
	 */
	addr->flags = (addr->flags & ~mask) | (bits & mask);

	UNLOCK(&adb->entrylocks[bucket]);
}

isc_result_t
dns_adb_findaddrinfo(dns_adb_t *adb, isc_sockaddr_t *sa,
		     dns_adbaddrinfo_t **addrp, isc_stdtime_t now)
{
	int bucket;
	dns_adbentry_t *entry;
	dns_adbaddrinfo_t *addr;
	isc_result_t result;
	in_port_t port;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(addrp != NULL && *addrp == NULL);

	UNUSED(now);

	result = ISC_R_SUCCESS;
	bucket = DNS_ADB_INVALIDBUCKET;
	entry = find_entry_and_lock(adb, sa, &bucket, now);
	INSIST(bucket != DNS_ADB_INVALIDBUCKET);
	if (adb->entry_sd[bucket]) {
		result = ISC_R_SHUTTINGDOWN;
		goto unlock;
	}
	if (entry == NULL) {
		/*
		 * We don't know anything about this address.
		 */
		entry = new_adbentry(adb);
		if (entry == NULL) {
			result = ISC_R_NOMEMORY;
			goto unlock;
		}
		entry->sockaddr = *sa;
		link_entry(adb, bucket, entry);
		DP(ENTER_LEVEL, "findaddrinfo: new entry %p", entry);
	} else
		DP(ENTER_LEVEL, "findaddrinfo: found entry %p", entry);

	port = isc_sockaddr_getport(sa);
	addr = new_adbaddrinfo(adb, entry, port);
	if (addr == NULL) {
		result = ISC_R_NOMEMORY;
	} else {
		inc_entry_refcnt(adb, entry, ISC_FALSE);
		*addrp = addr;
	}

 unlock:
	UNLOCK(&adb->entrylocks[bucket]);

	return (result);
}

void
dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp) {
	dns_adbaddrinfo_t *addr;
	dns_adbentry_t *entry;
	int bucket;
	isc_stdtime_t now;
	isc_boolean_t want_check_exit = ISC_FALSE;
	isc_boolean_t overmem;

	REQUIRE(DNS_ADB_VALID(adb));
	REQUIRE(addrp != NULL);
	addr = *addrp;
	REQUIRE(DNS_ADBADDRINFO_VALID(addr));
	entry = addr->entry;
	REQUIRE(DNS_ADBENTRY_VALID(entry));

	*addrp = NULL;
	overmem = isc_mem_isovermem(adb->mctx);

	bucket = addr->entry->lock_bucket;
	LOCK(&adb->entrylocks[bucket]);

	if (entry->expires == 0) {
		isc_stdtime_get(&now);
	entry->expires = now + ADB_ENTRY_WINDOW;
	}

	want_check_exit = dec_entry_refcnt(adb, overmem, entry, ISC_FALSE);

	UNLOCK(&adb->entrylocks[bucket]);

	addr->entry = NULL;
	free_adbaddrinfo(adb, &addr);

	if (want_check_exit) {
		LOCK(&adb->lock);
		check_exit(adb);
		UNLOCK(&adb->lock);
	}
}

void
dns_adb_flush(dns_adb_t *adb) {
	unsigned int i;

	INSIST(DNS_ADB_VALID(adb));

	LOCK(&adb->lock);

	/*
	 * Call our cleanup routines.
	 */
	for (i = 0; i < adb->nnames; i++)
		RUNTIME_CHECK(cleanup_names(adb, i, INT_MAX) == ISC_FALSE);
	for (i = 0; i < adb->nentries; i++)
		RUNTIME_CHECK(cleanup_entries(adb, i, INT_MAX) == ISC_FALSE);

#ifdef DUMP_ADB_AFTER_CLEANING
	dump_adb(adb, stdout, ISC_TRUE, INT_MAX);
#endif

	UNLOCK(&adb->lock);
}

void
dns_adb_flushname(dns_adb_t *adb, dns_name_t *name) {
	dns_adbname_t *adbname;
	dns_adbname_t *nextname;
	int bucket;

	INSIST(DNS_ADB_VALID(adb));

	LOCK(&adb->lock);
	bucket = dns_name_hash(name, ISC_FALSE) % adb->nnames;
	LOCK(&adb->namelocks[bucket]);
	adbname = ISC_LIST_HEAD(adb->names[bucket]);
	while (adbname != NULL) {
		nextname = ISC_LIST_NEXT(adbname, plink);
		if (!NAME_DEAD(adbname) &&
		    dns_name_equal(name, &adbname->name)) {
			RUNTIME_CHECK(kill_name(&adbname,
						DNS_EVENT_ADBCANCELED) ==
				      ISC_FALSE);
		}
		adbname = nextname;
	}
	UNLOCK(&adb->namelocks[bucket]);
	UNLOCK(&adb->lock);
}

static void
water(void *arg, int mark) {
	/*
	 * We're going to change the way to handle overmem condition: use
	 * isc_mem_isovermem() instead of storing the state via this callback,
	 * since the latter way tends to cause race conditions.
	 * To minimize the change, and in case we re-enable the callback
	 * approach, however, keep this function at the moment.
	 */

	dns_adb_t *adb = arg;
	isc_boolean_t overmem = ISC_TF(mark == ISC_MEM_HIWATER);

	REQUIRE(DNS_ADB_VALID(adb));

	DP(ISC_LOG_DEBUG(1),
	   "adb reached %s water mark", overmem ? "high" : "low");
}

void
dns_adb_setadbsize(dns_adb_t *adb, size_t size) {
	size_t hiwater, lowater;

	INSIST(DNS_ADB_VALID(adb));

	if (size != 0U && size < DNS_ADB_MINADBSIZE)
		size = DNS_ADB_MINADBSIZE;

	hiwater = size - (size >> 3);   /* Approximately 7/8ths. */
	lowater = size - (size >> 2);   /* Approximately 3/4ths. */

	if (size == 0U || hiwater == 0U || lowater == 0U)
		isc_mem_setwater(adb->mctx, water, adb, 0, 0);
	else
		isc_mem_setwater(adb->mctx, water, adb, hiwater, lowater);
}