Skip to content

Commit ae288e4

Browse files
yonghong-songkernel-patches-bot
authored andcommitted
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 structs 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 <[email protected]> Signed-off-by: Yonghong Song <[email protected]>
1 parent afe24c4 commit ae288e4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/core/filter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9558,6 +9558,12 @@ const struct bpf_func_proto bpf_skc_to_tcp_sock_proto = {
95589558

95599559
BPF_CALL_1(bpf_skc_to_tcp_timewait_sock, struct sock *, sk)
95609560
{
9561+
/* BTF types for tcp_timewait_sock and inet_timewait_sock are not
9562+
* generated if CONFIG_INET=n. Trigger an explicit generation here.
9563+
*/
9564+
BTF_TYPE_EMIT(struct inet_timewait_sock);
9565+
BTF_TYPE_EMIT(struct tcp_timewait_sock);
9566+
95619567
#ifdef CONFIG_INET
95629568
if (sk && sk->sk_prot == &tcp_prot && sk->sk_state == TCP_TIME_WAIT)
95639569
return (unsigned long)sk;

0 commit comments

Comments
 (0)