2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

43636 Commits

Author SHA1 Message Date
Ondřej Surý
4a6835b51f fix: dev: Refactor resolver cache_name() and validated() functions
These functions were excessive in length and complexity, with McCabe complexity values of 110 and 105 respectively, and also included some dead code. They have been cleaned up and split into smaller functions, with a maximum complexity of 27.  A few minor coding errors were discovered and fixed along the way.

Merge branch 'each-refactor-cache-name' into 'main'

See merge request isc-projects/bind9!10198
2025-08-05 13:27:59 +02:00
Evan Hunt
5a2938b452
refactor validated()
- there was special-case code in validated() to handle the results
  of a validator started by a CD=1 query. since that never happens,
  the code has been removed.
- the section of code that handles opportunistic caching of
  validated SOA, NS and NSEC data has been split out to a separate
  function.
- the number of goto statements has been reduced considerably.
2025-08-05 12:16:36 +02:00
Evan Hunt
9f674c43cf
split out helper functions
- fctx_setresult() sets the event result in a fetch response
  according to the rdataset being returned - DNS_R_NCACHENXDOMAIN or
  DNS_R_NXRRSET for negative responses, ISC_R_SUCCESS, DNS_R_CNAME,
  or DNS_R_DNAME for positive ones.
- cache_rrset() looks up a node and adds an rdataset.
- delete_rrset() looks up a node and removes rdatasets of a specified
  type and, optionally, the associated signatures.
- gettrust() returns the trust level of an rdataset, or dns_trust_none
  if the rdataset is NULL or not associated.
- getrrsig() scans the rdatasets associated with a name for the
  RRSIG covering a given type.
2025-08-05 12:16:36 +02:00
Evan Hunt
723d167f26
further subdivide caching functions
rctx_cacherdataset() has been split into two functions:
- rctx_cache_secure() starts validation for rdatasets
  that need it; they are then cached by the validator
  completion callback validated()
- rctx_cache_insecure() caches rdatasets immediately; it
  is called when validation is disabled or the data
  to be cached is glue.
2025-08-05 12:16:36 +02:00
Evan Hunt
ed56a91d7d
rename and refactor cache_name() and related functions
- renamed cache_message() to rctx_cachemessage()
- renamed cache_name() to rctx_cachename()
- merged ncache_message() into rctx_ncache()
- split out a new function, rctx_cacherdataset(), which is
  called by rctx_cachename() in a loop to process each of
  the rdatasets associated with the name.
2025-08-05 12:16:36 +02:00
Evan Hunt
83980d76b2
reduce code duplication around findnoqname()
every call to findnoqname() was followed by a call to
dns_rdataset_addnoqname(). we can move that call into
findnoqname() itself, and simplify the calling functions
a bit.
2025-08-05 12:16:36 +02:00
Evan Hunt
b940d40635
set ANSWERSIG flag when processing ANY responses
previously, rctx_answer_any() set the ANSWER flag for all
rdatasets in the answer section; it now sets ANSWERSIG for
RRSIG/SIG rdatasets and ANSWER for everything else.  this
error didn't cause any harm in the current code, but it
could have led to unexpected behavior in the future.
2025-08-05 12:16:36 +02:00
Evan Hunt
c23cc105a1
split out some functionality in cache_name()
there are now separate functions to check the cacheability of
an rdataset or to normalize TTLs, and the code to determine
whether validation is necessary has been simplified.
2025-08-05 12:16:36 +02:00
Evan Hunt
7841de08af
add functions to match rdataset types
- dns_rdataset_issigtype() returns true if the rdataset is
  of type RRSIG and covers a specified type
- dns_rdataset_matchestype() returns true if the rdataset
  is of the specified type *or* the RRSIG covering it.
2025-08-05 12:16:36 +02:00
Evan Hunt
51a4e00d1d
reduce steps for negative caching
whenever ncache_adderesult() was called, some preparatory code
was run first; this has now been moved into a single function
negcache() to reduce code duplication.
2025-08-05 12:16:36 +02:00
Evan Hunt
7371c4882a
change issecuredomain() functions to bool
dns_keytable_issecuredomain() and dns_view_issecuredomain()
previously returned a result code to inform the caller of
unexpected database failures when looking up names in the
keytable and/or NTA table. such failures are not actually
possible. both functions now return a simple bool.

