Commit 686ed304 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

rocker: use change upper info

Since now information about changed upper is passed along, benefit from
that and use this info directly.

This also fixes possible issues that could happen when non-master device
is added (current code does not distinguish between master and non-master
upper device).
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: Scott Feldman <sfeldma@gmail.com
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb4bf214
...@@ -5326,46 +5326,61 @@ static int rocker_port_ovs_changed(struct rocker_port *rocker_port, ...@@ -5326,46 +5326,61 @@ static int rocker_port_ovs_changed(struct rocker_port *rocker_port,
return err; return err;
} }
static int rocker_port_master_changed(struct net_device *dev) static int rocker_port_master_linked(struct rocker_port *rocker_port,
struct net_device *master)
{
int err = 0;
if (netif_is_bridge_master(master))
err = rocker_port_bridge_join(rocker_port, master);
else if (netif_is_ovs_master(master))
err = rocker_port_ovs_changed(rocker_port, master);
return err;
}
static int rocker_port_master_unlinked(struct rocker_port *rocker_port)
{ {
struct rocker_port *rocker_port = netdev_priv(dev);
struct net_device *master = netdev_master_upper_dev_get(dev);
int err = 0; int err = 0;
/* N.B: Do nothing if the type of master is not supported */ if (rocker_port_is_bridged(rocker_port))
if (master) {
if (netif_is_bridge_master(master))
err = rocker_port_bridge_join(rocker_port, master);
else if (netif_is_ovs_master(master))
err = rocker_port_ovs_changed(rocker_port, master);
} else if (rocker_port_is_bridged(rocker_port)) {
err = rocker_port_bridge_leave(rocker_port); err = rocker_port_bridge_leave(rocker_port);
} else if (rocker_port_is_ovsed(rocker_port)) { else if (rocker_port_is_ovsed(rocker_port))
err = rocker_port_ovs_changed(rocker_port, NULL); err = rocker_port_ovs_changed(rocker_port, NULL);
}
return err; return err;
} }
static int rocker_netdevice_event(struct notifier_block *unused, static int rocker_netdevice_event(struct notifier_block *unused,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct net_device *dev; struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_changeupper_info *info;
struct rocker_port *rocker_port;
int err; int err;
if (!rocker_port_dev_check(dev))
return NOTIFY_DONE;
switch (event) { switch (event) {
case NETDEV_CHANGEUPPER: case NETDEV_CHANGEUPPER:
dev = netdev_notifier_info_to_dev(ptr); info = ptr;
if (!rocker_port_dev_check(dev)) if (!info->master)
return NOTIFY_DONE; goto out;
err = rocker_port_master_changed(dev); rocker_port = netdev_priv(dev);
if (err) if (info->linking) {
netdev_warn(dev, err = rocker_port_master_linked(rocker_port,
"failed to reflect master change (err %d)\n", info->upper_dev);
err); if (err)
netdev_warn(dev, "failed to reflect master linked (err %d)\n",
err);
} else {
err = rocker_port_master_unlinked(rocker_port);
if (err)
netdev_warn(dev, "failed to reflect master unlinked (err %d)\n",
err);
}
break; break;
} }
out:
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
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