18c2ecf20Sopenharmony_ciThis file describes how to run the tcp_*_kern.o tcp_bpf (or socket_ops) 28c2ecf20Sopenharmony_ciprograms. These programs attach to a cgroupv2. The following commands create 38c2ecf20Sopenharmony_cia cgroupv2 and attach a bash shell to the group. 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci mkdir -p /tmp/cgroupv2 68c2ecf20Sopenharmony_ci mount -t cgroup2 none /tmp/cgroupv2 78c2ecf20Sopenharmony_ci mkdir -p /tmp/cgroupv2/foo 88c2ecf20Sopenharmony_ci bash 98c2ecf20Sopenharmony_ci echo $$ >> /tmp/cgroupv2/foo/cgroup.procs 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciAnything that runs under this shell belongs to the foo cgroupv2. To load 128c2ecf20Sopenharmony_ci(attach) one of the tcp_*_kern.o programs: 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci bpftool prog load tcp_basertt_kern.o /sys/fs/bpf/tcp_prog 158c2ecf20Sopenharmony_ci bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog 168c2ecf20Sopenharmony_ci bpftool prog tracelog 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci"bpftool prog tracelog" will continue to run printing the BPF log buffer. 198c2ecf20Sopenharmony_ciThe tcp_*_kern.o programs use special print functions to print logging 208c2ecf20Sopenharmony_ciinformation (if enabled by the ifdef). 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciIf using netperf/netserver to create traffic, you need to run them under the 238c2ecf20Sopenharmony_cicgroupv2 to which the BPF programs are attached (i.e. under bash shell 248c2ecf20Sopenharmony_ciattached to the cgroupv2). 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciTo remove (unattach) a socket_ops BPF program from a cgroupv2: 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog 29