From: Hangbin Liu <liuhangbin@gmail.com>
To: Jianbo Liu <jianbol@nvidia.com>
Cc: Tariq Toukan <tariqt@nvidia.com>,
"davem@davemloft.net" <davem@davemloft.net>,
Leon Romanovsky <leonro@nvidia.com>,
"andy@greyhouse.net" <andy@greyhouse.net>,
Gal Pressman <gal@nvidia.com>,
"jv@jvosburgh.net" <jv@jvosburgh.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"edumazet@google.com" <edumazet@google.com>,
Saeed Mahameed <saeedm@nvidia.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net V3 3/3] bonding: change ipsec_lock from spin lock to mutex
Date: Fri, 9 Aug 2024 10:31:11 +0800 [thread overview]
Message-ID: <ZrV_b9IfYXwSm3pm@Laptop-X1> (raw)
In-Reply-To: <0ed0935e51c244086529a43aa6ccf599e5b3bc52.camel@nvidia.com>
On Thu, Aug 08, 2024 at 10:05:26AM +0000, Jianbo Liu wrote:
> On Thu, 2024-08-08 at 17:34 +0800, Hangbin Liu wrote:
> > On Mon, Aug 05, 2024 at 08:03:57AM +0300, Tariq Toukan wrote:
> > > drivers/net/bonding/bond_main.c | 75 +++++++++++++++++------------
> > > ----
> > > include/net/bonding.h | 2 +-
> > > 2 files changed, 40 insertions(+), 37 deletions(-)
> > >
> > > diff --git a/drivers/net/bonding/bond_main.c
> > > b/drivers/net/bonding/bond_main.c
> > > index e550b1c08fdb..56764f1c39b8 100644
> > > --- a/drivers/net/bonding/bond_main.c
> > > +++ b/drivers/net/bonding/bond_main.c
> > > @@ -481,35 +476,43 @@ static void bond_ipsec_add_sa_all(struct
> > > bonding *bond)
> > > struct bond_ipsec *ipsec;
> > > struct slave *slave;
> > >
> > > - rcu_read_lock();
> > > - slave = rcu_dereference(bond->curr_active_slave);
> > > - if (!slave)
> > > - goto out;
> > > + slave = rtnl_dereference(bond->curr_active_slave);
> > > + real_dev = slave ? slave->dev : NULL;
> > > + if (!real_dev)
> > > + return;
> > >
> > > - real_dev = slave->dev;
> > > + mutex_lock(&bond->ipsec_lock);
> > > if (!real_dev->xfrmdev_ops ||
> > > !real_dev->xfrmdev_ops->xdo_dev_state_add ||
> > > netif_is_bond_master(real_dev)) {
> > > - spin_lock_bh(&bond->ipsec_lock);
> > > if (!list_empty(&bond->ipsec_list))
> > > slave_warn(bond_dev, real_dev,
> > > "%s: no slave
> > > xdo_dev_state_add\n",
> > > __func__);
> > > - spin_unlock_bh(&bond->ipsec_lock);
> > > goto out;
> > > }
> > >
> > > - spin_lock_bh(&bond->ipsec_lock);
> > > list_for_each_entry(ipsec, &bond->ipsec_list, list) {
> > > + struct net_device *dev = ipsec->xs->xso.real_dev;
> > > +
> > > + /* If new state is added before ipsec_lock acquired
> > > */
> > > + if (dev) {
> > > + if (dev == real_dev)
> > > + continue;
> > Hi Jianbo,
> >
> > Why we skip the deleting here if dev == real_dev? What if the state
>
> Here the bond active slave is updated. If dev == real_dev, the state
> (should be newly added) is offloaded to new active, so no need to
> delete and add back again.
>
> > is added again on the same slave? From the previous logic it looks we
>
> Why is it added to the same slave? It's not the active one.
OK, I got what you mean now. Thanks for the explaination.
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
prev parent reply other threads:[~2024-08-09 2:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 5:03 [PATCH net V3 0/3] Fixes for IPsec over bonding Tariq Toukan
2024-08-05 5:03 ` [PATCH net V3 1/3] bonding: implement xdo_dev_state_free and call it after deletion Tariq Toukan
2024-08-06 8:45 ` Hangbin Liu
2024-08-06 9:09 ` Jianbo Liu
2024-08-07 10:11 ` Hangbin Liu
2024-08-13 0:48 ` Jakub Kicinski
2024-08-13 2:58 ` Jianbo Liu
2024-08-13 14:14 ` Jakub Kicinski
2024-08-14 2:03 ` Jianbo Liu
2024-08-14 3:11 ` Hangbin Liu
2024-08-15 1:23 ` Jianbo Liu
2024-08-15 3:34 ` Hangbin Liu
2024-08-15 3:57 ` Jianbo Liu
2024-08-05 5:03 ` [PATCH net V3 2/3] bonding: extract the use of real_device into local variable Tariq Toukan
2024-08-07 10:13 ` Hangbin Liu
2024-08-05 5:03 ` [PATCH net V3 3/3] bonding: change ipsec_lock from spin lock to mutex Tariq Toukan
2024-08-08 9:34 ` Hangbin Liu
2024-08-08 10:05 ` Jianbo Liu
2024-08-09 2:31 ` Hangbin Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZrV_b9IfYXwSm3pm@Laptop-X1 \
--to=liuhangbin@gmail.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jianbol@nvidia.com \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox