Re: [PATCH net-next v3 6/6] bonding: Fix multiple long standing offload races

2025-04-11 Thread Hangbin Liu
On Fri, Apr 11, 2025 at 10:49:58AM +0300, Cosmin Ratiu wrote: > Refactor the bonding ipsec offload operations to fix a number of > long-standing control plane races between state migration and user > deletion and a few other issues. > > xfrm state deletion can happen concurrently with > bond_chang

Re: [PATCH net-next v3 5/6] bonding: Mark active offloaded xfrm_states

2025-04-11 Thread Hangbin Liu
On Fri, Apr 11, 2025 at 10:49:57AM +0300, Cosmin Ratiu wrote: > When the active link is changed for a bond device, the existing xfrm > states need to be migrated over to the new link. This is done with: > - bond_ipsec_del_sa_all() goes through the offloaded states list and > removes all of them f

Re: [PATCH net-next v3 0/6] xfrm & bonding: Correct use of xso.real_dev

2025-04-11 Thread Nikolay Aleksandrov
On 4/11/25 10:49, Cosmin Ratiu wrote: > This patch series was motivated by fixing a few bugs in the bonding > driver related to xfrm state migration on device failover. > > struct xfrm_dev_offload has two net_device pointers: dev and real_dev. > The first one is the device the xfrm_state is offloa

[PATCH net-next v3 5/6] bonding: Mark active offloaded xfrm_states

2025-04-11 Thread Cosmin Ratiu
When the active link is changed for a bond device, the existing xfrm states need to be migrated over to the new link. This is done with: - bond_ipsec_del_sa_all() goes through the offloaded states list and removes all of them from hw. - bond_ipsec_add_sa_all() re-offloads all states to the new de

[PATCH net-next v3 6/6] bonding: Fix multiple long standing offload races

2025-04-11 Thread Cosmin Ratiu
Refactor the bonding ipsec offload operations to fix a number of long-standing control plane races between state migration and user deletion and a few other issues. xfrm state deletion can happen concurrently with bond_change_active_slave() operation. This manifests itself as a bond_ipsec_del_sa()

[PATCH net-next v3 4/6] xfrm: Add explicit dev to .xdo_dev_state_{add,delete,free}

2025-04-11 Thread Cosmin Ratiu
Previously, device driver IPSec offload implementations would fall into two categories: 1. Those that used xso.dev to determine the offload device. 2. Those that used xso.real_dev to determine the offload device. The first category didn't work with bonding while the second did. In a non-bonding se

[PATCH net-next v3 2/6] xfrm: Use xdo.dev instead of xdo.real_dev

2025-04-11 Thread Cosmin Ratiu
The policy offload struct was reused from the state offload and real_dev was copied from dev, but it was never set to anything else. Simplify the code by always using xdo.dev for policies. Signed-off-by: Cosmin Ratiu Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/en_ac

[PATCH net-next v3 3/6] xfrm: Remove unneeded device check from validate_xmit_xfrm

2025-04-11 Thread Cosmin Ratiu
validate_xmit_xfrm checks whether a packet already passed through it on the master device (xso.dev) and skips processing the skb again on the slave device (xso.real_dev). This check was added in commit [1] to avoid tx packets on a bond device pass through xfrm twice and get two sets of headers, bu

[PATCH net-next v3 1/6] net/mlx5: Avoid using xso.real_dev unnecessarily

2025-04-11 Thread Cosmin Ratiu
xso.real_dev is the active device of an offloaded xfrm state and is managed by bonding. As such, it's subject to change when states are migrated to a new device. Using it in places other than offloading/unoffloading the states is risky. This commit saves the device into the driver-specific struct

[PATCH net-next v3 0/6] xfrm & bonding: Correct use of xso.real_dev

2025-04-11 Thread Cosmin Ratiu
This patch series was motivated by fixing a few bugs in the bonding driver related to xfrm state migration on device failover. struct xfrm_dev_offload has two net_device pointers: dev and real_dev. The first one is the device the xfrm_state is offloaded on and the second one is used by the bonding

Re: [PATCH net-next v2 0/6] xfrm & bonding: Correct use of xso.real_dev

2025-04-11 Thread Cosmin Ratiu
On Thu, 2025-04-10 at 14:10 +0300, Nikolay Aleksandrov wrote: > > Thank you for following up on this. It's definitely not getting > cleaner with a bond > ptr in xfrm protected by two locks in different drivers, but it > should do AFAICT. > In case there is another version I'd add a big comment of

Re: [PATCH net-next v2 6/6] bonding: Fix multiple long standing offload races

2025-04-11 Thread Cosmin Ratiu
On Thu, 2025-04-10 at 03:07 +, Hangbin Liu wrote: > > The bond is not used in bond_ipsec_del_sa() any more. You can remove > it too. Right, will do, thanks for pointing it out. Cosmin.