[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240912064043.36956-1-suresh2514@gmail.com>
Date: Thu, 12 Sep 2024 12:10:43 +0530
From: Suresh Kumar <suresh2514@...il.com>
To: jv@...sburgh.net,
andy@...yhouse.net,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Suresh Kumar <suresh2514@...il.com>
Subject: [PATCH] net: bonding: do not set force_primary if reselect is set to failure
when bond_enslave() is called, it sets bond->force_primary to true
without checking if primary_reselect is set to 'failure' or 'better'.
This can result in primary becoming active again when link is back which
is not what we want when primary_reselect is set to 'failure'
Test
====
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: enp1s0 (primary_reselect failure)
Currently Active Slave: enp1s0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: enp1s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:d7:a7:2a
Slave queue ID: 0
Slave Interface: enp9s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:da:9a:f9
Slave queue ID: 0
After primary link failure:
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: enp9s0 <---- secondary is active now
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: enp9s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:da:9a:f9
Slave queue ID: 0
Now add primary link back and check bond status:
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: enp1s0 (primary_reselect failure)
Currently Active Slave: enp1s0 <------------- primary is active again
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: enp9s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:da:9a:f9
Slave queue ID: 0
Slave Interface: enp1s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:d7:a7:2a
Slave queue ID: 0
Signed-off-by: Suresh Kumar <suresh2514@...il.com>
---
drivers/net/bonding/bond_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index bb9c3d6ef435..731256fbb996 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2146,7 +2146,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
/* if there is a primary slave, remember it */
if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
rcu_assign_pointer(bond->primary_slave, new_slave);
- bond->force_primary = true;
+ if (bond->params.primary_reselect != BOND_PRI_RESELECT_FAILURE &&
+ bond->params.primary_reselect != BOND_PRI_RESELECT_BETTER)
+ bond->force_primary = true;
}
}
--
2.43.0
Powered by blists - more mailing lists