All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v4 0/2] Two fixes for test_sockmap
@ 2024-04-09  5:18 Geliang Tang
  2024-04-09  5:18 ` [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Geliang Tang @ 2024-04-09  5:18 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>

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(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-09  5:18 [PATCH bpf v4 0/2] Two fixes for test_sockmap Geliang Tang
@ 2024-04-09  5:18 ` Geliang Tang
  2024-04-11 18:10   ` Martin KaFai Lau
  2024-04-09  5:18 ` [PATCH bpf v4 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Geliang Tang @ 2024-04-09  5:18 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 fail.

Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
---
 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..4feed253fca2 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -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;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH bpf v4 2/2] selftests/bpf: Fix umount cgroup2 error in test_sockmap
  2024-04-09  5:18 [PATCH bpf v4 0/2] Two fixes for test_sockmap Geliang Tang
  2024-04-09  5:18 ` [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
@ 2024-04-09  5:18 ` Geliang Tang
  2024-04-09  6:07 ` [PATCH bpf v4 0/2] Two fixes for test_sockmap MPTCP CI
  2024-04-11 18:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 10+ messages in thread
From: Geliang Tang @ 2024-04-09  5:18 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>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
---
 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 4feed253fca2..efb4f34bf703 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] 10+ messages in thread

* Re: [PATCH bpf v4 0/2] Two fixes for test_sockmap
  2024-04-09  5:18 [PATCH bpf v4 0/2] Two fixes for test_sockmap Geliang Tang
  2024-04-09  5:18 ` [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
  2024-04-09  5:18 ` [PATCH bpf v4 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
@ 2024-04-09  6:07 ` MPTCP CI
  2024-04-11 18:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 10+ messages in thread
From: MPTCP CI @ 2024-04-09  6:07 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: 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-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] 10+ messages in thread

* Re: [PATCH bpf v4 0/2] Two fixes for test_sockmap
  2024-04-09  5:18 [PATCH bpf v4 0/2] Two fixes for test_sockmap Geliang Tang
                   ` (2 preceding siblings ...)
  2024-04-09  6:07 ` [PATCH bpf v4 0/2] Two fixes for test_sockmap MPTCP CI
@ 2024-04-11 18:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-11 18:10 UTC (permalink / raw)
  To: Geliang Tang
  Cc: andrii, eddyz87, mykolal, ast, daniel, martin.lau, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
	shuah, jakub, tanggeliang, bpf, mptcp

Hello:

This series was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Tue,  9 Apr 2024 13:18:38 +0800 you wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-09  5:18 ` [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
@ 2024-04-11 18:10   ` Martin KaFai Lau
  2024-04-17  8:14     ` Geliang Tang
  0 siblings, 1 reply; 10+ messages in thread
From: Martin KaFai Lau @ 2024-04-11 18:10 UTC (permalink / raw)
  To: Geliang Tang
  Cc: 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, Geliang Tang, bpf, mptcp

On 4/8/24 10:18 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 fail.
> 
> Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> Acked-by: Yonghong Song <yonghong.song@linux.dev>
> ---
>   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..4feed253fca2 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -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;

 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.

>   			}
>   
>   			s->bytes_recvd += recv;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-11 18:10   ` Martin KaFai Lau
@ 2024-04-17  8:14     ` Geliang Tang
  2024-04-18  0:28       ` Martin KaFai Lau
  0 siblings, 1 reply; 10+ messages in thread
From: Geliang Tang @ 2024-04-17  8:14 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: 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, bpf, Geliang Tang

[-- Attachment #1: Type: text/plain, Size: 2189 bytes --]

Hi Martin,

On Thu, Apr 11, 2024 at 11:10:49AM -0700, Martin KaFai Lau wrote:
> On 4/8/24 10:18 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 fail.
> > 
> > Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > Acked-by: Yonghong Song <yonghong.song@linux.dev>
> > ---
> >   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..4feed253fca2 100644
> > --- a/tools/testing/selftests/bpf/test_sockmap.c
> > +++ b/tools/testing/selftests/bpf/test_sockmap.c
> > @@ -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;
> 
> 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

> 
> Patch 2 looks good. Only patch 2 is applied. Thanks.
> 
> >   			}
> >   			s->bytes_recvd += recv;

[-- Attachment #2: 0001-selftests-bpf-Add-F_SETFL-for-fcntl-in-test_sockmap.patch --]
[-- Type: text/x-diff, Size: 1994 bytes --]

From d20ac7e06d9e869094f452d8c2dcdc316508dcc8 Mon Sep 17 00:00:00 2001
Message-Id: <d20ac7e06d9e869094f452d8c2dcdc316508dcc8.1713340686.git.tanggeliang@kylinos.cn>
From: Geliang Tang <tanggeliang@kylinos.cn>
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.

Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
---
 tools/testing/selftests/bpf/test_sockmap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index 024a0faafb3b..8130f465afb9 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -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;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-17  8:14     ` Geliang Tang
@ 2024-04-18  0:28       ` Martin KaFai Lau
  2024-04-23 10:28         ` Geliang Tang
  0 siblings, 1 reply; 10+ messages in thread
From: Martin KaFai Lau @ 2024-04-18  0:28 UTC (permalink / raw)
  To: Geliang Tang, Jakub Sitnicki, John Fastabend
  Cc: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
	Alexei Starovoitov, Daniel Borkmann, Song Liu, Yonghong Song,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	bpf

On 4/17/24 1:14 AM, Geliang Tang wrote:
> Hi Martin,
> 
> On Thu, Apr 11, 2024 at 11:10:49AM -0700, Martin KaFai Lau wrote:
>> On 4/8/24 10:18 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 fail.
>>>
>>> Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
>>> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
>>> Acked-by: Yonghong Song <yonghong.song@linux.dev>
>>> ---
>>>    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..4feed253fca2 100644
>>> --- a/tools/testing/selftests/bpf/test_sockmap.c
>>> +++ b/tools/testing/selftests/bpf/test_sockmap.c
>>> @@ -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;
>>
>>  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.

I don't know what is the correct expectation also. John and JakubS, can you take 
a look?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-18  0:28       ` Martin KaFai Lau
@ 2024-04-23 10:28         ` Geliang Tang
  2024-04-25 12:26           ` Jakub Sitnicki
  0 siblings, 1 reply; 10+ messages in thread
From: Geliang Tang @ 2024-04-23 10:28 UTC (permalink / raw)
  To: Martin KaFai Lau, Jakub Sitnicki, John Fastabend
  Cc: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
	Alexei Starovoitov, Daniel Borkmann, Song Liu, Yonghong Song,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	bpf

On Wed, 2024-04-17 at 17:28 -0700, Martin KaFai Lau wrote:
> On 4/17/24 1:14 AM, Geliang Tang wrote:
> > Hi Martin,
> > 
> > On Thu, Apr 11, 2024 at 11:10:49AM -0700, Martin KaFai Lau wrote:
> > > On 4/8/24 10:18 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 fail.
> > > > 
> > > > Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> > > > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > > > Acked-by: Yonghong Song <yonghong.song@linux.dev>
> > > > ---
> > > >    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..4feed253fca2 100644
> > > > --- a/tools/testing/selftests/bpf/test_sockmap.c
> > > > +++ b/tools/testing/selftests/bpf/test_sockmap.c
> > > > @@ -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;
> > > 
> > >  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.
> 
> 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap
  2024-04-23 10:28         ` Geliang Tang
@ 2024-04-25 12:26           ` Jakub Sitnicki
  0 siblings, 0 replies; 10+ messages in thread
From: Jakub Sitnicki @ 2024-04-25 12:26 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Martin KaFai Lau, John Fastabend, Andrii Nakryiko,
	Eduard Zingerman, Mykola Lysenko, Alexei Starovoitov,
	Daniel Borkmann, Song Liu, Yonghong Song, KP Singh,
	Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan, bpf

On Tue, Apr 23, 2024 at 12:29 PM Geliang Tang <geliang@kernel.org> wrote:
> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-04-25 12:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09  5:18 [PATCH bpf v4 0/2] Two fixes for test_sockmap Geliang Tang
2024-04-09  5:18 ` [PATCH bpf v4 1/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Geliang Tang
2024-04-11 18:10   ` Martin KaFai Lau
2024-04-17  8:14     ` Geliang Tang
2024-04-18  0:28       ` Martin KaFai Lau
2024-04-23 10:28         ` Geliang Tang
2024-04-25 12:26           ` Jakub Sitnicki
2024-04-09  5:18 ` [PATCH bpf v4 2/2] selftests/bpf: Fix umount cgroup2 error " Geliang Tang
2024-04-09  6:07 ` [PATCH bpf v4 0/2] Two fixes for test_sockmap MPTCP CI
2024-04-11 18:10 ` patchwork-bot+netdevbpf

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.