Preserve flow ordering with Linux TAP multiqueue - #2609
Open
alatteri wants to merge 1 commit into
Open
Conversation
alatteri
marked this pull request as ready for review
August 14, 2026 22:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Use Linux TAP multiqueue when the configured receive concurrency is greater
than one. Each TAP receive worker gets its own
/dev/net/tundescriptor insteadof having every worker read the same descriptor.
This change:
IFF_MULTI_QUEUEfor multi-worker operation;Motivation and observed failure mode
The current Linux multicore path starts several receive workers, but all of
them read one TAP descriptor. Packets are dequeued from one FIFO, then handled
by different threads. Adjacent packets from a single high-rate flow can
therefore complete processing in a different order.
This was reproducible with sustained, low-latency SRT/UDP video traffic. A
single TAP reader preserved ordering but could not drain the TAP ring quickly
enough and the interface's
tx_droppedcounter increased. Multiple readers onthe shared descriptor improved drain rate but introduced packet reordering,
which appeared to SRT as gaps and unnecessary retransmissions.
Linux multiqueue provides the intended middle ground: the kernel assigns a
flow to a queue, each queue has one reader, and unrelated flows can still be
processed in parallel. This preserves ordering within a flow without removing
multicore TAP processing.
Implementation details
When
concurrency > 1, the firstTUNSETIFFusesIFF_MULTI_QUEUE. Additionaldescriptors are opened and attached to the same interface name with the same
flags. Each receive thread selects and reads only its assigned descriptor.
If an additional queue cannot be attached, interface creation fails with the
underlying error rather than silently returning to multiple readers on a
shared FIFO. The existing
multicoreEnabled,concurrency, andcpuPinningEnabledsettings remain the only configuration; this introduces nonew setting and makes no wire-protocol, routing, encryption, or controller
change.
Validation
devbranch withmake -j4.zerotier-selftest; all tests passed, including 10,000-packetUDP and 10 MB TCP transport tests.
multicoreEnabled=trueandconcurrency=2.tx_droppedcounter remained unchanged through the observation interval.Compatibility and scope