move PRIVATE/SHARED/MANDATORY/OPTIONAL/{LOAD,IGNORE}_ON_* into core headers
Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7053ab46e73b763f64f36baf5e7ab64b62421045
This commit is contained in:
@@ -87,14 +87,6 @@ static inline __always_inline void try_make_writable(struct __sk_buff* skb, int
|
||||
if (skb->data_end - skb->data < len) bpf_skb_pull_data(skb, len);
|
||||
}
|
||||
|
||||
// constants for passing in to 'bool shared' (for maps)
|
||||
static const bool PRIVATE = false;
|
||||
static const bool SHARED = true;
|
||||
|
||||
// constants for passing in to 'bool optional' (for programs)
|
||||
static const bool MANDATORY = false;
|
||||
static const bool OPTIONAL = true;
|
||||
|
||||
// constants for passing in to 'bool egress'
|
||||
static const bool INGRESS = false;
|
||||
static const bool EGRESS = true;
|
||||
@@ -111,12 +103,4 @@ static const bool ETHER = true;
|
||||
static const bool NO_UPDATETIME = false;
|
||||
static const bool UPDATETIME = 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;
|
||||
|
||||
#define KVER_4_14 KVER(4, 14, 0)
|
||||
|
||||
@@ -312,11 +312,11 @@ static void (*bpf_ringbuf_submit_unsafe)(const void* data, __u64 flags) = (void*
|
||||
#error "Bpf Map UID must be left at default of AID_ROOT for BpfLoader prior to v0.28"
|
||||
#endif
|
||||
|
||||
#define DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md) \
|
||||
DEFINE_BPF_MAP_EXT(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md, \
|
||||
DEFAULT_BPF_MAP_SELINUX_CONTEXT, DEFAULT_BPF_MAP_PIN_SUBDIR, false, \
|
||||
BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, /*ignore_on_eng*/false, \
|
||||
/*ignore_on_user*/false, /*ignore_on_userdebug*/false)
|
||||
#define DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md) \
|
||||
DEFINE_BPF_MAP_EXT(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md, \
|
||||
DEFAULT_BPF_MAP_SELINUX_CONTEXT, DEFAULT_BPF_MAP_PIN_SUBDIR, PRIVATE, \
|
||||
BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, LOAD_ON_ENG, \
|
||||
LOAD_ON_USER, LOAD_ON_USERDEBUG)
|
||||
|
||||
#define DEFINE_BPF_MAP(the_map, TYPE, KeyType, ValueType, num_entries) \
|
||||
DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, \
|
||||
@@ -389,7 +389,7 @@ static long (*bpf_get_current_comm)(void* buf, uint32_t buf_size) = (void*) BPF_
|
||||
DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \
|
||||
BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, opt, \
|
||||
DEFAULT_BPF_PROG_SELINUX_CONTEXT, DEFAULT_BPF_PROG_PIN_SUBDIR, \
|
||||
false, false, false)
|
||||
LOAD_ON_ENG, LOAD_ON_USER, LOAD_ON_USERDEBUG)
|
||||
|
||||
// Programs (here used in the sense of functions/sections) marked optional are allowed to fail
|
||||
// to load (for example due to missing kernel patches).
|
||||
@@ -405,21 +405,24 @@ static long (*bpf_get_current_comm)(void* buf, uint32_t buf_size) = (void*) BPF_
|
||||
// programs requiring a kernel version >= min_kv && < max_kv
|
||||
#define DEFINE_BPF_PROG_KVER_RANGE(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \
|
||||
false)
|
||||
MANDATORY)
|
||||
#define DEFINE_OPTIONAL_BPF_PROG_KVER_RANGE(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, \
|
||||
max_kv) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, true)
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \
|
||||
OPTIONAL)
|
||||
|
||||
// programs requiring a kernel version >= min_kv
|
||||
#define DEFINE_BPF_PROG_KVER(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, KVER_INF, \
|
||||
false)
|
||||
MANDATORY)
|
||||
#define DEFINE_OPTIONAL_BPF_PROG_KVER(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, KVER_INF, \
|
||||
true)
|
||||
OPTIONAL)
|
||||
|
||||
// programs with no kernel version requirements
|
||||
#define DEFINE_BPF_PROG(SECTION_NAME, prog_uid, prog_gid, the_prog) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, 0, KVER_INF, false)
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, 0, KVER_INF, \
|
||||
MANDATORY)
|
||||
#define DEFINE_OPTIONAL_BPF_PROG(SECTION_NAME, prog_uid, prog_gid, the_prog) \
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, 0, KVER_INF, true)
|
||||
DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, 0, KVER_INF, \
|
||||
OPTIONAL)
|
||||
|
||||
@@ -114,6 +114,24 @@ _Static_assert(__alignof__(unsigned long long) == 8, "__alignof__ unsigned long
|
||||
// BPF wants 8, but 32-bit x86 wants 4
|
||||
//_Static_assert(_Alignof(unsigned long long) == 8, "_Alignof unsigned long long != 8");
|
||||
|
||||
|
||||
// constants for passing in to 'bool shared' (for maps)
|
||||
static const bool PRIVATE = false;
|
||||
static const bool SHARED = true;
|
||||
|
||||
// constants for passing in to 'bool optional' (for programs)
|
||||
static const bool MANDATORY = false;
|
||||
static const 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;
|
||||
|
||||
|
||||
// Length of strings (incl. selinux_context and pin_subdir)
|
||||
// in the bpf_map_def and bpf_prog_def structs.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user