]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Update tuning/design documentation for DoQ and DoH3 14076/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 18 Apr 2024 15:23:30 +0000 (17:23 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 18 Apr 2024 15:23:30 +0000 (17:23 +0200)
pdns/dnsdistdist/docs/advanced/internal-design.rst
pdns/dnsdistdist/docs/advanced/tuning.rst
pdns/dnsdistdist/docs/imgs/DNSDistDoH19.png [new file with mode: 0644]
pdns/dnsdistdist/docs/imgs/DNSDistDoH3.png [new file with mode: 0644]
pdns/dnsdistdist/docs/imgs/DNSDistDoQ.png [new file with mode: 0644]
pdns/dnsdistdist/docs/reference/config.rst
pdns/dnsdistdist/docs/running.rst

index 505be769c84a5db0330abe65d632b823f5581867..7263f07336bd52e61dd08cd6597dedf50a0743b9 100644 (file)
@@ -34,19 +34,53 @@ TCP / DoT design
 
 For TCP and DoT, a single thread is created for each :func:`addLocal` and :func:`addTLSLocal` directive, listening to the incoming TCP sockets, accepting new connections and distributing them over a pipe to the TCP worker threads. These threads handle both the TCP connection with the client and the one with the backend.
 
-DoH design
-----------
+DNS over HTTP/2 design
+----------------------
+
+h2o (up to 1.7)
+^^^^^^^^^^^^^^^
 
 .. figure:: ../imgs/DNSDistDoH.png
    :align: center
    :alt: DNSDist DoH design before 1.7
 
-For DoH, two threads are created for each :func:`addDOHLocal` directive, one handling the TLS and HTTP layers, then passing the queries to the second one over a pipe. The second thread does DNS processing, applying rules and forwarding the query to the backend if needed, over UDP.
+For DNS over HTTP/2, two threads are created for each :func:`addDOHLocal` directive, one handling the TLS and HTTP layers, then passing the queries to the second one over a pipe. The second thread does DNS processing, applying rules and forwarding the query to the backend if needed, over UDP.
 Note that even if the query does not need to be passed to a backend (cache-hit, self-generated answer), the response will be passed back to the first thread via a pipe, since only that thread deals with the client.
 If the response comes from a backend, it will be picked up by the regular UDP listener for that backend, the corresponding *IDState* object located, and the response sent to the first thread over a pipe.
 
+h2o (1.7 - 1.9)
+^^^^^^^^^^^^^^^
+
 Since 1.7, if the UDP response coming from the backend has been truncated (TC bit is set), dnsdist will retry over TCP by passing the query to a TCP worker over a pipe, as was already done for incoming TCP queries. The response will then be passed back to the DoH worker thread over the same pipe that for UDP queries. That also happens if the backend is marked TCP-only, or configured for DNS over TLS, in which case the query is obviously not sent over UDP first but immediately sent to a TCP worker thread.
 
 .. figure:: ../imgs/DNSDistDoH17.png
    :align: center
    :alt: DNSDist DoH design since 1.7
+
+nghttp2 (since 1.9)
+^^^^^^^^^^^^^^^^^^^
+
+Since 1.9 incoming DNS over HTTP/2 is no longer implemented via the ``h2o`` library but by ``nghttp2`` instead. The design is roughly the same but has been simplified a bit.
+As before, if the UDP response coming from the backend has been truncated (TC bit is set), dnsdist will retry over TCP by passing the query to a TCP worker over a pipe, as was already done for incoming TCP queries. The response will then be passed back to the DoH worker thread over the same pipe that for UDP queries. That also happens if the backend is marked TCP-only, or configured for DNS over TLS, in which case the query is obviously not sent over UDP first but immediately sent to a TCP worker thread.
+
+.. figure:: ../imgs/DNSDistDoH19.png
+   :align: center
+   :alt: DNSDist DoH design since 1.9
+
+DNS over HTTP/3 design
+----------------------
+
+DNS over HTTP/3 is implemented since 1.9.0 via the ``Quiche`` library. In 1.9.x, queries received over DNS over HTTP/3 are forwarded to the backend over TCP (Do53 TCP, DoT or DoH2).
+
+.. figure:: ../imgs/DNSDistDoH3.png
+   :align: center
+   :alt: DNSDist DoH3 design since 1.9
+
+DoQ design
+----------
+
+DNS over QUIC is implemented since 1.9.0 via the ``Quiche`` library. In 1.9.x, queries received over DNS over QUIC are forwarded to the backend over TCP (Do53 TCP, DoT or DoH2).
+
+.. figure:: ../imgs/DNSDistDoQ.png
+   :align: center
+   :alt: DNSDist DoH3 design since 1.9
index ab5f59e12fa4ae5cf64a17a2c9672fb9219d3338..6fdef8cd22d78a2e4fcbaaa1004a6df415198d98 100644 (file)
@@ -62,9 +62,9 @@ Note that, since 1.7, dnsdist supports marking a backend as "TCP only", as well
    :align: center
    :alt: DNSDist UDP design for TCP-only, DoT backends
 
-For DNS over HTTPS, every :func:`addDOHLocal` directive adds a new thread dealing with incoming connections, so it might be useful to add more than one directive, as indicated above.
+For DNS over HTTPS, every :func:`addDOHLocal`/:func:`addDOH3Local` directive adds a new thread dealing with incoming connections, so it might be useful to add more than one directive, as indicated above.
 
-.. figure:: ../imgs/DNSDistDoH17.png
+.. figure:: ../imgs/DNSDistDoH19.png
    :align: center
    :alt: DNSDist DoH design
 
@@ -119,9 +119,9 @@ A different possibility is that there is not enough threads accepting new connec
 
 For incoming and outgoing DNS over TLS support, the choice of the TLS provider (OpenSSL and GnuTLS are both supported) might yield very different results depending on the exact architecture.
 
-Since 1.8.0, incoming DNS over TLS might also benefit from experimental support for TLS acceleration engines, like Intel QAT. See :func:`loadTLSEngine`, and the `tlsAsyncMode` parameter of :func:`addTLSLocal` for more information.
+Incoming DNS over TLS (since 1.8.0) and incoming DNS over HTTPS (since 1.9.0) might also benefit from experimental support for TLS acceleration engines, like Intel QAT. See :func:`loadTLSEngine`, and the `tlsAsyncMode` parameter of :func:`addTLSLocal` and :func:`addDOHLocal` for more information.
 
-Incoming and outgoing DNS over TLS, as well as outgoing DNS over HTTPS, might benefit from experimental support kernel-accelerated TLS on Linux, when supported by the kernel and OpenSSL. See the `ktls` options on :func:`addTLSLocal` and :func:`newServer` for more information. Kernel support for kTLS might be verified by looking at the counters in ``/proc/net/tls_stat``. Note that:
+Incoming and outgoing DNS over TLS, outgoing DNS over HTTPS, as well as incoming DNS over HTTPS with the ``nghttp2`` library (since 1.9.0), might benefit from experimental support kernel-accelerated TLS on Linux, when supported by the kernel and OpenSSL. See the `ktls` options on :func:`addTLSLocal`, :func:`addDOHLocal` and :func:`newServer` for more information. Kernel support for kTLS might be verified by looking at the counters in ``/proc/net/tls_stat``. Note that:
 
  * supported ciphers depend on the exact kernel version used. ``TLS_AES_128_GCM_SHA256`` might be a good option for testing purpose since it was supported pretty early
  * as of OpenSSL 3.0.7, kTLS can only be used for sending TLS 1.3 packets, not receiving them. Both sending and receiving packets should be working for TLS 1.2.
@@ -131,6 +131,15 @@ TLS performance
 
 For DNS over HTTPS and DNS over TLS, in addition to the advice above we suggest reading the :doc:`tls-sessions-management` page to learn how to improve TLS session resumption ratio, which has a huge impact on CPU usage and latency.
 
+DNS over QUIC
+-------------
+
+For DNS over QUIC, every :func:`addDOQLocal` directive adds a new thread dealing with incoming datagrams, so it might be useful to add more than one directive.
+
+.. figure:: ../imgs/DNSDistDoQ.png
+   :align: center
+   :alt: DNSDist QUIC design
+
 Rules and Lua
 -------------
 
diff --git a/pdns/dnsdistdist/docs/imgs/DNSDistDoH19.png b/pdns/dnsdistdist/docs/imgs/DNSDistDoH19.png
new file mode 100644 (file)
index 0000000..e085276
Binary files /dev/null and b/pdns/dnsdistdist/docs/imgs/DNSDistDoH19.png differ
diff --git a/pdns/dnsdistdist/docs/imgs/DNSDistDoH3.png b/pdns/dnsdistdist/docs/imgs/DNSDistDoH3.png
new file mode 100644 (file)
index 0000000..1ba620c
Binary files /dev/null and b/pdns/dnsdistdist/docs/imgs/DNSDistDoH3.png differ
diff --git a/pdns/dnsdistdist/docs/imgs/DNSDistDoQ.png b/pdns/dnsdistdist/docs/imgs/DNSDistDoQ.png
new file mode 100644 (file)
index 0000000..1914e59
Binary files /dev/null and b/pdns/dnsdistdist/docs/imgs/DNSDistDoQ.png differ
index 072ade479d2e31601155049c2d637e484309bbea..0484a2e09a7eea3c8d59c840b0a8c277c6e108f8 100644 (file)
@@ -128,7 +128,7 @@ Listen Sockets
      ``additionalAddresses``, ``ignoreTLSConfigurationErrors`` and ``keepIncomingHeaders`` options added.
 
   .. versionchanged:: 1.9.0
-     ``enableProxyProtocol``, ``library``, ``proxyProtocolOutsideTLS`` and ``readAhead`` options added.
+     ``enableProxyProtocol``, ``ktls``, ``library``, ``proxyProtocolOutsideTLS``, ``readAhead``, ``tlsAsyncMode`` options added.
 
   Listen on the specified address and TCP port for incoming DNS over HTTPS connections, presenting the specified X.509 certificate. See :doc:`../advanced/tls-certificates-management` for details about the handling of TLS certificates and keys.
   If no certificate (or key) files are specified, listen for incoming DNS over HTTP connections instead.
@@ -174,6 +174,8 @@ Listen Sockets
   * ``additionalAddresses``: list - List of additional addresses (with port) to listen on. Using this option instead of creating a new frontend for each address avoids the creation of new thread and Frontend objects, reducing the memory usage. The drawback is that there will be a single set of metrics for all addresses.
   * ``ignoreTLSConfigurationErrors=false``: bool - Ignore TLS configuration errors (such as invalid certificate path) and just issue a warning instead of aborting the whole process
   * ``library``: str - Which underlying HTTP2 library should be used, either h2o or nghttp2. Until 1.9.0 only h2o was available, but the use of this library is now deprecated as it is no longer maintained. nghttp2 is the new default since 1.9.0.
+  * ``ktls=false``: bool - Whether to enable the experimental kernel TLS support on Linux, if both the kernel and the OpenSSL library support it. Default is false.
+  * ``tlsAsyncMode=false``: bool - Whether to enable experimental asynchronous TLS I/O operations if the ``nghttp2`` library is used, ``OpenSSL`` is used as the TLS implementation and an asynchronous capable SSL engine (or provider) is loaded. See also :func:`loadTLSEngine` or :func:`loadTLSProvider` to load the engine (or provider).
   * ``readAhead``: bool - When the TLS provider is set to OpenSSL, whether we tell the library to read as many input bytes as possible, which leads to better performance by reducing the number of syscalls. Default is true.
   * ``proxyProtocolOutsideTLS``: bool - When the use of incoming proxy protocol is enabled, whether the payload is prepended after the start of the TLS session (so inside, meaning it is protected by the TLS layer providing encryption and authentication) or not (outside, meaning it is in clear-text). Default is false which means inside. Note that most third-party software like HAproxy expect the proxy protocol payload to be outside, in clear-text.
   * ``enableProxyProtocol=true``: bool - Whether to expect a proxy protocol v2 header in front of incoming queries coming from an address in :func:`setProxyProtocolACL`. Default is ``true``, meaning that queries are expected to have a proxy protocol payload if they come from an address present in the :func:`setProxyProtocolACL` ACL.
@@ -2167,7 +2169,7 @@ Other functions
 
   Load the OpenSSL engine named ``engineName``, setting the engine default string to ``defaultString`` if supplied. Engines can be used to accelerate cryptographic operations, like for example Intel QAT.
   At the moment up to a maximum of 32 loaded engines are supported, and that support is experimental.
-  Some engines might actually degrade performance unless the TLS asynchronous mode of OpenSSL is enabled. To enable it see the ``tlsAsyncMode`` parameter on :func:`addTLSLocal`.
+  Some engines might actually degrade performance unless the TLS asynchronous mode of OpenSSL is enabled. To enable it see the ``tlsAsyncMode`` parameter on :func:`addTLSLocal` and :func:`addDOHLocal`.
 
   :param string engineName: The name of the engine to load.
   :param string defaultString: The default string to pass to the engine. The exact value depends on the engine but represents the algorithms to register with the engine, as a list of  comma-separated keywords. For example "RSA,EC,DSA,DH,PKEY,PKEY_CRYPTO,PKEY_ASN1".
@@ -2179,7 +2181,7 @@ Other functions
   Load the OpenSSL provider named ``providerName``. Providers can be used to accelerate cryptographic operations, like for example Intel QAT.
   At the moment up to a maximum of 32 loaded providers are supported, and that support is experimental.
   Note that :func:`loadTLSProvider` is only available when building against OpenSSL version >= 3.0 and with the `--enable-tls-provider` configure flag on. In other cases, :func:`loadTLSEngine` should be used instead.
-  Some providers might actually degrade performance unless the TLS asynchronous mode of OpenSSL is enabled. To enable it see the ``tlsAsyncMode`` parameter on :func:`addTLSLocal`.
+  Some providers might actually degrade performance unless the TLS asynchronous mode of OpenSSL is enabled. To enable it see the ``tlsAsyncMode`` parameter on :func:`addTLSLocal` and :func:`addDOHLocal`.
 
   :param string providerName: The name of the provider to load.
 
index 6d753dd6e2d9383133b26e682c43fb8e3f230eec..23d7ba123ae825ace82d4d54d999424e0ae6d45a 100644 (file)
@@ -61,3 +61,7 @@ To sum it up:
 +--------------+--------------------+---------------------------+----------------------+----------------------+
 | DoH          | **UDP**            | TCP                       | TLS                  | DoH                  |
 +--------------+--------------------+---------------------------+----------------------+----------------------+
+| DoQ          | TCP                | TCP                       | TLS                  | DoH                  |
++--------------+--------------------+---------------------------+----------------------+----------------------+
+| DoH3         | TCP                | TCP                       | TLS                  | DoH                  |
++--------------+--------------------+---------------------------+----------------------+----------------------+