add ringbuf reserve function

This commit is contained in:
2025-10-02 06:07:17 +05:30
parent 1a66887f48
commit 2a93a325ce
5 changed files with 82 additions and 33 deletions

View File

@ -28,22 +28,22 @@ int trace_execve(void *ctx)
// Reserve space in the ringbuffer
e = bpf_ringbuf_reserve(&events, sizeof(*e), 0);
if (!e)
return 0;
// Fill the struct with data
pid_tgid = bpf_get_current_pid_tgid();
e->pid = pid_tgid >> 32;
uid_gid = bpf_get_current_uid_gid();
e->uid = uid_gid & 0xFFFFFFFF;
e->timestamp = bpf_ktime_get_ns();
bpf_get_current_comm(&e->comm, sizeof(e->comm));
// Submit the event to ringbuffer
bpf_ringbuf_submit(e, 0);
// if (!e)
// return 0;
//
// // Fill the struct with data
// pid_tgid = bpf_get_current_pid_tgid();
// e->pid = pid_tgid >> 32;
//
// uid_gid = bpf_get_current_uid_gid();
// e->uid = uid_gid & 0xFFFFFFFF;
//
// e->timestamp = bpf_ktime_get_ns();
//
// bpf_get_current_comm(&e->comm, sizeof(e->comm));
//
// // Submit the event to ringbuffer
// bpf_ringbuf_submit(e, 0);
return 0;
}