libbpf: Simplify BPF_CORE_READ_BITFIELD_PROBED usage
authorAndrii Nakryiko <andriin@fb.com>
Wed, 6 Nov 2019 20:15:00 +0000 (12:15 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 6 Nov 2019 21:54:59 +0000 (13:54 -0800)
commited578021210e14f15a654c825fba6a700c9a39a7
tree0c47815ef3f5ba07f5e0e1262b9a6127fed70bca
parent65a052d537f40e992eb1629cc6c25874064f51fd
libbpf: Simplify BPF_CORE_READ_BITFIELD_PROBED usage

Streamline BPF_CORE_READ_BITFIELD_PROBED interface to follow
BPF_CORE_READ_BITFIELD (direct) and BPF_CORE_READ, in general, i.e., just
return read result or 0, if underlying bpf_probe_read() failed.

In practice, real applications rarely check bpf_probe_read() result, because
it has to always work or otherwise it's a bug. So propagating internal
bpf_probe_read() error from this macro hurts usability without providing real
benefits in practice. This patch fixes the issue and simplifies usage,
noticeable even in selftest itself.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20191106201500.2582438-1-andriin@fb.com
tools/lib/bpf/bpf_core_read.h
tools/testing/selftests/bpf/progs/test_core_reloc_bitfields_probed.c