Skip to contentSkip to conversation

bonding: introduce primary_reselect option

PATCH Applied Jiri Pirko 4 participants 7 messages Sep 18, 2009 – Oct 7, 2009

Subsystems (4)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH v2 1/1 bonding: introduce primary_reselect option

(updated 4)

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Documentation/networking/bonding.txt +26 -0
index d5181ce..fd650e0 100644
@@ -614,6 +614,32 @@ primary
 
 	The primary option is only valid for active-backup mode.
 
+primary_reselect
+
+	Specifies the behavior of the current active slave when the primary was
+	down and comes back up.  This option is designed to prevent
+	flip-flopping between the primary slave and other slaves.  The possible
+	values and their respective effects are:
+
+	always or 0 (default)
+
+		The primary slave becomes the active slave whenever it comes
+		back up.
+
+	better or 1
+
+		The primary slave becomes the active slave when it comes back
+		up, if the speed and duplex of the primary slave is better
+		than the speed and duplex of the current active slave.
+
+	failure or 2
+
+		The primary slave becomes the active slave only if the current
+		active slave fails and the primary slave is up.
+
+	When no slave are active, if the primary comes back up, it becomes the
+	active slave, regardless of the value of primary_reselect.
+
 updelay
 
 	Specifies the time, in milliseconds, to wait before enabling a
drivers/net/bonding/bond_main.c +56 -3

114 lines not on this page · raw message

drivers/net/bonding/bond_sysfs.c +56 -0

68 lines not on this page · raw message

drivers/net/bonding/bonding.h +7 -0
index 6824771..b5b1530 100644
@@ -131,6 +131,7 @@ struct bond_params {
 	int lacp_fast;
 	int ad_select;
 	char primary[IFNAMSIZ];
+	int primary_reselect;
 	__be32 arp_targets[BOND_MAX_ARP_TARGETS];
 };
 
@@ -190,6 +191,7 @@ struct bonding {
 	struct   slave *curr_active_slave;
 	struct   slave *current_arp_slave;
 	struct   slave *primary_slave;
+	bool     force_primary;
 	s32      slave_cnt; /* never change this value outside the attach/detach wrappers */
 	rwlock_t lock;
 	rwlock_t curr_slave_lock;
@@ -258,6 +260,10 @@ static inline bool bond_is_lb(const struct bonding *bond)
 		|| bond->params.mode == BOND_MODE_ALB;
 }
 
+#define BOND_PRI_RESELECT_ALWAYS	0
+#define BOND_PRI_RESELECT_BETTER	1
+#define BOND_PRI_RESELECT_FAILURE	2
+
 #define BOND_FOM_NONE			0
 #define BOND_FOM_ACTIVE			1
 #define BOND_FOM_FOLLOW			2
@@ -348,6 +354,7 @@ extern const struct bond_parm_tbl bond_mode_tbl[];
 extern const struct bond_parm_tbl xmit_hashtype_tbl[];
 extern const struct bond_parm_tbl arp_validate_tbl[];
 extern const struct bond_parm_tbl fail_over_mac_tbl[];
+extern const struct bond_parm_tbl pri_reselect_tbl[];
 extern struct bond_parm_tbl ad_select_tbl[];
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#1 lore raw

From: Jiri Pirko <[email protected]>

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

---

Note that this patch depends on the "make ab_arp select active
slaves as other modes" patch recently approved, but not yet appearing in net-next-2.6 as I write this. http://patchwork.ozlabs.org/patch/32684/

 Documentation/networking/bonding.txt |   42 +++++++++++++++++++++-
 drivers/net/bonding/bond_main.c      |   66 +++++++++++++++++++++++++++++++---
 drivers/net/bonding/bond_main.c.rej  |   18 +++++++++
 drivers/net/bonding/bond_sysfs.c     |   53 +++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |   11 +++++-
 5 files changed, 182 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/bonding/bond_main.c.rej
Documentation/networking/bonding.txt +41 -1
index d5181ce..61f516b 100644
@@ -1,7 +1,7 @@
 
 		Linux Ethernet Bonding Driver HOWTO
 
-		Latest update: 12 November 2007
+		Latest update: 23 September 2009
 
 Initial release : Thomas Davis <tadavis at lbl.gov>
 Corrections, HA extensions : 2000/10/03-15 :
@@ -614,6 +614,46 @@ primary
 
 	The primary option is only valid for active-backup mode.
 
+primary_reselect
+
+	Specifies the reselection policy for the primary slave.  This
+	affects how the primary slave is chosen to become the active slave
+	when failure of the active slave or recovery of the primary slave
+	occurs.  This option is designed to prevent flip-flopping between
+	the primary slave and other slaves.  Possible values are:
+
+	always or 0 (default)
+
+		The primary slave becomes the active slave whenever it
+		comes back up.
+
+	better or 1
+
+		The primary slave becomes the active slave when it comes
+		back up, if the speed and duplex of the primary slave is
+		better than the speed and duplex of the current active
+		slave.
+
+	failure or 2
+
+		The primary slave becomes the active slave only if the
+		current active slave fails and the primary slave is up.
+
+	The primary_reselect setting is ignored in two cases:
+
+		If no slaves are active, the first slave to recover is
+		made the active slave.
+
+		When initially enslaved, the primary slave is always made
+		the active slave.
+
+	Changing the primary_reselect policy via sysfs will cause an
+	immediate selection of the best active slave according to the new
+	policy.  This may or may not result in a change of the active
+	slave, depending upon the circumstances.
+
+	This option was added for bonding version 3.6.0.
+
 updelay
 
 	Specifies the time, in milliseconds, to wait before enabling a
drivers/net/bonding/bond_main.c +61 -5

130 lines not on this page · raw message

drivers/net/bonding/bond_main.c.rej new file +18 -0
new file mode 100644
index 0000000..6854718
@@ -0,0 +1,18 @@
+*************** static struct slave *bond_find_best_slave(struct bonding *bond)
+*** 1094,1100 ****
+  	}
+  
+  	if ((bond->primary_slave) &&
+- 	    bond->primary_slave->link == BOND_LINK_UP) {
+  		new_active = bond->primary_slave;
+  	}
+  
+--- 1129,1136 ----
+  	}
+  
+  	if ((bond->primary_slave) &&
++ 	    bond->primary_slave->link == BOND_LINK_UP &&
++ 	    bond_should_change_active(bond)) {
+  		new_active = bond->primary_slave;
+  	}
+  
drivers/net/bonding/bond_sysfs.c +53 -0

65 lines not on this page · raw message

drivers/net/bonding/bonding.h +9 -2
index 6824771..9c03c2e 100644
@@ -23,8 +23,8 @@
 #include "bond_3ad.h"
 #include "bond_alb.h"
 
-#define DRV_VERSION	"3.5.0"
-#define DRV_RELDATE	"November 4, 2008"
+#define DRV_VERSION	"3.6.0"
+#define DRV_RELDATE	"September 26, 2009"
 #define DRV_NAME	"bonding"
 #define DRV_DESCRIPTION	"Ethernet Channel Bonding Driver"
 
@@ -131,6 +131,7 @@ struct bond_params {
 	int lacp_fast;
 	int ad_select;
 	char primary[IFNAMSIZ];
+	int primary_reselect;
 	__be32 arp_targets[BOND_MAX_ARP_TARGETS];
 };
 
@@ -190,6 +191,7 @@ struct bonding {
 	struct   slave *curr_active_slave;
 	struct   slave *current_arp_slave;
 	struct   slave *primary_slave;
+	bool     force_primary;
 	s32      slave_cnt; /* never change this value outside the attach/detach wrappers */
 	rwlock_t lock;
 	rwlock_t curr_slave_lock;
@@ -258,6 +260,10 @@ static inline bool bond_is_lb(const struct bonding *bond)
 		|| bond->params.mode == BOND_MODE_ALB;
 }
 
+#define BOND_PRI_RESELECT_ALWAYS	0
+#define BOND_PRI_RESELECT_BETTER	1
+#define BOND_PRI_RESELECT_FAILURE	2
+
 #define BOND_FOM_NONE			0
 #define BOND_FOM_ACTIVE			1
 #define BOND_FOM_FOLLOW			2
@@ -348,6 +354,7 @@ extern const struct bond_parm_tbl bond_mode_tbl[];
 extern const struct bond_parm_tbl xmit_hashtype_tbl[];
 extern const struct bond_parm_tbl arp_validate_tbl[];
 extern const struct bond_parm_tbl fail_over_mac_tbl[];
