Loading...
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* [**effective**]
24| **bpftool** **cgroup tree** [*CGROUP_ROOT*] [**effective**]
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| **getpeername4** | **getpeername6** | **getsockname4** | **getsockname6** | **sendmsg4** |
33| **sendmsg6** | **recvmsg4** | **recvmsg6** | **sysctl** | **getsockopt** | **setsockopt** |
34| **sock_release** }
35| *ATTACH_FLAGS* := { **multi** | **override** }
36
37DESCRIPTION
38===========
39 **bpftool cgroup { show | list }** *CGROUP* [**effective**]
40 List all programs attached to the cgroup *CGROUP*.
41
42 Output will start with program ID followed by attach type,
43 attach flags and program name.
44
45 If **effective** is specified retrieve effective programs that
46 will execute for events within a cgroup. This includes
47 inherited along with attached ones.
48
49 **bpftool cgroup tree** [*CGROUP_ROOT*] [**effective**]
50 Iterate over all cgroups in *CGROUP_ROOT* and list all
51 attached programs. If *CGROUP_ROOT* is not specified,
52 bpftool uses cgroup v2 mountpoint.
53
54 The output is similar to the output of cgroup show/list
55 commands: it starts with absolute cgroup path, followed by
56 program ID, attach type, attach flags and program name.
57
58 If **effective** is specified retrieve effective programs that
59 will execute for events within a cgroup. This includes
60 inherited along with attached ones.
61
62 **bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
63 Attach program *PROG* to the cgroup *CGROUP* with attach type
64 *ATTACH_TYPE* and optional *ATTACH_FLAGS*.
65
66 *ATTACH_FLAGS* can be one of: **override** if a sub-cgroup installs
67 some bpf program, the program in this cgroup yields to sub-cgroup
68 program; **multi** if a sub-cgroup installs some bpf program,
69 that cgroup program gets run in addition to the program in this
70 cgroup.
71
72 Only one program is allowed to be attached to a cgroup with
73 no attach flags or the **override** flag. Attaching another
74 program will release old program and attach the new one.
75
76 Multiple programs are allowed to be attached to a cgroup with
77 **multi**. They are executed in FIFO order (those that were
78 attached first, run first).
79
80 Non-default *ATTACH_FLAGS* are supported by kernel version 4.14
81 and later.
82
83 *ATTACH_TYPE* can be on of:
84 **ingress** ingress path of the inet socket (since 4.10);
85 **egress** egress path of the inet socket (since 4.10);
86 **sock_create** opening of an inet socket (since 4.10);
87 **sock_ops** various socket operations (since 4.12);
88 **device** device access (since 4.15);
89 **bind4** call to bind(2) for an inet4 socket (since 4.17);
90 **bind6** call to bind(2) for an inet6 socket (since 4.17);
91 **post_bind4** return from bind(2) for an inet4 socket (since 4.17);
92 **post_bind6** return from bind(2) for an inet6 socket (since 4.17);
93 **connect4** call to connect(2) for an inet4 socket (since 4.17);
94 **connect6** call to connect(2) for an inet6 socket (since 4.17);
95 **sendmsg4** call to sendto(2), sendmsg(2), sendmmsg(2) for an
96 unconnected udp4 socket (since 4.18);
97 **sendmsg6** call to sendto(2), sendmsg(2), sendmmsg(2) for an
98 unconnected udp6 socket (since 4.18);
99 **recvmsg4** call to recvfrom(2), recvmsg(2), recvmmsg(2) for
100 an unconnected udp4 socket (since 5.2);
101 **recvmsg6** call to recvfrom(2), recvmsg(2), recvmmsg(2) for
102 an unconnected udp6 socket (since 5.2);
103 **sysctl** sysctl access (since 5.2);
104 **getsockopt** call to getsockopt (since 5.3);
105 **setsockopt** call to setsockopt (since 5.3);
106 **getpeername4** call to getpeername(2) for an inet4 socket (since 5.8);
107 **getpeername6** call to getpeername(2) for an inet6 socket (since 5.8);
108 **getsockname4** call to getsockname(2) for an inet4 socket (since 5.8);
109 **getsockname6** call to getsockname(2) for an inet6 socket (since 5.8).
110 **sock_release** closing an userspace inet socket (since 5.9).
111
112 **bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
113 Detach *PROG* from the cgroup *CGROUP* and attach type
114 *ATTACH_TYPE*.
115
116 **bpftool prog help**
117 Print short help message.
118
119OPTIONS
120=======
121 .. include:: common_options.rst
122
123 -f, --bpffs
124 Show file names of pinned programs.
125
126EXAMPLES
127========
128|
129| **# mount -t bpf none /sys/fs/bpf/**
130| **# mkdir /sys/fs/cgroup/test.slice**
131| **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog**
132| **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi**
133
134**# bpftool cgroup list /sys/fs/cgroup/test.slice/**
135
136::
137
138 ID AttachType AttachFlags Name
139 1 device allow_multi bpf_prog1
140
141|
142| **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1**
143| **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
144
145::
146
147 ID AttachType AttachFlags Name
1.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
3================
4bpftool-cgroup
5================
6-------------------------------------------------------------------------------
7tool for inspection and simple manipulation of eBPF progs
8-------------------------------------------------------------------------------
9
10:Manual section: 8
11
12.. include:: substitutions.rst
13
14SYNOPSIS
15========
16
17 **bpftool** [*OPTIONS*] **cgroup** *COMMAND*
18
19 *OPTIONS* := { |COMMON_OPTIONS| | { **-f** | **--bpffs** } }
20
21 *COMMANDS* :=
22 { **show** | **list** | **tree** | **attach** | **detach** | **help** }
23
24CGROUP COMMANDS
25===============
26
27| **bpftool** **cgroup** { **show** | **list** } *CGROUP* [**effective**]
28| **bpftool** **cgroup tree** [*CGROUP_ROOT*] [**effective**]
29| **bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
30| **bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
31| **bpftool** **cgroup help**
32|
33| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
34| *ATTACH_TYPE* := { **cgroup_inet_ingress** | **cgroup_inet_egress** |
35| **cgroup_inet_sock_create** | **cgroup_sock_ops** |
36| **cgroup_device** | **cgroup_inet4_bind** | **cgroup_inet6_bind** |
37| **cgroup_inet4_post_bind** | **cgroup_inet6_post_bind** |
38| **cgroup_inet4_connect** | **cgroup_inet6_connect** |
39| **cgroup_unix_connect** | **cgroup_inet4_getpeername** |
40| **cgroup_inet6_getpeername** | **cgroup_unix_getpeername** |
41| **cgroup_inet4_getsockname** | **cgroup_inet6_getsockname** |
42| **cgroup_unix_getsockname** | **cgroup_udp4_sendmsg** |
43| **cgroup_udp6_sendmsg** | **cgroup_unix_sendmsg** |
44| **cgroup_udp4_recvmsg** | **cgroup_udp6_recvmsg** |
45| **cgroup_unix_recvmsg** | **cgroup_sysctl** |
46| **cgroup_getsockopt** | **cgroup_setsockopt** |
47| **cgroup_inet_sock_release** }
48| *ATTACH_FLAGS* := { **multi** | **override** }
49
50DESCRIPTION
51===========
52 **bpftool cgroup { show | list }** *CGROUP* [**effective**]
53 List all programs attached to the cgroup *CGROUP*.
54
55 Output will start with program ID followed by attach type,
56 attach flags and program name.
57
58 If **effective** is specified retrieve effective programs that
59 will execute for events within a cgroup. This includes
60 inherited along with attached ones.
61
62 **bpftool cgroup tree** [*CGROUP_ROOT*] [**effective**]
63 Iterate over all cgroups in *CGROUP_ROOT* and list all
64 attached programs. If *CGROUP_ROOT* is not specified,
65 bpftool uses cgroup v2 mountpoint.
66
67 The output is similar to the output of cgroup show/list
68 commands: it starts with absolute cgroup path, followed by
69 program ID, attach type, attach flags and program name.
70
71 If **effective** is specified retrieve effective programs that
72 will execute for events within a cgroup. This includes
73 inherited along with attached ones.
74
75 **bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
76 Attach program *PROG* to the cgroup *CGROUP* with attach type
77 *ATTACH_TYPE* and optional *ATTACH_FLAGS*.
78
79 *ATTACH_FLAGS* can be one of: **override** if a sub-cgroup installs
80 some bpf program, the program in this cgroup yields to sub-cgroup
81 program; **multi** if a sub-cgroup installs some bpf program,
82 that cgroup program gets run in addition to the program in this
83 cgroup.
84
85 Only one program is allowed to be attached to a cgroup with
86 no attach flags or the **override** flag. Attaching another
87 program will release old program and attach the new one.
88
89 Multiple programs are allowed to be attached to a cgroup with
90 **multi**. They are executed in FIFO order (those that were
91 attached first, run first).
92
93 Non-default *ATTACH_FLAGS* are supported by kernel version 4.14
94 and later.
95
96 *ATTACH_TYPE* can be on of:
97 **ingress** ingress path of the inet socket (since 4.10);
98 **egress** egress path of the inet socket (since 4.10);
99 **sock_create** opening of an inet socket (since 4.10);
100 **sock_ops** various socket operations (since 4.12);
101 **device** device access (since 4.15);
102 **bind4** call to bind(2) for an inet4 socket (since 4.17);
103 **bind6** call to bind(2) for an inet6 socket (since 4.17);
104 **post_bind4** return from bind(2) for an inet4 socket (since 4.17);
105 **post_bind6** return from bind(2) for an inet6 socket (since 4.17);
106 **connect4** call to connect(2) for an inet4 socket (since 4.17);
107 **connect6** call to connect(2) for an inet6 socket (since 4.17);
108 **connect_unix** call to connect(2) for a unix socket (since 6.7);
109 **sendmsg4** call to sendto(2), sendmsg(2), sendmmsg(2) for an
110 unconnected udp4 socket (since 4.18);
111 **sendmsg6** call to sendto(2), sendmsg(2), sendmmsg(2) for an
112 unconnected udp6 socket (since 4.18);
113 **sendmsg_unix** call to sendto(2), sendmsg(2), sendmmsg(2) for
114 an unconnected unix socket (since 6.7);
115 **recvmsg4** call to recvfrom(2), recvmsg(2), recvmmsg(2) for
116 an unconnected udp4 socket (since 5.2);
117 **recvmsg6** call to recvfrom(2), recvmsg(2), recvmmsg(2) for
118 an unconnected udp6 socket (since 5.2);
119 **recvmsg_unix** call to recvfrom(2), recvmsg(2), recvmmsg(2) for
120 an unconnected unix socket (since 6.7);
121 **sysctl** sysctl access (since 5.2);
122 **getsockopt** call to getsockopt (since 5.3);
123 **setsockopt** call to setsockopt (since 5.3);
124 **getpeername4** call to getpeername(2) for an inet4 socket (since 5.8);
125 **getpeername6** call to getpeername(2) for an inet6 socket (since 5.8);
126 **getpeername_unix** call to getpeername(2) for a unix socket (since 6.7);
127 **getsockname4** call to getsockname(2) for an inet4 socket (since 5.8);
128 **getsockname6** call to getsockname(2) for an inet6 socket (since 5.8).
129 **getsockname_unix** call to getsockname(2) for a unix socket (since 6.7);
130 **sock_release** closing an userspace inet socket (since 5.9).
131
132 **bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
133 Detach *PROG* from the cgroup *CGROUP* and attach type
134 *ATTACH_TYPE*.
135
136 **bpftool prog help**
137 Print short help message.
138
139OPTIONS
140=======
141 .. include:: common_options.rst
142
143 -f, --bpffs
144 Show file names of pinned programs.
145
146EXAMPLES
147========
148|
149| **# mount -t bpf none /sys/fs/bpf/**
150| **# mkdir /sys/fs/cgroup/test.slice**
151| **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog**
152| **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi**
153
154**# bpftool cgroup list /sys/fs/cgroup/test.slice/**
155
156::
157
158 ID AttachType AttachFlags Name
159 1 device allow_multi bpf_prog1
160
161|
162| **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1**
163| **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
164
165::
166
167 ID AttachType AttachFlags Name