From: Ivan Malov Date: Fri, 28 Jun 2019 03:13:09 +0000 (+0300) Subject: net: fix how L4 checksum choice is tested X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=39a94299195f3329a28a3556e2431b9d6b83b222;p=dpdk.git net: fix how L4 checksum choice is tested 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: stable@dpdk.org Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Acked-by: Stephen Hemminger Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 461f2c81da..1560ecfa46 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -113,7 +113,8 @@ 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 to avoid false positive compiler warnings. */ + 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; @@ -151,7 +152,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) 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); @@ -167,7 +168,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) 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 */