diff mbox series

[bpf-next] samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60

Message ID 168545704139.2996228.2516528552939485216.stgit@firesoul (mailing list archive)
State Accepted
Commit 60548b825b082cedf89b275c21c28b1e1d030e50
Delegated to: BPF
Headers show
Series [bpf-next] samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60 | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 1 blamed authors not CCed: john.fastabend@gmail.com; 13 maintainers not CCed: kuba@kernel.org hawk@kernel.org daniel@iogearbox.net yhs@fb.com kpsingh@kernel.org martin.lau@linux.dev john.fastabend@gmail.com sdf@google.com song@kernel.org andrii@kernel.org davem@davemloft.net jolsa@kernel.org haoluo@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 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-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on s390x with gcc

Commit Message

Jesper Dangaard Brouer May 30, 2023, 2:30 p.m. UTC
Default samples/pktgen scripts send 60 byte packets as hardware
adds 4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes
frame size.

XDP layer will not necessary have access to the 4-bytes FCS checksum.

This leads to bpf_xdp_load_bytes() failing as it tries to copy
64-bytes from an XDP packet that only have 60-bytes available.

Fixes: 772251742262 ("samples/bpf: fixup some tools to be able to support xdp multibuffer")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 samples/bpf/xdp1_kern.c |    2 +-
 samples/bpf/xdp2_kern.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Tariq Toukan May 31, 2023, 7:23 a.m. UTC | #1
On 30/05/2023 17:30, Jesper Dangaard Brouer wrote:
> Default samples/pktgen scripts send 60 byte packets as hardware
> adds 4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes
> frame size.
> 
> XDP layer will not necessary have access to the 4-bytes FCS checksum.
> 
> This leads to bpf_xdp_load_bytes() failing as it tries to copy
> 64-bytes from an XDP packet that only have 60-bytes available.
> 
> Fixes: 772251742262 ("samples/bpf: fixup some tools to be able to support xdp multibuffer")
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>   samples/bpf/xdp1_kern.c |    2 +-
>   samples/bpf/xdp2_kern.c |    2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/samples/bpf/xdp1_kern.c b/samples/bpf/xdp1_kern.c
> index 0a5c704badd0..d91f27cbcfa9 100644
> --- a/samples/bpf/xdp1_kern.c
> +++ b/samples/bpf/xdp1_kern.c
> @@ -39,7 +39,7 @@ static int parse_ipv6(void *data, u64 nh_off, void *data_end)
>   	return ip6h->nexthdr;
>   }
>   
> -#define XDPBUFSIZE	64
> +#define XDPBUFSIZE	60

Perf with the presence of load/store copies is far from being optimal..
Still, do we care if memcpy of 60 bytes performs worse than 64 (full 
cacheline)?
Maybe not really in this case, looking forward for the replacement of 
memcpy with the proper dyncptr API.

Other than that:
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>


