History

bpf: Migrate cgroup_bpf to internal cgroup_bpf_attach_type enum

Add an enum (cgroup_bpf_attach_type) containing only valid cgroup_bpf attach types and a function to map bpf_attach_type values to the new enum. Inspired by netns_bpf_attach_type. Then, migrate cgroup_bpf to use cgroup_bpf_attach_type wherever possible. Functionality is unchanged as attach_type_to_prog_type switches in bpf/syscall.c were preventing non-cgroup programs from making use of the invalid cgroup_bpf array slots. As a result struct cgroup_bpf uses 504 fewer bytes relative to when its arrays were sized using MAX_BPF_ATTACH_TYPE. bpf_cgroup_storage is notably not migrated as struct bpf_cgroup_storage_key is part of uapi and contains a bpf_attach_type member which is not meant to be opaque. Similarly, bpf_cgroup_link continues to report its bpf_attach_type member to userspace via fdinfo and bpf_link_info. To ease disambiguation, bpf_attach_type variables are renamed from 'type' to 'atype' when changed to cgroup_bpf_attach_type.

Dave Marchevsky committed 5 years ago

Commit 6fc88c31 parent d3599028 files · +226 −132Browse files

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

Unified · Split

tools/include/uapi/linux/bpf.h+1−1
@@ -84,7 +84,7 @@ struct bpf_lpm_trie_key { · 83 unmodified lines
8484
8585 struct bpf_cgroup_storage_key {
8686 __u64 cgroup_inode_id; /* cgroup inode id */
87− __u32 attach_type; /* program attach type */
87+ __u32 attach_type; /* program attach type (enum bpf_attach_type) */
8888 };
8989
9090 union bpf_iter_link_info {

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