summaryrefslogtreecommitdiff
path: root/kernel/trace
diff options
context:
space:
mode:
authorFlorent Revest <revest@chromium.org>2020-12-08 18:36:23 +0100
committerAlexei Starovoitov <ast@kernel.org>2020-12-08 18:23:36 -0800
commitb60da4955f53d1f50e44351a9c3a37a92503079e (patch)
tree35605a7a6667b10c8dc1354aa76751d4f63f9126 /kernel/trace
parent8bdd8e275ede9786d845b3ec952836e61fd824e9 (diff)
bpf: Only provide bpf_sock_from_file with CONFIG_NET
This moves the bpf_sock_from_file definition into net/core/filter.c which only gets compiled with CONFIG_NET and also moves the helper proto usage next to other tracing helpers that are conditional on CONFIG_NET. This avoids ld: kernel/trace/bpf_trace.o: in function `bpf_sock_from_file': bpf_trace.c:(.text+0xe23): undefined reference to `sock_from_file' When compiling a kernel with BPF and without NET. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Florent Revest <revest@chromium.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Acked-by: KP Singh <kpsingh@kernel.org> Link: https://lore.kernel.org/bpf/20201208173623.1136863-1-revest@chromium.org
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/bpf_trace.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 0cf0a6331482..52ddd217d6a1 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1270,24 +1270,6 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = {
.arg5_type = ARG_ANYTHING,
};
-BPF_CALL_1(bpf_sock_from_file, struct file *, file)
-{
- return (unsigned long) sock_from_file(file);
-}
-
-BTF_ID_LIST(bpf_sock_from_file_btf_ids)
-BTF_ID(struct, socket)
-BTF_ID(struct, file)
-
-static const struct bpf_func_proto bpf_sock_from_file_proto = {
- .func = bpf_sock_from_file,
- .gpl_only = false,
- .ret_type = RET_PTR_TO_BTF_ID_OR_NULL,
- .ret_btf_id = &bpf_sock_from_file_btf_ids[0],
- .arg1_type = ARG_PTR_TO_BTF_ID,
- .arg1_btf_id = &bpf_sock_from_file_btf_ids[1],
-};
-
const struct bpf_func_proto *
bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
@@ -1384,8 +1366,6 @@ bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_per_cpu_ptr_proto;
case BPF_FUNC_bpf_this_cpu_ptr:
return &bpf_this_cpu_ptr_proto;
- case BPF_FUNC_sock_from_file:
- return &bpf_sock_from_file_proto;
default:
return NULL;
}
@@ -1778,6 +1758,8 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_sk_storage_get_tracing_proto;
case BPF_FUNC_sk_storage_delete:
return &bpf_sk_storage_delete_tracing_proto;
+ case BPF_FUNC_sock_from_file:
+ return &bpf_sock_from_file_proto;
#endif
case BPF_FUNC_seq_printf:
return prog->expected_attach_type == BPF_TRACE_ITER ?