All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
@ 2020-12-08 17:36 Florent Revest
  2020-12-08 20:06 ` Randy Dunlap
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Florent Revest @ 2020-12-08 17:36 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, kpsingh, rdunlap, kafai, linux-next,
	linux-kernel, Florent Revest, kernel test robot

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>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Florent Revest <revest@chromium.org>
---
 include/linux/bpf.h      |  1 +
 kernel/trace/bpf_trace.c | 22 ++--------------------
 net/core/filter.c        | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index d05e75ed8c1b..07cb5d15e743 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1859,6 +1859,7 @@ extern const struct bpf_func_proto bpf_snprintf_btf_proto;
 extern const struct bpf_func_proto bpf_per_cpu_ptr_proto;
 extern const struct bpf_func_proto bpf_this_cpu_ptr_proto;
 extern const struct bpf_func_proto bpf_ktime_get_coarse_ns_proto;
+extern const struct bpf_func_proto bpf_sock_from_file_proto;
 
 const struct bpf_func_proto *bpf_tracing_func_proto(
 	enum bpf_func_id func_id, const struct bpf_prog *prog);
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 ?
diff --git a/net/core/filter.c b/net/core/filter.c
index 77001a35768f..255aeee72402 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -10413,6 +10413,24 @@ const struct bpf_func_proto bpf_skc_to_udp6_sock_proto = {
 	.ret_btf_id		= &btf_sock_ids[BTF_SOCK_TYPE_UDP6],
 };
 
+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)
+
+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],
+};
+
 static const struct bpf_func_proto *
 bpf_sk_base_func_proto(enum bpf_func_id func_id)
 {
-- 
2.29.2.576.ga3fc446d84-goog


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

* Re: [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
  2020-12-08 17:36 [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET Florent Revest
@ 2020-12-08 20:06 ` Randy Dunlap
  2020-12-08 20:19   ` Florent Revest
  2020-12-08 20:54 ` Martin KaFai Lau
  2020-12-09  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2020-12-08 20:06 UTC (permalink / raw)
  To: Florent Revest, bpf
  Cc: ast, daniel, andrii, kpsingh, kafai, linux-next, linux-kernel,
	kernel test robot

On 12/8/20 9:36 AM, Florent Revest wrote:
> 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>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>

I would say that I didn't ack this version of the patch (hey,
it's 3x the size of the v1/v2 patches), but I have just
rebuilt with v3, so the Ack is OK.  :)


> Signed-off-by: Florent Revest <revest@chromium.org>
> ---
>  include/linux/bpf.h      |  1 +
>  kernel/trace/bpf_trace.c | 22 ++--------------------
>  net/core/filter.c        | 18 ++++++++++++++++++
>  3 files changed, 21 insertions(+), 20 deletions(-)


-- 
~Randy


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

* Re: [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
  2020-12-08 20:06 ` Randy Dunlap
@ 2020-12-08 20:19   ` Florent Revest
  0 siblings, 0 replies; 6+ messages in thread
From: Florent Revest @ 2020-12-08 20:19 UTC (permalink / raw)
  To: Randy Dunlap, bpf
  Cc: ast, daniel, andrii, kpsingh, kafai, linux-next, linux-kernel,
	kernel test robot

On Tue, 2020-12-08 at 12:06 -0800, Randy Dunlap wrote:
> On 12/8/20 9:36 AM, Florent Revest wrote:
> > Acked-by: Randy Dunlap <rdunlap@infradead.org>
> 
> I would say that I didn't ack this version of the patch (hey,
> it's 3x the size of the v1/v2 patches), but I have just
> rebuilt with v3, so the Ack is OK.  :)

Oops! I'll be more careful in the future, thank you Randy. ;)


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

* Re: [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
  2020-12-08 17:36 [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET Florent Revest
  2020-12-08 20:06 ` Randy Dunlap
@ 2020-12-08 20:54 ` Martin KaFai Lau
  2020-12-08 21:58   ` KP Singh
  2020-12-09  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Martin KaFai Lau @ 2020-12-08 20:54 UTC (permalink / raw)
  To: Florent Revest
  Cc: bpf, ast, daniel, andrii, kpsingh, rdunlap, linux-next,
	linux-kernel, kernel test robot

On Tue, Dec 08, 2020 at 06:36:23PM +0100, Florent Revest wrote:
> 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.
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
  2020-12-08 20:54 ` Martin KaFai Lau
@ 2020-12-08 21:58   ` KP Singh
  0 siblings, 0 replies; 6+ messages in thread
From: KP Singh @ 2020-12-08 21:58 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: Florent Revest, bpf, ast, daniel, andrii, kpsingh, rdunlap,
	linux-next, linux-kernel, kernel test robot

On Tue, Dec 8, 2020 at 9:56 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Tue, Dec 08, 2020 at 06:36:23PM +0100, Florent Revest wrote:
> > 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.
> Acked-by: Martin KaFai Lau <kafai@fb.com>

Acked-by: KP Singh <kpsingh@kernel.org>

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

* Re: [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
  2020-12-08 17:36 [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET Florent Revest
  2020-12-08 20:06 ` Randy Dunlap
  2020-12-08 20:54 ` Martin KaFai Lau
@ 2020-12-09  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-09  2:30 UTC (permalink / raw)
  To: Florent Revest
  Cc: bpf, ast, daniel, andrii, kpsingh, rdunlap, kafai, linux-next,
	linux-kernel, lkp

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue,  8 Dec 2020 18:36:23 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET
    https://git.kernel.org/bpf/bpf-next/c/b60da4955f53

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2020-12-09  2:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 17:36 [PATCH bpf-next v3] bpf: Only provide bpf_sock_from_file with CONFIG_NET Florent Revest
2020-12-08 20:06 ` Randy Dunlap
2020-12-08 20:19   ` Florent Revest
2020-12-08 20:54 ` Martin KaFai Lau
2020-12-08 21:58   ` KP Singh
2020-12-09  2:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.