Skip to content

Commit c04fdca

Browse files
author
Paolo Abeni
committed
Merge tag 'ipsec-2025-08-11' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
Steffen Klassert says: ==================== pull request (net): ipsec 2025-08-11 1) Fix flushing of all states in xfrm_state_fini. From Sabrina Dubroca. 2) Fix some IPsec software offload features. These got lost with some recent HW offload changes. From Sabrina Dubroca. Please pull or let me know if there are problems. * tag 'ipsec-2025-08-11' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec: udp: also consider secpath when evaluating ipsec use for checksumming xfrm: bring back device check in validate_xmit_xfrm xfrm: restore GSO for SW crypto xfrm: flush all states in xfrm_state_fini ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 7407881 + d836918 commit c04fdca

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

net/ipv4/udp_offload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
217217
remcsum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TUNNEL_REMCSUM);
218218
skb->remcsum_offload = remcsum;
219219

220-
need_ipsec = skb_dst(skb) && dst_xfrm(skb_dst(skb));
220+
need_ipsec = (skb_dst(skb) && dst_xfrm(skb_dst(skb))) || skb_sec_path(skb);
221221
/* Try to offload checksum if possible */
222222
offload_csum = !!(need_csum &&
223223
!need_ipsec &&

net/ipv6/xfrm6_tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static void __net_exit xfrm6_tunnel_net_exit(struct net *net)
334334
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
335335
unsigned int i;
336336

337-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
337+
xfrm_state_flush(net, 0, false);
338338
xfrm_flush_gc();
339339

340340
for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)

net/xfrm/xfrm_device.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
155155
return skb;
156156
}
157157

158-
if (skb_is_gso(skb) && unlikely(xmit_xfrm_check_overflow(skb))) {
158+
if (skb_is_gso(skb) && (unlikely(x->xso.dev != dev) ||
159+
unlikely(xmit_xfrm_check_overflow(skb)))) {
159160
struct sk_buff *segs;
160161

161162
/* Packet got rerouted, fixup features and segment it. */
@@ -415,10 +416,12 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
415416
struct net_device *dev = x->xso.dev;
416417
bool check_tunnel_size;
417418

418-
if (x->xso.type == XFRM_DEV_OFFLOAD_UNSPECIFIED)
419+
if (!x->type_offload ||
420+
(x->xso.type == XFRM_DEV_OFFLOAD_UNSPECIFIED && x->encap))
419421
return false;
420422

421-
if ((dev == xfrm_dst_path(dst)->dev) && !xdst->child->xfrm) {
423+
if ((!dev || dev == xfrm_dst_path(dst)->dev) &&
424+
!xdst->child->xfrm) {
422425
mtu = xfrm_state_mtu(x, xdst->child_mtu_cached);
423426
if (skb->len <= mtu)
424427
goto ok;
@@ -430,6 +433,9 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
430433
return false;
431434

432435
ok:
436+
if (!dev)
437+
return true;
438+
433439
check_tunnel_size = x->xso.type == XFRM_DEV_OFFLOAD_PACKET &&
434440
x->props.mode == XFRM_MODE_TUNNEL;
435441
switch (x->props.family) {

net/xfrm/xfrm_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ void xfrm_state_fini(struct net *net)
32973297
unsigned int sz;
32983298

32993299
flush_work(&net->xfrm.state_hash_work);
3300-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
3300+
xfrm_state_flush(net, 0, false);
33013301
flush_work(&xfrm_state_gc_work);
33023302

33033303
WARN_ON(!list_empty(&net->xfrm.state_all));

0 commit comments

Comments
 (0)