]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoMerge branch 'mnowak/make-openbsd-allow_failure-true' into 'main'
Michal Nowak [Tue, 28 Feb 2023 10:27:17 +0000 (10:27 +0000)] 
Merge branch 'mnowak/make-openbsd-allow_failure-true' into 'main'

Do not fail pipeline because of failed OpenBSD system test

See merge request isc-projects/bind9!7609

3 years agoDo not fail pipeline because of failed OpenBSD system test
Michal Nowak [Mon, 27 Feb 2023 18:22:52 +0000 (19:22 +0100)] 
Do not fail pipeline because of failed OpenBSD system test

System test on OpenBSD is unstable even when test parallelism is
disabled.

3 years agoRevert "Disable OpenBSD system test parallelism in CI"
Michal Nowak [Mon, 27 Feb 2023 18:21:58 +0000 (19:21 +0100)] 
Revert "Disable OpenBSD system test parallelism in CI"

This reverts commit d73eba57bd03dce575f4cf4e42c80e1bced08bed.

3 years agoMerge branch '3837-cds-digest-type' into 'main'
Matthijs Mekking [Tue, 28 Feb 2023 10:01:50 +0000 (10:01 +0000)] 
Merge branch '3837-cds-digest-type' into 'main'

Add cds-digest-type configuration option

Closes #3837

See merge request isc-projects/bind9!7457

3 years agoTest dnssec-signzone -G digests
Matthijs Mekking [Mon, 27 Feb 2023 12:40:01 +0000 (13:40 +0100)] 
Test dnssec-signzone -G digests

Add test cases for the new dnssec-signzone -G option.

3 years agoRequire to be dereferenced arguments are non-NULL
Matthijs Mekking [Wed, 22 Feb 2023 11:12:15 +0000 (12:12 +0100)] 
Require to be dereferenced arguments are non-NULL

The function 'dns_dnssec_syncupdate()' is dereferencing arguments
'keys' and 'rmkeys'. There should be a REQUIRE that those are not
null pointers.

3 years agodnssec-signzone can now create multiple CDS RRs
Matthijs Mekking [Tue, 21 Feb 2023 07:50:04 +0000 (08:50 +0100)] 
dnssec-signzone can now create multiple CDS RRs

Change the commandline option -G to take a string that determines what
sync records should be published. It is a comma-separated string with
each element being either "cdnskey", or "cds:<algorithm>", where
<algorithm> is a valid digest type. Duplicates are suppressed.

3 years agoUpdate syncupdate() function to disable CDNSKEY
Matthijs Mekking [Tue, 21 Feb 2023 07:46:43 +0000 (08:46 +0100)] 
Update syncupdate() function to disable CDNSKEY

Add a new function argument so you can choose whether the CDNSKEY
record should be published or not.

3 years agoFix dns_kasp_attach / dns_kasp_detach usage
Mark Andrews [Tue, 21 Feb 2023 01:15:01 +0000 (12:15 +1100)] 
Fix dns_kasp_attach / dns_kasp_detach usage

The kasp pointers in dns_zone_t should consistently be changed by
dns_kasp_attach and dns_kasp_detach so the usage is balanced.

3 years agoSuppress duplicate digest types
Matthijs Mekking [Mon, 13 Feb 2023 15:11:46 +0000 (16:11 +0100)] 
Suppress duplicate digest types

When adding CDS digest types to the kasp structure, check for
duplicates.

3 years agoAdd 'dns_dnssec_syncupdate' argument descriptions
Matthijs Mekking [Mon, 13 Feb 2023 13:36:20 +0000 (14:36 +0100)] 
Add 'dns_dnssec_syncupdate' argument descriptions

3 years agoMake cds-digest-type plural
Matthijs Mekking [Fri, 10 Feb 2023 14:18:36 +0000 (15:18 +0100)] 
Make cds-digest-type plural

Allow for configuring multiple CDS records with different digest
types (currently only SHA-256 and SHA-384 are allowed).

3 years agoNew option to dnssec-signzone to ignore sync rrs
Matthijs Mekking [Fri, 10 Feb 2023 14:05:02 +0000 (15:05 +0100)] 
New option to dnssec-signzone to ignore sync rrs

By default, CDS and CDNSKEY records are generated from the given
key list. In some cases you don't want that.

3 years agoAdd release note and change for cds-digest-type
Matthijs Mekking [Tue, 31 Jan 2023 09:59:45 +0000 (10:59 +0100)] 
Add release note and change for cds-digest-type

3 years agoUpdate code to publish CDS with other digest type
Matthijs Mekking [Tue, 31 Jan 2023 09:25:48 +0000 (10:25 +0100)] 
Update code to publish CDS with other digest type

Now that we can configure a different digest type, update the code
to honor the configuration. Update 'dns_dnssec_syncupdate' so that
the correct CDS record is published, and also when deleting CDS records,
ensure that all possible CDS records are removed from the zone.

3 years agoAdd test case for different digest type
Matthijs Mekking [Tue, 31 Jan 2023 09:20:00 +0000 (10:20 +0100)] 
Add test case for different digest type

Change one of the test cases to use a different digest type (4).  The
system tests and kasp script need to be updated to take into account
the new algorithm (instead of the hard coded 2).

3 years agoTest cds-digest-type configuration
Matthijs Mekking [Mon, 30 Jan 2023 11:42:33 +0000 (12:42 +0100)] 
Test cds-digest-type configuration

