Skip to content

Commit

Permalink
selftests/bpf: Use start_server_addr in sk_lookup
Browse files Browse the repository at this point in the history
This patch uses public helper start_server_addr() in udp_recv_send()
in prog_tests/sk_lookup.c to simplify the code.

And use ASSERT_OK_FD() to check fd returned by start_server_addr().

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://lore.kernel.org/r/f11cabfef4a2170ecb66a1e8e2e72116d8f621b3.1720515893.git.tanggeliang@kylinos.cn
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
  • Loading branch information
Geliang Tang authored and Martin KaFai Lau committed Jul 10, 2024
1 parent 14fc6fc commit d9810c4
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tools/testing/selftests/bpf/prog_tests/sk_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,12 @@ static int udp_recv_send(int server_fd)
}

/* Reply from original destination address. */
fd = socket(dst_addr->ss_family, SOCK_DGRAM, 0);
if (CHECK(fd < 0, "socket", "failed\n")) {
fd = start_server_addr(SOCK_DGRAM, dst_addr, sizeof(*dst_addr), NULL);
if (!ASSERT_OK_FD(fd, "start_server_addr")) {
log_err("failed to create tx socket");
return -1;
}

ret = bind(fd, (struct sockaddr *)dst_addr, sizeof(*dst_addr));
if (CHECK(ret, "bind", "failed\n")) {
log_err("failed to bind tx socket");
goto out;
}

msg.msg_control = NULL;
msg.msg_controllen = 0;
n = sendmsg(fd, &msg, 0);
Expand Down

0 comments on commit d9810c4

Please sign in to comment.