Skip to content
Snippets Groups Projects
Commit bae4e2c3 authored by Petr Špaček's avatar Petr Špaček
Browse files

Merge branch 'xdp-emulation' into 'master'

xdp: warn when using XDP emulation

See merge request !1092
parents f15a30c0 c318e386
No related branches found
No related tags found
1 merge request!1092xdp: warn when using XDP emulation
Pipeline #72633 passed
......@@ -13,6 +13,7 @@
#if ENABLE_XDP
#include <libknot/xdp/xdp.h>
#include <net/if.h>
#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) {
......
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment