Skip to content

Commit 586b7b3

Browse files
committed
Merge tag 'ipsec-next-2025-03-24' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next
Steffen Klassert says: ==================== pull request (net-next): ipsec-next 2025-03-24 1) Prevent setting high order sequence number bits input in non-ESN mode. From Leon Romanovsky. 2) Support PMTU handling in tunnel mode for packet offload. From Leon Romanovsky. 3) Make xfrm_state_lookup_byaddr lockless. From Florian Westphal. 4) Remove unnecessary NULL check in xfrm_lookup_with_ifid(). From Dan Carpenter. * tag 'ipsec-next-2025-03-24' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next: xfrm: Remove unnecessary NULL check in xfrm_lookup_with_ifid() xfrm: state: make xfrm_state_lookup_byaddr lockless xfrm: check for PMTU in tunnel mode for packet offload xfrm: provide common xdo_dev_offload_ok callback implementation xfrm: rely on XFRM offload xfrm: simplify SA initialization routine xfrm: delay initialization of offload path till its actually requested xfrm: prevent high SEQ input in non-ESN mode ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a8b4ea7 + 399e0aa commit 586b7b3

File tree

17 files changed

+102
-193
lines changed

17 files changed

+102
-193
lines changed

Documentation/networking/xfrm_device.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ been setup for offload, it first calls into xdo_dev_offload_ok() with
126126
the skb and the intended offload state to ask the driver if the offload
127127
will serviceable. This can check the packet information to be sure the
128128
offload can be supported (e.g. IPv4 or IPv6, no IPv4 options, etc) and
129-
return true of false to signify its support.
129+
return true or false to signify its support. In case driver doesn't implement
130+
this callback, the stack provides reasonable defaults.
130131

131132
Crypto offload mode:
132133
When ready to send, the driver needs to inspect the Tx packet for the

drivers/net/bonding/bond_main.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -674,22 +674,16 @@ static void bond_ipsec_free_sa(struct xfrm_state *xs)
674674
static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
675675
{
676676
struct net_device *real_dev;
677-
bool ok = false;
678677

679678
rcu_read_lock();
680679
real_dev = bond_ipsec_dev(xs);
681-
if (!real_dev)
682-
goto out;
683-
684-
if (!real_dev->xfrmdev_ops ||
685-
!real_dev->xfrmdev_ops->xdo_dev_offload_ok ||
686-
netif_is_bond_master(real_dev))
687-
goto out;
680+
if (!real_dev || netif_is_bond_master(real_dev)) {
681+
rcu_read_unlock();
682+
return false;
683+
}
688684

689-
ok = real_dev->xfrmdev_ops->xdo_dev_offload_ok(skb, xs);
690-
out:
691685
rcu_read_unlock();
692-
return ok;
686+
return true;
693687
}
694688

695689
/**

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6538,26 +6538,6 @@ static void cxgb4_xfrm_free_state(struct xfrm_state *x)
65386538
mutex_unlock(&uld_mutex);
65396539
}
65406540

6541-
static bool cxgb4_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
6542-
{
6543-
struct adapter *adap = netdev2adap(x->xso.dev);
6544-
bool ret = false;
6545-
6546-
if (!mutex_trylock(&uld_mutex)) {
6547-
dev_dbg(adap->pdev_dev,
6548-
"crypto uld critical resource is under use\n");
6549-
return ret;
6550-
}
6551-
if (chcr_offload_state(adap, CXGB4_XFRMDEV_OPS))
6552-
goto out_unlock;
6553-
6554-
ret = adap->uld[CXGB4_ULD_IPSEC].xfrmdev_ops->xdo_dev_offload_ok(skb, x);
6555-
6556-
out_unlock:
6557-
mutex_unlock(&uld_mutex);
6558-
return ret;
6559-
}
6560-
65616541
static void cxgb4_advance_esn_state(struct xfrm_state *x)
65626542
{
65636543
struct adapter *adap = netdev2adap(x->xso.dev);
@@ -6583,7 +6563,6 @@ static const struct xfrmdev_ops cxgb4_xfrmdev_ops = {
65836563
.xdo_dev_state_add = cxgb4_xfrm_add_state,
65846564
.xdo_dev_state_delete = cxgb4_xfrm_del_state,
65856565
.xdo_dev_state_free = cxgb4_xfrm_free_state,
6586-
.xdo_dev_offload_ok = cxgb4_ipsec_offload_ok,
65876566
.xdo_dev_state_advance_esn = cxgb4_advance_esn_state,
65886567
};
65896568

drivers/net/ethernet/chelsio/inline_crypto/ch_ipsec/chcr_ipsec.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
static LIST_HEAD(uld_ctx_list);
7272
static DEFINE_MUTEX(dev_mutex);
7373

74-
static bool ch_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
7574
static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state);
7675
static int ch_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
7776
static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop);
@@ -85,7 +84,6 @@ static const struct xfrmdev_ops ch_ipsec_xfrmdev_ops = {
8584
.xdo_dev_state_add = ch_ipsec_xfrm_add_state,
8685
.xdo_dev_state_delete = ch_ipsec_xfrm_del_state,
8786
.xdo_dev_state_free = ch_ipsec_xfrm_free_state,
88-
.xdo_dev_offload_ok = ch_ipsec_offload_ok,
8987
.xdo_dev_state_advance_esn = ch_ipsec_advance_esn_state,
9088
};
9189

@@ -323,20 +321,6 @@ static void ch_ipsec_xfrm_free_state(struct xfrm_state *x)
323321
module_put(THIS_MODULE);
324322
}
325323

326-
static bool ch_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
327-
{
328-
if (x->props.family == AF_INET) {
329-
/* Offload with IP options is not supported yet */
330-
if (ip_hdr(skb)->ihl > 5)
331-
return false;
332-
} else {
333-
/* Offload with IPv6 extension headers is not support yet */
334-
if (ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
335-
return false;
336-
}
337-
return true;
338-
}
339-
340324
static void ch_ipsec_advance_esn_state(struct xfrm_state *x)
341325
{
342326
/* do nothing */

drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -817,30 +817,9 @@ static void ixgbe_ipsec_del_sa(struct xfrm_state *xs)
817817
}
818818
}
819819

820-
/**
821-
* ixgbe_ipsec_offload_ok - can this packet use the xfrm hw offload
822-
* @skb: current data packet
823-
* @xs: pointer to transformer state struct
824-
**/
825-
static bool ixgbe_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
826-
{
827-
if (xs->props.family == AF_INET) {
828-
/* Offload with IPv4 options is not supported yet */
829-
if (ip_hdr(skb)->ihl != 5)
830-
return false;
831-
} else {
832-
/* Offload with IPv6 extension headers is not support yet */
833-
if (ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
834-
return false;
835-
}
836-
837-
return true;
838-
}
839-
840820
static const struct xfrmdev_ops ixgbe_xfrmdev_ops = {
841821
.xdo_dev_state_add = ixgbe_ipsec_add_sa,
842822
.xdo_dev_state_delete = ixgbe_ipsec_del_sa,
843-
.xdo_dev_offload_ok = ixgbe_ipsec_offload_ok,
844823
};
845824

846825
/**

drivers/net/ethernet/intel/ixgbevf/ipsec.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -428,30 +428,9 @@ static void ixgbevf_ipsec_del_sa(struct xfrm_state *xs)
428428
}
429429
}
430430

431-
/**
432-
* ixgbevf_ipsec_offload_ok - can this packet use the xfrm hw offload
433-
* @skb: current data packet
434-
* @xs: pointer to transformer state struct
435-
**/
436-
static bool ixgbevf_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
437-
{
438-
if (xs->props.family == AF_INET) {
439-
/* Offload with IPv4 options is not supported yet */
440-
if (ip_hdr(skb)->ihl != 5)
441-
return false;
442-
} else {
443-
/* Offload with IPv6 extension headers is not support yet */
444-
if (ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
445-
return false;
446-
}
447-
448-
return true;
449-
}
450-
451431
static const struct xfrmdev_ops ixgbevf_xfrmdev_ops = {
452432
.xdo_dev_state_add = ixgbevf_ipsec_add_sa,
453433
.xdo_dev_state_delete = ixgbevf_ipsec_del_sa,
454-
.xdo_dev_offload_ok = ixgbevf_ipsec_offload_ok,
455434
};
456435

457436
/**

drivers/net/ethernet/marvell/octeontx2/nic/cn10k_ipsec.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,24 +744,9 @@ static void cn10k_ipsec_del_state(struct xfrm_state *x)
744744
queue_work(pf->ipsec.sa_workq, &pf->ipsec.sa_work);
745745
}
746746

747-
static bool cn10k_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
748-
{
749-
if (x->props.family == AF_INET) {
750-
/* Offload with IPv4 options is not supported yet */
751-
if (ip_hdr(skb)->ihl > 5)
752-
return false;
753-
} else {
754-
/* Offload with IPv6 extension headers is not support yet */
755-
if (ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
756-
return false;
757-
}
758-
return true;
759-
}
760-
761747
static const struct xfrmdev_ops cn10k_ipsec_xfrmdev_ops = {
762748
.xdo_dev_state_add = cn10k_ipsec_add_state,
763749
.xdo_dev_state_delete = cn10k_ipsec_del_state,
764-
.xdo_dev_offload_ok = cn10k_ipsec_offload_ok,
765750
};
766751

767752
static void cn10k_ipsec_sa_wq_handler(struct work_struct *work)

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -966,21 +966,6 @@ void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv)
966966
priv->ipsec = NULL;
967967
}
968968

