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 7971BA052B for ; Fri, 10 Jul 2020 14:37:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 560881DD0B; Fri, 10 Jul 2020 14:37:27 +0200 (CEST) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 8BEFD1DB66 for ; Fri, 10 Jul 2020 14:37:24 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id q5so5794062wru.6 for ; Fri, 10 Jul 2020 05:37:24 -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=o8NiTHFC+TMtWSVDqAM+8VvbE09EuvWhrwYRToxsQwI=; b=IgCwu29MBEWgkVO7F4kmnPOXPjQravpviOc6N3hXCuOybJyCKIT9EfCmd+QxjQgFq+ nM6avwMYR209ZpyeteNKqsvEkvBlZRPnxs2me80js/lbqJVCS0ZfjV2FyPDaabIwihd/ ZELJ6exQRIsWn7Uo1RfNZDs85zSq8/PGANYzvwQ5PGOhmk4baR4Xq7eZ+iFep89msi7I nA17makDxkPTxhgNrTquTqRboVjnu4ErT8cVWFBk2pgtAyJUSEAdOF41HHLR/Q6ngCbn 9jz/gOIXvujjk00tqx8HalVvDenT5Xhi0Im7tcKFROc4604AAJ7RD2L2IJMQhyTIRLEi sOwg== 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=o8NiTHFC+TMtWSVDqAM+8VvbE09EuvWhrwYRToxsQwI=; b=gWF/oMtkHGEBgiJB76Ua00qJOsYNqAGYOTMnV3nOVajnlUUm4jE/+BW7V0lJAhmLMo 3uDnyEl6AxxHXz3AIdpd7okVd6oq3hkVA4LvtmL2aR97ET7TbhDx8rEstH+Vrc8v7QDu cSxfdpFcxAEI6IP7dP0KNqJhvnGxjr3pmqruxobIFK/7whH7mn5Hy6pvqnz/Q40dY/pU g9gAn84yL0Zo7qiJ0GnnPZjlYHeYnKlveYCsffMW+VHz3bnRo6mOuTq+/XCaPlWMvq5Z XCy9KHT3sf8wOYKVkP+KjjdrWcYleXZIyqldDVr6JJMM/fSrnhtyPij5iE1hF2pJLrAS ZeCA== X-Gm-Message-State: AOAM531lmUu7i+yqX8cTj4fNmKlnSQ4ZQRp9N2iKS0LEstqsmHmG7Rql 651/J7h+LFd9ZtI1uF7XJeijbg== X-Google-Smtp-Source: ABdhPJyTrOuBgsYfKuqrVJqIO/rJYX6Gk1MXUrnCkVWnIB6Q0ulyOj58NK+NLylUA2rEqlG2b53H9w== X-Received: by 2002:adf:ce85:: with SMTP id r5mr75068025wrn.157.1594384644220; Fri, 10 Jul 2020 05:37:24 -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 t15sm9301401wmj.14.2020.07.10.05.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 05:37:23 -0700 (PDT) Date: Fri, 10 Jul 2020 14:37:22 +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: <20200710123722.GX5869@platinum> References: <20200710114313.7412-1-guohongzhi1@huawei.com> <98CBD80474FA8B44BF855DF32C47DC35C61117@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C61117@smartserver.smartshare.dk> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net: fix checksum on big endian CPUs X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Fri, Jul 10, 2020 at 02:20:08PM +0200, Morten Brørup wrote: > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Hongzhi Guo > > Sent: Friday, July 10, 2020 1:43 PM > > > > With current code, the checksum of odd-length buffers is wrong on > > big endian CPUs: the last byte is not properly summed to the > > accumulator. > > > > Fix this by left-shifting the remaining byte by 8. For instance, > > if the last byte is 0x42, we should add 0x4200 to the accumulator > > on big endian CPUs. > > > > This change is similar to what is suggested in Errata 3133 of > > RFC 1071. > > > > Fixes: 6006818cfb26("net: new checksum functions") > > Cc: stable@dpdk.org > > > > Signed-off-by: Hongzhi Guo > > --- > > v2: > > * Explain the logic in the commit log > > * Fixed commit title > > --- > > --- > > lib/librte_net/rte_ip.h | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h > > index 292f63fd7..4fb0e314a 100644 > > --- a/lib/librte_net/rte_ip.h > > +++ b/lib/librte_net/rte_ip.h > > @@ -139,8 +139,11 @@ __rte_raw_cksum(const void *buf, size_t len, > > uint32_t sum) > > } > > > > /* if length is in odd bytes */ > > - if (len == 1) > > - sum += *((const uint8_t *)u16_buf); > > + if (len == 1) { > > + uint16_t left = 0; > > + *(uint8_t *)&left = *(const uint8_t *)u16_buf; > > + sum += left; > > + } > > > > return sum; > > } > > -- > > 2.21.0.windows.1 > > > > This is correct for both big and little endian CPUs. > > Reviewed-by: Morten Brørup Acked-by: Olivier Matz Thanks!