lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvbK_fwrM627cxt59SDkS5uuaRsDhpZ2X_BZsqdHJ9D8t+H+A@mail.gmail.com>
Date:   Thu, 8 Oct 2020 18:01:06 +0800
From:   Xin Long <lucien.xin@...il.com>
To:     network dev <netdev@...r.kernel.org>, linux-sctp@...r.kernel.org
Cc:     Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
        Neil Horman <nhorman@...driver.com>,
        Michael Tuexen <tuexen@...muenster.de>,
        davem <davem@...emloft.net>, Tom Herbert <tom@...bertland.com>
Subject: Re: [PATCHv2 net-next 03/17] udp: do checksum properly in skb_udp_tunnel_segment

CCing Tom Herbert

On Thu, Oct 8, 2020 at 5:48 PM Xin Long <lucien.xin@...il.com> wrote:
>
> This patch fixes two things:
>
>   When skb->ip_summed == CHECKSUM_PARTIAL, skb_checksum_help() should be
>   called do the checksum, instead of gso_make_checksum(), which is used
>   to do the checksum for current proto after calling skb_segment(), not
>   after the inner proto's gso_segment().
>
>   When offload_csum is disabled, the hardware will not do the checksum
>   for the current proto, udp. So instead of calling gso_make_checksum(),
>   it should calculate checksum for udp itself.
>
> Cc: Tom Herbert <tom@...bertland.com>
> Signed-off-by: Xin Long <lucien.xin@...il.com>
> ---
>  net/ipv4/udp_offload.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index e67a66f..c0b010b 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -131,14 +131,15 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
>                 uh->check = ~csum_fold(csum_add(partial,
>                                        (__force __wsum)htonl(len)));
>
> -               if (skb->encapsulation || !offload_csum) {
> -                       uh->check = gso_make_checksum(skb, ~uh->check);
> -                       if (uh->check == 0)
> -                               uh->check = CSUM_MANGLED_0;
> -               } else {
> +               if (skb->encapsulation)
> +                       skb_checksum_help(skb);
> +
> +               if (offload_csum) {
>                         skb->ip_summed = CHECKSUM_PARTIAL;
>                         skb->csum_start = skb_transport_header(skb) - skb->head;
>                         skb->csum_offset = offsetof(struct udphdr, check);
> +               } else {
> +                       uh->check = csum_fold(skb_checksum(skb, udp_offset, len, 0));
>                 }
>         } while ((skb = skb->next));
>  out:
> --
> 2.1.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