Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch fixes the family test, but small_ipv6 in
xfrm4_tunnel_encap_add() (net/xfrm/xfrm_output.c:283-284) is still…
--
xfrm: check inner family via skb_dst for small_ipv6 DF clearing
This commit changes the small_ipv6 test in xfrm4_tunnel_encap_add(). It
now checks dst->ops->family == AF_INET6 instead of skb->protocol, because
xfrm4_prepare_output() has already set skb->protocol to ETH_P_IP. The aim
is to clear the outer IPv4 DF bit when the inner IPv6 frame is 1280 bytes
or less.
> diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
> index f1f612cd7b438..60ffe9549c094 100644
> --- a/net/xfrm/xfrm_output.c
> +++ b/net/xfrm/xfrm_output.c
> @@ -275,11 +275,14 @@ static int xfrm4_beet_encap_add(struct xfrm_state *x, struct sk_buff *skb)
> */
> static int xfrm4_tunnel_encap_add(struct xfrm_state *x, struct sk_buff *skb)
> {
> - bool small_ipv6 = (skb->protocol == htons(ETH_P_IPV6)) && (skb->len <= IPV6_MIN_MTU);
> struct dst_entry *dst = skb_dst(skb);
> struct iphdr *top_iph;
> + bool small_ipv6;
> int flags;
>
> + small_ipv6 = (dst->ops->family == AF_INET6) &&
> + (skb->len <= IPV6_MIN_MTU);
> +
[Severity: High]
Does this test still give the wrong answer for GSO skbs that take the ESP
offload path?
The commit message says that "skb->len still holds the unencapsulated
inner packet length". On this path, though, skb->len appears to be the
length of the whole unsegmented GSO skb.
In xfrm_output(), when xfrm_dev_offload_ok() returns true and the skb is
GSO with no inner_protocol (for example, locally generated TCP over IPv6),
the skb is not segmented first:
net/xfrm/xfrm_output.c:xfrm_output() {
...
if (skb_is_gso(skb)) {
if (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL)
return xfrm_output_gso(net, sk, skb);
skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
goto out;
}
...
}
It then reaches xfrm4_tunnel_encap_add() through this chain:
xfrm_output2()->xfrm_output_resume()->xfrm_output_one()->
xfrm4_prepare_output()->xfrm4_tunnel_encap_add()
At that point skb->len can be close to 64KB.
Earlier on the same skb, xfrm6_tunnel_check_size() checks each segment
rather than the total length:
net/xfrm/xfrm_output.c:xfrm6_tunnel_check_size() {
...
if ((!skb_is_gso(skb) && skb->len > mtu) ||
(skb_is_gso(skb) &&
!skb_gso_validate_network_len(skb, ip6_skb_dst_mtu(skb)))) {
...
}
So every segment can be an IPv6 frame of 1280 bytes or less while
small_ipv6 is still false. In that case frag_off is taken from
XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF), and xfrm6_extract_header()
always sets that field to htons(IP_DF). When esp4_gso_segment() or
hardware crypto offload segments the skb later, each segment gets a copy
of the outer IPv4 header with DF set.
This path does not seem to need offload hardware. xfrm_set_type_offload(x,
false) sets x->type_offload whenever esp4_offload is registered. For a
plain ESP software SA (x->xso.dev == NULL, x->encap == NULL),
xfrm_dev_offload_ok() then reaches:
net/xfrm/xfrm_device.c:xfrm_dev_offload_ok() {
...
ok:
if (!dev)
return true;
...
}
The ESP-in-UDP case reported in the commit message looks fully fixed.
With x->encap set, xfrm_dev_offload_ok() returns false, and the GSO skb
is segmented in xfrm_output_gso() before encapsulation.
Would it make sense to mirror xfrm6_tunnel_check_size() here, along these
lines?
small_ipv6 = dst->ops->family == AF_INET6 &&
(skb_is_gso(skb) ?
skb_gso_validate_network_len(skb, IPV6_MIN_MTU) :
skb->len <= IPV6_MIN_MTU);
> if (!skb->inner_protocol) {
> skb_set_inner_network_header(skb, skb_network_offset(skb));
> skb_set_inner_transport_header(skb, skb_transport_offset(skb));
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40secunet.com