Skip to content

Commit 8ae211f

Browse files
Florent Revestkernel-patches-bot
Florent Revest
authored andcommitted
bpf: Expose bpf_sk_storage_* to iterator programs
Iterators are currently used to expose kernel information to userspace over fast procfs-like files but iterators could also be used to initialize local storage. For example, the task_file iterator could be used to store associations between processes and sockets. This exposes the socket local storage helpers to all iterators. Martin Kafai checked that this was safe to call these helpers from the sk_storage_map iterators. Signed-off-by: Florent Revest <revest@google.com>
1 parent cfc26c2 commit 8ae211f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kernel/trace/bpf_trace.c

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/error-injection.h>
1818
#include <linux/btf_ids.h>
1919

20+
#include <net/bpf_sk_storage.h>
21+
2022
#include <uapi/linux/bpf.h>
2123
#include <uapi/linux/btf.h>
2224

@@ -1750,6 +1752,14 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
17501752
NULL;
17511753
case BPF_FUNC_d_path:
17521754
return &bpf_d_path_proto;
1755+
case BPF_FUNC_sk_storage_get:
1756+
return prog->expected_attach_type == BPF_TRACE_ITER ?
1757+
&bpf_sk_storage_get_proto :
1758+
NULL;
1759+
case BPF_FUNC_sk_storage_delete:
1760+
return prog->expected_attach_type == BPF_TRACE_ITER ?
1761+
&bpf_sk_storage_delete_proto :
1762+
NULL;
17531763
default:
17541764
return raw_tp_prog_func_proto(func_id, prog);
17551765
}

0 commit comments

Comments
 (0)