[5/5,pktgen] fix cleanup of not sent packets

Message ID 1547136846-23319-6-git-send-email-rk@semihalf.com (mailing list archive)
State Not Applicable, archived
Headers
Series fixes and minor features |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Rafal Kozik Jan. 10, 2019, 4:14 p.m. UTC
  Not sent packets are copied to the beginning of array to be reused in next
iteration. But as in some cases more than half of mbuf could not be sent,
source and destination locations would overlap. In such case rte_memcpy
cannot be used.
One of side effects is double sending the same mbuf and as a consequence
double returning it to the mempool.

Fixes: 2bf1eecea240 ("fixup code for 18.05 and cleanup")

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 app/pktgen.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Patch

diff --git a/app/pktgen.c b/app/pktgen.c
index f7eee07..c1039a6 100644
--- a/app/pktgen.c
+++ b/app/pktgen.c
@@ -272,11 +272,10 @@  _send_burst_fast(port_info_t *info, uint16_t qid)
 {
 	struct mbuf_table   *mtab = &info->q[qid].tx_mbufs;
 	struct rte_mbuf **pkts;
-	uint32_t ret, cnt, sav, retry;
+	uint32_t ret, cnt, retry, i;
 
 	cnt = mtab->len;
 	mtab->len = 0;
-	sav = cnt;
 
 	pkts = mtab->m_table;
 
@@ -299,8 +298,8 @@  _send_burst_fast(port_info_t *info, uint16_t qid)
 		}
 	}
 	if (cnt) {
-		rte_memcpy(&mtab->m_table[0], &mtab->m_table[sav - cnt],
-		           sizeof(char *) * cnt);
+		for (i = 0; i < cnt; i++)
+			mtab->m_table[i] = pkts[i];
 		mtab->len = cnt;
 	}
 }