From patchwork Mon Jan 18 19:32:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12028037 X-Patchwork-Delegate: kuba@kernel.org 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 5D92CC433DB for ; Mon, 18 Jan 2021 19:42:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AEEF22CA1 for ; Mon, 18 Jan 2021 19:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394123AbhARTmm (ORCPT ); Mon, 18 Jan 2021 14:42:42 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:49746 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437340AbhARTdr (ORCPT ); Mon, 18 Jan 2021 14:33:47 -0500 Date: Mon, 18 Jan 2021 19:32:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610998379; bh=z2BgOHJQihEnZJluF+2PjwdFI80xZFFK5NdPVZjc2KU=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=RtXGISrjXU7lTSaAaDTkKXl/3TbgsmZk3CMUU+Y/Lv4b/vdC9DIOMcC9GiK0tMUVR pclzQoZkmqRAczGjRuTKEgbg+L8HMcSBxS41Uyb3qbDsSVlc29Xk7pzunDBx0IbjW/ Uun5Ri1kLZrGZOpHWwnnQcvlWhuEcAloXEgWWNvrB3YSLUIwiDwzCFXPjUPsD0Lxjs rtcZo1z+m+nIqfk5925u7dVy/1I1GYmWEgsCy2IBThOg7WlV5J4UF+3RwNsAUCUEQ6 mmdjqD3D8B+JQgvdZl3vPSvVY4Vb+VLPDsqcaPhCRHDJgpu/wW1GXg7MR7/gf/LCNO d5FYEWbBU8/Cg== 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 1/2] net: introduce UDP GRO netdev feature Message-ID: <20210118193232.87583-1-alobakin@pm.me> In-Reply-To: <20210118193122.87271-1-alobakin@pm.me> References: <20210118193122.87271-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Introduce a new netdev_feature, NETIF_F_GRO_UDP, to allow user to turn UDP GRO on and off when there is no socket, e.g. when forwarding. Defaults to off to not change current datapath. Suggested-by: Paolo Abeni Signed-off-by: Alexander Lobakin --- include/linux/netdev_features.h | 4 +++- net/ethtool/common.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index 934de56644e7..c6526aa13684 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -84,6 +84,7 @@ enum { NETIF_F_GRO_FRAGLIST_BIT, /* Fraglist GRO */ NETIF_F_HW_MACSEC_BIT, /* Offload MACsec operations */ + NETIF_F_GRO_UDP_BIT, /* Enable UDP GRO */ /* * Add your fresh new feature above and remember to update @@ -157,6 +158,7 @@ enum { #define NETIF_F_GRO_FRAGLIST __NETIF_F(GRO_FRAGLIST) #define NETIF_F_GSO_FRAGLIST __NETIF_F(GSO_FRAGLIST) #define NETIF_F_HW_MACSEC __NETIF_F(HW_MACSEC) +#define NETIF_F_GRO_UDP __NETIF_F(GRO_UDP) /* Finds the next feature with the highest number of the range of start till 0. */ @@ -234,7 +236,7 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start) #define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO) /* Changeable features with no special hardware requirements that defaults to off. */ -#define NETIF_F_SOFT_FEATURES_OFF NETIF_F_GRO_FRAGLIST +#define NETIF_F_SOFT_FEATURES_OFF (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP) #define NETIF_F_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_FILTER | \ NETIF_F_HW_VLAN_CTAG_RX | \ diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 24036e3055a1..e45128882372 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -68,6 +68,7 @@ const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = { [NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload", [NETIF_F_GRO_FRAGLIST_BIT] = "rx-gro-list", [NETIF_F_HW_MACSEC_BIT] = "macsec-hw-offload", + [NETIF_F_GRO_UDP_BIT] = "rx-gro-udp", }; const char From patchwork Mon Jan 18 19:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12028039 X-Patchwork-Delegate: kuba@kernel.org 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 CDDA8C433E0 for ; Mon, 18 Jan 2021 19:43:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 954E322C9D for ; Mon, 18 Jan 2021 19:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394118AbhARTm0 (ORCPT ); Mon, 18 Jan 2021 14:42:26 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:29460 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437399AbhARTeY (ORCPT ); Mon, 18 Jan 2021 14:34:24 -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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 *head, struct sk_buff *skb, struct sk_buff *p; struct udphdr *uh2; unsigned int off = skb_gro_offset(skb); - int flush = 1; + int flist = 0, flush = 1; + bool gro_by_feat = false; - NAPI_GRO_CB(skb)->is_flist = 0; - if (skb->dev->features & NETIF_F_GRO_FRAGLIST) - NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1; + if (skb->dev->features & NETIF_F_GRO_UDP) { + if (skb->dev->features & NETIF_F_GRO_FRAGLIST) + flist = !sk || !udp_sk(sk)->gro_enabled; - if ((sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) { + gro_by_feat = !sk || flist; + } + + NAPI_GRO_CB(skb)->is_flist = flist; + + if (gro_by_feat || (sk && udp_sk(sk)->gro_enabled)) { pp = call_gro_receive(udp_gro_receive_segment, head, skb); return pp; }