[v2] net/bonding: fix race condition

Message ID 1532511580-2631-1-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/bonding: fix race condition |

Checks

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

Commit Message

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

Re-ordered calls in bond_ethdev_start() to have callback alarm set
after slave ports are reconfigured.

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

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
v2: reworked patch

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

Comments

Chas Williams July 27, 2018, 10:55 a.m. UTC | #1
On Wed, Jul 25, 2018 at 5:46 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.
>
> Re-ordered calls in bond_ethdev_start() to have callback alarm set
> after slave ports are reconfigured.
>
> Fixes: 2efb58cbab6e ("bond: new link bonding library")
> Cc: stable@dpdk.org
>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
>

Acked-by: Chas Williams <chas3@att.com>


> ---
> v2: reworked patch
>
>  drivers/net/bonding/rte_eth_bond_pmd.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c
> b/drivers/net/bonding/rte_eth_bond_pmd.c
> index fc4d4fd..70ec728 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2113,10 +2113,6 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
>                 }
>         }
>
> -       /* Update all slave devices MACs*/
> -       if (mac_address_slaves_update(eth_dev) != 0)
> -               goto out_err;
> -
>         /* If bonded device is configure in promiscuous mode then re-apply
> config */
>         if (internals->promiscuous_en)
>                 bond_ethdev_promiscuous_enable(eth_dev);
> @@ -2157,6 +2153,10 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
>                         (void *)&rte_eth_devices[internals->port_id]);
>         }
>
> +       /* Update all slave devices MACs*/
> +       if (mac_address_slaves_update(eth_dev) != 0)
> +               goto out_err;
> +
>         if (internals->user_defined_primary_port)
>                 bond_ethdev_primary_set(internals,
> internals->primary_port);
>
> --
> 2.7.5
>
>
  
Thomas Monjalon Aug. 5, 2018, 12:09 a.m. UTC | #2
27/07/2018 12:55, Chas Williams:
> On Wed, Jul 25, 2018 at 5:46 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.
> >
> > Re-ordered calls in bond_ethdev_start() to have callback alarm set
> > after slave ports are reconfigured.
> >
> > Fixes: 2efb58cbab6e ("bond: new link bonding library")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> >
> 
> Acked-by: Chas Williams <chas3@att.com>

Applied, thanks
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index fc4d4fd..70ec728 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2113,10 +2113,6 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 		}
 	}
 
-	/* Update all slave devices MACs*/
-	if (mac_address_slaves_update(eth_dev) != 0)
-		goto out_err;
-
 	/* If bonded device is configure in promiscuous mode then re-apply config */
 	if (internals->promiscuous_en)
 		bond_ethdev_promiscuous_enable(eth_dev);
@@ -2157,6 +2153,10 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 			(void *)&rte_eth_devices[internals->port_id]);
 	}
 
+	/* Update all slave devices MACs*/
+	if (mac_address_slaves_update(eth_dev) != 0)
+		goto out_err;
+
 	if (internals->user_defined_primary_port)
 		bond_ethdev_primary_set(internals, internals->primary_port);