bpf_helpers: change how default map flags are calculated
This is more legible then a series of if's, although thus require manually adding support for new map types. Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8900eb8ced5e4a1cb161b49e5c68d2effe36af57
This commit is contained in:
parent
eaf2fea0d2
commit
eb485ae1e9
1 changed files with 10 additions and 6 deletions
|
|
@ -236,12 +236,16 @@ static long (*bpf_sk_storage_delete_unsafe) (const void* sk_storage,
|
|||
|
||||
#define ABSOLUTE(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
#define DEFAULT_BPF_MAP_FLAGS(TYPE, num_entries, mapflags) \
|
||||
( (mapflags) | \
|
||||
((num_entries) < 0 ? BPF_F_NO_PREALLOC : 0) | \
|
||||
( (BPF_MAP_TYPE_##TYPE == BPF_MAP_TYPE_LPM_TRIE || \
|
||||
BPF_MAP_TYPE_##TYPE == BPF_MAP_TYPE_SK_STORAGE) ? BPF_F_NO_PREALLOC : 0) \
|
||||
)
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_ARRAY 0
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_DEVMAP_HASH 0
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_HASH 0
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_LPM_TRIE BPF_F_NO_PREALLOC
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_PERCPU_ARRAY 0
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_RINGBUF 0
|
||||
#define DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_SK_STORAGE BPF_F_NO_PREALLOC
|
||||
|
||||
#define DEFAULT_BPF_MAP_FLAGS(TYPE, num_entries, mapflags) \
|
||||
(DEFAULT_FLAGS_FOR_BPF_MAP_TYPE_##TYPE | ((num_entries) < 0 ? BPF_F_NO_PREALLOC : 0) | (mapflags))
|
||||
|
||||
#define DEFINE_BPF_MAP_BASE(the_map, TYPE, keysize, valuesize, num_entries, usr, grp, md, \
|
||||
selinux, pindir, minkver, maxkver, minloader, maxloader, mapflags) \
|
||||
|
|
|
|||
Loading…
Reference in a new issue