Skip to contentSkip to conversation

examples/l3fwd: fix core dump after packet match

PATCH Applied Sean Morrissey 4 participants 4 messages Sep 7, 2022 – Oct 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/l3fwd: fix core dump after packet match

This patch fixes a core dump which occurs on 32-bit-builds after sending a matched packet due to overrunning an array.

Fixes 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
---
 examples/l3fwd/l3fwd_acl_scalar.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
examples/l3fwd/l3fwd_acl_scalar.h +5 -8
index cd99f8594a..542c303d3b 100644
@@ -70,15 +70,12 @@ send_packets_single(struct lcore_conf *qconf, struct rte_mbuf *pkts[], uint16_t
 
 		/* Set MAC addresses. */
 		eth_hdr = rte_pktmbuf_mtod(pkts[j], struct rte_ether_hdr *);
-		*(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[hops[j]];
-		rte_ether_addr_copy(&ports_eth_addr[hops[j]],
-						&eth_hdr->src_addr);
-	}
-
-	for (j  = 0; j != nb_tx; j++) {
-		if (hops[j] != BAD_PORT)
+		if (hops[j] != BAD_PORT) {
+			*(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[hops[j]];
+			rte_ether_addr_copy(&ports_eth_addr[hops[j]],
+							&eth_hdr->src_addr);
 			send_single_packet(qconf, pkts[j], hops[j]);
-		else
+		} else
 			rte_pktmbuf_free(pkts[j]);
 	}
 }
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 37 lines · Sean Morrissey

This patch fixes a core dump which occurs on 32-bit-builds after sending a matched packet due to overrunning an array.

Fixes 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
---
  examples/l3fwd/l3fwd_acl_scalar.h | 13 +++++--------
  1 file changed, 5 insertions(+), 8 deletions(-)
examples/l3fwd/l3fwd_acl_scalar.h +5 -8
index cd99f8594a..542c303d3b 100644
@@ -70,15 +70,12 @@ send_packets_single(struct lcore_conf *qconf, struct rte_mbuf *pkts[], uint16_t
 
  		/* Set MAC addresses. */
  		eth_hdr = rte_pktmbuf_mtod(pkts[j], struct rte_ether_hdr *);
-		*(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[hops[j]];
-		rte_ether_addr_copy(&ports_eth_addr[hops[j]],
-						&eth_hdr->src_addr);
-	}
-
-	for (j  = 0; j != nb_tx; j++) {
-		if (hops[j] != BAD_PORT)
+		if (hops[j] != BAD_PORT) {
+			*(uint64_t *)&eth_hdr->dst_addr = dest_eth_addr[hops[j]];
+			rte_ether_addr_copy(&ports_eth_addr[hops[j]],
+							&eth_hdr->src_addr);
  			send_single_packet(qconf, pkts[j], hops[j]);
-		else
+		} else
  			rte_pktmbuf_free(pkts[j]);
  	}
  }
Signature · 2 lines
Regards,
Vladimir
Tested-by on v1 1/1
#2 lore raw
In reply to Sean Morrissey
Quoted 12 lines

-----Original Message-----
From: Sean Morrissey <[email protected]>
Sent: Wednesday, September 7, 2022 7:34 PM
To: Konstantin Ananyev <[email protected]>; Morrissey, Sean <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH v1] examples/l3fwd: fix core dump after packet match

This patch fixes a core dump which occurs on 32-bit-builds after sending a matched packet due to overrunning an array.

Quoted 6 lines
Fixes 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")

---