[dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init
Xueming Li
xuemingl at mellanox.com
Wed Aug 23 04:21:35 CEST 2017
rte_pktmbuf_pool_init and rte_pktmbuf_init callback caused memory
corruption on a message memory pool, remove both.
On the other hand, add rte_pktmbuf_pool assertion of private data size
in function rte_pktmbuf_pool_init() to avoid initializing none mbuf
memory pool.
Fixes: 95e8005a56e8 ("examples/l2fwd_fork: new app")
Cc: Sergio Gonzalez Monroy <sergio.gonzalez.monroy at intel.com>
Cc: Olivier Matz <olivier.matz at 6wind.com>
Signed-off-by: Xueming Li <xuemingl at mellanox.com>
---
examples/multi_process/l2fwd_fork/main.c | 5 +----
lib/librte_mbuf/rte_mbuf.c | 2 ++
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index f8a626ba7..2e70c2faf 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -1204,10 +1204,7 @@ main(int argc, char **argv)
message_pool = rte_mempool_create("ms_msg_pool",
NB_CORE_MSGBUF * RTE_MAX_LCORE,
sizeof(enum l2fwd_cmd), NB_CORE_MSGBUF / 2,
- 0,
- rte_pktmbuf_pool_init, NULL,
- rte_pktmbuf_init, NULL,
- rte_socket_id(), 0);
+ 0, NULL, NULL, NULL, NULL, rte_socket_id(), 0);
if (message_pool == NULL)
rte_exit(EXIT_FAILURE, "Create msg mempool failed\n");
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 26a62b8e1..aa924fde6 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -88,6 +88,8 @@ rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg)
uint16_t roomsz;
RTE_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf));
+ RTE_ASSERT(mp->private_data_size == ((sizeof(*mbp_priv) +
+ RTE_MEMPOOL_ALIGN_MASK) & (~RTE_MEMPOOL_ALIGN_MASK)));
/* if no structure is provided, assume no mbuf private area */
user_mbp_priv = opaque_arg;
--
2.13.3
More information about the dev
mailing list