Slide 22
Slide 22 text
Fork: eBPF Program
Assembles the Clone Event and writes it to the eBPF Map: tcpmon_map
Tetragon eBPF: bpf_fork.c
Mechanism to ignore thread creation and deletion within processes:
Since wake_up_new_task is also called when creating a thread, it checks if a Clone Event has already
been created with the same TGID, and only creates a new one if it hasn’t been created yet.
curr = execve_map_get(tgid);
if (curr->key.ktime != 0) // Check whether the event for the tgid has already been created.
return 0;
``` -->
23 __attribute__((section("kprobe/wake_up_new_task"), used)) int
24 BPF_KPROBE(event_wake_up_new_task, struct task_struct *task)
25 {
26 struct msg_clone_event msg;
27 ...
28 perf_event_output_metric(ctx, MSG_OP_CLONE, &tcpmon_map,
29 BPF_F_CURRENT_CPU, &msg, msg_size); // Write msg_clone_event to tcpmon_map