Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetra: Add debug progs command #2967

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ PROCESS = bpf_execve_event.o bpf_execve_event_v53.o bpf_fork.o bpf_exit.o bpf_ge
bpf_loader.o \
bpf_cgroup.o \
bpf_enforcer.o bpf_multi_enforcer.o bpf_fmodret_enforcer.o \
bpf_map_test_p1.o bpf_map_test_p2.o bpf_map_test_p3.o
bpf_map_test_p1.o bpf_map_test_p2.o bpf_map_test_p3.o \
bpf_prog_iter.o

CGROUP = bpf_cgroup_mkdir.o bpf_cgroup_rmdir.o bpf_cgroup_release.o
BPFTEST = bpf_lseek.o
Expand Down
2 changes: 2 additions & 0 deletions bpf/include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ static long BPF_FUNC(sock_ops_cb_flags_set, struct bpf_sock_ops *bpf_sock, int a
static long BPF_FUNC(ima_file_hash, struct file *file, void *dst, uint32_t size);
static long BPF_FUNC(ima_inode_hash, struct inode *inode, void *dst, uint32_t size);

static int BPF_FUNC(seq_write, struct seq_file *m, const void *data, uint32_t len);

/** LLVM built-ins, mem*() routines work for constant size */

#ifndef lock_xadd
Expand Down
9 changes: 9 additions & 0 deletions bpf/include/vmlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -33383,6 +33383,15 @@ struct bpf_iter_seq_task_file_info {
u32 fd;
};

struct bpf_iter__bpf_prog {
union {
struct bpf_iter_meta *meta;
};
union {
struct bpf_prog *prog;
};
};

struct bpf_iter__task_file {
union {
struct bpf_iter_meta *meta;
Expand Down
21 changes: 21 additions & 0 deletions bpf/process/bpf_prog_iter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright Authors of Cilium */

#include "vmlinux.h"
#include "bpf_helpers.h"

SEC("iter/bpf_prog")
int iter(struct bpf_iter__bpf_prog *ctx)
{
struct bpf_prog *prog = ctx->prog;
__u32 id;

if (!prog)
return 0;

_(id = prog->aux->id);
seq_write(ctx->meta->seq, &id, sizeof(id));
return 0;
}

char LICENSE[] SEC("license") = "Dual BSD/GPL";
1 change: 1 addition & 0 deletions cmd/tetra/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ func New() *cobra.Command {
}
cmd.AddCommand(NewMapCmd())
cmd.AddCommand(NewDumpCommand())
cmd.AddCommand(NewProgsCmd())
return &cmd
}
Loading
Loading