]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
2 years agoFix a statschannel system test zone loadtime issue
Aram Sargsyan [Tue, 12 Dec 2023 14:54:40 +0000 (14:54 +0000)] 
Fix a statschannel system test zone loadtime issue

The check_loaded() function compares the zone's loadtime value and
an expected loadtime value, which is based on the zone file's mtime
extracted from the filesystem.

For the secondary zones there may be cases, when the zone file isn't
ready yet before the zone transfer is complete and the zone file is
dumped to the disk, so a so zero value mtime is retrieved.

In such cases wait one second and retry until timeout. Also modify
the affected check to allow a possible difference of the same amount
of seconds as the chosen timeout value.

2 years agoMerge branch '4493-data-race-in-xfrin_send_request' into 'main'
Arаm Sаrgsyаn [Mon, 18 Dec 2023 08:44:33 +0000 (08:44 +0000)] 
Merge branch '4493-data-race-in-xfrin_send_request' into 'main'

Resolve "ThreadSanitizer: data race xfrin.c:1555:2 in xfrin_send_request"

Closes #4493

See merge request isc-projects/bind9!8579

2 years agoAdd a CHANGES note for [GL #4493]
Aram Sargsyan [Fri, 15 Dec 2023 09:48:19 +0000 (09:48 +0000)] 
Add a CHANGES note for [GL #4493]

2 years agoUse atomic store operations instead of atomic initialize
Aram Sargsyan [Fri, 15 Dec 2023 09:43:36 +0000 (09:43 +0000)] 
Use atomic store operations instead of atomic initialize

The atomic_init() function makes sense to use with structure's
members when creating a new instance of a strucutre. In other
places, use atomic store operations instead, in order to avoid
data races.

2 years agoMerge branch '4467-fix-stats-export-overflow' into 'main'
Petr Špaček [Thu, 14 Dec 2023 08:13:46 +0000 (08:13 +0000)] 
Merge branch '4467-fix-stats-export-overflow' into 'main'

Avoid overflow during statistics dump

Closes #4467

See merge request isc-projects/bind9!8532

2 years agoMove atomic statscounter next to the non-atomic definition
Aydın Mercan [Mon, 11 Dec 2023 14:26:04 +0000 (17:26 +0300)] 
Move atomic statscounter next to the non-atomic definition

2 years agoUse a non-atomic counter when passing to stats dumper
Aydın Mercan [Mon, 11 Dec 2023 10:50:45 +0000 (13:50 +0300)] 
Use a non-atomic counter when passing to stats dumper

2 years agoAdd CHANGES and release note for [GL #4467]
Petr Špaček [Mon, 4 Dec 2023 15:14:31 +0000 (16:14 +0100)] 
Add CHANGES and release note for [GL #4467]

2 years agoAvoid overflow during statistics dump
Petr Špaček [Fri, 1 Dec 2023 08:29:54 +0000 (09:29 +0100)] 
Avoid overflow during statistics dump

Related: !1493
Fixes: #4467
2 years agoMerge branch '4478-redefinition-of-hmac-as-different-kind-of-symbol-on-netbsd' into...
Mark Andrews [Wed, 13 Dec 2023 23:32:41 +0000 (23:32 +0000)] 
Merge branch '4478-redefinition-of-hmac-as-different-kind-of-symbol-on-netbsd' into 'main'

Resolve "Redefinition of 'hmac' as different kind of symbol on NetBSD"

Closes #4478

See merge request isc-projects/bind9!8555

2 years agoAdd CHANGES note for [GL #4478]
Mark Andrews [Thu, 7 Dec 2023 07:11:06 +0000 (18:11 +1100)] 
Add CHANGES note for [GL #4478]

2 years agoNetBSD has added 'hmac' to libc so rename out uses of hmac
Mark Andrews [Thu, 7 Dec 2023 07:07:55 +0000 (18:07 +1100)] 
NetBSD has added 'hmac' to libc so rename out uses of hmac

2 years agoMerge branch 'pspacek/update-gitlab-issue-templates' into 'main'
Petr Špaček [Wed, 13 Dec 2023 16:30:04 +0000 (16:30 +0000)] 
Merge branch 'pspacek/update-gitlab-issue-templates' into 'main'

Update Gitlab issue templates

See merge request isc-projects/bind9!8542

2 years agoAdd Acknowledgements into Security issue template
Petr Špaček [Wed, 13 Dec 2023 08:23:42 +0000 (09:23 +0100)] 
Add Acknowledgements into Security issue template

Hopefully it will save us one round-trip with the reporter.

2 years agoFix Gitlab label in Feature request template
Petr Špaček [Tue, 5 Dec 2023 17:30:26 +0000 (18:30 +0100)] 
Fix Gitlab label in Feature request template

2 years agoModernize Gitlab Bug template
Petr Špaček [Tue, 5 Dec 2023 17:29:37 +0000 (18:29 +0100)] 
Modernize Gitlab Bug template

2 years agoAdd a default Gitlab issue template
Petr Špaček [Tue, 5 Dec 2023 17:24:00 +0000 (18:24 +0100)] 
Add a default Gitlab issue template

It's an attempt to make people use correct Gitlab templates, or use them
at all.

2 years agoMake CVE issues confidential by default
Petr Špaček [Tue, 5 Dec 2023 17:06:41 +0000 (18:06 +0100)] 
Make CVE issues confidential by default

An trivial attempt to avoid accidental disclosures.

2 years agoLabel CVE issue template as internal-use only
Petr Špaček [Tue, 5 Dec 2023 17:06:15 +0000 (18:06 +0100)] 
Label CVE issue template as internal-use only

2 years agoAdd Gitlab template for security issues
Petr Špaček [Tue, 5 Dec 2023 17:05:36 +0000 (18:05 +0100)] 
Add Gitlab template for security issues

2 years agoMerge branch 'mnowak/alpine-3.19' into 'main'
Michal Nowak [Tue, 12 Dec 2023 10:10:50 +0000 (10:10 +0000)] 
Merge branch 'mnowak/alpine-3.19' into 'main'

Add Alpine Linux 3.19

See merge request isc-projects/bind9!8562

2 years agoAdd Alpine Linux 3.19
Michal Nowak [Mon, 11 Dec 2023 10:49:40 +0000 (11:49 +0100)] 
Add Alpine Linux 3.19

2 years agoMerge branch 'matthijs-qp-lookup-iterator' into 'main'
Evan Hunt [Mon, 11 Dec 2023 21:01:46 +0000 (21:01 +0000)] 
Merge branch 'matthijs-qp-lookup-iterator' into 'main'

Follow-up on !8468, more dns_qp_lookup bug fixes related to the iterator

See merge request isc-projects/bind9!8558

2 years agoAdd CHANGES
Matthijs Mekking [Mon, 11 Dec 2023 09:34:44 +0000 (10:34 +0100)] 
Add CHANGES

2 years agoRefactor getpred code
Matthijs Mekking [Thu, 7 Dec 2023 15:55:37 +0000 (16:55 +0100)] 
Refactor getpred code

Move the code to find the predecessor into one function, as it is shares
quite some similarities: In both cases we first need to find the
immediate predecessor/successor, then we need to find the immediate
predecessor if the iterator is not already pointing at it.

2 years agoand fix yet another dns_qp_lookup() iterator bug
Matthijs Mekking [Thu, 7 Dec 2023 10:51:23 +0000 (11:51 +0100)] 
and fix yet another dns_qp_lookup() iterator bug

This one is similar to the bug when searching for a key, reaching a
dead-end branch that doesn't match, because the branch offset point
is after the point where the search key differs.

This fixes the case where we are multiple levels deep. In other
words, we had a more-than-one matches *after* the point where the
search key differs.

For example, consider the following qp-trie:

branch: "[e]", "[m]":
 - leaf: "a.b.c.d.e"
 - branch: "moo[g]", "moo[k]", "moo[n]":
   - leaf: "moog"
   - branch: "mook[e]", "mook[o]"
     - leaf: "mooker"
     - leaf: "mooko"
   - leaf: "moon"

If searching for a key "monky", we would reach the branch with
twigs "moo[k]" and "moo[n]". The key matches on the 'k' on offset=4,
and reaches the branch with twigs "mook[e]" and "mook[o]". This time
we cannot find a twig that matches our key at offset=5, there is no
twig for 'y'. The closest name we found was "mooker".

Note that on a branch it can't detect it is on a dead branch because the
key is not encapsulated in a branch node.

In the previous code we considered "mooker" to be the successor of
"monky" and so we needed to the predecessor of "mooker" to find the
predecessor for "monky". However, since the search key alread differed
before entering this branch, this is not enough. We would be left with
"moog" as the predecessor of "monky", while in this example "a.b.c.d.e"
is the actual predecessor.

Instead, we need to go up a level, find the predecessor and check
again if we are on the right branch, and repeat the process until we
are.

Unit tests to cover the scenario are now added.

2 years agoand fix another dns_qp_lookup() iterator bug
Matthijs Mekking [Thu, 7 Dec 2023 09:11:14 +0000 (10:11 +0100)] 
and fix another dns_qp_lookup() iterator bug

There was yet another edge case in which an iterator could be
positioned at the wrong node after dns_qp_lookup(). When searching for
a key, it's possible to reach a leaf that matches at the given offset,
but because the offset point is *after* the point where the search key
differs from the leaf's contents, we are now at the wrong leaf.

In other words, the bug fixed the previous commit for dead-end branches
must also be applied on matched leaves.

For example, if searching for the key "monpop", we could reach a branch
containing "moop" and "moor". the branch offset point - i.e., the point
after which the branch's leaves differ from each other - is the
fourth character ("p" or "r"). The search key matches the fourth
character "p", and takes that twig to the next node (which can be
a branch for names starting with "moop", or could be a leaf node for
"moop").

The old code failed to detect this condition, and would have
incorrectly left the iterator pointing at some successor, and not
at the predecessor of the "moop".

To find the right predecessor in this case, we need to get to the
previous branch and get the previous from there.

This has been fixed and the unit test now includes several new
scenarios for testing search names that match and unmatch on the
offset but have a different character before the offset.

2 years agoMerge branch 'mnowak/replace-danger-python-with-hazard' into 'main'
Michal Nowak [Mon, 11 Dec 2023 17:02:47 +0000 (17:02 +0000)] 
Merge branch 'mnowak/replace-danger-python-with-hazard' into 'main'

Replace danger-python with Hazard

See merge request isc-projects/bind9!8548

2 years agoHandle empty MR description in dangerfile
Tom Krizek [Fri, 8 Dec 2023 15:31:46 +0000 (16:31 +0100)] 
Handle empty MR description in dangerfile

A merge request might have no description at all (i.e. None, rather than
an empty string). This might happen when the MR is created via an API.
Check a description is present before trying to find a backport string
in it.

2 years agoImprove determining the lines added by a branch
Michał Kępień [Thu, 7 Dec 2023 12:23:22 +0000 (13:23 +0100)] 
Improve determining the lines added by a branch

Since the list of lines added to Git-tracked text files in a given
branch is not part of the Danger DSL [1], it is determined using custom
code in dangerfile.py.  The current implementation of that logic is less
than perfect as it examines the diff between the current tip of the
target branch and the source branch rather than the diff between the
merge base of the two branches and the source branch.  Consider a Git
history like this:

    *   F (target)
    ...
    *   E
    *   D
    *   C
    | * B (source)
    |/
    *   A (merge base)

If danger-python or Hazard are run for commit B, the current logic for
determining the list of added lines in dangerfile.py examines the diff
between commits F and B rather than between commits A and B.  Therefore,
the added_lines() function returns not just the lines added by commit B
on top of commit A, but also the list of lines that were removed between
commits A and F, which leads to confusing results.

Fix by using the triple-dot diff operator in the Git invocation whose
output is used as the source of information for determining the list of
lines added by a given branch.

Since Hazard fetches the target branch itself when it is run, remove the
explicit "git fetch" invocation that fetches the target branch from
GitLab (shortening its local history to a single commit in the process)
before "git diff" is invoked.

[1] https://danger.systems/js/reference.html#GitDSL

2 years agoReplace danger-python with Hazard
Michal Nowak [Tue, 5 Dec 2023 10:55:03 +0000 (11:55 +0100)] 
Replace danger-python with Hazard

Hazard is a minimal danger-python replacement.

2 years agoMerge branch 'tkrizek/set-up-version-and-release-notes-for-bind-9.19.20' into 'main'
Tom Krizek [Fri, 8 Dec 2023 15:04:58 +0000 (15:04 +0000)] 
Merge branch 'tkrizek/set-up-version-and-release-notes-for-bind-9.19.20' into 'main'

Set up version and release notes for BIND 9.19.20

See merge request isc-projects/bind9!8560

2 years agoSet up release notes for BIND 9.19.20
Tom Krizek [Fri, 8 Dec 2023 14:51:48 +0000 (15:51 +0100)] 
Set up release notes for BIND 9.19.20

2 years agoUpdate BIND version to 9.19.20-dev
Tom Krizek [Fri, 8 Dec 2023 14:51:48 +0000 (15:51 +0100)] 
Update BIND version to 9.19.20-dev

2 years agoMerge branch '4405-cleanup-resolver-nonbackoff-tries-check' into 'main'
Tom Krizek [Thu, 7 Dec 2023 12:53:32 +0000 (12:53 +0000)] 
Merge branch '4405-cleanup-resolver-nonbackoff-tries-check' into 'main'

Remove obsolete check for resolver-nonbackoff-tries

See merge request isc-projects/bind9!8557

2 years agoRemove obsolete check for resolver-nonbackoff-tries
Tom Krizek [Thu, 7 Dec 2023 12:10:58 +0000 (13:10 +0100)] 
Remove obsolete check for resolver-nonbackoff-tries

With the resolver-nonbackoff-tries statement being removed in #4405,
this check can no longer be reached and can be safely removed.

2 years agoMerge branch '4448-improve-lur-cleaning-behaviour' into 'main'
Mark Andrews [Thu, 7 Dec 2023 09:48:55 +0000 (09:48 +0000)] 
Merge branch '4448-improve-lur-cleaning-behaviour' into 'main'

Resolve "Improve LRU cleaning behaviour"

Closes #4448 and #4269

See merge request isc-projects/bind9!8516

2 years agoAdd CHANGES for [GL #4448]
Mark Andrews [Tue, 5 Dec 2023 03:54:21 +0000 (14:54 +1100)] 
Add CHANGES for [GL #4448]

2 years agoAlso cleanup the space for the rbt nodes
Mark Andrews [Tue, 5 Dec 2023 02:15:03 +0000 (13:15 +1100)] 
Also cleanup the space for the rbt nodes

As we are in overmem state we want to free more memory than we are
adding so we need to add in an allowance for the rbtnodes that may
have been added and the names stored with them.  There is the node
for the owner name and a possible ENT node if there was a node split.

2 years agoProcess the combined LRU lists in LRU order
Mark Andrews [Thu, 23 Nov 2023 04:47:35 +0000 (15:47 +1100)] 
Process the combined LRU lists in LRU order

Only cleanup headers that are less than equal to the rbt's last_used
time.  Adjust the rbt's last_used time when the target cleaning was
not achieved to the oldest value of the remaining set of headers.

When updating delegating NS and glue records last_used was not being
updated when it should have been.

When adding zero TTL records to the tail of the LRU lists set
last_used to rbtdb->last_used + 1 rather than now.  This appoximately
preserves the lists LRU order.

2 years agoMerge branch 'each-cleanup-trivia' into 'main'
Evan Hunt [Thu, 7 Dec 2023 02:40:05 +0000 (02:40 +0000)] 
Merge branch 'each-cleanup-trivia' into 'main'

assorted trivial cleanups

See merge request isc-projects/bind9!8450

2 years agoremove some long-deprecated arguments from dig
Evan Hunt [Wed, 1 Nov 2023 16:09:16 +0000 (17:09 +0100)] 
remove some long-deprecated arguments from dig

certain dig options which were deprecated and became nonoperational
several releases ago still had documentation in the dig man page and
warnings printed when they were used: these included +mapped,
+sigchase, +topdown, +unexpected, +trusted-key, and the -i and -n
options. these are now all fatal errors.

another option was described as deprecated in the man page, but
the code to print a warning was never added. it has been added now.

2 years agofix consistency check for delv +ns and +qmin
Evan Hunt [Wed, 1 Nov 2023 16:00:45 +0000 (17:00 +0100)] 
fix consistency check for delv +ns and +qmin

the code to prevent +qmin from being used without +ns was
in the wrong place, resulting in it only working correctly
if +ns was specified first.

2 years agofix unnecessary capitalization
Evan Hunt [Wed, 1 Nov 2023 07:37:44 +0000 (08:37 +0100)] 
fix unnecessary capitalization

there was a typo in the copyright header.

2 years agoremove bin/rndc/rndc.conf
Evan Hunt [Tue, 31 Oct 2023 13:25:54 +0000 (14:25 +0100)] 
remove bin/rndc/rndc.conf

this file was no longer used.

2 years agoclean up client.c
Evan Hunt [Tue, 31 Oct 2023 13:20:51 +0000 (14:20 +0100)] 
clean up client.c

- make dns_client_startresolve() static since it's only used internally
- remove outdated comments

2 years agoremove unused functions in dns_master
Evan Hunt [Mon, 2 Oct 2023 20:52:58 +0000 (13:52 -0700)] 
remove unused functions in dns_master

dns_master_dumpnode() and dns_master_dumpnodetostream() were
never used and can be removed.

2 years agoMerge branch '4405-remove-resolver-opts' into 'main'
Evan Hunt [Wed, 6 Dec 2023 21:39:05 +0000 (21:39 +0000)] 
Merge branch '4405-remove-resolver-opts' into 'main'

deprecate/remove resolver-retry-interval and resolver-nonbackoff-tries

Closes #4405

See merge request isc-projects/bind9!8448

2 years agoremove resolver-retry-interval and resolver-nonbackoff-tries
Evan Hunt [Tue, 31 Oct 2023 14:13:30 +0000 (15:13 +0100)] 
remove resolver-retry-interval and resolver-nonbackoff-tries

fully remove these options and mark them as ancient.

2 years agodeprecate resolver-retry-interval and resolver-nonbackoff-tries
Evan Hunt [Tue, 31 Oct 2023 14:09:05 +0000 (15:09 +0100)] 
deprecate resolver-retry-interval and resolver-nonbackoff-tries

these options control default timing of retries in the resolver
for experimental purposes; they are not known to useful in production
environments.  they will be removed in the future; for now, we
only log a warning if they are used.

2 years agoMerge branch 'each-qp-lookup-iterator' into 'main'
Evan Hunt [Wed, 6 Dec 2023 19:17:20 +0000 (19:17 +0000)] 
Merge branch 'each-qp-lookup-iterator' into 'main'

add an iterator argument to dns_qp_lookup()

See merge request isc-projects/bind9!8468

2 years agofix another dns_qp_lookup() iterator bug
Evan Hunt [Mon, 4 Dec 2023 19:21:40 +0000 (11:21 -0800)] 
fix another dns_qp_lookup() iterator bug

there was another edge case in which an iterator could be positioned at
the wrong node after dns_qp_lookup().  when searching for a key, it's
possible to reach a dead-end branch that doesn't match, because the
branch offset point is *after* the point where the search key differs
from the branch's contents.

for example, if searching for the key "mop", we could reach a branch
containing "moon" and "moor". the branch offset point - i.e., the
point after which the branch's leaves differ from each other - is the
fourth character ("n" or "r"). however, both leaves differ from the
search key at position *three* ("o" or "p"). the old code failed to
detect this condition, and would have incorrectly left the iterator
pointing at some lower value and not at "moor".

this has been fixed and the unit test now includes this scenario.

2 years agofix dns_qp_lookup() iterator bug
Evan Hunt [Sun, 3 Dec 2023 22:02:29 +0000 (14:02 -0800)] 
fix dns_qp_lookup() iterator bug

in some cases it was possible for the iterator to be positioned in the
wrong place by dns_qp_lookup(). previously, when a leaf node was found
which matched the search key at its parent branch's offset point, but
did not match after that point, the code incorrectly assumed the leaf
it had found was a successor to the searched-for name, and stepped the
iterator back to find a predecessor.  however, it was possible for the
non-matching leaf to be the predecessor, in which case stepping the
iterator back was wrong.

(for example: a branch contains "aba" and "abcd", and we are searching
for "abcde". we step down to the twig matching the letter "c" in
position 3. "abcd" is the predecessor of "abcde", so the iterator is
already correctly positioned, but because the twig was an exact match,
we would have moved it back one step to "aba".)

this previously went unnoticed due to a mistake in the qp_test unit
test, which had the wrong expected result for the test case that should
have detected the error. both the code and the test have been fixed.

2 years agoadd an iterator argument to dns_qp_lookup()
Evan Hunt [Sun, 5 Nov 2023 12:42:42 +0000 (13:42 +0100)] 
add an iterator argument to dns_qp_lookup()

the 'predecessor' argument to dns_qp_lookup() turns out not to
be sufficient for our needs: the predecessor node in a QP database
could have become "empty" (for the current version) because of an
update or because cache data expired, and in that case the caller
would have to iterate more than one step back to find the predecessor
node that it needs.

it may also be necessary for a caller to iterate forward, in
order to determine whether a node has any children.

for both of these reasons, we now replace the 'predecessor'
argument with an 'iter' argument. if set, this points to memory
with enough space for a dns_qpiter object.

when an exact match is found by the lookup, the iterator will be
pointing to the matching node. if not, it will be pointing to the
lexical predecessor of the nae that was searched for.

a dns_qpiter_current() method has been added for examining
the current value of the iterator without moving it in either
direction.

2 years agoMerge branch 'tkrizek/add-changes-entry-for-4462' into 'main'
Tom Krizek [Wed, 6 Dec 2023 16:33:51 +0000 (16:33 +0000)] 
Merge branch 'tkrizek/add-changes-entry-for-4462' into 'main'

Add CHANGES entry for #4462

See merge request isc-projects/bind9!8551

2 years agoAdd CHANGES entry for #4462
Tom Krizek [Wed, 6 Dec 2023 15:47:51 +0000 (16:47 +0100)] 
Add CHANGES entry for #4462

2 years agoMerge branch '4464-multithread-tls-initialisation-crash-fix' into 'main'
Artem Boldariev [Wed, 6 Dec 2023 15:29:05 +0000 (15:29 +0000)] 
Merge branch '4464-multithread-tls-initialisation-crash-fix' into 'main'

Fix TLS certs store deletion on concurrent access

Closes #4464

See merge request isc-projects/bind9!8531

2 years agoUpdate CHANGES [GL #4464]
Artem Boldariev [Mon, 4 Dec 2023 12:42:30 +0000 (14:42 +0200)] 
Update CHANGES [GL #4464]

Mention that BIND crashing due to a `tls` multithreaded entry
initialisation attempts has been fixed.

2 years agodoth test: add a secondary NS instance that reuses a 'tls' entry
Artem Boldariev [Mon, 4 Dec 2023 13:12:57 +0000 (15:12 +0200)] 
doth test: add a secondary NS instance that reuses a 'tls' entry

This commit extends the 'doth' system tests with additional secondary
NS instance that reuses the same 'tls' entry for connecting the the
primary to download zones. This configurations were known to crash
secondaries in some cases.

2 years agoFix TLS certs store deletion on concurrent access
Artem Boldariev [Mon, 4 Dec 2023 12:28:28 +0000 (14:28 +0200)] 
Fix TLS certs store deletion on concurrent access

During initialisation or reconfiguration, it is possible that multiple
threads are trying to create a TLS context and associated data (like
TLS certs store) concurrently. In some cases, a thread might be too
late to add newly created data to the TLS contexts cache, in which
case it needs to be discarded. In the code that handles that case, it
was not taken into account that, in some cases, the TLS certs store
could not have been created or should not be deleted, as it is being
managed by the TLS contexts cache already. Deleting the store in such
cases might lead to crashes.

This commit fixes the issue.

2 years agoMerge branch '4388-initial-proxyv2-support-in-bind-and-dig' into 'main'
Artem Boldariev [Wed, 6 Dec 2023 13:49:01 +0000 (13:49 +0000)] 
Merge branch '4388-initial-proxyv2-support-in-bind-and-dig' into 'main'

Make it possible to accept PROXYv2 in BIND (and send it in dig)

Closes #4388

See merge request isc-projects/bind9!8417

2 years agoUpdate CHANGES [GL #4388]
Artem Boldariev [Thu, 23 Nov 2023 16:50:01 +0000 (18:50 +0200)] 
Update CHANGES [GL #4388]

Mention the initial support for PROXYv2.

2 years agoUpdate release notes [GL #4388]
Artem Boldariev [Thu, 23 Nov 2023 16:44:38 +0000 (18:44 +0200)] 
Update release notes [GL #4388]

Mention the initial support for PROXYv2.

2 years agoDoH unit test: do not increase 'active_cconnects' too much
Artem Boldariev [Mon, 27 Nov 2023 21:10:36 +0000 (23:10 +0200)] 
DoH unit test: do not increase 'active_cconnects' too much

Theoretically, the value could get too big, not letting the test to
finish. This commit fixes that omission.

2 years agoSystem test for PROXYv2
Artem Boldariev [Tue, 14 Nov 2023 16:19:12 +0000 (18:19 +0200)] 
System test for PROXYv2

This commit adds a system test suite for PROXYv2. The idea on which it
is based is simple:

1. Firstly we check that 'allow-proxy' and 'allow-proxy-on' (whatever
is using the new 'isc_nmhandle_real_localaddr/peeraddr()') do what
they intended to do.

2. Anything else that needs an interface or peer address (ACL
functionality, for example) is using the old
'isc_nmhandle_localaddr/peeraddr()' - which are now returning
addresses received via PROXY (if any) instead of the real connection
addresses. The beauty of it that we DO NOT need to verify every bit of
the code relying on these functions: whatever works in one place will
work everywhere else, as these were the only functions that allowed
any higher level code to get peer and interface addresses.

This way it is relatively easy to see if PROXYv2 works as intended.

2 years agoAdd checkonf tests for the PROXYv2 related options
Artem Boldariev [Tue, 14 Nov 2023 18:33:30 +0000 (20:33 +0200)] 
Add checkonf tests for the PROXYv2 related options

This commit adds necessary PROXYv2 configuration options checks.

2 years agoAdd pre-rendered PROXY header test for PROXY over UDP
Artem Boldariev [Mon, 13 Nov 2023 20:55:46 +0000 (22:55 +0200)] 
Add pre-rendered PROXY header test for PROXY over UDP

This commit extends the PROXY over UDP transport test with
a pre-rendered PROXY header handling test.

2 years agoPROXY Stream pre-rendered PROXY handling test
Artem Boldariev [Mon, 13 Nov 2023 20:35:50 +0000 (22:35 +0200)] 
PROXY Stream pre-rendered PROXY handling test

This commit extends the PROXY Stream transport unit test suite with a
pre-rendered PROXY header handling test.

2 years agoBIND: Add 'allow-proxy' and 'allow-proxy-on' options
Artem Boldariev [Tue, 31 Oct 2023 10:39:04 +0000 (12:39 +0200)] 
BIND: Add 'allow-proxy' and 'allow-proxy-on' options

The main intention of PROXY protocol is to pass endpoints information
to a back-end server (in our case - BIND). That means that it is a
valid way to spoof endpoints information, as the addresses and ports
extracted from PROXYv2 headers, from the point of view of BIND, are
used instead of the real connection addresses.

Of course, an ability to easily spoof endpoints information can be
considered a security issue when used uncontrollably. To resolve that,
we introduce 'allow-proxy' and 'allow-proxy-on' ACL options. These are
the only ACL options in BIND that work with real PROXY connections
addresses, allowing a DNS server operator to specify from what clients
and on which interfaces he or she is willing to accept PROXY
headers. By default, for security reasons we do not allow to accept
them.

2 years agoAvoid using sock->iface and sock->peer from the lower transport
Artem Boldariev [Mon, 30 Oct 2023 17:37:34 +0000 (19:37 +0200)] 
Avoid using sock->iface and sock->peer from the lower transport

This commit modifies TLS Stream and DNS-over-HTTPS transports so that
they do not use the "sock->iface" and "sock->peer" of the lower level
transport directly.

That did not cause any problems before, as things worked as expected,
but with the introduction of PROXYv2 support we use handles to store
the information in both PROXY Stream and UDP Proxy
transports. Therefore, in order to propagate the information (like
addresses), extracted from PROXYv2 headers, from the lower level
transports to the higher-level ones, we need to get that information
from the lower-level handles rather than sockets. That means that we
should get the peer and interface addresses using the intended
APIs ("isc_nmhandle_peeraddr()" and "isc_nmhandle_localaddr()").

2 years agoAdd 'proxy' option to 'listen-on' statement
Artem Boldariev [Mon, 30 Oct 2023 15:03:30 +0000 (17:03 +0200)] 
Add 'proxy' option to 'listen-on' statement

This commit extends "listen-on" statement with "proxy" options that
allows one to enable PROXYv2 support on a dedicated listener. It can
have the following values:

- "plain" to send PROXYv2 headers without encryption, even in the case
of encrypted transports.
- "encrypted" to send PROXYv2 headers encrypted right after the TLS
handshake.

2 years agoIncrease conn. timeout in the timeout recovery tests
Artem Boldariev [Thu, 26 Oct 2023 22:43:00 +0000 (01:43 +0300)] 
Increase conn. timeout in the timeout recovery tests

Due to increased number of the NM unit tests and, thus, increased load
on the system timeout recovery tests can sometimes fail, in particular
on FreeBSD. This commit fixes that. Besides, it seems that use of
T_SOFT here was unintentional to begin with.

2 years agoDocument the new PROXY-related options for dig
Artem Boldariev [Wed, 18 Oct 2023 13:51:06 +0000 (16:51 +0300)] 
Document the new PROXY-related options for dig

This commit adds new documentation for +[no]proxy and +[no]proxy-plain
dig options.

2 years agoIntegrate PROXYv2 support into dig
Artem Boldariev [Mon, 16 Oct 2023 19:54:13 +0000 (22:54 +0300)] 
Integrate PROXYv2 support into dig

This commit adds PROXYv2 support into dig by the means of adding
+[no]proxy and +[no]proxy-plain options. Since this commit dig
supports sending PROXYv2 headers on all supported DNS-transports.

The support for PROXYv2 is modelled after that one in kdig.

2 years agoPROXY over UDP unit tests
Artem Boldariev [Fri, 13 Oct 2023 12:31:32 +0000 (15:31 +0300)] 
PROXY over UDP unit tests

This commit adds a unit test suite for the new PROXY over UDP
transport. Most of the code is reused from the UDP unit test suite, as
the new transport aims to be fully compatible with UDP on the API
level.

2 years agoRefactor UDP tests
Artem Boldariev [Wed, 11 Oct 2023 19:18:54 +0000 (22:18 +0300)] 
Refactor UDP tests

This commit mostly moves the code around to make the parts of the UDP
unit test suite reusable. That changes the unit test suite structure
to resemble that of stream based unit tests.

The motivation behind this is to reuse most of the code for the new
PROXY over UDP uni tests suite.

2 years agoAdd a utility function to dump all active sockets on a NM instance
Artem Boldariev [Tue, 26 Sep 2023 12:37:48 +0000 (15:37 +0300)] 
Add a utility function to dump all active sockets on a NM instance

Add the new isc__nm_dump_active_manager() function that can be used
for debugging purposes: it dumps all active sockets withing the
network manager instance.

2 years agoPROXYv2 over UDP transport
Artem Boldariev [Wed, 12 Jul 2023 12:25:38 +0000 (15:25 +0300)] 
PROXYv2 over UDP transport

This commit adds a new transport that supports PROXYv2 over UDP. It is
built on top of PROXYv2 handling code (just like PROXY Stream). It
works by processing and stripping the PROXYv2 headers at the beginning
of a datagram (when accepting a datagram) or by placing a PROXYv2
header to the beginning of an outgoing datagram.

The transport is built in such a way that incoming datagrams are being
handled with minimal memory allocations and copying.

2 years agoExtend DNS over HTTP(S) unit tests with PROXY over TLS checks
Artem Boldariev [Wed, 21 Jun 2023 18:50:26 +0000 (21:50 +0300)] 
Extend DNS over HTTP(S) unit tests with PROXY over TLS checks

This commit adds PROXY over TLS related checks to DNS over HTTP(S)
transport in order to ensure its compatibility with this mode.

2 years agoAdapt DNS over HTTP(S) unit tests for PROXY over TLS mode
Artem Boldariev [Wed, 21 Jun 2023 18:23:41 +0000 (21:23 +0300)] 
Adapt DNS over HTTP(S) unit tests for PROXY over TLS mode

This commit fixes the common, infrastructural code within the DNS over
HTTP unit test suite to fix and prepare it for PROXY over TLS mode.

2 years agoStreamDNS over TLS: Add PROXY over TLS tests
Artem Boldariev [Wed, 21 Jun 2023 15:35:42 +0000 (18:35 +0300)] 
StreamDNS over TLS: Add PROXY over TLS tests

This commit extends the TLS DNS unit tests suite with checks related
to PROXY over TLS support in StreamDNS.

2 years agoExtend PROXY Stream tests to include checks for PROXY over TLS
Artem Boldariev [Wed, 21 Jun 2023 13:33:13 +0000 (16:33 +0300)] 
Extend PROXY Stream tests to include checks for PROXY over TLS

This commit extends the PROXY stream unit test suite with checks
related to PROXY over TLS support within the transport.

2 years agoTLS: detect ISC_R_SHUTTINGDOWN and ISC_R_CANCELED cases properly
Artem Boldariev [Thu, 25 May 2023 15:47:07 +0000 (18:47 +0300)] 
TLS: detect ISC_R_SHUTTINGDOWN and ISC_R_CANCELED cases properly

In the previous versions of the NM, detecting the case when worker is
shutting down was not that important and actual status code did not
matter much. However, that might be not the case all the time.

This commit makes necessary modifications to the code.

2 years agoPROXY over TLS: Fix stream-based DNS transports tests support
Artem Boldariev [Thu, 25 May 2023 15:22:55 +0000 (18:22 +0300)] 
PROXY over TLS: Fix stream-based DNS transports tests support

This commit fixes the infrastructural code of the stream-based DNS
transports to take PROXY over TLS support into account.

2 years agoDoH: add PROXY over TLS support
Artem Boldariev [Fri, 19 May 2023 11:56:45 +0000 (14:56 +0300)] 
DoH: add PROXY over TLS support

This commit extends DNS over HTTP(S) transport with PROXY over TLS
support.

2 years agoStream DNS: add PROXY over TLS support
Artem Boldariev [Fri, 19 May 2023 11:28:52 +0000 (14:28 +0300)] 
Stream DNS: add PROXY over TLS support

This commit extends Stream DNS with PROXY over TLS support.

2 years agoFix TLS Stream in accordance with PROXY Stream over TLS support
Artem Boldariev [Thu, 18 May 2023 18:52:23 +0000 (21:52 +0300)] 
Fix TLS Stream in accordance with PROXY Stream over TLS support

This commit makes TLS Stream code to take PROXY Stream over TLS
support into account.

2 years agoFix common netmgr unit testing code for PROXY Stream over TLS
Artem Boldariev [Thu, 25 May 2023 11:59:50 +0000 (14:59 +0300)] 
Fix common netmgr unit testing code for PROXY Stream over TLS

This commit fixes common netmgr unit testing code to take PROXY Stream
over TLS support into account.

2 years agoAdd PROXY over TLS support to PROXY Stream
Artem Boldariev [Tue, 17 Oct 2023 17:36:58 +0000 (20:36 +0300)] 
Add PROXY over TLS support to PROXY Stream

This commit makes it possible to use PROXY Stream not only over TCP,
but also over TLS. That is, now PROXY Stream can work in two modes as
far as TLS is involved:

1. PROXY over (plain) TCP - PROXYv2 headers are sent unencrypted before
TLS handshake messages. That is the main mode as described in the
PROXY protocol specification (as it is clearly stated there), and most
of the software expects PROXYv2 support to be implemented that
way (e.g. HAProxy);

2. PROXY over (encrypted) TLS - PROXYv2 headers are sent after the TLS
handshake has happened. For example, this mode is being used (only ?)
by "dnsdist". As far as I can see, that is, in fact, a deviation from
the spec, but I can certainly see how PROXYv2 could end up being
implemented this way elsewhere.

2 years agoAdd PROXYv2 related checks to DNS over HTTP(S) unit test suite
Artem Boldariev [Thu, 11 May 2023 13:53:16 +0000 (16:53 +0300)] 
Add PROXYv2 related checks to DNS over HTTP(S) unit test suite

This commit extends DNS over HTTP(S) unit test suite with PROXYv2
related checks to ensure that the transport is compatible with that
mode.

2 years agoAdd PROXYv2 support to DNS over HTTP(S) transport
Artem Boldariev [Wed, 10 May 2023 19:01:36 +0000 (22:01 +0300)] 
Add PROXYv2 support to DNS over HTTP(S) transport

This commit extends DNS over HTTP(S) transport with PROXYv2 support.

2 years agoAdd PROXYv2 related tests for TLS DNS transport
Artem Boldariev [Tue, 9 May 2023 17:49:38 +0000 (20:49 +0300)] 
Add PROXYv2 related tests for TLS DNS transport

This commit adds a set of PROXYv2 related tests to ensure that Stream
DNS over TLS supports this mode.

2 years agoAdd PROXYv2 related tests for TCP DNS transport
Artem Boldariev [Tue, 9 May 2023 17:35:24 +0000 (20:35 +0300)] 
Add PROXYv2 related tests for TCP DNS transport

This commit adds a set of PROXYv2 related tests to ensure that Stream
DNS over TCP supports this mode.

2 years agoAdd PROXY support to Stream DNS
Artem Boldariev [Tue, 9 May 2023 12:13:05 +0000 (15:13 +0300)] 
Add PROXY support to Stream DNS

This commit makes it possible to use Stream DNS on top of PROXY Stream
either directly or indirectly (in the case when TLS is involved).

2 years agoExtend TLS Stream unit suite with PROXYv2 related tests
Artem Boldariev [Tue, 9 May 2023 16:49:40 +0000 (19:49 +0300)] 
Extend TLS Stream unit suite with PROXYv2 related tests

This commit adds a set of tests which help to verify that TLS Stream
works as expected on top of PROXY Stream.

2 years agoMake it possible to use TLS Stream on top of PROXY Stream
Artem Boldariev [Thu, 4 May 2023 20:06:23 +0000 (23:06 +0300)] 
Make it possible to use TLS Stream on top of PROXY Stream

This commit modifies TLS Stream to make it possible to use over PROXY
Stream. That is required to add PROVYv2 support into TLS-based
transports (DNS over HTTP, DNS over TLS).

2 years agoPROXY Stream: add unit test suite
Artem Boldariev [Thu, 27 Apr 2023 17:17:18 +0000 (20:17 +0300)] 
PROXY Stream: add unit test suite

This commit adds a specialised test suite for the PROXY Stream
transport by reusing most of the testing code from other unit tests
for other stream-based transports.

2 years agoPROXY Stream transport
Artem Boldariev [Thu, 16 Mar 2023 10:50:04 +0000 (12:50 +0200)] 
PROXY Stream transport

This commit adds a new stream-based transport with an interface
compatible with TCP. The transport is built on top of TCP transport
and the new PROXYv2 handling code. Despite being built on top of TCP,
it can be easily extended to work on top of any TCP-like stream-based
transport. The intention of having this transport is to add PROXYv2
support into all existing stream-based DNS transport (DNS over TCP,
DNS over TLS, DNS over HTTP) by making the work on top of this new
transport.

The idea behind the transport is simple after accepting the connection
or connecting to a remote server it enters PROXYv2 handling mode: that
is, it either attempts to read (when accepting the connection) or send
(when establishing a connection) a PROXYv2 header. After that it works
like a mere wrapper on top of the underlying stream-based
transport (TCP).

2 years agoAdd PROXY header handling unit test suite
Artem Boldariev [Fri, 3 Mar 2023 14:43:15 +0000 (16:43 +0200)] 
Add PROXY header handling unit test suite

The commit adds a fairly comprehensive unit test suite for our new
PROXYv2 handling code. The unit tests suite ensures both the
correctness of the code and ensures that the part responsible for
handling incoming headers is very strict regarding what to accept as
valid.

2 years agoAdd PROXYv2 header utilities
Artem Boldariev [Fri, 3 Mar 2023 14:42:47 +0000 (16:42 +0200)] 
Add PROXYv2 header utilities

This commit adds a set of utilities for dealing with PROXYv2 headers,
both parsing and generating them. The code has no dependencies from
the networking code and is (for the most part) a "separate library".

The part responsible for handling incoming PROXYv2 headers is
structured as a state machine which accepts data as input and calls a
callback to notify the upper-level code about the data processing
status.

Such a design, among other things, makes it easy to write a thorough
unit test suite for that, as there are fewer dependencies as well as
will not stand in the way of any changes in the networking code.