]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
make quic/DoQ optional
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 30 Dec 2025 09:59:30 +0000 (10:59 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 27 Jan 2026 11:31:25 +0000 (12:31 +0100)
daemon/bindings/net.c
daemon/meson.build
daemon/network.c
daemon/quic_common.h
daemon/session2.c
daemon/worker.c
meson.build
meson_options.txt

index e4f6dcba47bb763d52a52232aff10873583d8359..e5f5fa4e202c929503fa8255333ac0b3a0b387a6 100644 (file)
@@ -623,6 +623,7 @@ static int net_doh_headers(lua_State *L)
 
 static int net_quic_max_conns(lua_State *L)
 {
+#if ENABLE_QUIC
        if (kr_fails_assert(the_network)) {
                return 0;
        }
@@ -651,12 +652,14 @@ static int net_quic_max_conns(lua_State *L)
                lua_error_p(L, "net.quic_max_conns must be within <1,  4096>");
 
        the_network->quic_params->max_conns = (uint16_t)v;
+#endif // otherwise we just ignore the setting
        lua_pushboolean(L, true);
        return 1;
 }
 
 static int net_quic_max_streams(lua_State *L)
 {
+#if ENABLE_QUIC
        if (kr_fails_assert(the_network)) {
                return 0;
        }
@@ -685,12 +688,14 @@ static int net_quic_max_streams(lua_State *L)
                lua_error_p(L, "net.quic_max_streams must be within <1,  4096>");
 
        the_network->quic_params->max_streams = (uint16_t)v;
+#endif // otherwise we just ignore the setting
        lua_pushboolean(L, true);
        return 1;
 }
 
 static int net_quic_reqire_retry(lua_State *L)
 {
+#if ENABLE_QUIC
        if (kr_fails_assert(the_network)) {
                return 0;
        }
@@ -717,6 +722,7 @@ static int net_quic_reqire_retry(lua_State *L)
        }
 
        the_network->quic_params->require_retry = v;
+#endif // otherwise we just ignore the setting
        lua_pushboolean(L, true);
        return 1;
 }
index 3a0c44aeefdd5679dca9074bc3e2dbf1565bf549..eb62d6da9298ebe04319271183c01fa5e58a2498 100644 (file)
@@ -23,12 +23,17 @@ kresd_src = files([
   'udp_queue.c',
   'worker.c',
   'zimport.c',
-  'quic_common.c',
-  'quic_demux.c',
-  'quic_conn.c',
-  'quic_stream.c',
 ])
 
+if enable_quic
+  kresd_src += files([
+    'quic_common.c',
+    'quic_demux.c',
+    'quic_conn.c',
+    'quic_stream.c',
+  ])
+endif
+
 if nghttp2.found()
   kresd_src += files(['http.c'])
 endif
@@ -67,10 +72,12 @@ kresd_deps = [
   nghttp2,
   malloc,
   libm,
-  libngtcp2,
-  libngtcp2_crypto,
 ]
 
+if enable_quic
+  kresd_deps += libngtcp2_deps
+endif
+
 
 subdir('lua')
 
index 18b1159b7f40722300ce4ecdd4495ea631e457ec..5341601f7c90eebcc01244f198603d3b857b90ab 100644 (file)
@@ -312,7 +312,9 @@ void network_deinit(void)
        trie_free(the_network->proxy_addrs6);
 
        tls_credentials_free(the_network->tls_credentials);
+#if HAS_QUIC
        quic_configuration_free(the_network->quic_params);
+#endif
        tls_client_params_free(the_network->tls_client_params);
        tls_session_ticket_ctx_destroy(the_network->tls_session_ticket_ctx);
 #ifndef NDEBUG
index 675ec60f945fa3b19488e6b812569e6d4cd83cea..17d0b26faabcfc35a82ccc821e6ee27ded356db8 100644 (file)
@@ -4,6 +4,11 @@
 
 #pragma once
 
+#include "kresconfig.h"
+
+#if !ENABLE_QUIC
+#else
+
 #include <ngtcp2/ngtcp2.h>
 #include <ngtcp2/ngtcp2_crypto.h>
 #include <ngtcp2/ngtcp2_crypto_gnutls.h>
@@ -120,3 +125,5 @@ int write_retry_packet(struct wire_buf *dest, kr_quic_table_t *table,
                ngtcp2_version_cid *dec_cids,
                const struct sockaddr *src_addr,
                uint8_t *secret, size_t secret_len);
+
+#endif
index 17fe8e2f0d260d0772ac8b1b19aaaac0fe4366e8..2388824fa28ef69f177c0d0d0fb142452aa2ef2c 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "daemon/session2.h"
 
-#include "ngtcp2/ngtcp2.h"
-
 
 #define VERBOSE_LOG(session, fmt, ...) do {\
        if (kr_log_is_debug(PROTOLAYER, NULL)) {\
index 29a31119d2ec970651e5f7c92c30a7deec2f7f79..5fc05604807ae55cf7554f9e73a15ab03ea7feea 100644 (file)
@@ -5,11 +5,9 @@
 #include "kresconfig.h"
 #include "lib/proto.h"
 #include "mempattern.h"
-#include "quic_conn.h"
 #include "daemon/worker.h"
 
 #include <libknot/wire.h>
-#include <ngtcp2/ngtcp2.h>
 #include <string.h>
 #include <uv.h>
 #include <lua.h>
index f9e5f35dd1ebebb0d4a15f565c0d47faf99ed6de..e3608c1bb3d754f259c578d72833c096486d2c42 100644 (file)
@@ -35,8 +35,6 @@ gnutls = dependency('gnutls', version: '>=3.4', required: true)
 luajit = dependency('luajit')
 # https://mesonbuild.com/howtox.html#add-math-library-lm-portably
 libm = meson.get_compiler('c').find_library('m', required : false)
-libngtcp2 = dependency('libngtcp2', version: '>=1.11.0')
-libngtcp2_crypto = dependency('libngtcp2_crypto_gnutls')
 message('------------------------------')
 
 
@@ -139,6 +137,14 @@ message('--- optional dependencies ---')
 nghttp2 = dependency('libnghttp2', required: false)
 openssl = dependency('openssl', required: false)
 
+libngtcp2 = dependency('libngtcp2', version: '>=1.11.0', required: get_option('quic') == 'external')
+libngtcp2_crypto = dependency('libngtcp2_crypto_gnutls', required: get_option('quic') == 'external')
+enable_quic = libngtcp2.found() and libngtcp2_crypto.found()
+if enable_quic
+  libngtcp2_deps = [libngtcp2, libngtcp2_crypto]
+endif
+quic_summary = [enable_quic, 'with external libngtcp2*']
+
 have_asprintf = meson.get_compiler('c').has_function('asprintf',
   prefix: '#define _GNU_SOURCE\n#include <stdio.h>')
 
@@ -179,6 +185,7 @@ malloc = meson.get_compiler('c').find_library(
 summary({'sendmmsg': sendmmsg,
          'XDP (in libknot)': xdp,
          'doh2 (serving)': nghttp2.found(),
+         'DoQ': quic_summary,
          'capabilities': capng.found(),
          'malloc': malloc.found() ? malloc_name : 'libc default',
         }, section: 'Features', bool_yn: true)
@@ -265,6 +272,7 @@ conf_data.set('ENABLE_XDP', xdp.to_int())
 conf_data.set('ENABLE_CAP_NG', capng.found().to_int())
 conf_data.set('ENABLE_JEMALLOC', malloc.found().to_int())
 conf_data.set('ENABLE_DOH2', nghttp2.found().to_int())
+conf_data.set('ENABLE_QUIC', enable_quic.to_int())
 conf_data.set('DBG_ASSERTION_ABORT', get_option('debug').to_int())
 if get_option('debug')
   conf_data.set('DBG_ASSERTION_FORK', '0')
index 0f40485032e3b943ea8181591f05c117bf015ec5..58c9e76f4bd0a5c3d3f1331f6a48979dff70e634 100644 (file)
@@ -161,6 +161,18 @@ option(
   description: 'memory allocator to use in kresd',
 )
 
+option(
+  'quic',
+  type: 'combo',
+  choices: [
+    'auto',
+    'external',
+    'disabled',
+  ],
+  value: 'auto',
+  description: 'build DNS-over-QUIC support, requiring compatible libngtcp2',
+)
+
 option(
   'doc',
   type: 'combo',