[5/5,pktgen] fix cleanup of not sent packets
Checks
Commit Message
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(-)
@@ -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;
}
}