netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Hunt <johunt@akamai.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Alexander Duyck <alexander.duyck@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	Netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	"Duyck, Alexander H" <alexander.h.duyck@intel.com>
Subject: Re: [PATCH 2/2] udp: only do GSO if # of segs > 1
Date: Tue, 1 Oct 2019 08:08:48 -0700	[thread overview]
Message-ID: <53290360-a34a-3fc3-0fbc-dcbe19393d69@akamai.com> (raw)
In-Reply-To: <CA+FuTSfHxNw4P9sp83_DoMmb-5NQXwSn74CUH80Ai2MSjPcjZw@mail.gmail.com>



On 10/1/19 5:22 AM, Willem de Bruijn wrote:
> On Mon, Sep 30, 2019 at 7:57 PM Alexander Duyck
> <alexander.duyck@gmail.com> wrote:
>>
>> On Mon, Sep 30, 2019 at 3:13 PM Josh Hunt <johunt@akamai.com> wrote:
>>>
>>> Prior to this change an application sending <= 1MSS worth of data and
>>> enabling UDP GSO would fail if the system had SW GSO enabled, but the
>>> same send would succeed if HW GSO offload is enabled. In addition to this
>>> inconsistency the error in the SW GSO case does not get back to the
>>> application if sending out of a real device so the user is unaware of this
>>> failure.
>>>
>>> With this change we only perform GSO if the # of segments is > 1 even
>>> if the application has enabled segmentation. I've also updated the
>>> relevant udpgso selftests.
>>>
>>> Fixes: bec1f6f69736 ("udp: generate gso with UDP_SEGMENT")
>>> Signed-off-by: Josh Hunt <johunt@akamai.com>
>>> ---
>>>   net/ipv4/udp.c                       |  5 +++--
>>>   net/ipv6/udp.c                       |  5 +++--
>>>   tools/testing/selftests/net/udpgso.c | 16 ++++------------
>>>   3 files changed, 10 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
>>> index be98d0b8f014..ac0baf947560 100644
>>> --- a/net/ipv4/udp.c
>>> +++ b/net/ipv4/udp.c
>>> @@ -821,6 +821,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
>>>          int is_udplite = IS_UDPLITE(sk);
>>>          int offset = skb_transport_offset(skb);
>>>          int len = skb->len - offset;
>>> +       int datalen = len - sizeof(*uh);
>>>          __wsum csum = 0;
>>>
>>>          /*
>>> @@ -832,7 +833,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
>>>          uh->len = htons(len);
>>>          uh->check = 0;
>>>
>>> -       if (cork->gso_size) {
>>> +       if (cork->gso_size && datalen > cork->gso_size) {
>>>                  const int hlen = skb_network_header_len(skb) +
>>>                                   sizeof(struct udphdr);
>>>
>>
>> So what about the datalen == cork->gso_size case? That would only
>> generate one segment wouldn't it?
> 
> Segmentation drops packets in this boundary case (not sure why).
> 
>> Shouldn't the test really be "datalen < cork->gso_size"? That should
>> be the only check you need since if gso_size is 0 this statement would
>> always fail anyway.
>>
>> Thanks.
>>
>> - Alex
> 
> The original choice was made to match GSO behavior of other protocols.
> The drop occurs in protocol-independent skb_segment.
> 
> But I had not anticipated HW GSO to behave differently. With that,

Right and for HW GSO we don't call skb_segment().

> aligning the two makes sense. Especially as UDP GSO is exposed to
> userspace. Having to explicitly code a branch whether or not to pass
> UDP_SEGMENT on each send based on size is confusing.
> 
> gso_size is supplied by the user. That value need not be smaller than
> or equal to MTU minus headers. Some of the tests inside the branch,
> especially
> 
>        if (hlen + cork->gso_size > cork->fragsize) {
>                kfree_skb(skb);
>                return -EINVAL;
>        }
> 
> still need to be checked.
> 

Thanks for the review Willem. I will look at those checks and send a v2.

Thanks!
Josh

  reply	other threads:[~2019-10-01 15:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 22:11 [PATCH 1/2] udp: fix gso_segs calculations Josh Hunt
2019-09-30 22:11 ` [PATCH 2/2] udp: only do GSO if # of segs > 1 Josh Hunt
2019-09-30 23:56   ` Alexander Duyck
2019-10-01 12:22     ` Willem de Bruijn
2019-10-01 15:08       ` Josh Hunt [this message]
2019-10-01 14:36     ` Josh Hunt
2019-10-01 15:05       ` Alexander Duyck
2019-09-30 23:51 ` [PATCH 1/2] udp: fix gso_segs calculations Alexander Duyck
2019-10-01 12:12   ` Willem de Bruijn
2019-10-01 14:31     ` Josh Hunt
2019-10-01 14:31   ` Josh Hunt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53290360-a34a-3fc3-0fbc-dcbe19393d69@akamai.com \
    --to=johunt@akamai.com \
    --cc=alexander.duyck@gmail.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).