* [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 2024-04-08 1:36 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang 0 siblings, 2 replies; 6+ 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] 6+ 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 1 sibling, 2 replies; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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 1 sibling, 1 reply; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread
end of thread, other threads:[~2024-04-08 23:24 UTC | newest] Thread overview: 6+ 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox