net/ixgbe: do not update link status in secondary process

Message ID 20240320173407.216307-1-stephen@networkplumber.org (mailing list archive)
State Accepted
Delegated to: Bruce Richardson
Headers
Series net/ixgbe: do not update link status in secondary process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Stephen Hemminger March 20, 2024, 5:33 p.m. UTC
  The code to update link status is not safe in secondary process.
If called from secondary it will crash, example from dumpcap:
	ixgbe_dev_link_update_share()
	ixgbe_dev_link_update()
	rte_eth_link_get()

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reported-by: Jun Wang <junwang01@cestc.cn>
---
Simpler version of earlier patch, and add explanation.

 drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

junwang01@cestc.cn March 21, 2024, 4:39 a.m. UTC | #1
Addressed
I tried this modification and it works as well.

[root@compute3 /]# /dpdk/app/dpdk-dumpcap -i 0000:18:00.0
File: /tmp/dpdk-dumpcap_0_0000:18:00.0_20240321043451.pcapng
Capturing on '0000:18:00.0'
Packets captured: 499 ^C
Packets received/dropped on interface '0000:18:00.0': 499/0 (100.0)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index c61c52b2966b..86ccbdd78292 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4293,6 +4293,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
int wait = 1;
u32 esdp_reg;
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return -1;
+
memset(&link, 0, sizeof(link));
link.link_status = RTE_ETH_LINK_DOWN;
link.link_speed = RTE_ETH_SPEED_NUM_NONE;




junwang01@cestc.cn

From: Stephen Hemminger
Date: 2024-03-21 01:33
To: dev
CC: junwang01; Stephen Hemminger
Subject: [PATCH] net/ixgbe: do not update link status in secondary process
The code to update link status is not safe in secondary process.
If called from secondary it will crash, example from dumpcap:
ixgbe_dev_link_update_share()
ixgbe_dev_link_update()
rte_eth_link_get()

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reported-by: Jun Wang <junwang01@cestc.cn>
---
Simpler version of earlier patch, and add explanation.

drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index c61c52b2966b..86ccbdd78292 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4293,6 +4293,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
int wait = 1;
u32 esdp_reg;
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return -1;
+
memset(&link, 0, sizeof(link));
link.link_status = RTE_ETH_LINK_DOWN;
link.link_speed = RTE_ETH_SPEED_NUM_NONE;
-- 
2.43.0
  
Bruce Richardson April 4, 2024, 2:56 p.m. UTC | #2
On Wed, Mar 20, 2024 at 10:33:04AM -0700, Stephen Hemminger wrote:
> The code to update link status is not safe in secondary process.
> If called from secondary it will crash, example from dumpcap:
> 	ixgbe_dev_link_update_share()
> 	ixgbe_dev_link_update()
> 	rte_eth_link_get()
> 

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Reported-by: Jun Wang <junwang01@cestc.cn>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied to dpdk-next-net-intel.

Thanks,
/Bruce

> ---
> Simpler version of earlier patch, and add explanation.
> 
>  drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index c61c52b2966b..86ccbdd78292 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -4293,6 +4293,9 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
>  	int wait = 1;
>  	u32 esdp_reg;
>  
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return -1;
> +
>  	memset(&link, 0, sizeof(link));
>  	link.link_status = RTE_ETH_LINK_DOWN;
>  	link.link_speed = RTE_ETH_SPEED_NUM_NONE;
> -- 
> 2.43.0
>
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index c61c52b2966b..86ccbdd78292 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4293,6 +4293,9 @@  ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	int wait = 1;
 	u32 esdp_reg;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -1;
+
 	memset(&link, 0, sizeof(link));
 	link.link_status = RTE_ETH_LINK_DOWN;
 	link.link_speed = RTE_ETH_SPEED_NUM_NONE;