Oto Šťáva [Tue, 28 May 2024 15:03:24 +0000 (17:03 +0200)]
amend! daemon/proxyv2: move PROXY protocol into its own layer
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 removes support for `PROTOLAYER_PAYLOAD_IOVEC`-type
buffers from the PROXYv2 layer, as it was unused in this context.
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.
Oto Šťáva [Thu, 23 May 2024 15:33:46 +0000 (17:33 +0200)]
daemon: merge protolayer_manager and session2 into one struct
It actually made no real sense to have these two structs 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.
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 [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