also, dns_view_issecuredomain() now returns false if
view->enablevalidation is false, so the caller no longer
has to check for that.
2025-08-05 12:16:36 +02:00
Evan Hunt
5d56df23f2
split out cookie checks from resquery_response_continue()
split the code section that handles cookie issues into a
separate function for better readablity.
2025-08-05 12:16:36 +02:00
Evan Hunt
5e1df53d05
simplify dns_ncache_add()
there's no longer any reason to have both dns_ncache_add() and
dns_ncache_addoptout().
2025-08-05 12:16:36 +02:00
Ondřej Surý
f635bf4df8 fix: test: Add support for small stack size for threads
When running the isc_quota unit test with less than
usual amount of RAM (e.g. in a CI for architectures
with 32 bits of address space), the pthread_create()
function fails with the "Resource temporarily unavailable
(11)" error code.

Add functions to get and set the thread stack size (if requested),
and use these to set the thread stack size to smaller value in the
isc_quota unit test.

Merge branch 'aram/isc-thread-stack-size-small' into 'main'

See merge request isc-projects/bind9!10778
2025-08-05 11:24:35 +02:00
Ondřej Surý
f23bdc29ef
Document the current default stack sizes on different systems
The default stack sizes varies between operating systems and between
different system libc libraries from 128kB (Alpine Linux with MUSL) to
8M (Linux with glibc).  Document the different values used to justify
the value of THREAD_MINSTACKSIZE (currently set to 1MB).
2025-08-05 10:46:09 +02:00
Ondřej Surý
96dad96ae5
Add support for setting thread stack size
When running the isc_quota unit test with less than usual amount of
RAM (e.g. in a CI for architectures with 32 bits of address space),
the pthread_create() function fails with the "Resource temporarily
unavailable (11):" error code.

Add functions to get and set the thread stack size (if requested),
and use these to set the thread stack size to smaller value in the
isc_quota unit test.
2025-08-05 10:46:09 +02:00
Aram Sargsyan
f22c980173
meson: add 'threads' dependency for pthread_* function checks
This fixes the correct detection of these functions on some
platforms like Alma Linux 8.

Co-authored-by: Aydın Mercan <aydin@isc.org>
2025-08-05 10:46:09 +02:00
Mark Andrews
fdf7e2f773 new: usr: Support for parsing the DSYNC record has been added
Closes #5440

Merge branch '5440-add-dsync-record' into 'main'

See merge request isc-projects/bind9!10776
2025-08-05 18:11:41 +10:00
Mark Andrews
53c8c5233a Add tests for DSYNC 2025-08-05 17:27:44 +10:00
Mark Andrews
c47615094e Add support for parsing and displaying DSYNC rdata type 2025-08-05 17:27:44 +10:00
Mark Andrews
6e1311c624 Add support for parsing DSYNC scheme mnemonics
Adds dns_dsyncscheme_fromtext, dns_dsyncscheme_totext and
dns_dsyncscheme_format.  Adds type dns_dsyncscheme_t.
2025-08-05 17:27:44 +10:00
Matthijs Mekking
09efe6039c fix: usr: Add RPZ extended DNS error for zones with a CNAME override policy configured
When the zone is configured with a CNAME override policy, or the response policy zone contains a wildcard CNAME, the extended DNS error code was not added. This has been fixed.

Closes #5342

Merge branch '5342-rpz-cname-override-ede-not-added' into 'main'

See merge request isc-projects/bind9!10777
2025-08-05 07:19:49 +00:00
Matthijs Mekking
2f70a0ef12 Add ede for zone with rpz cname override policy
When the zone is configured with a CNAME override policy, also add the
configured EDE code.

