File Index
Files and directories
Sign in
FILE

test_sk_storage_trace_itself.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/bpf/progs/test_sk_storage_trace_itself.c C
 1// SPDX-License-Identifier: GPL-2.0
 2/* Copyright (c) 2020 Facebook */
 3
 4#include <vmlinux.h>
 5#include <bpf/bpf_tracing.h>
 6#include <bpf/bpf_helpers.h>
 7
 8struct {
 9	__uint(type, BPF_MAP_TYPE_SK_STORAGE);
10	__uint(map_flags, BPF_F_NO_PREALLOC);
11	__type(key, int);
12	__type(value, int);
13} sk_stg_map SEC(".maps");
14
15SEC("fentry/bpf_sk_storage_free")
16int BPF_PROG(trace_bpf_sk_storage_free, struct sock *sk)
17{
18	int *value;
19
20	value = bpf_sk_storage_get(&sk_stg_map, sk, 0,
21				   BPF_SK_STORAGE_GET_F_CREATE);
22
23	if (value)
24		*value = 1;
25
26	return 0;
27}
28
29char _license[] SEC("license") = "GPL";
~/ Read-only file preview.