Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2496237pxb; Mon, 18 Jan 2021 21:11:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvDUMHYHUAhZNz0UvinFgdDEjZGp6zDktFy8K2VQ0zE+zbRjd6M7JFeYGZ+dNObQH6LOhA X-Received: by 2002:a05:6402:31bb:: with SMTP id dj27mr1981297edb.285.1611033109480; Mon, 18 Jan 2021 21:11:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611033109; cv=none; d=google.com; s=arc-20160816; b=yNmBr/JhMYqNFQkSA1/lhZj8m0y9UKFhpQKoYVkA6xXY385YCdR52aLXIukWMcBMjP PQzjiQH5UXrLd/ILxxEMqeYPyshPy1k8UabAY7Hnxe4mBIjDhYm8SprOegV77rsT73Np YrQC/TmSAscaTgcd7TzD5kWOh61HH4JY7/xCqXoj1mYeYC2Ss16bv50ULj3db6CGy2Lh PXUrZ/3qiiSIqJhWOpLL4d0wtZ4qC1DQ8aGeFZyiejv9Vyf8HWb05eVb1GAbJFIKyZlK BUCcXzTTmQ7ncSkEERDKN5RX6iYN4vr8UDa0DbdiP4wMZ1+7xdew0L71ovtv3Z72CCAq AqwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=C8ABwwYHkwQARcAAcxQdRAoNdGpuSuZgs01wmbrorcQ=; b=iNW8f8TJryzBmc7SKPg6YSyzkV5CPrPbWPwsI2iNZ8cgDGBRq644bW3vy/GC+r/thM 30lKl50/XxXCrhBxHJVfvVk+mHNw6IF9X1cifUvb3gAnVh0NtbeeF+DKnO/Z3r4NcEa4 5DXL02JNW1k/6+8zw2JM7osCcGvcK7+8lsfN5ScWzfYeL4ir7sVf3bqOVq61JPnLUcGD cgVD924DKV7Sb95hvelSUVc6gNWC//XCjBLylkBfYfca56YOlpXSq5LjlQ8QfhLZwnjZ Cd8LNjfdnq6fftPk55S5oIEoolkeU+HhV49AknTsc6SjozuH/7s50hYLjViFajzS660q L6+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=Q9N36USt; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c23si8322620edv.521.2021.01.18.21.11.15; Mon, 18 Jan 2021 21:11:49 -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=@pm.me header.s=protonmail header.b=Q9N36USt; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394088AbhARTmM (ORCPT + 99 others); Mon, 18 Jan 2021 14:42:12 -0500 Received: from mail-40133.protonmail.ch ([185.70.40.133]:19702 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437401AbhARTei (ORCPT ); Mon, 18 Jan 2021 14:34:38 -0500 Date: Mon, 18 Jan 2021 19:33:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610998404; bh=C8ABwwYHkwQARcAAcxQdRAoNdGpuSuZgs01wmbrorcQ=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=Q9N36UStJD0wddnkzstxJ6fT0Gb4cEX/rwY+UVjVcYuz8vBG54JfxmJYWzEEbMy+E mhRwwHj7SZL65Orwdv7xcnTwk9RtwxQMexxDul5fTqxlftFGuwfbA5M+BqS/AKeskV XtyuBbi660cLFXukPjWsPmkZsQXoqAku7ut5IgfYXp8RWZ4OiCWEg8U+FloftNruto ruHlFQ/eiv7SxIjwG1+AJ8LgQxm2RsNIdmLQn20v/27IGzd14l1SAAh+reKITU3alJ k2Io/awU6ndYfbBRPMBLLZB6Rpr2pyvC0c7/IgWFmV0t9F4nkguIe6kUBGwoCV9yzX Md3D77KPBtsoA== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Hideaki YOSHIFUJI , Willem de Bruijn , Steffen Klassert , Alexander Duyck , Paolo Abeni , Alexander Lobakin , Igor Russkikh , Mauro Carvalho Chehab , Miaohe Lin , Antoine Tenart , Michal Kubecek , Andrew Lunn , Meir Lichtinger , Aya Levin , Florian Fainelli , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH net-next 2/2] udp: allow forwarding of plain (non-fraglisted) UDP GRO packets Message-ID: <20210118193232.87583-2-alobakin@pm.me> In-Reply-To: <20210118193232.87583-1-alobakin@pm.me> References: <20210118193122.87271-1-alobakin@pm.me> <20210118193232.87583-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.") actually not only added a support for fraglisted UDP GRO, but also tweaked some logics the way that non-fraglisted UDP GRO started to work for forwarding too. Commit 2e4ef10f5850 ("net: add GSO UDP L4 and GSO fraglists to the list of software-backed types") added GSO UDP L4 to the list of software GSO to allow virtual netdevs to forward them as is up to the real drivers. Tests showed that currently forwarding and NATing of plain UDP GRO packets are performed fully correctly, regardless if the target netdevice has a support for hardware/driver GSO UDP L4 or not. Plain UDP GRO forwarding even shows better performance than fraglisted UDP GRO in some cases due to not wasting one skbuff_head per every segment. Add the last element and allow to form plain UDP GRO packets if there is no socket -> we are on forwarding path, and the new NETIF_F_GRO_UDP is enabled on a receiving netdevice. Note that fraglisted UDP GRO now also depends on this feature, as NETIF_F_GRO_FRAGLIST isn't tied to any particular L4 protocol. Signed-off-by: Alexander Lobakin --- net/ipv4/udp_offload.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index ff39e94781bf..781a035de5a9 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -454,13 +454,19 @@ struct sk_buff *udp_gro_receive(struct list_head *hea= d, struct sk_buff *skb, =09struct sk_buff *p; =09struct udphdr *uh2; =09unsigned int off =3D skb_gro_offset(skb); -=09int flush =3D 1; +=09int flist =3D 0, flush =3D 1; +=09bool gro_by_feat =3D false; =20 -=09NAPI_GRO_CB(skb)->is_flist =3D 0; -=09if (skb->dev->features & NETIF_F_GRO_FRAGLIST) -=09=09NAPI_GRO_CB(skb)->is_flist =3D sk ? !udp_sk(sk)->gro_enabled: 1; +=09if (skb->dev->features & NETIF_F_GRO_UDP) { +=09=09if (skb->dev->features & NETIF_F_GRO_FRAGLIST) +=09=09=09flist =3D !sk || !udp_sk(sk)->gro_enabled; =20 -=09if ((sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) { +=09=09gro_by_feat =3D !sk || flist; +=09} + +=09NAPI_GRO_CB(skb)->is_flist =3D flist; + +=09if (gro_by_feat || (sk && udp_sk(sk)->gro_enabled)) { =09=09pp =3D call_gro_receive(udp_gro_receive_segment, head, skb); =09=09return pp; =09} --=20 2.30.0