From patchwork Wed May 29 17:33:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 53857 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68F901B95A; Wed, 29 May 2019 19:33:44 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [84.52.114.115]) by dpdk.org (Postfix) with ESMTP id F14F81B959; Wed, 29 May 2019 19:33:42 +0200 (CEST) Received: from olwe.oktetlabs.ru (olwe.oktetlabs.ru [192.168.37.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 73F0C7F794; Wed, 29 May 2019 20:33:42 +0300 (MSK) From: Ivan Malov To: Olivier Matz Cc: dev@dpdk.org, Tomasz Kulasek , stable@dpdk.org Date: Wed, 29 May 2019 20:33:37 +0300 Message-Id: <20190529173337.31157-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net: fix the way how L4 checksum choice is tested 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" The API to prepare checksum offloads mistreats L4 checksum type enum values as self-contained flags. Turning these flag checks into enum checks causes warnings by GCC about possibly uninitialised IPv4 header pointer. The issue was found to show up in the case of GCC versions 4.8.5 and 5.4.0, however, it might be the case for a wider variety of other versions. As GCC version 7.4.0 is not susceptible to the said false positive assessment, this patch maintains a compiler barrier for earlier versions. Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") Cc: Tomasz Kulasek Cc: stable@dpdk.org Signed-off-by: Ivan Malov Signed-off-by: Ivan Malov --- lib/librte_net/rte_net.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 7088584..fb09431 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -151,7 +151,19 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, ipv4_hdr->hdr_checksum = 0; } - if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) { +#ifdef GCC_VERSION +#if GCC_VERSION < 70400 + /* + * Earlier versions of GCC suspect access to possibly + * uninitialised ipv4_hdr in the code below, although + * the said variable is properly initialised above. + * Use compiler barrier to cope with the problem. + */ + rte_compiler_barrier(); +#endif +#endif + + if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) { if (ol_flags & PKT_TX_IPV4) { udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + m->l3_len); @@ -167,7 +179,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); } - } else if ((ol_flags & PKT_TX_TCP_CKSUM) || + } else if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM || (ol_flags & PKT_TX_TCP_SEG)) { if (ol_flags & PKT_TX_IPV4) { /* non-TSO tcp or TSO */