Skip to contentSkip to conversation

bonding: fix link down handling in 802.3ad mode

PATCH Applied Stephen Hemminger 3 participants 3 messages May 15, 2009 – May 18, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: fix link down handling in 802.3ad mode

One of the purposes of bonding is to allow for redundant links, and failover correctly if the cable is pulled. If all the members of a bonded device have no carrier present, the bonded device itself needs to report no carrier present to user space so management tools (like routing daemons) can respond.

Bonding in 802.3ad mode does not work correctly for this because it incorrectly chooses a link that is down as a possible aggregator.

---
This patch is a bug fix and should go into 2.6.30

drivers/net/bonding/bond_3ad.c +8 -3
@@ -1465,6 +1465,12 @@ static struct aggregator *ad_agg_selecti
 	return best;
 }
 
+static int agg_device_up(const struct aggregator *agg)
+{
+	return (netif_running(agg->slave->dev) &&
+		netif_carrier_ok(agg->slave->dev));
+}
+
 /**
  * ad_agg_selection_logic - select an aggregation group for a team
  * @aggregator: the aggregator we're looking at
@@ -1496,14 +1502,13 @@ static void ad_agg_selection_logic(struc
 	struct port *port;
 
 	origin = agg;
-
 	active = __get_active_agg(agg);
-	best = active;
+	best = (active && agg_device_up(active)) ? active : NULL;
 
 	do {
 		agg->is_active = 0;
 
-		if (agg->num_of_ports)
+		if (agg->num_of_ports && agg_device_up(agg))
 			best = ad_agg_selection_test(best, agg);
 
 	} while ((agg = __get_next_agg(agg)));
#1 lore raw
Quoted 9 lines · Stephen Hemminger

One of the purposes of bonding is to allow for redundant links, and failover correctly if the cable is pulled. If all the members of a bonded device have no carrier present, the bonded device itself needs to report no carrier present to user space so management tools (like routing daemons) can respond.

Bonding in 802.3ad mode does not work correctly for this because it incorrectly chooses a link that is down as a possible aggregator.

Looks good. I tested this after putting some printks in the agg
selection logic, and I don't see any undesirable side effects.

	-J
Quoted 35 lines

---
This patch is a bug fix and should go into 2.6.30

drivers/net/bonding/bond_3ad.c +8 -3
@@ -1465,6 +1465,12 @@ static struct aggregator *ad_agg_selecti
 	return best;
 }
 
+static int agg_device_up(const struct aggregator *agg)
+{
+	return (netif_running(agg->slave->dev) &&
+		netif_carrier_ok(agg->slave->dev));
+}
+
 /**
 * ad_agg_selection_logic - select an aggregation group for a team
 * @aggregator: the aggregator we're looking at
@@ -1496,14 +1502,13 @@ static void ad_agg_selection_logic(struc
 	struct port *port;
 
 	origin = agg;
-
 	active = __get_active_agg(agg);
-	best = active;
+	best = (active && agg_device_up(active)) ? active : NULL;
 
 	do {
 		agg->is_active = 0;
 
-		if (agg->num_of_ports)
+		if (agg->num_of_ports && agg_device_up(agg))
 			best = ad_agg_selection_test(best, agg);
 
 	} while ((agg = __get_next_agg(agg)));
maintainer Applied
#2 lore raw

From: Jay Vosburgh <[email protected]>
Date: Fri, 15 May 2009 12:35:55 -0700

Quoted 10 lines
Quoted 8 lines · Stephen Hemminger

One of the purposes of bonding is to allow for redundant links, and failover correctly if the cable is pulled. If all the members of a bonded device have no carrier present, the bonded device itself needs to report no carrier present to user space so management tools (like routing daemons) can respond.

Bonding in 802.3ad mode does not work correctly for this because it incorrectly chooses a link that is down as a possible aggregator.

Quoted 6 lines
Quoted 1 line

Looks good. I tested this after putting some printks in the agg
selection logic, and I don't see any undesirable side effects.

Applied, thanks everyone.