Skip to content

Commit dd82cf3

Browse files
committed
bpf: add bpf_features enum
This commit adds a kernel side enum for use in conjucntion with BTF CO-RE bpf_core_enum_value_exists. The goal of the enum is to assist with available BPF features detection. Support for bpf_rdonly_cast to void* is the first feature listed in the enum. Here is an example usage: if (bpf_core_enum_value_exists(enum bpf_features, BPF_FEAT_RDONLY_CAST_TO_VOID)) ... bpf_rdonly_cast(..., 0) ... Signed-off-by: Eduard Zingerman <[email protected]>
1 parent 10f8eab commit dd82cf3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ static const struct bpf_verifier_ops * const bpf_verifier_ops[] = {
4444
#undef BPF_LINK_TYPE
4545
};
4646

47+
enum bpf_features {
48+
BPF_FEAT_RDONLY_CAST_TO_VOID = 0,
49+
BPF_FEAT_TOTAL,
50+
};
51+
4752
struct bpf_mem_alloc bpf_global_percpu_ma;
4853
static bool bpf_global_percpu_ma_set;
4954

@@ -24436,6 +24441,8 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
2443624441
u32 log_true_size;
2443724442
bool is_priv;
2443824443

24444+
BTF_TYPE_EMIT(enum bpf_features);
24445+
2443924446
/* no program is valid */
2444024447
if (ARRAY_SIZE(bpf_verifier_ops) == 0)
2444124448
return -EINVAL;

0 commit comments

Comments
 (0)