bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined
Subsystems (3)
PATCH v2 1/1 bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined
Kernel test robot ([email protected]) 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.
--- 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.
include/linux/btf.h +14 -0
@@ -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
Signature · 1 line
2.17.1
Alexei Starovoitov
AppliedQuoted 14 lines · Yonghong Song
Kernel test robot ([email protected]) reports a compilation error at
https://www.spinics.net/lists/netdev/msg534913.html
introduced by commit838e96904ff3("bpf: Introducebpf_func_info").If
CONFIG_BPFis defined andCONFIG_BPF_SYSCALLis not defined, the following error will appear:
kernel/bpf/core.c:414: undefined reference tobtf_type_by_id' kernel/bpf/core.c:415: undefined reference tobtf_name_by_offset'When
CONFIG_BPF_SYSCALLis not defined,
let us define stub inline functions forbtf_type_by_id()andbtf_name_by_offset()ininclude/linux/btf.h. This way, the compilation failure can be avoided.
Quoted 4 lines
Fixes 838e96904ff3 ("bpf: Introduce bpf_func_info")Reported-by kbuild test robot <[email protected]>Cc Martin KaFai Lau <[email protected]>Signed-off-by Yonghong Song <[email protected]>
Applied, Thanks