DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: check process type before reset dev data
@ 2017-01-12  8:33 Haibo Zhang
  2017-01-12 13:45 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Haibo Zhang @ 2017-01-12  8:33 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, zhanghaibo5, zhoujingbin, zhangyuexi

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

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

end of thread, other threads:[~2017-01-12 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12  8:33 [dpdk-dev] [PATCH] ethdev: check process type before reset dev data Haibo Zhang
2017-01-12 13:45 ` 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).