Skip to content

Commit 2a2beab

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, for two timewait structures, if CONFIG_INET=n, use BTF_ID_UNUSED instead of BTF_ID to skip btf id generation in resolve_btfids. Fixes: fce557b ("bpf: Make btf_sock_ids global") Reported-by: Michal Kubecek <mkubecek@suse.cz> Signed-off-by: Yonghong Song <yhs@fb.com>
1 parent fcd416a commit 2a2beab

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

include/linux/btf_ids.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,37 @@ asm( \
102102
* skc_to_*_sock() helpers. All these sockets should have
103103
* sock_common as the first argument in its memory layout.
104104
*/
105-
#define BTF_SOCK_TYPE_xxx \
105+
106+
#define __BTF_SOCK_TYPE_xxx \
106107
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \
107108
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \
108109
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \
109-
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
110110
BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \
111111
BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \
112112
BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \
113113
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \
114114
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \
115-
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \
116115
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \
117116
BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \
118117
BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock)
119118

119+
#ifdef CONFIG_INET
120+
#define __BTF_SOCK_TW_TYPE_xxx \
121+
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
122+
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock)
123+
#else
124+
#define __BTF_SOCK_TW_TYPE_xxx \
125+
BTF_SOCK_TYPE_UNUSED(BTF_SOCK_TYPE_INET_TW) \
126+
BTF_SOCK_TYPE_UNUSED(BTF_SOCK_TYPE_TCP_TW)
127+
#endif
128+
129+
#define BTF_SOCK_TYPE_xxx \
130+
__BTF_SOCK_TYPE_xxx \
131+
__BTF_SOCK_TW_TYPE_xxx
132+
120133
enum {
121134
#define BTF_SOCK_TYPE(name, str) name,
135+
#define BTF_SOCK_TYPE_UNUSED(name) name,
122136
BTF_SOCK_TYPE_xxx
123137
#undef BTF_SOCK_TYPE
124138
MAX_BTF_SOCK_TYPE,

net/core/filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9500,6 +9500,7 @@ void bpf_prog_change_xdp(struct bpf_prog *prev_prog, struct bpf_prog *prog)
95009500
#ifdef CONFIG_DEBUG_INFO_BTF
95019501
BTF_ID_LIST_GLOBAL(btf_sock_ids)
95029502
#define BTF_SOCK_TYPE(name, type) BTF_ID(struct, type)
9503+
#define BTF_SOCK_TYPE_UNUSED(name) BTF_ID_UNUSED
95039504
BTF_SOCK_TYPE_xxx
95049505
#undef BTF_SOCK_TYPE
95059506
#else

0 commit comments

Comments
 (0)