Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net-next v5 0/2] net: keep the TCP fixed-ID flags on the header they describe
@ 2026-12-04 22:45 Julius Bairaktaris
  2026-12-04 22:45 ` [PATCH net-next v5 1/2] " Julius Bairaktaris
  2026-12-04 22:45 ` [PATCH net-next v5 2/2] selftests: net: check TCP IP IDs across tunnels after GRO and GSO Julius Bairaktaris
  0 siblings, 2 replies; 3+ messages in thread
From: Julius Bairaktaris @ 2026-12-04 22:45 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, willemb, horms, andrew+netdev,
	dsahern, idosch, ncardwell, kuniyu, steffen.klassert, herbert,
	ecree.xilinx, andy.moreton, alex.austin, linux-net-drivers,
	saeedm, tariqt, mbloch, leon, linux-rdma, alexei.starovoitov, ast,
	daniel, andrii, eddyz87, memxor, martin.lau, song, yonghong.song,
	jolsa, emil, ihor.solodrai, john.fastabend, sdf, izaiahsun,
	zirajs7, corbet, skhan, rdunlap, shuah, bpf, ipsec, linux-doc,
	linux-kselftest, linux-kernel

GRO sets SKB_GSO_TCP_FIXEDID for a TCP packet whose IPv4 IDs do not
change. Since commit 3271f19bf7b9 ("net: gso: restore ids of outer ip
headers correctly") the flag describes the outermost header and
SKB_GSO_TCP_FIXEDID_INNER the inner one, so every path that adds or
removes a header would have to move the flags. None does, and a TCP
stream that GRO merged and that crosses a tunnel boundary is segmented
with the fixed-ID state of the wrong header.

Patch 1 lets SKB_GSO_TCP_FIXEDID describe the innermost header again and
replaces the inner flag with SKB_GSO_TCP_FIXEDID_OUTER, as Alexei
suggested in review of v1. iptunnel_handle_offloads() and the BPF LWT
encapsulation clear the outer flag when they add a header,
iptunnel_pull_offloads() and bpf_skb_net_shrink() when they remove one,
and ESP transport and BEET mode with crypto offload, which keep the IPv4
header, copy the inner flag to the outer one. GRO of an IPv6 stream in
an IPv4 tunnel sets the outer flag as it does for an IPv4 stream, and
xfrm_output() no longer treats a decapsulated packet as an encapsulated
one. Two flags cannot describe the middle header of a packet with three
IPv4 headers: software segmentation uses SKB_GSO_TCP_FIXEDID for it, as
it used SKB_GSO_TCP_FIXEDID_INNER before. Patch 2 adds a selftest.

A host with GRO on its ingress device that forwards a TCP stream into or
out of an IPIP, GRE, VXLAN or crypto-offloaded ESP tunnel sends IPv4 IDs
that repeat across the segments of a tunnel's outer header, or that
change on a header whose IDs the sender kept fixed.

The hosted Sashiko AI review of v2 2/3 of my "ipmr: forward GSO multicast
packets" series reported the issue [1], its reviews of the later
versions the IPv6, xfrm_output() and selftest points, and the selftest
in patch 2 reproduces each.

Tested in QEMU (KVM) with the selftest, 25 cases, 400 segments each:
- net-next (d5cf954cebe4), the 6in4 and ESP cases, 1 run: 6in4 with
  fixed outer IDs fails (390 outer IDs the sender did not write), the
  ESP tunnel mode cases fail (390 of 400 inner IDs renumbered, or after
  fraglist GRO no outer ID increments), ESP transport mode after VXLAN
  decapsulation fails (390), and after fraglist GRO all 400 segments
  are dropped as SKB_BAD_GSO.
- v4, the same cases, 2 runs: both ESP cases after VXLAN decapsulation
  with fraglist GRO lose all 400 segments (SKB_BAD_GSO), the rest pass.
- this series, the same cases, 1 run, and the whole selftest, 3 runs:
  every case passes.

Changes in v5:
- Patch 1: in xfrm_output(), clear skb->inner_protocol in the crypto
  offload path for a packet that is not encapsulated, so that the tunnel
  and transport mode outputs record its inner headers; after fraglist
  GRO and a decapsulation v4 dropped the ESP packet as SKB_BAD_GSO
  (Sashiko, Willem).
- Patch 2: check the 6in4 outer IDs against the values the sender wrote
  (Sashiko); add ESP cases after VXLAN decapsulation with fraglist GRO
  and in transport mode.
- Rebased onto net-next d5cf954cebe4.
- The flowtable's IPIP and IP6IP6 decapsulation keeps the encapsulation
  state of the removed header, with and without this series (Sashiko);
  that is a separate netfilter fix.
- v4: https://lore.kernel.org/netdev/cover.1795869698.git.julius@bairaktaris.de/
- v3: https://lore.kernel.org/netdev/cover.1795284858.git.julius@bairaktaris.de/
- v2: https://lore.kernel.org/netdev/cover.1794139176.git.julius@bairaktaris.de/
- v1: https://lore.kernel.org/netdev/cover.1792857378.git.julius@bairaktaris.de/

[1] https://lore.kernel.org/netdev/179182559332.434549.18294510093742639467@kernel.org/

I used Claude (Anthropic) to help write these patches.

Julius Bairaktaris (2):
  net: keep the TCP fixed-ID flags on the header they describe
  selftests: net: check TCP IP IDs across tunnels after GRO and GSO

 .../networking/segmentation-offloads.rst      |   8 +-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   |   8 +-
 drivers/net/ethernet/sfc/ef100_tx.c           |  12 +-
 include/linux/netdevice.h                     |   2 +-
 include/linux/skbuff.h                        |  12 +-
 include/net/ip_tunnels.h                      |   1 +
 include/uapi/linux/bpf.h                      |  16 +-
 net/core/filter.c                             |   1 +
 net/core/lwt_bpf.c                            |   2 +
 net/ipv4/af_inet.c                            |   9 +-
 net/ipv4/ip_tunnel_core.c                     |   2 +
 net/ipv4/tcp_offload.c                        |   7 +-
 net/ipv6/tcpv6_offload.c                      |   5 +-
 net/xfrm/xfrm_output.c                        |  20 +
 tools/include/uapi/linux/bpf.h                |  16 +-
 tools/testing/selftests/net/.gitignore        |   1 +
 tools/testing/selftests/net/Makefile          |   2 +
 tools/testing/selftests/net/tcp_fixedid.c     | 554 ++++++++++++++++++
 tools/testing/selftests/net/tcp_fixedid.sh    | 494 ++++++++++++++++
 19 files changed, 1132 insertions(+), 40 deletions(-)
 create mode 100644 tools/testing/selftests/net/tcp_fixedid.c
 create mode 100755 tools/testing/selftests/net/tcp_fixedid.sh


base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 22:45 [PATCH net-next v5 0/2] net: keep the TCP fixed-ID flags on the header they describe Julius Bairaktaris
2026-12-04 22:45 ` [PATCH net-next v5 1/2] " Julius Bairaktaris
2026-12-04 22:45 ` [PATCH net-next v5 2/2] selftests: net: check TCP IP IDs across tunnels after GRO and GSO Julius Bairaktaris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox