1 #include <uapi/linux/ptrace.h>
2 #include <linux/sched.h>
4 #define COUNTS COUNTS_T
8 char comm[TASK_COMM_LEN];
15 BPF_HASH(size_sent, struct data_t, struct bytes_t)
19 int do_write_exit(struct pt_regs *ctx) {
20 struct data_t data = {};
21 data.pid = bpf_get_current_pid_tgid();
22 bpf_get_current_comm(&data.comm, sizeof(data.comm));
23 struct bytes_t *bytes;
24 bytes = size_sent.lookup(&data);
25 if (bytes != 0 & bytes->bytes > 0) {
26 sizes.increment(bpf_log2l(bytes->bytes));
28 size_sent.delete(&data);
32 int do_return(struct pt_regs *ctx){
33 struct bytes_t size = {};
34 size.bytes = PT_REGS_RC(ctx);
35 struct bytes_t zero = {0}, *val;
37 struct data_t data = {};
38 bpf_get_current_comm(&data.comm, sizeof(data.comm));
39 data.pid = bpf_get_current_pid_tgid();
40 val = size_sent.lookup_or_init(&data, &zero);
41 size.bytes += val->bytes;
42 size_sent.update(&data, &size);