[net] bonding: re-evaluate force_primary when the primary slave name changes

Message ID A977208F-4266-411B-8DA5-0C6901F201E7@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net] bonding: re-evaluate force_primary when the primary slave name changes
Related show

Commit Message

Xiangning Yu June 7, 2018, 5:39 a.m.
From: Xiangning Yu <yuxiangning@gmail.com>

There is a timing issue under active-standy mode, when bond_enslave() is
called, bond->params.primary might not be initialized yet.

Any time the primary slave string changes, bond->force_primary should be
set to true to make sure the primary becomes the active slave.

Signed-off-by: Xiangning Yu <yuxiangning@gmail.com>
---
 drivers/net/bonding/bond_options.c | 1 +
 1 file changed, 1 insertion(+)

Comments

David Miller June 7, 2018, 8:54 p.m. | #1
From: Xiangning Yu <yuxiangning@gmail.com>
Date: Thu, 7 Jun 2018 13:39:59 +0800

> From: Xiangning Yu <yuxiangning@gmail.com>
> 
> There is a timing issue under active-standy mode, when bond_enslave() is
> called, bond->params.primary might not be initialized yet.
> 
> Any time the primary slave string changes, bond->force_primary should be
> set to true to make sure the primary becomes the active slave.
> 
> Signed-off-by: Xiangning Yu <yuxiangning@gmail.com>

Applied and queued up for -stable.

Patch

diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 8a945c9..98663c5 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -1142,6 +1142,7 @@  static int bond_option_primary_set(struct bonding *bond,
 				   slave->dev->name);
 			rcu_assign_pointer(bond->primary_slave, slave);
 			strcpy(bond->params.primary, slave->dev->name);
+			bond->force_primary = true;
 			bond_select_active_slave(bond);
 			goto out;
 		}