summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
diff options
context:
space:
mode:
authorDave Marchevsky <davemarchevsky@fb.com>2023-04-15 13:18:11 -0700
committerAlexei Starovoitov <ast@kernel.org>2023-04-15 17:36:50 -0700
commit6147f15131e2df544a5449815f456da48c0c88e7 (patch)
tree94d7c2b79cf60f0aecafab0fe209008a27957d44 /tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
parent3e81740a90626024a9d9c6f9bfa3d36204dafefb (diff)
downloadlinux-6147f15131e2df544a5449815f456da48c0c88e7.tar.gz
linux-6147f15131e2df544a5449815f456da48c0c88e7.tar.bz2
linux-6147f15131e2df544a5449815f456da48c0c88e7.zip
selftests/bpf: Add refcounted_kptr tests
Test refcounted local kptr functionality added in previous patches in the series. Usecases which pass verification: * Add refcounted local kptr to both tree and list. Then, read and - possibly, depending on test variant - delete from tree, then list. * Also test doing read-and-maybe-delete in opposite order * Stash a refcounted local kptr in a map_value, then add it to a rbtree. Read from both, possibly deleting after tree read. * Add refcounted local kptr to both tree and list. Then, try reading and deleting twice from one of the collections. * bpf_refcount_acquire of just-added non-owning ref should work, as should bpf_refcount_acquire of owning ref just out of bpf_obj_new Usecases which fail verification: * The simple successful bpf_refcount_acquire cases from above should both fail to verify if the newly-acquired owning ref is not dropped Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com> Link: https://lore.kernel.org/r/20230415201811.343116-10-davemarchevsky@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c b/tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
new file mode 100644
index 000000000000..2ab23832062d
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
+
+#include <test_progs.h>
+#include <network_helpers.h>
+
+#include "refcounted_kptr.skel.h"
+#include "refcounted_kptr_fail.skel.h"
+
+void test_refcounted_kptr(void)
+{
+ RUN_TESTS(refcounted_kptr);
+}
+
+void test_refcounted_kptr_fail(void)
+{
+ RUN_TESTS(refcounted_kptr_fail);
+}