]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
adapt to libknot 3.1 API changes in XDP
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 22 Dec 2020 08:07:27 +0000 (09:07 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 10 Feb 2021 17:01:20 +0000 (18:01 +0100)
daemon/io.c
daemon/worker.c

index 11437670aeafba2be254848c1e17784da7efc122..361797745b57a03478a9216ae6e7781efef9ecf4 100644 (file)
@@ -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);
index 4bc45185d0dd9b642b573adbf978a528d9869bde..b13bb3911f1ee1eff4e3588ac607bc50f2021bb6 100644 (file)
@@ -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;