Files
aya-mirror/test/integration-test/bpf/iter.bpf.c
Michal Rostecki bf2164c92f feat(aya): Add iterator program type
BPF iterators[0] are a way to dump kernel data into user-space and an
alternative to `/proc` filesystem.

This change adds support for BPF iterators on the user-space side. It
provides a possibility to retrieve the outputs of BPF iterator programs
both from sync and async Rust code.

[0] https://docs.kernel.org/bpf/bpf_iterators.html
2024-11-24 16:27:44 +01:00

24 lines
530 B
C

// clang-format off
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
// clang-format on
char _license[] SEC("license") = "GPL";
SEC("iter/task")
int iter_task(struct bpf_iter__task *ctx) {
struct seq_file *seq = ctx->meta->seq;
struct task_struct *task = ctx->task;
// Verifier requires this check.
if (task == NULL) {
return 0;
}
if (ctx->meta->seq_num == 0) {
BPF_SEQ_PRINTF(seq, "tgid pid name\n");
}
BPF_SEQ_PRINTF(seq, "%-8d %-8d %s\n", task->tgid, task->pid, task->comm);
return 0;
}