[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db1cec73-a16a-5407-1bc5-cd7afd557771@fb.com>
Date: Wed, 30 Sep 2020 12:24:48 -0700
From: Yonghong Song <yhs@...com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
CC: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>,
Michal Kubecek <mkubecek@...e.cz>
Subject: Re: [PATCH bpf] bpf: fix "unresolved symbol" build error with
resolve_btfids
On 9/30/20 11:40 AM, Andrii Nakryiko wrote:
> On Wed, Sep 30, 2020 at 9:41 AM Yonghong Song <yhs@...com> 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, omit the above two types for BTF_SOCK_TYPE_xxx
>> macro if CONFIG_INET is not defined.
>>
>> Fixes: fce557bcef11 ("bpf: Make btf_sock_ids global")
>> Reported-by: Michal Kubecek <mkubecek@...e.cz>
>> Signed-off-by: Yonghong Song <yhs@...com>
>> ---
>> include/linux/btf_ids.h | 20 ++++++++++++++++----
>> 1 file changed, 16 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
>> index 4867d549e3c1..d9a1e18d0921 100644
>> --- a/include/linux/btf_ids.h
>> +++ b/include/linux/btf_ids.h
>> @@ -102,24 +102,36 @@ asm( \
>> * skc_to_*_sock() helpers. All these sockets should have
>> * sock_common as the first argument in its memory layout.
>> */
>> -#define BTF_SOCK_TYPE_xxx \
>> +
>> +#define __BTF_SOCK_TYPE_xxx \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \
>> - BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \
>> - BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \
>> BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock)
>>
>> +#define __BTF_SOCK_TW_TYPE_xxx \
>> + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
>> + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock)
>> +
>> +#ifdef CONFIG_INET
>> +#define BTF_SOCK_TYPE_xxx \
>> + __BTF_SOCK_TYPE_xxx \
>> + __BTF_SOCK_TW_TYPE_xxx
>> +#else
>> +#define BTF_SOCK_TYPE_xxx __BTF_SOCK_TYPE_xxx
>> +#endif
>> +
>> enum {
>> #define BTF_SOCK_TYPE(name, str) name,
>> -BTF_SOCK_TYPE_xxx
>> +__BTF_SOCK_TYPE_xxx
>> +__BTF_SOCK_TW_TYPE_xxx
>
> Why BTF_SOCK_TYPE_xxx doesn't still work here after the above changes?
The macro, e.g., BTF_SOCK_TYPE_TCP_TW, still needed to be defined as
it is used to get the location for btf_id.
const struct bpf_func_proto bpf_skc_to_tcp_timewait_sock_proto = {
.func = bpf_skc_to_tcp_timewait_sock,
.gpl_only = false,
.ret_type = RET_PTR_TO_BTF_ID_OR_NULL,
.arg1_type = ARG_PTR_TO_BTF_ID_SOCK_COMMON,
.ret_btf_id = &btf_sock_ids[BTF_SOCK_TYPE_TCP_TW],
};
If CONFIG_INET is not defined, bpf_sock_ids[BTF_SOCK_TYPE_TCP_TW]
will be 0.
>
>> #undef BTF_SOCK_TYPE
>> MAX_BTF_SOCK_TYPE,
>> };
>> --
>> 2.24.1
>>
Powered by blists - more mailing lists