969-
static bool mlx5e_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
970-
{
971-
if (x->props.family == AF_INET) {
972-
/* Offload with IPv4 options is not supported yet */
973-
if (ip_hdr(skb)->ihl > 5)
974-
return false;
975-
} else {
976-
/* Offload with IPv6 extension headers is not support yet */
977-
if (ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
978-
return false;
979-
}
980-
981-
return true;
982-
}
983-
984969
static void mlx5e_xfrm_advance_esn_state(struct xfrm_state *x)
985970
{
986971
struct mlx5e_ipsec_sa_entry *sa_entry = to_ipsec_sa_entry(x);
@@ -1247,7 +1232,6 @@ static const struct xfrmdev_ops mlx5e_ipsec_xfrmdev_ops = {
12471232
.xdo_dev_state_add = mlx5e_xfrm_add_state,
12481233
.xdo_dev_state_delete = mlx5e_xfrm_del_state,
12491234
.xdo_dev_state_free = mlx5e_xfrm_free_state,
1250-
.xdo_dev_offload_ok = mlx5e_ipsec_offload_ok,
12511235
.xdo_dev_state_advance_esn = mlx5e_xfrm_advance_esn_state,
12521236

12531237
.xdo_dev_state_update_stats = mlx5e_xfrm_update_stats,

drivers/net/ethernet/netronome/nfp/crypto/ipsec.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,20 +565,9 @@ static void nfp_net_xfrm_del_state(struct xfrm_state *x)
565565
xa_erase(&nn->xa_ipsec, x->xso.offload_handle - 1);
566566
}
567567

568-
static bool nfp_net_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
569-
{
570-
if (x->props.family == AF_INET)
571-
/* Offload with IPv4 options is not supported yet */
572-
return ip_hdr(skb)->ihl == 5;
573-
574-
/* Offload with IPv6 extension headers is not support yet */
575-
return !(ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr));
576-
}
577-
578568
static const struct xfrmdev_ops nfp_net_ipsec_xfrmdev_ops = {
579569
.xdo_dev_state_add = nfp_net_xfrm_add_state,
580570
.xdo_dev_state_delete = nfp_net_xfrm_del_state,
581-
.xdo_dev_offload_ok = nfp_net_ipsec_offload_ok,
582571
};
583572

584573
void nfp_net_ipsec_init(struct nfp_net *nn)

drivers/net/netdevsim/ipsec.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,9 @@ static void nsim_ipsec_del_sa(struct xfrm_state *xs)
217217
ipsec->count--;
218218
}
219219

220-
static bool nsim_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
221-
{
222-
struct netdevsim *ns = netdev_priv(xs->xso.real_dev);
223-
struct nsim_ipsec *ipsec = &ns->ipsec;
224-
225-
ipsec->ok++;
226-
227-
return true;
228-
}
229-
230220
static const struct xfrmdev_ops nsim_xfrmdev_ops = {
231221
.xdo_dev_state_add = nsim_ipsec_add_sa,
232222
.xdo_dev_state_delete = nsim_ipsec_del_sa,
233-
.xdo_dev_offload_ok = nsim_ipsec_offload_ok,
234223
};
235224

236225
bool nsim_ipsec_tx(struct netdevsim *ns, struct sk_buff *skb)

0 commit comments

Comments
 (0)