Add tests for good and bad configuration values in the checkconf system
test.

3 years agoAdd configuration cds-digest-type
Matthijs Mekking [Mon, 30 Jan 2023 10:20:53 +0000 (11:20 +0100)] 
Add configuration cds-digest-type

Add the 'cds-digest-type' configuration option to 'dnssec-policy'.

3 years agoAdd functions to set CDS digest-type
Matthijs Mekking [Mon, 30 Jan 2023 10:18:42 +0000 (11:18 +0100)] 
Add functions to set CDS digest-type

BIND dnssec-policy currently only supports CDS digest-type 2. Add
API functions to allow other digest-types.

3 years agoFix CDS/CDSNKEY publication logging
Matthijs Mekking [Mon, 30 Jan 2023 09:51:06 +0000 (10:51 +0100)] 
Fix CDS/CDSNKEY publication logging

The CDS and CDNSKEY "is published" logs were mixed up (CDNSKEY was
logged when CDS was published and vice versa).

3 years agoMerge branch '3891-fix-dnsrps-code' into 'main'
Michał Kępień [Tue, 28 Feb 2023 08:17:30 +0000 (08:17 +0000)] 
Merge branch '3891-fix-dnsrps-code' into 'main'

Fix DNSRPS code after struct dns_db refactoring

Closes #3891

See merge request isc-projects/bind9!7595

3 years agoFix DNSRPS code after struct dns_db refactoring
Michał Kępień [Tue, 28 Feb 2023 08:16:05 +0000 (09:16 +0100)] 
Fix DNSRPS code after struct dns_db refactoring

Commits ffa4757c792579e3bc8316df6ce4f47093e0bde3 and
77e7eac54c51c5e23bf6e0349237442ea105d02a inadvertently broke
DNSRPS-enabled builds:

  - the new member of struct dns_db that holds a reference count for the
    database is called 'references', not 'refcount',

  - a syntax error was introduced in the designated initializer for
    'rpsdb_rdataset_methods',

  - rpsdb_destroy() no longer takes a 'dbp' argument.

Address all of the above issues to make DNSRPS-enabled builds work
again.

3 years agoMerge branch '3902-fetchlimit-system-test-failed' into 'main'
Mark Andrews [Tue, 28 Feb 2023 07:23:00 +0000 (07:23 +0000)] 
Merge branch '3902-fetchlimit-system-test-failed' into 'main'

Resolve "'fetchlimit' system test failed"

Closes #3902

See merge request isc-projects/bind9!7615

3 years agoFix 'checking drop statistics' test
Mark Andrews [Tue, 28 Feb 2023 03:24:20 +0000 (14:24 +1100)] 
Fix 'checking drop statistics' test

Wait for the desired log message to appear in ns3/named.stats rather
than the creation of the file.

3 years agoFix 'lame server clients are dropped below the hard limit' test
Mark Andrews [Tue, 28 Feb 2023 03:10:56 +0000 (14:10 +1100)] 
Fix 'lame server clients are dropped below the hard limit' test

The test was setting a minimum count for recursive clients which
was not always being met (e.g. 91 instead of 100) producing a false
positive.  Lower the lower bound on recursive clients for this
test to 1.

3 years agoMerge branch 'fanf-qp-import' into 'main'
Tony Finch [Mon, 27 Feb 2023 14:11:05 +0000 (14:11 +0000)] 
Merge branch 'fanf-qp-import' into 'main'

Import a qp-trie implementation

See merge request isc-projects/bind9!7130

3 years agoImprove qp-trie compaction in write transactions
Tony Finch [Thu, 16 Feb 2023 21:42:04 +0000 (21:42 +0000)] 
Improve qp-trie compaction in write transactions

In general, it's better to do one thorough compaction when a batch of
work is complete, which is the way that `update` transactions work.
Conversely, `write` transactions are designed so that lots of little
transactions are not too inefficient, but they need explicit
compaction. This changes `dns_qp_compact()` so that it is easier to
compact any time that makes sense, if there isn't a better way to
schedule compaction. And `dns_qpmulti_commit()` only recycles garbage
when there is enough to make it worthwhile.

3 years agoImprove qp-trie refcount debugging
Tony Finch [Fri, 17 Feb 2023 18:28:24 +0000 (18:28 +0000)] 
Improve qp-trie refcount debugging

Add some qp-trie tracing macros which can be enabled by a
developer. These print a message when a leaf is attached or
detached, indicating which part of the qp-trie implementation
did so. The refcount methods must now return the refcount value
so it can be printed by the trace macros.

3 years agoMake the qp-trie stats logging quieter
Tony Finch [Thu, 16 Feb 2023 21:41:02 +0000 (21:41 +0000)] 
Make the qp-trie stats logging quieter

Only log when useful work was done

3 years agoRefactor qp-trie to use QSBR
Tony Finch [Thu, 22 Dec 2022 14:55:14 +0000 (14:55 +0000)] 
Refactor qp-trie to use QSBR

The first working multi-threaded qp-trie was stuck with an unpleasant
trade-off:

  * Use `isc_rwlock`, which has acceptable write performance, but
    terrible read scalability because the qp-trie made all accesses
    through a single lock.

  * Use `liburcu`, which has great read scalability, but terrible
    write performance, because I was relying on `rcu_synchronize()`
    which is rather slow. And `liburcu` is LGPL.

To get the best of both worlds, we need our own scalable read side,
which we now have with `isc_qsbr`. And we need to modify the write
side so that it is not blocked by readers.

