History

bpf: Add basic bpf_rb_{root,node} support

This patch adds special BPF_RB_{ROOT,NODE} btf_field_types similar to BPF_LIST_{HEAD,NODE}, adds the necessary plumbing to detect the new types, and adds bpf_rb_root_free function for freeing bpf_rb_root in map_values. structs bpf_rb_root and bpf_rb_node are opaque types meant to obscure structs rb_root_cached rb_node, respectively. btf_struct_access will prevent BPF programs from touching these special fields automatically now that they're recognized. btf_check_and_fixup_fields now groups list_head and rb_root together as "graph root" fields and {list,rb}_node as "graph node", and does same ownership cycle checking as before. Note that this function does _not_ prevent ownership type mixups (e.g. rb_root owning list_node) - that's handled by btf_parse_graph_root. After this patch, a bpf program can have a struct bpf_rb_root in a map_value, but not add anything to nor do anything useful with it.

Dave Marchevsky committed 3 years ago

Commit 9c395c11 parent 6a3cd338 files · +216 −73Browse files

Showing the changes to include/uapi (1 of 8 files). Show all

Unified · Split

include/uapi/linux/bpf.h+11−0
@@ -6917,6 +6917,17 @@ struct bpf_list_node { · 6916 unmodified lines
6917 __u64 :64;6917 __u64 :64;
6918} __attribute__((aligned(8)));6918} __attribute__((aligned(8)));
6919 6919
6920struct bpf_rb_root {
6921 __u64 :64;
6922 __u64 :64;
6923} __attribute__((aligned(8)));
6924
6925struct bpf_rb_node {
6926 __u64 :64;
6927 __u64 :64;
6928 __u64 :64;
6929} __attribute__((aligned(8)));
6930
6920struct bpf_sysctl {6931struct bpf_sysctl {
6921 __u32 write; /* Sysctl is being read (= 0) or written (= 1).6932 __u32 write; /* Sysctl is being read (= 0) or written (= 1).
6922 * Allows 1,2,4-byte read, but no write.6933 * Allows 1,2,4-byte read, but no write.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t