0001
0002
0003
0004 #include <vmlinux.h>
0005 #include <bpf/bpf_tracing.h>
0006 #include <bpf/bpf_helpers.h>
0007
0008 struct {
0009 __uint(type, BPF_MAP_TYPE_SK_STORAGE);
0010 __uint(map_flags, BPF_F_NO_PREALLOC);
0011 __type(key, int);
0012 __type(value, int);
0013 } sk_stg_map SEC(".maps");
0014
0015 SEC("fentry/bpf_sk_storage_free")
0016 int BPF_PROG(trace_bpf_sk_storage_free, struct sock *sk)
0017 {
0018 int *value;
0019
0020 value = bpf_sk_storage_get(&sk_stg_map, sk, 0,
0021 BPF_SK_STORAGE_GET_F_CREATE);
0022
0023 if (value)
0024 *value = 1;
0025
0026 return 0;
0027 }
0028
0029 char _license[] SEC("license") = "GPL";