bind9/lib/dns
Ondřej Surý 3c33e7d937
Implement Fisher-Yates shuffle for nameserver selection
Replace the two-pass "random start index and wrap around" logic in
fctx_getaddresses_nameservers() with a statistically sound Fisher-Yates
shuffle.

The previous implementation picked a random starting node and did two
passes over the linked list to find query candidates.  The new logic
extracts the available nameservers into a bounded, stack-allocated array
of dns_rdata_t structures.

This array is then randomized in-place using a Fisher-Yates shuffle.
Finally, the shuffled array is traversed sequentially to launch fetches
until the dynamic quota (fctx->pending_running >= fetches_allowed) is
reached.

This guarantees a fair random distribution for outbound queries while
properly respecting dynamic query limits, entirely within O(1) memory
and without the overhead of linked-list pointer shuffling or multiple
dataset traversals.
2026-02-26 06:57:53 +01:00
..
include Enforce NSEC3 record consistency 2026-02-24 14:57:22 +01:00
rdata Remove invalid REQUIRE in NSEC3 fromstruct method 2026-02-24 14:58:18 +01:00
.gitignore Add support for User Statically Defined Tracing (USDT) probes 2023-08-21 18:39:53 +02:00
acl.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
acl_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
adb.c Remove purged adb names and entries from SIEVE list immediately 2026-02-25 07:26:38 +01:00
badcache.c Apply the changes from updated set_if_not_null semantic patch 2025-10-08 17:44:50 +02:00
byaddr.c Share reverse (ARPA) domain names 2025-10-01 12:16:05 +02:00
cache.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
callbacks.c Convert all categories and modules into static lists 2024-08-20 12:50:39 +00:00
catz.c switch isc_md_type_t to a proper enum 2026-02-02 11:12:55 +03:00
client.c Rename isc_net_getudpportrange() to isc_net_getportrange() 2026-02-20 14:06:23 +01:00
clientinfo.c refactor dns_clientinfo_init(); use separate function to set ECS 2023-02-07 23:48:22 -08:00
compress.c remove the 'name_coff' parameter in dns_name_towire() 2025-02-25 12:53:25 -08:00
db.c Fix formatting 2025-12-09 13:32:24 +01:00
db_p.h Switch qpzone to rdatavec 2025-12-10 12:18:34 +01:00
dbiterator.c Implement dns_dbiterator_seek3 2025-12-10 14:18:52 +01:00
diff.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
dispatch.c Rename isc_net_getudpportrange() to isc_net_getportrange() 2026-02-20 14:06:23 +01:00
dlz.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
dlz_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
dns64.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
dnssec.c Update dns_dnssec_sync(update|delete) return code 2025-12-19 14:08:15 +01:00
dnstap.c Record query time for all dnstap responses 2026-02-06 15:38:48 +01:00
ds.c switch isc_md_type_t to a proper enum 2026-02-02 11:12:55 +03:00
dst_api.c switch isc_md_type_t to a proper enum 2026-02-02 11:12:55 +03:00
dst_internal.h Separate isc_hmac between pre and post OpenSSL 3.0 2026-02-02 11:50:14 +03:00
dst_openssl.h move openssl error reporting to isc/ossl_wrap 2026-02-02 11:50:14 +03:00
dst_parse.c Use isc__zero_or_more when calling isc_base64_tobuffer 2026-01-28 00:25:04 +11:00
dst_parse.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
dyndb.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
dyndb_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
ecs.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
ede.c add dns_message API to add EDNS options 2025-11-21 11:13:18 -08:00
fixedname.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
forward.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
gen.c Silence "may be truncated" warnings 2025-08-04 15:38:17 +02:00
geoip2.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
gssapi_link.c Deprecate max-rsa-exponent-size, always use 4096 instead 2025-05-21 00:50:08 +02:00
gssapictx.c Release gnamebuf also on the error path 2026-02-06 18:33:44 +01:00
hmac_link.c don't transform errors in hmac_sign 2026-02-02 11:50:14 +03:00
ipkeylist.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
iptable.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
journal.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
kasp.c Refactor dns_kasp_attach/detach 2026-01-23 09:59:52 +00:00
key.c Cleanup the DST cryptographic API 2025-05-20 09:52:35 +02:00
keydata.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
keymgr.c Make keymgr state machine more robust 2025-12-05 12:14:14 +01:00
keystore.c Fix log level bug in keystore 2026-02-25 11:34:07 +01:00
keytable.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
lib.c Replace per-zone lock buckets with global buckets 2025-07-09 15:27:38 +02:00
master.c Fix formatting 2025-12-09 13:32:24 +01:00
masterdump.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
meson.build Add rdatavec 2025-12-10 12:18:34 +01:00
message.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
name.c dns_name_totext() can now resize dynamic buffers 2025-12-09 12:26:30 -08:00
nametree.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
ncache.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
notify.c Don't retry notify over TCP if it could not successed 2026-02-19 13:44:28 +01:00
nsec.c Lower case the NSEC next owner name when signing 2026-01-23 11:52:59 +00:00
nsec3.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
nta.c rename fetch response db field to cache 2026-02-10 08:50:16 +01:00
openssl_link.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
openssl_shim.h Move the dst__openssl_toresult to isc_tls unit 2024-08-08 11:59:41 +02:00
opensslecdsa_link.c expose isc__crypto_md in isc/ossl_wrap.h 2026-02-02 11:50:14 +03:00
openssleddsa_link.c cleanup unused header in isc/md.h 2026-02-02 11:50:14 +03:00
opensslrsa_link.c expose isc__crypto_md in isc/ossl_wrap.h 2026-02-02 11:50:14 +03:00
order.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
peer.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
private.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
probes-dns.d Use unique names for probes.d files 2025-09-24 13:18:13 +02:00
qp.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
qp_p.h Fix formatting after refactor 2025-12-10 11:28:10 +01:00
qpcache.c Fix NULL Pointer Dereference in QP-trie Cache add() 2026-02-07 11:50:14 +01:00
qpcache_p.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
qpzone.c Return node pointer in step 2026-02-12 17:36:48 +01:00
qpzone_p.h Replace per-zone lock buckets with global buckets 2025-07-09 15:27:38 +02:00
rcode.c standardize CHECK and RETERR macros 2025-12-03 13:26:28 -08:00
rdata.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
rdatalist.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
rdataset.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
rdatasetiter.c add DNS_DBITERATOR_FOREACH and DNS_RDATASETITER_FOREACH 2025-05-27 21:08:09 -07:00
rdataslab.c Use offsetof() instead of pointer arithmetics to get slabheader 2026-02-18 14:29:16 +01:00
rdataslab_p.h Use ISC_UxxTOyy_BE macros for {peek,get,put}_uint16 macros 2025-08-18 12:36:47 +02:00
rdatavec.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
rdatavec_p.h Fix formatting 2025-12-10 12:18:34 +01:00
remote.c simplify code around isc_mem_put() and isc_mem_free() 2025-05-28 17:22:32 -07:00
request.c Fix assertion failure when sending notify fails over UDP 2026-02-19 13:44:23 +01:00
resconf.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
resolver.c Implement Fisher-Yates shuffle for nameserver selection 2026-02-26 06:57:53 +01:00
result.c clean up result codes that are never used 2025-01-23 15:54:57 -08:00
rootns.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
rpz.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
rriterator.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
rrl.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
sdlz.c dns_rdataset_* const parameters 2026-01-30 19:33:42 +01:00
skr.c Importing invalid SKR file might overflow the stack buffer 2026-02-24 19:44:57 +01:00
soa.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
ssu.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
ssu_external.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
stats.c Use clang-format-20 to update formatting 2025-06-25 12:44:22 +10:00
tests Move all the unit tests to /tests/<libname>/ 2022-05-28 14:53:02 -07:00
time.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
tkey.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
transport.c switch to CHECK where it wasn't being used 2025-12-03 13:45:42 -08:00
tsig.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
tsig_p.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
ttl.c standardize CHECK and RETERR macros 2025-12-03 13:26:28 -08:00
unreachcache.c Change the loopmgr to be singleton 2025-07-23 22:44:16 +02:00
update.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
validator.c Invalid NSEC3 can cause OOB read of the isdelegation() stack 2026-02-24 14:56:29 +01:00
view.c Remove unused dns_view_load() and dns_zt_load() 2026-02-12 13:43:13 +00:00
xfrin.c Implement qpzone specific update path 2025-12-09 12:55:30 +01:00
zone.c Fix a bug in zone_loaddone() 2026-01-27 11:31:15 +00:00
zone_p.h Use notify type in logging and for getting context 2025-12-19 14:08:15 +01:00
zonefetch.c rename fetch response db field to cache 2026-02-10 08:50:16 +01:00
zoneverify.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
zt.c Remove unused dns_view_load() and dns_zt_load() 2026-02-12 13:43:13 +00:00