selftests/bpf: Drop get_port in test_tcp_check_syncookie

The arguments "addr" and "len" of run_test() have dropped. This makes
function get_port() useless. Drop it from test_tcp_check_syncookie_user.c.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://lore.kernel.org/r/a9b5c8064ab4cbf0f68886fe0e4706428b8d0d47.1714907662.git.tanggeliang@kylinos.cn
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
Geliang Tang 2024-05-05 19:35:13 +08:00 committed by Martin KaFai Lau
parent 65a3f0df44
commit 7abbf38cd8

View File

@ -139,21 +139,6 @@ out:
return ret;
}
static bool get_port(int server_fd, in_port_t *port)
{
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
if (getsockname(server_fd, (struct sockaddr *)&addr, &len)) {
log_err("Failed to get server addr");
return false;
}
/* sin_port and sin6_port are located at the same offset. */
*port = addr.sin_port;
return true;
}
static int v6only_true(int fd, const struct post_socket_opts *opts)
{
int mode = true;
@ -214,19 +199,19 @@ int main(int argc, char **argv)
server = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr4,
sizeof(addr4), NULL);
if (server == -1 || !get_port(server, &addr4.sin_port))
if (server == -1)
goto err;
opts.post_socket_cb = v6only_true;
server_v6 = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6,
sizeof(addr6), &opts);
if (server_v6 == -1 || !get_port(server_v6, &addr6.sin6_port))
if (server_v6 == -1)
goto err;
opts.post_socket_cb = v6only_false;
server_dual = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6dual,
sizeof(addr6dual), &opts);
if (server_dual == -1 || !get_port(server_dual, &addr4dual.sin_port))
if (server_dual == -1)
goto err;
if (run_test(server, results, xdp))