>   SEC("xdp.frags")
>   int xdp_prog1(struct xdp_md *ctx)
>   {
> diff --git a/samples/bpf/xdp2_kern.c b/samples/bpf/xdp2_kern.c
> index 67804ecf7ce3..8bca674451ed 100644
> --- a/samples/bpf/xdp2_kern.c
> +++ b/samples/bpf/xdp2_kern.c
> @@ -55,7 +55,7 @@ static int parse_ipv6(void *data, u64 nh_off, void *data_end)
>   	return ip6h->nexthdr;
>   }
>   
> -#define XDPBUFSIZE	64
> +#define XDPBUFSIZE	60
>   SEC("xdp.frags")
>   int xdp_prog1(struct xdp_md *ctx)
>   {
> 
>
Jesper Dangaard Brouer May 31, 2023, 9:38 a.m. UTC | #2
On 31/05/2023 09.23, Tariq Toukan wrote:
> 
> 
> On 30/05/2023 17:30, Jesper Dangaard Brouer wrote:
>> Default samples/pktgen scripts send 60 byte packets as hardware
>> adds 4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes
>> frame size.
>>
>> XDP layer will not necessary have access to the 4-bytes FCS checksum.
>>
>> This leads to bpf_xdp_load_bytes() failing as it tries to copy
>> 64-bytes from an XDP packet that only have 60-bytes available.
>>
>> Fixes: 772251742262 ("samples/bpf: fixup some tools to be able to 
>> support xdp multibuffer")
>> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
>> ---
>>   samples/bpf/xdp1_kern.c |    2 +-
>>   samples/bpf/xdp2_kern.c |    2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/samples/bpf/xdp1_kern.c b/samples/bpf/xdp1_kern.c
>> index 0a5c704badd0..d91f27cbcfa9 100644
>> --- a/samples/bpf/xdp1_kern.c
>> +++ b/samples/bpf/xdp1_kern.c
>> @@ -39,7 +39,7 @@ static int parse_ipv6(void *data, u64 nh_off, void 
>> *data_end)
>>       return ip6h->nexthdr;
>>   }
>> -#define XDPBUFSIZE    64
>> +#define XDPBUFSIZE    60
> 
> Perf with the presence of load/store copies is far from being optimal..
> Still, do we care if memcpy of 60 bytes performs worse than 64 (full 
> cacheline)?

In this case that statement isn't true. I tested it and the
60 bytes define performs (slightly) better than 64 bytes one.

> Maybe not really in this case, looking forward for the replacement of 
> memcpy with the proper dyncptr API.
>

This is a fix to allow sending minimum sized Ethernet frames to these 
samples.

Looking forward, yes once dynptr is ready, we should update these
samples to use that, because the use of bpf_xdp_load_bytes() have a
surprisingly large overhead. But we cannot leave these samples broken in
the mean while.


> Other than that:
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
> 

Thanks

> 
>>   SEC("xdp.frags")
>>   int xdp_prog1(struct xdp_md *ctx)
>>   {
>> diff --git a/samples/bpf/xdp2_kern.c b/samples/bpf/xdp2_kern.c
>> index 67804ecf7ce3..8bca674451ed 100644
>> --- a/samples/bpf/xdp2_kern.c
>> +++ b/samples/bpf/xdp2_kern.c
>> @@ -55,7 +55,7 @@ static int parse_ipv6(void *data, u64 nh_off, void 
>> *data_end)
>>       return ip6h->nexthdr;
>>   }
>> -#define XDPBUFSIZE    64
>> +#define XDPBUFSIZE    60
>>   SEC("xdp.frags")
>>   int xdp_prog1(struct xdp_md *ctx)
>>   {
>>
>>
>
patchwork-bot+netdevbpf@kernel.org May 31, 2023, 11:10 a.m. UTC | #3
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 30 May 2023 16:30:41 +0200 you wrote:
> Default samples/pktgen scripts send 60 byte packets as hardware
> adds 4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes
> frame size.
> 
> XDP layer will not necessary have access to the 4-bytes FCS checksum.
> 
> This leads to bpf_xdp_load_bytes() failing as it tries to copy
> 64-bytes from an XDP packet that only have 60-bytes available.
> 
> [...]

Here is the summary with links:
  - [bpf-next] samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60
    https://git.kernel.org/bpf/bpf-next/c/60548b825b08

You are awesome, thank you!
diff mbox series

Patch

diff --git a/samples/bpf/xdp1_kern.c b/samples/bpf/xdp1_kern.c
index 0a5c704badd0..d91f27cbcfa9 100644
--- a/samples/bpf/xdp1_kern.c
+++ b/samples/bpf/xdp1_kern.c
@@ -39,7 +39,7 @@  static int parse_ipv6(void *data, u64 nh_off, void *data_end)
 	return ip6h->nexthdr;
 }
 
-#define XDPBUFSIZE	64
+#define XDPBUFSIZE	60
 SEC("xdp.frags")
 int xdp_prog1(struct xdp_md *ctx)
 {
diff --git a/samples/bpf/xdp2_kern.c b/samples/bpf/xdp2_kern.c
index 67804ecf7ce3..8bca674451ed 100644
--- a/samples/bpf/xdp2_kern.c
+++ b/samples/bpf/xdp2_kern.c
@@ -55,7 +55,7 @@  static int parse_ipv6(void *data, u64 nh_off, void *data_end)
 	return ip6h->nexthdr;
 }
 
-#define XDPBUFSIZE	64
+#define XDPBUFSIZE	60
 SEC("xdp.frags")
 int xdp_prog1(struct xdp_md *ctx)
 {