Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 30 Nov 2026 04:52
Re: [PATCH ipsec 1/3] xfrm: iptfs: don't let the inner MTU wrap around
Author: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 04:52
Date: Mon, 30 Nov 2026 04:52
130 lines
12455 bytes
12455 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch makes __iptfs_get_inner_mtu() return 0 when nothing
fits.
- [Low] The kernel-doc of iptfs_get_inner_mtu()
(net/xfrm/xfrm_iptfs.c:2535) still says 'Return: Correct MTU taking inβ¦
--
xfrm: iptfs: don't let the inner MTU wrap around
This patch makes __iptfs_get_inner_mtu() return 0 instead of wrapping
around when the outer MTU is too small for the SA overhead. It also drops
such packets in iptfs_output_queued(). The get_inner_mtu callback raises
the 0 to 1, as xfrm_state_mtu() does.
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> index 76272b0a18296..ea88c6618ca73 100644
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
[ ... ]
> @@ -2505,17 +2506,25 @@ static int iptfs_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
> * @x: xfrm state.
> * @outer_mtu: the outer mtu
> *
> - * Return: Correct MTU taking in to account the encap overhead.
> + * Return: Correct MTU taking in to account the encap overhead, or 0 if the
> + * outer MTU leaves no room for data.
> */
> static u32 __iptfs_get_inner_mtu(struct xfrm_state *x, int outer_mtu)
> {
> struct crypto_aead *aead;
> - u32 blksize;
> + u32 blksize, overhead, payload;
>
> aead = x->data;
> blksize = ALIGN(crypto_aead_blocksize(aead), 4);
> - return ((outer_mtu - x->props.header_len - crypto_aead_authsize(aead)) &
> - ~(blksize - 1)) - 2;
> + overhead = x->props.header_len + crypto_aead_authsize(aead);
> + if (outer_mtu <= overhead)
> + return 0;
> +
> + payload = (outer_mtu - overhead) & ~(blksize - 1);
> + if (payload <= 2)
> + return 0;
> +
> + return payload - 2;
> }
[Severity: Low]
Only iptfs_get_inner_mtu() raises the new 0 return value to 1.
iptfs_get_cur_pmtu() is the other caller, and it passes the raw value
through:
net/xfrm/xfrm_iptfs.c:iptfs_get_cur_pmtu() {
...
u32 pmtu = __iptfs_get_inner_mtu(x, xdst->child_mtu_cached);
if (payload_mtu && payload_mtu < pmtu)
pmtu = payload_mtu;
return pmtu;
}
Take a dont_frag SA whose outer MTU is at most the overhead, such as the
IPv4 MTU 68 with AES-CBC-256/HMAC-SHA512-256 case from the commit
message. In that case iptfs_output_collect() passes pmtu == 0 to
iptfs_is_too_big(). That function treats every packet as too big and
reports the 0:
net/xfrm/xfrm_iptfs.c:iptfs_is_too_big() {
...
if (sk)
xfrm_local_error(skb, pmtu);
else if (ip_hdr(skb)->version == 4)
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(pmtu));
else
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, pmtu);
...
}
Would this put an MTU of 0 in the ICMP FRAG_NEEDED and PKT_TOOBIG
messages and in the socket error queue? For the same SA,
xfrm_state_mtu() reports 1.
Before this patch the value wrapped to about 4G, so this path never ran
for this configuration. iptfs_output_queued() drops on !mtu without
reporting any MTU, so this enqueue path is the only place that reports 0.
The later patches in the series leave iptfs_get_cur_pmtu() and
iptfs_is_too_big() unchanged here. After "xfrm: iptfs: keep outer packets
within pkt_size", iptfs_get_cur_pmtu() still returns 0 when
child_mtu_cached leaves no room.
The packets are dropped either way, so only the reported value differs.
Should iptfs_get_cur_pmtu() or iptfs_is_too_big() use the same "?: 1"
floor so both paths report the same MTU?
>
> /**
> @@ -2532,7 +2541,8 @@ static u32 iptfs_get_inner_mtu(struct xfrm_state *x, int outer_mtu)
> /* If not dont-frag we have no MTU */
> if (!xtfs->cfg.dont_frag)
> return x->outer_mode.family == AF_INET ? IP_MAX_MTU : IP6_MAX_MTU;
> - return __iptfs_get_inner_mtu(x, outer_mtu);
> + /* Like xfrm_state_mtu() for the other modes, never return 0 */
> + return __iptfs_get_inner_mtu(x, outer_mtu) ?: 1;
> }
[Severity: Low]
This isn't a bug, but the kernel-doc above iptfs_get_inner_mtu() still
says:
* Return: Correct MTU taking in to account the encap overhead.
The function now also returns 1 when the outer MTU can't carry any data.
The patch updated the Return: line of __iptfs_get_inner_mtu() for its 0
case. Could this Return: line mention the 1 case too? The later patches
in the series don't change this comment either.
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/8cfaaaca-0668-485f-bc87-f9fde6c4b25d%40mid.andrii.net
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads