netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] udp: Complement partial checksum for GSO packet
@ 2018-05-01  0:01 Sean Tranchetti
  2018-05-01 10:06 ` Willem de Bruijn
  0 siblings, 1 reply; 4+ messages in thread
From: Sean Tranchetti @ 2018-05-01  0:01 UTC (permalink / raw)
  To: willemb, davem, netdev; +Cc: Sean Tranchetti, Subash Abhinov Kasiviswanathan

Using the udp_v4_check() function to calculate the pseudo header
for the newly segmented UDP packets results in assigning the complement
of the value to the UDP header checksum field.

Always undo the complement the partial checksum value in order to
match the case where GSO is not used on the UDP transmit path.

Fixes: ee80d1ebe5ba ("udp: add udp gso")
Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
---
 net/ipv4/udp_offload.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index f78fb36..0062570 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -223,6 +223,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 			csum_replace2(&uh->check, htons(mss),
 				      htons(seg->len - hdrlen - sizeof(*uh)));
 
+		uh->check = ~uh->check;
 		seg->destructor = sock_wfree;
 		seg->sk = sk;
 		sum_truesize += seg->truesize;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] udp: Complement partial checksum for GSO packet
  2018-05-01  0:01 [PATCH net-next] udp: Complement partial checksum for GSO packet Sean Tranchetti
@ 2018-05-01 10:06 ` Willem de Bruijn
  2018-05-02  9:25   ` Willem de Bruijn
  0 siblings, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2018-05-01 10:06 UTC (permalink / raw)
  To: Sean Tranchetti
  Cc: Willem de Bruijn, David Miller, Network Development,
	Subash Abhinov Kasiviswanathan

On Tue, May 1, 2018 at 2:01 AM, Sean Tranchetti <stranche@codeaurora.org> wrote:
> Using the udp_v4_check() function to calculate the pseudo header
> for the newly segmented UDP packets results in assigning the complement
> of the value to the UDP header checksum field.
>
> Always undo the complement the partial checksum value in order to
> match the case where GSO is not used on the UDP transmit path.
>
> Fixes: ee80d1ebe5ba ("udp: add udp gso")
> Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
> ---
>  net/ipv4/udp_offload.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index f78fb36..0062570 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -223,6 +223,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
>                         csum_replace2(&uh->check, htons(mss),
>                                       htons(seg->len - hdrlen - sizeof(*uh)));
>
> +               uh->check = ~uh->check;
>                 seg->destructor = sock_wfree;
>                 seg->sk = sk;
>                 sum_truesize += seg->truesize;

Thanks, this looks plausible. I may have been mistaken by evaluation
showing packets arriving at the peer with the correct checksum before.

On retesting, packets arrive with correct checksum in both cases, and
even when setting purposely bad uh->check values.

Perhaps the two platforms I tested on (bnx2x, mlx4) ignore the pseudo
header and recompute from scratch if CHECKSUM_PARTIAL is set for
udp. Still having a look..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] udp: Complement partial checksum for GSO packet
  2018-05-01 10:06 ` Willem de Bruijn
@ 2018-05-02  9:25   ` Willem de Bruijn
  2018-05-02 15:00     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2018-05-02  9:25 UTC (permalink / raw)
  To: Sean Tranchetti
  Cc: Willem de Bruijn, David Miller, Network Development,
	Subash Abhinov Kasiviswanathan

On Tue, May 1, 2018 at 12:06 PM, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
> On Tue, May 1, 2018 at 2:01 AM, Sean Tranchetti <stranche@codeaurora.org> wrote:
>> Using the udp_v4_check() function to calculate the pseudo header
>> for the newly segmented UDP packets results in assigning the complement
>> of the value to the UDP header checksum field.
>>
>> Always undo the complement the partial checksum value in order to
>> match the case where GSO is not used on the UDP transmit path.
>>
>> Fixes: ee80d1ebe5ba ("udp: add udp gso")
>> Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
>> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>

Acked-by: Willem de Bruijn <willemb@google.com>

Thanks Sean.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] udp: Complement partial checksum for GSO packet
  2018-05-02  9:25   ` Willem de Bruijn
@ 2018-05-02 15:00     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-05-02 15:00 UTC (permalink / raw)
  To: willemdebruijn.kernel; +Cc: stranche, willemb, netdev, subashab

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Wed, 2 May 2018 11:25:43 +0200

> On Tue, May 1, 2018 at 12:06 PM, Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
>> On Tue, May 1, 2018 at 2:01 AM, Sean Tranchetti <stranche@codeaurora.org> wrote:
>>> Using the udp_v4_check() function to calculate the pseudo header
>>> for the newly segmented UDP packets results in assigning the complement
>>> of the value to the UDP header checksum field.
>>>
>>> Always undo the complement the partial checksum value in order to
>>> match the case where GSO is not used on the UDP transmit path.
>>>
>>> Fixes: ee80d1ebe5ba ("udp: add udp gso")
>>> Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
>>> Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
> 
> Acked-by: Willem de Bruijn <willemb@google.com>
> 
> Thanks Sean.

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-02 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-01  0:01 [PATCH net-next] udp: Complement partial checksum for GSO packet Sean Tranchetti
2018-05-01 10:06 ` Willem de Bruijn
2018-05-02  9:25   ` Willem de Bruijn
2018-05-02 15:00     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).