BPFTOOL-CGROUP(8) | System Manager's Manual | BPFTOOL-CGROUP(8) |
bpftool-cgroup - tool for inspection and simple manipulation of eBPF progs
bpftool [OPTIONS] cgroup COMMAND
OPTIONS := { { -j | --json } [{ -p | --pretty }] | { -d | --debug } | { -f | --bpffs } }
COMMANDS := { show | list | tree | attach | detach | help }
bpftool cgroup { show | list } CGROUP [effective] bpftool cgroup tree [CGROUP_ROOT] [effective] bpftool cgroup attach CGROUP ATTACH_TYPE PROG [ATTACH_FLAGS] bpftool cgroup detach CGROUP ATTACH_TYPE PROG bpftool cgroup help PROG := { id PROG_ID | pinned FILE | tag PROG_TAG | name PROG_NAME } ATTACH_TYPE := { cgroup_inet_ingress | cgroup_inet_egress |
cgroup_inet_sock_create | cgroup_sock_ops | cgroup_device | cgroup_inet4_bind | cgroup_inet6_bind | cgroup_inet4_post_bind | cgroup_inet6_post_bind | cgroup_inet4_connect | cgroup_inet6_connect | cgroup_unix_connect | cgroup_inet4_getpeername | cgroup_inet6_getpeername | cgroup_unix_getpeername | cgroup_inet4_getsockname | cgroup_inet6_getsockname | cgroup_unix_getsockname | cgroup_udp4_sendmsg | cgroup_udp6_sendmsg | cgroup_unix_sendmsg | cgroup_udp4_recvmsg | cgroup_udp6_recvmsg | cgroup_unix_recvmsg | cgroup_sysctl | cgroup_getsockopt | cgroup_setsockopt | cgroup_inet_sock_release }
ATTACH_FLAGS := { multi | override }
Output will start with program ID followed by attach type, attach flags and program name.
If effective is specified retrieve effective programs that will execute for events within a cgroup. This includes inherited along with attached ones.
The output is similar to the output of cgroup show/list commands: it starts with absolute cgroup path, followed by program ID, attach type, attach flags and program name.
If effective is specified retrieve effective programs that will execute for events within a cgroup. This includes inherited along with attached ones.
ATTACH_FLAGS can be one of: override if a sub-cgroup installs some bpf program, the program in this cgroup yields to sub-cgroup program; multi if a sub-cgroup installs some bpf program, that cgroup program gets run in addition to the program in this cgroup.
Only one program is allowed to be attached to a cgroup with no attach flags or the override flag. Attaching another program will release old program and attach the new one.
Multiple programs are allowed to be attached to a cgroup with multi. They are executed in FIFO order (those that were attached first, run first).
Non-default ATTACH_FLAGS are supported by kernel version 4.14 and later.
ATTACH_TYPE can be one of:
# mount -t bpf none /sys/fs/bpf/ # mkdir /sys/fs/cgroup/test.slice # bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog # bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi
# bpftool cgroup list /sys/fs/cgroup/test.slice/
ID AttachType AttachFlags Name 1 device allow_multi bpf_prog1
# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1 # bpftool cgroup list /sys/fs/cgroup/test.slice/
ID AttachType AttachFlags Name
bpf(2), bpf-helpers(7), bpftool(8), bpftool-btf(8), bpftool-feature(8), bpftool-gen(8), bpftool-iter(8), bpftool-link(8), bpftool-map(8), bpftool-net(8), bpftool-perf(8), bpftool-prog(8), bpftool-struct_ops(8)