From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_ADSP_DISCARD, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3246DC4321A for ; Thu, 27 Jun 2019 21:52:16 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id C51202075E for ; Thu, 27 Jun 2019 21:52:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C51202075E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=oktetlabs.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 93FAC28EE; Thu, 27 Jun 2019 23:52:14 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [84.52.114.115]) by dpdk.org (Postfix) with ESMTP id 2AF8C1E2F; Thu, 27 Jun 2019 23:52:13 +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 C0AAC7F7B4; Fri, 28 Jun 2019 00:52:12 +0300 (MSK) From: Ivan Malov To: Olivier Matz Cc: dev@dpdk.org, "Ananyev, Konstantin" , Andrew Rybchenko , Tomasz Kulasek , stable@dpdk.org Date: Fri, 28 Jun 2019 00:52:02 +0300 Message-Id: <20190627215202.794-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190529173337.31157-1-ivan.malov@oktetlabs.ru> References: <20190529173337.31157-1-ivan.malov@oktetlabs.ru> Subject: [dpdk-dev] [PATCH v2] 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. Initialise the pointer upon declaration and explain the reason behind this in the comment. Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") Cc: Tomasz Kulasek Cc: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- lib/librte_net/rte_net.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 7be69f8..6eab230 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -112,7 +112,13 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, static inline int rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) { - struct rte_ipv4_hdr *ipv4_hdr; + /* + * Initialise ipv4_hdr beforehand to mute false positive + * compiler warnings about this variable being possibly used + * uninitialised in L4 parsing branches below albeit it is clearly + * initialised in IPv4 parsing branch prior L4-related code. + */ + struct rte_ipv4_hdr *ipv4_hdr = NULL; struct rte_ipv6_hdr *ipv6_hdr; struct rte_tcp_hdr *tcp_hdr; struct rte_udp_hdr *udp_hdr; @@ -150,7 +156,7 @@ 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) { + 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); @@ -166,7 +172,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 */ -- 1.8.3.1