From: Remi Gacogne Date: Thu, 25 Jan 2024 11:32:09 +0000 (+0100) Subject: dnsdist: Properly detect whether `bpf_xdp_query` is available X-Git-Tag: dnsdist-1.9.0-rc1^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=265ece9c2de43073a9781596089925fe4f3fc80e;p=thirdparty%2Fpdns.git dnsdist: Properly detect whether `bpf_xdp_query` is available It was added in libbpf 0.7 and EL8 only has 0.5, sadly. --- diff --git a/pdns/dnsdistdist/m4/pdns_with_xsk.m4 b/pdns/dnsdistdist/m4/pdns_with_xsk.m4 index 32cee27077..a8faf13806 100644 --- a/pdns/dnsdistdist/m4/pdns_with_xsk.m4 +++ b/pdns/dnsdistdist/m4/pdns_with_xsk.m4 @@ -14,6 +14,13 @@ AC_DEFUN([PDNS_WITH_XSK],[ ], [:]) PKG_CHECK_MODULES([BPF], [libbpf], [ AC_DEFINE([HAVE_BPF], [1], [Define to 1 if you have the BPF library]) + save_CFLAGS=$CFLAGS + save_LIBS=$LIBS + CFLAGS="$BPF_CFLAGS $CFLAGS" + LIBS="$BPF_LIBS $LIBS" + AC_CHECK_FUNCS([bpf_xdp_query]) + CFLAGS=$save_CFLAGS + LIBS=$save_LIBS ], [:]) ]) ]) diff --git a/pdns/xsk.cc b/pdns/xsk.cc index 7c6d67e1bd..ee05b3a37a 100644 --- a/pdns/xsk.cc +++ b/pdns/xsk.cc @@ -472,9 +472,10 @@ std::string XskSocket::getMetrics() const [[nodiscard]] std::string XskSocket::getXDPMode() const { +#ifdef HAVE_BPF_XDP_QUERY unsigned int itfIdx = if_nametoindex(ifName.c_str()); if (itfIdx == 0) { - return {}; + return "unable to get interface index"; } bpf_xdp_query_opts info{}; info.sz = sizeof(info); @@ -491,6 +492,9 @@ std::string XskSocket::getMetrics() const default: return "unknown"; } +#else /* HAVE_BPF_XDP_QUERY */ + return "undetected"; +#endif /* HAVE_BPF_XDP_QUERY */ } void XskSocket::markAsFree(const XskPacket& packet)