From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <zhanghaibo5@huawei.com>
Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66])
 by dpdk.org (Postfix) with ESMTP id 028C469FC
 for <dev@dpdk.org>; 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 <zhanghaibo5@huawei.com>
To: <thomas.monjalon@6wind.com>
CC: <dev@dpdk.org>, <zhanghaibo5@huawei.com>, <zhoujingbin@huawei.com>,
 <zhangyuexi@huawei.com>
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
Content-Type: text/plain
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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jan 2017 08:32:15 -0000

Overwrite dev date by no primary process would cause
segment fault issue to primary proccess during receive pkt

Signed-off-by: Haibo Zhang <zhanghaibo5@huawei.com>
---
 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++;
-- 
1.8.3.1