All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bonding: 802.3ad - fix agg_device_up
@ 2011-04-19 12:09 Jiri Bohac
  2011-04-19 16:55 ` Jay Vosburgh
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Bohac @ 2011-04-19 12:09 UTC (permalink / raw)
  To: netdev; +Cc: Jay Vosburgh, Andy Gospodarek, Stephen Hemminger

The slave member of struct aggregator does not necessarily point
to a slave which is part of the aggregator. It points to the
slave structure containing the aggregator structure, while
completely different slaves (or no slaves at all) may be part of
the aggregator.

The agg_device_up() function wrongly uses agg->slave to find the state of the
aggregator.  Use agg->lag_ports->slave instead. The bug has been
introduced by commit 4cd6fe1c6483cde93e2ec91f58b7af9c9eea51ad.

Signed-off-by: Jiri Bohac <jbohac@suse.cz>

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 494bf96..31912f1 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1482,8 +1482,11 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
 
 static int agg_device_up(const struct aggregator *agg)
 {
-	return (netif_running(agg->slave->dev) &&
-		netif_carrier_ok(agg->slave->dev));
+	struct port *port = agg->lag_ports;
+	if (!port)
+		return 0;
+	return (netif_running(port->slave->dev) &&
+		netif_carrier_ok(port->slave->dev));
 }
 
 /**
-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ


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

* Re: [PATCH] bonding: 802.3ad - fix agg_device_up
  2011-04-19 12:09 [PATCH] bonding: 802.3ad - fix agg_device_up Jiri Bohac
@ 2011-04-19 16:55 ` Jay Vosburgh
  2011-04-20  8:45   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Jay Vosburgh @ 2011-04-19 16:55 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: netdev, Andy Gospodarek, Stephen Hemminger

Jiri Bohac <jbohac@suse.cz> wrote:

>The slave member of struct aggregator does not necessarily point
>to a slave which is part of the aggregator. It points to the
>slave structure containing the aggregator structure, while
>completely different slaves (or no slaves at all) may be part of
>the aggregator.
>
>The agg_device_up() function wrongly uses agg->slave to find the state of the
>aggregator.  Use agg->lag_ports->slave instead. The bug has been
>introduced by commit 4cd6fe1c6483cde93e2ec91f58b7af9c9eea51ad.
>
>Signed-off-by: Jiri Bohac <jbohac@suse.cz>

	One additional note: port->slave can be NULL when the slave is
transitioning in or out of the bond, but not when the port is part of an
aggregator, so this usage should be safe.

	-J

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>


>diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
>index 494bf96..31912f1 100644
>--- a/drivers/net/bonding/bond_3ad.c
>+++ b/drivers/net/bonding/bond_3ad.c
>@@ -1482,8 +1482,11 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
>
> static int agg_device_up(const struct aggregator *agg)
> {
>-	return (netif_running(agg->slave->dev) &&
>-		netif_carrier_ok(agg->slave->dev));
>+	struct port *port = agg->lag_ports;
>+	if (!port)
>+		return 0;
>+	return (netif_running(port->slave->dev) &&
>+		netif_carrier_ok(port->slave->dev));
> }
>
> /**
>-- 
>Jiri Bohac <jbohac@suse.cz>
>SUSE Labs, SUSE CZ
>

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

* Re: [PATCH] bonding: 802.3ad - fix agg_device_up
  2011-04-19 16:55 ` Jay Vosburgh
@ 2011-04-20  8:45   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-04-20  8:45 UTC (permalink / raw)
  To: fubar; +Cc: jbohac, netdev, andy, shemminger

From: Jay Vosburgh <fubar@us.ibm.com>
Date: Tue, 19 Apr 2011 09:55:03 -0700

> Jiri Bohac <jbohac@suse.cz> wrote:
> 
>>The slave member of struct aggregator does not necessarily point
>>to a slave which is part of the aggregator. It points to the
>>slave structure containing the aggregator structure, while
>>completely different slaves (or no slaves at all) may be part of
>>the aggregator.
>>
>>The agg_device_up() function wrongly uses agg->slave to find the state of the
>>aggregator.  Use agg->lag_ports->slave instead. The bug has been
>>introduced by commit 4cd6fe1c6483cde93e2ec91f58b7af9c9eea51ad.
>>
>>Signed-off-by: Jiri Bohac <jbohac@suse.cz>
> 
> 	One additional note: port->slave can be NULL when the slave is
> transitioning in or out of the bond, but not when the port is part of an
> aggregator, so this usage should be safe.
> 
> 	-J
> 
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2011-04-20  8:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19 12:09 [PATCH] bonding: 802.3ad - fix agg_device_up Jiri Bohac
2011-04-19 16:55 ` Jay Vosburgh
2011-04-20  8:45   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.