Blame view

samples/bpf/tcp_bpf.readme 1.1 KB
bfdf75693   Lawrence Brakmo   bpf: create sampl...
1
2
3
4
5
6
7
8
9
  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
ea9b63620   Jakub Kicinski   samples: bpf: rem...
10
  Anything that runs under this shell belongs to the foo cgroupv2. To load
bfdf75693   Lawrence Brakmo   bpf: create sampl...
11
  (attach) one of the tcp_*_kern.o programs:
ea9b63620   Jakub Kicinski   samples: bpf: rem...
12
13
14
    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
bfdf75693   Lawrence Brakmo   bpf: create sampl...
15

ea9b63620   Jakub Kicinski   samples: bpf: rem...
16
17
18
  "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).
bfdf75693   Lawrence Brakmo   bpf: create sampl...
19
20
21
22
23
24
  
  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:
d78e3f061   Stanislav Fomichev   samples/bpf: fix ...
25
    bpftool cgroup detach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog