summaryrefslogtreecommitdiff
path: root/drivers/net/mlx4/mlx4.c
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2019-07-12 13:54:24 -0700
committerRaslan Darawsheh <rasland@mellanox.com>2019-08-06 17:42:12 +0200
commit164cad78b040122eac581a905a466bd22e7e66b8 (patch)
tree1318d3f3ba3b5c758c9442b57308de0970398749 /drivers/net/mlx4/mlx4.c
parent20215627cd5268a90c309cc91ee08b9e95c2c107 (diff)
downloaddpdk-164cad78b040122eac581a905a466bd22e7e66b8.zip
dpdk-164cad78b040122eac581a905a466bd22e7e66b8.tar.gz
dpdk-164cad78b040122eac581a905a466bd22e7e66b8.tar.xz
net/mlx4: fix crash on info query in secondary process
mlx4_dev_info_get calls mlx4_get_ifname, but mlx4_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. Bugzilla ID: 320 Fixes: 61cbdd419478 ("net/mlx4: separate device control functions") Cc: stable@dpdk.org Reported-by: Suyang Ju <sju@paloaltonetworks.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Matan Azrad <matan@mellanox.com>
Diffstat (limited to 'drivers/net/mlx4/mlx4.c')
-rw-r--r--drivers/net/mlx4/mlx4.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index d6e5753..931e4f4 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -763,6 +763,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
};
unsigned int vf;
int i;
+ char ifname[IF_NAMESIZE];
(void)pci_drv;
err = mlx4_init_once();
@@ -1002,17 +1003,15 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
mac.addr_bytes[4], mac.addr_bytes[5]);
/* Register MAC address. */
priv->mac[0] = mac;
-#ifndef NDEBUG
- {
- char ifname[IF_NAMESIZE];
-
- if (mlx4_get_ifname(priv, &ifname) == 0)
- DEBUG("port %u ifname is \"%s\"",
- priv->port, ifname);
- else
- DEBUG("port %u ifname is unknown", priv->port);
+
+ if (mlx4_get_ifname(priv, &ifname) == 0) {
+ DEBUG("port %u ifname is \"%s\"",
+ priv->port, ifname);
+ priv->if_index = if_nametoindex(ifname);
+ } else {
+ DEBUG("port %u ifname is unknown", priv->port);
}
-#endif
+
/* Get actual MTU if possible. */
mlx4_mtu_get(priv, &priv->mtu);
DEBUG("port %u MTU is %u", priv->port, priv->mtu);