From: Vladimír Čunát Date: Wed, 15 Jun 2022 07:30:02 +0000 (+0200) Subject: daemon: adapt XDP to libknot 3.2 X-Git-Tag: v5.5.2~9^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c92e5c2aa027c12f6a4bb52b68b20604c1bf00bb;p=thirdparty%2Fknot-resolver.git daemon: adapt XDP to libknot 3.2 --- diff --git a/daemon/io.c b/daemon/io.c index e1e5cac35..824a4b9f5 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -1029,15 +1029,24 @@ int io_listen_xdp(uv_loop_t *loop, struct endpoint *ep, const char *ifname) xdp_handle_data_t *xhd = malloc(sizeof(*xhd)); if (!xhd) return kr_error(ENOMEM); - const int port = ep->port ? ep->port : // all ports otherwise - #if KNOT_VERSION_HEX >= 0x030100 - (KNOT_XDP_LISTEN_PORT_PASS | 0); - #else - KNOT_XDP_LISTEN_PORT_ALL; - #endif xhd->socket = NULL; // needed for some reason - int ret = knot_xdp_init(&xhd->socket, ifname, ep->nic_queue, port, - KNOT_XDP_LOAD_BPF_MAYBE); + + // This call is a libknot version hell, unfortunately. + int ret = knot_xdp_init(&xhd->socket, ifname, ep->nic_queue, + #if KNOT_VERSION_HEX < 0x030100 + ep->port ? ep->port : KNOT_XDP_LISTEN_PORT_ALL, + KNOT_XDP_LOAD_BPF_MAYBE + #elif KNOT_VERSION_HEX < 0x030200 + ep->port ? ep->port : (KNOT_XDP_LISTEN_PORT_PASS | 0), + KNOT_XDP_LOAD_BPF_MAYBE + #else + KNOT_XDP_FILTER_UDP | (ep->port ? 0 : KNOT_XDP_FILTER_PASS), + ep->port, 0/*quic_port*/, + KNOT_XDP_LOAD_BPF_MAYBE, + NULL/*xdp_config*/ + #endif + ); + if (!ret) xdp_warn_mode(ifname); if (!ret) ret = uv_idle_init(loop, &xhd->tx_waker);