public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Only call sock_from_file with CONFIG_NET
@ 2020-12-07 19:55 Florent Revest
  2020-12-07 20:04 ` Florent Revest
  0 siblings, 1 reply; 2+ messages in thread
From: Florent Revest @ 2020-12-07 19:55 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, kpsingh, rdunlap, linux-next, linux-kernel,
	Florent Revest

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: Randy Dunlap <rdunlap@infradead•org>
Signed-off-by: Florent Revest <revest@chromium•org>
---
 kernel/trace/bpf_trace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 0cf0a6331482..877123bae71f 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1272,7 +1272,11 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = {
 
 BPF_CALL_1(bpf_sock_from_file, struct file *, file)
 {
+#ifdef CONFIG_NET
 	return (unsigned long) sock_from_file(file);
+#else
+	return NULL;
+#endif
 }
 
 BTF_ID_LIST(bpf_sock_from_file_btf_ids)
-- 
2.29.2.576.ga3fc446d84-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-07 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-07 19:55 [PATCH bpf-next] bpf: Only call sock_from_file with CONFIG_NET Florent Revest
2020-12-07 20:04 ` Florent Revest

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox