2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

457 Commits

Author SHA1 Message Date
Artem Boldariev
b6cdebcf5c 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
148cfb17d5 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
69995bc7b7 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
bf3f0c45cb 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
90a00d8de2 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
c8d4f3b565 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
9a7e30b1ca 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.
2023-12-06 15:15:25 +02:00
Artem Boldariev
eb52015db1 Stream DNS: add PROXY over TLS support
This commit extends Stream DNS with PROXY over TLS support.
2023-12-06 15:15:25 +02:00
Artem Boldariev
e5852bea1c 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
fee8b0d8d5 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
eccc3fe0a0 Add PROXYv2 support to DNS over HTTP(S) transport
This commit extends DNS over HTTP(S) transport with PROXYv2 support.
2023-12-06 15:15:24 +02:00
Artem Boldariev
d199265e95 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
96ba4d2a9a 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
e97903ca14 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).
2023-12-06 15:15:24 +02:00
Artem Boldariev
2020dce326 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
4437096ba0 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).
2023-12-06 15:15:24 +02:00
Artem Boldariev
4330014fce 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.
2023-12-06 15:15:24 +02:00
Artem Boldariev
7d9a8ddc00 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.
2023-12-06 15:15:24 +02:00
Matthijs Mekking
a759f7f33c Change max NSEC3 iterations in unit tests to 50
The nsec3 unit test needs to be adjusted to accept a lower maximum value
for NSEC3 iterations.
2023-12-05 14:58:58 +00:00
Ondřej Surý
0b865c781a
Add isc_mem_overmem unit test
The new unit isc_mem_overmem unit test sets hi and lo water marks and
then does allocations to go over:

0. x < lo_water
1. lo_water < x < hi_water
2. x > hi_water
3. lo_water < x < hi_water
4. < lo_water
2023-11-29 14:16:20 +01:00
Ondřej Surý
14bdd21e0a
Refactor the handling of isc_mem overmem condition
Previously, there were two methods of working with the overmem
condition:

1. hi/lo water callback - when the overmem condition was reached
   for the first time, the water callback was called with HIWATER
   mark and .is_overmem boolean was set internally.  Similarly,
   when the used memory went below the lo water mark, the water
   callback would be called with LOWATER mark and .is_overmem
   was reset.  This check would be called **every** time memory
   was allocated or freed.

2. isc_mem_isovermem() - a simple getter for the internal
   .is_overmem flag

This commit refactors removes the first method and move the hi/lo water
checks to the isc_mem_isovermem() function, thus we now have only a
single method of checking overmem condition and the check for hi/lo
water is removed from the hot path for memory contexts that doesn't use
overmem checks.
2023-11-29 14:16:20 +01:00
Mark Andrews
cbfcdbc199 Adjust message buffer sizes in test code 2023-11-16 11:22:02 +11:00
Ondřej Surý
17da9fed58
Remove AES algorithm for DNS cookies
The AES algorithm for DNS cookies was being kept for legacy reasons, and
it can be safely removed in the next major release.  Remove both the AES
usage for DNS cookies and the AES implementation itself.
2023-11-15 10:31:16 +01:00
Ondřej Surý
aa393b9e57
Bump the timeouts in the dispatch_test
The client connection timeout was set to just one second, which might
not be enough on busy systems (and the CI machines are oh-boy-busy).
Bump the server timeouts to 10 seconds and client timeouts to 5 seconds,
this will make the unit test run a little bit longer, but it should be
more reliable.
2023-10-27 12:55:51 +02:00
Ondřej Surý
b7e793b84c
Add tests/dns/badcache.out to .gitignore 2023-10-27 12:55:51 +02:00
Tom Krizek
4cb8b13987
Reformat shell scripts with shfmt
All changes in this commit were automated using the command:

  shfmt -w -i 2 -ci -bn . $(find . -name "*.sh.in")

