diff options
author | Yonghong Song <yhs@fb.com> | 2020-09-01 19:31:13 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-09-02 16:40:33 +0200 |
commit | 858e8b2eb4dd6fe6c4640463ad2f2ed3b8249ad4 (patch) | |
tree | 7e2f8b0dd99a8f8315caa48781d948fd13f3d3be /tools/testing/selftests/bpf/progs/bpf_iter_task_file.c | |
parent | 203d7b054fc719561fe258e46e280930890dceaf (diff) | |
download | linux-858e8b2eb4dd6fe6c4640463ad2f2ed3b8249ad4.tar.bz2 |
selftests/bpf: Test task_file iterator without visiting pthreads
Modified existing bpf_iter_test_file.c program to check whether
all accessed files from the main thread or not.
Modified existing bpf_iter_test_file program to check
whether all accessed files from the main thread or not.
$ ./test_progs -n 4
...
#4/7 task_file:OK
...
#4 bpf_iter:OK
Summary: 1/24 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200902023113.1672863-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_iter_task_file.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_iter_task_file.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_file.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_file.c index 8b787baa2654..b2f7c7c5f952 100644 --- a/tools/testing/selftests/bpf/progs/bpf_iter_task_file.c +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_file.c @@ -6,6 +6,9 @@ char _license[] SEC("license") = "GPL"; +int count = 0; +int tgid = 0; + SEC("iter/task_file") int dump_task_file(struct bpf_iter__task_file *ctx) { @@ -17,8 +20,13 @@ int dump_task_file(struct bpf_iter__task_file *ctx) if (task == (void *)0 || file == (void *)0) return 0; - if (ctx->meta->seq_num == 0) + if (ctx->meta->seq_num == 0) { + count = 0; BPF_SEQ_PRINTF(seq, " tgid gid fd file\n"); + } + + if (tgid == task->tgid && task->tgid != task->pid) + count++; BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd, (long)file->f_op); |