OSDN Git Service

selftests/bpf: Add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET tests
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 23 May 2023 17:00:13 +0000 (10:00 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 May 2023 21:41:07 +0000 (23:41 +0200)
commit3b22f98e5a05feee20699df0870dc5d47c9b61dd
treea5fe13fa1ed1702f0b2e486f6ecf50fc29757cbf
parentf1674dc79fd276aeef6cad738a5f25ed2ba6d329
selftests/bpf: Add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET tests

Add a selftest demonstrating using detach-mounted BPF FS using new mount
APIs, and pinning and getting BPF map using such mount. This
demonstrates how something like container manager could setup BPF FS,
pin and adjust all the necessary objects in it, all before exposing BPF
FS to a particular mount namespace.

Also add a few subtests validating all meaningful combinations of
path_fd and pathname. We use mounted /sys/fs/bpf location for these.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230523170013.728457-5-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c [new file with mode: 0644]