2017-10-21 01:05:43 +07:00
|
|
|
This file describes how to run the tcp_*_kern.o tcp_bpf (or socket_ops)
|
|
|
|
programs. These programs attach to a cgroupv2. The following commands create
|
|
|
|
a cgroupv2 and attach a bash shell to the group.
|
|
|
|
|
|
|
|
mkdir -p /tmp/cgroupv2
|
|
|
|
mount -t cgroup2 none /tmp/cgroupv2
|
|
|
|
mkdir -p /tmp/cgroupv2/foo
|
|
|
|
bash
|
|
|
|
echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
|
|
|
|
|
2019-02-28 10:04:11 +07:00
|
|
|
Anything that runs under this shell belongs to the foo cgroupv2. To load
|
2017-10-21 01:05:43 +07:00
|
|
|
(attach) one of the tcp_*_kern.o programs:
|
|
|
|
|
2019-02-28 10:04:11 +07:00
|
|
|
bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog
|
|
|
|
bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
|
|
|
|
bpftool prog tracelog
|
2017-10-21 01:05:43 +07:00
|
|
|
|
2019-02-28 10:04:11 +07:00
|
|
|
"bpftool prog tracelog" will continue to run printing the BPF log buffer.
|
|
|
|
The tcp_*_kern.o programs use special print functions to print logging
|
|
|
|
information (if enabled by the ifdef).
|
2017-10-21 01:05:43 +07:00
|
|
|
|
|
|
|
If using netperf/netserver to create traffic, you need to run them under the
|
|
|
|
cgroupv2 to which the BPF programs are attached (i.e. under bash shell
|
|
|
|
attached to the cgroupv2).
|
|
|
|
|
|
|
|
To remove (unattach) a socket_ops BPF program from a cgroupv2:
|
|
|
|
|
2019-07-02 23:14:03 +07:00
|
|
|
bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
|