selftests: bpf: Add test for sk_assign
authorLorenz Bauer <lmb@cloudflare.com>
Sun, 29 Mar 2020 22:53:41 +0000 (15:53 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 30 Mar 2020 20:45:05 +0000 (13:45 -0700)
commit2d7824ffd25ce041db952d713567d54314cb7c29
treeb4174abd7a7e99a44e12942bb6027fd1b206b8fd
parent7ae215d23c12a939005f35d1848ca55b6109b9c0
selftests: bpf: Add test for sk_assign

Attach a tc direct-action classifier to lo in a fresh network
namespace, and rewrite all connection attempts to localhost:4321
to localhost:1234 (for port tests) and connections to unreachable
IPv4/IPv6 IPs to the local socket (for address tests). Includes
implementations for both TCP and UDP.

Keep in mind that both client to server and server to client traffic
passes the classifier.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200329225342.16317-5-joe@wand.net.nz
Co-authored-by: Joe Stringer <joe@wand.net.nz>
tools/testing/selftests/bpf/prog_tests/sk_assign.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_sk_assign.c [new file with mode: 0644]