Oto Šťáva [Tue, 4 Jun 2024 08:49:49 +0000 (10:49 +0200)]
daemon/session2.h: clarify `struct session2` docs
As pointed out by @lukas.ondracek, the wording could be confusing when
mentioning *bottommost* and *topmost* layers. The original wording was
meant to reference the way the arrays in `daemon/session2.c` are laid
out, but never explicitly mentioned that, so one could be implicitly
think it was in reference to the widely known ISO/OSI or TCP/IP models,
which could be interpreted incorrectly (the layers are traditionally
laid out the other way around there).
There were a few bugs in the protolayer system that prevented us from
pausing iteration and resuming it properly. This commit should hopefully
resolve them.
Oto Šťáva [Wed, 22 May 2024 13:18:30 +0000 (15:18 +0200)]
daemon/session2: optimize allocations
A) Context-specific allocations
-------------------------------
There were two problems:
1) Some payloads are short-lived (e.g. allocated on stack) and we need
to make a copy of them if the iteration over protocol layers becomes
asynchronous.
2) The `pl_dns_stream_wrap` function used a mempool belonging to its
session-wide context. Some sessions may live for a long time, which
could potentially lead to needlessly long-lived memory allocations.
Both of these problems are solved in this commit by using a new
`knot_mm_t pool` field in `struct protolayer_iter_ctx`, which lives only
for a single submit (and survives asynchronicity). The whole pool is
then freed all at once when the `struct protolayer_iter_ctx` is
finalized.
B) Merging `struct protolayer_manager` into `struct session2`
-------------------------------------------------------------
It actually made no real sense to have the two separated. It only
introduced an extra layer of indirection and many layers actually needed
to access both anyway. This should simplify things considerably.
Oto Šťáva [Tue, 21 May 2024 17:04:38 +0000 (19:04 +0200)]
daemon/proxyv2: move PROXY protocol into its own layer
Previously, PROXYv2 handling was partially implemented in the `io.c`
unit in the `_TCP` and `_UDP` protocol layers, which technically made
very little sense. This commit moves this handling into separate
`_PROXYV2_DGRAM` and `_PROXYV2_STREAM` protocol layers, basically
encapsulating the handling of proxies in the `proxyv2.c` unit.
This commit also makes the PROXYv2 stream layer only support
`PROTOLAYER_PAYLOAD_WIRE_BUF` on its input, as other payload types were
unused and untested in this context.
Oto Šťáva [Tue, 21 May 2024 16:38:56 +0000 (18:38 +0200)]
daemon/session2: protocol layer refactors + docs
This makes some readability enhancements to the `protolayer_` API as
well as clarifies some of the documentation.
There is also a change where the definitions of protocol layer sequences
does not require a `_NULL` layer to be present at the end anymore, as
the number of layers in a sequence is determined at compile time. This
makes defining new sequences less error-prone.
Oto Šťáva [Wed, 15 May 2024 14:04:21 +0000 (16:04 +0200)]
utils/client/.clang-tidy: remove
This is a leftover from the merged CI/CD overhaul. Only relevant for
Knot Resolver 5 - in 6, the experimental client was removed in favour of
`kresctl` from `manager`.
Oto Šťáva [Thu, 16 May 2024 12:17:12 +0000 (14:17 +0200)]
manager: configurable Meson directory
This commit makes it more convenient to change the configuration of the
build directory of `kresd` when using Knot Resolver Manager. It adds a
new `./poe configure` command, which optionally takes the same arguments
as the standard `meson configure` command.
The `./poe run` command now requires running `./poe configure` at least
once to set up the build directory. If the directory has been configured
before this commit (i.e. `./poe run` has been executed at least once),
no extra action is required, as the directory structure remains the
same.
The commit also removes the `manager` configuration option from Meson as
we were not using it and it was broken and potentially confusing to
newcomers.
Oto Šťáva [Mon, 27 May 2024 10:59:51 +0000 (12:59 +0200)]
Non-trivial merge 'master-5' (see 'modules/stats')
modules/stats: adapt aggregate stats to the new hierarchical format
Knot Resolver 6 changed the structure of the stats return value, making
it more hierarchical, i.e. the returned object contains nested
"sub-objects", rather than being flat. This commit adapts the new
aggregate stats to this new structure, for consistency.
Vladimír Čunát [Mon, 20 May 2024 11:32:52 +0000 (13:32 +0200)]
modules/stats: split request.* metrics to IPv4 and IPv6
Let's have .total4 and .total6, too. Then .total could be expressed
as a sum of *three* (including .internal), so it's still counted
separately, as an exception.
Oto Šťáva [Tue, 7 May 2024 14:41:42 +0000 (16:41 +0200)]
tests/pytests/utils: handle SSLEOFError
It used to just throw BrokenPipeError, but newer versions of Python have
a separate exception for when the connection is closed in violation of
TLS rules, which Knot Resolver does deliberately so as to not waste time
on properly closing TLS connections with misbehaving peers.
Oto Šťáva [Tue, 7 May 2024 11:29:32 +0000 (13:29 +0200)]
test/pytests/test_tls: remove resumption test
Knot Resolver disables resumption on TLS <=1.2 as it is vulnerable to
replay attacks, so the test makes no sense, as that one was specifically
disabled for TLS >=1.3 (Python had no support for it at the time).
We should make a new test for this with TLS 1.3 support.
Oto Šťáva [Mon, 29 Apr 2024 13:09:01 +0000 (15:09 +0200)]
Silence Clang-Tidy
This commit makes lots of changes to the C code to appease the
Clang-Tidy linter. Some of the less obvious ones are due to C's weird
semantics regarding handling of numeric literals.
We also disable a bunch of the detections because they are
super-pedantic, arguably useless, or we have our own unwritten coding
style rules that solve the issues.
Oto Šťáva [Tue, 23 Apr 2024 14:34:08 +0000 (16:34 +0200)]
.gitlab-ci, tests, modules: adapt to knot-resolver-ci repo
This is the bulk of the CI/CD overhaul.
Most of the changes are to the `.gitlab-ci.yml` file, where the build
images used are replaced with the ones provided by the
`knot-resolver-ci` repository. Some cleanups have also been done.
The commit also adds unit testing with Knot Resolver built against
multiple versions of Knot DNS, including the `master` branch. The
`master` branch image is built nightly in the `knot-resolver-ci` repo.
We have also removed `scan-build`, as its tests change frequently, with
lots of false-positives, which are very different on each version, and
there is no good way to ignore some detections. Clang-Tidy covers some
of the same issues, and we also have Coverity Scan. Should be more than
enough.
A few config tests were also excluded in the AddressSanitizer tests,
because they produce false-positives.
Vladimír Čunát [Thu, 9 May 2024 06:36:08 +0000 (08:36 +0200)]
Resolve !1509 with 6.0 (libknot 3.4 compatibility)
- some knot_wire_next_label() calls were added since master,
so those get changed as in a083f3fe63cffbabb19e6b67848151f4bb6d623c
- some code has moved since master (to lib/resolve-produce.c),
and unfortunately the MR !1509 did change some of it,
and git was unable to handle this automatically
This merge commit is separate, only bringing !1509 and no other
changes from master, so that it's easier to understand.
Vladimír Čunát [Sat, 20 Apr 2024 07:16:29 +0000 (09:16 +0200)]
fixup! rrl: modify KRU api to return maximum final load value
- reordering saves 8 bytes per struct (on typical 64-bit platforms)
- don't assume that *max_load_out is initialized reasonably
(the doc-comment doesn't suggest that it's needed)
Aleš Mrázek [Thu, 21 Mar 2024 13:53:54 +0000 (14:53 +0100)]
manager: api: metrics: JSON support as default
- /metrics - returns 301, redirects to /metrics/json
- /metrics/json - exports metrics in JSON format
- /metrics/prometheus - optional, exports metrics in Prometheus format, returns 404 if not supported