+extern const struct bond_parm_tbl pri_reselect_tbl[];
 extern struct bond_parm_tbl ad_select_tbl[];
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
Signature · 1 line
1.6.0.2
#2 lore raw
Quoted 21 lines · Jay Vosburgh

From: Jiri Pirko <[email protected]>

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

---

Note that this patch depends on the "make ab_arp select active
slaves as other modes" patch recently approved, but not yet appearing in net-next-2.6 as I write this. http://patchwork.ozlabs.org/patch/32684/

Quoted 7 lines
 Documentation/networking/bonding.txt |   42 +++++++++++++++++++++-
 drivers/net/bonding/bond_main.c      |   66 +++++++++++++++++++++++++++++++---
 drivers/net/bonding/bond_main.c.rej  |   18 +++++++++
 drivers/net/bonding/bond_sysfs.c     |   53 +++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |   11 +++++-
 5 files changed, 182 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/bonding/bond_main.c.rej

I doubt you intended to include a patch reject file in your patch.

-Bill

author
#3 lore raw
Quoted 31 lines · Fri, Sep 25, 2009 at 09:47:25AM CEST, [email protected] wrote:
Quoted 21 lines · Jay Vosburgh

From: Jiri Pirko <[email protected]>

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

---

Note that this patch depends on the "make ab_arp select active
slaves as other modes" patch recently approved, but not yet appearing in net-next-2.6 as I write this. http://patchwork.ozlabs.org/patch/32684/

Quoted 7 lines
 Documentation/networking/bonding.txt |   42 +++++++++++++++++++++-
 drivers/net/bonding/bond_main.c      |   66 +++++++++++++++++++++++++++++++---
 drivers/net/bonding/bond_main.c.rej  |   18 +++++++++
 drivers/net/bonding/bond_sysfs.c     |   53 +++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |   11 +++++-
 5 files changed, 182 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/bonding/bond_main.c.rej
Quoted 1 line

I doubt you intended to include a patch reject file in your patch.

Noticed - I'm about to resend...

Quoted 2 lines

-Bill

#4 lore raw
Quoted 32 lines · Jiri Pirko
Quoted 31 lines · Fri, Sep 25, 2009 at 09:47:25AM CEST, [email protected] wrote:
Quoted 28 lines · Jay Vosburgh

From: Jiri Pirko <[email protected]>

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

---

Note that this patch depends on the "make ab_arp select active
slaves as other modes" patch recently approved, but not yet appearing in net-next-2.6 as I write this. http://patchwork.ozlabs.org/patch/32684/

 Documentation/networking/bonding.txt |   42 +++++++++++++++++++++-
 drivers/net/bonding/bond_main.c      |   66 +++++++++++++++++++++++++++++++---
 drivers/net/bonding/bond_main.c.rej  |   18 +++++++++
 drivers/net/bonding/bond_sysfs.c     |   53 +++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |   11 +++++-
 5 files changed, 182 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/bonding/bond_main.c.rej
Quoted 3 lines
Quoted 1 line

I doubt you intended to include a patch reject file in your patch.

Noticed - I'm about to resend...

	Thanks, guys.

	-J

---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]

author
#5 lore raw
In reply to Jay Vosburgh

Subject: [PATCH net-2.6 v3] bonding: introduce primary_reselect option

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

---

Note that this patch depends on the "make ab_arp select active
slaves as other modes" patch recently approved, but not yet appearing in net-next-2.6 as I write this. http://patchwork.ozlabs.org/patch/32684/

Dave, this patch is diffed against net-2.6 but should be cleanly applied on net-next-2.6 when it will include mentioned patch.

Documentation/networking/bonding.txt +41 -1
index d5181ce..61f516b 100644
@@ -1,7 +1,7 @@
 
 		Linux Ethernet Bonding Driver HOWTO
 
-		Latest update: 12 November 2007
+		Latest update: 23 September 2009
 
 Initial release : Thomas Davis <tadavis at lbl.gov>
 Corrections, HA extensions : 2000/10/03-15 :
@@ -614,6 +614,46 @@ primary
 
 	The primary option is only valid for active-backup mode.
 
