From patchwork Wed Aug 23 02:21:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 27736 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 729865905; Wed, 23 Aug 2017 06:08:46 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id ED18E374F for ; Wed, 23 Aug 2017 06:08:44 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 23 Aug 2017 05:22:32 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.222]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v7N2MVeh010858; Wed, 23 Aug 2017 05:22:32 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id v7N2MURw169061; Wed, 23 Aug 2017 10:22:30 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id v7N2MOL7169059; Wed, 23 Aug 2017 10:22:24 +0800 From: Xueming Li To: dev@dpdk.org Cc: Sergio Gonzalez Monroy , Olivier Matz , Xueming Li Date: Wed, 23 Aug 2017 10:21:35 +0800 Message-Id: <20170823022135.169012-1-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 Subject: [dpdk-dev] [PATCH] examples/l2fwd_fork: fix messaage pool init X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Cc: Olivier Matz Signed-off-by: Xueming Li --- 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;