From: Volodymyr Fialko <vfialko@marvell.com>
To: <dev@dpdk.org>, Radu Nicolau <radu.nicolau@intel.com>,
Akhil Goyal <gakhil@marvell.com>,
Volodymyr Fialko <vfialko@marvell.com>
Cc: <jerinj@marvell.com>, <anoobj@marvell.com>
Subject: [PATCH] examples/ipsec-secgw: fix uninitialized variable access
Date: Wed, 9 Nov 2022 10:52:37 +0100 [thread overview]
Message-ID: <20221109095237.1773458-1-vfialko@marvell.com> (raw)
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(-)
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
next reply other threads:[~2022-11-09 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 9:52 Volodymyr Fialko [this message]
2022-11-10 14:14 ` Akhil Goyal
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=20221109095237.1773458-1-vfialko@marvell.com \
--to=vfialko@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=jerinj@marvell.com \
--cc=radu.nicolau@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).