xref: /linux/tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include "vmlinux.h"
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
6 #include "../bpf_testmod/bpf_testmod.h"
7 #include "bpf_misc.h"
8 
9 SEC("tp_btf/bpf_testmod_test_nullable_bare")
10 /* This used to be a failure test, but raw_tp nullable arguments can now
11  * directly be dereferenced, whether they have nullable annotation or not,
12  * and don't need to be explicitly checked.
13  */
14 __success
15 int BPF_PROG(handle_tp_btf_nullable_bare1, struct bpf_testmod_test_read_ctx *nullable_ctx)
16 {
17 	return nullable_ctx->len;
18 }
19 
20 SEC("tp_btf/bpf_testmod_test_nullable_bare")
21 int BPF_PROG(handle_tp_btf_nullable_bare2, struct bpf_testmod_test_read_ctx *nullable_ctx)
22 {
23 	if (nullable_ctx)
24 		return nullable_ctx->len;
25 	return 0;
26 }
27 
28 char _license[] SEC("license") = "GPL";
29