Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3416525pxb; Mon, 9 Nov 2020 10:31:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuRtLzHJtJ41b2CAZd58VxMMHvfWJutYKGywaDW3UPucBd15IEGdf+f7QKRDmzA88cuJcs X-Received: by 2002:a17:906:3852:: with SMTP id w18mr15806786ejc.551.1604946693611; Mon, 09 Nov 2020 10:31:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604946693; cv=none; d=google.com; s=arc-20160816; b=rbbKjhf7FnOYWDHzZ7/QYdqD4n5J+ZOR4hlwnvUWbLTI/nVvcl81JIsK7/OfixPK/q OI6Y8llq/XPqIJl3WvaN3pMWJ6IsI/Y4Vl+xcepBk1WXUOAcJgFHKm05w6NthVTzXSVV sZd2ngz9vOPFalv/IpD0svAr7jA58acvzwZvMzhNYrqcAVmEL7ltbHExdRQFEFiJwomg 6XAJNyvdoNR6pk8VkQ2S5v0LpkzZT0P31KdVducJq2lClfOS4EwM7ZSeSrRrofPCIv8o TDUNQAVQonXXQoGl3UDpEtWslRy/X0H+ozjYNUqGeTWDtsl9z60IZGoZRvkR4krjqbok bWRA== 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=jLA7/mamq88rlEqhjwdpSzG3LkBhX2EWIU1whnjCGZU=; b=vSPE9Rsx1QLD6lboKr+vNnhVS18uZVIZjo28bNcOXx5qhzcIdOlDynYcs8scAglVUq oCINrKjyy1l/+jtsxoNoMvj2kL4vUL6eoTOp/qx4yKZrCQkStbQj0AXcGQMeJlODBU0+ 6T63WAQ1acW6MCUlATDOjpyEOJSDFq2R7FB06bcNxcoxH3JK6/aD1GMmtGg00cLOSppc n+YY22St8gIwGbHNrKeS54spArL598X1punM9ltBDcfPzaIThOx4fWFUe9a+Y2lNN3aU 91zUMPpOuaVus78+Kgyj0J4AgTTGZ2632GE7rG3nRB/kKrZP3SFQIt1unegncEVdZiYQ EsiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B7rwhjI0; 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 x14si4903873edj.87.2020.11.09.10.31.08; Mon, 09 Nov 2020 10:31:33 -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=B7rwhjI0; 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 S1729661AbgKIS3f (ORCPT + 99 others); Mon, 9 Nov 2020 13:29:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbgKIS3e (ORCPT ); Mon, 9 Nov 2020 13:29:34 -0500 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF4A0C0613CF for ; Mon, 9 Nov 2020 10:29:34 -0800 (PST) Received: by mail-vk1-xa44.google.com with SMTP id e8so1621108vkk.8 for ; Mon, 09 Nov 2020 10:29:34 -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=jLA7/mamq88rlEqhjwdpSzG3LkBhX2EWIU1whnjCGZU=; b=B7rwhjI0RLzwkFqQMa3OcYJxW6clmqovdwWLxiGbE2JhOl4pPKyEXj3+VowoG8xdwq J32UKP1mRlgB5VAGzAQc6X2Y/6CdTFx4SEGCr9tJvqirBKa8LWrfX92+Ji1DqaaYF4UW Spt5qjLccd502QWiuJqhnLJArWa20Dc2EMqkr8LyMcCeKGcTW2Z9pLsewCrWHmyabxej PinweqLPNYStuMZDfhoucH8qZuz/LOmmBKxQUBgJOre94Od6rXOxxWUGHqIYwGyTLn4m 8R+h0p00lY2VwtE7YLTDHAovtHCwpBFtFgNwXKhxC/LRocTnJKUY/EnISDdWCy/7Ot+L IT5A== 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=jLA7/mamq88rlEqhjwdpSzG3LkBhX2EWIU1whnjCGZU=; b=IFCIDtPutoxxQ1nGpQYjehUE4hPSggofXanIBHvY1tjjRc51Lz7FokcrZXtU6USctv 71AJGQ9tEvPo3TalCp+zd+//9ZbicfM//rW7eDZBgQcaYMTqMoolYW8p3/vF+7Lx99ld CjiFeBlFmVwCY0mD4JYWjmBlYAK7lkl9WVuI791P6yHQ35bQt4d3cunbFdHOSyjvvRp9 5fN6LbK2hcniVSCVPdEO4rGmbr6jZqswxIa5NyfVOOilox4uFWZvq76GjhJfpqR+6+d0 9yl51PQQ6atwJYYwVbIOGfgZHdZ8g5CY9nhcKBC5WAGXl/4yZf7VNmZZcz5sAhU7pbzd WdNQ== X-Gm-Message-State: AOAM531cQaqHpECMlxmHL/807n328GF4HP/M6YbZ6FwjxnQsFTeJw4nB qmcMLoSrwTQAHVm+0F5yLojrMJ63gqE= X-Received: by 2002:a05:6122:1286:: with SMTP id i6mr2437886vkp.11.1604946572927; Mon, 09 Nov 2020 10:29:32 -0800 (PST) Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com. [209.85.217.43]) by smtp.gmail.com with ESMTPSA id i19sm1220590uah.0.2020.11.09.10.29.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 10:29:31 -0800 (PST) Received: by mail-vs1-f43.google.com with SMTP id x11so5503819vsx.12 for ; Mon, 09 Nov 2020 10:29:31 -0800 (PST) X-Received: by 2002:a67:ce0e:: with SMTP id s14mr8950211vsl.13.1604946571245; Mon, 09 Nov 2020 10:29:31 -0800 (PST) MIME-Version: 1.0 References: <0eaG8xtbtKY1dEKCTKUBubGiC9QawGgB3tVZtNqVdY@cp4-web-030.plabs.ch> In-Reply-To: From: Willem de Bruijn Date: Mon, 9 Nov 2020 13:28:54 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 net] net: udp: fix Fast/frag0 UDP GRO To: Eric Dumazet Cc: Alexander Lobakin , "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 Mon, Nov 9, 2020 at 12:37 PM Eric Dumazet wrote: > > > > On 11/9/20 5:56 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. > > > > Since v1 [1]: > > - added a NULL pointer check for "uh" as suggested by Willem. > > > > [1] https://lore.kernel.org/netdev/YazU6GEzBdpyZMDMwJirxDX7B4sualpDG68ADZYvJI@cp4-web-034.plabs.ch > > > > Fixes: e20cf8d3f1f7 ("udp: implement GRO for plain UDP sockets.") > > Signed-off-by: Alexander Lobakin > > --- > > net/ipv4/udp_offload.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c > > index e67a66fbf27b..7f6bd221880a 100644 > > --- a/net/ipv4/udp_offload.c > > +++ b/net/ipv4/udp_offload.c > > @@ -366,13 +366,18 @@ 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; > > unsigned int ulen; > > int ret = 0; > > > > + if (unlikely(!uh)) { > > How uh could be NULL here ? > > My understanding is that udp_gro_receive() is called > only after udp4_gro_receive() or udp6_gro_receive() > validated that udp_gro_udphdr(skb) was not NULL. Oh indeed. This has already been checked before. > > + NAPI_GRO_CB(skb)->flush = 1; > > + return NULL; > > + } > > + > > /* requires non zero csum, for symmetry with GSO */ > > if (!uh->check) { > > NAPI_GRO_CB(skb)->flush = 1; > > > > Why uh2 is left unchanged ? > > uh2 = udp_hdr(p); Isn't that the same as th2 = tcp_hdr(p) in tcp_gro_receive? no frag0 optimization to worry about for packets on the list. > ... >