From c6a390480371a604f2cedaad29ea187087dd5593 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Tue, 22 Dec 2020 09:07:27 +0100 Subject: [PATCH] adapt to libknot 3.1 API changes in XDP --- daemon/io.c | 13 +++++++++++-- daemon/worker.c | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/daemon/io.c b/daemon/io.c index 11437670a..361797745 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -808,7 +808,11 @@ static void xdp_rx(uv_poll_t* handle, int status, int events) assert(xhd && xhd->session && xhd->socket); uint32_t rcvd; knot_xdp_msg_t msgs[XDP_RX_BATCH_SIZE]; - int ret = knot_xdp_recv(xhd->socket, msgs, XDP_RX_BATCH_SIZE, &rcvd); + int ret = knot_xdp_recv(xhd->socket, msgs, XDP_RX_BATCH_SIZE, &rcvd + #if KNOT_VERSION_HEX >= 0x030100 + , NULL + #endif + ); if (ret == KNOT_EOK) { kr_log_verbose("[xdp] poll triggered, processing a batch of %d packets\n", (int)rcvd); @@ -880,7 +884,12 @@ 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 : KNOT_XDP_LISTEN_PORT_ALL; + 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); diff --git a/daemon/worker.c b/daemon/worker.c index 4bc45185d..b13bb3911 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -275,8 +275,13 @@ static uint8_t *alloc_wire_cb(struct kr_request *req, uint16_t *maxlen) assert(handle->type == UV_POLL); xdp_handle_data_t *xhd = handle->data; knot_xdp_msg_t out; - int ret = knot_xdp_send_alloc(xhd->socket, ctx->source.addr.ip.sa_family == AF_INET6, - &out, NULL); + bool ipv6 = ctx->source.addr.ip.sa_family == AF_INET6; + int ret = knot_xdp_send_alloc(xhd->socket, + #if KNOT_VERSION_HEX >= 0x030100 + ipv6 ? KNOT_XDP_MSG_IPV6 : 0, &out); + #else + ipv6, &out, NULL); + #endif if (ret != KNOT_EOK) { assert(ret == KNOT_ENOMEM); *maxlen = 0; -- 2.47.2