By default, only *.sh and files without extension are checked, so
*.sh.in files have to be added additionally. (See mvdan/sh#944)
2023-10-26 10:23:50 +02:00
Ondřej Surý
d246aa02a6
Add dispatch_getcp and dispatch_newtcp tests
Refactor the dispatch unit test to use more local variables (previously
dispatchmgr, dispatch and dispentry were all global), and add two new
tests:

* dispatch_getcp - test whether the TCP connection will get reused
* dispatch_newtcp - test that the TCP connection will not get reused
                    when DNS_DISPATCHOPT_UNSHARED is in effect
2023-10-24 13:07:03 +02:00
Ondřej Surý
f213f644ed
Add option to mark TCP dispatch as unshared
The current dispatch code could reuse the TCP connection when
dns_dispatch_gettcp() would be used first.  This is problematic as the
dns_resolver doesn't use TCP connection sharing, but dns_request could
get the TCP stream that was created outside of the dns_request.

Add new DNS_DISPATCHOPT_UNSHARED option to dns_dispatch_createtcp() that
would prevent the TCP stream to be reused.  Use that option in the
dns_resolver call to dns_dispatch_createtcp() to prevent dns_request
from reusing the TCP connections created by dns_resolver.

Additionally, the dns_xfrin unit added TCP connection sharing for
incoming transfers.  While interleaving *xfr streams on a TCP connection
should work this should be a deliberate change and be property of the
server that can be controlled.  Additionally some level of parallel TCP
streams is desirable.  Revert to the old behaviour by removing the
dns_dispatch_gettcp() calls from dns_xfrin and use the new option to
prevent from sharing the transfer streams with dns_request.
2023-10-24 13:07:03 +02:00
Aram Sargsyan
b535843bb7 Fix an error in the qp_test.c unit test
In order to check whether there are enough inserted values the
code uses the 'tests' variable (loop counter), which is unreliable,
because the loop sometimes removes an item instead of inserting
one (when the randomly generated item already exists).

Instead of the loop counter, use the existing variable 'inserted',
which should indicate the correct number of the inserted items.
2023-10-19 08:46:58 +00:00
Michal Nowak
dd234c60fe
Update the source code formatting using clang-format-17 2023-10-17 17:47:46 +02:00
Ondřej Surý
b3a8f0048f Refactor dns_{acl,aclenv}_create to return void
The dns_{acl,aclenv}_create() can't fail, so change it to return void.
2023-10-13 14:44:40 +02:00
Ondřej Surý
d46d51be78 Refactor isc_radix_create to return void
The isc_radix_create() can't fail, so change it to return void.
2023-10-13 14:44:40 +02:00
Aram Sargsyan
20fdab8667 Fix undefined behaviour occurrences
The undefined behaviour was detected by LLVM 17. Fix the affected
functions definitions to match the expected function type.
2023-10-13 09:57:28 +00:00
Petr Špaček
992b87ccc1 Add qplookups test to .gitignore 2023-10-13 09:00:43 +02:00
Evan Hunt
8f6a3f47db fix a QP chain bug
depending on how the QP trie is traversed during a lookup, it is
possible for a search to terminate on a leaf which is a partial
match, without that leaf being added to the chain. to ensure the
chain is correct in this case, when a partial match condition is
detected via qpkey_compare(), we will call add_link() again, just
in case.  (add_link() will check for a duplicated node, so it will
be harmless if it was already done.)
2023-10-09 13:29:02 -07:00
Ondřej Surý
1974a91e58
Add base testing set of names for load-names benchmark
This was generated from dnsperf queryfile with following script:

    #!/usr/bin/env python3
    names = {}

    import sys

    i = 0
    for line in iter(sys.stdin.readline, ''):
	name = line.rstrip('\n')
	if not name in names:
	    names[name] = line
	    print(f"{i},{name}")
	    i += 1
	if i >= 1024*1024:
	    break
2023-10-09 21:04:21 +02:00
Ondřej Surý
9a45fd6f33
Fix hashmap part of load-names benchmark
The name_match() was errorneously converting struct item into dns_name
pointer.  Correctly retype void *node to struct item * first and then
use item.fixed.name to pass the name to dns_name_equal() function.
2023-10-09 21:04:21 +02:00
Ondřej Surý
81f48e11e4
Use read number of items instead of raw array size in load_names
The load_names benchmark expected the input CSV with domains would fill
the whole item array and it would crash when the number of lines would
be less than that.

Fix the expectations by using the real number or lines read to calculate
the array start and end position for each benchmark thread.
2023-10-09 21:04:21 +02:00
Evan Hunt
03016902dd rename dns_qp_findname_ancestor() to dns_qp_lookup()
I am weary of typing so long a name. (plus, the name has become slightly
misleading now that the DNS_QPFIND_NOEXACT option no longer exists.)
2023-09-28 00:32:44 -07:00
Evan Hunt
6231fd66af rename QP-related types to use standard BIND nomenclature
changed type names in QP trie code to match the usual convention:
 - qp_node_t -> dns_qpnode_t
 - qp_ref_t -> dns_qpref_t
 - qp_shift_t -> dns_qpshift_t
 - qp_weight_t -> dns_qpweight_t
 - qp_chunk_t -> dns_qpchunk_t
 - qp_cell_t -> dns_qpcell_t
2023-09-28 00:32:39 -07:00
Evan Hunt
4e3e61806c get predecessor name in dns_qp_findname_ancestor()
dns_qp_findname_ancestor() now takes an optional 'predecessor'
parameter, which if non-NULL is updated to contain the DNSSEC
predecessor of the name searched for. this is done by constructing
an iterator stack while carrying out the search, so it can be used
to step backward if needed.
2023-09-28 00:32:37 -07:00
Evan Hunt
606232b8d5 remove DNS_QPFIND_NOEXACT
since dns_qp_findname_ancestor() can now return a chain object, it is no
longer necessary to provide a _NOEXACT search option. if we want to look
up the closest ancestor of a name, we can just do a normal search, and
if successful, retrieve the second-to-last node from the QP chain.

this makes ancestor lookups slightly more complicated for the caller,
but allows us to simplify the code in dns_qp_findname_ancestor(), making
it easier to ensure correctness.  this was a fairly rare use case:
outside of unit tests, DNS_QPFIND_NOEXACT was only used in the zone
table, which has now been updated to use the QP chain.  the equivalent
RBT feature is only used by the resolver for cache lookups of 'atparent'
types (i.e, DS records).
2023-09-28 00:30:57 -07:00
Evan Hunt
3bf23fadb0 improvements to the QP iterator
- make iterators reversible: refactor dns_qpiter_next() and add a new
  dns_qpiter_prev() function to support iterating both forwards and
  backwards through a QP trie.
- added a 'name' parameter to dns_qpiter_next() (as well as _prev())
  to make it easier to retrieve the nodename while iterating, without
  having to construct it from pointer value data.
2023-09-28 00:30:51 -07:00
Evan Hunt
7f0242b8c7 tidy the helper functions for retrieving twigs
- the helper functions for accessing twigs beneath a branch
  (branch_twig_pos(), branch_twig_ptr(), etc) were somewhat confusing
  to read, since several of them were implemented by calling other
  helper functions. they now all show what they're really doing.
- branch_twigs_vector() has been renamed to simply branch_twigs().
- revised some unrelated comments in qp_p.h for clarity.
2023-09-28 00:30:47 -07:00
Evan Hunt
7f766ba7c4 add a node chain traversal mechanism
dns_qp_findname_ancestor() now takes an optional 'chain' parameter;
if set, the dns_qpchain object it points to will be updated with an
array of pointers to the populated nodes between the tree root and the
requested name. the number of nodes in the chain can then be accessed
using dns_qpchain_length() and the individual nodes using
dns_qpchain_node().
2023-09-28 00:30:43 -07:00
Evan Hunt
29cf7dceb7 modify dns_qp_findname_ancestor() to return found name
add a 'foundname' parameter to dns_qp_findname_ancestor(),
and use it to set the found name in dns_nametree.

this required adding a dns_qpkey_toname() function; that was
done by moving qp_test_keytoname() from the test library to qp.c.
added some more test cases and fixed bugs with the handling of
relative and empty names.
2023-09-28 07:01:13 +00:00
Evan Hunt
e68a691904 add a "qplookups" benchmark test
this loads a file containing DNS names and measures the time it takes to:
1) iterate it,
2) look up each name with dns_qp_getname()
3) look up each name with dns_qp_findname_ancestor()
4) look up a modified name based on the name, to check performance
   when the name is not found.
2023-09-27 16:24:04 -07:00
Evan Hunt
d71ebd2086 minor cleanups
- removed some commented-out code
- cleaned up uses of pval and ival that were not needed
2023-09-27 13:05:05 -07:00
Evan Hunt
232f90f005 fixed the qpmulti benchmark
the refactoring of isc_job_run() and isc_async_run() in 9.19.12
intefered with the way the qpmulti benchmark uses uv_idle.
it has now been modified to use isc_job/isc_async instead.
2023-09-27 11:51:03 -07:00
Ondřej Surý
f5af981831
Change dns_message_create() function to accept memory pools
Instead of creating new memory pools for each new dns_message, change
dns_message_create() method to optionally accept externally created
dns_fixedname_t and dns_rdataset_t memory pools.  This allows us to
preallocate the memory pools in ns_client and dns_resolver units for the
lifetime of dns_resolver_t and ns_clientmgr_t.
2023-09-24 18:07:40 +02:00