selftests: bpf: Test sockmap update from BPF
authorLorenz Bauer <lmb@cloudflare.com>
Fri, 21 Aug 2020 10:29:48 +0000 (11:29 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 21 Aug 2020 22:16:12 +0000 (15:16 -0700)
commitbb23c0e1c57f3b40c8d2713401c1b42df911d424
tree50361f2ed977f724fc78f240c2a01df9f130f87f
parent0126240f448d5bba29d0d1593aa527d3bf67b916
selftests: bpf: Test sockmap update from BPF

Add a test which copies a socket from a sockmap into another sockmap
or sockhash. This excercises bpf_map_update_elem support from BPF
context. Compare the socket cookies from source and destination to
ensure that the copy succeeded.

Also check that the verifier rejects map_update from unsafe contexts.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200821102948.21918-7-lmb@cloudflare.com
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
tools/testing/selftests/bpf/progs/test_sockmap_invalid_update.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_sockmap_update.c [new file with mode: 0644]