• Stanislav Fomichev's avatar
    samples/bpf: add sample program that periodically dumps TCP stats · 39533884
    Stanislav Fomichev authored
    Uses new RTT callback to dump stats every second.
    
    $ mkdir -p /tmp/cgroupv2
    $ mount -t cgroup2 none /tmp/cgroupv2
    $ mkdir -p /tmp/cgroupv2/foo
    $ echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
    $ bpftool prog load ./tcp_dumpstats_kern.o /sys/fs/bpf/tcp_prog
    $ bpftool cgroup attach /tmp/cgroupv2/foo sock_ops pinned /sys/fs/bpf/tcp_prog
    $ bpftool prog tracelog
    $ # run neper/netperf/etc
    
    Used neper to compare performance with and without this program attached
    and didn't see any noticeable performance impact.
    
    Sample output:
      <idle>-0     [015] ..s.  2074.128800: 0: dsack_dups=0 delivered=242526
      <idle>-0     [015] ..s.  2074.128808: 0: delivered_ce=0 icsk_retransmits=0
      <idle>-0     [015] ..s.  2075.130133: 0: dsack_dups=0 delivered=323599
      <idle>-0     [015] ..s.  2075.130138: 0: delivered_ce=0 icsk_retransmits=0
      <idle>-0     [005] .Ns.  2076.131440: 0: dsack_dups=0 delivered=404648
      <idle>-0     [005] .Ns.  2076.131447: 0: delivered_ce=0 icsk_retransmits=0
    
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Priyaranjan Jha <priyarjha@google.com>
    Cc: Yuchung Cheng <ycheng@google.com>
    Cc: Soheil Hassas Yeganeh <soheil@google.com>
    Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
    Acked-by: default avatarYuchung Cheng <ycheng@google.com>
    Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    39533884
tcp_dumpstats_kern.c 1.31 KB