]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/bpf: Test for get_socket_cookie
authorAndrey Ignatov <rdna@fb.com>
Tue, 31 Jul 2018 00:42:31 +0000 (17:42 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 31 Jul 2018 07:33:48 +0000 (09:33 +0200)
commit194db0d95802fb48d03034fb6bfead1235de3450
tree9bfc7b1ef2469887c901f345c99909c2c482a509
parent0289a2cca0a5b75a0167243429d9163ec3fdf279
selftests/bpf: Test for get_socket_cookie

Add test to use get_socket_cookie() from BPF programs of types
BPF_PROG_TYPE_SOCK_OPS and BPF_PROG_TYPE_CGROUP_SOCK_ADDR.

The test attaches two programs to cgroup, runs TCP server and client in
the cgroup and checks that two operations are done properly on client
socket when user calls connect(2):

1. In BPF_CGROUP_INET6_CONNECT socket cookie is used as the key to write
   new value in a map for client socket.

2. In BPF_CGROUP_SOCK_OPS (BPF_SOCK_OPS_TCP_CONNECT_CB callback) the
   value written in "1." is found by socket cookie, since it's the same
   socket, and updated.

Finally the test verifies the value in the map.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/socket_cookie_prog.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_socket_cookie.c [new file with mode: 0644]