xfrm: Add explicit dev to .xdo_dev_state_{add,delete,free}

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 setup the two pointers are the same.

This commit adds explicit pointers for the offload netdevice to
.xdo_dev_state_add() / .xdo_dev_state_delete() / .xdo_dev_state_free()
which eliminates the confusion and allows drivers from the first
category to work with bonding.

xso.real_dev now becomes a private pointer managed by the bonding
driver.

Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Cosmin Ratiu
2025-04-11 10:49:56 +03:00
committed by Steffen Klassert
parent d53dda291b
commit 43eca05b6a
14 changed files with 136 additions and 99 deletions

View File

@@ -75,9 +75,12 @@ static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state);
static int ch_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop);
static void ch_ipsec_advance_esn_state(struct xfrm_state *x);
static void ch_ipsec_xfrm_free_state(struct xfrm_state *x);
static void ch_ipsec_xfrm_del_state(struct xfrm_state *x);
static int ch_ipsec_xfrm_add_state(struct xfrm_state *x,
static void ch_ipsec_xfrm_free_state(struct net_device *dev,
struct xfrm_state *x);
static void ch_ipsec_xfrm_del_state(struct net_device *dev,
struct xfrm_state *x);
static int ch_ipsec_xfrm_add_state(struct net_device *dev,
struct xfrm_state *x,
struct netlink_ext_ack *extack);
static const struct xfrmdev_ops ch_ipsec_xfrmdev_ops = {
@@ -223,7 +226,8 @@ out:
* returns 0 on success, negative error if failed to send message to FPGA
* positive error if FPGA returned a bad response
*/
static int ch_ipsec_xfrm_add_state(struct xfrm_state *x,
static int ch_ipsec_xfrm_add_state(struct net_device *dev,
struct xfrm_state *x,
struct netlink_ext_ack *extack)
{
struct ipsec_sa_entry *sa_entry;
@@ -302,14 +306,16 @@ out:
return res;
}
static void ch_ipsec_xfrm_del_state(struct xfrm_state *x)
static void ch_ipsec_xfrm_del_state(struct net_device *dev,
struct xfrm_state *x)
{
/* do nothing */
if (!x->xso.offload_handle)
return;
}
static void ch_ipsec_xfrm_free_state(struct xfrm_state *x)
static void ch_ipsec_xfrm_free_state(struct net_device *dev,
struct xfrm_state *x)
{
struct ipsec_sa_entry *sa_entry;