net/bonding: set started flag at the end of dev start

Message ID 1532080957-26940-1-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: set started flag at the end of dev start |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Radu Nicolau July 20, 2018, 10:02 a.m. UTC
  Race condition can appear in the bond_mode_8023ad_periodic_cb()
callback when bonding port is stopped, reconfigured and restarted.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Chas Williams July 24, 2018, 2:34 p.m. UTC | #1
I think this adds another race.  In
bond_ethdev_slave_link_status_change_monitor(), it checks to see if bonding
is started, if not it exits.  So you need to have dev_started = 1 set
before you enable this callback.

On Fri, Jul 20, 2018 at 6:09 AM Radu Nicolau <radu.nicolau@intel.com> wrote:

> Race condition can appear in the bond_mode_8023ad_periodic_cb()
> callback when bonding port is stopped, reconfigured and restarted.
>
> Fixes: 2efb58cbab6e ("bond: new link bonding library")
> Cc: stable@dpdk.org
>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>  drivers/net/bonding/rte_eth_bond_pmd.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c
> b/drivers/net/bonding/rte_eth_bond_pmd.c
> index fc4d4fd..6f66743 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2087,8 +2087,6 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
>         }
>
>         eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
> -       eth_dev->data->dev_started = 1;
> -
>         internals = eth_dev->data->dev_private;
>
>         if (internals->slave_count == 0) {
> @@ -2167,6 +2165,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
>                         internals->mode == BONDING_MODE_ALB)
>                 bond_tlb_enable(internals);
>
> +       eth_dev->data->dev_started = 1;
>         return 0;
>
>  out_err:
> --
> 2.7.5
>
>
  
Radu Nicolau July 25, 2018, 8:53 a.m. UTC | #2
On 7/24/2018 3:34 PM, Chas Williams wrote:
> I think this adds another race.  In 
> bond_ethdev_slave_link_status_change_monitor(), it checks to see if 
> bonding is started, if not it exits.  So you need to have dev_started 
> = 1 set before you enable this callback.
>
Indeed, I will have another look at this. Thanks for reviewing!
Can you also have a look at this one? https://patches.dpdk.org/patch/43187/
I think I addressed all your previous feedback.
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index fc4d4fd..6f66743 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2087,8 +2087,6 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
-	eth_dev->data->dev_started = 1;
-
 	internals = eth_dev->data->dev_private;
 
 	if (internals->slave_count == 0) {
@@ -2167,6 +2165,7 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 			internals->mode == BONDING_MODE_ALB)
 		bond_tlb_enable(internals);
 
+	eth_dev->data->dev_started = 1;
 	return 0;
 
 out_err: