In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT, have ethsw check that the bridge port flags that are being set are supported when SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS is specified. Signed-off-by: Florian Fainelli <f.fainelli@xxxxxxxxx> --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 1b3943b71254..f788a9458b89 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -668,13 +668,16 @@ static int port_attr_stp_state_set(struct net_device *netdev, static int port_attr_br_flags_set(struct net_device *netdev, struct switchdev_trans *trans, - unsigned long flags) + unsigned long flags, bool pre_set) { struct ethsw_port_priv *port_priv = netdev_priv(netdev); int err = 0; - if (switchdev_trans_ph_prepare(trans)) + if (switchdev_trans_ph_prepare(trans) && pre_set) { + if (flags & ~(BR_LEARNING | BR_FLOOD)) + return -EOPNOTSUPP; return 0; + } /* Learning is enabled per switch */ err = ethsw_set_learning(port_priv->ethsw_data, flags & BR_LEARNING); @@ -691,6 +694,7 @@ static int swdev_port_attr_set(struct net_device *netdev, const struct switchdev_attr *attr, struct switchdev_trans *trans) { + bool pre_set = false; int err = 0; switch (attr->id) { @@ -698,9 +702,11 @@ static int swdev_port_attr_set(struct net_device *netdev, err = port_attr_stp_state_set(netdev, trans, attr->u.stp_state); break; + case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: + pre_set = true; /* fall through */ case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: err = port_attr_br_flags_set(netdev, trans, - attr->u.brport_flags); + attr->u.brport_flags, pre_set); break; case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: /* VLANs are supported by default */ -- 2.17.1