Better write performance requires an async cleanup function like
`call_rcu()`, instead of the blocking `rcu_synchronize()`. (There
is no blocking cleanup in `isc_qsbr`, because I have concluded
that it would be an attractive nuisance.)

Until now, all my multithreading qp-trie designs have been based
around two versions, read-only and mutable. This is too few to
work with asynchronous cleanup. The bare minimum (as in epoch
based reclamation) is three, but it makes more sense to support an
arbitrary number. Doing multi-version support "properly" makes
fewer assumptions about how safe memory reclamation works, and it
makes snapshots and rollbacks simpler.

To avoid making the memory management even more complicated, I
have introduced a new kind of "packed reader node" to anchor the
root of a version of the trie. This is simpler because it re-uses
the existing chunk lifetime logic - see the discussion under
"packed reader nodes" in `qp_p.h`.

I have also made the chunk lifetime logic simpler. The idea of a
"generation" is gone; instead, chunks are either mutable or
immutable. And the QSBR phase number is used to indicate when a
chunk can be reclaimed.

Instead of the `shared_base` flag (which was basically a one-bit
reference count, with a two version limit) the base array now has a
refcount, which replaces the confusing ad-hoc lifetime logic with
something more familiar and systematic.

3 years agoSome minor qp-trie improvements
Tony Finch [Fri, 6 Jan 2023 19:10:19 +0000 (19:10 +0000)] 
Some minor qp-trie improvements

Adjust the dns_qp_memusage() and dns_qp_compact() functions
to be more informative and flexible about handling fragmentation.

Avoid wasting space in runt chunks.

Switch from twigs_mutable() to cells_immutable() because that is the
sense we usually want.

Drop the redundant evacuate() function and rename evacuate_twigs() to
evacuate(). Move some chunk test functions closer to their point of
use.

Clarify compact_recursive(). Some small cleanups to comments.

Use isc_time_monotonic() for qp-trie timing stats.

Use #define constants to control debug logging.

Set up DNS name label offsets in dns_qpkey_fromname() so it is easier
to use in cases where the name is not fully hydrated.

3 years agoqp-trie naming improvements
Tony Finch [Fri, 6 Jan 2023 18:25:34 +0000 (18:25 +0000)] 
qp-trie naming improvements

Adjust to typename_operation style
s/VALID_QP/QP_VALID/g
s/QP_VALIDMULTI/QPMULTI_VALID/g

Improved greppability
s/\bctx\b/uctx/g

Less cluttered logging
s/QP_TRACE/TRACE/g
s/QP_LOG_STATS/LOG_STATS/g

3 years agoBenchmarks for the qp-trie
Tony Finch [Wed, 28 Sep 2022 15:56:46 +0000 (16:56 +0100)] 
Benchmarks for the qp-trie

The main benchmark is `qpmulti`, which exercizes the qp-trie
transactional API with differing numbers of threads and differing data
sizes, to get some idea of how its performance scales.

The `load-names` benchmark compares the times to populate and query
and the memory used by various BIND data structures: qp-trie, hash
table (chained), hash map (closed), and red-black tree.

The `qp-dump` program is a test utility rather than a benchmark. It
populates a qp-trie and prints it out, either in an ad-hoc text
format, or as input to the graphviz `dot` program.

3 years agoFuzz testing the qp-trie
Tony Finch [Sun, 12 Jun 2022 14:52:35 +0000 (15:52 +0100)] 
Fuzz testing the qp-trie

Ensure dns_qpkey_fromname() and dns_qpkey_toname() are inverses.

Excercise a single-threaded dns_qp_t with a fixed set of random keys
and a small chunk size. Use the table of names to ensure that the trie
is behaving as expected. This is (in effect) randomized testing like
the `qpmulti` unit test, but making use of coverage-guided fuzzing
and (in principle) test case minimization.

3 years agoTest the qp-trie transactional API
Tony Finch [Thu, 6 Oct 2022 14:59:14 +0000 (15:59 +0100)] 
Test the qp-trie transactional API

Randomized testing with intensive consistency and correctness checks
make it much easier to get good coverage and to shake out bugs than
hand-written unit tests for specific cases.

These tests only run in a single thread, but each test transaction
uses both a write/update and a query/snapshot, to ensure that
modifications are not visible to concurrent readers.

3 years agoTest infrastructure for the qp-trie
Tony Finch [Tue, 14 Jun 2022 15:20:28 +0000 (16:20 +0100)] 
Test infrastructure for the qp-trie

This change adds a number of support routines for the unit tests, and
for benchmarks and fuzz tests to be added later. It isn't necessary to
include the support routines in libdns, since they are not needed by
BIND's installed programs. So `libtest` seems like the best place for
them.

The tests themselves verify that dns_qpkey_fromname() behaves as
expected.

3 years agoFix qp-trie refcounting mistake
Tony Finch [Wed, 22 Feb 2023 18:08:26 +0000 (18:08 +0000)] 
Fix qp-trie refcounting mistake

