Skip to content

Commit b23e97f

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
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. Intended usage looks as follows: if (bpf_core_enum_value_exists(enum bpf_features, BPF_FEAT_<f>)) ... use feature f ... Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 0967f53 commit b23e97f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/bpf/verifier.c

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

47+
enum bpf_features {
48+
__MAX_BPF_FEAT,
49+
};
50+
4751
struct bpf_mem_alloc bpf_global_percpu_ma;
4852
static bool bpf_global_percpu_ma_set;
4953

@@ -24439,6 +24443,8 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
2443924443
u32 log_true_size;
2444024444
bool is_priv;
2444124445

24446+
BTF_TYPE_EMIT(enum bpf_features);
24447+
2444224448
/* no program is valid */
2444324449
if (ARRAY_SIZE(bpf_verifier_ops) == 0)
2444424450
return -EINVAL;

0 commit comments

Comments
 (0)