Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037AbbGBMIM (ORCPT ); Thu, 2 Jul 2015 08:08:12 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:35236 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753387AbbGBMHs (ORCPT ); Thu, 2 Jul 2015 08:07:48 -0400 From: Mazhar Rana To: netdev@vger.kernel.org, j.vosburgh@gmail.com, vfalico@gmail.com, gospo@cumulusnetworks.com Cc: Mazhar Rana , davem@davemloft.net, sanket.shah@cyberoam.com, mazhar.rana@cyberoam.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] bonding: "primary_reselect" with "failure" is not working properly Date: Thu, 2 Jul 2015 17:37:19 +0530 Message-Id: <1435838839-21233-1-git-send-email-ranamazharp@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2091 Lines: 54 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. Signed-off-by: Mazhar Rana Reviewed-by: Sanket Shah --- v2: return "curr" instead of "bond->curr_active_slave". drivers/net/bonding/bond_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 19eb990..ac71261 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -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 curr; + bond_for_each_slave(bond, slave, iter) { if (slave->link == BOND_LINK_UP) return slave; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/