Debian Codegraph @

examples/ringbuffer/ringbuffer.c

raw symbols SCIP
1 //go:build ignore
2
3 #include "common.h"
4
5 #ifndef TASK_COMM_LEN
6 #define TASK_COMM_LEN 16
7 #endif
8
9 char __license[] SEC("license") = "Dual MIT/GPL";
10
11 struct event {
12 u32 pid;
13 u8 comm[TASK_COMM_LEN];
14 };
15
16 struct {
17 __uint(type, BPF_MAP_TYPE_RINGBUF);
18 __uint(max_entries, 1 << 24);
19 __type(value, struct event);
20 } events SEC(".maps");
21
22 SEC("kprobe/sys_execve")
23 int kprobe_execve(struct pt_regs *ctx) {
24 u64 id = bpf_get_current_pid_tgid();
25 u32 tgid = id >> 32;
26 struct event *task_info;
27
28 task_info = bpf_ringbuf_reserve(&events, sizeof(struct event), 0);
29 if (!task_info) {
30 return 0;
31 }
32
33 task_info->pid = tgid;
34 bpf_get_current_comm(&task_info->comm, TASK_COMM_LEN);
35
36 bpf_ringbuf_submit(task_info, 0);
37
38 return 0;
39 }