Skip to content

Commit

Permalink
net/mlx4: fix crash on info query in secondary process
Browse files Browse the repository at this point in the history
[ upstream commit 164cad7 ]

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: 61cbdd4 ("net/mlx4: separate device control functions")

Reported-by: Suyang Ju <sju@paloaltonetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Matan Azrad <matan@mellanox.com>
  • Loading branch information
shemminger authored and kevintraynor committed Sep 4, 2019
1 parent d78c697 commit 2609b07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
17 changes: 8 additions & 9 deletions drivers/net/mlx4/mlx4.c
Expand Up @@ -520,6 +520,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;
assert(pci_drv == &mlx4_driver);
Expand Down Expand Up @@ -703,17 +704,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);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/mlx4/mlx4.h
Expand Up @@ -84,6 +84,7 @@ struct mlx4_priv {
struct ibv_device_attr device_attr; /**< Device properties. */
struct ibv_pd *pd; /**< Protection Domain. */
/* Device properties. */
unsigned int if_index; /**< Associated network device index */
uint16_t mtu; /**< Configured MTU. */
uint8_t port; /**< Physical port number. */
uint32_t started:1; /**< Device started, flows enabled. */
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/mlx4/mlx4_ethdev.c
Expand Up @@ -559,7 +559,6 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
{
struct mlx4_priv *priv = dev->data->dev_private;
unsigned int max;
char ifname[IF_NAMESIZE];

/* FIXME: we should ask the device for these values. */
info->min_rx_bufsize = 32;
Expand All @@ -580,8 +579,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
info->rx_queue_offload_capa = mlx4_get_rx_queue_offloads(priv);
info->rx_offload_capa = (mlx4_get_rx_port_offloads(priv) |
info->rx_queue_offload_capa);
if (mlx4_get_ifname(priv, &ifname) == 0)
info->if_index = if_nametoindex(ifname);
info->if_index = priv->if_index;
info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE;
info->speed_capa =
ETH_LINK_SPEED_1G |
Expand Down

0 comments on commit 2609b07

Please sign in to comment.