1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <vmlinux.h> 4 #include <bpf/bpf_helpers.h> 5 6 struct { 7 __uint(type, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE); 8 __type(key, struct bpf_cgroup_storage_key); 9 __type(value, __u64); 10 } storage_map SEC(".maps"); 11 12 struct { 13 __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 14 __uint(max_entries, 1); 15 __uint(key_size, sizeof(__u32)); 16 __uint(value_size, sizeof(__u32)); 17 } prog_array SEC(".maps"); 18 19 SEC("cgroup_skb/egress") 20 int caller_prog(struct __sk_buff *skb) 21 { 22 __u64 *storage; 23 24 storage = bpf_get_local_storage(&storage_map, 0); 25 if (storage) 26 *storage = 1; 27 28 bpf_tail_call(skb, &prog_array, 0); 29 return 1; 30 } 31 32 SEC("cgroup_skb/egress") 33 int callee_prog(struct __sk_buff *skb) 34 { 35 __u64 *storage; 36 37 storage = bpf_get_local_storage(&storage_map, 0); 38 if (storage) 39 *storage = 1; 40 41 return 1; 42 } 43 44 char _license[] SEC("license") = "GPL"; 45