diff mbox series

[bpf-next] selftests/bpf: Fix error reporting from sock_fields programs

Message ID 20220225184130.483208-1-jakub@cloudflare.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Fix error reporting from sock_fields programs | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 6 maintainers not CCed: linux-kselftest@vger.kernel.org kpsingh@kernel.org john.fastabend@gmail.com songliubraving@fb.com shuah@kernel.org yhs@fb.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next fail VM_Test

Commit Message

Jakub Sitnicki Feb. 25, 2022, 6:41 p.m. UTC
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(-)

Comments

Martin KaFai Lau Feb. 25, 2022, 8:13 p.m. UTC | #1
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>
Jakub Sitnicki Feb. 27, 2022, 4:16 p.m. UTC | #2
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.
diff mbox series

Patch

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;						\
 })