Skip to content

Commit 15f8f16

Browse files
w1ldptrSaeed Mahameed
authored and
Saeed Mahameed
committed
net/mlx5: Bridge, verify LAG state when adding bond to bridge
Mlx5 LAG is initialized asynchronously on a workqueue which means that for a brief moment after setting mlx5 UL representors as lower devices of a bond netdevice the LAG itself is not fully initialized in the driver. When adding such bond device to a bridge mlx5 bridge code will not consider it as offload-capable, skip creating necessary bookkeeping and fail any further bridge offload-related commands with it (setting VLANs, offloading FDBs, etc.). In order to make the error explicit during bridge initialization stage implement the code that detects such condition during NETDEV_PRECHANGEUPPER event and returns an error. Fixes: ff9b752 ("net/mlx5: Bridge, support LAG") Signed-off-by: Vlad Buslov <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 27c064a commit 15f8f16

File tree

1 file changed

+31
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en/rep

1 file changed

+31
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,44 @@ static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr
164164
return err;
165165
}
166166

167+
static int
168+
mlx5_esw_bridge_changeupper_validate_netdev(void *ptr)
169+
{
170+
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
171+
struct netdev_notifier_changeupper_info *info = ptr;
172+
struct net_device *upper = info->upper_dev;
173+
struct net_device *lower;
174+
struct list_head *iter;
175+
176+
if (!netif_is_bridge_master(upper) || !netif_is_lag_master(dev))
177+
return 0;
178+
179+
netdev_for_each_lower_dev(dev, lower, iter) {
180+
struct mlx5_core_dev *mdev;
181+
struct mlx5e_priv *priv;
182+
183+
if (!mlx5e_eswitch_rep(lower))
184+
continue;
185+
186+
priv = netdev_priv(lower);
187+
mdev = priv->mdev;
188+
if (!mlx5_lag_is_active(mdev))
189+
return -EAGAIN;
190+
if (!mlx5_lag_is_shared_fdb(mdev))
191+
return -EOPNOTSUPP;
192+
}
193+
194+
return 0;
195+
}
196+
167197
static int mlx5_esw_bridge_switchdev_port_event(struct notifier_block *nb,
168198
unsigned long event, void *ptr)
169199
{
170200
int err = 0;
171201

172202
switch (event) {
173203
case NETDEV_PRECHANGEUPPER:
204+
err = mlx5_esw_bridge_changeupper_validate_netdev(ptr);
174205
break;
175206

176207
case NETDEV_CHANGEUPPER:

0 commit comments

Comments
 (0)