From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 873D4A052A; Fri, 10 Jul 2020 14:41:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6151B1DD43; Fri, 10 Jul 2020 14:41:12 +0200 (CEST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 197471DD6A for ; Fri, 10 Jul 2020 14:41:11 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id r12so5755209wrj.13 for ; Fri, 10 Jul 2020 05:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=w2gUD4JnP5y38FzvMrBDarQATrGkttJTLnedgunLc3A=; b=C34B7vkwv+Di8eYj4MznFDnNJKDQ9QTGG34fGvXRNADfuOuz5fEt7H0DK7Ai0djRst vkjoPHKiIn8lxBdRrCDBon04PWQSvQ1O3rSBy0DxHUW65Irw33vAGpIiSkxvbZK7ZrrE xS3x7qATR4ZBDaifZWfbtAnYG4JfujTpouSOX4zcTXj5PgDX460YJk9OLTMAg4BoJb4J fj66TWKbZwIbp7xdiGvwcNo10puH1cqVLWSmw0QbnhTh7hhxsdsGERwp/jwNboo0dnLK T08Sbh7HfdvYnEp85aCIXEJSE5bwjKrLb9A3a/wE+xs3gvq9MavcKalpy/SJmnXf7LSj 7UTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w2gUD4JnP5y38FzvMrBDarQATrGkttJTLnedgunLc3A=; b=G7uVhi0x8aFA9DKKiqzhi4Aogm9D83fCvXyszu87k+zezZaxV2ePf9rWGuQRvZajyn WQcwNwhV+EnTUa+h7VLNIvWNPzAzbi5auuad2g1ebAifTkFNuGDkAnOCqwgNTY3Ba/wX 02qD+bYoP1bB3Pgx9xXHSXWriQsJjtYIik8XpYpTmrZsTXsMA6CMVZk+mCyor8RVR91t GQW3ZsxqmcCJHxHbyP6PzFooy3D/NETmw5r/n1Jayd7ChlNFbqpOHHBKvQMdiQKDLkHr 64kbfoH78sWDQBlO3EwuwoPnWxVZ9C3UrUmZxRUwb1aGiGfsgqGFsMCpHycBSsSRJeDA XY9g== X-Gm-Message-State: AOAM531IVHxrLbL2Qi9JBHYIWS9w+5YyrzUpjBujiOndGLBB4U/VgQEa oXJI7l8ufapVeT9c9PNT+e3Dvbts+ZhVyQ== X-Google-Smtp-Source: ABdhPJwR6ulqxFWR2wLf9ZB+Apvj5QceFvQPxspU7CQ66CLHoa2cjdcHI78tU9A3Lm5F8sLcVLrFZQ== X-Received: by 2002:adf:ded2:: with SMTP id i18mr68270323wrn.109.1594384870847; Fri, 10 Jul 2020 05:41:10 -0700 (PDT) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id 12sm8957146wmg.6.2020.07.10.05.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 05:41:10 -0700 (PDT) Date: Fri, 10 Jul 2020 14:41:09 +0200 From: Olivier Matz To: Hongzhi Guo Cc: dev@dpdk.org, stable@dpdk.org, stephen@networkplumber.org, mb@smartsharesystems.com, thomas@monjalon.net, konstantin.ananyev@intel.com, ferruh.yigit@intel.com, nicolas.chautru@intel.com, zhoujingbin@huawei.com, chenchanghu@huawei.com, jerry.lilijun@huawei.com, haifeng.lin@huawei.com Message-ID: <20200710124109.GY5869@platinum> References: <20200710065551.59352-1-guohongzhi1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710065551.59352-1-guohongzhi1@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH] net: fix unneeded replacement of 0 by ffff for TCP checksum X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Jul 10, 2020 at 02:55:51PM +0800, Hongzhi Guo wrote: > Per RFC768: > If the computed checksum is zero, it is transmitted as all ones. > An all zero transmitted checksum value means that the transmitter > generated no checksum. > > RFC793 for TCP has no such special treatment for the checksum of zero. > > Fixes: 6006818cfb26 ("net: new checksum functions") > Cc: stable@dpdk.org > > Signed-off-by: Hongzhi Guo > --- > v2: > * Fixed commit tile > * Fixed the API comment > --- > --- > lib/librte_net/rte_ip.h | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h > index 292f63fd7..d03c77120 100644 > --- a/lib/librte_net/rte_ip.h > +++ b/lib/librte_net/rte_ip.h > @@ -325,7 +325,7 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) > * The pointer to the beginning of the L4 header. > * @return > * The complemented checksum to set in the IP packet > - * or 0 on error > + * or 0 if the IP length is invalid in the header. > */ > static inline uint16_t > rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) > @@ -344,7 +344,13 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) > > cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); > cksum = (~cksum) & 0xffff; > - if (cksum == 0) > + /* > + *Per RFC768: > + *If the computed checksum is zero for udp, > + *it is transmitted as all ones. > + *(the equivalent in one's complement arithmetic). > + */ There should be a space after the '*', and maybe it could be on less lines. Thomas, maybe you can do it when applying? > + if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP) > cksum = 0xffff; > > return (uint16_t)cksum; > @@ -438,7 +444,13 @@ rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) > > cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); > cksum = (~cksum) & 0xffff; > - if (cksum == 0) > + /* > + *Per RFC768: > + *If the computed checksum is zero for udp, > + *it is transmitted as all ones. > + *(the equivalent in one's complement arithmetic). > + */ Same here > + if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP) > cksum = 0xffff; > > return (uint16_t)cksum; > -- > 2.21.0.windows.1 > > Acked-by: Olivier Matz