From: Vladimír Čunát Date: Thu, 12 Nov 2020 13:13:49 +0000 (+0100) Subject: xdp: warn when using XDP emulation X-Git-Tag: v5.2.1~10^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c318e386d4d495e776eed6da69d600c2d3412d24;p=thirdparty%2Fknot-resolver.git xdp: warn when using XDP emulation For simplicity we bump Knot version that's required for using XDP. Syntax: I found no better way to split the line; alternative: backslash in meson >= 0.50. --- diff --git a/daemon/io.c b/daemon/io.c index 28894da65..83263387d 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -13,6 +13,7 @@ #if ENABLE_XDP #include + #include #endif #include "daemon/network.h" @@ -842,6 +843,31 @@ static void xdp_rx(uv_poll_t* handle, int status, int events) } knot_xdp_recv_finish(xhd->socket, msgs, rcvd); } +/// Warn if the XDP program is running in emulated mode (XDP_SKB) +static void xdp_warn_mode(const char *ifname) +{ + assert(ifname); + const unsigned if_index = if_nametoindex(ifname); + if (!if_index) { + kr_log_info("[xdp] warning: interface %s, unexpected error when converting its name: %s\n", + ifname, strerror(errno)); + return; + } + + const knot_xdp_mode_t mode = knot_eth_xdp_mode(if_index); + switch (mode) { + case KNOT_XDP_MODE_FULL: + return; + case KNOT_XDP_MODE_EMUL: + kr_log_info("[xdp] warning: interface %s running only with XDP emulation\n", + ifname); + return; + case KNOT_XDP_MODE_NONE: // enum warnings from compiler + break; + } + kr_log_info("[xdp] warning: interface %s running in unexpected XDP mode %d\n", + ifname, (int)mode); +} int io_listen_xdp(uv_loop_t *loop, struct endpoint *ep, const char *ifname) { if (!ep || !ep->handle) { @@ -864,6 +890,7 @@ int io_listen_xdp(uv_loop_t *loop, struct endpoint *ep, const char *ifname) xhd->socket = NULL; // needed for some reason int ret = knot_xdp_init(&xhd->socket, ifname, ep->nic_queue, port, KNOT_XDP_LOAD_BPF_MAYBE); + if (!ret) xdp_warn_mode(ifname); if (!ret) ret = uv_idle_init(loop, &xhd->tx_waker); if (ret) { diff --git a/meson.build b/meson.build index 62e03bca8..da5e34858 100644 --- a/meson.build +++ b/meson.build @@ -111,7 +111,8 @@ else endif ### XDP: not configurable - we just check if libknot supports it -xdp = meson.get_compiler('c').has_header('libknot/xdp/xdp.h') +xdp = meson.get_compiler('c').has_header('libknot/xdp/xdp.h' + ) and libknot.version().version_compare('>= 3.0.2') ### Systemd systemd_files = get_option('systemd_files')