Two fixes for test_sockmap
Subsystems (4)
Geliang Tang
reviewerv4 cover Two fixes for test_sockmap
From: Geliang Tang <[email protected]>
v4:
- address Martin's comments for v3. (thanks.)
- add Yonghong's "Acked-by" tags. (thanks.)
- update subject-prefix from "bpf-next" to "bpf".
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(-)
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH v4 1/2 selftests/bpf: Add F_SETFL for fcntl in test_sockmap
From: Geliang Tang <[email protected]>
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 fail.
--- tools/testing/selftests/bpf/test_sockmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_sockmap.c +4 -1
@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,struct timeval timeout;fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; +/* 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 +680,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,perror ("recv failed()" ); goto out_errno; } +continue ; } s->bytes_recvd += recv;
Signature · 1 line
2.40.1
Martin KaFai Lau
reviewerRe: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
Quoted 34 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Incorrect arguments are passed to
fcntl()intest_sockmap.cwhen invoking it to set file status flags. IfO_NONBLOCKis used as 2nd argument and passed into fcntl,-EINVALwill be returned (Seedo_fcntl()infs/fcntl.c). The correct approach is to useF_SETFLas 2nd argument, andO_NONBLOCKas 3rd one.In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise some subtests of
test_sockmapfail.Fixes 16962b2404ac ("bpf: sockmap, add selftests")Signed-off-by Geliang Tang <[email protected]>Acked-by Yonghong Song <[email protected]>--- tools/testing/selftests/bpf/test_sockmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/test_sockmap.c +3
-1@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,struct timeval timeout;fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; +/* 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
tools/testing/selftests/bpf/test_sockmap.c static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · line 683
Quoted 4 lines
tools/testing/selftests/bpf/test_sockmap.c +1
-0@@ -678,6 +680,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,perror ("recv failed()" ); goto out_errno; } +continue ;
From looking at it again, there is a select() earlier, so it should not hit EWOULDBLOCK.
Patch 2 looks good. Only patch 2 is applied. Thanks.
Quoted 3 lines
tools/testing/selftests/bpf/test_sockmap.c +0
-0} s->bytes_recvd += recv;
Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
Hi Martin,
Quoted 33 lines · Martin KaFai Lau
Quoted 32 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Incorrect arguments are passed to
fcntl()intest_sockmap.cwhen invoking it to set file status flags. IfO_NONBLOCKis used as 2nd argument and passed into fcntl,-EINVALwill be returned (Seedo_fcntl()infs/fcntl.c). The correct approach is to useF_SETFLas 2nd argument, andO_NONBLOCKas 3rd one.In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise some subtests of
test_sockmapfail.Fixes 16962b2404ac ("bpf: sockmap, add selftests")Signed-off-by Geliang Tang <[email protected]>Acked-by Yonghong Song <[email protected]>--- tools/testing/selftests/bpf/test_sockmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/test_sockmap.c +3
-1@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,struct timeval timeout;fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; +/* 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
Quoted 8 lines
tools/testing/selftests/bpf/test_sockmap.c static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · line 683
Quoted 5 lines
tools/testing/selftests/bpf/test_sockmap.c +1
-0@@ -678,6 +680,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,perror ("recv failed()" ); goto out_errno; } +continue ;From looking at it again, there is a
select()earlier, so it should not hit EWOULDBLOCK.
Can the patch in the attachment be accepted? It can work, but I'm not sure if it has changed the behavior of this test. Anyway, I would like to hear your opinion.
Thanks,
-Geliang
Quoted 5 lines
Patch 2 looks good. Only patch 2 is applied. Thanks.
Quoted 2 lines
tools/testing/selftests/bpf/test_sockmap.c +0
-0} s->bytes_recvd += recv;
From d20ac7e06d9e869094f452d8c2dcdc316508dcc8 Mon Sep 17 00:00:00 2001
Message-Id: <d20ac7e06d9e869094f452d8c2dcdc316508dcc8.1713340686.git.tanggeliang@kylinos.cn>
From: Geliang Tang <[email protected]>
Date: Wed, 3 Apr 2024 16:08:21 +0800
Subject: [PATCH] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
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 fail.
--- tools/testing/selftests/bpf/test_sockmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_sockmap.c +4 -2
@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,struct timeval timeout;fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; +/* 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
@@ -1531,10 +1533,10 @@ static void test_txmsg_skb(int cgrp, struct sockmap_options *opt) txmsg_ktls_skb_drop =1 ;test_exec (cgrp, opt); - txmsg_ktls_skb_drop =0 ; txmsg_ktls_skb_redir =1 ;test_exec (cgrp, opt); txmsg_ktls_skb_redir =0 ; + txmsg_ktls_skb_drop =0 ;/* Tests that omit skb_parser */ txmsg_omit_skb_parser =1 ;
Signature · 1 line
2.40.1
Martin KaFai Lau
reviewerRe: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
Quoted 45 lines · Geliang Tang
Hi Martin,
Quoted 33 lines · Martin KaFai Lau
Quoted 32 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Incorrect arguments are passed to
fcntl()intest_sockmap.cwhen invoking it to set file status flags. IfO_NONBLOCKis used as 2nd argument and passed into fcntl,-EINVALwill be returned (Seedo_fcntl()infs/fcntl.c). The correct approach is to useF_SETFLas 2nd argument, andO_NONBLOCKas 3rd one.In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise some subtests of
test_sockmapfail.Fixes 16962b2404ac ("bpf: sockmap, add selftests")Signed-off-by Geliang Tang <[email protected]>Acked-by Yonghong Song <[email protected]>--- tools/testing/selftests/bpf/test_sockmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/test_sockmap.c +3
-1@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,struct timeval timeout;fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; +/* 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 Quoted 8 lines
tools/testing/selftests/bpf/test_sockmap.c static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · line 683
Quoted 5 lines
tools/testing/selftests/bpf/test_sockmap.c +1
-0@@ -678,6 +680,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,perror ("recv failed()" ); goto out_errno; } +continue ;From looking at it again, there is a
select()earlier, so it should not hit
EWOULDBLOCK.
Quoted 3 lines
Can the patch in the attachment be accepted? It can work, but I'm not sure if it has changed the behavior of this test. Anyway, I would like to hear your opinion.
I don't know what is the correct expectation also. John and JakubS, can you take a look?
Geliang Tang
reviewerRe: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
Quoted 65 lines · Martin KaFai Lau
Quoted 58 lines · Geliang Tang
Hi Martin,
Quoted 46 lines · Martin KaFai Lau
Quoted 45 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Incorrect arguments are passed to
fcntl()intest_sockmap.cwhen invoking
it to set file status flags. IfO_NONBLOCKis used as 2nd argument and
passed into fcntl,-EINVALwill be returned (Seedo_fcntl()infs/fcntl.c).
The correct approach is to useF_SETFLas 2nd argument, andO_NONBLOCKas
3rd one.In nonblock mode, if EWOULDBLOCK is received, continue receiving, otherwise
some subtests oftest_sockmapfail.Fixes 16962b2404ac ("bpf: sockmap, add selftests")Signed-off-by Geliang Tang <[email protected]>Acked-by Yonghong Song <[email protected]>---
tools/testing/selftests/bpf/test_sockmap.c| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/test_sockmap.c +3
-1@@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, struct timeval timeout; fd_set w; -fcntl (fd, fd_flags); +if (fcntl (fd,F_SETFL , fd_flags)) + goto out_errno; + /* Account for pop bytes noting each iterationof apply will
* callmsg_pop_datahelper so we need to account for this
* by calculating the number of apply iterations. Note usertools/testing/selftests/bpf/test_sockmap.c +0
-0@@ -678,6 +680,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,perror("recv
Quoted 8 lines
tools/testing/selftests/bpf/test_sockmap.c
Quoted 4 lines
failed()");
gotoout_errno; }tools/testing/selftests/bpf/test_sockmap.c +1
-0+continue ;From looking at it again, there is a
select()earlier, so it should not hit
EWOULDBLOCK.Quoted 5 lines
Can the patch in the attachment be accepted? It can work, but I'm not sure
if it has changed the behavior of this test. Anyway, I would like to hear
your opinion.
Quoted 3 lines
I don't know what is the correct expectation also. John and JakubS, can you take
a look?
Hello,
New version v5 has been sent. Please review it for me.
Thanks,
-Geliang
Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
Quoted 1 line · Geliang Tang
New version v5 has been sent. Please review it for me.
Sorry for the long delay. I'm in between laptops. But I will take a look this week.
Geliang Tang
reviewerPATCH v4 2/2 selftests/bpf: Fix umount cgroup2 error in test_sockmap
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
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().
--- tools/testing/selftests/bpf/test_sockmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_sockmap.c +1 -1
@@ -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; }
Signature · 1 line
2.40.1
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: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8610829214
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/cc8f1e4c2ba4
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=842664
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-normalFor 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)
This series was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Hello:
This series was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Quoted 8 lines · On Tue, 9 Apr 2024 13:18:38 +0800 you wrote:
From: Geliang Tang <[email protected]>
v4:
- address Martin's comments for v3. (thanks.)
- add Yonghong's "Acked-by" tags. (thanks.)
- update subject-prefix from "bpf-next" to "bpf".[...]
Here is the summary with links:
- [bpf,v4,1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap (no matching commit)
- [bpf,v4,2/2] selftests/bpf: Fix umount cgroup2 error in test_sockmap
https://git.kernel.org/bpf/bpf-next/c/d75142dbeb2b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html