DPDK patches and discussions
 help / color / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: matan@mellanox.com, shahafs@mellanox.com, yskoh@mellanox.com,
	viacheslavo@mellanox.com
Cc: dev@dpdk.org, sju@paloaltonetworks.com,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process
Date: Fri, 12 Jul 2019 13:54:25 -0700
Message-ID: <20190712205425.17781-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20190712205425.17781-1-stephen@networkplumber.org>

mlx5_dev_info_get calls mlx5_get_ifname, but mlx5_get_ifname
uses priv->ctx which is not a valid pointer in a secondary
process. The fix is to cache the value in primary.

In the primary process, get and store the interface index of
the device so that secondary process can see it.

Fixes: e60fbd5b24fc ("mlx5: add device configure/start/stop")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/mlx5/mlx5.c        | 17 ++++++++---------
 drivers/net/mlx5/mlx5.h        |  1 +
 drivers/net/mlx5/mlx5_ethdev.c |  4 +---
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index d93f92db56b5..27c5ef9b1763 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1105,6 +1105,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	int own_domain_id = 0;
 	uint16_t port_id;
 	unsigned int i;
+	char ifname[IF_NAMESIZE];
 
 	/* Determine if this port representor is supposed to be spawned. */
 	if (switch_info->representor && dpdk_dev->devargs) {
@@ -1479,18 +1480,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		mac.addr_bytes[0], mac.addr_bytes[1],
 		mac.addr_bytes[2], mac.addr_bytes[3],
 		mac.addr_bytes[4], mac.addr_bytes[5]);
-#ifndef NDEBUG
-	{
-		char ifname[IF_NAMESIZE];
 
-		if (mlx5_get_ifname(eth_dev, &ifname) == 0)
-			DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
+	if (mlx5_get_ifname(eth_dev, &ifname) == 0) {
+		priv->if_index = if_nametoindex(ifname);
+		DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
 				eth_dev->data->port_id, ifname);
-		else
-			DRV_LOG(DEBUG, "port %u ifname is unknown",
-				eth_dev->data->port_id);
+	} else {
+		DRV_LOG(DEBUG, "port %u ifname is unknown",
+			eth_dev->data->port_id);
 	}
-#endif
+
 	/* Get actual MTU if possible. */
 	err = mlx5_get_mtu(eth_dev, &priv->mtu);
 	if (err) {
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 5af3f413cdcb..a06ffd444255 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -342,6 +342,7 @@ struct mlx5_priv {
 	uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
 	unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
 	/* Device properties. */
+	unsigned int if_index; /* Associated kernel network device index. */
 	uint16_t mtu; /* Configured MTU. */
 	unsigned int isolated:1; /* Whether isolated mode is enabled. */
 	unsigned int representor:1; /* Device is a port representor. */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index eeefe4df3cd4..41e58db5e573 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -605,7 +605,6 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_dev_config *config = &priv->config;
 	unsigned int max;
-	char ifname[IF_NAMESIZE];
 
 	/* FIXME: we should ask the device for these values. */
 	info->min_rx_bufsize = 32;
@@ -626,8 +625,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	info->rx_offload_capa = (mlx5_get_rx_port_offloads() |
 				 info->rx_queue_offload_capa);
 	info->tx_offload_capa = mlx5_get_tx_port_offloads(dev);
-	if (mlx5_get_ifname(dev, &ifname) == 0)
-		info->if_index = if_nametoindex(ifname);
+	info->if_index = priv->if_index;
 	info->reta_size = priv->reta_idx_n ?
 		priv->reta_idx_n : config->ind_table_max_size;
 	info->hash_key_size = MLX5_RSS_HASH_KEY_LEN;
-- 
2.20.1


  parent reply index

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 20:54 [dpdk-dev] [PATCH 0/2] fix dev_info_get in mlx " Stephen Hemminger
2019-07-12 20:54 ` [dpdk-dev] [PATCH 1/2] net/mlx4: fix crash in dev_info_get in " Stephen Hemminger
2019-07-30 13:48   ` Matan Azrad
2019-08-04  6:57   ` Raslan Darawsheh
2019-08-05  7:42     ` Raslan Darawsheh
2019-07-12 20:54 ` Stephen Hemminger [this message]
2019-07-15  7:41   ` [dpdk-dev] [PATCH 2/2] net/mlx5: " Slava Ovsiienko
2019-07-19  5:31   ` [dpdk-dev] [PATCH 0/2] net/mlx5: cache the associated network device ifindex Viacheslav Ovsiienko
2019-07-19  5:31     ` [dpdk-dev] [PATCH 1/2] " Viacheslav Ovsiienko
2019-07-19 16:15       ` Stephen Hemminger
2019-07-19 16:41         ` Slava Ovsiienko
2019-07-19 18:03           ` Stephen Hemminger
2019-07-19 18:31             ` Slava Ovsiienko
2019-07-19  5:31     ` [dpdk-dev] [PATCH 2/2] Revert "net/mlx5: fix master device Netlink socket sharing" Viacheslav Ovsiienko
2019-07-19 16:16       ` Stephen Hemminger
2019-07-19 16:21         ` Slava Ovsiienko
2019-07-19 16:23           ` Stephen Hemminger
2019-07-21 14:56     ` [dpdk-dev] [PATCH v2 0/2] net/mlx5: cache the associated network device ifindex Viacheslav Ovsiienko
2019-07-21 14:56       ` [dpdk-dev] [PATCH v2 1/2] " Viacheslav Ovsiienko
2019-07-22  5:52         ` Yongseok Koh
2019-07-21 14:56       ` [dpdk-dev] [PATCH v2 2/2] Revert "net/mlx5: fix master device Netlink socket sharing" Viacheslav Ovsiienko
2019-07-22  5:53         ` Yongseok Koh
2019-07-22  8:43       ` [dpdk-dev] [PATCH v2 0/2] net/mlx5: cache the associated network device ifindex Raslan Darawsheh
2019-07-31  7:36   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process Raslan Darawsheh
2019-07-31 13:47     ` Stephen Hemminger

Reply instructions:

You may reply publically 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=20190712205425.17781-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=sju@paloaltonetworks.com \
    --cc=viacheslavo@mellanox.com \
    --cc=yskoh@mellanox.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

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox