From 41661a10e342c04deea39b91912c455321d219e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Fri, 22 Oct 2021 21:20:57 -0700 Subject: [PATCH] add mainline module support for targetting only newer bpfloader versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow shipping .o's targetting only T and not S devices. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I651b4442625df9011ff7c5ad283943caae579565 --- libbpf_android/Loader.cpp | 4 ++-- progs/include/bpf_helpers.h | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp index 529c69c..9fd7dff 100644 --- a/libbpf_android/Loader.cpp +++ b/libbpf_android/Loader.cpp @@ -28,9 +28,9 @@ #include #include -// This is BpfLoader v0.5 +// This is BpfLoader v0.6 #define BPFLOADER_VERSION_MAJOR 0u -#define BPFLOADER_VERSION_MINOR 5u +#define BPFLOADER_VERSION_MINOR 6u #define BPFLOADER_VERSION ((BPFLOADER_VERSION_MAJOR << 16) | BPFLOADER_VERSION_MINOR) #include "../progs/include/bpf_map_def.h" diff --git a/progs/include/bpf_helpers.h b/progs/include/bpf_helpers.h index 97cb012..878bb10 100644 --- a/progs/include/bpf_helpers.h +++ b/progs/include/bpf_helpers.h @@ -19,6 +19,21 @@ * * ******************************************************************************/ +/* For mainline module use, you can #define BPFLOADER_{MIN/MAX}_VER + * before #include "bpf_helpers.h" to change which bpfloaders will + * process the resulting .o file. + * + * While this will work outside of mainline too, there just is no point to + * using it when the .o and the bpfloader ship in sync with each other. + */ +#ifndef BPFLOADER_MIN_VER +#define BPFLOADER_MIN_VER DEFAULT_BPFLOADER_MIN_VER +#endif + +#ifndef BPFLOADER_MAX_VER +#define BPFLOADER_MAX_VER DEFAULT_BPFLOADER_MAX_VER +#endif + /* place things in different elf sections */ #define SECTION(NAME) __attribute__((section(NAME), used)) @@ -42,8 +57,8 @@ * while size_of_bpf_{map/prog}_def default to 32/20 which are the v0.0 sizes. */ #define LICENSE(NAME) \ - unsigned int _bpfloader_min_ver SECTION("bpfloader_min_ver") = DEFAULT_BPFLOADER_MIN_VER; \ - unsigned int _bpfloader_max_ver SECTION("bpfloader_max_ver") = DEFAULT_BPFLOADER_MAX_VER; \ + unsigned int _bpfloader_min_ver SECTION("bpfloader_min_ver") = BPFLOADER_MIN_VER; \ + unsigned int _bpfloader_max_ver SECTION("bpfloader_max_ver") = BPFLOADER_MAX_VER; \ size_t _size_of_bpf_map_def SECTION("size_of_bpf_map_def") = sizeof(struct bpf_map_def); \ size_t _size_of_bpf_prog_def SECTION("size_of_bpf_prog_def") = sizeof(struct bpf_prog_def); \ char _license[] SECTION("license") = (NAME)