Skip to content

Commit 1757c4b

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, omit the above two types for BTF_SOCK_TYPE_xxx macro if CONFIG_INET is not defined. Fixes: fce557b ("bpf: Make btf_sock_ids global") Reported-by: Michal Kubecek <[email protected]> Signed-off-by: Yonghong Song <[email protected]> Acked-by: Andrii Nakryiko <[email protected]>
1 parent ca7924b commit 1757c4b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

include/linux/btf_ids.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,36 @@ 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+
#define __BTF_SOCK_TW_TYPE_xxx \
120+
BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
121+
BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock)
122+
123+
#ifdef CONFIG_INET
124+
#define BTF_SOCK_TYPE_xxx \
125+
__BTF_SOCK_TYPE_xxx \
126+
__BTF_SOCK_TW_TYPE_xxx
127+
#else
128+
#define BTF_SOCK_TYPE_xxx __BTF_SOCK_TYPE_xxx
129+
#endif
130+
120131
enum {
121132
#define BTF_SOCK_TYPE(name, str) name,
122-
BTF_SOCK_TYPE_xxx
133+
__BTF_SOCK_TYPE_xxx
134+
__BTF_SOCK_TW_TYPE_xxx
123135
#undef BTF_SOCK_TYPE
124136
MAX_BTF_SOCK_TYPE,
125137
};

0 commit comments

Comments
 (0)