* [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids
@ 2020-10-01 5:13 Yonghong Song
2020-10-01 15:57 ` Martin KaFai Lau
2020-10-01 16:50 ` patchwork-bot+bpf
0 siblings, 2 replies; 3+ messages in thread
From: Yonghong Song @ 2020-10-01 5:13 UTC (permalink / raw)
To: bpf, netdev
Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Michal Kubecek
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: fce557bcef11 ("bpf: Make btf_sock_ids global")
Reported-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
net/core/filter.c | 6 ++++++
1 file changed, 6 insertions(+)
Changelog:
v2 -> v3:
. instead of avoiding generating BTF types which is more
complex, just always generating these BTF types (under CONFIG_NET).
v1 -> v2:
. For unsupported socket times, using BTF_ID_UNUSED to
keep the id as 0. (Martin)
diff --git a/net/core/filter.c b/net/core/filter.c
index 21eaf3b182f2..b5f3faac5e3b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -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;
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids
2020-10-01 5:13 [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids Yonghong Song
@ 2020-10-01 15:57 ` Martin KaFai Lau
2020-10-01 16:50 ` patchwork-bot+bpf
1 sibling, 0 replies; 3+ messages in thread
From: Martin KaFai Lau @ 2020-10-01 15:57 UTC (permalink / raw)
To: Yonghong Song
Cc: bpf, netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team,
Michal Kubecek
On Wed, Sep 30, 2020 at 10:13:39PM -0700, Yonghong Song wrote:
> 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.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids
2020-10-01 5:13 [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids Yonghong Song
2020-10-01 15:57 ` Martin KaFai Lau
@ 2020-10-01 16:50 ` patchwork-bot+bpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bpf @ 2020-10-01 16:50 UTC (permalink / raw)
To: Yonghong Song; +Cc: bpf
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
On Wed, 30 Sep 2020 22:13:39 -0700 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v3] bpf: fix "unresolved symbol" build error with resolve_btfids
https://git.kernel.org/bpf/bpf/c/d82a532a6115
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-01 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 5:13 [PATCH bpf v3] bpf: fix "unresolved symbol" build error with resolve_btfids Yonghong Song
2020-10-01 15:57 ` Martin KaFai Lau
2020-10-01 16:50 ` patchwork-bot+bpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.