bpf: selftests: Add defrag selftests
authorDaniel Xu <dxu@dxuuu.xyz>
Fri, 21 Jul 2023 20:22:49 +0000 (14:22 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 28 Jul 2023 23:52:08 +0000 (16:52 -0700)
commitc313eae739b9a0fc5fbe655cece38eae0a90ec42
tree2c104e0eb24012bfbfd6c0bd4d9dd34ccf24a211
parente15a22095608ae5e1da5892da739d83b49b3bba5
bpf: selftests: Add defrag selftests

These selftests tests 2 major scenarios: the BPF based defragmentation
can successfully be done and that packet pointers are invalidated after
calls to the kfunc. The logic is similar for both ipv4 and ipv6.

In the first scenario, we create a UDP client and UDP echo server. The
the server side is fairly straightforward: we attach the prog and simply
echo back the message.

The on the client side, we send fragmented packets to and expect the
reassembled message back from the server.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/33e40fdfddf43be93f2cb259303f132f46750953.1689970773.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/generate_udp_fragments.py [new file with mode: 0755]
tools/testing/selftests/bpf/ip_check_defrag_frags.h [new file with mode: 0644]
tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/ip_check_defrag.c [new file with mode: 0644]