Skip to content

feat(vmnetsock): convert Virtio headers for Ethernet peers - #293

Merged
Code-Hex merged 2 commits into
mainfrom
codex/vmnetsock-virtio-conversion
Oct 29, 2026
Merged

Code-Hex merged 2 commits into
mainfrom
codex/vmnetsock-virtio-conversion

Conversation

@Code-Hex

Copy link
Copy Markdown
Owner

Why

A vmnet interface with Virtio headers cannot connect directly to a peer that expects plain Ethernet frames. Removing the header alone can leave partial checksums unfinished.

Add vmnetsock.WithVirtioHeaderConversion() to convert between these formats. This continues the work from #205 and builds on the raw Virtio header support in #290.

Scope

The adapter completes partial checksums and removes the 12-byte Virtio header from packets sent to the peer. In the other direction, it adds a zeroed header to fully checksummed Ethernet frames.

Conversion supports both Stream and Datagram framing. The peer can use QEMU stream or socket networking, a VZ file-handle attachment, or krunkit Unixgram with offloading=off.

Interface.VirtioHeaderEnabled() and Interface.TSOEnabled() let the adapter reject incompatible settings before it opens sockets. Existing calls still pass bytes through unchanged unless conversion is enabled.

Dup still returns a caller-owned descriptor. Close stops the adapter without stopping the borrowed interface. Conversion uses reusable buffers in the existing packet pumps.

Limits

The interface must have Virtio headers enabled and TSO disabled. The adapter does not perform TSO or GSO segmentation. A nonzero GSO type or RSC_INFO combined with NEEDS_CSUM stops forwarding, and Close returns the error.

Packet tests cover partial-checksum completion, but the guest runs did not exercise NEEDS_CSUM.

The peer must supply complete Ethernet frames with finished checksums. The socket protocol does not negotiate offload features. The guest configurations covered here use MTU 1500. This change does not alter MTU settings.

@Code-Hex
Code-Hex merged commit 2ece4ca into main Oct 29, 2026
12 of 13 checks passed
@Code-Hex
Code-Hex deleted the codex/vmnetsock-virtio-conversion branch October 29, 2026 06:16
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