selftests/bpf: add a test case for sock_ops perf-event notification
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 8 Nov 2018 00:12:02 +0000 (16:12 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 9 Nov 2018 08:40:17 +0000 (09:40 +0100)
commit435f90a338ae42c0d7c0109a1742d1b16bc99bf6
treed9b8382a1b809c45809135400fdeda9d9fe51be9
parenta5a3a828cd00788a78da686c57c6d1f66191d8af
selftests/bpf: add a test case for sock_ops perf-event notification

This patch provides a tcp_bpf based eBPF sample. The test

- ncat(1) as the TCP client program to connect() to a port
  with the intention of triggerring SYN retransmissions: we
  first install an iptables DROP rule to make sure ncat SYNs are
  resent (instead of aborting instantly after a TCP RST)

- has a bpf kernel module that sends a perf-event notification for
  each TCP retransmit, and also tracks the number of such notifications
  sent in the global_map

The test passes when the number of event notifications intercepted
in user-space matches the value in the global_map.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/test_tcpnotify.h [new file with mode: 0644]
tools/testing/selftests/bpf/test_tcpnotify_kern.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_tcpnotify_user.c [new file with mode: 0644]