Skip to content

Commit

Permalink
bpf: Fix "unresolved symbol" build error with resolve_btfids
Browse files Browse the repository at this point in the history
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: fce557b ("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
  • Loading branch information
yonghong-song authored and borkmann committed Oct 1, 2020
1 parent a59cf61 commit d82a532
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -9558,6 +9558,12 @@ const struct bpf_func_proto bpf_skc_to_tcp_sock_proto = {

BPF_CALL_1(bpf_skc_to_tcp_timewait_sock, struct sock *, sk)
{
/* BTF types for tcp_timewait_sock and inet_timewait_sock are not
* generated if CONFIG_INET=n. Trigger an explicit generation here.
*/
BTF_TYPE_EMIT(struct inet_timewait_sock);
BTF_TYPE_EMIT(struct tcp_timewait_sock);

#ifdef CONFIG_INET
if (sk && sk->sk_prot == &tcp_prot && sk->sk_state == TCP_TIME_WAIT)
return (unsigned long)sk;
Expand Down

0 comments on commit d82a532

Please sign in to comment.