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** | **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		  **sysctl** sysctl access (since 5.2).
90
91	**bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
92		  Detach *PROG* from the cgroup *CGROUP* and attach type
93		  *ATTACH_TYPE*.
94
95	**bpftool prog help**
96		  Print short help message.
97
98OPTIONS
99=======
100	-h, --help
101		  Print short generic help message (similar to **bpftool help**).
102
103	-V, --version
104		  Print version number (similar to **bpftool version**).
105
106	-j, --json
107		  Generate JSON output. For commands that cannot produce JSON, this
108		  option has no effect.
109
110	-p, --pretty
111		  Generate human-readable JSON output. Implies **-j**.
112
113	-f, --bpffs
114		  Show file names of pinned programs.
115
116EXAMPLES
117========
118|
119| **# mount -t bpf none /sys/fs/bpf/**
120| **# mkdir /sys/fs/cgroup/test.slice**
121| **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog**
122| **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi**
123
124**# bpftool cgroup list /sys/fs/cgroup/test.slice/**
125
126::
127
128    ID       AttachType      AttachFlags     Name
129    1        device          allow_multi     bpf_prog1
130
131|
132| **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1**
133| **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
134
135::
136
137    ID       AttachType      AttachFlags     Name
138
139SEE ALSO
140========
141	**bpf**\ (2),
142	**bpf-helpers**\ (7),
143	**bpftool**\ (8),
144	**bpftool-prog**\ (8),
145	**bpftool-map**\ (8),
146	**bpftool-feature**\ (8),
147	**bpftool-net**\ (8),
148	**bpftool-perf**\ (8),
149	**bpftool-btf**\ (8)
150