diff --git a/staticlibs/native/bpf_headers/include/bpf/bpf_helpers.h b/staticlibs/native/bpf_headers/include/bpf/bpf_helpers.h index eea7dd21a4..abeb4f6e48 100644 --- a/staticlibs/native/bpf_headers/include/bpf/bpf_helpers.h +++ b/staticlibs/native/bpf_headers/include/bpf/bpf_helpers.h @@ -188,10 +188,12 @@ static void (*bpf_ringbuf_submit_unsafe)(const void* data, __u64 flags) = (void* __attribute__ ((section(".maps." #name), used)) \ ____btf_map_##name = { } -#define BPF_ASSERT_LOADER_VERSION(min_loader, ignore_eng, ignore_user, ignore_userdebug) \ - _Static_assert( \ - (min_loader) >= BPFLOADER_IGNORED_ON_VERSION || \ - !((ignore_eng) || (ignore_user) || (ignore_userdebug)), \ +#define BPF_ASSERT_LOADER_VERSION(min_loader, ignore_eng, ignore_user, ignore_userdebug) \ + _Static_assert( \ + (min_loader) >= BPFLOADER_IGNORED_ON_VERSION || \ + !((ignore_eng).ignore_on_eng || \ + (ignore_user).ignore_on_user || \ + (ignore_userdebug).ignore_on_userdebug), \ "bpfloader min version must be >= 0.33 in order to use ignored_on"); #define DEFINE_BPF_MAP_BASE(the_map, TYPE, keysize, valuesize, num_entries, \ @@ -214,9 +216,9 @@ static void (*bpf_ringbuf_submit_unsafe)(const void* data, __u64 flags) = (void* .selinux_context = (selinux), \ .pin_subdir = (pindir), \ .shared = (share).shared, \ - .ignore_on_eng = (ignore_eng), \ - .ignore_on_user = (ignore_user), \ - .ignore_on_userdebug = (ignore_userdebug), \ + .ignore_on_eng = (ignore_eng).ignore_on_eng, \ + .ignore_on_user = (ignore_user).ignore_on_user, \ + .ignore_on_userdebug = (ignore_userdebug).ignore_on_userdebug, \ }; \ BPF_ASSERT_LOADER_VERSION(minloader, ignore_eng, ignore_user, ignore_userdebug); @@ -369,9 +371,9 @@ static long (*bpf_get_current_comm)(void* buf, uint32_t buf_size) = (void*) BPF_ .bpfloader_max_ver = (max_loader), \ .selinux_context = (selinux), \ .pin_subdir = (pindir), \ - .ignore_on_eng = (ignore_eng), \ - .ignore_on_user = (ignore_user), \ - .ignore_on_userdebug = (ignore_userdebug), \ + .ignore_on_eng = (ignore_eng).ignore_on_eng, \ + .ignore_on_user = (ignore_user).ignore_on_user, \ + .ignore_on_userdebug = (ignore_userdebug).ignore_on_userdebug, \ }; \ SECTION(SECTION_NAME) \ int the_prog diff --git a/staticlibs/native/bpf_headers/include/bpf/bpf_map_def.h b/staticlibs/native/bpf_headers/include/bpf/bpf_map_def.h index 615a570bda..ef03c4daad 100644 --- a/staticlibs/native/bpf_headers/include/bpf/bpf_map_def.h +++ b/staticlibs/native/bpf_headers/include/bpf/bpf_map_def.h @@ -125,13 +125,18 @@ struct optional_bool { bool optional; }; #define MANDATORY ((struct optional_bool){ .optional = false }) #define OPTIONAL ((struct optional_bool){ .optional = true }) -// constants for passing in to ignore_on_eng / ignore_on_user / ignore_on_userdebug -static const bool LOAD_ON_ENG = false; -static const bool LOAD_ON_USER = false; -static const bool LOAD_ON_USERDEBUG = false; -static const bool IGNORE_ON_ENG = true; -static const bool IGNORE_ON_USER = true; -static const bool IGNORE_ON_USERDEBUG = true; +// for both maps and programs: +struct ignore_on_eng_bool { bool ignore_on_eng; }; +#define LOAD_ON_ENG ((struct ignore_on_eng_bool){ .ignore_on_eng = false }) +#define IGNORE_ON_ENG ((struct ignore_on_eng_bool){ .ignore_on_eng = true }) + +struct ignore_on_user_bool { bool ignore_on_user; }; +#define LOAD_ON_USER ((struct ignore_on_user_bool){ .ignore_on_user = false }) +#define IGNORE_ON_USER ((struct ignore_on_user_bool){ .ignore_on_user = true }) + +struct ignore_on_userdebug_bool { bool ignore_on_userdebug; }; +#define LOAD_ON_USERDEBUG ((struct ignore_on_userdebug_bool){ .ignore_on_userdebug = false }) +#define IGNORE_ON_USERDEBUG ((struct ignore_on_userdebug_bool){ .ignore_on_userdebug = true }) // Length of strings (incl. selinux_context and pin_subdir)