1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
8 char _license[] SEC("license") = "GPL";
11 __uint(type, BPF_MAP_TYPE_CGRP_STORAGE);
12 __uint(map_flags, BPF_F_NO_PREALLOC);
18 __uint(type, BPF_MAP_TYPE_CGRP_STORAGE);
19 __uint(map_flags, BPF_F_NO_PREALLOC);
24 SEC("fentry/bpf_local_storage_lookup")
25 int BPF_PROG(on_lookup)
27 struct task_struct *task = bpf_get_current_task_btf();
29 bpf_cgrp_storage_delete(&map_a, task->cgroups->dfl_cgrp);
30 bpf_cgrp_storage_delete(&map_b, task->cgroups->dfl_cgrp);
34 SEC("fentry/bpf_local_storage_update")
35 int BPF_PROG(on_update)
37 struct task_struct *task = bpf_get_current_task_btf();
40 ptr = bpf_cgrp_storage_get(&map_a, task->cgroups->dfl_cgrp, 0,
41 BPF_LOCAL_STORAGE_GET_F_CREATE);
45 ptr = bpf_cgrp_storage_get(&map_b, task->cgroups->dfl_cgrp, 0,
46 BPF_LOCAL_STORAGE_GET_F_CREATE);
53 SEC("tp_btf/sys_enter")
54 int BPF_PROG(on_enter, struct pt_regs *regs, long id)
56 struct task_struct *task;
59 task = bpf_get_current_task_btf();
60 ptr = bpf_cgrp_storage_get(&map_a, task->cgroups->dfl_cgrp, 0,
61 BPF_LOCAL_STORAGE_GET_F_CREATE);
65 ptr = bpf_cgrp_storage_get(&map_b, task->cgroups->dfl_cgrp, 0,
66 BPF_LOCAL_STORAGE_GET_F_CREATE);