From: Geliang Tang tanggeliang@kylinos.cn
v4: - add more patches using make_sockaddr and get_socket_local_port helpers.
v3: - address comments of Martin and Eduard in v2. (thanks) - move "int type" to the first argument of start_server_addr and connect_to_addr. - add start_server_addr_opts. - using "sockaddr_storage" instead of "sockaddr". - move start_server_setsockopt patches out of this series.
v2: - update patch 6 only, fix errors reported by CI.
This patchset uses public helpers start_server_* and connect_to_* defined in network_helpers.c to drop duplicate code.
Geliang Tang (14): selftests/bpf: Update arguments of connect_to_addr selftests/bpf: Add start_server_addr* helpers selftests/bpf: Use start_server_addr in cls_redirect selftests/bpf: Use connect_to_addr in cls_redirect selftests/bpf: Use start_server_addr in sk_assign selftests/bpf: Use connect_to_addr in sk_assign selftests/bpf: Use get_socket_local_port in sk_assign selftests/bpf: Use make_sockaddr in sk_assign selftests/bpf: Use log_err in network_helpers selftests/bpf: Use start_server_addr in test_sock_addr selftests/bpf: Use connect_to_addr in test_sock_addr selftests/bpf: Use make_sockaddr in test_sock_addr selftests/bpf: Use make_sockaddr in test_sock selftests/bpf: Use make_sockaddr in ip_check_defrag
tools/testing/selftests/bpf/Makefile | 4 +- tools/testing/selftests/bpf/network_helpers.c | 37 ++++- tools/testing/selftests/bpf/network_helpers.h | 6 +- .../selftests/bpf/prog_tests/cls_redirect.c | 38 +---- .../selftests/bpf/prog_tests/empty_skb.c | 2 + .../bpf/prog_tests/ip_check_defrag.c | 20 +-- .../selftests/bpf/prog_tests/sk_assign.c | 92 ++---------- .../selftests/bpf/prog_tests/sock_addr.c | 6 +- .../selftests/bpf/prog_tests/tc_redirect.c | 2 +- .../selftests/bpf/prog_tests/test_tunnel.c | 4 + .../selftests/bpf/prog_tests/xdp_metadata.c | 16 +++ tools/testing/selftests/bpf/test_sock.c | 28 +--- tools/testing/selftests/bpf/test_sock_addr.c | 136 +++--------------- 13 files changed, 104 insertions(+), 287 deletions(-)