examples/ipsec-secgw: fix uninitialized variable access

Message ID 20221109095237.1773458-1-vfialko@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series examples/ipsec-secgw: fix uninitialized variable access |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Volodymyr Fialko Nov. 9, 2022, 9:52 a.m. UTC
  Fix uninitialized variable access of outbound offloads flags.

Coverity issue: 381669
Fixes: 6938fc92c404 ("examples/ipsec-secgw: add lookaside event mode")

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 examples/ipsec-secgw/ipsec-secgw.c  | 19 +++++++++++--------
 examples/ipsec-secgw/ipsec.h        |  7 +++++++
 examples/ipsec-secgw/ipsec_worker.c |  2 ++
 3 files changed, 20 insertions(+), 8 deletions(-)
  

Comments

Akhil Goyal Nov. 10, 2022, 2:14 p.m. UTC | #1
> Subject: [PATCH] examples/ipsec-secgw: fix uninitialized variable access
> 
> Fix uninitialized variable access of outbound offloads flags.
> 
> Coverity issue: 381669
> Fixes: 6938fc92c404 ("examples/ipsec-secgw: add lookaside event mode")
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 24d895451a..a64a26c992 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -105,6 +105,8 @@  struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd) }
 };
 
+struct offloads tx_offloads;
+
 /*
  * To hold ethernet header per port, which will be applied
  * to outgoing packets.
@@ -3017,16 +3019,17 @@  main(int32_t argc, char **argv)
 			ipv4_cksum_port_mask |= 1U << portid;
 	}
 
-	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-		if (rte_lcore_is_enabled(lcore_id) == 0)
-			continue;
+	tx_offloads.ipv4_offloads = RTE_MBUF_F_TX_IPV4;
+	tx_offloads.ipv6_offloads = RTE_MBUF_F_TX_IPV6;
+	/* Update per lcore checksum offload support only if all ports support it */
+	if (ipv4_cksum_port_mask == enabled_port_mask)
+		tx_offloads.ipv4_offloads |= RTE_MBUF_F_TX_IP_CKSUM;
 
+	lcore_id = 0;
+	RTE_LCORE_FOREACH(lcore_id) {
 		/* Pre-populate pkt offloads based on capabilities */
-		lcore_conf[lcore_id].outbound.ipv4_offloads = RTE_MBUF_F_TX_IPV4;
-		lcore_conf[lcore_id].outbound.ipv6_offloads = RTE_MBUF_F_TX_IPV6;
-		/* Update per lcore checksum offload support only if all ports support it */
-		if (ipv4_cksum_port_mask == enabled_port_mask)
-			lcore_conf[lcore_id].outbound.ipv4_offloads |= RTE_MBUF_F_TX_IP_CKSUM;
+		lcore_conf[lcore_id].outbound.ipv4_offloads = tx_offloads.ipv4_offloads;
+		lcore_conf[lcore_id].outbound.ipv6_offloads = tx_offloads.ipv6_offloads;
 	}
 
 	/*
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index a21402ef5f..6bef2a7285 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -242,6 +242,13 @@  struct ipsec_ctx {
 	uint32_t lcore_id;
 };
 
+struct offloads {
+	uint64_t ipv4_offloads;
+	uint64_t ipv6_offloads;
+};
+
+extern struct offloads tx_offloads;
+
 struct cdev_key {
 	uint16_t lcore_id;
 	uint8_t cipher_algo;
diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c
index cbb41bc192..2f02946f86 100644
--- a/examples/ipsec-secgw/ipsec_worker.c
+++ b/examples/ipsec-secgw/ipsec_worker.c
@@ -1342,6 +1342,8 @@  ipsec_wrkr_non_burst_int_port_app_mode(struct eh_event_link_info *links,
 	lconf.outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	lconf.outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
 	lconf.outbound.sa_ctx = socket_ctx[socket_id].sa_out;
+	lconf.outbound.ipv4_offloads = tx_offloads.ipv4_offloads;
+	lconf.outbound.ipv6_offloads = tx_offloads.ipv6_offloads;
 	lconf.outbound.lcore_id = lcore_id;
 
 	RTE_LOG(INFO, IPSEC,