btf_loader: Support for multiple BTF_DECL_TAGs pointing to same tag
btf_loader issues a warning when it sees several BTF_DECL_TAGs
pointing to the same type. Such situation is possible in practice
after patch [0], that marks certain functions with kfunc and
bpf_fastcall tags. E.g.:
$ pfunct vmlinux -F btf -f bpf_rdonly_cast
WARNING: still unsuported BTF_KIND_DECL_TAG(bpf_fastcall) for bpf_cast_to_kern_ctx already with attribute (bpf_kfunc), ignoring
WARNING: still unsuported BTF_KIND_DECL_TAG(bpf_fastcall) for bpf_rdonly_cast already with attribute (bpf_kfunc), ignoring
bpf_kfunc void * bpf_rdonly_cast(const void * obj__ign, u32 btf_id__k);
This commit extends 'struct tag' to allow attaching multiple
attributes. Define 'struct attributes' as follows:
struct attributes {
uint64_t cnt;
const char *values[];
};
In order to avoid adding counter field in 'struct tag',
as not many instances of 'struct tag' would have attributes.
Same command after this patch:
$ pfunct vmlinux -F btf -f bpf_rdonly_cast
bpf_kfunc bpf_fastcall void * bpf_rdonly_cast(const void * obj__ign, u32 btf_id__k);
[0] https://lore.kernel.org/dwarves/094b626d44e817240ae8e44b6f7933b13c26d879.camel@gmail.com/T/#m8a6cb49a99d1b2ba38d616495a540ae8fc5f3a76
Closes: https://lore.kernel.org/dwarves/Z1dFXVFYmQ-nHSVO@x1/
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: kernel-team@fb.com
Link: https://lore.kernel.org/r/20241211021227.2341735-1-eddyz87@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
6 files changed