From: Xueming Li <xuemingl@mellanox.com>
To: dev@dpdk.org
Cc: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>,
Olivier Matz <olivier.matz@6wind.com>,
Xueming Li <xuemingl@mellanox.com>
Subject: [dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init
Date: Wed, 23 Aug 2017 10:21:35 +0800 [thread overview]
Message-ID: <20170823022135.169012-1-xuemingl@mellanox.com> (raw)
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@intel.com>
Cc: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Xueming Li <xuemingl@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
next reply other threads:[~2017-08-23 4:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-23 2:21 Xueming Li [this message]
2017-09-15 15:37 ` [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message " Xueming Li
2017-10-13 22:33 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170823022135.169012-1-xuemingl@mellanox.com \
--to=xuemingl@mellanox.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
--cc=sergio.gonzalez.monroy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).