diff --git a/configure.ac b/configure.ac index aa3cc303..f0e63951 100644 --- a/configure.ac +++ b/configure.ac @@ -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 + ]], + [[ + 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 diff --git a/src/shrpx.h b/src/shrpx.h index 60e873dd..d881ef5d 100644 --- a/src/shrpx.h +++ b/src/shrpx.h @@ -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