Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3253429pxb; Mon, 9 Nov 2020 06:39:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJygh0H144Dsg+HYQgurULT9w11l5RAbGvXRHD7txNyFxZYIDaWkEVLi4L+hUjOflOW7wAqQ X-Received: by 2002:a17:906:3a49:: with SMTP id a9mr15504409ejf.95.1604932751547; Mon, 09 Nov 2020 06:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604932751; cv=none; d=google.com; s=arc-20160816; b=nv3/ODVjLsUVzctvShhHtRhbydqSnCGLfsjlnDnoHyPsAdttnvA/WJTABwPOHESw40 fdNnxFUZcZNRB11qzS0pUwULMELsWOV/3LtdyNODjebtx6R3Lp01YOSP3/zwcxSiN6vC TkTqEGDWKrypLpFj4VzYIy2dfZzuV88I7yxYG93cz9Q8mvZd0ofcDYxjkgiuQQgnHxwb D311v+DmCsHAIdbRAhWwqp96KSvobP5oCkESCHP/vuVyi/z8auIbT8mRHOBUFq9c5mSL XepaC9gnNaD0WzoMZo3RJsbzc/JQOgwsGde6nhAUiAUTptpDRa5ddhS8Q0v4GMNaZwJr nHyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xDniQAvxFLBjIKTPYpnf40KKSY2vMSiv1LR/tBJSqcA=; b=p2B01ogq2D0VODp53983YCfzjPXMmotWyUKmXW2OAPQ2lrvoBRA/EJj7ycIln0imo8 Sz6YxGBcxBQb6DAD0AV9+iAOOcTM2517WMz05kBxLUbkQWHYy5dmLGHVMAQ4Rb2KuZg3 4NGEXJmwJa/KTUQCEf55TwPyiT3cE8QzSJjxlWUpx//1yXv3FvZDUzHMg7/lANQ0+bhW ysj/jfaL623vryoVRYmwYkqRIDSI3YiZAxGDUgRKfT3WW3ZcIyW3r4YVzDHHOQ+2YkZc Txd6L8tOepBTGkcV3IFET7t2qFuTaikB823pNJLkI6dd5i+H1+VuQGbKrLtWW62aP35N mIkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LxF1L+qG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no2si7066426ejb.422.2020.11.09.06.38.26; Mon, 09 Nov 2020 06:39:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LxF1L+qG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730963AbgKIOgx (ORCPT + 99 others); Mon, 9 Nov 2020 09:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729976AbgKIOgx (ORCPT ); Mon, 9 Nov 2020 09:36:53 -0500 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E92F5C0613CF for ; Mon, 9 Nov 2020 06:36:52 -0800 (PST) Received: by mail-vs1-xe41.google.com with SMTP id f7so5056004vsh.10 for ; Mon, 09 Nov 2020 06:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xDniQAvxFLBjIKTPYpnf40KKSY2vMSiv1LR/tBJSqcA=; b=LxF1L+qGOIsxg05Lh0AzTGP5Iwb+FRJjDr/EMmjoNpyVVkoZAK0uPsRHh/wau4UHyD xh2hlTuIE0nsNZz9H+gMOuMzCX6gEHNOwVtmZZOo7wMGB8sPHTGPpaY1s0Y5TJ48nRWx lINJc8eu3GQFZBbrP/2MbKJgiFRoWYnrgOd0xb1B4no4COrC5vQiuj4bxlstYDKdMLkk Zp/0j7JV5Bg0FEsvyCQrkL/wM+Y7As52L6u9wKkSeIPdQ+oRw6cD/CNWA8ouiqSODa4a WilzHKCrQyEs4yPCINqM+NEE116rmHFQiJPxEd9pd4xyahqi+k8AnC+1He5l4QT/6tnJ I6YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xDniQAvxFLBjIKTPYpnf40KKSY2vMSiv1LR/tBJSqcA=; b=m6fh8rURQcxLfPwlkxmHAgMbKel7h5TFcns126wVIl4A9ZOjGLRQyqoMz9T8q5G049 +3AvHPxzmgYPVRDpWFtXAzWw0BYI7Z/ges9axV96+SJo9VJdX4F+kuDjZEn898QCRZnW GG/KwH6s57+oUtCu2zJlmqxzQWnf4ZcubG7clH0d+N11aUt83ZTNnmtfjztaEsdTMdlv LoX4lXf5Jl+KnadUuMOqEnuMQNrlgKvlr0GIqNwWEcI6Y1RAiTCjk8fvVvn5pMvEN8KM W6P6XkrQqJQ7VPk9kK2vI8/yZkd19kF6sJ254+SVqPfwi4PQa0YJMLhBVOTADjVrb+sn WWuQ== X-Gm-Message-State: AOAM531MiIAJYgXai3wzeYaAaOITPhMcOYkHRm5FGELR5UnILPgvuym9 VZGnnadXP4Ua46PVzo6m3zp7lOu8Kqk= X-Received: by 2002:a05:6102:309a:: with SMTP id l26mr7993654vsb.4.1604932611331; Mon, 09 Nov 2020 06:36:51 -0800 (PST) Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com. [209.85.222.45]) by smtp.gmail.com with ESMTPSA id k6sm1270883uaq.12.2020.11.09.06.36.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 06:36:50 -0800 (PST) Received: by mail-ua1-f45.google.com with SMTP id q68so2835211uaq.3 for ; Mon, 09 Nov 2020 06:36:50 -0800 (PST) X-Received: by 2002:a9f:2067:: with SMTP id 94mr6343749uam.141.1604932609475; Mon, 09 Nov 2020 06:36:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Willem de Bruijn Date: Mon, 9 Nov 2020 09:36:12 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net] net: udp: fix Fast/frag0 UDP GRO To: Alexander Lobakin Cc: "David S. Miller" , Jakub Kicinski , Alexey Kuznetsov , Hideaki YOSHIFUJI , Paolo Abeni , Network Development , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 7, 2020 at 8:11 PM Alexander Lobakin wrote: > > While testing UDP GSO fraglists forwarding through driver that uses > Fast GRO (via napi_gro_frags()), I was observing lots of out-of-order > iperf packets: > > [ ID] Interval Transfer Bitrate Jitter > [SUM] 0.0-40.0 sec 12106 datagrams received out-of-order > > Simple switch to napi_gro_receive() any other method without frag0 > shortcut completely resolved them. > > I've found that UDP GRO uses udp_hdr(skb) in its .gro_receive() > callback. While it's probably OK for non-frag0 paths (when all > headers or even the entire frame are already in skb->data), this > inline points to junk when using Fast GRO (napi_gro_frags() or > napi_gro_receive() with only Ethernet header in skb->data and all > the rest in shinfo->frags) and breaks GRO packet compilation and > the packet flow itself. > To support both modes, skb_gro_header_fast() + skb_gro_header_slow() > are typically used. UDP even has an inline helper that makes use of > them, udp_gro_udphdr(). Use that instead of troublemaking udp_hdr() > to get rid of the out-of-order delivers. > > Present since the introduction of plain UDP GRO in 5.0-rc1. > > Fixes: e20cf8d3f1f7 ("udp: implement GRO for plain UDP sockets.") > Signed-off-by: Alexander Lobakin > --- > net/ipv4/udp_offload.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c > index e67a66fbf27b..13740e9fe6ec 100644 > --- a/net/ipv4/udp_offload.c > +++ b/net/ipv4/udp_offload.c > @@ -366,7 +366,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, > static struct sk_buff *udp_gro_receive_segment(struct list_head *head, > struct sk_buff *skb) > { > - struct udphdr *uh = udp_hdr(skb); > + struct udphdr *uh = udp_gro_udphdr(skb); > struct sk_buff *pp = NULL; > struct udphdr *uh2; > struct sk_buff *p; Good catch. skb_gro_header_slow may fail and return NULL. Need to check that before dereferencing uh below in /* requires non zero csum, for symmetry with GSO */ if (!uh->check) { NAPI_GRO_CB(skb)->flush = 1; return NULL; }