提交 e387f7d5 编写于 作者: J Jiri Pirko 提交者: David S. Miller

mlx5: register lag notifier for init network namespace only

The current code causes problems when the unregistering netdevice could
be different then the registering one.

Since the check in mlx5_lag_netdev_event() does not allow any other
network namespace anyway, fix this by registerting the lag notifier
per init network namespace only.

Fixes: d48834f9 ("mlx5: Use dev_net netdevice notifier registrations")
Signed-off-by: NJiri Pirko <jiri@mellanox.com>
Tested-by: NAya Levin <ayal@mellanox.com>
Acked-by: NSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3a12500e
...@@ -5147,7 +5147,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) ...@@ -5147,7 +5147,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
static void mlx5e_nic_disable(struct mlx5e_priv *priv) static void mlx5e_nic_disable(struct mlx5e_priv *priv)
{ {
struct net_device *netdev = priv->netdev;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
#ifdef CONFIG_MLX5_CORE_EN_DCB #ifdef CONFIG_MLX5_CORE_EN_DCB
...@@ -5168,7 +5167,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv) ...@@ -5168,7 +5167,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
mlx5e_monitor_counter_cleanup(priv); mlx5e_monitor_counter_cleanup(priv);
mlx5e_disable_async_events(priv); mlx5e_disable_async_events(priv);
mlx5_lag_remove(mdev, netdev); mlx5_lag_remove(mdev);
} }
int mlx5e_update_nic_rx(struct mlx5e_priv *priv) int mlx5e_update_nic_rx(struct mlx5e_priv *priv)
......
...@@ -1861,7 +1861,6 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv) ...@@ -1861,7 +1861,6 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv) static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
{ {
struct net_device *netdev = priv->netdev;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -1870,7 +1869,7 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv) ...@@ -1870,7 +1869,7 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
#endif #endif
mlx5_notifier_unregister(mdev, &priv->events_nb); mlx5_notifier_unregister(mdev, &priv->events_nb);
cancel_work_sync(&rpriv->uplink_priv.reoffload_flows_work); cancel_work_sync(&rpriv->uplink_priv.reoffload_flows_work);
mlx5_lag_remove(mdev, netdev); mlx5_lag_remove(mdev);
} }
static MLX5E_DEFINE_STATS_GRP(sw_rep, 0); static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);
......
...@@ -464,9 +464,6 @@ static int mlx5_lag_netdev_event(struct notifier_block *this, ...@@ -464,9 +464,6 @@ static int mlx5_lag_netdev_event(struct notifier_block *this,
struct mlx5_lag *ldev; struct mlx5_lag *ldev;
int changed = 0; int changed = 0;
if (!net_eq(dev_net(ndev), &init_net))
return NOTIFY_DONE;
if ((event != NETDEV_CHANGEUPPER) && (event != NETDEV_CHANGELOWERSTATE)) if ((event != NETDEV_CHANGEUPPER) && (event != NETDEV_CHANGELOWERSTATE))
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -586,8 +583,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev) ...@@ -586,8 +583,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
if (!ldev->nb.notifier_call) { if (!ldev->nb.notifier_call) {
ldev->nb.notifier_call = mlx5_lag_netdev_event; ldev->nb.notifier_call = mlx5_lag_netdev_event;
if (register_netdevice_notifier_dev_net(netdev, &ldev->nb, if (register_netdevice_notifier_net(&init_net, &ldev->nb)) {
&ldev->nn)) {
ldev->nb.notifier_call = NULL; ldev->nb.notifier_call = NULL;
mlx5_core_err(dev, "Failed to register LAG netdev notifier\n"); mlx5_core_err(dev, "Failed to register LAG netdev notifier\n");
} }
...@@ -600,7 +596,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev) ...@@ -600,7 +596,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
} }
/* Must be called with intf_mutex held */ /* Must be called with intf_mutex held */
void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev) void mlx5_lag_remove(struct mlx5_core_dev *dev)
{ {
struct mlx5_lag *ldev; struct mlx5_lag *ldev;
int i; int i;
...@@ -620,8 +616,7 @@ void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev) ...@@ -620,8 +616,7 @@ void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev)
if (i == MLX5_MAX_PORTS) { if (i == MLX5_MAX_PORTS) {
if (ldev->nb.notifier_call) if (ldev->nb.notifier_call)
unregister_netdevice_notifier_dev_net(netdev, &ldev->nb, unregister_netdevice_notifier_net(&init_net, &ldev->nb);
&ldev->nn);
mlx5_lag_mp_cleanup(ldev); mlx5_lag_mp_cleanup(ldev);
cancel_delayed_work_sync(&ldev->bond_work); cancel_delayed_work_sync(&ldev->bond_work);
mlx5_lag_dev_free(ldev); mlx5_lag_dev_free(ldev);
......
...@@ -44,7 +44,6 @@ struct mlx5_lag { ...@@ -44,7 +44,6 @@ struct mlx5_lag {
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct delayed_work bond_work; struct delayed_work bond_work;
struct notifier_block nb; struct notifier_block nb;
struct netdev_net_notifier nn;
struct lag_mp lag_mp; struct lag_mp lag_mp;
}; };
......
...@@ -157,7 +157,7 @@ int mlx5_query_qcam_reg(struct mlx5_core_dev *mdev, u32 *qcam, ...@@ -157,7 +157,7 @@ int mlx5_query_qcam_reg(struct mlx5_core_dev *mdev, u32 *qcam,
u8 feature_group, u8 access_reg_group); u8 feature_group, u8 access_reg_group);
void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev); void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev);
void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev); void mlx5_lag_remove(struct mlx5_core_dev *dev);
int mlx5_irq_table_init(struct mlx5_core_dev *dev); int mlx5_irq_table_init(struct mlx5_core_dev *dev);
void mlx5_irq_table_cleanup(struct mlx5_core_dev *dev); void mlx5_irq_table_cleanup(struct mlx5_core_dev *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册