bonding: 802.3ad - fix agg_device_up
Subsystems (3)
PATCH 1/1 bonding: 802.3ad - fix agg_device_up
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.
drivers/net/bonding/bond_3ad.c +5 -2
@@ -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)); }/**
Signature · 2 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
Quoted 11 lines · Jiri Bohac
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 usesagg->slaveto find the state of the aggregator. Useagg->lag_ports->slaveinstead. The bug has been introduced by commit4cd6fe1c6483cde93e2ec91f58b7af9c9eea51ad.Signed-off-by Jiri Bohac <[email protected]>
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
Quoted 22 lines
drivers/net/bonding/bond_3ad.c +5
-2@@ -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)); }/** Signature · 2 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
David Miller
maintainerFrom: Jay Vosburgh <[email protected]>
Date: Tue, 19 Apr 2011 09:55:03 -0700
Quoted 14 lines
Quoted 11 lines · Jiri Bohac
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 usesagg->slaveto find the state of the aggregator. Useagg->lag_ports->slaveinstead. The bug has been introduced by commit4cd6fe1c6483cde93e2ec91f58b7af9c9eea51ad.Signed-off-by Jiri Bohac <[email protected]>
Quoted 7 lines
One additional note: port->slave can be NULL when the slave istransitioning in or out of the bond, but not when the port is part of an aggregator, so this usage should be safe.
-JSigned-off-by Jay Vosburgh <[email protected]>
Applied and queued up for -stable, thanks.