netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined
@ 2018-11-20 22:08 Yonghong Song
  2018-11-20 23:23 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2018-11-20 22:08 UTC (permalink / raw)
  To: ast, daniel, netdev, kbuild-all; +Cc: kernel-team, Martin KaFai Lau

Kernel test robot (lkp@intel.com) reports a compilation error at
  https://www.spinics.net/lists/netdev/msg534913.html
introduced by commit 838e96904ff3 ("bpf: Introduce bpf_func_info").

If CONFIG_BPF is defined and CONFIG_BPF_SYSCALL is not defined,
the following error will appear:
  kernel/bpf/core.c:414: undefined reference to `btf_type_by_id'
  kernel/bpf/core.c:415: undefined reference to `btf_name_by_offset'

When CONFIG_BPF_SYSCALL is not defined,
let us define stub inline functions for btf_type_by_id()
and btf_name_by_offset() in include/linux/btf.h.
This way, the compilation failure can be avoided.

Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info")
Reported-by: kbuild test robot <lkp@intel.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
 include/linux/btf.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Changelog:
  v1 -> v2:
    . Two functions should be static inline functions
      if CONFIG_BPF_SYSCALL is not defined.

diff --git a/include/linux/btf.h b/include/linux/btf.h
index 7f2c0a4a45ea..8c2199b5d250 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -46,7 +46,21 @@ void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj,
 		       struct seq_file *m);
 int btf_get_fd_by_id(u32 id);
 u32 btf_id(const struct btf *btf);
+
+#ifdef CONFIG_BPF_SYSCALL
 const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id);
 const char *btf_name_by_offset(const struct btf *btf, u32 offset);
+#else
+static inline const struct btf_type *btf_type_by_id(const struct btf *btf,
+						    u32 type_id)
+{
+	return NULL;
+}
+static inline const char *btf_name_by_offset(const struct btf *btf,
+					     u32 offset)
+{
+	return NULL;
+}
+#endif
 
 #endif
-- 
2.17.1

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

* Re: [PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined
  2018-11-20 22:08 [PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined Yonghong Song
@ 2018-11-20 23:23 ` Alexei Starovoitov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2018-11-20 23:23 UTC (permalink / raw)
  To: Yonghong Song
  Cc: ast, daniel, netdev, kbuild-all, kernel-team, Martin KaFai Lau

On Tue, Nov 20, 2018 at 02:08:20PM -0800, Yonghong Song wrote:
> Kernel test robot (lkp@intel.com) reports a compilation error at
>   https://www.spinics.net/lists/netdev/msg534913.html
> introduced by commit 838e96904ff3 ("bpf: Introduce bpf_func_info").
> 
> If CONFIG_BPF is defined and CONFIG_BPF_SYSCALL is not defined,
> the following error will appear:
>   kernel/bpf/core.c:414: undefined reference to `btf_type_by_id'
>   kernel/bpf/core.c:415: undefined reference to `btf_name_by_offset'
> 
> When CONFIG_BPF_SYSCALL is not defined,
> let us define stub inline functions for btf_type_by_id()
> and btf_name_by_offset() in include/linux/btf.h.
> This way, the compilation failure can be avoided.
> 
> Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info")
> Reported-by: kbuild test robot <lkp@intel.com>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Yonghong Song <yhs@fb.com>

Applied, Thanks

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

end of thread, other threads:[~2018-11-21  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-20 22:08 [PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined Yonghong Song
2018-11-20 23:23 ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).