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 <[email protected]>
---
 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(-)

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,
-- 
2.25.1

Reply via email to