Skip to content

Commit a461b2f

Browse files
committed
Merge tag 'ipsec-2025-09-22' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
Steffen Klassert says: ==================== pull request (net): ipsec 2025-09-22 1) Fix 0 assignment for SPIs. 0 is not a valid SPI, it means no SPI assigned. 2) Fix offloading for inter address family tunnels. * tag 'ipsec-2025-09-22' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec: xfrm: fix offloading of cross-family tunnels xfrm: xfrm_alloc_spi shouldn't use 0 as SPI ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 91fc617 + 91d8a53 commit a461b2f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

net/xfrm/xfrm_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
438438

439439
check_tunnel_size = x->xso.type == XFRM_DEV_OFFLOAD_PACKET &&
440440
x->props.mode == XFRM_MODE_TUNNEL;
441-
switch (x->props.family) {
441+
switch (x->inner_mode.family) {
442442
case AF_INET:
443443
/* Check for IPv4 options */
444444
if (ip_hdr(skb)->ihl != 5)

net/xfrm/xfrm_state.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,8 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high,
25832583

25842584
for (h = 0; h < range; h++) {
25852585
u32 spi = (low == high) ? low : get_random_u32_inclusive(low, high);
2586+
if (spi == 0)
2587+
goto next;
25862588
newspi = htonl(spi);
25872589

25882590
spin_lock_bh(&net->xfrm.xfrm_state_lock);
@@ -2598,6 +2600,7 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high,
25982600
xfrm_state_put(x0);
25992601
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
26002602

2603+
next:
26012604
if (signal_pending(current)) {
26022605
err = -ERESTARTSYS;
26032606
goto unlock;

0 commit comments

Comments
 (0)