1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2020 Google LLC.
10 #include <linux/udp.h>
11 #include <bpf/bpf_helpers.h>
13 #include "progs/cg_storage_multi.h"
16 __uint(type
, BPF_MAP_TYPE_CGROUP_STORAGE
);
17 __type(key
, struct bpf_cgroup_storage_key
);
18 __type(value
, struct cgroup_value
);
19 } cgroup_storage
SEC(".maps");
21 __u32 invocations
= 0;
23 SEC("cgroup_skb/egress/1")
24 int egress1(struct __sk_buff
*skb
)
26 struct cgroup_value
*ptr_cg_storage
=
27 bpf_get_local_storage(&cgroup_storage
, 0);
29 __sync_fetch_and_add(&ptr_cg_storage
->egress_pkts
, 1);
30 __sync_fetch_and_add(&invocations
, 1);
35 SEC("cgroup_skb/egress/2")
36 int egress2(struct __sk_buff
*skb
)
38 struct cgroup_value
*ptr_cg_storage
=
39 bpf_get_local_storage(&cgroup_storage
, 0);
41 __sync_fetch_and_add(&ptr_cg_storage
->egress_pkts
, 1);
42 __sync_fetch_and_add(&invocations
, 1);
47 SEC("cgroup_skb/ingress")
48 int ingress(struct __sk_buff
*skb
)
50 struct cgroup_value
*ptr_cg_storage
=
51 bpf_get_local_storage(&cgroup_storage
, 0);
53 __sync_fetch_and_add(&ptr_cg_storage
->ingress_pkts
, 1);
54 __sync_fetch_and_add(&invocations
, 1);