Skip to content

Commit e387f7d

Browse files
jpirkodavem330
authored andcommitted
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: d48834f ("mlx5: Use dev_net netdevice notifier registrations") Signed-off-by: Jiri Pirko <[email protected]> Tested-by: Aya Levin <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3a12500 commit e387f7d

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5147,7 +5147,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
51475147

51485148
static void mlx5e_nic_disable(struct mlx5e_priv *priv)
51495149
{
5150-
struct net_device *netdev = priv->netdev;
51515150
struct mlx5_core_dev *mdev = priv->mdev;
51525151

51535152
#ifdef CONFIG_MLX5_CORE_EN_DCB
@@ -5168,7 +5167,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
51685167
mlx5e_monitor_counter_cleanup(priv);
51695168

51705169
mlx5e_disable_async_events(priv);
5171-
mlx5_lag_remove(mdev, netdev);
5170+
mlx5_lag_remove(mdev);
51725171
}
51735172

51745173
int mlx5e_update_nic_rx(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,6 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
18611861

18621862
static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
18631863
{
1864-
struct net_device *netdev = priv->netdev;
18651864
struct mlx5_core_dev *mdev = priv->mdev;
18661865
struct mlx5e_rep_priv *rpriv = priv->ppriv;
18671866

@@ -1870,7 +1869,7 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
18701869
#endif
18711870
mlx5_notifier_unregister(mdev, &priv->events_nb);
18721871
cancel_work_sync(&rpriv->uplink_priv.reoffload_flows_work);
1873-
mlx5_lag_remove(mdev, netdev);
1872+
mlx5_lag_remove(mdev);
18741873
}
18751874

18761875
static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);

drivers/net/ethernet/mellanox/mlx5/core/lag.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ static int mlx5_lag_netdev_event(struct notifier_block *this,
464464
struct mlx5_lag *ldev;
465465
int changed = 0;
466466

467-
if (!net_eq(dev_net(ndev), &init_net))
468-
return NOTIFY_DONE;
469-
470467
if ((event != NETDEV_CHANGEUPPER) && (event != NETDEV_CHANGELOWERSTATE))
471468
return NOTIFY_DONE;
472469

@@ -586,8 +583,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
586583

587584
if (!ldev->nb.notifier_call) {
588585
ldev->nb.notifier_call = mlx5_lag_netdev_event;
589-
if (register_netdevice_notifier_dev_net(netdev, &ldev->nb,
590-
&ldev->nn)) {
586+
if (register_netdevice_notifier_net(&init_net, &ldev->nb)) {
591587
ldev->nb.notifier_call = NULL;
592588
mlx5_core_err(dev, "Failed to register LAG netdev notifier\n");
593589
}
@@ -600,7 +596,7 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
600596
}
601597

602598
/* Must be called with intf_mutex held */
603-
void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev)
599+
void mlx5_lag_remove(struct mlx5_core_dev *dev)
604600
{
605601
struct mlx5_lag *ldev;
606602
int i;
@@ -620,8 +616,7 @@ void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev)
620616

621617
if (i == MLX5_MAX_PORTS) {
622618
if (ldev->nb.notifier_call)
623-
unregister_netdevice_notifier_dev_net(netdev, &ldev->nb,
624-
&ldev->nn);
619+
unregister_netdevice_notifier_net(&init_net, &ldev->nb);
625620
mlx5_lag_mp_cleanup(ldev);
626621
cancel_delayed_work_sync(&ldev->bond_work);
627622
mlx5_lag_dev_free(ldev);

drivers/net/ethernet/mellanox/mlx5/core/lag.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct mlx5_lag {
4444
struct workqueue_struct *wq;
4545
struct delayed_work bond_work;
4646
struct notifier_block nb;
47-
struct netdev_net_notifier nn;
4847
struct lag_mp lag_mp;
4948
};
5049

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int mlx5_query_qcam_reg(struct mlx5_core_dev *mdev, u32 *qcam,
157157
u8 feature_group, u8 access_reg_group);
158158

159159
void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev);
160-
void mlx5_lag_remove(struct mlx5_core_dev *dev, struct net_device *netdev);
160+
void mlx5_lag_remove(struct mlx5_core_dev *dev);
161161

162162
int mlx5_irq_table_init(struct mlx5_core_dev *dev);
163163
void mlx5_irq_table_cleanup(struct mlx5_core_dev *dev);

0 commit comments

Comments
 (0)