netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about force_primary in bonding driver
@ 2018-06-06 10:18 Xiangning Yu
  2018-06-06 17:57 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Xiangning Yu @ 2018-06-06 10:18 UTC (permalink / raw)
  To: Linux Kernel Network Developers

Hi netdev folks,

While playing with bonding active-standby mode, we found a possible
timing issue that the primary might not initialized in bond_enslave():

        if (bond_uses_primary(bond) && bond->params.primary[0]) {
                /* if there is a primary slave, remember it */
                if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
                        rcu_assign_pointer(bond->primary_slave, new_slave);
                        bond->force_primary = true;
                }
        }

Hence bond->force_primary won't be set and bond_select_active_slave()
ends up not selecting the primary slave as specified in bond params.

We applied the following patch to make sure force_primary is set when
primary is copied, and it seems to fix the issue. Could you please
provide some comments/thoughts on this?

Thank you very much!

- Xiangning

diff --git a/drivers/net/bonding/bond_options.c
b/drivers/net/bonding/bond_options.c
index 58c705f..b594bae 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -1142,6 +1142,7 @@ static int bond_option_primary_set(struct bonding *bond,
                                   slave->dev->name);
                        rcu_assign_pointer(bond->primary_slave, slave);
                        strcpy(bond->params.primary, slave->dev->name);
+                       bond->force_primary = true;
                        bond_select_active_slave(bond);
                        goto out;
                }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Question about force_primary in bonding driver
  2018-06-06 10:18 Question about force_primary in bonding driver Xiangning Yu
@ 2018-06-06 17:57 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-06-06 17:57 UTC (permalink / raw)
  To: yuxiangning; +Cc: netdev

From: Xiangning Yu <yuxiangning@gmail.com>
Date: Wed, 6 Jun 2018 03:18:23 -0700

> diff --git a/drivers/net/bonding/bond_options.c
> b/drivers/net/bonding/bond_options.c
> index 58c705f..b594bae 100644
> --- a/drivers/net/bonding/bond_options.c
> +++ b/drivers/net/bonding/bond_options.c
> @@ -1142,6 +1142,7 @@ static int bond_option_primary_set(struct bonding *bond,
>                                    slave->dev->name);
>                         rcu_assign_pointer(bond->primary_slave, slave);
>                         strcpy(bond->params.primary, slave->dev->name);
> +                       bond->force_primary = true;
>                         bond_select_active_slave(bond);
>                         goto out;
>                 }

Based upon your analysis, it does indeed seem logical that we
need to re-evaluate bond->force_primary any time the primary
slave name string changes.

Please submit this formally, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-06 17:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 10:18 Question about force_primary in bonding driver Xiangning Yu
2018-06-06 17:57 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).