[PATCH bpf-next v1 24/25] selftests/bpf: Add __contains macro to bpf_experimental.h

Kumar Kartikeya Dwivedi
2022-10-11T01:28:05Z

Add user facing __contains macro which provides a convenient wrapper
over the verbose kernel specific BTF declaration tag required to
annotate BPF list head structs in user types.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
tools/testing/selftests/bpf/bpf_experimental.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index 21b85cd721cb..dc71b58b123c 100644
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -5,6 +5,8 @@
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_core_read.h>

+#define __contains(name, node) __attribute__((btf_decl_tag("contains:struct:" #name ":" #node)))
+
#else

struct bpf_list_head {
--
2.34.1