diff --git a/distro/deb/libknot11.symbols b/distro/deb/libknot11.symbols
index 90964e390..6df77119b 100644
--- a/distro/deb/libknot11.symbols
+++ b/distro/deb/libknot11.symbols
@@ -80,6 +80,7 @@ libknot.so.11 libknot11 #MINVER#
knot_error_from_libdnssec@Base 3.0.0
knot_eth_name_from_addr@Base 3.0.0
knot_eth_queues@Base 3.0.0
+ knot_eth_xdp_mode@Base 3.0.2
knot_get_obsolete_rdata_descriptor@Base 3.0.0
knot_get_rdata_descriptor@Base 3.0.0
knot_naptr_header_size@Base 3.0.0
diff --git a/src/libknot/xdp/eth.c b/src/libknot/xdp/eth.c
index d5d1d2ae5..b3614b6e2 100644
--- a/src/libknot/xdp/eth.c
+++ b/src/libknot/xdp/eth.c
@@ -14,10 +14,12 @@
along with this program. If not, see .
*/
+#include
#include
#include
#include
#include
+#include
#include
#include
#include
@@ -105,3 +107,23 @@ int knot_eth_name_from_addr(const struct sockaddr_storage *addr, char *out,
freeifaddrs(ifaces);
return matches == 0 ? KNOT_EADDRNOTAVAIL : KNOT_ELIMIT;
}
+
+_public_
+knot_xdp_mode_t knot_eth_xdp_mode(int if_index)
+{
+ struct xdp_link_info info;
+ int ret = bpf_get_link_xdp_info(if_index, &info, sizeof(info), 0);
+ if (ret != 0) {
+ return KNOT_XDP_MODE_NONE;
+ }
+
+ switch (info.attach_mode) {
+ case XDP_ATTACHED_DRV:
+ case XDP_ATTACHED_HW:
+ return KNOT_XDP_MODE_FULL;
+ case XDP_ATTACHED_SKB:
+ return KNOT_XDP_MODE_EMUL;
+ default:
+ return KNOT_XDP_MODE_NONE;
+ }
+}
diff --git a/src/libknot/xdp/eth.h b/src/libknot/xdp/eth.h
index b5fc7ff25..eb196e19b 100644
--- a/src/libknot/xdp/eth.h
+++ b/src/libknot/xdp/eth.h
@@ -40,3 +40,18 @@ int knot_eth_queues(const char *devname);
*/
int knot_eth_name_from_addr(const struct sockaddr_storage *addr, char *out,
size_t out_len);
+
+typedef enum {
+ KNOT_XDP_MODE_NONE, /*!< XDP not available or error. */
+ KNOT_XDP_MODE_FULL, /*!< Full XDP support in driver or HW. */
+ KNOT_XDP_MODE_EMUL, /*!< Emulated XDP support. */
+} knot_xdp_mode_t;
+
+/*!
+ * \brief Check if the network inteface supports XDP.
+ *
+ * \param if_index Index of interface, output from if_nametoindex().
+ *
+ * \return Supported XDP mode.
+ */
+knot_xdp_mode_t knot_eth_xdp_mode(int if_index);