Netdev List
 help / color / mirror / Atom feed
* [PATCH net] rocker: handle non-bridge master change
@ 2015-03-23  6:13 Simon Horman
  2015-03-23  6:23 ` Jiri Pirko
  2015-03-23 18:43 ` Scott Feldman
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Horman @ 2015-03-23  6:13 UTC (permalink / raw)
  To: Jiri Pirko, Scott Feldman, David S. Miller; +Cc: netdev, Simon Horman

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: 6c7079450071f ("rocker: implement L2 bridge offloading")
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/ethernet/rocker/rocker.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 9fb6948..0390714 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -4468,10 +4468,16 @@ static int rocker_port_master_changed(struct net_device *dev)
 	struct net_device *master = netdev_master_upper_dev_get(dev);
 	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 &&
 	    !strcmp(master->rtnl_link_ops->kind, "bridge"))
 		err = rocker_port_bridge_join(rocker_port, master);
-	else
+	else if (rocker_port->bridge_dev)
 		err = rocker_port_bridge_leave(rocker_port);
 
 	return err;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rocker: handle non-bridge master change
  2015-03-23  6:13 [PATCH net] rocker: handle non-bridge master change Simon Horman
@ 2015-03-23  6:23 ` Jiri Pirko
  2015-03-23  6:53   ` Simon Horman
  2015-03-23 18:43 ` Scott Feldman
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2015-03-23  6:23 UTC (permalink / raw)
  To: Simon Horman; +Cc: Scott Feldman, David S. Miller, netdev

Mon, Mar 23, 2015 at 07:13:21AM CET, simon.horman@netronome.com wrote:
>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: 6c7079450071f ("rocker: implement L2 bridge offloading")
>Signed-off-by: Simon Horman <simon.horman@netronome.com>

Acked-by: Jiri Pirko <jiri@resnulli.us>

Thanks Simon.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rocker: handle non-bridge master change
  2015-03-23  6:23 ` Jiri Pirko
@ 2015-03-23  6:53   ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2015-03-23  6:53 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: Scott Feldman, David S. Miller, netdev

On Mon, Mar 23, 2015 at 07:23:09AM +0100, Jiri Pirko wrote:
> Mon, Mar 23, 2015 at 07:13:21AM CET, simon.horman@netronome.com wrote:
> >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: 6c7079450071f ("rocker: implement L2 bridge offloading")
> >Signed-off-by: Simon Horman <simon.horman@netronome.com>
> 
> Acked-by: Jiri Pirko <jiri@resnulli.us>

I would like to clarify that I lightly tested this patch to the
extent that I no longer see a null-pointer dereference.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rocker: handle non-bridge master change
  2015-03-23  6:13 [PATCH net] rocker: handle non-bridge master change Simon Horman
  2015-03-23  6:23 ` Jiri Pirko
@ 2015-03-23 18:43 ` Scott Feldman
  1 sibling, 0 replies; 4+ messages in thread
From: Scott Feldman @ 2015-03-23 18:43 UTC (permalink / raw)
  To: Simon Horman; +Cc: Jiri Pirko, David S. Miller, Netdev

On Sun, Mar 22, 2015 at 11:13 PM, Simon Horman
<simon.horman@netronome.com> wrote:
> 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: 6c7079450071f ("rocker: implement L2 bridge offloading")
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---
>  drivers/net/ethernet/rocker/rocker.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
> index 9fb6948..0390714 100644
> --- a/drivers/net/ethernet/rocker/rocker.c
> +++ b/drivers/net/ethernet/rocker/rocker.c
> @@ -4468,10 +4468,16 @@ static int rocker_port_master_changed(struct net_device *dev)
>         struct net_device *master = netdev_master_upper_dev_get(dev);
>         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 &&
>             !strcmp(master->rtnl_link_ops->kind, "bridge"))
>                 err = rocker_port_bridge_join(rocker_port, master);
> -       else
> +       else if (rocker_port->bridge_dev)
>                 err = rocker_port_bridge_leave(rocker_port);

Please send v2 that uses rocker_port_is_bridged(), otherwise looks
good, thanks Simon.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-23 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-23  6:13 [PATCH net] rocker: handle non-bridge master change Simon Horman
2015-03-23  6:23 ` Jiri Pirko
2015-03-23  6:53   ` Simon Horman
2015-03-23 18:43 ` Scott Feldman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox