From: Vladimír Čunát Date: Tue, 30 Dec 2025 09:59:30 +0000 (+0100) Subject: make quic/DoQ optional X-Git-Tag: v6.2.0~2^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66d99d956b8b96d29e28a61532df7394ac35d8fa;p=thirdparty%2Fknot-resolver.git make quic/DoQ optional --- diff --git a/daemon/bindings/net.c b/daemon/bindings/net.c index e4f6dcba4..e5f5fa4e2 100644 --- a/daemon/bindings/net.c +++ b/daemon/bindings/net.c @@ -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; } diff --git a/daemon/meson.build b/daemon/meson.build index 3a0c44aee..eb62d6da9 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -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') diff --git a/daemon/network.c b/daemon/network.c index 18b1159b7..5341601f7 100644 --- a/daemon/network.c +++ b/daemon/network.c @@ -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 diff --git a/daemon/quic_common.h b/daemon/quic_common.h index 675ec60f9..17d0b26fa 100644 --- a/daemon/quic_common.h +++ b/daemon/quic_common.h @@ -4,6 +4,11 @@ #pragma once +#include "kresconfig.h" + +#if !ENABLE_QUIC +#else + #include #include #include @@ -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 diff --git a/daemon/session2.c b/daemon/session2.c index 17fe8e2f0..2388824fa 100644 --- a/daemon/session2.c +++ b/daemon/session2.c @@ -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)) {\ diff --git a/daemon/worker.c b/daemon/worker.c index 29a31119d..5fc056048 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -5,11 +5,9 @@ #include "kresconfig.h" #include "lib/proto.h" #include "mempattern.h" -#include "quic_conn.h" #include "daemon/worker.h" #include -#include #include #include #include diff --git a/meson.build b/meson.build index f9e5f35dd..e3608c1bb 100644 --- a/meson.build +++ b/meson.build @@ -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 ') @@ -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') diff --git a/meson_options.txt b/meson_options.txt index 0f4048503..58c9e76f4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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',