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 static bool less(struct bpf_rb_node *a, const struct bpf_rb_node *b) 20 { 21 struct node_data *node_a; 22 struct node_data *node_b; 23 24 node_a = container_of(a, struct node_data, node); 25 node_b = container_of(b, struct node_data, node); 26 27 return node_a->key < node_b->key; 28 } 29 30 #define private(name) SEC(".data." #name) __hidden __attribute__((aligned(8))) 31 private(A) struct bpf_spin_lock glock; 32 private(A) struct bpf_rb_root groot __contains(node_data, node); 33 34 SEC("tc") 35 long rbtree_api_add__wrong_node_type(void *ctx) 36 { 37 struct node_data *n; 38 39 n = bpf_obj_new(typeof(*n)); 40 if (!n) 41 return 1; 42 43 bpf_spin_lock(&glock); 44 bpf_rbtree_first(&groot); 45 bpf_spin_unlock(&glock); 46 return 0; 47 } 48 49 char _license[] SEC("license") = "GPL"; 50