Skip to contentSkip to conversation

bonding: "primary_reselect" with "failure" is not working properly

PATCH Superseded Mazhar Rana 3 participants 3 messages Jul 2, 2015 1 message not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: "primary_reselect" with "failure" is not working properly

When "primary_reselect" is set to "failure", primary interface should not become active until current active slave is up. But if we set first member of bond device as a "primary" interface and "primary_reselect" is set to "failure" then whenever primary interface's link get back(up) it become active slave even if current active slave is still up.

With this patch, "bond_find_best_slave" will not traverse members if primary interface is not candidate for failover/reselection and current active slave is still up.

---
 drivers/net/bonding/bond_main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +9 -1
index 19eb990..ac71261 100644
@@ -715,7 +715,7 @@ static bool bond_should_change_active(struct bonding *bond)
  */
 static struct slave *bond_find_best_slave(struct bonding *bond)
 {
-	struct slave *slave, *bestslave = NULL, *primary;
+	struct slave *slave, *bestslave = NULL, *primary, *curr;
 	struct list_head *iter;
 	int mintime = bond->params.updelay;
 
@@ -724,6 +724,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
 	    bond_should_change_active(bond))
 		return primary;
 
+	/* We are here means primary interface is not candidate for
+	 * reslection/failover. If currenet active slave is still up
+	 * then there is no meaning to traverse  members.
+	 */
+	curr = rtnl_dereference(bond->curr_active_slave);
+	if (curr && curr->link == BOND_LINK_UP)
+		return bond->curr_active_slave;
+
 	bond_for_each_slave(bond, slave, iter) {
 		if (slave->link == BOND_LINK_UP)
 			return slave;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 30 lines · Mazhar Rana

When "primary_reselect" is set to "failure", primary interface should not become active until current active slave is up. But if we set first member of bond device as a "primary" interface and "primary_reselect" is set to "failure" then whenever primary interface's link get back(up) it become active slave even if current active slave is still up.

With this patch, "bond_find_best_slave" will not traverse members if primary interface is not candidate for failover/reselection and current active slave is still up.

---
 drivers/net/bonding/bond_main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
index 19eb990..ac71261 100644
@@ -715,7 +715,7 @@ static bool bond_should_change_active(struct bonding *bond)
  */
 static struct slave *bond_find_best_slave(struct bonding *bond)
 {
-	struct slave *slave, *bestslave = NULL, *primary;
+	struct slave *slave, *bestslave = NULL, *primary, *curr;
 	struct list_head *iter;
 	int mintime = bond->params.updelay;
 

drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 731

Quoted 8 lines
drivers/net/bonding/bond_main.c +5 -0
@@ -724,6 +724,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
 	    bond_should_change_active(bond))
 		return primary;
 
+	/* We are here means primary interface is not candidate for
+	 * reslection/failover. If currenet active slave is still up
+	 * then there is no meaning to traverse  members.
+	 */
+	curr = rtnl_dereference(bond->curr_active_slave);

Here you carefully use rtnl_dereference(bond->curr_active_slave)

(This is good)

drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 733

Quoted 2 lines
drivers/net/bonding/bond_main.c +2 -0
+	if (curr && curr->link == BOND_LINK_UP)
+		return bond->curr_active_slave;

But here you return bond->curr_active_slave
instead of curr

Quoted 4 lines
drivers/net/bonding/bond_main.c +1 -0
+
 	bond_for_each_slave(bond, slave, iter) {
 		if (slave->link == BOND_LINK_UP)
 			return slave;

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw

Emails encoded in HTML will not reach the mailing list, only plain ASCII text is accepted.