#if ENABLE_XDP
#include <libknot/xdp/xdp.h>
+ #include <net/if.h>
#endif
#include "daemon/network.h"
}
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) {
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) {
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')