Skip to content

Commit 3799b46

Browse files
shayshyiNipaLocal
authored andcommitted
net/mlx5: Lag, add net namespace support
Update the LAG implementation to support net namespace isolation. With recent changes to the devcom framework allowing namespace-aware matching, the LAG layer is updated to register devcom clients with the associated net namespace. This ensures that LAG formation only occurs between mlx5 interfaces that reside in the same namespace. This change ensures that devices in different namespaces do not interfere with each other's LAG setup and behavior. For example, if two PCI PFs are in the same namespace, they are eligible to form a hardware LAG. In addition, reload behavior for LAG is adjusted to handle namespace contexts appropriately. Signed-off-by: Shay Drory <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Reviewed-by: Parav Pandit <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent a8a398d commit 3799b46

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
204204
return 0;
205205
}
206206

207-
if (mlx5_lag_is_active(dev)) {
208-
NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
209-
return -EOPNOTSUPP;
210-
}
211-
212207
if (mlx5_core_is_mp_slave(dev)) {
213208
NL_SET_ERR_MSG_MOD(extack, "reload is unsupported for multi port slave");
214209
return -EOPNOTSUPP;

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/mlx5/driver.h>
3636
#include <linux/mlx5/eswitch.h>
3737
#include <linux/mlx5/vport.h>
38+
#include "lib/mlx5.h"
3839
#include "lib/devcom.h"
3940
#include "mlx5_core.h"
4041
#include "eswitch.h"
@@ -231,9 +232,13 @@ static void mlx5_do_bond_work(struct work_struct *work);
231232
static void mlx5_ldev_free(struct kref *ref)
232233
{
233234
struct mlx5_lag *ldev = container_of(ref, struct mlx5_lag, ref);
235+
struct net *net;
236+
237+
if (ldev->nb.notifier_call) {
238+
net = read_pnet(&ldev->net);
239+
unregister_netdevice_notifier_net(net, &ldev->nb);
240+
}
234241

235-
if (ldev->nb.notifier_call)
236-
unregister_netdevice_notifier_net(&init_net, &ldev->nb);
237242
mlx5_lag_mp_cleanup(ldev);
238243
cancel_delayed_work_sync(&ldev->bond_work);
239244
destroy_workqueue(ldev->wq);
@@ -271,7 +276,8 @@ static struct mlx5_lag *mlx5_lag_dev_alloc(struct mlx5_core_dev *dev)
271276
INIT_DELAYED_WORK(&ldev->bond_work, mlx5_do_bond_work);
272277

273278
ldev->nb.notifier_call = mlx5_lag_netdev_event;
274-
if (register_netdevice_notifier_net(&init_net, &ldev->nb)) {
279+
write_pnet(&ldev->net, mlx5_core_net(dev));
280+
if (register_netdevice_notifier_net(read_pnet(&ldev->net), &ldev->nb)) {
275281
ldev->nb.notifier_call = NULL;
276282
mlx5_core_err(dev, "Failed to register LAG netdev notifier\n");
277283
}
@@ -1413,6 +1419,8 @@ static int mlx5_lag_register_hca_devcom_comp(struct mlx5_core_dev *dev)
14131419
{
14141420
struct mlx5_devcom_match_attr attr = {
14151421
.key.val = mlx5_query_nic_system_image_guid(dev),
1422+
.flags = MLX5_DEVCOM_MATCH_FLAGS_NS,
1423+
.net = mlx5_core_net(dev),
14161424
};
14171425

14181426
/* This component is use to sync adding core_dev to lag_dev and to sync

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct mlx5_lag {
6767
struct workqueue_struct *wq;
6868
struct delayed_work bond_work;
6969
struct notifier_block nb;
70+
possible_net_t net;
7071
struct lag_mp lag_mp;
7172
struct mlx5_lag_port_sel port_sel;
7273
/* Protect lag fields/state changes */

0 commit comments

Comments
 (0)