* [PATCH bpf-next v4 1/2] selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca
2024-03-26 10:03 [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd Geliang Tang
@ 2024-03-26 10:03 ` Geliang Tang
2024-03-26 10:03 ` [PATCH bpf-next v4 2/2] selftests/bpf: Drop settimeo in do_test Geliang Tang
2024-03-28 4:50 ` [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Geliang Tang @ 2024-03-26 10:03 UTC (permalink / raw)
To: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
Cc: Geliang Tang, bpf, mptcp
From: Geliang Tang <tanggeliang@kylinos.cn>
To simplify the code, use BPF selftests helper connect_fd_to_fd() in
bpf_tcp_ca.c instead of open-coding it. This helper is defined in
network_helpers.c, and exported in network_helpers.h, which is already
included in bpf_tcp_ca.c.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
index 94cb22b01482..5aa3ccdc1351 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
@@ -78,11 +78,9 @@ static void *server(void *arg)
static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
{
- struct sockaddr_in6 sa6 = {};
ssize_t nr_recv = 0, bytes = 0;
int lfd = -1, fd = -1;
pthread_t srv_thread;
- socklen_t addrlen = sizeof(sa6);
void *thread_ret;
char batch[1500];
int err;
@@ -103,10 +101,6 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
settimeo(lfd, 0) || settimeo(fd, 0))
goto done;
- err = getsockname(lfd, (struct sockaddr *)&sa6, &addrlen);
- if (!ASSERT_NEQ(err, -1, "getsockname"))
- goto done;
-
if (sk_stg_map) {
err = bpf_map_update_elem(bpf_map__fd(sk_stg_map), &fd,
&expected_stg, BPF_NOEXIST);
@@ -115,7 +109,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
}
/* connect to server */
- err = connect(fd, (struct sockaddr *)&sa6, addrlen);
+ err = connect_fd_to_fd(fd, lfd, 0);
if (!ASSERT_NEQ(err, -1, "connect"))
goto done;
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH bpf-next v4 2/2] selftests/bpf: Drop settimeo in do_test
2024-03-26 10:03 [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd Geliang Tang
2024-03-26 10:03 ` [PATCH bpf-next v4 1/2] selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca Geliang Tang
@ 2024-03-26 10:03 ` Geliang Tang
2024-03-28 4:50 ` [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Geliang Tang @ 2024-03-26 10:03 UTC (permalink / raw)
To: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
Cc: Geliang Tang, bpf, mptcp
From: Geliang Tang <tanggeliang@kylinos.cn>
settimeo is invoked in start_server() and in connect_fd_to_fd() already,
no need to invoke settimeo(lfd, 0) and settimeo(fd, 0) in do_test()
anymore. This patch drops them.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
index 5aa3ccdc1351..3da3030c9365 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
@@ -97,8 +97,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
return;
}
- if (settcpca(lfd, tcp_ca) || settcpca(fd, tcp_ca) ||
- settimeo(lfd, 0) || settimeo(fd, 0))
+ if (settcpca(lfd, tcp_ca) || settcpca(fd, tcp_ca))
goto done;
if (sk_stg_map) {
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd
2024-03-26 10:03 [PATCH bpf-next v4 0/2] Use start_server and connect_fd_to_fd Geliang Tang
2024-03-26 10:03 ` [PATCH bpf-next v4 1/2] selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca Geliang Tang
2024-03-26 10:03 ` [PATCH bpf-next v4 2/2] selftests/bpf: Drop settimeo in do_test Geliang Tang
@ 2024-03-28 4:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-28 4:50 UTC (permalink / raw)
To: Geliang Tang
Cc: andrii, eddyz87, mykolal, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah,
tanggeliang, bpf, mptcp
Hello:
This series was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:
On Tue, 26 Mar 2024 18:03:37 +0800 you wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> v4:
> - Matt reminded me that I shouldn't send a square-to patch to BPF (thanks),
> so I update them into two patches in v4.
>
> v3:
> - split v2 as two patches as Daniel suggested.
> - The patch "selftests/bpf: Use start_server in bpf_tcp_ca" is merged
> by Daniel (thanks), but I forgot to drop 'settimeo(lfd, 0)' in it, so
> I send a squash-to patch to fix this.
>
> [...]
Here is the summary with links:
- [bpf-next,v4,1/2] selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca
https://git.kernel.org/bpf/bpf-next/c/ed1697153d40
- [bpf-next,v4,2/2] selftests/bpf: Drop settimeo in do_test
https://git.kernel.org/bpf/bpf-next/c/9a3aa22de842
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread