* [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl
@ 2024-04-08 1:36 Geliang Tang
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Geliang Tang @ 2024-04-08 1:36 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, Jakub Sitnicki
Cc: Geliang Tang, bpf, mptcp
From: Geliang Tang <tanggeliang@kylinos.cn>
Two fixes for test_sockmap:
Patch 1, v3 of "selftests/bpf: Add F_SETFL for fcntl":
- detect nonblock flag automaticly, then test_sockmap can run in both
block and nonblock modes.
- use continue instead of again in v2.
Patch 2, fix for umount cgroup2 error.
Geliang Tang (2):
selftests/bpf: Add F_SETFL for fcntl in test_sockmap
selftests/bpf: Fix umount cgroup2 error in test_sockmap
tools/testing/selftests/bpf/test_sockmap.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
2024-04-08 1:36 [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl Geliang Tang
@ 2024-04-08 1:36 ` Geliang Tang
2024-04-08 15:55 ` Yonghong Song
2024-04-08 23:24 ` Martin KaFai Lau
2024-04-08 1:36 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
2024-04-08 2:28 ` [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl MPTCP CI
2 siblings, 2 replies; 7+ messages in thread
From: Geliang Tang @ 2024-04-08 1:36 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, Jakub Sitnicki
Cc: Geliang Tang, bpf, mptcp
From: Geliang Tang <tanggeliang@kylinos.cn>
Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking
it to set file status flags. If O_NONBLOCK is used as 2nd argument and
passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c).
The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as
3rd one.
In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise
some subtests of test_sockmap will fail.
Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/bpf/test_sockmap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index 024a0faafb3b..4f32a5eb3864 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -603,7 +603,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
struct timeval timeout;
fd_set w;
- fcntl(fd, fd_flags);
+ fcntl(fd, F_SETFL, fd_flags);
/* Account for pop bytes noting each iteration of apply will
* call msg_pop_data helper so we need to account for this
* by calculating the number of apply iterations. Note user
@@ -678,6 +678,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
perror("recv failed()");
goto out_errno;
}
+ fd_flags = fcntl(fd, F_GETFL);
+ if (fd_flags & O_NONBLOCK)
+ continue;
}
s->bytes_recvd += recv;
--
2.40.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error in test_sockmap
2024-04-08 1:36 [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl Geliang Tang
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
@ 2024-04-08 1:36 ` Geliang Tang
2024-04-08 15:55 ` Yonghong Song
2024-04-08 2:28 ` [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl MPTCP CI
2 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2024-04-08 1:36 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, Jakub Sitnicki
Cc: Geliang Tang, bpf, mptcp
From: Geliang Tang <tanggeliang@kylinos.cn>
This patch fixes the following "umount cgroup2" error in test_sockmap.c:
(cgroup_helpers.c:353: errno: Device or resource busy) umount cgroup2
Cgroup fd cg_fd should be closed before cleanup_cgroup_environment().
Fixes: 13a5f3ffd202 ("bpf: Selftests, sockmap test prog run without setting cgroup")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/bpf/test_sockmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index 4f32a5eb3864..520b7d0dadda 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -2107,9 +2107,9 @@ int main(int argc, char **argv)
free(options.whitelist);
if (options.blacklist)
free(options.blacklist);
+ close(cg_fd);
if (cg_created)
cleanup_cgroup_environment();
- close(cg_fd);
return err;
}
--
2.40.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl
2024-04-08 1:36 [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl Geliang Tang
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
2024-04-08 1:36 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
@ 2024-04-08 2:28 ` MPTCP CI
2 siblings, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2024-04-08 2:28 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Unstable: 1 failed test(s): packetdrill_sockopts 🔴
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8593412186
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/49fb69b19ca2
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=842235
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normal
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
@ 2024-04-08 15:55 ` Yonghong Song
2024-04-08 23:24 ` Martin KaFai Lau
1 sibling, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2024-04-08 15:55 UTC (permalink / raw)
To: Geliang Tang, Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Shuah Khan, Jakub Sitnicki
Cc: Geliang Tang, bpf, mptcp
On 4/7/24 6:36 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking
> it to set file status flags. If O_NONBLOCK is used as 2nd argument and
> passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c).
> The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as
> 3rd one.
>
> In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise
> some subtests of test_sockmap will fail.
>
> Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error in test_sockmap
2024-04-08 1:36 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
@ 2024-04-08 15:55 ` Yonghong Song
0 siblings, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2024-04-08 15:55 UTC (permalink / raw)
To: Geliang Tang, Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Shuah Khan, Jakub Sitnicki
Cc: Geliang Tang, bpf, mptcp
On 4/7/24 6:36 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> This patch fixes the following "umount cgroup2" error in test_sockmap.c:
>
> (cgroup_helpers.c:353: errno: Device or resource busy) umount cgroup2
>
> Cgroup fd cg_fd should be closed before cleanup_cgroup_environment().
>
> Fixes: 13a5f3ffd202 ("bpf: Selftests, sockmap test prog run without setting cgroup")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
2024-04-08 15:55 ` Yonghong Song
@ 2024-04-08 23:24 ` Martin KaFai Lau
1 sibling, 0 replies; 7+ messages in thread
From: Martin KaFai Lau @ 2024-04-08 23:24 UTC (permalink / raw)
To: Geliang Tang
Cc: Geliang Tang, bpf, mptcp, Andrii Nakryiko, Eduard Zingerman,
Mykola Lysenko, Alexei Starovoitov, Daniel Borkmann, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan, Jakub Sitnicki
On 4/7/24 6:36 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking
> it to set file status flags. If O_NONBLOCK is used as 2nd argument and
> passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c).
> The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as
> 3rd one.
>
> In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise
> some subtests of test_sockmap will fail.
>
> Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/bpf/test_sockmap.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> index 024a0faafb3b..4f32a5eb3864 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -603,7 +603,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
> struct timeval timeout;
> fd_set w;
>
> - fcntl(fd, fd_flags);
> + fcntl(fd, F_SETFL, fd_flags);
Should it just error out here if fcntl did fail (unlikely?) ...
> /* Account for pop bytes noting each iteration of apply will
> * call msg_pop_data helper so we need to account for this
> * by calculating the number of apply iterations. Note user
> @@ -678,6 +678,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
> perror("recv failed()");
> goto out_errno;
> }
> + fd_flags = fcntl(fd, F_GETFL);
> + if (fd_flags & O_NONBLOCK)
... then no need to test fd_flags here?
pw-bot: cr
> + continue;
> }
>
> s->bytes_recvd += recv;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-08 23:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08 1:36 [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl Geliang Tang
2024-04-08 1:36 ` [PATCH bpf-next v3 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
2024-04-08 15:55 ` Yonghong Song
2024-04-08 23:24 ` Martin KaFai Lau
2024-04-08 1:36 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
2024-04-08 15:55 ` Yonghong Song
2024-04-08 2:28 ` [PATCH bpf-next v3 0/2] Add F_SETFL for fcntl MPTCP CI
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.