Message ID | 20240729124406.1824592-2-tariqt@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Fixes for IPsec over bonding | expand |
On Mon, Jul 29, 2024 at 03:44:02PM +0300, Tariq Toukan wrote: > From: Jianbo Liu <jianbol@nvidia.com> > > Add this implementation for bonding, so hardware resources can be > freed after xfrm state is deleted. > > Fixes: 9a5605505d9c ("bonding: Add struct bond_ipesc to manage SA") > Signed-off-by: Jianbo Liu <jianbol@nvidia.com> > Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> > Signed-off-by: Tariq Toukan <tariqt@nvidia.com> > --- > drivers/net/bonding/bond_main.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 1cd92c12e782..3b880ff2b82a 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -588,6 +588,15 @@ 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 *real_dev = xs->xso.real_dev; I think it's also good to check the bond/slave status like bond_ipsec_del_sa() does, no? > + > + if (real_dev && real_dev->xfrmdev_ops && > + real_dev->xfrmdev_ops->xdo_dev_state_free) > + real_dev->xfrmdev_ops->xdo_dev_state_free(xs); > +} And we should call this in bond_ipsec_del_sa_all() for each slave. Thanks Hangbin > + > /** > * bond_ipsec_offload_ok - can this packet use the xfrm hw offload > * @skb: current data packet > @@ -632,6 +641,7 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) > static const struct xfrmdev_ops bond_xfrmdev_ops = { > .xdo_dev_state_add = bond_ipsec_add_sa, > .xdo_dev_state_delete = bond_ipsec_del_sa, > + .xdo_dev_state_free = bond_ipsec_free_sa, > .xdo_dev_offload_ok = bond_ipsec_offload_ok, > }; > #endif /* CONFIG_XFRM_OFFLOAD */ > -- > 2.44.0 >
On Wed, 2024-07-31 at 11:27 +0800, Hangbin Liu wrote: > On Mon, Jul 29, 2024 at 03:44:02PM +0300, Tariq Toukan wrote: > > From: Jianbo Liu <jianbol@nvidia.com> > > > > Add this implementation for bonding, so hardware resources can be > > freed after xfrm state is deleted. > > > > Fixes: 9a5605505d9c ("bonding: Add struct bond_ipesc to manage SA") > > Signed-off-by: Jianbo Liu <jianbol@nvidia.com> > > Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> > > Signed-off-by: Tariq Toukan <tariqt@nvidia.com> > > --- > > drivers/net/bonding/bond_main.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/drivers/net/bonding/bond_main.c > > b/drivers/net/bonding/bond_main.c > > index 1cd92c12e782..3b880ff2b82a 100644 > > --- a/drivers/net/bonding/bond_main.c > > +++ b/drivers/net/bonding/bond_main.c > > @@ -588,6 +588,15 @@ 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 *real_dev = xs->xso.real_dev; > > I think it's also good to check the bond/slave status like > bond_ipsec_del_sa() > does, no? It seems no necessary, but I will try adding. Thanks! > > > + > > + if (real_dev && real_dev->xfrmdev_ops && > > + real_dev->xfrmdev_ops->xdo_dev_state_free) > > + real_dev->xfrmdev_ops->xdo_dev_state_free(xs); > > +} > > And we should call this in bond_ipsec_del_sa_all() for each slave. Yes, it's in the next patch. > > Thanks > Hangbin > > + > > /** > > * bond_ipsec_offload_ok - can this packet use the xfrm hw offload > > * @skb: current data packet > > @@ -632,6 +641,7 @@ static bool bond_ipsec_offload_ok(struct > > sk_buff *skb, struct xfrm_state *xs) > > static const struct xfrmdev_ops bond_xfrmdev_ops = { > > .xdo_dev_state_add = bond_ipsec_add_sa, > > .xdo_dev_state_delete = bond_ipsec_del_sa, > > + .xdo_dev_state_free = bond_ipsec_free_sa, > > .xdo_dev_offload_ok = bond_ipsec_offload_ok, > > }; > > #endif /* CONFIG_XFRM_OFFLOAD */ > > -- > > 2.44.0 > >
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 1cd92c12e782..3b880ff2b82a 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -588,6 +588,15 @@ 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 *real_dev = xs->xso.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); +} + /** * bond_ipsec_offload_ok - can this packet use the xfrm hw offload * @skb: current data packet @@ -632,6 +641,7 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) static const struct xfrmdev_ops bond_xfrmdev_ops = { .xdo_dev_state_add = bond_ipsec_add_sa, .xdo_dev_state_delete = bond_ipsec_del_sa, + .xdo_dev_state_free = bond_ipsec_free_sa, .xdo_dev_offload_ok = bond_ipsec_offload_ok, }; #endif /* CONFIG_XFRM_OFFLOAD */