selftests/bpf: Test that SO_REUSEPORT can be used with sk_assign helper
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 20 Jul 2023 15:30:12 +0000 (17:30 +0200)
committerMartin KaFai Lau <martin.lau@kernel.org>
Tue, 25 Jul 2023 21:02:47 +0000 (14:02 -0700)
commit22408d58a42cb59b88dcec3694f477a838dd68ed
tree3ab10cc4d9b1eaf4dc31abbb2840f41e4221bdde
parent9c02bec95954252c3c01bfbb3f7560e0b95ca955
selftests/bpf: Test that SO_REUSEPORT can be used with sk_assign helper

We use two programs to check that the new reuseport logic is executed
appropriately.

The first is a TC clsact program which bpf_sk_assigns
the skb to a UDP or TCP socket created by user space. Since the test
communicates via lo we see both directions of packets in the eBPF.
Traffic ingressing to the reuseport socket is identified by looking
at the destination port. For TCP, we additionally need to make sure
that we only assign the initial SYN packets towards our listening
socket. The network stack then creates a request socket which
transitions to ESTABLISHED after the 3WHS.

The second is a reuseport program which shares the fact that
it has been executed with user space. This tells us that the delayed
lookup mechanism is working.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Co-developed-by: Lorenz Bauer <lmb@isovalent.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Cc: Joe Stringer <joe@cilium.io>
Link: https://lore.kernel.org/r/20230720-so-reuseport-v6-8-7021b683cdae@isovalent.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/network_helpers.c
tools/testing/selftests/bpf/prog_tests/assign_reuse.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_assign_reuse.c [new file with mode: 0644]