bpf: extract bpf_ctx_convert_map logic and make it more reusable
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 18 Jan 2024 03:31:40 +0000 (19:31 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 18 Jan 2024 04:20:05 +0000 (20:20 -0800)
commit66967a32d3b16ed447e76fed4d946bab52e43d86
treecf12401fd7bc09c7a4b63ce9eadbe67ce63038b2
parent01b55f4f0cd6ad1a16eca6c43a3190005892ef91
bpf: extract bpf_ctx_convert_map logic and make it more reusable

Refactor btf_get_prog_ctx_type() a bit to allow reuse of
bpf_ctx_convert_map logic in more than one places. Simplify interface by
returning btf_type instead of btf_member (field reference in BTF).

To do the above we need to touch and start untangling
btf_translate_to_vmlinux() implementation. We do the bare minimum to
not regress anything for btf_translate_to_vmlinux(), but its
implementation is very questionable for what it claims to be doing.
Mapping kfunc argument types to kernel corresponding types conceptually
is quite different from recognizing program context types. Fixing this
is out of scope for this change though.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240118033143.3384355-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf.h
kernel/bpf/btf.c