1 // SPDX-License-Identifier: GPL-2.0
4 #include <bpf/bpf_helpers.h>
7 __uint(type, BPF_MAP_TYPE_CGROUP_STORAGE);
8 __type(key, struct bpf_cgroup_storage_key);
10 } cgroup_storage SEC(".maps");
12 SEC("cgroup_skb/egress")
13 int bpf_prog(struct __sk_buff *skb)
17 counter = bpf_get_local_storage(&cgroup_storage, 0);
18 __sync_fetch_and_add(counter, 1);
20 /* Drop one out of every two packets */
21 return (*counter & 1);
24 char _license[] SEC("license") = "GPL";