Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
|
Chat: Review posted | View chat Review historydeep-review v0.13.0 | Round 2 | Last posted: Round 2, 9 findings (3 P3, 5 P4, 1 Nit), COMMENT. Review Finding inventoryFindings
Contested and acknowledgedCRF-5 (P4, tailnet/conn_test.go:623) - newTUNStack doc comment restates the signature
CRF-6 (P4, tailnet/conn_test.go:604) - Reused client source port 40000 is an unnamed literal
CRF-7 (P4, tailnet/conn_test.go:630) - channel.New queue size 64 is unexplained
Round logRound 1Full panel (round 1). Netero: no findings, 1 Note. Law not run (135 effective additions). Panel: ging-go, ryosuke, takumi, killua, kurapika (security-sensitive network input path, multi-domain size target), pariston, mafuuu, bisky, komugi, gon, leorio, wildcard zoro. 3 P3, 5 P4, 1 Nit, 2 Notes, 1 out of scope. CRF-5 downgraded P2 to P4: keep-argument was that the comment hides the NIC ID contract; downgraded because the comment is accurate, the helper has one caller in the same file, and CRF-4's constant carries the missing fact. CRF-2 set to P3 (Komugi) over P4 (Takumi): both reproduced; Komugi line used (Takumi's 613 points at require.Equal). Reviewed against 4e827d7..9636abc. Round 2Fix round (no files added or renamed, no exported signature change, effective additions +10; branch rebased onto 95e6a73, gVisor pin unchanged). Churn guard PROCEED: CRF-2, 4, 8, 9, 10 addressed; CRF-3 addressed in title and description; CRF-5, 6, 7 contested. Netero: no new findings. Panel: gon (resumed R1 agent for dispute check-in), komugi, takumi (CRF-2 raisers), pariston (CRF-3), leorio (CRF-8, 9), zoro (CRF-10), ging-go, bisky (Go test changes), wildcard meruem. CRF-5, 6, 7 closed 1/1. CRF-3 re-raised by Pariston and Leorio (both P4): the go.mod comment added in 70a41a1 still describes the forward unconditionally; reply on the existing thread, no new ID. CRF-2 fix verified by Komugi, Takumi, Netero, Bisky against stack.go:1688-1694 and endpoint.go:1224,1242. New: CRF-13 OOS, CRF-14 Note. Reviewed against 95e6a73..0b03c70. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
This PR bumps the gVisor fork so the agent netstack hands a SYN that reopens a TIME_WAIT 4-tuple to tcp.Forwarder, adds a tailnet regression test for it, and re-enables the two tests that #30465 skipped. 3 P3, 5 P4, 1 Nit.
Out of scope (needs a ticket or explicit acceptance by a human):
- coder/gvisor
pkg/tcpip/transport/tcp/rcv.go:586: in TIME_WAIT, gVisor accepts a reopening SYN only when its sequence number is above the old connection'sRcvNxt, has no RFC 6191 timestamp path, and drops RSTs (rcv.go:566), so a SYN that fails the sequence test still stalls the dial for the full TIME_WAIT with no way for the client to recover.
Notes:
go.mod:50:ebe33a4c2cb5exists only on the coder/gvisor#4 branch (andrefs/pull/4/head), and nothing in CI enforces the re-bump to the squash commit that the description requires before merge.go.mod:50: the reopen path calls the samewrapProtoHandler(tcpFwd.HandlePacket)as a normal SYN, after the packet filter and the WireGuard AllowedIPs check, so a peer can only reopen 4-tuples with its own source IP.
🤖 This review was automatically generated with Coder Agents.
|
In reply to CRF-1 (Note, No CI check: this PR stays in draft until coder/gvisor#4 squash-merges and In reply to CRF-11 (OOS, Same cause as CRF-3, tracked on PLAT-717.
|
8d09eaf to
bcb7405
Compare
bcb7405 to
b094a26
Compare
b094a26 to
0892aef
Compare
8f2145f to
0b03c70
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dfc393d to
0933acc
Compare
spikecurtis
left a comment
There was a problem hiding this comment.
These tests are not appropriate for coder/coder.
The issue is with gvisor and any tests for it should live there.
|
Fair, these tests were added before I pulled in the gvisor test suite needed to test it there. I'll drop them from this PR, whether or not it gets merged. |
1bbde36 to
223369e
Compare
… TIME_WAIT fix (#32752) Temporarily skip `TestACPTransport` ([CODAGT-1495](https://linear.app/codercom/issue/CODAGT-1495)) until [CORE-717](https://linear.app/codercom/issue/CORE-717) is fixed, as #30465 and #32058 do for the other tests it hits. Remove this skip with #30471. A scratch test looping this test's calls through the real `AgentConn` shows the cause: on main's gVisor pin, every dial that reused a source port the agent held in TIME_WAIT stalled (8 of about 1,316 dials). With #30471's pin, all 24 such reuses in 2,100 dials connected and nothing stalled. > 🤖 Created with the help of Coder Agents.
The agent netstack accepts TCP through tcp.Forwarder and has no listening endpoint. gVisor only hands a SYN that reuses a 4-tuple in TIME_WAIT to a listening endpoint, so the agent drops it and every retransmit until TIME_WAIT expires, about 60s later (PLAT-717). The test dials the agent twice from the same source port, after the agent closed the first connection. The client is a gVisor stack behind a channel TUN, because tailnet.Conn's own dialer cannot choose a source port. It fails against the current coder/gvisor pin and passes with a cherry-pick of gvisor/gvisor#15019. The test does not call t.Parallel: setting TUNDev enables tailscale's process-global netns setting, which sockets opened by Conns in parallel tests would pick up.
The agent netstack accepts connections through tcp.Forwarder and has no listening endpoint, so gVisor drops a SYN that reuses a 4-tuple the agent holds in TIME_WAIT, and the client's dial hangs for about 63s. The new pin is the head of coder/gvisor#4, which cherry-picks gvisor/gvisor#15019. That PR hands the SYN to the forwarder. It is open, from an outside contributor, and no gVisor maintainer has reviewed it.
They were skipped because the agent netstack dropped SYNs that reused a source port in TIME_WAIT. The coder/gvisor bump makes the agent netstack accept those SYNs.
The test's WaitLong deadline started before RunDERPAndSTUN and both NewConn calls, so setup time ate into it. Create it right before AwaitReachable instead. newTUNStack's packet pumps used that deadline context as their lifetime. Tie them to t.Context so they run until the test ends.
gVisor removes a closing endpoint from RegisteredEndpoints before it calls ReleasePort, so the second dial could race the port release and fail to bind. The endpoint stays in CleanupEndpoints until after the release, so wait for both sets to drain. Also bind to any NIC, drop "reused" from the dial failure message, and reword the doc comment and nolint reason to cite the gVisor issue the test covers.
The doc comment now names the RFC 1122 reopen condition gVisor checks, and the wait comment matches the order in which gVisor adds the endpoint to CleanupEndpoints, unregisters it, and releases the port.
Run the accept loop and the TUN pumps with testutil.Go so the test waits for them to exit instead of letting them outlive it. The pumps are registered after the stack cleanup, so they finish before the link endpoint and stack close.
coder/gvisor#4 now also hands a SYN queued on a closing TIME_WAIT connection to the forwarder instead of answering it with RST.
Picks up comment fixes only.
NewConn with a TUN device enables netns and soft isolation for the whole process, and closing the Conn does not undo that, so later tests in the package ran with both on. Reset them to their defaults, which are off, when the test returns.
Picks up comment changes only.
coder/gvisor#4 now reopens TIME_WAIT only for a SYN without ACK, so a SYN-ACK no longer ends TIME_WAIT with a RST.
coder/gvisor#4 now delivers the reopening SYN before the segments queued behind it, so a stale SYN in the queue no longer gets the SYN-ACK.
These behaviors exist only in the coder/gvisor fork, so this test fails a pin bump that drops them.
coder/gvisor#4 was rebuilt with its tests committed; the code is unchanged.
These tests exercise gVisor's TCP behavior rather than coder/coder code, so they belong in coder/gvisor next to the change they cover.
It was skipped because the agent netstack dropped SYNs that reused a source port in TIME_WAIT. The coder/gvisor pin makes the agent netstack accept those SYNs.
coder/gvisor#4 was rebased onto new-coder-main with an identical tree, and the previous pinned commit is no longer on any coder/gvisor branch.
It was skipped because the agent netstack dropped SYNs that reused a source port in TIME_WAIT. The coder/gvisor pin makes the agent netstack accept those SYNs.
223369e to
c295a6c
Compare
The workspace agent's tailnet netstack accepts TCP through
tcp.Forwarderand has no gVisor listening endpoint. gVisor only delivers a SYN that reopens a 4-tuple in TIME_WAIT to a listening endpoint, so it dropped the SYN and every retransmit until TIME_WAIT expired, and the client's dial hung for up to about 63s (gvisor/gvisor#15013). The agent holds TIME_WAIT whenever it closes first, which is every agent API request, and any forwarded port whose server closes first.This bumps the gVisor fork to coder/gvisor@327336af3995, the head of coder/gvisor#4. That branch is based on gvisor/gvisor#15019, an open PR from an outside contributor, plus our fixes for a duplicate or stale SYN queued behind the reopening SYN and for a SYN-ACK that ended TIME_WAIT. It also re-enables the two tests that #30465 skips,
TestOpenVSCodeDevContainer, which #32058 skips, andTestACPTransport, which #32752 skips.This is the reopen RFC 1122 allows, a SYN above the old connection's
RcvNxt. A reopening SYN at or below it is a separate bug, tracked in CORE-809.The fix only takes effect on upgraded agents.
Merge order: this PR pins
327336af3995, the unmerged head of coder/gvisor#4. coder/gvisor only allows squash merges, so re-bumpgo.modto the squash commit of coder/gvisor#4 before merging this PR, as main does for coder/gvisor#3 (7a658db7b714).Fixes CORE-717, CODAGT-1331, CODAGT-1336, CODAGT-1495
Evidence and decisions
Reproduction
tailnet.Conns, where the client reuses its source port after the agent closed the connection, fails 3 of 3 on the old pin, with the reused-port dial timing out, and passes 50 of 50 with the bump. A control using a fresh source port passes on the old pin.ListProcessescalls throughAgentConnagainst agenttest: 29 stalls of about 63s on the old pin, 0 with the bump. Every stall reused a source port the agent held in TIME_WAIT.Production (dogfood, one real agent)
Test scenarios against an agent without the fix. The fix has only run in the test suite and CI, not on dogfood.
listening-ports, which the dashboard polls every 5s: 5 of 2617 requests failed with a 500 after the handler's 30s timeout.coder port-forwardto a server that closes first: 0.7% to 1.0% of connections stalled for 7, 15, 31 or 63s, the SYN retransmit times. With the client closing first there were 0 stalls in 6000.coder sshis not exposed: one connection per process, from a new tailnet IP.Alternatives considered
Not included: tests of the gVisor behavior. They are in coder/gvisor#4, which lists their results against the pinned branch.