From: Jason Ish Date: Wed, 22 Mar 2023 21:13:46 +0000 (-0600) Subject: source-xf-xdp: update for deprecated function in libbpf X-Git-Tag: suricata-7.0.0-rc2~501 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=744759b0c9582fb88a785e621693c903e714c633;p=thirdparty%2Fsuricata.git source-xf-xdp: update for deprecated function in libbpf libbpf 0.8 deprecates bpf_get_link_xpd_id, and 1.0 removes it. Add ./configure check to see if this method is available and use it if so, otherwise use the deprecated method which is not available on older but still supported Linux distributions. Ticket: #5924 --- diff --git a/configure.ac b/configure.ac index e1ad8c0c50..47888f6645 100644 --- a/configure.ac +++ b/configure.ac @@ -1369,6 +1369,10 @@ # Are all required libs installed, yes=HAVE_AF_XDP AS_IF([test "x$enable_af_xdp" = "xyes"], AC_DEFINE([HAVE_AF_XDP],[1],[AF_XDP support is available])) + + # bpf_get_link_xpd_id has been removed in the most recent + # versions of libbpf. + AC_CHECK_FUNCS([bpf_xdp_query_id]) ]) # DPDK support diff --git a/src/source-af-xdp.c b/src/source-af-xdp.c index 287a15a997..4036e05076 100644 --- a/src/source-af-xdp.c +++ b/src/source-af-xdp.c @@ -493,10 +493,17 @@ static TmEcode AFXDPSocketCreation(AFXDPThreadVars *ptv) } /* Has the eBPF program successfully bound? */ +#ifdef HAVE_BPF_XDP_QUERY_ID + if (bpf_xdp_query_id(ptv->ifindex, ptv->xsk.cfg.xdp_flags, &ptv->prog_id)) { + SCLogError("Failed to attach eBPF program to interface: %s", ptv->livedev->dev); + SCReturnInt(TM_ECODE_FAILED); + } +#else if (bpf_get_link_xdp_id(ptv->ifindex, &ptv->prog_id, ptv->xsk.cfg.xdp_flags)) { SCLogError("Failed to attach eBPF program to interface: %s", ptv->livedev->dev); SCReturnInt(TM_ECODE_FAILED); } +#endif SCReturnInt(TM_ECODE_OK); }