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 54C7BA052A; Fri, 10 Jul 2020 16:52:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B53771DEA0; Fri, 10 Jul 2020 16:52:33 +0200 (CEST) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id 9623A1DE6B for ; Fri, 10 Jul 2020 16:52:32 +0200 (CEST) Received: by mail-wm1-f67.google.com with SMTP id 22so6468606wmg.1 for ; Fri, 10 Jul 2020 07:52:32 -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:content-transfer-encoding:in-reply-to :user-agent; bh=rcM1oQ1w/OY9d8qBa6zkqqWkggLCqXAL99QsmAUlJUw=; b=itWZQ/QZK2G8SIdx4uzorlfhM70FFgKcyK1qhBj0iA0WMty+lTNWmOZl4felgPYrVw Qh34x+TTHBBkPIgI6tVkGGKSyGU7a30Ad2hw/XVOhL5JCu71EP1zGUh6YsyiTOCTelsj Mp6XrMeOnnkr4cJw1Tg3+YY3xHiGPkKD69hYIeVyumWpkUto9AaYPgGvKsK70ACfFXjK lF1ydrLYEr1ZMPuF2/1G54htEURWlotiBOqPs5ThCAe6oDiTjGFJwyk9AkN5bmvDSTfc cI0fOggI6b11Kqby82K76IMl6C4bbtly/0InoIFujeKr9xdd5u8a2PjMM7jfKQuM+ni5 X3Eg== 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:content-transfer-encoding :in-reply-to:user-agent; bh=rcM1oQ1w/OY9d8qBa6zkqqWkggLCqXAL99QsmAUlJUw=; b=LsU2POntjf4wKpql6BnsuKLXJJ3lTnL8O83EUk19YLTszWs7aa71hUN7X21koMPdjz vdTUZ0DY8Xdav6aGnZIkFr31csG2K4ObOqiG/aybMLKCQIn7CdXRM8IKWBBt4QVvyAAr 5inUSaH35s5UXj3bYfuhyB5M9f0mrsZiRPuhlhWG11ykRgGoNq2s/6gftR84lawcQsvd u9us70NL0mfvT0DghxmYtnQNpFRkNgFIvt/5f+BInIK27kWuNQ8xqxXtQ2DzfympCxEr UfrOeObox3P006P0BH8vd9g6iwjIgVzdzjkPxYsAlGxUqWAMFxJ5z1+Wws7t3YlcMwb1 ax3w== X-Gm-Message-State: AOAM533ED12RkXJmCXRw741UUX59nLgNE6AZL0Q0LoKROG0YNGamoh9u y3SQHAreypJmACxb2XxT5P/IOA== X-Google-Smtp-Source: ABdhPJyl8XWOBLyllGHi3k4Jmmb3ehzX0qcDgiYhLtsA/aig6mjIi5S8wGj20ToYyTUp3gWu1u9uGg== X-Received: by 2002:a1c:80c8:: with SMTP id b191mr5256884wmd.37.1594392752288; Fri, 10 Jul 2020 07:52:32 -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 r1sm10341138wrt.73.2020.07.10.07.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 07:52:31 -0700 (PDT) Date: Fri, 10 Jul 2020 16:52:31 +0200 From: Olivier Matz To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Hongzhi Guo , dev@dpdk.org, stable@dpdk.org, stephen@networkplumber.org, 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: <20200710145231.GG5869@platinum> References: <20200710065551.59352-1-guohongzhi1@huawei.com> <20200710124109.GY5869@platinum> <98CBD80474FA8B44BF855DF32C47DC35C61118@smartserver.smartshare.dk> <20200710131604.GB5869@platinum> <98CBD80474FA8B44BF855DF32C47DC35C61119@smartserver.smartshare.dk> <20200710134102.GC5869@platinum> <98CBD80474FA8B44BF855DF32C47DC35C6111B@smartserver.smartshare.dk> <20200710144059.GF5869@platinum> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200710144059.GF5869@platinum> 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 04:40:59PM +0200, Olivier Matz wrote: > On Fri, Jul 10, 2020 at 03:56:11PM +0200, Morten Brørup wrote: > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz > > > Sent: Friday, July 10, 2020 3:41 PM > > > > > > On Fri, Jul 10, 2020 at 03:29:36PM +0200, Morten Brørup wrote: > > > > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > > > > Sent: Friday, July 10, 2020 3:16 PM > > > > > > > > > > On Fri, Jul 10, 2020 at 03:10:34PM +0200, Morten Brørup wrote: > > > > > > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > > > > > > Sent: Friday, July 10, 2020 2:41 PM > > > > > > > > > > > > > > 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) > > > > > > > > > > > > 0 is a valid return value, so I suggest omitting it from the > > > return > > > > > value description: > > > > > > > > > > > > * @return > > > > > > - * The complemented checksum to set in the IP packet > > > > > > - * or 0 on error > > > > > > + * The complemented checksum to set in the IP packet. > > > > > > > > > > > > The comparison "if (l3_len < sizeof(struct rte_ipv4_hdr))" is > > > only > > > > > there to protect against invalid input; it prevents l4_len from > > > > > becoming negative. > > > > > > > > > > I don't get why "0 if the IP length is invalid in the header" > > > should > > > > > be removed from the comment: 0 is both a valid return value and > > > > > the value returned on invalid packet. > > > > > > > > To avoid confusion. We do not want people to add error handling for a > > > return value of 0. > > > > > > > > 0 is not a special value or an error, so it does not deserve explicit > > > mentioning. > > > > > > > > If we want to mention the return value for garbage input, we should > > > not use the wording "or 0", because this suggests that 0 is not a > > > normal return value. > > > > > > Ok, got it. > > > > > > So maybe this? > > > > > > The complemented checksum to set in the IP packet. If > > > the IP length is invalid in the header, it returns 0. > > > > > It still mentions 0 as a special value, increasing the risk of the defensive user adding "error handling" for a return value of 0. > > > > How about this? > > > > The complemented checksum to set in the IP packet. If > > the IP length is invalid in the header, the return value > > is undefined. > > After reading again your arguments, I think I prefer your first > proposal, which was also Hongzhi's initial submission: > > - * The complemented checksum to set in the IP packet > - * or 0 on error > + * The complemented checksum to set in the IP packet. > > Thomas, do you want to to resubmit with this change? Sorry, I meant "do you want me to resubmit?" > > > > > > > > > > > > > > > > > > > For the same reason, unlikely() should be added to this > > > comparison. > > > > > > > > > > Maybe yes, but that's another story I think. > > > > > > > > Agree. I was just mentioning it so it can be done when modifying the > > > function anyway. > > > > > > > > > > > > > > > Otherwise, > > > > > > > > > > > > Acked-by: Morten Brørup > > > > > > > > > > > >