diff options
author | Matteo Croce <mcroce@microsoft.com> | 2022-02-04 01:55:19 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-02-04 11:29:01 -0800 |
commit | 976a38e05a49f401cf9ae3ae20273db6d69783cf (patch) | |
tree | aacf4465982ac8e65482c3e844d161e4b360a33b /tools/testing/selftests/bpf/progs/core_kern.c | |
parent | e70e13e7d4ab8f932f49db1c9500b30a34a6d420 (diff) | |
download | linux-stable-976a38e05a49f401cf9ae3ae20273db6d69783cf.tar.gz linux-stable-976a38e05a49f401cf9ae3ae20273db6d69783cf.tar.bz2 linux-stable-976a38e05a49f401cf9ae3ae20273db6d69783cf.zip |
selftests/bpf: Test bpf_core_types_are_compat() functionality.
Add several tests to check bpf_core_types_are_compat() functionality:
- candidate type name exists and types match
- candidate type name exists but types don't match
- nested func protos at kernel recursion limit
- nested func protos above kernel recursion limit. Such bpf prog
is rejected during the load.
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220204005519.60361-3-mcroce@linux.microsoft.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/core_kern.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/core_kern.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/core_kern.c b/tools/testing/selftests/bpf/progs/core_kern.c index 13499cc15c7d..2715fe27d4cf 100644 --- a/tools/testing/selftests/bpf/progs/core_kern.c +++ b/tools/testing/selftests/bpf/progs/core_kern.c @@ -101,4 +101,20 @@ int balancer_ingress(struct __sk_buff *ctx) return 0; } +typedef int (*func_proto_typedef___match)(long); +typedef int (*func_proto_typedef___doesnt_match)(char *); +typedef int (*func_proto_typedef_nested1)(func_proto_typedef___match); + +int proto_out[3]; + +SEC("raw_tracepoint/sys_enter") +int core_relo_proto(void *ctx) +{ + proto_out[0] = bpf_core_type_exists(func_proto_typedef___match); + proto_out[1] = bpf_core_type_exists(func_proto_typedef___doesnt_match); + proto_out[2] = bpf_core_type_exists(func_proto_typedef_nested1); + + return 0; +} + char LICENSE[] SEC("license") = "GPL"; |