]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
source-xf-xdp: update for deprecated function in libbpf
authorJason Ish <jason.ish@oisf.net>
Wed, 22 Mar 2023 21:13:46 +0000 (15:13 -0600)
committerVictor Julien <vjulien@oisf.net>
Fri, 24 Mar 2023 05:28:54 +0000 (06:28 +0100)
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

configure.ac
src/source-af-xdp.c

index e1ad8c0c5027f5ccfb67a0a1f1c4714ec7aaed1f..47888f66450074b8f2ef441013ac76cb02dffc94 100644 (file)
         # 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
index 287a15a9974e4d126c61924e14b1808c9dd46dfe..4036e0507684cb09a8b83f39be428d3b7c97e30f 100644 (file)
@@ -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);
 }