+primary_reselect
+
+	Specifies the reselection policy for the primary slave.  This
+	affects how the primary slave is chosen to become the active slave
+	when failure of the active slave or recovery of the primary slave
+	occurs.  This option is designed to prevent flip-flopping between
+	the primary slave and other slaves.  Possible values are:
+
+	always or 0 (default)
+
+		The primary slave becomes the active slave whenever it
+		comes back up.
+
+	better or 1
+
+		The primary slave becomes the active slave when it comes
+		back up, if the speed and duplex of the primary slave is
+		better than the speed and duplex of the current active
+		slave.
+
+	failure or 2
+
+		The primary slave becomes the active slave only if the
+		current active slave fails and the primary slave is up.
+
+	The primary_reselect setting is ignored in two cases:
+
+		If no slaves are active, the first slave to recover is
+		made the active slave.
+
+		When initially enslaved, the primary slave is always made
+		the active slave.
+
+	Changing the primary_reselect policy via sysfs will cause an
+	immediate selection of the best active slave according to the new
+	policy.  This may or may not result in a change of the active
+	slave, depending upon the circumstances.
+
+	This option was added for bonding version 3.6.0.
+
 updelay
 
 	Specifies the time, in milliseconds, to wait before enabling a
drivers/net/bonding/bond_main.c +61 -5

130 lines not on this page · raw message

drivers/net/bonding/bond_sysfs.c +53 -0

65 lines not on this page · raw message

drivers/net/bonding/bonding.h +9 -2
index 6824771..9c03c2e 100644
@@ -23,8 +23,8 @@
 #include "bond_3ad.h"
 #include "bond_alb.h"
 
-#define DRV_VERSION	"3.5.0"
-#define DRV_RELDATE	"November 4, 2008"
+#define DRV_VERSION	"3.6.0"
+#define DRV_RELDATE	"September 26, 2009"
 #define DRV_NAME	"bonding"
 #define DRV_DESCRIPTION	"Ethernet Channel Bonding Driver"
 
@@ -131,6 +131,7 @@ struct bond_params {
 	int lacp_fast;
 	int ad_select;
 	char primary[IFNAMSIZ];
+	int primary_reselect;
 	__be32 arp_targets[BOND_MAX_ARP_TARGETS];
 };
 
@@ -190,6 +191,7 @@ struct bonding {
 	struct   slave *curr_active_slave;
 	struct   slave *current_arp_slave;
 	struct   slave *primary_slave;
+	bool     force_primary;
 	s32      slave_cnt; /* never change this value outside the attach/detach wrappers */
 	rwlock_t lock;
 	rwlock_t curr_slave_lock;
@@ -258,6 +260,10 @@ static inline bool bond_is_lb(const struct bonding *bond)
 		|| bond->params.mode == BOND_MODE_ALB;
 }
 
+#define BOND_PRI_RESELECT_ALWAYS	0
+#define BOND_PRI_RESELECT_BETTER	1
+#define BOND_PRI_RESELECT_FAILURE	2
+
 #define BOND_FOM_NONE			0
 #define BOND_FOM_ACTIVE			1
 #define BOND_FOM_FOLLOW			2
@@ -348,6 +354,7 @@ extern const struct bond_parm_tbl bond_mode_tbl[];
 extern const struct bond_parm_tbl xmit_hashtype_tbl[];
 extern const struct bond_parm_tbl arp_validate_tbl[];
 extern const struct bond_parm_tbl fail_over_mac_tbl[];
+extern const struct bond_parm_tbl pri_reselect_tbl[];
 extern struct bond_parm_tbl ad_select_tbl[];
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
maintainer Applied
#6 lore raw

From: Jiri Pirko <[email protected]>
Date: Fri, 25 Sep 2009 15:28:09 +0200

Quoted 8 lines

Subject: [PATCH net-2.6 v3] bonding: introduce primary_reselect option

In some cases there is not desirable to switch back to primary interface when it's link recovers and rather stay with currently active one. We need to avoid packetloss as much as we can in some cases. This is solved by introducing primary_reselect option. Note that enslaved primary slave is set as current active no matter what.

Quoted 6 lines

Patch modified by Jay Vosburgh as follows: fixed bug in action after change of option setting via sysfs, revised the documentation update, and bumped the bonding version number.

Applied, thanks.