]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Drop type from network_helper_opts
authorGeliang Tang <tanggeliang@kylinos.cn>
Fri, 21 Jun 2024 02:15:58 +0000 (10:15 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 21 Jun 2024 03:42:44 +0000 (20:42 -0700)
commit34ad6ec972525b903d4680202d7b8360f71d0d89
tree476a2cb04e158fa6be0acc0711d12dd1368a53fb
parentbf977ee4a9e2ad8a41b3a2497aada5e7eb09eaea
selftests/bpf: Drop type from network_helper_opts

The opts.{type, noconnect} is at least a bit non intuitive or unnecessary.
The only use case now is in test_bpf_ip_check_defrag_ok which ends up
bypassing most (or at least some) of the connect_to_fd_opts() logic. It's
much better that test should have its own connect_to_fd_opts() instead.

This patch adds a new "type" parameter for connect_to_fd_opts(), then
opts->type and getsockopt(SO_TYPE) can be replaced by "type" parameter in
it.

In connect_to_fd(), use getsockopt(SO_TYPE) to get "type" value and pass
it to connect_to_fd_opts().

In bpf_tcp_ca.c and cgroup_v1v2.c, "SOCK_STREAM" types are passed to
connect_to_fd_opts(), and in ip_check_defrag.c, different types "SOCK_RAW"
and "SOCK_DGRAM" are passed to it.

With these changes, the strcut member "type" of network_helper_opts can be
dropped now.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://lore.kernel.org/r/cfd20b5ad4085c1d1af5e79df3b09013a407199f.1718932493.git.tanggeliang@kylinos.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/network_helpers.c
tools/testing/selftests/bpf/network_helpers.h
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
tools/testing/selftests/bpf/prog_tests/cgroup_v1v2.c
tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c