• Martin KaFai Lau's avatar
    bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP · 8e4597c6
    Martin KaFai Lau authored
    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: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarSong Liu <songliubraving@fb.com>
    Link: https://lore.kernel.org/bpf/20201112211313.2587383-1-kafai@fb.com
    8e4597c6
bpf_sk_storage.c 22.9 KB