Skip to content

feat(vmnetsock): normalize UDP L4 GSO datagrams - #309

Merged
Code-Hex merged 3 commits into
mainfrom
codex/vmnetsock-udp-gso
Nov 1, 2026
Merged

Code-Hex merged 3 commits into
mainfrom
codex/vmnetsock-udp-gso

Conversation

@Code-Hex

@Code-Hex Code-Hex commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Virtio UDP_L4 GSO currently stops forwarding in vmnetsock. This PR adds segmentation into complete UDP datagrams for WithVirtioHeaderConversion and WithPeerVirtioHeaderNormalization.

The adapter emits datagrams with gso_size bytes of payload, except for a shorter final datagram. The adapter updates IP and UDP lengths, IPv4 IDs, and checksums. UDP segmentation has no connection state and does not require a TCP handshake. Dup and Close keep their existing contracts.

Scope

  • Add IPv4 and IPv6 UDP_L4 segmentation to the existing bounded packet batches.
  • Share the existing checksum arithmetic with TCP without changing its behavior.
  • Add regression tests for datagram boundaries, checksum completion, invalid metadata, MTU limits, padding, input ownership, and batch write errors.

Limits

  • GSO still requires vmnet.WithInterfaceTSO(true) because the adapter uses that setting for aggregate input and output buffers. Input must fit iface.MaxPacketSize().
  • gso_size plus the IP and UDP headers must fit the interface MTU. Oversized values fail before output. Reducing gso_size would change UDP datagram boundaries.
  • UDP_L4 requires NEEDS_CSUM with checksum metadata that matches the UDP header. Output has a complete checksum.
  • UDP packets must have fixed IPv4 or IPv6 headers, without fragments or VLAN tags. IPv4 options, IPv6 extension headers, and jumbograms are unsupported.
  • Legacy UFO and UDP RSC remain unsupported. The TCP-only GSO ECN modifier is invalid for UDP_L4. IP ECN bits are preserved.
  • Local guest tests exercise UDP_L4 produced by Linux TAP with UDP_SEGMENT. They do not test USO negotiation by QEMU, VZ, or krunkit virtio NICs.

UDP_L4 segmentation follows Virtio 1.3 and the Linux distinction between USO and UFO.

@Code-Hex
Code-Hex merged commit 3298d84 into main Nov 1, 2026
13 checks passed
@Code-Hex
Code-Hex deleted the codex/vmnetsock-udp-gso branch November 1, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant