netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix error reporting from sock_fields programs
@ 2022-02-25 18:41 Jakub Sitnicki
  2022-02-25 20:13 ` Martin KaFai Lau
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Sitnicki @ 2022-02-25 18:41 UTC (permalink / raw)
  To: bpf
  Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Ilya Leoshkevich, kernel-team

The helper macro that records an error in BPF programs that exercise sock
fields access has been indavertedly broken by adaptation work that happened
in commit b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel
and global variables").

BPF_NOEXIST flag cannot be used to update BPF_MAP_TYPE_ARRAY. The operation
always fails with -EEXIST, which in turn means the error never gets
recorded, and the checks for errors always pass.

Revert the change in update flags.

Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
 tools/testing/selftests/bpf/progs/test_sock_fields.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/test_sock_fields.c b/tools/testing/selftests/bpf/progs/test_sock_fields.c
index 246f1f001813..3e2e3ee51cc9 100644
--- a/tools/testing/selftests/bpf/progs/test_sock_fields.c
+++ b/tools/testing/selftests/bpf/progs/test_sock_fields.c
@@ -114,7 +114,7 @@ static void tpcpy(struct bpf_tcp_sock *dst,
 
 #define RET_LOG() ({						\
 	linum = __LINE__;					\
-	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_NOEXIST);	\
+	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_ANY);	\
 	return CG_OK;						\
 })
 
-- 
2.35.1


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

* Re: [PATCH bpf-next] selftests/bpf: Fix error reporting from sock_fields programs
  2022-02-25 18:41 [PATCH bpf-next] selftests/bpf: Fix error reporting from sock_fields programs Jakub Sitnicki
@ 2022-02-25 20:13 ` Martin KaFai Lau
  2022-02-27 16:16   ` Jakub Sitnicki
  0 siblings, 1 reply; 3+ messages in thread
From: Martin KaFai Lau @ 2022-02-25 20:13 UTC (permalink / raw)
  To: Jakub Sitnicki
  Cc: bpf, netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Ilya Leoshkevich, kernel-team

On Fri, Feb 25, 2022 at 07:41:30PM +0100, Jakub Sitnicki wrote:
> The helper macro that records an error in BPF programs that exercise sock
> fields access has been indavertedly broken by adaptation work that happened
> in commit b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel
> and global variables").
> 
> BPF_NOEXIST flag cannot be used to update BPF_MAP_TYPE_ARRAY. The operation
> always fails with -EEXIST, which in turn means the error never gets
> recorded, and the checks for errors always pass.
> 
> Revert the change in update flags.
> 
> Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
> ---
>  tools/testing/selftests/bpf/progs/test_sock_fields.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/test_sock_fields.c b/tools/testing/selftests/bpf/progs/test_sock_fields.c
> index 246f1f001813..3e2e3ee51cc9 100644
> --- a/tools/testing/selftests/bpf/progs/test_sock_fields.c
> +++ b/tools/testing/selftests/bpf/progs/test_sock_fields.c
> @@ -114,7 +114,7 @@ static void tpcpy(struct bpf_tcp_sock *dst,
>  
>  #define RET_LOG() ({						\
>  	linum = __LINE__;					\
> -	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_NOEXIST);	\
> +	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_ANY);	\
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH bpf-next] selftests/bpf: Fix error reporting from sock_fields programs
  2022-02-25 20:13 ` Martin KaFai Lau
@ 2022-02-27 16:16   ` Jakub Sitnicki
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Sitnicki @ 2022-02-27 16:16 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: bpf, netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Ilya Leoshkevich, kernel-team


On Fri, Feb 25, 2022 at 12:13 PM -08, Martin KaFai Lau wrote:
> On Fri, Feb 25, 2022 at 07:41:30PM +0100, Jakub Sitnicki wrote:
>> The helper macro that records an error in BPF programs that exercise sock
>> fields access has been indavertedly broken by adaptation work that happened
>> in commit b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel
>> and global variables").
>> 
>> BPF_NOEXIST flag cannot be used to update BPF_MAP_TYPE_ARRAY. The operation
>> always fails with -EEXIST, which in turn means the error never gets
>> recorded, and the checks for errors always pass.
>> 
>> Revert the change in update flags.
>> 
>> Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
>> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
>> ---
>>  tools/testing/selftests/bpf/progs/test_sock_fields.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/tools/testing/selftests/bpf/progs/test_sock_fields.c b/tools/testing/selftests/bpf/progs/test_sock_fields.c
>> index 246f1f001813..3e2e3ee51cc9 100644
>> --- a/tools/testing/selftests/bpf/progs/test_sock_fields.c
>> +++ b/tools/testing/selftests/bpf/progs/test_sock_fields.c
>> @@ -114,7 +114,7 @@ static void tpcpy(struct bpf_tcp_sock *dst,
>>  
>>  #define RET_LOG() ({						\
>>  	linum = __LINE__;					\
>> -	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_NOEXIST);	\
>> +	bpf_map_update_elem(&linum_map, &linum_idx, &linum, BPF_ANY);	\
> Acked-by: Martin KaFai Lau <kafai@fb.com>

Thanks for the quick review.

I need to follow up with a v2. Was too quick to send this patch out by
itself. Now that the error reporting works, the test sock_fields tests
are failing on little- and big-endian.

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

end of thread, other threads:[~2022-02-27 16:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-25 18:41 [PATCH bpf-next] selftests/bpf: Fix error reporting from sock_fields programs Jakub Sitnicki
2022-02-25 20:13 ` Martin KaFai Lau
2022-02-27 16:16   ` Jakub Sitnicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).