DPDK patches and discussions
 help / color / mirror / Atom feed
From: Haibo Zhang <zhanghaibo5@huawei.com>
To: <thomas.monjalon@6wind.com>
Cc: <dev@dpdk.org>, <zhanghaibo5@huawei.com>,
	<zhoujingbin@huawei.com>, <zhangyuexi@huawei.com>
Subject: [dpdk-dev] [PATCH] ethdev: check process type before reset dev data
Date: Thu, 12 Jan 2017 16:33:18 +0800	[thread overview]
Message-ID: <1484209998-21852-1-git-send-email-zhanghaibo5@huawei.com> (raw)

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

             reply	other threads:[~2017-01-12  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  8:33 Haibo Zhang [this message]
2017-01-12 13:45 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484209998-21852-1-git-send-email-zhanghaibo5@huawei.com \
    --to=zhanghaibo5@huawei.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    --cc=zhangyuexi@huawei.com \
    --cc=zhoujingbin@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).