The error occurred when:

  * The bump chunk was re-used across multiple write transactions.
    In this situation the bump chunk is marked immutable, but the
    immutable flag is disregarded for cells after the fender, which
    were allocated in the current transaction.

  * The bump chunk fills up during an insert operation, so that the
    enlarged twigs vector is allocated from a new bump chunk.

  * Before this happened, we should have (but didn't) made the twigs
    vector mutable. This would have adjusted its refcounts as necessary.

  * However, moving to a new bump chunk has a side effect: twigs that
    were previously considered mutable because they are after the
    fender become immutable.

  * Because of this, the old twigs vector was not destroyed as expected.

  * So leaves were duplicated without their refcounts being increased.

The effect is that the refcounts were lower than they should have
been, and underflowed. The tests failed to check for refcount
underflow, so this mistake was detected much later than it ideally
could have been.

After the fix, it is now correct not to ensure the twigs are mutable,
because they are about to be copied to a larger vector. Instead, we
need to find out whether `squash_twigs()` destroyed the old twigs, and
adjust the refcounts accordingly.

3 years agoAdd a qp-trie data structure
Tony Finch [Mon, 9 May 2022 13:31:35 +0000 (14:31 +0100)] 
Add a qp-trie data structure

A qp-trie is a kind of radix tree that is particularly well-suited to
DNS servers. I invented the qp-trie in 2015, based on Dan Bernstein's
crit-bit trees and Phil Bagwell's HAMT. https://dotat.at/prog/qp/

This code incorporates some new ideas that I prototyped using
NLnet Labs NSD in 2020 (optimizations for DNS names as keys)
and 2021 (custom allocator and garbage collector).
https://dotat.at/cgi/git/nsd.git

The BIND version of my qp-trie code has a number of improvements
compared to the prototype developed for NSD.

  * The main omission in the prototype was the very sketchy outline of
    how locking might work. Now the locking has been implemented,
    using a reader/writer lock and a mutex. However, it is designed to
    benefit from liburcu if that is available.

  * The prototype was designed for two-version concurrency, one
    version for readers and one for the writer. The new code supports
    multiversion concurrency, to provide a basis for BIND's dbversion
    machinery, so that updates are not blocked by long-running zone
    transfers.

  * There are now two kinds of transaction that modify the trie: an
    `update` aims to support many very small zones without wasting
    memory; a `write` avoids unnecessary allocation to help the
    performance of many small changes to the cache.

  * There is also a single-threaded interface for situations where
    concurrent access is not necessary.

  * The API makes better use of types to make it more clear which
    operations are permitted when.

  * The lookup table used to convert a DNS name to a qp-trie key is
    now initialized by a run-time constructor instead of a programmer
    using copy-and-paste. Key conversion is more flexible, so the
    qp-trie can be used with keys other than DNS names.

  * There has been much refactoring and re-arranging things to improve
    the terminology and order of presentation in the code, and the
    internal documentation has been moved from a comment into a file
    of its own.

Some of the required functionality has been stripped out, to be
brought back later after the basics are known to work.

  * Garbage collector performance statistics are missing.

  * Fancy searches are missing, such as longest match and
    nearest match.

  * Iteration is missing.

  * Search for update is missing, for cases where the caller needs to
    know if the value object is mutable or not.

3 years agoSupport for relative names in unit tests
Evan Hunt [Thu, 9 Jun 2022 19:29:58 +0000 (12:29 -0700)] 
Support for relative names in unit tests

The dns_test_namefromstring() function can now generate relative
names, and all the tests that used it before it have been updated
to use FQDNs.

3 years agoMerge branch '3900-placeholder' into 'main'
Arаm Sаrgsyаn [Mon, 27 Feb 2023 13:20:19 +0000 (13:20 +0000)] 
Merge branch '3900-placeholder' into 'main'

Add a CHANGES placeholder for [GL #3900]

See merge request isc-projects/bind9!7606

3 years agoAdd a CHANGES placeholder for [GL #3900]
Aram Sargsyan [Mon, 27 Feb 2023 13:10:22 +0000 (13:10 +0000)] 
Add a CHANGES placeholder for [GL #3900]

3 years agoMerge branch 'fanf-dns-name-maxlabels' into 'main'
Tony Finch [Mon, 27 Feb 2023 12:08:52 +0000 (12:08 +0000)] 
Merge branch 'fanf-dns-name-maxlabels' into 'main'

Define DNS_NAME_MAXLABELS and DNS_NAME_LABELLEN

See merge request isc-projects/bind9!7598

3 years agoDefine DNS_NAME_MAXLABELS and DNS_NAME_LABELLEN
Tony Finch [Fri, 24 Feb 2023 08:10:20 +0000 (08:10 +0000)] 
Define DNS_NAME_MAXLABELS and DNS_NAME_LABELLEN

Some qp-trie operations will need to know the maximum number of labels
in a name, so I wanted a standard macro definition with the right
value.

Replace DNS_MAX_LABELS from <dns/resolver.h with DNS_NAME_MAXLABELS in
<dns/name.h>, and add its counterpart DNS_NAME_LABELLEN.

Use these macros in `name.c` and `resolver.c`.

Fix an off-by-one error in an assertion in `dns_name_countlabels()`.

3 years agoMerge branch '3777-fix-crash-after-failed-ixfr-from-differences' into 'main'
Arаm Sаrgsyаn [Mon, 27 Feb 2023 11:25:00 +0000 (11:25 +0000)] 
Merge branch '3777-fix-crash-after-failed-ixfr-from-differences' into 'main'

Resolve "crash after failed ixfr-from-differences on a catalog zone"

Closes #3777

See merge request isc-projects/bind9!7431

3 years agoAdd a CHANGES note for [GL #3777]
Aram Sargsyan [Fri, 27 Jan 2023 09:38:33 +0000 (09:38 +0000)] 
Add a CHANGES note for [GL #3777]

3 years agocatz: unregister the db update-notify callback before detaching from db
Aram Sargsyan [Fri, 27 Jan 2023 08:47:52 +0000 (08:47 +0000)] 
catz: unregister the db update-notify callback before detaching from db

When detaching from the previous version of the database, make sure
that the update-notify callback is unregistered, otherwise there is
an INSIST check which can generate an assertion failure in free_rbtdb(),
which checks that there are no outstanding update listeners in the list.

There is a similar code already in place for RPZ.

3 years agoSearching catzs->zones requires a read lock
Aram Sargsyan [Fri, 27 Jan 2023 18:04:41 +0000 (18:04 +0000)] 
Searching catzs->zones requires a read lock

Lock the catzs->lock mutex before searching in the catzs->zones
hash table.

3 years agoProcess db callbacks in zone_loaddone() after zone_postload()
Aram Sargsyan [Thu, 26 Jan 2023 19:08:19 +0000 (19:08 +0000)] 
Process db callbacks in zone_loaddone() after zone_postload()

The zone_postload() function can fail and unregister the callbacks.

Call dns_db_endload() only after calling zone_postload() to make
sure that the registered update-notify callbacks are not called
when the zone loading has failed during zone_postload().

Also, don't ignore the return value of zone_postload().

3 years agoAdd a system test for [GL #3777]
Aram Sargsyan [Fri, 27 Jan 2023 09:22:11 +0000 (09:22 +0000)] 
Add a system test for [GL #3777]

Add the 'ixfr-from-differences yes;' option to trigger a failed
zone postload operation when a zone is updated but the serial
number is not updated, then issue two successive 'rndc reload'
commands to trigger the bug, which causes an assertion failure.

3 years agoMerge branch '3895-memory-leak-in-isc_hmac_init' into 'main'
Mark Andrews [Sun, 26 Feb 2023 23:17:35 +0000 (23:17 +0000)] 
Merge branch '3895-memory-leak-in-isc_hmac_init' into 'main'

Resolve "memory leak in isc_hmac_init"

Closes #3895

See merge request isc-projects/bind9!7588

3 years agoFix memory leak in isc_hmac_init
Mark Andrews [Fri, 24 Feb 2023 01:57:39 +0000 (12:57 +1100)] 
Fix memory leak in isc_hmac_init

If EVP_DigestSignInit failed 'pkey' was not freed.

3 years agoMerge branch 'aram/catz-do-not-destroy-catzs-before-catz' into 'main'
Arаm Sаrgsyаn [Fri, 24 Feb 2023 20:31:08 +0000 (20:31 +0000)] 
Merge branch 'aram/catz-do-not-destroy-catzs-before-catz' into 'main'

Make sure catz->catzs isn't destroyed before catz

See merge request isc-projects/bind9!7603

3 years agoMake sure catz->catzs isn't destroyed before catz
Aram Sargsyan [Fri, 24 Feb 2023 19:17:09 +0000 (19:17 +0000)] 
Make sure catz->catzs isn't destroyed before catz

Call dns_catz_unref_catzs() only after detaching 'catz'.

3 years agoMerge branch '3881-catz-offload' into 'main'
Ondřej Surý [Fri, 24 Feb 2023 16:11:58 +0000 (16:11 +0000)] 
Merge branch '3881-catz-offload' into 'main'

Resolve "Run the catalog zone update as an offloaded work"

Closes #3881

See merge request isc-projects/bind9!7560

3 years agoAdd CHANGES and release notes for [GL #3881]
Aram Sargsyan [Tue, 21 Feb 2023 14:39:27 +0000 (14:39 +0000)] 
Add CHANGES and release notes for [GL #3881]

3 years agoPause the catz dbiterator while processing the zone
Ondřej Surý [Thu, 23 Feb 2023 10:10:39 +0000 (11:10 +0100)] 
Pause the catz dbiterator while processing the zone

The dbiterator read-locks the whole zone and it stayed locked during
whole processing time when catz is being read.  Pause the iterator, so
the updates to catz zone are not being blocked while processing the catz
update.

3 years agoUnlock catzs during dns__catz_update_cb()
Ondřej Surý [Fri, 24 Feb 2023 09:46:00 +0000 (09:46 +0000)] 
Unlock catzs during dns__catz_update_cb()

Instead of holding the catzs->lock the whole time we process the catz
update, only hold it for hash table lookup and then release it.  This
should unblock any other threads that might be processing updates to
catzs triggered by extra incoming transfer.

3 years agoOffload catalog zone updates
Aram Sargsyan [Tue, 21 Feb 2023 14:23:38 +0000 (14:23 +0000)] 
Offload catalog zone updates

Offload catalog zone processing so that the network manager threads
are not interrupted by a large catalog zone update.

Introduce a new 'updaterunning' state alongside with 'updatepending',
like it is done in the RPZ module.

Note that the dns__catz_update_cb() function currently holds the
catzs->lock during the whole process, which is far from being optimal,
but the issue is going to be addressed separately.

3 years agoMerge branch 'aram/catz-add-shutdown-signaling' into 'main'
Ondřej Surý [Fri, 24 Feb 2023 14:08:20 +0000 (14:08 +0000)] 
Merge branch 'aram/catz-add-shutdown-signaling' into 'main'

Add shutdown signaling for catalog zones

See merge request isc-projects/bind9!7602

3 years agoAdd a CHANGES note for [GL !7571]
Aram Sargsyan [Tue, 21 Feb 2023 21:20:56 +0000 (21:20 +0000)] 
Add a CHANGES note for [GL !7571]

3 years agoAdd shutdown signaling for catalog zones
Aram Sargsyan [Tue, 21 Feb 2023 21:14:44 +0000 (21:14 +0000)] 
Add shutdown signaling for catalog zones

This change should make sure that catalog zone update processing
doesn't happen when the catalog zone is being shut down. This
should help avoid races when offloading the catalog zone updates
in the follow-up commit.

3 years agoMerge branch 'aram/catz-light-refactoring-and-reference-count-tracing' into 'main'
Ondřej Surý [Fri, 24 Feb 2023 14:06:06 +0000 (14:06 +0000)] 
Merge branch 'aram/catz-light-refactoring-and-reference-count-tracing' into 'main'

Implement reference count tracing for dns_catz_zone_t and dns_catz_zones_t

See merge request isc-projects/bind9!7570

3 years agoAdd a CHANGES note for [GL !7570]
Aram Sargsyan [Tue, 21 Feb 2023 21:10:17 +0000 (21:10 +0000)] 
Add a CHANGES note for [GL !7570]

3 years agoCall dns_catz_new_zones() only when it is needed
Aram Sargsyan [Thu, 23 Feb 2023 14:43:41 +0000 (14:43 +0000)] 
Call dns_catz_new_zones() only when it is needed

The configure_catz() function creates the catalog zones structure
for the view even when it is not needed, in which case it then
discards it (by detaching) later.

Instead, call dns_catz_new_zones() only when it is needed, i.e. when
there is no existing "previous" view with an existing 'catzs', that
is going to be reused.

3 years agoAdd reference count tracing for dns_catz_zone_t and dns_catz_zones_t
Aram Sargsyan [Tue, 21 Feb 2023 14:11:04 +0000 (14:11 +0000)] 
Add reference count tracing for dns_catz_zone_t and dns_catz_zones_t

Tracing can be activated by defining DNS_RPZ_TRACE in catz.h.

3 years agoLight refactoring of catz.c
Aram Sargsyan [Thu, 9 Feb 2023 10:32:33 +0000 (10:32 +0000)] 
Light refactoring of catz.c

* Change 'dns_catz_new_zones()' function's prototype (the order of the
  arguments) to synchronize it with the similar function in rpz.c.
* Rename 'refs' to 'references' in preparation of ISC_REFCOUNT_*
  macros usage for reference tracking.
* Unify dns_catz_zone_t naming to catz, and dns_catz_zones_t naming to
  catzs, following the logic of similar changes in rpz.c.
* Use C compound literals for structure initialization.
* Synchronize the "new zone version came too soon" log message with the
  one in rpz.c.
* Use more of 'sizeof(*ptr)' style instead of the 'sizeof(type_t)' style
  expressions when allocating or freeing memory for 'ptr'.

3 years agoMerge branch 'mnowak/freebsd-12.4' into 'main'
Michal Nowak [Fri, 24 Feb 2023 12:58:38 +0000 (12:58 +0000)] 
Merge branch 'mnowak/freebsd-12.4' into 'main'

Add FreeBSD 12.4

See merge request isc-projects/bind9!7169

3 years agoAdd FreeBSD 12.4
Michal Nowak [Tue, 6 Dec 2022 16:58:47 +0000 (17:58 +0100)] 
Add FreeBSD 12.4

3 years agoMerge branch 'mnowak/alpine-3.17' into 'main'
Michal Nowak [Fri, 24 Feb 2023 11:46:50 +0000 (11:46 +0000)] 
Merge branch 'mnowak/alpine-3.17' into 'main'

Add Alpine Linux 3.17

See merge request isc-projects/bind9!7586

3 years agoDrop date from "Regularly Tested Platforms" section
Michal Nowak [Tue, 3 Jan 2023 10:08:37 +0000 (11:08 +0100)] 
Drop date from "Regularly Tested Platforms" section

Changing the date is easy to forget and may be outdated.

3 years agoAdd Alpine Linux 3.17
Michal Nowak [Wed, 25 Jan 2023 15:55:46 +0000 (16:55 +0100)] 
Add Alpine Linux 3.17

3 years agoMerge branch 'fanf-prune-libirs' into 'main'
Tony Finch [Fri, 24 Feb 2023 10:01:05 +0000 (10:01 +0000)] 
Merge branch 'fanf-prune-libirs' into 'main'

Move irs_resconf into libdns and remove libirs

See merge request isc-projects/bind9!7463

3 years agoMove irs_resconf into libdns and remove libirs
Tony Finch [Fri, 16 Dec 2022 12:19:08 +0000 (12:19 +0000)] 
Move irs_resconf into libdns and remove libirs

`libirs` used to be a reference implementation of `getaddrinfo` and
related modern resolver APIs. It was stripped down in BIND 9.18
leaving only the `irs_resconf` module, which parses
`/etc/resolv.conf`. I have kept its include path and namespace prefix,
so it remains a little fragment of libirs now embedded in libdns.

3 years agoMerge branch 'ondrej-restore-sonarcloud-analysis' into 'main'
Ondřej Surý [Fri, 24 Feb 2023 08:53:45 +0000 (08:53 +0000)] 
Merge branch 'ondrej-restore-sonarcloud-analysis' into 'main'

Add SonarCloud GitHub Action

See merge request isc-projects/bind9!7589

3 years agoAdd SonarCloud GitHub Action
Ondřej Surý [Fri, 24 Feb 2023 07:41:51 +0000 (08:41 +0100)] 
Add SonarCloud GitHub Action

Add new SonarCloud GitHub Action and configuration; something (maybe
the way the builds were submitted) has apparently changed and the
project got deleted and the analysis wasn't working.

3 years agoMerge branch '3886-xfrin-dispatch' into 'main'
Evan Hunt [Fri, 24 Feb 2023 08:30:48 +0000 (08:30 +0000)] 
Merge branch '3886-xfrin-dispatch' into 'main'

refactor dns_xfrin to use dns_dispatch

Closes #3886

See merge request isc-projects/bind9!7573

3 years agoCHANGES for [GL #3886]
Evan Hunt [Wed, 22 Feb 2023 06:00:52 +0000 (22:00 -0800)] 
CHANGES for [GL #3886]

3 years agofix a bug in dns_dispatch_getnext()
Evan Hunt [Wed, 22 Feb 2023 19:04:12 +0000 (11:04 -0800)] 
fix a bug in dns_dispatch_getnext()

when a message arrives over a TCP connection matching an expected
QID, the dispatch is updated so it no longer expects that QID,
but continues reading. subsequent messages with the same QID are
ignored, unless the dispatch entry has called dns_dispatch_getnext()
or dns_dispatch_resume().

however, a coding error caused those functions to have no effect
when the dispatch was reading, so streams of messages with the same
QID could not be received over a single TCP connection, breaking *XFR.

this has been corrected by changing the order of operations in
tcp_dispatch_getnext() so that disp->reading isn't checked until
after the dispatch entry has been reactivated.

3 years agorefactor dns_xfrin to use dns_dispatch
Evan Hunt [Wed, 22 Feb 2023 04:14:30 +0000 (20:14 -0800)] 
refactor dns_xfrin to use dns_dispatch

the dns_xfrin module was still using the network manager directly to
manage TCP connections and send and receive messages.  this commit
changes it to use the dispatch manager instead.

3 years agoimplement refcount tracing in xfrin.c
Evan Hunt [Thu, 23 Feb 2023 18:29:33 +0000 (10:29 -0800)] 
implement refcount tracing in xfrin.c

use ISC_REFCOUNT_IMPL for dns_xfrin_ctx_t (which has been renamed
to dns_xfrin_t to keep the function names dns_xfrin_attach() and
dns_xfrin_detach() unchanged).

3 years agominor cleanups in dispatch.c
Evan Hunt [Wed, 22 Feb 2023 04:14:30 +0000 (20:14 -0800)] 
minor cleanups in dispatch.c

- simplified tcp_startrecv()
- removed a short function that was only called once
- removed an unnecessary if statement

3 years agolog the xfrin pointer address in xfrin_log()
Evan Hunt [Wed, 22 Feb 2023 05:09:05 +0000 (21:09 -0800)] 
log the xfrin pointer address in xfrin_log()

to make it easier to trace xfrin events in the log, include
the address of the dns_xfrin_t object in all xfrin log messages.

3 years agoremove dead code in dns_request
Evan Hunt [Wed, 22 Feb 2023 02:15:55 +0000 (18:15 -0800)] 
remove dead code in dns_request

the 'connected' variable in 'dns_request_create()` was always false.

3 years agomove dispatchmgr from resolver to view
Evan Hunt [Wed, 22 Feb 2023 00:34:41 +0000 (16:34 -0800)] 
move dispatchmgr from resolver to view

the 'dispatchmgr' member of the resolver object is used by both
the dns_resolver and dns_request modules, and may in the future
be used by others such as dns_xfrin. it doesn't make sense for it
to live in the resolver object; this commit moves it into dns_view.

3 years agoMerge branch 'mnowak/update_TEST_PARALLEL_JOBS_for_BSD' into 'main'
Michal Nowak [Fri, 24 Feb 2023 08:16:14 +0000 (08:16 +0000)] 
Merge branch 'mnowak/update_TEST_PARALLEL_JOBS_for_BSD' into 'main'

Disable OpenBSD system test parallelism in CI

See merge request isc-projects/bind9!7585

3 years agoDisable OpenBSD system test parallelism in CI
Michal Nowak [Wed, 22 Feb 2023 10:42:36 +0000 (11:42 +0100)] 
Disable OpenBSD system test parallelism in CI

Make OpenBSD system tests more stable by disabling parallelism in CI.

Accordingly, they will run 3-4 times longer.

3 years agoDo not set TEST_PARALLEL_JOBS in FreeBSD system test
Michal Nowak [Wed, 22 Feb 2023 10:38:45 +0000 (11:38 +0100)] 
Do not set TEST_PARALLEL_JOBS in FreeBSD system test

Setting TEST_PARALLEL_JOBS to 4 in FreeBSD system test jobs is a no-op
because it's already set to 4, one level above, on the global level.

3 years agoMerge branch 'fanf-qsbr' into 'main'
Tony Finch [Thu, 23 Feb 2023 16:43:56 +0000 (16:43 +0000)] 
Merge branch 'fanf-qsbr' into 'main'

QSBR: safe memory reclamation for lock-free data structures

See merge request isc-projects/bind9!7290

3 years agoQSBR: safe memory reclamation for lock-free data structures
Tony Finch [Thu, 29 Dec 2022 19:18:00 +0000 (19:18 +0000)] 
QSBR: safe memory reclamation for lock-free data structures

This "quiescent state based reclamation" module provides support for
the qp-trie module in dns/qp. It is a replacement for liburcu, written
without reference to the urcu source code, and in fact it works in a
significantly different way.

A few specifics of BIND make this variant of QSBR somewhat simpler:

  * We can require that wait-free access to a qp-trie only happens in
    an isc_loop callback. The loop provides a natural quiescent state,
    after the callbacks are done, when no qp-trie access occurs.

  * We can dispense with any API like rcu_synchronize(). In practice,
    it takes far too long to wait for a grace period to elapse for each
    write to a data structure.

  * We use the idea of "phases" (aka epochs or eras) from EBR to
    reduce the amount of bookkeeping needed to track memory that is no
    longer needed, knowing that the qp-trie does most of that work
    already.

I considered hazard pointers for safe memory reclamation. They have
more read-side overhead (updating the hazard pointers) and it wasn't
clear to me how to nicely schedule the cleanup work. Another
alternative, epoch-based reclamation, is designed for fine-grained
lock-free updates, so it needs some rethinking to work well with the
heavily read-biased design of the qp-trie. QSBR has the fastest read
side of the basic SMR algorithms (with no barriers), and fits well
into a libuv loop. More recent hybrid SMR algorithms do not appear to
have enough benefits to justify the extra complexity.

3 years agoMerge branch 'fanf-refcount-trace-tid' into 'main'
Tony Finch [Thu, 23 Feb 2023 14:28:34 +0000 (14:28 +0000)] 
Merge branch 'fanf-refcount-trace-tid' into 'main'

Include thread ID in refcount trace output

See merge request isc-projects/bind9!7584

3 years agoInclude thread ID in refcount trace output
Tony Finch [Wed, 22 Feb 2023 17:32:47 +0000 (17:32 +0000)] 
Include thread ID in refcount trace output

3 years agoMerge branch 'aram/catz-remove-unused-catzs-loop' into 'main'
Arаm Sаrgsyаn [Thu, 23 Feb 2023 09:39:17 +0000 (09:39 +0000)] 
Merge branch 'aram/catz-remove-unused-catzs-loop' into 'main'

Remove catzs->loop

See merge request isc-projects/bind9!7569

3 years agoRemove catzs->loop
Aram Sargsyan [Tue, 21 Feb 2023 20:57:02 +0000 (20:57 +0000)] 
Remove catzs->loop

The 'loop' member of the dns_catz_zones structure is not used.

3 years agoMerge branch '3778-empty-include' into 'main'
Evan Hunt [Wed, 22 Feb 2023 17:36:13 +0000 (17:36 +0000)] 
Merge branch '3778-empty-include' into 'main'

fix a crash from using an empty string for "include"

Closes #3778

See merge request isc-projects/bind9!7572

3 years agoremove isc_glob
Evan Hunt [Tue, 21 Feb 2023 22:39:43 +0000 (14:39 -0800)] 
remove isc_glob

the isc_glob module was originally needed to support posix-style glob
processing on Windows, but is now just an unnecessary wrapper around
glob(3). this commit removes it.

3 years agofix a crash from using an empty string for "include"
Evan Hunt [Tue, 21 Feb 2023 22:31:58 +0000 (14:31 -0800)] 
fix a crash from using an empty string for "include"

the parser could crash when "include" specified an empty string in place
of the filename. this has been fixed by returning ISC_R_FILENOTFOUND
when the string length is 0.

3 years agoMerge branch 'fanf-atomic-lists' into 'main'
Tony Finch [Wed, 22 Feb 2023 17:05:51 +0000 (17:05 +0000)] 
Merge branch 'fanf-atomic-lists' into 'main'

Simple lock-free singly-linked stack

See merge request isc-projects/bind9!7470

3 years agoUse atomic stack for async job queue
Ondřej Surý [Mon, 20 Feb 2023 15:16:07 +0000 (16:16 +0100)] 
Use atomic stack for async job queue

Previously, the async job queue would use a locked-list (ISC_LIST).
With introduction of atomic stack (that has to be drained at once), we
could use it to remove some contention between the threads and simplify
the async queue.

Fortunately, the reverse order still works for us - instead of append
and tail/prev operation on the list, we are now using prepend and
head/next operation on the atomic stack.

3 years agoSimple lock-free stack in <isc/stack.h>
Tony Finch [Mon, 2 Jan 2023 14:49:52 +0000 (14:49 +0000)] 
Simple lock-free stack in <isc/stack.h>

Add a singly-linked stack that supports lock-free prepend and drain (to
empty the list and clean up its elements).  Intended for use with QSBR
to collect objects that need safe memory reclamation, or any other user
that works with adding objects to the stack and then draining them in
one go like various work queues.

In <isc/atomic.h>, add an `atomic_ptr()` macro to make type
declarations a little less abominable, and clean up a duplicate
definition of `atomic_compare_exchange_strong_acq_rel()`

3 years agoMerge branch '3622-serve-stale-rrsig-test' into 'main'
Tom Krizek [Wed, 22 Feb 2023 12:57:09 +0000 (12:57 +0000)] 
Merge branch '3622-serve-stale-rrsig-test' into 'main'

[CVE-2022-3736] Test RRSIG queries with serve-stale enabled

Closes #3622

See merge request isc-projects/bind9!7578