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