net/bonding: fix double get slave link status

Message ID 598d08fa7e4da0ba42ba21ed3461ead4f6f9d23f.1657710002.git.wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: fix double get slave link status |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Yunjian Wang July 13, 2022, 11:11 a.m. UTC
  When link status polling mode is using, the slave link status is
queried twice, which may be inconsistent. To fix this, we can keep
the lastest queried link state.

Fixes: a45b288ef21a ("bond: support link status polling")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 845e8fd0cf..5c4c47251b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2390,9 +2390,6 @@  bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
 			 * event callback */
 			if (slave_ethdev->data->dev_link.link_status !=
 					internals->slaves[i].last_link_status) {
-				internals->slaves[i].last_link_status =
-						slave_ethdev->data->dev_link.link_status;
-
 				bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
 						RTE_ETH_EVENT_INTR_LSC,
 						&bonded_ethdev->data->port_id,
@@ -2891,7 +2888,7 @@  bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 
 	uint8_t lsc_flag = 0;
 	int valid_slave = 0;
-	uint16_t active_pos;
+	uint16_t active_pos, slave_idx;
 	uint16_t i;
 
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
@@ -2912,6 +2909,7 @@  bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 	for (i = 0; i < internals->slave_count; i++) {
 		if (internals->slaves[i].port_id == port_id) {
 			valid_slave = 1;
+			slave_idx = i;
 			break;
 		}
 	}
@@ -3000,6 +2998,7 @@  bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 	 * slaves
 	 */
 	bond_ethdev_link_update(bonded_eth_dev, 0);
+	internals->slaves[slave_idx].last_link_status = link.link_status;
 
 	if (lsc_flag) {
 		/* Cancel any possible outstanding interrupts if delays are enabled */