selftests/bpf: Add __contains macro to bpf_experimental.h
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 18 Nov 2022 01:56:09 +0000 (07:26 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 18 Nov 2022 03:22:14 +0000 (19:22 -0800)
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.

Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20221118015614.2013203-20-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/bpf_experimental.h

index d6b143275e82342ae11486a7ff5588b30b1401cc..424f7bbbfe9b89e4c6ee50b2359ca8a051632816 100644 (file)
@@ -6,6 +6,8 @@
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_core_read.h>
 
+#define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node)))
+
 /* Description
  *     Allocates an object of the type represented by 'local_type_id' in
  *     program BTF. User may use the bpf_core_type_id_local macro to pass the