summaryrefslogtreecommitdiffstats
path: root/src/knot/server/udp-handler.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/knot/server/udp-handler.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/knot/server/udp-handler.c b/src/knot/server/udp-handler.c
index e54ce2c..c5166f9 100644
--- a/src/knot/server/udp-handler.c
+++ b/src/knot/server/udp-handler.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -73,9 +73,15 @@ typedef struct {
static void udp_handler(udp_context_t *udp, knotd_qdata_params_t *params,
struct iovec *rx, struct iovec *tx)
{
+ if (process_query_proto(params, KNOTD_STAGE_PROTO_BEGIN) == KNOTD_PROTO_STATE_BLOCK) {
+ return;
+ }
+
// Prepare a reply.
struct sockaddr_storage proxied_remote;
handle_udp_reply(params, &udp->layer, rx, tx, &proxied_remote);
+
+ (void)process_query_proto(params, KNOTD_STAGE_PROTO_END);
}
typedef struct {
@@ -153,7 +159,7 @@ void cmsg_handle(const struct msghdr *rx, struct msghdr *tx,
}
struct cmsghdr *cmsg = CMSG_FIRSTHDR(tx);
- if (iface->quic) {
+ if (iface->tls) {
*p_ecn = NULL;
while (cmsg != NULL) {
cmsg_handle_ecn(p_ecn, cmsg);
@@ -246,9 +252,9 @@ static void udp_msg_handle(udp_context_t *ctx, const iface_t *iface, void *d)
/* Process received pkt. */
knotd_qdata_params_t params = params_init(
- iface->quic ? KNOTD_QUERY_PROTO_QUIC : KNOTD_QUERY_PROTO_UDP,
+ iface->tls ? KNOTD_QUERY_PROTO_QUIC : KNOTD_QUERY_PROTO_UDP,
&rq->addr, local, rq->fd, ctx->server, ctx->thread_id);
- if (iface->quic) {
+ if (iface->tls) {
#ifdef ENABLE_QUIC
quic_handler(&params, &ctx->layer, ctx->quic_idle_close,
ctx->quic_table, &rq->iov[RX], &rq->msg[TX], p_ecn);
@@ -357,9 +363,9 @@ static void udp_mmsg_handle(udp_context_t *ctx, const iface_t *iface, void *d)
const sockaddr_t *local = local_addr(&ctx->local, iface);
knotd_qdata_params_t params = params_init(
- iface->quic ? KNOTD_QUERY_PROTO_QUIC : KNOTD_QUERY_PROTO_UDP,
+ iface->tls ? KNOTD_QUERY_PROTO_QUIC : KNOTD_QUERY_PROTO_UDP,
&rq->addrs[i], local, rq->fd, ctx->server, ctx->thread_id);
- if (iface->quic) {
+ if (iface->tls) {
#ifdef ENABLE_QUIC
quic_handler(&params, &ctx->layer, ctx->quic_idle_close,
ctx->quic_table, rx->msg_iov, tx, p_ecn);
@@ -432,7 +438,7 @@ static int xdp_mmsg_recv(_unused_ int fd, void *d)
static void xdp_mmsg_handle(udp_context_t *ctx, _unused_ const iface_t *iface, void *d)
{
- assert(!iface->quic);
+ assert(!iface->tls);
xdp_handle_msgs(d, &ctx->layer, ctx->server, ctx->thread_id);
}
@@ -482,7 +488,6 @@ static int iface_udp_fd(const iface_t *iface, int thread_id, bool xdp_thread,
#endif
} else { // UDP thread.
if (iface->fd_udp_count == 0) { // No UDP interfaces.
- assert(iface->fd_xdp_count > 0);
return -1;
}
#ifdef ENABLE_REUSEPORT
@@ -508,7 +513,7 @@ static unsigned udp_set_ifaces(const server_t *server, size_t n_ifaces, fdset_t
#ifndef ENABLE_REUSEPORT
/* If loadbalanced SO_REUSEPORT isn't available, ensure that
* just one (first) UDP worker handles the QUIC sockets. */
- if (i->quic && thread_id > 0) {
+ if (i->tls && thread_id > 0) {
continue;
}
#endif
@@ -520,7 +525,7 @@ static unsigned udp_set_ifaces(const server_t *server, size_t n_ifaces, fdset_t
if (ret < 0) {
return 0;
}
- if (i->quic) {
+ if (i->tls) {
*quic = true;
}
}