bpf: Add selftests for local_storage
authorKP Singh <kpsingh@google.com>
Tue, 25 Aug 2020 18:29:19 +0000 (20:29 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Aug 2020 22:00:04 +0000 (15:00 -0700)
commitcd324d7abb3d850ae083bda1239f800abe21fe25
treef24d4ea8decc92139a1acaaf8e68024420293bb5
parent30897832d8b97e93833fb52c0a02951db3692ed2
bpf: Add selftests for local_storage

inode_local_storage:

* Hook to the file_open and inode_unlink LSM hooks.
* Create and unlink a temporary file.
* Store some information in the inode's bpf_local_storage during
  file_open.
* Verify that this information exists when the file is unlinked.

sk_local_storage:

* Hook to the socket_post_create and socket_bind LSM hooks.
* Open and bind a socket and set the sk_storage in the
  socket_post_create hook using the start_server helper.
* Verify if the information is set in the socket_bind hook.

Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200825182919.1118197-8-kpsingh@chromium.org
tools/testing/selftests/bpf/prog_tests/test_local_storage.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/local_storage.c [new file with mode: 0644]