162306a36Sopenharmony_ciThis file describes how to run the tcp_*_kern.o tcp_bpf (or socket_ops)
262306a36Sopenharmony_ciprograms. These programs attach to a cgroupv2. The following commands create
362306a36Sopenharmony_cia cgroupv2 and attach a bash shell to the group.
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci  mkdir -p /tmp/cgroupv2
662306a36Sopenharmony_ci  mount -t cgroup2 none /tmp/cgroupv2
762306a36Sopenharmony_ci  mkdir -p /tmp/cgroupv2/foo
862306a36Sopenharmony_ci  bash
962306a36Sopenharmony_ci  echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciAnything that runs under this shell belongs to the foo cgroupv2. To load
1262306a36Sopenharmony_ci(attach) one of the tcp_*_kern.o programs:
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci  bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog
1562306a36Sopenharmony_ci  bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
1662306a36Sopenharmony_ci  bpftool prog tracelog
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci"bpftool prog tracelog" will continue to run printing the BPF log buffer.
1962306a36Sopenharmony_ciThe tcp_*_kern.o programs use special print functions to print logging
2062306a36Sopenharmony_ciinformation (if enabled by the ifdef).
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciIf using netperf/netserver to create traffic, you need to run them under the
2362306a36Sopenharmony_cicgroupv2 to which the BPF programs are attached (i.e. under bash shell
2462306a36Sopenharmony_ciattached to the cgroupv2).
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciTo remove (unattach) a socket_ops BPF program from a cgroupv2:
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci  bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
29