Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3715494pxb; Tue, 26 Jan 2021 02:55:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJw06BLvyENYe+pSp+dMgeC1JeiJpUl2X2K5r9AD1X6sapM4qzMWZc6Ai8a4NtIFrhSHCAS7 X-Received: by 2002:a17:906:c09:: with SMTP id s9mr3044488ejf.539.1611658548913; Tue, 26 Jan 2021 02:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611658548; cv=none; d=google.com; s=arc-20160816; b=gidiUNoD6Oy4X/sP8VVJHfODuBFMF8X9uNVlxK5HfeQOUZS60b50D73KgL+phmTx4D AeR56IVE5ZeOMDHcME2xr6quNFPxVUsNvr9Cu9ZS21rkKEXFCKkhPCrYvbNqEJY/XO30 lhKNpc2hWbGDXBPCjuzlKGJTNl+ZhqnJtD0A1LYnQOubCORIDwh1SKJI/FVvz2Wv9+5k 9lZKvODGUKJe8LVN5tpsFMVsZcIgin3JGHj0YvPg5foF2qEAcAgEBO+5cX4LSrauygdR c9Sqo+kKlqfoxhUcLp0L8snVeiUkxEAHV6RvRRhnf3k+tyhYTNbo5G5uAizb2fWFfz8A nISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=OGsj0MIkfZyHE5NB7L5PUMSmlStzrlK4MtVhzEASbSs=; b=jqRxuhQ19GqiaOrXNQCoQNx6+pnkzfbDgP70c+xluEA3EehMsNIfo9C3z018uJfCsW BFxMCKLBf4ChTbSnjZQ2xG/eCm6hqbfzCMmowMzzQUTHEw5gcsOMw5+7XXOO9HJiHfKV GGX/wvZcbl3j66y6svt64WODyU+kVgVXTmia4dGs3iE56RsiB6tJqGnxb3QWQ4Ambsbh gLrHRk3qBVW12s+exzg/EqJsI7n6Xsi/eFv2hckj/1/NPeF8ju+G9Z0xXwR8lbVV6lV9 Wi/LOY66sPnXBXIQupK0PFqlI+jvI9WZewyfxnY1/oXJcsolFBOoZtlUDIHt5ncY3QY5 HH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=B0p6OWhG; 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=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si8297797edw.448.2021.01.26.02.55.24; Tue, 26 Jan 2021 02:55:48 -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=@samsung.com header.s=mail20170921 header.b=B0p6OWhG; 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=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404570AbhAZKyX (ORCPT + 99 others); Tue, 26 Jan 2021 05:54:23 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:36351 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728310AbhAZDJC (ORCPT ); Mon, 25 Jan 2021 22:09:02 -0500 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210126003135epoutp0248988f7f26b8fed3a6553639225ebf80~doNkEiG9i2925729257epoutp02C for ; Tue, 26 Jan 2021 00:31:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210126003135epoutp0248988f7f26b8fed3a6553639225ebf80~doNkEiG9i2925729257epoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1611621095; bh=OGsj0MIkfZyHE5NB7L5PUMSmlStzrlK4MtVhzEASbSs=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=B0p6OWhGMQlNRmkHj4YUQp7gfboquYB4cc++ftdLQtcD5b9Uj6vhLR50ZbbFMY+jh 9Xr9AO/qBH6EyZyKwtN4/2lgu7sxXdQDziDzoak7anqPeZkvlC6kJ8lS/eJa1jl/g6 ZW2qMC5UjhHfPBlCkQEMIXj92fbOoLZEyCV0qDMk= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20210126003135epcas2p4647eac927b8dd478b8e804f3100b1736~doNjpjh1b2228122281epcas2p4u; Tue, 26 Jan 2021 00:31:35 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.40.187]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4DPnjK1vzbz4x9Pp; Tue, 26 Jan 2021 00:31:33 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 98.1E.05262.2E26F006; Tue, 26 Jan 2021 09:31:30 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20210126003130epcas2p4edac02397592781f3f06fd0c58421c44~doNfXQtOm2472924729epcas2p4y; Tue, 26 Jan 2021 00:31:30 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210126003130epsmtrp26f9d9f62bdd05e83caca4106c42dedb3~doNfWbMQl0296902969epsmtrp2G; Tue, 26 Jan 2021 00:31:30 +0000 (GMT) X-AuditID: b6c32a47-b81ff7000000148e-e1-600f62e2bcb5 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 00.78.13470.2E26F006; Tue, 26 Jan 2021 09:31:30 +0900 (KST) Received: from KORDO035731 (unknown [12.36.185.47]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210126003130epsmtip2e461871cde2e8e6352adef2e2667bb26~doNfH35tU2637426374epsmtip21; Tue, 26 Jan 2021 00:31:30 +0000 (GMT) From: "Dongseok Yi" To: "'Steffen Klassert'" Cc: "'David S. Miller'" , "'Alexander Lobakin'" , , "'Jakub Kicinski'" , "'Hideaki YOSHIFUJI'" , "'Willem de Bruijn'" , , In-Reply-To: <20210125124544.GW3576117@gauss3.secunet.de> Subject: RE: [PATCH net v3] udp: ipv4: manipulate network header of NATed UDP GRO fraglist Date: Tue, 26 Jan 2021 09:31:29 +0900 Message-ID: <026001d6f37a$97461300$c5d23900$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQD8+b0cWZtPvmUMIOPw0keCYjUzAAJKUisyAbm6YsWrzN/I0A== Content-Language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHJsWRmVeSWpSXmKPExsWy7bCmqe6jJP4Eg70rzC1WPd7OYjHnfAuL xYVtfawWl3fNYbNouNPMZnFsgZjF7s4f7Bbvthxht/i6t4vFgdNjy8qbTB4LNpV6bFrVyebR dm0Vk8fRPefYPPq2rGL02NS6hNXj8ya5AI6oHJuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMD Q11DSwtzJYW8xNxUWyUXnwBdt8wcoOuUFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnFJbZKqQUp OQWGhgV6xYm5xaV56XrJ+blWhgYGRqZAlQk5GW9nnGMvuGtSsb3zGnMD42bNLkZODgkBE4mV RzqZuhi5OIQEdjBKXPzcwQ7hfGKU+LPtMzOE841R4vmDBWxdjBxgLRcPFEPE9zJ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4oLpuU1JzMstQifbsEroy3M86xF9w1qdjeeY25 gXGzZhcjB4eEgInExQPFXYxcHEICuxklHh/exwYRl5DYtdm1i5ETyBSWuN9yhBWi5hmjxJv7 k1hAEmwCWhJvZrWzgtgiAuYSq19NYwIpYhbYzSTxtec+M0THYUaJO/M+sIJM5RSwlPh4oASk QVggSuLy1K2MIDaLgKrE9U3dzCA2L1DJsonL2CFsQYmTM5+ALWMWMJI4d2g/G4QtL7H97Rxm iOsUJH4+XQZ1hJNE3/1eJogaEYnZnW3MExiFZyEZNQvJqFlIRs1C0rKAkWUVo2RqQXFuem6x YYFhXmq5XnFibnFpXrpecn7uJkZw7Glp7mDcvuqD3iFGJg7GQ4wSHMxKIry79XgShHhTEiur Uovy44tKc1KLDzFKc7AoifNe6DoZLySQnliSmp2aWpBaBJNl4uCUamAKyJ3hd/e1zq2FV7tf 35rBUb7k9obexOK/J7dk362q+9odId3zLW22Dtf6XjZeQ9cO5TTGpljdnC7uWwumxwXM2rnt 40Sh6x3JV+4bhZktz76vy/rrTdMTvu5Ny7Q0a29EBoov/DzV99KhiDTBn09PXZhXLvd6kc3F TT+3K6SnKc1o/MnQr5U0/9vZlYve2q6NObD6pb3Ahw/3fit16U1ytEsVShUqnM/NlzL/fNqZ 5jXPZy6KeV7w2lr15Kdgx/0vOeS7C9TepV44cFpjtopLaO9qX5dJWyv9VSYUs56SvLnnTc+H RyWe7dduL98Wxmm7Lsj1n1et9NxXRgLHohu0TMuNHntmXPrzYEP59f+9SizFGYmGWsxFxYkA H/WuMiwDAAA= X-CMS-MailID: 20210126003130epcas2p4edac02397592781f3f06fd0c58421c44 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210121133649epcas2p493d5d59df1b48ee8e3282ab766f37a70 References: <1611235479-39399-1-git-send-email-dseok.yi@samsung.com> <20210125124544.GW3576117@gauss3.secunet.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/25/21 9:45 PM, Steffen Klassert wrote: > On Thu, Jan 21, 2021 at 10:24:39PM +0900, Dongseok Yi wrote: > > 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 but copy > > only the MAC header. > > > > Update port, addr and check of each skb of the segment list in > > __udp_gso_segment_list. It covers both SNAT and DNAT. > > > > Fixes: 9fd1ff5d2ac7 (udp: Support UDP fraglist GRO/GSO.) > > Signed-off-by: Dongseok Yi > > --- > > v1: > > 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. > > > > v2: > > Per Steffen Klassert request, moved the procedure from > > udp4_ufo_fragment to __udp_gso_segment_list and support SNAT. > > > > v3: > > Per Steffen Klassert request, applied fast return by comparing seg > > and seg->next at the beginning of __udpv4_gso_segment_list_csum. > > > > Fixed uh->dest = *newport and iph->daddr = *newip to > > *oldport = *newport and *oldip = *newip. > > > > include/net/udp.h | 2 +- > > net/ipv4/udp_offload.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++---- > > net/ipv6/udp_offload.c | 2 +- > > 3 files changed, 69 insertions(+), 7 deletions(-) > > > > diff --git a/include/net/udp.h b/include/net/udp.h > > index 877832b..01351ba 100644 > > --- a/include/net/udp.h > > +++ b/include/net/udp.h > > @@ -178,7 +178,7 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, > > int udp_gro_complete(struct sk_buff *skb, int nhoff, udp_lookup_t lookup); > > > > struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, > > - netdev_features_t features); > > + netdev_features_t features, bool is_ipv6); > > > > static inline struct udphdr *udp_gro_udphdr(struct sk_buff *skb) > > { > > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c > > index ff39e94..43660cf 100644 > > --- a/net/ipv4/udp_offload.c > > +++ b/net/ipv4/udp_offload.c > > @@ -187,8 +187,67 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, > > } > > EXPORT_SYMBOL(skb_udp_tunnel_segment); > > > > +static void __udpv4_gso_segment_csum(struct sk_buff *seg, > > + __be32 *oldip, __be32 *newip, > > + __be16 *oldport, __be16 *newport) > > +{ > > + struct udphdr *uh; > > + struct iphdr *iph; > > + > > + if (*oldip == *newip && *oldport == *newport) > > + return; > > This check is redundant as you check this already in > __udpv4_gso_segment_list_csum. When comes in __udpv4_gso_segment_csum, the condition would be SNAT or DNAT. I think we don't need to do the function if the condition is not met. I want to skip the function for SNAT checksum when DNAT only case. Is it better to remove the check? > > Looks ok otherwise. > > > + > > + uh = udp_hdr(seg); > > + iph = ip_hdr(seg); > > + > > + if (uh->check) { > > + inet_proto_csum_replace4(&uh->check, seg, *oldip, *newip, > > + true); > > + inet_proto_csum_replace2(&uh->check, seg, *oldport, *newport, > > + false); > > + if (!uh->check) > > + uh->check = CSUM_MANGLED_0; > > + } > > + *oldport = *newport; > > + > > + csum_replace4(&iph->check, *oldip, *newip); > > + *oldip = *newip; > > +} > > + > > +static struct sk_buff *__udpv4_gso_segment_list_csum(struct sk_buff *segs) > > +{ > > + struct sk_buff *seg; > > + struct udphdr *uh, *uh2; > > + struct iphdr *iph, *iph2; > > + > > + seg = segs; > > + uh = udp_hdr(seg); > > + iph = ip_hdr(seg); > > + > > + if ((udp_hdr(seg)->dest == udp_hdr(seg->next)->dest) && > > + (udp_hdr(seg)->source == udp_hdr(seg->next)->source) && > > + (ip_hdr(seg)->daddr == ip_hdr(seg->next)->daddr) && > > + (ip_hdr(seg)->saddr == ip_hdr(seg->next)->saddr)) > > + return segs; > > + > > + while ((seg = seg->next)) { > > + uh2 = udp_hdr(seg); > > + iph2 = ip_hdr(seg); > > + > > + __udpv4_gso_segment_csum(seg, > > + &iph2->saddr, &iph->saddr, > > + &uh2->source, &uh->source); > > + __udpv4_gso_segment_csum(seg, > > + &iph2->daddr, &iph->daddr, > > + &uh2->dest, &uh->dest); > > + } > > + > > + return segs; > > +} > > + > > static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb, > > - netdev_features_t features) > > + netdev_features_t features, > > + bool is_ipv6) > > { > > unsigned int mss = skb_shinfo(skb)->gso_size; > > > > @@ -198,11 +257,14 @@ static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb, > > > > udp_hdr(skb)->len = htons(sizeof(struct udphdr) + mss); > > > > - return skb; > > + if (is_ipv6) > > + return skb; > > + else > > + return __udpv4_gso_segment_list_csum(skb); > > } > > > > struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, > > - netdev_features_t features) > > + netdev_features_t features, bool is_ipv6) > > { > > struct sock *sk = gso_skb->sk; > > unsigned int sum_truesize = 0; > > @@ -214,7 +276,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, > > __be16 newlen; > > > > if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) > > - return __udp_gso_segment_list(gso_skb, features); > > + return __udp_gso_segment_list(gso_skb, features, is_ipv6); > > > > mss = skb_shinfo(gso_skb)->gso_size; > > if (gso_skb->len <= sizeof(*uh) + mss) > > @@ -328,7 +390,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, > > goto out; > > > > if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) > > - return __udp_gso_segment(skb, features); > > + return __udp_gso_segment(skb, features, false); > > > > mss = skb_shinfo(skb)->gso_size; > > if (unlikely(skb->len <= mss)) > > diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c > > index c7bd7b1..faa823c 100644 > > --- a/net/ipv6/udp_offload.c > > +++ b/net/ipv6/udp_offload.c > > @@ -42,7 +42,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, > > goto out; > > > > if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) > > - return __udp_gso_segment(skb, features); > > + return __udp_gso_segment(skb, features, true); > > > > mss = skb_shinfo(skb)->gso_size; > > if (unlikely(skb->len <= mss)) > > -- > > 2.7.4