On 11/14, Alexis Lothoré (eBPF Foundation) wrote:
> xdp_metadata test has a small helper computing ipv checksums to allow
> manually building packets.
> 
> Move this helper to network_helpers to share it with other tests.
> 
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.loth...@bootlin.com>
> ---
> Changes in v2:
> - new patch
> ---
>  tools/testing/selftests/bpf/network_helpers.h      | 23 
> ++++++++++++++++++++++
>  .../selftests/bpf/prog_tests/xdp_metadata.c        | 19 +-----------------
>  2 files changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/network_helpers.h 
> b/tools/testing/selftests/bpf/network_helpers.h
> index 
> c72c16e1aff825439896b38e59962ffafe92dc71..c9b72960c651ab9fb249f6eb9e153b8416b7a488
>  100644
> --- a/tools/testing/selftests/bpf/network_helpers.h
> +++ b/tools/testing/selftests/bpf/network_helpers.h
> @@ -104,6 +104,29 @@ static __u16 csum_fold(__u32 csum)
>       return (__u16)~csum;
>  }
>  

[..]

> +static unsigned long add_csum_hword(const __u16 *start, int num_u16)
> +{
> +     unsigned long sum = 0;
> +     int i;
> +
> +     for (i = 0; i < num_u16; i++)
> +             sum += start[i];
> +
> +     return sum;
> +}

Sorry for nitpicking, but can we call it csum_partial? And match
kernel's prototype with extra sum argument? Should be more greppable
for the future test cases that might want to use it...

Reply via email to