selftests/bpf: Use start_server_addr in sk_lookup
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>
This commit is contained in:
parent
14fc6fcd35
commit
d9810c43f6
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user