DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init
@ 2017-08-23  2:21 Xueming Li
  2017-09-15 15:37 ` [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message " Xueming Li
  0 siblings, 1 reply; 3+ messages in thread
From: Xueming Li @ 2017-08-23  2:21 UTC (permalink / raw)
  To: dev; +Cc: Sergio Gonzalez Monroy, Olivier Matz, Xueming Li

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message pool init
  2017-08-23  2:21 [dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init Xueming Li
@ 2017-09-15 15:37 ` Xueming Li
  2017-10-13 22:33   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Xueming Li @ 2017-09-15 15:37 UTC (permalink / raw)
  To: Sergio Gonzalez Monroy; +Cc: dev, Xueming Li

Some invalid callback functions are provided to rte_pktmbuf_pool_init()
without their associated data causing a segmentation fault when the
function tries to use it. In this example, those callbacks are not
necessary, they can be safely replaced by NULL pointers.

Fixes: 95e8005a56e8 ("examples/l2fwd_fork: new app")

Cc: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 examples/multi_process/l2fwd_fork/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index f8a626b..2e70c2f 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -1204,10 +1204,7 @@ struct l2fwd_port_statistics {
 	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");
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message pool init
  2017-09-15 15:37 ` [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message " Xueming Li
@ 2017-10-13 22:33   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-10-13 22:33 UTC (permalink / raw)
  To: Xueming Li; +Cc: dev, Sergio Gonzalez Monroy

15/09/2017 17:37, Xueming Li:
> Some invalid callback functions are provided to rte_pktmbuf_pool_init()
> without their associated data causing a segmentation fault when the
> function tries to use it. In this example, those callbacks are not
> necessary, they can be safely replaced by NULL pointers.
> 
> Fixes: 95e8005a56e8 ("examples/l2fwd_fork: new app")
> 
> Cc: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-13 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23  2:21 [dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init Xueming Li
2017-09-15 15:37 ` [dpdk-dev] [PATCH v2] examples/l2fwd_fork: fix message " Xueming Li
2017-10-13 22:33   ` Thomas Monjalon

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).