When the zone is contains a wildcard CNAME, also add the configured
EDE code.
2025-08-05 08:35:51 +02:00
Matthijs Mekking
4ef00f97d6 Test adding ede with rpz cname override policy
When the zone is configured with a CNAME override policy, the EDE code
is not added as expected. Add a test case based on the issue in GitLab
(#5342).

When the zone contains a wildcard CNAME, the EDE code is not added as
expected. Also add a test case for this.
2025-08-05 08:35:51 +02:00
Ondřej Surý
c613d87308 fix: dev: Silence "may be truncated" warnings
Use memccpy() instead of strncpy() for safe string manipulation. 

Closes #5395

Merge branch '5395-gen-c-silence-truncated-warnings' into 'main'

See merge request isc-projects/bind9!10647
2025-08-04 16:52:11 +02:00
Ondřej Surý
3a06c24962
Silence "may be truncated" warnings
Use memccpy() instead of strncpy() for safe string manipulation.
2025-08-04 15:38:17 +02:00
Ondřej Surý
999d7a5558 chg: dev: Add and use global memory context called isc_g_mctx
Instead of having individual memory contexts scattered across different
files and called different names, add a single memory context called
isc_g_mctx that replaces named_g_mctx and various other global memory
contexts in various utilities and tests.

Merge branch 'ondrej/add-global-isc_g_mctx-instance' into 'main'

See merge request isc-projects/bind9!10737
2025-08-04 12:11:01 +02:00
Ondřej Surý
f2e107508a
Add rcu_barrier() to isc__log_shutdown()
There is a data race when QP is reclaiming chunks on the call_rcu
threads and it tries to log the number of reclaimed chunks while the
server is shuttingdown.  Workaround this by adding rcu_barrier() before
shuttingdown the global log context.
2025-08-04 11:29:54 +02:00
Ondřej Surý
f7e5c1db38
Change the 'isc_g_mctx' to be always available
This required couple of internal changes to the isc_mem_debugging.

The isc_mem_debugging is now internal to isc_mem unit and there are
three new functions:

1. isc_mem_setdebugging() can change the debugging setting for an
   individual memory context.  This is need for the memory contexts used
   for OpenSSL, libxml and libuv accounting as recording and tracing
   memory is broken there.

2. isc_mem_debugon() / isc_mem_debugoff() can be used to change default
   memory debugging flags as well as debugging flags for isc_g_mctx.

Additionally, the memory debugging is inconsistent across the code-base.
For now, we are keeping the existing flags, but three new environment
variables have been added 'ISC_MEM_DEBUGRECORD', 'ISC_MEM_DEBUGTRACE'
and 'ISC_MEM_DEBUGUSAGE' to set the global debugging flags at any
program using the memory contexts.
2025-08-04 11:29:50 +02:00
Ondřej Surý
74726b3313
Add and use global memory context called isc_g_mctx
Instead of having individual memory contexts scattered across different
files and called different names, add a single memory context called
isc_g_mctx that replaces named_g_mctx and various other global memory
contexts in various utilities and tests.
2025-08-04 11:29:26 +02:00
Mark Andrews
719bb9443a fix: usr: Prevent spurious validation failures
Under rare circumstances, validation could fail if multiple clients simultaneously iterated the same set of signatures.

References #3014

Merge branch '3014-validator-c-check_signer-fails-to-call-dns_rdataset_clone' into 'main'

See merge request isc-projects/bind9!5578
2025-08-01 21:17:46 +10:00
Mark Andrews
8aa130f253 validator.c:check_signer now clones val->sigrdataset
Spurious validation failures were traced back to check_signer looping
over val->sigrdataset directly.  Cloning val->sigrdataset prevents
check_signer from interacting with callers that are also looping
over val->sigrdataset.
2025-07-31 19:21:32 -07:00
Evan Hunt
321aa313c4 fix: dev: convert dnssec system tests to python
Most of the shell-based tests in the `dnssec` system test have been converted to python.  The only exceptions are the test cases that exercised the `dnssec-*` command line tools, and did not interact with a name server; those have been relocated into a new `dnssectools` system test.

Merge branch 'each-convert-dnssec-test' into 'main'

See merge request isc-projects/bind9!10688
2025-07-31 20:34:56 +00:00
Nicki Křížek
53be3af05c Use nsX fixtures rather than servers
Rather than using servers["nsX"] syntax, utilize the nsX fixtures to
make the test code a bit more concise.

See fe5534291699572e67ad4a854b412e40c524307a
2025-07-31 12:55:40 -07:00
Nicki Křížek
d0e2487ab6 Various TTL fixes in dnssec tests
Make sure the various TTL checks are using a lower bound as well and use
a common TTL of 5 min.
2025-07-31 12:55:40 -07:00
Nicki Křížek
19941adab0 Split up dnssec validation tests to multiple modules
Put each config into a separate module to avoid interfering with other
tests.
2025-07-31 12:55:40 -07:00
Nicki Křížek
b7a2061e5f Split up badkey tests into separate modules
If nsX.reconfigure() is used in a way that might affect other tests
within the same module, it's best to split up the tests which need the
reconfig to a separate module. This ensures the reconfigure() won't
interfere with test results in case the tests are executed separately,
or in a different order.
2025-07-31 12:55:40 -07:00
Nicki Křížek
e7bd28dbf8 Parametrize dnssec/tests_badkey.py tests
Utilize test parametrization to reduce code duplication.
2025-07-31 12:55:40 -07:00
Evan Hunt
3c067e99b3 tidy up the dnssec test tree
many of the zones in the dnssec system test were identical or
had only trivial differences, and it would be easier to keep track
of them if they were sourced from template files.

also, the extra_artifacts have been simplified and restored to
the test files.
2025-07-31 12:55:40 -07:00
Evan Hunt
5a457268d1 convert delv tests to python
move all dnssec tests using delv from the shell test to tests_delv.py,
and remove tests.sh and tests_sh_dnssec.py.
2025-07-31 12:55:40 -07:00
Evan Hunt
4bd0213fe7 convert dnssec signing tests to python
the shell tests that queried servers to check correct signing
behavior (using dnssec-signzone, dnssec-policy and nsupdate),
as well as "rndc signing", private-type records, rndc zonestatus,
offline keys, etc, have been moved to tests_signing.py.

the minimal update test in the dnssec_update_test.pl script
was also moved here and the perl script has been removed.
2025-07-31 12:55:40 -07:00
Evan Hunt
950df056b3 convert dnssec validation tests to python
begin converting DNSSEC validation tests from shell to python,
and simplify the name servers used in the test.

ns4, the name server used for validation tests, is now configured
using jinja2 templates.

ns8, which was previously used for testing unsupported, disabled
and revoked keys and trust anchors, has been removed.  we now
use a jinja2 configuration in ns5 for this purpose.

the configurations in ns7 and ns6 didn't conflict with one another,
so the two servers have been merged into one.
2025-07-31 12:55:40 -07:00
Evan Hunt
8ddec41987 convert dnssec-policy tests to python
move the signatures-validity tests to tests_policy.py
2025-07-31 12:55:40 -07:00
Evan Hunt
0fabb0fbb6 convert TAT tests to python
the trust-anchor-telemetry tests have been moved to a new
python subtest, dnssec/tests_tat.py.
2025-07-31 12:55:40 -07:00
Evan Hunt
e1fa6f089b move some test cases to different system tests
- dnssec tool tests (i.e., dnssec-signzone, dnssec-keygen, etc) that
  don't require interaction with a running server have been moved
  to a new 'dnssectools' system test directory.
- a dig formatting test has been moved to digdelv.
- a named-rrchecker test has been moved to rrchecker
2025-07-31 12:55:40 -07:00
Evan Hunt
d3bfa916b3 move NTA test cases to a separate python test
the tests of "rndc nta" behavior have been moved out of the
dnssec shell test, into bin/tests/system/nta, and converted
to python. features of the dnssec test framework that were
needed for NTA testing have been moved to the nta test, and
dnssec has been correspondingly simplified.
2025-07-31 12:55:40 -07:00
Evan Hunt
bcf41973bb start converting dnssec system test to python/jinja2
- changed named.conf.in to named.conf.j2 in all server directories that
  don't currently need to use copy_setports() during the test.
- converted the tests that use ns5 to python, and replaced
  named1.conf.in and named2.conf.in with a jinja2 template instead.
  the only remaining server that still needs copy_setports() is ns4.
- removed ns4/named5.conf.in, and moved its functions to ns5 (which
  is supposed to be for servers with broken trust-anchor configurations,
  so it should have been there in the first place). converted the tests
  that used that ns4 configuration to use ns5 with jinja instead.
- revised the remaining ns4 configurations (named[1-4].conf.in) to
  minimize the differences between them. this will make it easier to
  convert it into a jinja2 template later.
2025-07-31 12:55:40 -07:00
Aydın Mercan
1563d71c1b fix: dev: reintroduce cross version tests
Merge branch 'aydin/meson-cross-version-test' into 'main'

See merge request isc-projects/bind9!10792
2025-07-31 14:54:03 +03:00
Aydın Mercan
0b309a829c
reintroduce cross version config tests
The `cross-version-config-tests` CI job had to be removed due to radical
differences between meson and autoconf. With the release of 9.21.11
this job now can be reintroduced by comparing two meson built BIND
source trees.
2025-07-31 14:17:14 +03:00
Michal Nowak
285dbc1893 fix: ci: Revert "Capture scripts for Coverity Scan analysis"
This reverts commit b4a2674d98902983e8096c99b747343482d30673.

The --fs-capture-search option is no more. The ability to analyse Python
scripts in Coverity turned out to be questionable anyways.

Closes #5456

Merge branch '5456-coverity-scan-drop-fs-capture-search-option' into 'main'

See merge request isc-projects/bind9!10808
2025-07-31 12:35:41 +02:00