bpf: Fix "unresolved symbol" build error with resolve_btfids
authorYonghong Song <yhs@fb.com>
Thu, 1 Oct 2020 05:13:39 +0000 (22:13 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 1 Oct 2020 16:38:50 +0000 (18:38 +0200)
commitd82a532a611572d85fd2610ec41b5c9e222931b6
tree97397fc70b916f554e8b39ff2ef8d790508c19a2
parenta59cf619787e628b31c310367f869fde26c8ede1
bpf: Fix "unresolved symbol" build error with resolve_btfids

Michal reported a build failure likes below:

   BTFIDS  vmlinux
   FAILED unresolved symbol tcp_timewait_sock
   make[1]: *** [/.../linux-5.9-rc7/Makefile:1176: vmlinux] Error 255

This error can be triggered when config has CONFIG_NET enabled
but CONFIG_INET disabled. In this case, there is no user of
istructs inet_timewait_sock and tcp_timewait_sock and hence
vmlinux BTF types are not generated for these two structures.

To fix the problem, let us force BTF generation for these two
structures with BTF_TYPE_EMIT.

Fixes: fce557bcef11 ("bpf: Make btf_sock_ids global")
Reported-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20201001051339.2549085-1-yhs@fb.com
net/core/filter.c