bpf: Make btf_find_field more generic
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 15 Apr 2022 16:03:42 +0000 (21:33 +0530)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Apr 2022 14:31:10 +0000 (16:31 +0200)
commit42ba1308074d9046386d58b56e793604be48ce22
treee89277c0f83b906d8dee3457346e962c4f789cb8
parenta66ab9a9e66ab868de7063622d91442181deba0f
bpf: Make btf_find_field more generic

Next commit introduces field type 'kptr' whose kind will not be struct,
but pointer, and it will not be limited to one offset, but multiple
ones. Make existing btf_find_struct_field and btf_find_datasec_var
functions amenable to use for finding kptrs in map value, by moving
spin_lock and timer specific checks into their own function.

The alignment, and name are checked before the function is called, so it
is the last point where we can skip field or return an error before the
next loop iteration happens. Size of the field and type is meant to be
checked inside the function.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220415160354.1050687-2-memxor@gmail.com
kernel/bpf/btf.c