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