Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Julius Bairaktaris <julius@bairaktaris.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, willemb@google.com, horms@kernel.org,
	andrew+netdev@lunn.ch, dsahern@kernel.org, idosch@nvidia.com,
	ncardwell@google.com, kuniyu@google.com,
	steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
	richardbgobert@gmail.com, ecree.xilinx@gmail.com,
	andy.moreton@amd.com, alex.austin@amd.com,
	linux-net-drivers@amd.com, saeedm@nvidia.com, tariqt@nvidia.com,
	mbloch@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org,
	alexei.starovoitov@gmail.com, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com,
	memxor@gmail.com, martin.lau@linux.dev, song@kernel.org,
	yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
	ihor.solodrai@linux.dev, john.fastabend@gmail.com,
	sdf@fomichev.me, izaiahsun@gmail.com, zirajs7@gmail.com,
	corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
	shuah@kernel.org, bpf@vger.kernel.org, ipsec@lists.linux.dev,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next v4 0/2] net: keep the TCP fixed-ID flags on the header they describe
Date: Sat, 28 Nov 2026 15:07:32 +0100	[thread overview]
Message-ID: <cover.1795869698.git.julius@bairaktaris.de> (raw)

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. A header added in front of a packet that is
already encapsulated clears the outer flag, 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 segments
a decapsulated packet for a tunnel mode SA 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.

Trigger: a host with GRO on its ingress device forwards a TCP stream
into or out of an IPIP, GRE, VXLAN or crypto-offloaded ESP tunnel; any
sender on the network can produce the stream. Impact: 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; no crash or memory
corruption. CVSS 3.1 3.7 (AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N). Until
the fix: "ethtool -K <dev> gro off" on the ingress device.

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

Tested in QEMU (KVM) with the selftest, 22 cases, 400 segments each:
- net (d5b89d55a322), the new cases, 1 run: 6in4 with fixed outer IDs
  fails (40 distinct outer IDs for 400 segments, want 1), and so do
  both ESP tunnel mode cases (390 of 400 segments carry an inner ID the
  sender did not use).
- v3 of this series, the new cases, 1 run: 6in4 with fixed outer IDs
  and ESP tunnel mode after VXLAN decapsulation fail, as above.
- this series on net-next (f89726ffabef), 3 of 3 runs: 22 of 22 pass,
  and with 2 busy loops on the 4 vCPUs, 3 of 3 runs: 22 of 22 pass.
- the v3 receiver on the v3 kernel with 2 busy loops on the 4 vCPUs,
  the 12 encap cases, 5 runs: 60 of 60 cases lose 18 to 62 segments,
  each exactly the frames the socket dropped, as on NIPA; the v4
  receiver: 0 of 60.

Changes in v4:
- Target net-next, as Paolo asked; rebased onto net-next f89726ffabef,
  and the Fixes: tag dropped.
- Patch 1: set SKB_GSO_TCP_FIXEDID_OUTER in tcp6_gro_complete() for an
  IPv4 outer header with fixed IDs in front of an IPv6 TCP stream;
  segmentation numbered those IDs from the first one (Sashiko).
- Patch 1: in xfrm_output(), segment a GSO packet for a tunnel mode SA
  before ESP only if it is still encapsulated; a decapsulated packet kept
  skb->inner_protocol, and its only IPv4 header got the outer flag
  (Sashiko).
- Patch 2: read the captured frames from a PACKET_RX_RING with room for
  every frame of a case and fail a case on a socket drop; on NIPA the
  socket buffer overflowed while the receiver was not scheduled (Paolo).
- Patch 2: add 6in4 cases with fixed and incrementing outer IDs and an
  ESP tunnel mode case after VXLAN decapsulation.
- 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                        |  18 +-
 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     | 538 ++++++++++++++++++
 tools/testing/selftests/net/tcp_fixedid.sh    | 472 +++++++++++++++
 19 files changed, 1091 insertions(+), 41 deletions(-)
 create mode 100644 tools/testing/selftests/net/tcp_fixedid.c
 create mode 100755 tools/testing/selftests/net/tcp_fixedid.sh


base-commit: f89726ffabef1b08c52e6163b7ab94b0d5f15503
-- 
2.53.0


             reply	other threads:[~2026-11-28 14:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 14:07 Julius Bairaktaris [this message]
2026-11-28 14:07 ` [PATCH net-next v4 1/2] net: keep the TCP fixed-ID flags on the header they describe Julius Bairaktaris
2026-11-28 14:07 ` [PATCH net-next v4 2/2] selftests: net: check TCP IP IDs across tunnels after GRO and GSO Julius Bairaktaris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1795869698.git.julius@bairaktaris.de \
    --to=julius@bairaktaris.de \
    --cc=alex.austin@amd.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=andy.moreton@amd.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=ecree.xilinx@gmail.com \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=ipsec@lists.linux.dev \
    --cc=izaiahsun@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-net-drivers@amd.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mbloch@nvidia.com \
    --cc=memxor@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=richardbgobert@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    --cc=yonghong.song@linux.dev \
    --cc=zirajs7@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox