Commit 5fd2b0c0 authored by Simon Horman's avatar Simon Horman Committed by Greg Kroah-Hartman

rocker: handle non-bridge master change

[ Upstream commit a6e95cc7 ]

Master change notifications may occur other than when joining or
leaving a bridge, for example when being added to or removed from
a bond or Open vSwitch.

Previously in those cases rocker_port_bridge_leave() was called
which results in a null-pointer dereference as rocker_port->bridge_dev
is NULL because there is no bridge device.

This patch makes provision for doing nothing in such cases.

Fixes: 6c707945 ("rocker: implement L2 bridge offloading")
Acked-by: default avatarJiri Pirko <jiri@resnulli.us>
Acked-by: default avatarScott Feldman <sfeldma@gmail.com>
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c3d7204d
...@@ -4305,10 +4305,16 @@ static int rocker_port_master_changed(struct net_device *dev) ...@@ -4305,10 +4305,16 @@ static int rocker_port_master_changed(struct net_device *dev)
struct net_device *master = netdev_master_upper_dev_get(dev); struct net_device *master = netdev_master_upper_dev_get(dev);
int err = 0; int err = 0;
/* There are currently three cases handled here:
* 1. Joining a bridge
* 2. Leaving a previously joined bridge
* 3. Other, e.g. being added to or removed from a bond or openvswitch,
* in which case nothing is done
*/
if (master && master->rtnl_link_ops && if (master && master->rtnl_link_ops &&
!strcmp(master->rtnl_link_ops->kind, "bridge")) !strcmp(master->rtnl_link_ops->kind, "bridge"))
err = rocker_port_bridge_join(rocker_port, master); err = rocker_port_bridge_join(rocker_port, master);
else else if (rocker_port_is_bridged(rocker_port))
err = rocker_port_bridge_leave(rocker_port); err = rocker_port_bridge_leave(rocker_port);
return err; return 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