diff mbox series

[bpf-next,v4,5/6] selftests/bpf: Fix error failure of case test_xdp_adjust_tail_grow

Message ID 20221011120108.782373-6-xukuohai@huaweicloud.com (mailing list archive)
State Accepted
Commit 496848b471260ce1475fd7a152580e068450407a
Delegated to: BPF
Headers show
Series Fix bugs found by ASAN when running selftests | expand

Checks

Context Check Description
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 Series has a cover letter
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 success CCed 20 of 20 maintainers
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/check_selftest success No net selftest shell script
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, 7 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-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16

Commit Message

Xu Kuohai Oct. 11, 2022, 12:01 p.m. UTC
From: Xu Kuohai <xukuohai@huawei.com>

test_xdp_adjust_tail_grow failed with ipv6:
  test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)

The reason is that this test case tests ipv4 before ipv6, and when ipv4
test finished, topts.data_size_out was set to 54, which is smaller than the
ipv6 output data size 114, so ipv6 test fails with NOSPC error.

Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.

Fixes: 04fcb5f9a104 ("selftests/bpf: Migrate from bpf_prog_test_run")
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
---
 tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Martin KaFai Lau Oct. 12, 2022, 11:17 p.m. UTC | #1
On 10/11/22 5:01 AM, Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
> 
> test_xdp_adjust_tail_grow failed with ipv6:
>    test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)
> 
> The reason is that this test case tests ipv4 before ipv6, and when ipv4
> test finished, topts.data_size_out was set to 54, which is smaller than the
> ipv6 output data size 114, so ipv6 test fails with NOSPC error.
> 
> Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.
> 
> Fixes: 04fcb5f9a104 ("selftests/bpf: Migrate from bpf_prog_test_run")
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
> ---
>   tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
> index 9b9cf8458adf..009ee37607df 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
> @@ -63,6 +63,7 @@ static void test_xdp_adjust_tail_grow(void)
>   	expect_sz = sizeof(pkt_v6) + 40; /* Test grow with 40 bytes */
>   	topts.data_in = &pkt_v6;
>   	topts.data_size_in = sizeof(pkt_v6);
> +	topts.data_size_out = sizeof(buf);

lgtm but how was it working before... weird.

>   	err = bpf_prog_test_run_opts(prog_fd, &topts);
>   	ASSERT_OK(err, "ipv6");
>   	ASSERT_EQ(topts.retval, XDP_TX, "ipv6 retval");
Xu Kuohai Oct. 13, 2022, 1:45 a.m. UTC | #2
On 10/13/2022 7:17 AM, Martin KaFai Lau wrote:
> On 10/11/22 5:01 AM, Xu Kuohai wrote:
>> From: Xu Kuohai <xukuohai@huawei.com>
>>
>> test_xdp_adjust_tail_grow failed with ipv6:
>>    test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)
>>
>> The reason is that this test case tests ipv4 before ipv6, and when ipv4
>> test finished, topts.data_size_out was set to 54, which is smaller than the
>> ipv6 output data size 114, so ipv6 test fails with NOSPC error.
>>
>> Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.
>>
>> Fixes: 04fcb5f9a104 ("selftests/bpf: Migrate from bpf_prog_test_run")
>> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
>> ---
>>   tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
>> index 9b9cf8458adf..009ee37607df 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
>> @@ -63,6 +63,7 @@ static void test_xdp_adjust_tail_grow(void)
>>       expect_sz = sizeof(pkt_v6) + 40; /* Test grow with 40 bytes */
>>       topts.data_in = &pkt_v6;
>>       topts.data_size_in = sizeof(pkt_v6);
>> +    topts.data_size_out = sizeof(buf);
> 
> lgtm but how was it working before... weird.
> 

the test case returns before this line is executed, see patch 6

>>       err = bpf_prog_test_run_opts(prog_fd, &topts);
>>       ASSERT_OK(err, "ipv6");
>>       ASSERT_EQ(topts.retval, XDP_TX, "ipv6 retval");
> 
> .
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
index 9b9cf8458adf..009ee37607df 100644
--- a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
@@ -63,6 +63,7 @@  static void test_xdp_adjust_tail_grow(void)
 	expect_sz = sizeof(pkt_v6) + 40; /* Test grow with 40 bytes */
 	topts.data_in = &pkt_v6;
 	topts.data_size_in = sizeof(pkt_v6);
+	topts.data_size_out = sizeof(buf);
 	err = bpf_prog_test_run_opts(prog_fd, &topts);
 	ASSERT_OK(err, "ipv6");
 	ASSERT_EQ(topts.retval, XDP_TX, "ipv6 retval");