Skip to content
Snippets Groups Projects
Commit 6dec6e93 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski
Browse files

type safety for bool ignore_on_{eng,user,userdebug}


Test: TreeHugger
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Change-Id: Ia85e16d1a7f8d1b21e4ce4c306db6bbea06138e0
parent f2466ef4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment