Skip to content

Commit 45035fe

Browse files
vladimirolteandavem330
authored andcommitted
net: dpaa2-switch: refactor prechangeupper sanity checks
Make more room for some extra code in the NETDEV_PRECHANGEUPPER handler by moving what already exists into a dedicated function. Cc: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 123338d commit 45035fe

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,28 @@ static int dpaa2_switch_prevent_bridging_with_8021q_upper(struct net_device *net
20302030
return 0;
20312031
}
20322032

2033+
static int
2034+
dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
2035+
struct net_device *upper_dev,
2036+
struct netlink_ext_ack *extack)
2037+
{
2038+
int err;
2039+
2040+
if (!br_vlan_enabled(upper_dev)) {
2041+
NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
2042+
return -EOPNOTSUPP;
2043+
}
2044+
2045+
err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
2046+
if (err) {
2047+
NL_SET_ERR_MSG_MOD(extack,
2048+
"Cannot join a bridge while VLAN uppers are present");
2049+
return 0;
2050+
}
2051+
2052+
return 0;
2053+
}
2054+
20332055
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
20342056
unsigned long event, void *ptr)
20352057
{
@@ -2050,18 +2072,11 @@ static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
20502072
if (!netif_is_bridge_master(upper_dev))
20512073
break;
20522074

2053-
if (!br_vlan_enabled(upper_dev)) {
2054-
NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
2055-
err = -EOPNOTSUPP;
2056-
goto out;
2057-
}
2058-
2059-
err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
2060-
if (err) {
2061-
NL_SET_ERR_MSG_MOD(extack,
2062-
"Cannot join a bridge while VLAN uppers are present");
2075+
err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
2076+
upper_dev,
2077+
extack);
2078+
if (err)
20632079
goto out;
2064-
}
20652080

20662081
break;
20672082
case NETDEV_CHANGEUPPER:

0 commit comments

Comments
 (0)