From patchwork Thu Jan 12 08:33:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Zhang X-Patchwork-Id: 19189 X-Patchwork-Delegate: thomas@monjalon.net 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 3A882F8AA; Thu, 12 Jan 2017 09:32:17 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) by dpdk.org (Postfix) with ESMTP id 028C469FC for ; Thu, 12 Jan 2017 09:32:11 +0100 (CET) Received: from 172.24.1.136 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.136]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CNX16473; Thu, 12 Jan 2017 16:32:06 +0800 (CST) Received: from localhost (10.175.104.147) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Thu, 12 Jan 2017 16:31:56 +0800 From: Haibo Zhang To: CC: , , , Date: Thu, 12 Jan 2017 16:33:18 +0800 Message-ID: <1484209998-21852-1-git-send-email-zhanghaibo5@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.147] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] ethdev: check process type before reset dev data 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" Overwrite dev date by no primary process would cause segment fault issue to primary proccess during receive pkt Signed-off-by: Haibo Zhang --- lib/librte_ether/rte_ethdev.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 9dea1f1..e25f056 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -212,12 +212,15 @@ struct rte_eth_dev * eth_dev = &rte_eth_devices[port_id]; eth_dev->data = &rte_eth_dev_data[port_id]; - memset(eth_dev->data, 0, sizeof(*eth_dev->data)); - snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name); - eth_dev->data->port_id = port_id; - eth_dev->data->mtu = ETHER_MTU; - TAILQ_INIT(&(eth_dev->link_intr_cbs)); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + memset(eth_dev->data, 0, sizeof(*eth_dev->data)); + snprintf(eth_dev->data->name, + sizeof(eth_dev->data->name), "%s", name); + eth_dev->data->port_id = port_id; + eth_dev->data->mtu = ETHER_MTU; + } + TAILQ_INIT(&(eth_dev->link_intr_cbs)); eth_dev->attached = DEV_ATTACHED; eth_dev_last_created_port = port_id; nb_ports++;