]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
dnsproxy: fix proxying TCP received over XDP
authorDavid Vašek <david.vasek@nic.cz>
Mon, 22 Jul 2024 18:15:54 +0000 (20:15 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Thu, 1 Aug 2024 17:18:56 +0000 (19:18 +0200)
src/knot/modules/dnsproxy/dnsproxy.c

index d51db5377fc63ad43bbec3f3b055c1cfa422c8b9..328bd94aaa64185a031bc9b39820073f3a03feaf 100644 (file)
@@ -19,6 +19,7 @@
 #include "knot/conf/schema.h"
 #include "knot/query/capture.h" // Forces static module!
 #include "knot/query/requestor.h" // Forces static module!
+#include "libknot/xdp.h"
 
 #define MOD_REMOTE             "\x06""remote"
 #define MOD_ADDRESS            "\x07""address"
@@ -74,8 +75,22 @@ static int fwd(dnsproxy_t *proxy, knot_pkt_t *pkt, knotd_qdata_t *qdata, int add
                return ret;
        }
 
+       bool udp = false;
+       if (qdata->params->xdp_msg == NULL) {
+               if (!net_is_stream(qdata->params->socket)) {
+                       udp = true;
+               }
+       }
+#if ENABLE_XDP
+       else {
+               if (!(qdata->params->xdp_msg->flags & KNOT_XDP_MSG_TCP)) {
+                       udp = true;
+               }
+       }
+#endif
+
        knot_request_flag_t flags = KNOT_REQUEST_NONE;
-       if (!net_is_stream(qdata->params->socket)) {
+       if (udp) {
                flags = KNOT_REQUEST_UDP;
        } else if (proxy->tfo) {
                flags = KNOT_REQUEST_TFO;