OSDN Git Service

bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP
authorMartin KaFai Lau <kafai@fb.com>
Thu, 12 Nov 2020 21:13:13 +0000 (13:13 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Nov 2020 02:39:28 +0000 (18:39 -0800)
commit8e4597c627fb48f361e2a5b012202cb1b6cbcd5e
treefeab62b4fd4006ab7d2536ec40b8aa923506eb9e
parente794bfddb8b8521bd016e73b411d6b03149e9e66
bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP

This patch enables the FENTRY/FEXIT/RAW_TP tracing program to use
the bpf_sk_storage_(get|delete) helper, so those tracing programs
can access the sk's bpf_local_storage and the later selftest
will show some examples.

The bpf_sk_storage is currently used in bpf-tcp-cc, tc,
cg sockops...etc which is running either in softirq or
task context.

This patch adds bpf_sk_storage_get_tracing_proto and
bpf_sk_storage_delete_tracing_proto.  They will check
in runtime that the helpers can only be called when serving
softirq or running in a task context.  That should enable
most common tracing use cases on sk.

During the load time, the new tracing_allowed() function
will ensure the tracing prog using the bpf_sk_storage_(get|delete)
helper is not tracing any bpf_sk_storage*() function itself.
The sk is passed as "void *" when calling into bpf_local_storage.

This patch only allows tracing a kernel function.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201112211313.2587383-1-kafai@fb.com
include/net/bpf_sk_storage.h
kernel/trace/bpf_trace.c
net/core/bpf_sk_storage.c