Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: add support for incoming DoQ #13280

Merged
merged 54 commits into from
Oct 16, 2023

Conversation

chbruyand
Copy link
Member

@chbruyand chbruyand commented Sep 20, 2023

Short description

A few items on the todo list:

  • have a proper retry token generation
  • have a look at which quiche configuration options do we want to make configurable to the user
  • test with async queries
  • add error stats for version errors and invalid tokens
  • add pipe error stats
  • tests: add cache hit tests
  • tests: fix checks with terminated streams with errors (dnspython doesn't notice and timeout)
  • build with doq support in the CI
  • enable doq in our packages
  • cover quiche dependance and add a DoQ guide in the documentation

Closes #9897

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@rgacogne rgacogne added this to the dnsdist-1.9 milestone Sep 20, 2023
@chbruyand chbruyand force-pushed the dnsdist-doq-quiche branch 2 times, most recently from ab81558 to bc1dc86 Compare September 22, 2023 08:40
@rgacogne
Copy link
Member

tests: fix checks with terminated streams with errors (dnspython doesn't notice and timeout)

This seems fixed with dnspython >= 2.4.0, see rthalley/dnspython#954

@rgacogne
Copy link
Member

One issue is that libquiche.a comes with BoringSSL symbols, which of course conflict with some of the ones from OpenSSL that we use for DoT and DoH. We currently work-around that by using libquiche.so so that the BoringSSL symbols are only visible inside the libquiche.so object, so Quiche is happy while not polluting the remaining namespace. But it means that we cannot statically link against libquiche.a, like we were doing for libh2o when it was not packaged by the distribution. Our options are:

  • provide libquiche.so as part of the dnsdist package, which seems awfully wrong
  • generate a separate libquiche package on all distributions for which we want to support DoQ
  • beg the distributions we care about to package Quiche, which I'm not very optimistic about.
  • ?

@zeha
Copy link
Collaborator

zeha commented Sep 22, 2023

provide libquiche.so as part of the dnsdist package, which seems awfully wrong

libpdns-quiche.so - in a per-version private directory, so more like /usr/lib/x86_64-.../dnsdist-1.9.xyz/libdnsdist-quiche.so. This is going to be ugly, but maybe the only way of doing it?

@rgacogne
Copy link
Member

Why the per-version private directory?

@zeha
Copy link
Collaborator

zeha commented Sep 22, 2023

Why the per-version private directory?

Sorry, that's a thinko. Multiple versions of the same product are irrelevant.

Would still need one .so for each product.

@rgacogne
Copy link
Member

Would still need one .so for each product.

Ah, yes, good one!

* ``idleTimeout=5``: int - Set the idle timeout, in seconds.
* ``internalPipeBufferSize=0``: int - Set the size in bytes of the internal buffer of the pipes used internally to pass queries and responses between threads. Requires support for ``F_SETPIPE_SZ`` which is present in Linux since 2.6.35. The actual size might be rounded up to a multiple of a page size. 0 means that the OS default size is used. The default value is 0, except on Linux where it is 1048576 since 1.6.0.
* ``maxInFlight=0``: int - Maximum number of in-flight queries. The default is 0, which disables out-of-order processing.
* ``congestionControlAlgo="reno"``: str - The congestion control algorithm to be chosen between ``reno``, ``cubic`` and ``bbr``

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[bbr](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@rgacogne
Copy link
Member

I pushed two commits:

  • test asynchronous queries / response with the DoQ transport
  • optionally log TLS keying material to a file with DoQ

@rgacogne
Copy link
Member

Would still need one .so for each product.

Ah, yes, good one!

For the record, this PR now builds Quiche for all supported distributions except el-7 (clang is too old for boring-sys there) and ships libdnsdist-quiche.so in our dnsdist packages.

@chbruyand chbruyand marked this pull request as ready for review September 29, 2023 09:10
@chbruyand chbruyand force-pushed the dnsdist-doq-quiche branch 2 times, most recently from 918da60 to a5ec588 Compare September 29, 2023 11:18
Copy link
Member

@omoerbeek omoerbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic local test looks good.
I'm seeing a few errors in the regression tests in debian bookworm:

FAILED test_Async.py::TestAsyncFFI::testAcceptThenDrop - doqclient.StreamRese...
FAILED test_Async.py::TestAsyncFFI::testDrop - doqclient.StreamResetError: St...
FAILED test_Async.py::TestAsyncLua::testAcceptThenDrop - doqclient.StreamRese...
FAILED test_Async.py::TestAsyncLua::testDrop - doqclient.StreamResetError: St...
FAILED test_RulesActions.py::TestAdvancedEDNSVersionRule::testBadVers - Asser...
======= 5 failed, 646 passed, 2 skipped, 7 warnings in 192.73s (0:03:12) =======

Also: the CI regression tests have quite some failures.

pdns/dnsdistdist/docs/reference/config.rst Outdated Show resolved Hide resolved
{
/* don't keep that pointer around, it will be invalidated if the buffer is ever resized */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
auto* dnsHeader = reinterpret_cast<struct dnsheader*>(unit->query.data());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should watch out for unaligned access here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked into this, and also other places where it might happen, which led to a pretty big commit: ca0346f I think we might want to make this a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a new commit taking care of potential unaligned accesses in the DoQ code. I'll open a new PR for the existing code once we have merged this one.

@omoerbeek
Copy link
Member

omoerbeek commented Sep 29, 2023

Embedded BoringSSL does not build on OpenBSD and the quiche install script has some Linuxism and fixed target locations. It's a pity quiche does not seem to be packaged on the platforms I looked at.

pdns/dnsdist-lua.cc Outdated Show resolved Hide resolved
@rgacogne
Copy link
Member

the quiche install script has some Linuxism and fixed target locations.

Do you mean builder-support/helpers/install_quiche.sh? If so I'll fix the issues, just let me know what they are :)

@omoerbeek
Copy link
Member

the quiche install script has some Linuxism and fixed target locations.

Do you mean builder-support/helpers/install_quiche.sh? If so I'll fix the issues, just let me know what they are :)

@omoerbeek omoerbeek closed this Sep 29, 2023
@rgacogne
Copy link
Member

rgacogne commented Oct 9, 2023

Rebased on master to fix a conflict.

@coveralls
Copy link

Coverage Status

coverage: 56.415%. first build when pulling d5d9573 on chbruyand:dnsdist-doq-quiche into 1e7c7f1 on PowerDNS:master.

@omoerbeek
Copy link
Member

omoerbeek commented Oct 13, 2023

There's an issue on macOS: while the link works and produces an executable, I get

....
CXXLD    dnsdist
ld: warning: -bind_at_load is deprecated on macOS
mbp:dnsdistdist otto$ ./dnsdist 
dyld[37051]: Library not loaded: /private/tmp/quiche-0.18.0/target/release/deps/libquiche.dylib
  Referenced from: <E692B5D9-8631-32A9-BDAF-BA2AD2993EC4> /Users/otto/pdns/pdns/dnsdistdist/dnsdist
  Reason: tried: '/private/tmp/quiche-0.18.0/target/release/deps/libquiche.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/tmp/quiche-0.18.0/target/release/deps/libquiche.dylib' (no such file), '/private/tmp/quiche-0.18.0/target/release/deps/libquiche.dylib' (no such file)
Abort trap: 6

when I try to run it. This is not a blocker for an alpha2 release as far as I am concerned.

It appears that after renaming/moving a library, you need to use install_name_tool:
x.diff.txt

With that, dnsdist starts up and my QUIC tests work!

Copy link
Member

@omoerbeek omoerbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this successfully on Debian bookworm and macOS and I read through the code (though not in great detail), saw two small nits in addition to my earlier comments that were already addressed. Great work!

pdns/dnsdistdist/doq.cc Outdated Show resolved Hide resolved
pdns/dnsdistdist/doq.cc Outdated Show resolved Hide resolved
@rgacogne
Copy link
Member

It appears that after renaming/moving a library, you need to use install_name_tool: x.diff.txt

With that, dnsdist starts up and my QUIC tests work!

Nice, I have pushed that change! I wonder what that tool does exactly, but that's a discussion for another day :)

@omoerbeek
Copy link
Member

Pondering how to solve the OpenBSD build, might try not using the built-in BoringSSL and just link everything against the BoringSSL package, not using LibreSSL at all.

@rgacogne rgacogne merged commit 87b575e into PowerDNS:master Oct 16, 2023
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dnsdist: Ponder DNS over QUIC support
5 participants