diff --git a/include/defs/android_bpf_defs.h b/include/defs/android_bpf_defs.h index 2a28f62..139edd5 100644 --- a/include/defs/android_bpf_defs.h +++ b/include/defs/android_bpf_defs.h @@ -18,6 +18,7 @@ #define __always_inline __attribute__((__always_inline__)) #include +#include #define DEFINE_BPF_MAP_BASE(the_map, TYPE, KeyType, ValueType, num_entries, gid) \ struct { \ diff --git a/progs/Android.bp b/progs/Android.bp index 3d9c5a6..9401df5 100644 --- a/progs/Android.bp +++ b/progs/Android.bp @@ -31,3 +31,11 @@ bpf { name: "bpfRingbufProg.o", srcs: ["bpfRingbufProg.c"], } + +libbpf_prog { + name: "bpfRingbufProg.bpf", + srcs: ["bpfRingbufProg.c"], + header_libs: [ + "android_bpf_defs", + ], +} diff --git a/progs/bpfRingbufProg.c b/progs/bpfRingbufProg.c index 4f268bf..19147e0 100644 --- a/progs/bpfRingbufProg.c +++ b/progs/bpfRingbufProg.c @@ -14,7 +14,13 @@ * limitations under the License. */ +// Because include_dirs is not allowed under system/bpf, include +// only if the code is built for libbpf_prog target. +#ifdef ENABLE_LIBBPF +#include +#else #include "bpf_helpers.h" +#endif // This can't be easily changed since the program is loaded on boot and may be // run against tests at a slightly different version.