Skip to content

Commit 26a4ea0

Browse files
Elad Razdavem330
authored andcommitted
mlxsw: Disable vlan_filtering for non .1D bridge
When a port is bridged, the bridge must be vlan aware bridge (.1Q) or the bridging should be on top of VLAN interfaces (.1D bridge). Signed-off-by: Elad Raz <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e4a1305 commit 26a4ea0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,22 @@ static int mlxsw_sp_port_attr_br_ageing_set(struct mlxsw_sp_port *mlxsw_sp_port,
299299
return mlxsw_sp_ageing_set(mlxsw_sp, ageing_time);
300300
}
301301

302+
static int mlxsw_sp_port_attr_br_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port,
303+
struct switchdev_trans *trans,
304+
struct net_device *orig_dev,
305+
bool vlan_enabled)
306+
{
307+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
308+
309+
/* SWITCHDEV_TRANS_PREPARE phase */
310+
if ((!vlan_enabled) && (mlxsw_sp->master_bridge.dev == orig_dev)) {
311+
netdev_err(mlxsw_sp_port->dev, "Bridge must be vlan-aware\n");
312+
return -EINVAL;
313+
}
314+
315+
return 0;
316+
}
317+
302318
static int mlxsw_sp_port_attr_set(struct net_device *dev,
303319
const struct switchdev_attr *attr,
304320
struct switchdev_trans *trans)
@@ -323,6 +339,11 @@ static int mlxsw_sp_port_attr_set(struct net_device *dev,
323339
err = mlxsw_sp_port_attr_br_ageing_set(mlxsw_sp_port, trans,
324340
attr->u.ageing_time);
325341
break;
342+
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
343+
err = mlxsw_sp_port_attr_br_vlan_set(mlxsw_sp_port, trans,
344+
attr->orig_dev,
345+
attr->u.vlan_filtering);
346+
break;
326347
default:
327348
err = -EOPNOTSUPP;
328349
break;

0 commit comments

Comments
 (0)