1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
3 
4 #include <vmlinux.h>
5 #include <bpf/bpf_tracing.h>
6 #include <bpf/bpf_helpers.h>
7 #include <bpf/bpf_core_read.h>
8 #include "bpf_experimental.h"
9 
10 /* BTF load should fail as bpf_rb_root __contains this type and points to
11  * 'node', but 'node' is not a bpf_rb_node
12  */
13 struct node_data {
14 	int key;
15 	int data;
16 	struct bpf_list_node node;
17 };
18 
19 #define private(name) SEC(".data." #name) __hidden __attribute__((aligned(8)))
20 private(A) struct bpf_spin_lock glock;
21 private(A) struct bpf_rb_root groot __contains(node_data, node);
22 
23 SEC("tc")
24 long rbtree_api_add__wrong_node_type(void *ctx)
25 {
26 	struct node_data *n;
27 
28 	n = bpf_obj_new(typeof(*n));
29 	if (!n)
30 		return 1;
31 
32 	bpf_spin_lock(&glock);
33 	bpf_rbtree_first(&groot);
34 	bpf_spin_unlock(&glock);
35 	return 0;
36 }
37 
38 char _license[] SEC("license") = "GPL";
39