Skip to content

net/tstun: implement tun.MultiQueueDevice - #21665

Merged
illotum merged 1 commit into
mainfrom
illotum/multiqueue-tstun
Oct 7, 2026
Merged

illotum merged 1 commit into
mainfrom
illotum/multiqueue-tstun

Conversation

@illotum

@illotum illotum commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Wrapper presents one read queue per queue of the underlying device, and forwards the flow it is given on the write side.

pollVector still multiplexes injected packets onto the device's own read, which is queue 0. Wrapper.Read is now queues[0].Read and behaves exactly as it did. Locally-terminated traffic stays on flow 0.

This is a no-op change: the Wrapper presents a single queue and wireguard-go runs the single reader goroutine it ran before.

Updates tailscale/corp#37878

Change-Id: I844e95cf430075e237ad7e83bdbaa8e43e067ccb

Wrapper presents one read queue per queue of the underlying device, and
forwards the flow it is given on the write side.

pollVector still multiplexes injected packets onto the device's own
read, which is queue 0. Wrapper.Read is now queues[0].Read and behaves
exactly as it did. Locally-terminated traffic stays on flow 0.

This is a no-op change: the Wrapper presents a single queue and
wireguard-go runs the single reader goroutine it ran before.

Updates tailscale/corp#37878

Change-Id: I844e95cf430075e237ad7e83bdbaa8e43e067ccb
Signed-off-by: Alex Valiushko <[email protected]>

@raggi raggi left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation lgtm, we could add more coverage.

Comment thread net/tstun/wrap.go Resolved
raggi added a commit that referenced this pull request Oct 6, 2026
gVisor can synchronously generate replies on a TUN reader or loopback consumer. Make link endpoint queue writes nonblocking so saturation cannot stop the goroutine needed to drain the queue. TCP can retransmit; UDP and other non-retrying traffic may lose packets under load.

Count all PacketBuffers rejected by queue saturation, including the unaccepted batch tail. Expose the same per-netstack counter through user-facing and debug metrics, and sum it across netstacks for the client-metrics pipeline.

Cancel pending tstun injections during netstack shutdown, close link queues before aborting endpoints, and stop the WireGuard injection pump on a closed Wrapper. Release rejected and canceled references, drain unread injections on Wrapper close, and release capture buffers.

Keep PR #21665 multiqueue semantics: injections are multiplexed only onto queue 0. Cover independent native-reader progress, concurrent reply saturation and drop accounting, cancellation, shutdown, ownership, loopback progress, and TCP recovery.

Fixes #21631
Updates #21638
Related: #21632, #21639

Signed-off-by: James Tucker <[email protected]>
@illotum
illotum merged commit 1eb2bb6 into main Oct 7, 2026
60 checks passed
@illotum
illotum deleted the illotum/multiqueue-tstun branch October 7, 2026 19:09
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.

3 participants