diff options
author | Yonghong Song <yhs@fb.com> | 2019-12-05 02:06:07 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-12-05 06:34:42 +0100 |
commit | 8f9081c92523328aa569d09051add79a6c0ae9ff (patch) | |
tree | 5cd0f621eb5b96126bf31cc8fec67a49d14e8e51 /tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c | |
parent | bpf: Fix a bug when getting subprog 0 jited image in check_attach_btf_id (diff) | |
download | linux-8f9081c92523328aa569d09051add79a6c0ae9ff.tar.xz linux-8f9081c92523328aa569d09051add79a6c0ae9ff.zip |
selftests/bpf: Add a fexit/bpf2bpf test with target bpf prog no callees
The existing fexit_bpf2bpf test covers the target progrm with callees.
This patch added a test for the target program without callees.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191205010607.177904-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c new file mode 100644 index 000000000000..ebc0ab7f0f5c --- /dev/null +++ b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2019 Facebook */ +#include <linux/bpf.h> +#include "bpf_helpers.h" +#include "bpf_trace_helpers.h" + +struct sk_buff { + unsigned int len; +}; + +__u64 test_result = 0; +BPF_TRACE_2("fexit/test_pkt_md_access", test_main2, + struct sk_buff *, skb, int, ret) +{ + int len; + + __builtin_preserve_access_index(({ + len = skb->len; + })); + if (len != 74 || ret != 0) + return 0; + + test_result = 1; + return 0; +} +char _license[] SEC("license") = "GPL"; |