1================ 2bpftool-cgroup 3================ 4------------------------------------------------------------------------------- 5tool for inspection and simple manipulation of eBPF progs 6------------------------------------------------------------------------------- 7 8:Manual section: 8 9 10SYNOPSIS 11======== 12 13 **bpftool** [*OPTIONS*] **cgroup** *COMMAND* 14 15 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } 16 17 *COMMANDS* := 18 { **show** | **list** | **tree** | **attach** | **detach** | **help** } 19 20CGROUP COMMANDS 21=============== 22 23| **bpftool** **cgroup { show | list }** *CGROUP* 24| **bpftool** **cgroup tree** [*CGROUP_ROOT*] 25| **bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*] 26| **bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG* 27| **bpftool** **cgroup help** 28| 29| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* } 30| *ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** | 31| **bind4** | **bind6** | **post_bind4** | **post_bind6** | **connect4** | **connect6** | 32| **sendmsg4** | **sendmsg6** | **recvmsg4** | **recvmsg6** | **sysctl** } 33| *ATTACH_FLAGS* := { **multi** | **override** } 34 35DESCRIPTION 36=========== 37 **bpftool cgroup { show | list }** *CGROUP* 38 List all programs attached to the cgroup *CGROUP*. 39 40 Output will start with program ID followed by attach type, 41 attach flags and program name. 42 43 **bpftool cgroup tree** [*CGROUP_ROOT*] 44 Iterate over all cgroups in *CGROUP_ROOT* and list all 45 attached programs. If *CGROUP_ROOT* is not specified, 46 bpftool uses cgroup v2 mountpoint. 47 48 The output is similar to the output of cgroup show/list 49 commands: it starts with absolute cgroup path, followed by 50 program ID, attach type, attach flags and program name. 51 52 **bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*] 53 Attach program *PROG* to the cgroup *CGROUP* with attach type 54 *ATTACH_TYPE* and optional *ATTACH_FLAGS*. 55 56 *ATTACH_FLAGS* can be one of: **override** if a sub-cgroup installs 57 some bpf program, the program in this cgroup yields to sub-cgroup 58 program; **multi** if a sub-cgroup installs some bpf program, 59 that cgroup program gets run in addition to the program in this 60 cgroup. 61 62 Only one program is allowed to be attached to a cgroup with 63 no attach flags or the **override** flag. Attaching another 64 program will release old program and attach the new one. 65 66 Multiple programs are allowed to be attached to a cgroup with 67 **multi**. They are executed in FIFO order (those that were 68 attached first, run first). 69 70 Non-default *ATTACH_FLAGS* are supported by kernel version 4.14 71 and later. 72 73 *ATTACH_TYPE* can be on of: 74 **ingress** ingress path of the inet socket (since 4.10); 75 **egress** egress path of the inet socket (since 4.10); 76 **sock_create** opening of an inet socket (since 4.10); 77 **sock_ops** various socket operations (since 4.12); 78 **device** device access (since 4.15); 79 **bind4** call to bind(2) for an inet4 socket (since 4.17); 80 **bind6** call to bind(2) for an inet6 socket (since 4.17); 81 **post_bind4** return from bind(2) for an inet4 socket (since 4.17); 82 **post_bind6** return from bind(2) for an inet6 socket (since 4.17); 83 **connect4** call to connect(2) for an inet4 socket (since 4.17); 84 **connect6** call to connect(2) for an inet6 socket (since 4.17); 85 **sendmsg4** call to sendto(2), sendmsg(2), sendmmsg(2) for an 86 unconnected udp4 socket (since 4.18); 87 **sendmsg6** call to sendto(2), sendmsg(2), sendmmsg(2) for an 88 unconnected udp6 socket (since 4.18); 89 **recvmsg4** call to recvfrom(2), recvmsg(2), recvmmsg(2) for 90 an unconnected udp4 socket (since 5.2); 91 **recvmsg6** call to recvfrom(2), recvmsg(2), recvmmsg(2) for 92 an unconnected udp6 socket (since 5.2); 93 **sysctl** sysctl access (since 5.2). 94 95 **bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG* 96 Detach *PROG* from the cgroup *CGROUP* and attach type 97 *ATTACH_TYPE*. 98 99 **bpftool prog help** 100 Print short help message. 101 102OPTIONS 103======= 104 -h, --help 105 Print short generic help message (similar to **bpftool help**). 106 107 -V, --version 108 Print version number (similar to **bpftool version**). 109 110 -j, --json 111 Generate JSON output. For commands that cannot produce JSON, this 112 option has no effect. 113 114 -p, --pretty 115 Generate human-readable JSON output. Implies **-j**. 116 117 -f, --bpffs 118 Show file names of pinned programs. 119 120EXAMPLES 121======== 122| 123| **# mount -t bpf none /sys/fs/bpf/** 124| **# mkdir /sys/fs/cgroup/test.slice** 125| **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog** 126| **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi** 127 128**# bpftool cgroup list /sys/fs/cgroup/test.slice/** 129 130:: 131 132 ID AttachType AttachFlags Name 133 1 device allow_multi bpf_prog1 134 135| 136| **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1** 137| **# bpftool cgroup list /sys/fs/cgroup/test.slice/** 138 139:: 140 141 ID AttachType AttachFlags Name 142 143SEE ALSO 144======== 145 **bpf**\ (2), 146 **bpf-helpers**\ (7), 147 **bpftool**\ (8), 148 **bpftool-prog**\ (8), 149 **bpftool-map**\ (8), 150 **bpftool-feature**\ (8), 151 **bpftool-net**\ (8), 152 **bpftool-perf**\ (8), 153 **bpftool-btf**\ (8) 154