net/bonding: fix link status callback stop

Message ID 20231016084744.734493-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: fix link status callback stop |

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 success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

David Marchand Oct. 16, 2023, 8:47 a.m. UTC
  If a bonding port gets released, a link status alarm callback still
referenced the ethdev port that may be reused later.
Cancel this callback when stopping the port.

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

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Note: this issue was made apparent now that we release the ethdev port
shared mem, see 36c46e738120 ("ethdev: cleanup shared data with ...").

---
 drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

fengchengwen Oct. 16, 2023, 10:33 a.m. UTC | #1
On 2023/10/16 16:47, David Marchand wrote:
> If a bonding port gets released, a link status alarm callback still
> referenced the ethdev port that may be reused later.
> Cancel this callback when stopping the port.
> 
> Bugzilla ID: 1301
> Fixes: a45b288ef21a ("bond: support link status polling")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Note: this issue was made apparent now that we release the ethdev port
> shared mem, see 36c46e738120 ("ethdev: cleanup shared data with ...").
> 
> ---
>  drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index 122b1187fd..b8ee8be50f 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2159,6 +2159,10 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
>  	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
>  	eth_dev->data->dev_started = 0;
>  
> +	if (internals->link_status_polling_enabled) {
> +		rte_eal_alarm_cancel(bond_ethdev_member_link_status_change_monitor,
> +			(void *)&rte_eth_devices[internals->port_id]);
> +	}
>  	internals->link_status_polling_enabled = 0;

How about move this line in above {}.

Anyway, both OK for me
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

>  	for (i = 0; i < internals->member_count; i++) {
>  		uint16_t member_id = internals->members[i].port_id;
>
  
Ferruh Yigit Oct. 16, 2023, 12:22 p.m. UTC | #2
On 10/16/2023 11:33 AM, fengchengwen wrote:
> On 2023/10/16 16:47, David Marchand wrote:
>> If a bonding port gets released, a link status alarm callback still
>> referenced the ethdev port that may be reused later.
>> Cancel this callback when stopping the port.
>>
>> Bugzilla ID: 1301
>> Fixes: a45b288ef21a ("bond: support link status polling")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
> 
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> 

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied to dpdk-next-net/main, thanks.
  
Stephen Hemminger Oct. 16, 2023, 3:54 p.m. UTC | #3
On Mon, 16 Oct 2023 18:33:01 +0800
fengchengwen <fengchengwen@huawei.com> wrote:

> > +	if (internals->link_status_polling_enabled) {
> > +		rte_eal_alarm_cancel(bond_ethdev_member_link_status_change_monitor,
> > +			(void *)&rte_eth_devices[internals->port_id]);

Is the cast to void * actually necessary?
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 122b1187fd..b8ee8be50f 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2159,6 +2159,10 @@  bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 	eth_dev->data->dev_started = 0;
 
+	if (internals->link_status_polling_enabled) {
+		rte_eal_alarm_cancel(bond_ethdev_member_link_status_change_monitor,
+			(void *)&rte_eth_devices[internals->port_id]);
+	}
 	internals->link_status_polling_enabled = 0;
 	for (i = 0; i < internals->member_count; i++) {
 		uint16_t member_id = internals->members[i].port_id;