From patchwork Fri Jan 15 05:58:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongseok Yi X-Patchwork-Id: 12021569 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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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,USER_AGENT_GIT 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 4A022C433E6 for ; Fri, 15 Jan 2021 06:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B87F23A05 for ; Fri, 15 Jan 2021 06:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbhAOGLa (ORCPT ); Fri, 15 Jan 2021 01:11:30 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:45894 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbhAOGL2 (ORCPT ); Fri, 15 Jan 2021 01:11:28 -0500 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210115061043epoutp014ae7905157d71a80ec063c8014a793f1~aUvhePThx2556025560epoutp01X for ; Fri, 15 Jan 2021 06:10:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210115061043epoutp014ae7905157d71a80ec063c8014a793f1~aUvhePThx2556025560epoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1610691043; bh=/ClZBDspCYZj+U5ATmBXmCgRr4LZt11VuernE0g7V68=; h=From:To:Cc:Subject:Date:References:From; b=EyiBgKkdOCPQGCAjJThu4qrAnUq3rGXYeG39VXnwMaNnFnB0qlJwZB1TBhEDFrTWz BzXFD+4LizRbkYuiaUbaLYiWzEEhkFQIgBG2Ezc3MQz6y6guYlaA3l0YC8+vFqDyj8 xfUNUYRypxMBzZUgqnBl9BAxHIfHzTceC2Xd7/wg= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20210115061042epcas2p20b960fe46f842c0865ae9e21d1b6bb07~aUvg29chO2011920119epcas2p2t; Fri, 15 Jan 2021 06:10:42 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.187]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4DH9lh3n3Dz4x9QM; Fri, 15 Jan 2021 06:10:40 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id C1.1A.52511.0E131006; Fri, 15 Jan 2021 15:10:40 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20210115061039epcas2p479bc5f3dd3dad5a250c4e0fc42896704~aUveGCn4X2762527625epcas2p4p; Fri, 15 Jan 2021 06:10:39 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210115061039epsmtrp18a68105e92a576c0b2a89ac7dce5389d~aUveFQdVA2704227042epsmtrp1L; Fri, 15 Jan 2021 06:10:39 +0000 (GMT) X-AuditID: b6c32a48-4f9ff7000000cd1f-56-600131e028f8 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4E.99.08745.FD131006; Fri, 15 Jan 2021 15:10:39 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210115061039epsmtip1370aaaa876c4e7f4df790d32f9dbc9d4~aUvd2JheV3029930299epsmtip1e; Fri, 15 Jan 2021 06:10:39 +0000 (GMT) From: Dongseok Yi To: "David S. Miller" , Steffen Klassert Cc: namkyu78.kim@samsung.com, Alexander Lobakin , Dongseok Yi , Hideaki YOSHIFUJI , Jakub Kicinski , Willem de Bruijn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] udp: ipv4: manipulate network header of NATed UDP GRO fraglist Date: Fri, 15 Jan 2021 14:58:24 +0900 Message-Id: <1610690304-167832-1-git-send-email-dseok.yi@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOKsWRmVeSWpSXmKPExsWy7bCmhe4DQ8YEg+2PBSxWPd7OYjHnfAuL xZVpfxgtLmzrY7W4vGsOm0XDnWY2i2MLxCx2d/5gt3i35Qi7xde9XSwOXB5bVt5k8liwqdRj 06pONo+2a6uYPI7uOcfm0bdlFaPHptYlrB6fN8kFcETl2GSkJqakFimk5iXnp2TmpdsqeQfH O8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYAnaikUJaYUwoUCkgsLlbSt7Mpyi8tSVXIyC8u sVVKLUjJKTA0LNArTswtLs1L10vOz7UyNDAwMgWqTMjJWPY4sOCPaMX3DzPZGxjPCXYxcnJI CJhIbPzUxtTFyMUhJLCDUeLavf0sEM4nRokdbdsYQaqEBD4zSjx+XwHT0f1lFVTRLkaJhq1X oJwfjBJv131nBaliE9CQ2P/uBZgtIhAn0XG0gxGkiFlgGpPE6untYGOFBUIlrjzqYQexWQRU Jabf+MYGYvMKuEqsevSWDWKdnMTNc53MEPY1dokjJ4C2cQDZLhK7FvlA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gieevbrOB2CwCqhLT b3wDs3kFXCVWPXrLBrFATuLmuU7mCYw8CxgZVjFKphYU56bnFhsWGOWllusVJ+YWl+al6yXn 525iBIeeltYOxj2rPugdYmTiYDzEKMHBrCTCm6/MkCDEm5JYWZValB9fVJqTWnyIUZqDRUmc 90LXyXghgfTEktTs1NSC1CKYLBMHp1QDE2vtG60NshyCvqt6q8LO+uje1PTXsuNtXbZ7orvU XuXijxWqvxmt9h27sfjVpedZqZ+SZh5rTptrby14nf9SLfPqRWYv47/Gr7RcH3ZEPEjyQbXu WtXSxEsplldUWzd97okPdvnWf+pg9ISnKY7hWln1JnddH164elSoUeehz6QT5sc/Tfty647b lk/dHH2N3SvEk77rxz59ob5ug2BMkHTnpDhRy8dybUY1ugFPX/Tfuh9/6N4E+yPGXx47Vc1j OHb+UhiDYP/azht7gpM2315dnBxsYfLd30z/ffsJ671tf7TUDloEz9OU5D+f9InnzuGaFemb tZ03WvS2b2aeJTB1NbuyPIe5feNW6TdBSizFGYmGWsxFxYkAJuVp/awCAAA= X-CMS-MailID: 20210115061039epcas2p479bc5f3dd3dad5a250c4e0fc42896704 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210115061039epcas2p479bc5f3dd3dad5a250c4e0fc42896704 References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org UDP/IP header of UDP GROed frag_skbs are not updated even after NAT forwarding. Only the header of head_skb from ip_finish_output_gso -> skb_gso_segment is updated but following frag_skbs are not updated. A call path skb_mac_gso_segment -> inet_gso_segment -> udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list does not try to update UDP/IP header of the segment list. Update dport, daddr and checksums of each skb of the segment list after __udp_gso_segment. Fixes: 9fd1ff5d2ac7 (udp: Support UDP fraglist GRO/GSO.) Signed-off-by: Dongseok Yi --- Steffen Klassert said, there could be 2 options. https://lore.kernel.org/patchwork/patch/1362257/ I was trying to write a quick fix, but it was not easy to forward segmented list. Currently, assuming DNAT only. Should we consider SNAT too? net/ipv4/udp_offload.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index ff39e94..7e24928 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -309,10 +309,12 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, netdev_features_t features) { struct sk_buff *segs = ERR_PTR(-EINVAL); + struct sk_buff *seg; unsigned int mss; __wsum csum; - struct udphdr *uh; - struct iphdr *iph; + struct udphdr *uh, *uh2; + struct iphdr *iph, *iph2; + bool is_fraglist = false; if (skb->encapsulation && (skb_shinfo(skb)->gso_type & @@ -327,8 +329,43 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, if (!pskb_may_pull(skb, sizeof(struct udphdr))) goto out; - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) - return __udp_gso_segment(skb, features); + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { + if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST) + is_fraglist = true; + + segs = __udp_gso_segment(skb, features); + if (IS_ERR_OR_NULL(segs) || !is_fraglist) + return segs; + + seg = segs; + uh = udp_hdr(seg); + iph = ip_hdr(seg); + + while ((seg = seg->next)) { + uh2 = udp_hdr(seg); + iph2 = ip_hdr(seg); + + if (uh->dest == uh2->dest && iph->daddr == iph2->daddr) + continue; + + if (uh2->check) { + inet_proto_csum_replace4(&uh2->check, seg, + iph2->daddr, + iph->daddr, true); + inet_proto_csum_replace2(&uh2->check, seg, + uh2->dest, uh->dest, + false); + if (!uh2->check) + uh2->check = CSUM_MANGLED_0; + } + uh2->dest = uh->dest; + + csum_replace4(&iph2->check, iph2->daddr, iph->daddr); + iph2->daddr = iph->daddr; + } + + return segs; + } mss = skb_shinfo(skb)->gso_size; if (unlikely(skb->len <= mss))