DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, "Ananyev,
	Konstantin" <konstantin.ananyev@intel.com>,
	Andrew Rybchenko <arybchenko@solarflare.com>,
	Tomasz Kulasek <tomaszx.kulasek@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net: fix the way how L4 checksum choice is tested
Date: Fri, 28 Jun 2019 00:52:02 +0300	[thread overview]
Message-ID: <20190627215202.794-1-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20190529173337.31157-1-ivan.malov@oktetlabs.ru>

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 <tomaszx.kulasek@intel.com>
Cc: stable@dpdk.org

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 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


  parent reply	other threads:[~2019-06-27 21:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 17:33 [dpdk-dev] [PATCH] " Ivan Malov
2019-06-24 11:52 ` Ananyev, Konstantin
2019-06-24 12:01 ` Ananyev, Konstantin
2019-06-24 12:16   ` Andrew Rybchenko
2019-06-27 13:26     ` Ananyev, Konstantin
2019-06-27 21:52 ` Ivan Malov [this message]
2019-06-28  0:10   ` [dpdk-dev] [PATCH v2] " Stephen Hemminger
2019-06-28  3:13 ` [dpdk-dev] [PATCH v3] " Ivan Malov
2019-06-28  4:26   ` Stephen Hemminger
2019-06-28 10:47   ` Ananyev, Konstantin
2019-06-28 16:24     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190627215202.794-1-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=tomaszx.kulasek@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).