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** | **attach** | **detach** | **help** }
19
20MAP COMMANDS
21=============
22
23|	**bpftool** **cgroup { show | list }** *CGROUP*
24|	**bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
25|	**bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
26|	**bpftool** **cgroup help**
27|
28|	*PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
29|	*ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** |
30|		**bind4** | **bind6** | **post_bind4** | **post_bind6** | **connect4** | **connect6** |
31|               **sendmsg4** | **sendmsg6** }
32|	*ATTACH_FLAGS* := { **multi** | **override** }
33
34DESCRIPTION
35===========
36	**bpftool cgroup { show | list }** *CGROUP*
37		  List all programs attached to the cgroup *CGROUP*.
38
39		  Output will start with program ID followed by attach type,
40		  attach flags and program name.
41
42	**bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
43		  Attach program *PROG* to the cgroup *CGROUP* with attach type
44		  *ATTACH_TYPE* and optional *ATTACH_FLAGS*.
45
46		  *ATTACH_FLAGS* can be one of: **override** if a sub-cgroup installs
47		  some bpf program, the program in this cgroup yields to sub-cgroup
48		  program; **multi** if a sub-cgroup installs some bpf program,
49		  that cgroup program gets run in addition to the program in this
50		  cgroup.
51
52		  Only one program is allowed to be attached to a cgroup with
53		  no attach flags or the **override** flag. Attaching another
54		  program will release old program and attach the new one.
55
56		  Multiple programs are allowed to be attached to a cgroup with
57		  **multi**. They are executed in FIFO order (those that were
58		  attached first, run first).
59
60		  Non-default *ATTACH_FLAGS* are supported by kernel version 4.14
61		  and later.
62
63		  *ATTACH_TYPE* can be on of:
64		  **ingress** ingress path of the inet socket (since 4.10);
65		  **egress** egress path of the inet socket (since 4.10);
66		  **sock_create** opening of an inet socket (since 4.10);
67		  **sock_ops** various socket operations (since 4.12);
68		  **device** device access (since 4.15);
69		  **bind4** call to bind(2) for an inet4 socket (since 4.17);
70		  **bind6** call to bind(2) for an inet6 socket (since 4.17);
71		  **post_bind4** return from bind(2) for an inet4 socket (since 4.17);
72		  **post_bind6** return from bind(2) for an inet6 socket (since 4.17);
73		  **connect4** call to connect(2) for an inet4 socket (since 4.17);
74		  **connect6** call to connect(2) for an inet6 socket (since 4.17);
75		  **sendmsg4** call to sendto(2), sendmsg(2), sendmmsg(2) for an
76		  unconnected udp4 socket (since 4.18);
77		  **sendmsg6** call to sendto(2), sendmsg(2), sendmmsg(2) for an
78		  unconnected udp6 socket (since 4.18).
79
80	**bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
81		  Detach *PROG* from the cgroup *CGROUP* and attach type
82		  *ATTACH_TYPE*.
83
84	**bpftool prog help**
85		  Print short help message.
86
87OPTIONS
88=======
89	-h, --help
90		  Print short generic help message (similar to **bpftool help**).
91
92	-v, --version
93		  Print version number (similar to **bpftool version**).
94
95	-j, --json
96		  Generate JSON output. For commands that cannot produce JSON, this
97		  option has no effect.
98
99	-p, --pretty
100		  Generate human-readable JSON output. Implies **-j**.
101
102	-f, --bpffs
103		  Show file names of pinned programs.
104
105EXAMPLES
106========
107|
108| **# mount -t bpf none /sys/fs/bpf/**
109| **# mkdir /sys/fs/cgroup/test.slice**
110| **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog**
111| **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi**
112
113**# bpftool cgroup list /sys/fs/cgroup/test.slice/**
114
115::
116
117    ID       AttachType      AttachFlags     Name
118    1        device          allow_multi     bpf_prog1
119
120|
121| **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1**
122| **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
123
124::
125
126    ID       AttachType      AttachFlags     Name
127
128SEE ALSO
129========
130	**bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-map**\ (8)
131