Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Add a selftest for the tracing bpf_get_socket_cookie

This builds up on the existing socket cookie test which checks whether
the bpf_get_socket_cookie helpers provide the same value in
cgroup/connect6 and sockops programs for a socket created by the
userspace part of the test.

Instead of having an update_cookie sockops program tag a socket local
storage with 0xFF, this uses both an update_cookie_sockops program and
an update_cookie_tracing program which succesively tag the socket with
0x0F and then 0xF0.

Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: KP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/bpf/20210210111406.785541-5-revest@chromium.org

authored by

Florent Revest and committed by
Alexei Starovoitov
6fdd671b 6cd4dcc3

+41 -6
+8 -3
tools/testing/selftests/bpf/prog_tests/socket_cookie.c
··· 35 35 if (!ASSERT_OK_PTR(skel->links.set_cookie, "prog_attach")) 36 36 goto close_cgroup_fd; 37 37 38 - skel->links.update_cookie = bpf_program__attach_cgroup( 39 - skel->progs.update_cookie, cgroup_fd); 40 - if (!ASSERT_OK_PTR(skel->links.update_cookie, "prog_attach")) 38 + skel->links.update_cookie_sockops = bpf_program__attach_cgroup( 39 + skel->progs.update_cookie_sockops, cgroup_fd); 40 + if (!ASSERT_OK_PTR(skel->links.update_cookie_sockops, "prog_attach")) 41 + goto close_cgroup_fd; 42 + 43 + skel->links.update_cookie_tracing = bpf_program__attach( 44 + skel->progs.update_cookie_tracing); 45 + if (!ASSERT_OK_PTR(skel->links.update_cookie_tracing, "prog_attach")) 41 46 goto close_cgroup_fd; 42 47 43 48 server_fd = start_server(AF_INET6, SOCK_STREAM, "::1", 0, 0);