Commit b9f4c01f3e0b ("selftest/bpf: Make bpf_iter selftest compilable against old vmlinux.h") and Commit dda18a5c0b75 ("selftests/bpf: Convert bpf_iter_test_kern{3, 4}.c to define own bpf_iter_meta") redefined newly introduced types in bpf programs so the bpf program can still compile properly with old kernels although loading may fail. Since this patch set introduced new types and the same workaround is needed, so let us move the workaround to a separate header file so they do not clutter bpf programs. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200623230816.3988656-1-yhs@fb.com
27 lines
665 B
C
27 lines
665 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2020 Facebook */
|
|
#include "bpf_iter.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
SEC("iter/task_file")
|
|
int dump_task_file(struct bpf_iter__task_file *ctx)
|
|
{
|
|
struct seq_file *seq = ctx->meta->seq;
|
|
struct task_struct *task = ctx->task;
|
|
__u32 fd = ctx->fd;
|
|
struct file *file = ctx->file;
|
|
|
|
if (task == (void *)0 || file == (void *)0)
|
|
return 0;
|
|
|
|
if (ctx->meta->seq_num == 0)
|
|
BPF_SEQ_PRINTF(seq, " tgid gid fd file\n");
|
|
|
|
BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd,
|
|
(long)file->f_op);
|
|
return 0;
|
|
}
|