[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <42393e6f05796b4af74e024eb28b6236cf379232.camel@nvidia.com>
Date: Tue, 6 Aug 2024 09:09:47 +0000
From: Jianbo Liu <jianbol@...dia.com>
To: Tariq Toukan <tariqt@...dia.com>, "liuhangbin@...il.com"
<liuhangbin@...il.com>
CC: "davem@...emloft.net" <davem@...emloft.net>, Leon Romanovsky
<leonro@...dia.com>, "andy@...yhouse.net" <andy@...yhouse.net>, Gal Pressman
<gal@...dia.com>, "jv@...sburgh.net" <jv@...sburgh.net>, "kuba@...nel.org"
<kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>, Saeed Mahameed
<saeedm@...dia.com>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net V3 1/3] bonding: implement xdo_dev_state_free and call
it after deletion
On Tue, 2024-08-06 at 16:45 +0800, Hangbin Liu wrote:
> On Mon, Aug 05, 2024 at 08:03:55AM +0300, Tariq Toukan wrote:
> > From: Jianbo Liu <jianbol@...dia.com>
> >
> > Add this implementation for bonding, so hardware resources can be
> > freed after xfrm state is deleted.
> >
> > And call it when deleting all SAs from old active real interface.
> >
> > Fixes: 9a5605505d9c ("bonding: Add struct bond_ipesc to manage SA")
> > Signed-off-by: Jianbo Liu <jianbol@...dia.com>
> > Signed-off-by: Tariq Toukan <tariqt@...dia.com>
> > ---
> > drivers/net/bonding/bond_main.c | 32
> > ++++++++++++++++++++++++++++++++
> > 1 file changed, 32 insertions(+)
> >
> > diff --git a/drivers/net/bonding/bond_main.c
> > b/drivers/net/bonding/bond_main.c
> > index 1cd92c12e782..eb5e43860670 100644
> > --- a/drivers/net/bonding/bond_main.c
> > +++ b/drivers/net/bonding/bond_main.c
> > @@ -581,6 +581,8 @@ static void bond_ipsec_del_sa_all(struct
> > bonding *bond)
> > __func__);
> > } else {
> > slave->dev->xfrmdev_ops-
> > >xdo_dev_state_delete(ipsec->xs);
> > + if (slave->dev->xfrmdev_ops-
> > >xdo_dev_state_free)
> > + slave->dev->xfrmdev_ops-
> > >xdo_dev_state_free(ipsec->xs);
> > }
> > ipsec->xs->xso.real_dev = NULL;
> > }
> > @@ -588,6 +590,35 @@ static void bond_ipsec_del_sa_all(struct
> > bonding *bond)
> > rcu_read_unlock();
> > }
> >
> > +static void bond_ipsec_free_sa(struct xfrm_state *xs)
> > +{
> > + struct net_device *bond_dev = xs->xso.dev;
> > + struct net_device *real_dev;
> > + struct bonding *bond;
> > + struct slave *slave;
> > +
> > + if (!bond_dev)
> > + return;
> > +
> > + rcu_read_lock();
> > + bond = netdev_priv(bond_dev);
> > + slave = rcu_dereference(bond->curr_active_slave);
> > + real_dev = slave ? slave->dev : NULL;
> > + rcu_read_unlock();
> > +
> > + if (!slave)
> > + return;
> > +
> > + if (!xs->xso.real_dev)
> > + return;
> > +
> > + WARN_ON(xs->xso.real_dev != real_dev);
> > +
> > + if (real_dev && real_dev->xfrmdev_ops &&
> > + real_dev->xfrmdev_ops->xdo_dev_state_free)
> > + real_dev->xfrmdev_ops->xdo_dev_state_free(xs);
>
> Do we need to check netif_is_bond_master(slave->dev) here?
Probably no need, because we will not call xdo_dev_state_free only. It
is called after xdo_dev_state_delete.
>
> Thanks
> Hangbin
Powered by blists - more mailing lists