blob: 78e247f62108ae34b0c7f5011f12fbbede75a6bd [file] [log] [blame]
Lawrence Brakmobfdf7562017-10-20 11:05:43 -07001This file describes how to run the tcp_*_kern.o tcp_bpf (or socket_ops)
2programs. These programs attach to a cgroupv2. The following commands create
3a cgroupv2 and attach a bash shell to the group.
4
5 mkdir -p /tmp/cgroupv2
6 mount -t cgroup2 none /tmp/cgroupv2
7 mkdir -p /tmp/cgroupv2/foo
8 bash
9 echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
10
Jakub Kicinskiea9b6362019-02-27 19:04:11 -080011Anything that runs under this shell belongs to the foo cgroupv2. To load
Lawrence Brakmobfdf7562017-10-20 11:05:43 -070012(attach) one of the tcp_*_kern.o programs:
13
Jakub Kicinskiea9b6362019-02-27 19:04:11 -080014 bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog
15 bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
16 bpftool prog tracelog
Lawrence Brakmobfdf7562017-10-20 11:05:43 -070017
Jakub Kicinskiea9b6362019-02-27 19:04:11 -080018"bpftool prog tracelog" will continue to run printing the BPF log buffer.
19The tcp_*_kern.o programs use special print functions to print logging
20information (if enabled by the ifdef).
Lawrence Brakmobfdf7562017-10-20 11:05:43 -070021
22If using netperf/netserver to create traffic, you need to run them under the
23cgroupv2 to which the BPF programs are attached (i.e. under bash shell
24attached to the cgroupv2).
25
26To remove (unattach) a socket_ops BPF program from a cgroupv2:
27
Stanislav Fomichevd78e3f02019-07-02 09:14:03 -070028 bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog