Skip to content

fix(net): preserve TCP listeners when accept slots are exhausted - #2316

Merged
fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/tcp-listener-overflow
Sep 21, 2026
Merged

fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/tcp-listener-overflow

Conversation

@fslongjin

@fslongjin fslongjin commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Root cause

A live listener has a bounded set of physical smoltcp slots. When all slots are occupied, a new SYN previously reached the closed-port RST fallback. The receive-path predictor only protected zero backlog and ran before TCP validation.

Changes

  • Replace the backlog predictor and raw receive filtering with per-interface logical listener facts.
  • Keep listener lifecycle, reservation identity, and address-family isolation in DragonOS; let smoltcp decide the unmatched-SYN fallback after validation and normal socket matching.
  • Remove repeated poll-time slot scans and add 12 mandatory dunitest cases.
  • Pin smoltcp 225c271ef40fa483c60a8f69c8d000d2af58a483.

Dependency / merge order

DragonOS-Community/smoltcp#30 has merged into dragonos/v0.12.0. The dependency pin now references its merged commit, 225c271ef40fa483c60a8f69c8d000d2af58a483, whose Git tree is identical to the previously tested commit.

Validation

  • Pre-fix minimal reproduction: listen(8), 16 clients, no accept: DragonOS refused 8 connections; Linux refused none.
  • New regressions: Linux 12/12; DragonOS 12/12.
  • Existing guest regressions: 111/111 across relisten, dual-stack, bind, close, listen poll, self-connect, IPv6 UDP, and socket options.
  • Rebuilt and rebooted using the remote pinned dependency: all 123 guest tests passed again.
  • make kernel, make fmt, and FMT_CHECK=1 make fmt passed.
  • Same guest nginx curl burst: 61/64 before, 64/64 after. Final 16-thread HTTP validation: 1000/1000 in 2.931 seconds.
  • Plan and implementation received independent correctness, concurrency/security, and performance/maintainability reviews.

Explicit limitations

This fixes erroneous resets on slot exhaustion, not all concurrent nginx problems. The unchanged host-forwarded load still had 42/1000 timeouts; phase-level investigation found predominantly host connect timeouts and QEMU host-listener backlog 1, plus unresolved response-header timeouts. An initial guest threaded run had one failure before subsequent full passes. A pre-existing early-accept SynReceived semantic issue also remains separate. No timeout increase, application retry workaround, or larger slot cap is used to mask these observations.

A live TCP listener can consume all physical smoltcp accept slots. Previously a subsequent SYN fell through normal demultiplexing and received a closed-port RST; the pre-stack filter only covered zero backlog and predicted slot availability before TCP validation.

Replace the receive-path backlog predictor with a per-interface logical listener registry. Register address domains and reservation identities on listen, unregister on shutdown or close, and let smoltcp consult these facts only after normal TCP matching fails. Remove raw packet filtering and repeated poll-time slot scans while preserving existing address-family isolation and relisten capacity behavior.

Pin smoltcp dff45e4d40ee043fd3060d33404606548daab17d (DragonOS-Community/smoltcp#30). Add 12 dunitest cases covering saturated positive and zero backlog recovery, closed-port refusal, and address-family isolation; enable them in the mandatory test lists.

Validation: make kernel, make fmt and FMT_CHECK=1 make fmt passed. All 123 focused guest tests passed with the remote pinned dependency. The same guest nginx curl burst improved from 61/64 to 64/64; a final 16-thread HTTP run passed 1000/1000. This addresses erroneous resets under slot pressure, not all concurrent nginx failures: host-forwarding timeouts and an earlier isolated guest failure remain separate unresolved observations.
Signed-off-by: longjin <longjin@dragonos.org>
@github-actions github-actions Bot added the Bug fix A bug is fixed in this pull request label Sep 21, 2026
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

Update the manifest and lockfile to 225c271ef40fa483c60a8f69c8d000d2af58a483, merged by DragonOS-Community/smoltcp#30 into dragonos/v0.12.0.

The merged commit has the same Git tree as the previously tested dff45e4 revision. make kernel passes with the merged dependency.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin
fslongjin merged commit c4e00ff into DragonOS-Community:master Sep 21, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant