Skip to content

Commit

Permalink
examples/ipsec-secgw: fix width of variables
Browse files Browse the repository at this point in the history
[ upstream commit 6b9dabfdffee7ff1efa83e9548b4063fab0819c5 ]

'rte_eth_rx_burst' returns uint16_t. The same value need to be passed
to 'process_packets' functions which performs further processing. Having
this function use 'uint8_t' can result in issues when MAX_PKT_BURST is
larger.

The route functions (route4_pkts & route6_pkts) take uint8_t as the
argument. The caller can pass larger values as the field that is passed
is of type uint32_t. And the function can work with uint32_t as it loops
through the packets and sends it out. Using uint8_t can result in silent
packet drops.

Fixes: 4fbfa6c ("examples/ipsec-secgw: update eth header during route lookup")

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  • Loading branch information
anoobj authored and bluca committed Mar 7, 2024
1 parent fac0d1f commit c5db2d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions examples/ipsec-secgw/ipsec-secgw.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ process_pkts_outbound_nosp(struct ipsec_ctx *ipsec_ctx,

static inline void
process_pkts(struct lcore_conf *qconf, struct rte_mbuf **pkts,
uint8_t nb_pkts, uint16_t portid, struct rte_security_ctx *ctx)
uint16_t nb_pkts, uint16_t portid, struct rte_security_ctx *ctx)
{
struct ipsec_traffic traffic;

Expand Down Expand Up @@ -695,8 +695,7 @@ ipsec_poll_mode_worker(void)
struct rte_mbuf *pkts[MAX_PKT_BURST];
uint32_t lcore_id;
uint64_t prev_tsc, diff_tsc, cur_tsc;
int32_t i, nb_rx;
uint16_t portid;
uint16_t i, nb_rx, portid;
uint8_t queueid;
struct lcore_conf *qconf;
int32_t rc, socket_id;
Expand Down
4 changes: 2 additions & 2 deletions examples/ipsec-secgw/ipsec_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ get_hop_for_offload_pkt(struct rte_mbuf *pkt, int is_ipv6)

static __rte_always_inline void
route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[],
uint8_t nb_pkts, uint64_t tx_offloads, bool ip_cksum)
uint32_t nb_pkts, uint64_t tx_offloads, bool ip_cksum)
{
uint32_t hop[MAX_PKT_BURST * 2];
uint32_t dst_ip[MAX_PKT_BURST * 2];
Expand Down Expand Up @@ -560,7 +560,7 @@ route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[],
}

static __rte_always_inline void
route6_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts)
route6_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint32_t nb_pkts)
{
int32_t hop[MAX_PKT_BURST * 2];
uint8_t dst_ip[MAX_PKT_BURST * 2][16];
Expand Down

0 comments on commit c5db2d6

Please sign in to comment.