path: root/app/test-pmd
diff options
authorDongsu Han <>2013-05-06 12:06:51 +0000
committerThomas Monjalon <>2013-07-25 15:54:18 +0200
commit84ac1559c455e5ef02bc77f6a19855037eccad01 (patch)
tree327a3711e9ddc6418da42dd3dad1ed0dc3e3efd6 /app/test-pmd
parenta40a1f8231b43844312c9b2ff7b3f1726c9a2c25 (diff)
app/testpmd: fix refcnt in mbuf allocation
test-pmd txonly leaks mbuf from the pool. The function tx_mbuf_alloc() does not change the refcnt and the refcnt is 0 when it is first allocated. However, rte_pktmbuf_free_seg called by the driver's xmit code decrements reference count to -1. So mbuf never goes back to the pool. As a result, txonly can't send packets after it exhausts the mempool. The function tx_mbuf_alloc() was getting mbuf directly from mempool and so was bypassing mbuf API. The dedicated function is rte_pktmbuf_alloc() but it is much slower because it does unnecessary initializations in rte_pktmbuf_reset(). By using the internal API __rte_mbuf_raw_alloc(), refcnt is correctly handled without adding too much overload. Signed-off-by: Dongsu Han <> Signed-off-by: Thomas Monjalon <> Acked-by: Adrien Mazarguil <>
Diffstat (limited to 'app/test-pmd')
1 files changed, 1 insertions, 4 deletions
diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 7f3b89c..63cc47a 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -92,11 +92,8 @@ static inline struct rte_mbuf *
tx_mbuf_alloc(struct rte_mempool *mp)
struct rte_mbuf *m;
- void *mb;
- if (rte_mempool_get(mp, &mb) < 0)
- return NULL;
- m = (struct rte_mbuf *)mb;
+ m = __rte_mbuf_raw_alloc(mp);
__rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1);
return m;