Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1934320lqa; Tue, 30 Apr 2024 03:58:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8MfnsZb9QbRR4fheL0zs4C5+q16npjLAcDd+vu5xL8NB24Y4P/t8/jSOIEMDJHk8DvCWm8lke4f/gPK4ezXMMv7ieYnYn6uHn24v6Pg== X-Google-Smtp-Source: AGHT+IH3Xw2mrXQLyA1KB9R/sO1eZWX7+amAiWBphDzbl2vU+k09eFZbh199dhPdSXYsUivTErmY X-Received: by 2002:a05:6870:d620:b0:23c:737f:5add with SMTP id a32-20020a056870d62000b0023c737f5addmr7941910oaq.13.1714474709528; Tue, 30 Apr 2024 03:58:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714474709; cv=pass; d=google.com; s=arc-20160816; b=sMkW0SeECg4einRJZD3/1Ur7p0zahVtdCEmh1Sz/gcOGPKZDXrc+4CcPbamhQux0Pu uYXth0qDXmxPxcjBW/vBXpIoKTDx4EWsxzJD0ra+xzmdMlclIqzeZTwJfZRNdIb2a5o7 IGBE0JuNIhIe/yAY9fmo9xyq1d9HeeGtOeZBLkravobAPZj4Wp7EyRhHdfOfdLD0QaGH Q1ryk96/5z67iogAns+1kRmPvj5RFcoLTYeY68fovNtJpGAKIl6EQRAnYymYmc9d/Qg5 euw8LHY2ra+qqCl/Jmi3Oya7LtoN3tO4srm9YMLnx/mkKydBzcSdvRCtuRRil92ZkzqX /oeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=4kgLqNqofDnZoG0xDYgtgTmPksD/HbavYHwR7M/aJI0=; fh=Gbu5VKP9pHFMOtrTTUAHv33gxh+S+imJmBKvbHJcbrU=; b=NSgVu8dCK+FIj62ERrCwZLPIttFQafzSz47psHqySubaSXtqxQ6S3sZZEENr+BEUyH 1a49hctF/wgKDeZPx00BAXHhknegUzj4imH789JO/FoUgtkAX1fPXp7Xbp37pfih0N/A Iyr9+vjAUpVYFiVxHttTUlPRfiEfZ0jyH0cPU8Dy/gkehUPYciiYtSYXJQzAGE9Nd6uV hMtOp9xKr8HRitlQm5X93LzurSfFvgUFL9SarkCZQFMMvcCf8/vriL4k2xmhXZXGVsbH ZkNscO2aiJ6ihu7IkQ+jPr07OuRIzMLZpmLBKPvg3jxuGp/iasEBh8N9SVNOI3x6y2Jm Bh7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="DGK9wm/C"; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-kernel+bounces-163811-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w1-20020a056a0014c100b006ed6b1140a3si21882249pfu.397.2024.04.30.03.58.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 03:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163811-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="DGK9wm/C"; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-kernel+bounces-163811-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 532522819A1 for ; Tue, 30 Apr 2024 10:57:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA61A12CD96; Tue, 30 Apr 2024 10:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="DGK9wm/C" Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1987D12C499; Tue, 30 Apr 2024 10:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474661; cv=none; b=tKF/KS671hcf36En0PDQt8KdNEwYnCnD4qLpmUpLdNac0W3bgPo3Dko9K30IsUHmqmCAluEKfCQ2vOiK9tXFjjaaBasIhYifprkBqGdGDhWCXOfVQG2HLsmf7qocxmo1jpHgFXsoZ29t+2pwOVkUz4KH0IWzBlmc2BzguUlpbzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474661; c=relaxed/simple; bh=z942sWrGBaul22LgSp6Y+y8wYhymamwrRpiwOhxsErU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kbXzGvqVErK9S0WyoJg4pqwvo9feJxSIMoCyCOG4NktoA8g513d2vEKZ04e2aceag5OjjHoe05u6gDqzRtO489a1//nfD3eZlRrFIZS+pUDdYn/Din7GWvAGRTBl1Ic4pxCZdy+kWSYqVTU7DdPbUKiWuYaU7S/DYVVXBX42+oE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=DGK9wm/C; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4kgLqNqofDnZoG0xDYgtgTmPksD/HbavYHwR7M/aJI0=; b=DGK9wm/CM/ZsRMtyG7jIObuEaj EzxDVoeQPvTFHGMdtD+zsmsMif8O+R99ekCM4ZBo5nvqfkmKcC7VM7Uj7vnrnRWvZ3HlzLDvphCvy fvbFbnH2jvso4uX/WpFG+RA9SScDP0dbLcedRS7cx0tkuYAIRNUUG8DhIJSBNR1bH1b0=; Received: from p54ae9c93.dip0.t-ipconnect.de ([84.174.156.147] helo=nf.local) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1s1lB0-00AFEt-1O; Tue, 30 Apr 2024 12:57:34 +0200 Message-ID: <80816246-1300-40b3-b0d4-1c1be2f8fc69@nbd.name> Date: Tue, 30 Apr 2024 12:57:33 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 net-next v4 2/6] net: add support for segmenting TCP fraglist GSO packets To: Paolo Abeni , netdev@vger.kernel.org, Eric Dumazet , "David S. Miller" , David Ahern , Jakub Kicinski Cc: willemdebruijn.kernel@gmail.com, linux-kernel@vger.kernel.org References: <20240427182305.24461-1-nbd@nbd.name> <20240427182305.24461-3-nbd@nbd.name> <9e686cb4-ed1f-4886-a0b7-328367e62757@nbd.name> Content-Language: en-US From: Felix Fietkau Autocrypt: addr=nbd@nbd.name; keydata= xsDiBEah5CcRBADIY7pu4LIv3jBlyQ/2u87iIZGe6f0f8pyB4UjzfJNXhJb8JylYYRzIOSxh ExKsdLCnJqsG1PY1mqTtoG8sONpwsHr2oJ4itjcGHfn5NJSUGTbtbbxLro13tHkGFCoCr4Z5 Pv+XRgiANSpYlIigiMbOkide6wbggQK32tC20QxUIwCg4k6dtV/4kwEeiOUfErq00TVqIiEE AKcUi4taOuh/PQWx/Ujjl/P1LfJXqLKRPa8PwD4j2yjoc9l+7LptSxJThL9KSu6gtXQjcoR2 vCK0OeYJhgO4kYMI78h1TSaxmtImEAnjFPYJYVsxrhay92jisYc7z5R/76AaELfF6RCjjGeP wdalulG+erWju710Bif7E1yjYVWeA/9Wd1lsOmx6uwwYgNqoFtcAunDaMKi9xVQW18FsUusM TdRvTZLBpoUAy+MajAL+R73TwLq3LnKpIcCwftyQXK5pEDKq57OhxJVv1Q8XkA9Dn1SBOjNB l25vJDFAT9ntp9THeDD2fv15yk4EKpWhu4H00/YX8KkhFsrtUs69+vZQwc0cRmVsaXggRmll dGthdSA8bmJkQG5iZC5uYW1lPsJgBBMRAgAgBQJGoeQnAhsjBgsJCAcDAgQVAggDBBYCAwEC HgECF4AACgkQ130UHQKnbvXsvgCgjsAIIOsY7xZ8VcSm7NABpi91yTMAniMMmH7FRenEAYMa VrwYTIThkTlQzsFNBEah5FQQCACMIep/hTzgPZ9HbCTKm9xN4bZX0JjrqjFem1Nxf3MBM5vN CYGBn8F4sGIzPmLhl4xFeq3k5irVg/YvxSDbQN6NJv8o+tP6zsMeWX2JjtV0P4aDIN1pK2/w VxcicArw0VYdv2ZCarccFBgH2a6GjswqlCqVM3gNIMI8ikzenKcso8YErGGiKYeMEZLwHaxE Y7mTPuOTrWL8uWWRL5mVjhZEVvDez6em/OYvzBwbkhImrryF29e3Po2cfY2n7EKjjr3/141K DHBBdgXlPNfDwROnA5ugjjEBjwkwBQqPpDA7AYPvpHh5vLbZnVGu5CwG7NAsrb2isRmjYoqk wu++3117AAMFB/9S0Sj7qFFQcD4laADVsabTpNNpaV4wAgVTRHKV/kC9luItzwDnUcsZUPdQ f3MueRJ3jIHU0UmRBG3uQftqbZJj3ikhnfvyLmkCNe+/hXhPu9sGvXyi2D4vszICvc1KL4RD aLSrOsROx22eZ26KqcW4ny7+va2FnvjsZgI8h4sDmaLzKczVRIiLITiMpLFEU/VoSv0m1F4B FtRgoiyjFzigWG0MsTdAN6FJzGh4mWWGIlE7o5JraNhnTd+yTUIPtw3ym6l8P+gbvfoZida0 TspgwBWLnXQvP5EDvlZnNaKa/3oBes6z0QdaSOwZCRA3QSLHBwtgUsrT6RxRSweLrcabwkkE GBECAAkFAkah5FQCGwwACgkQ130UHQKnbvW2GgCeMncXpbbWNT2AtoAYICrKyX5R3iMAoMhw cL98efvrjdstUfTCP2pfetyN In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 30.04.24 12:40, Paolo Abeni wrote: > On Tue, 2024-04-30 at 12:27 +0200, Felix Fietkau wrote: >> On 30.04.24 12:19, Paolo Abeni wrote: >> > On Sat, 2024-04-27 at 20:22 +0200, Felix Fietkau wrote: >> > > Preparation for adding TCP fraglist GRO support. It expects packets to be >> > > combined in a similar way as UDP fraglist GSO packets. >> > > For IPv4 packets, NAT is handled in the same way as UDP fraglist GSO. >> > > >> > > Signed-off-by: Felix Fietkau >> > > --- >> > > net/ipv4/tcp_offload.c | 67 ++++++++++++++++++++++++++++++++++++++++ >> > > net/ipv6/tcpv6_offload.c | 58 ++++++++++++++++++++++++++++++++++ >> > > 2 files changed, 125 insertions(+) >> > > >> > > diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c >> > > index fab0973f995b..affd4ed28cfe 100644 >> > > --- a/net/ipv4/tcp_offload.c >> > > +++ b/net/ipv4/tcp_offload.c >> > > @@ -28,6 +28,70 @@ static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq, >> > > } >> > > } >> > > >> > > +static void __tcpv4_gso_segment_csum(struct sk_buff *seg, >> > > + __be32 *oldip, __be32 newip, >> > > + __be16 *oldport, __be16 newport) >> > > +{ >> > > + struct tcphdr *th; >> > > + struct iphdr *iph; >> > > + >> > > + if (*oldip == newip && *oldport == newport) >> > > + return; >> > > + >> > > + th = tcp_hdr(seg); >> > > + iph = ip_hdr(seg); >> > > + >> > > + inet_proto_csum_replace4(&th->check, seg, *oldip, newip, true); >> > > + inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false); >> > > + *oldport = newport; >> > > + >> > > + csum_replace4(&iph->check, *oldip, newip); >> > > + *oldip = newip; >> > > +} >> > > + >> > > +static struct sk_buff *__tcpv4_gso_segment_list_csum(struct sk_buff *segs) >> > > +{ >> > > + const struct tcphdr *th; >> > > + const struct iphdr *iph; >> > > + struct sk_buff *seg; >> > > + struct tcphdr *th2; >> > > + struct iphdr *iph2; >> > > + >> > > + seg = segs; >> > > + th = tcp_hdr(seg); >> > > + iph = ip_hdr(seg); >> > > + th2 = tcp_hdr(seg->next); >> > > + iph2 = ip_hdr(seg->next); >> > > + >> > > + if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) && >> > > + iph->daddr == iph2->daddr && iph->saddr == iph2->saddr) >> > > + return segs; >> > > + >> > > + while ((seg = seg->next)) { >> > > + th2 = tcp_hdr(seg); >> > > + iph2 = ip_hdr(seg); >> > > + >> > > + __tcpv4_gso_segment_csum(seg, >> > > + &iph2->saddr, iph->saddr, >> > > + &th2->source, th->source); >> > > + __tcpv4_gso_segment_csum(seg, >> > > + &iph2->daddr, iph->daddr, >> > > + &th2->dest, th->dest); >> > > + } >> > > + >> > > + return segs; >> > > +} >> > >> > AFAICS, all the above is really alike the UDP side, except for the >> > transport header zero csum. >> > >> > What about renaming the udp version of this helpers as 'tcpudpv4_...', >> > move them in common code, add an explicit argument for >> > 'zerocsum_allowed' and reuse such helper for both tcp and udp? >> > >> > The same for the ipv6 variant. >> >> Wouldn't that make it more convoluted when taking into account that the >> checksum field offset is different for tcp vs udp? >> How would you handle that? > > Probably making a common helper just for > __tcpudpv{4,6}_gso_segment_csum and pass it the target l4 csum pointer > as an additional argument. It would not be spectacularly nice, so no > strong opinion either way. I'd rather keep it duplicated but more straightforward and easier to read. - Felix