Provide enum bpf_stats_type if not defined in linux/bpf.h for older kernel

This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-29 14:30:05 +09:00
parent 8d02203bb6
commit ef694923f7
2 changed files with 26 additions and 0 deletions

View File

@ -559,6 +559,25 @@ if test "x${request_libbpf}" != "xno"; then
# Add the include path for Debian
EXTRABPFCFLAGS="-I/usr/include/$host_cpu-$host_os"
AC_SUBST([EXTRABPFCFLAGS])
AC_MSG_CHECKING([whether enum bpf_stats_type is defined in linux/bpf.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <linux/bpf.h>
]],
[[
enum bpf_stats_type foo;
]])],
[have_bpf_stats_type=yes],
[have_bpf_stats_type=no])
if test "x${have_bpf_stats_type}" = "xyes"; then
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_BPF_STATS_TYPE], [1],
[Define to 1 if you have enum bpf_stats_type in linux/bpf.h.])
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_NOTICE($LIBBPF_PKG_ERRORS)
fi

View File

@ -48,4 +48,11 @@
inline int initgroups(const char *user, gid_t group) { return 0; }
#endif // defined(HAVE_DECL_INITGROUPS) && !HAVE_DECL_INITGROUPS
#ifndef HAVE_BPF_STATS_TYPE
/* Newer kernel should have this defined in linux/bpf.h */
enum bpf_stats_type {
BPF_STATS_RUN_TIME = 0,
};
#endif // !HAVE_BPF_STATS_TYPE
#endif // SHRPX_H