Commit 4ede74e7 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: refactor the prechangeupper sanity checks into a dedicated function

We need to add more logic to the DSA NETDEV_PRECHANGEUPPER event
handler, more exactly we need to request an unsync of switchdev objects.
In order to fit more code, refactor the existing logic into a helper.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7e8c1858
......@@ -2166,20 +2166,16 @@ dsa_slave_check_8021q_upper(struct net_device *dev,
return NOTIFY_DONE;
}
static int dsa_slave_netdevice_event(struct notifier_block *nb,
unsigned long event, void *ptr)
static int
dsa_slave_prechangeupper_sanity_check(struct net_device *dev,
struct netdev_notifier_changeupper_info *info)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
switch (event) {
case NETDEV_PRECHANGEUPPER: {
struct netdev_notifier_changeupper_info *info = ptr;
struct dsa_switch *ds;
struct dsa_port *dp;
int err;
if (!dsa_slave_dev_check(dev))
return dsa_prevent_bridging_8021q_upper(dev, ptr);
return dsa_prevent_bridging_8021q_upper(dev, info);
dp = dsa_slave_to_port(dev);
ds = dp->ds;
......@@ -2191,7 +2187,25 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb,
}
if (is_vlan_dev(info->upper_dev))
return dsa_slave_check_8021q_upper(dev, ptr);
return dsa_slave_check_8021q_upper(dev, info);
return NOTIFY_DONE;
}
static int dsa_slave_netdevice_event(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
switch (event) {
case NETDEV_PRECHANGEUPPER: {
struct netdev_notifier_changeupper_info *info = ptr;
int err;
err = dsa_slave_prechangeupper_sanity_check(dev, info);
if (err != NOTIFY_DONE)
return err;
break;
}
case NETDEV_CHANGEUPPER:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment