Commit 3d5048cc authored by Vadym Kochan's avatar Vadym Kochan Committed by David S. Miller

net: marvell: prestera: move netdev topology validation to prestera_main

Move handling of PRECHANGEUPPER event from prestera_switchdev to
prestera_main which is responsible for basic netdev events handling
and routing them to related module.
Signed-off-by: default avatarVadym Kochan <vkochan@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 950fd045
......@@ -508,13 +508,36 @@ struct prestera_port *prestera_port_dev_lower_find(struct net_device *dev)
static int prestera_netdev_port_event(struct net_device *dev,
unsigned long event, void *ptr)
{
struct netdev_notifier_changeupper_info *info = ptr;
struct netlink_ext_ack *extack;
struct net_device *upper;
extack = netdev_notifier_info_to_extack(&info->info);
upper = info->upper_dev;
switch (event) {
case NETDEV_PRECHANGEUPPER:
if (!netif_is_bridge_master(upper)) {
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
return -EINVAL;
}
if (!info->linking)
break;
if (netdev_has_any_upper_dev(upper)) {
NL_SET_ERR_MSG_MOD(extack, "Upper device is already enslaved");
return -EINVAL;
}
break;
case NETDEV_CHANGEUPPER:
if (netif_is_bridge_master(upper))
return prestera_bridge_port_event(dev, event, ptr);
default:
return 0;
break;
}
return 0;
}
static int prestera_netdev_event_handler(struct notifier_block *nb,
......
......@@ -537,35 +537,15 @@ int prestera_bridge_port_event(struct net_device *dev, unsigned long event,
void *ptr)
{
struct netdev_notifier_changeupper_info *info = ptr;
struct netlink_ext_ack *extack;
struct prestera_port *port;
struct net_device *upper;
int err;
extack = netdev_notifier_info_to_extack(&info->info);
port = netdev_priv(dev);
upper = info->upper_dev;
switch (event) {
case NETDEV_PRECHANGEUPPER:
if (!netif_is_bridge_master(upper)) {
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
return -EINVAL;
}
if (!info->linking)
break;
if (netdev_has_any_upper_dev(upper)) {
NL_SET_ERR_MSG_MOD(extack, "Upper device is already enslaved");
return -EINVAL;
}
break;
case NETDEV_CHANGEUPPER:
if (!netif_is_bridge_master(upper))
break;
if (info->linking) {
err = prestera_port_bridge_join(port, upper);
if (err)
......
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