mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bonding: "primary_reselect" with "failure" is not working properly
@ 2015-07-02 10:13 Mazhar Rana
  2015-07-02 11:35 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Mazhar Rana @ 2015-07-02 10:13 UTC (permalink / raw)
  To: netdev, j.vosburgh, vfalico, gospo
  Cc: Mazhar Rana, davem, sanket.shah, mazhar.rana, linux-kernel

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 <mazhar.rana@cyberoam.com>
Reviewed-by: Sanket Shah <sanket.shah@cyberoam.com>
---
 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 bond->curr_active_slave;
+
 	bond_for_each_slave(bond, slave, iter) {
 		if (slave->link == BOND_LINK_UP)
 			return slave;
-- 
1.9.1


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

* Re: [PATCH] bonding: "primary_reselect" with "failure" is not working properly
  2015-07-02 10:13 [PATCH] bonding: "primary_reselect" with "failure" is not working properly Mazhar Rana
@ 2015-07-02 11:35 ` Eric Dumazet
       [not found]   ` <559526F3.3000200@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2015-07-02 11:35 UTC (permalink / raw)
  To: Mazhar Rana
  Cc: netdev, j.vosburgh, vfalico, gospo, davem, sanket.shah,
	mazhar.rana, linux-kernel

On Thu, 2015-07-02 at 15:43 +0530, Mazhar Rana wrote:
> 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 <mazhar.rana@cyberoam.com>
> Reviewed-by: Sanket Shah <sanket.shah@cyberoam.com>
> ---
>  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);

Here you carefully use rtnl_dereference(bond->curr_active_slave)

(This is good)

> +	if (curr && curr->link == BOND_LINK_UP)
> +		return bond->curr_active_slave;

But here you return bond->curr_active_slave 
instead of curr

> +
>  	bond_for_each_slave(bond, slave, iter) {
>  		if (slave->link == BOND_LINK_UP)
>  			return slave;



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

* Re: [PATCH] bonding: "primary_reselect" with "failure" is not working properly
       [not found]   ` <559526F3.3000200@gmail.com>
@ 2015-07-02 17:57     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-07-02 17:57 UTC (permalink / raw)
  To: ranamazharp
  Cc: eric.dumazet, netdev, j.vosburgh, vfalico, gospo, sanket.shah,
	mazhar.rana, linux-kernel


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

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

end of thread, other threads:[~2015-07-02 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-02 10:13 [PATCH] bonding: "primary_reselect" with "failure" is not working properly Mazhar Rana
2015-07-02 11:35 ` Eric Dumazet
     [not found]   ` <559526F3.3000200@gmail.com>
2015-07-02 17:57     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®