mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
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>
This commit is contained in:
parent
123338d7d4
commit
45035febc4
|
|
@ -2030,6 +2030,28 @@ static int dpaa2_switch_prevent_bridging_with_8021q_upper(struct net_device *net
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
|
||||||
|
struct net_device *upper_dev,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!br_vlan_enabled(upper_dev)) {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
|
||||||
|
if (err) {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
|
"Cannot join a bridge while VLAN uppers are present");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
|
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
|
||||||
unsigned long event, void *ptr)
|
unsigned long event, void *ptr)
|
||||||
{
|
{
|
||||||
|
|
@ -2050,18 +2072,11 @@ static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
|
||||||
if (!netif_is_bridge_master(upper_dev))
|
if (!netif_is_bridge_master(upper_dev))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!br_vlan_enabled(upper_dev)) {
|
err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
|
||||||
NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
|
upper_dev,
|
||||||
err = -EOPNOTSUPP;
|
extack);
|
||||||
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
|
|
||||||
if (err) {
|
|
||||||
NL_SET_ERR_MSG_MOD(extack,
|
|
||||||
"Cannot join a bridge while VLAN uppers are present");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NETDEV_CHANGEUPPER:
|
case NETDEV_CHANGEUPPER:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user