From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B69ACC388F7 for ; Mon, 9 Nov 2020 14:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70940206E3 for ; Mon, 9 Nov 2020 14:36:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LxF1L+qG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730918AbgKIOgw (ORCPT ); Mon, 9 Nov 2020 09:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729976AbgKIOgw (ORCPT ); Mon, 9 Nov 2020 09:36:52 -0500 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 303E1C0613CF for ; Mon, 9 Nov 2020 06:36:52 -0800 (PST) Received: by mail-ua1-x944.google.com with SMTP id k12so2842181uad.11 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=ohcWjFRGiuStY5mJ6KiBinYWhQKlx5lmLipI5/JQW2eMw5ksUwA8c0ZueSeZytkyjF f66KYvO9Pk4IhSjSgrYrj0He8WybEHPkc5MtN+Ik9Ci6xVDRZerFoYRptd5cO8y+dE9U mtJFR5lM0Z+ZgHRjmWBJfdyB057HF9xjkyhyDVqH2GBHAs0fWZd5AObQzCCiXS2N4sSW MHiLsXvGj4ITl2rdiF81pH4nLVGDJ7iyNa8XfBJQPW5Y3ZJi8JJ4pqyGA8jxErP8bFMF 14aou/SEZ53d0V3FXC+EYDcS7HR2BU6KZETaD9TjuVBpSUOsEolp+mVUSY5kSF1eQjGp BPhg== X-Gm-Message-State: AOAM530slr7tHcR/Q9iXF75NW89wXNqLNxgxZMEVkn1Y9jkH+wXUl+1W oIBaEUkrXmdP9JSBHOYDSGK3+s8cPuo= X-Google-Smtp-Source: ABdhPJwysSiZ8PHQvW+vXhFyaizrobol//EviDvplpjLDA25tyjtyTiNk9ttdcrQwu2g+aYa3yu/7Q== X-Received: by 2002:ab0:403:: with SMTP id 3mr3679739uav.4.1604932611109; Mon, 09 Nov 2020 06:36:51 -0800 (PST) Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com. [209.85.222.52]) by smtp.gmail.com with ESMTPSA id 59sm1058936uag.13.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-f52.google.com with SMTP id p12so2843374uam.1 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: netdev@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; }