Skip to content

fix(tcp): open the receive window when the read buffer is smaller than the MTU - #5

Merged
acking-you merged 1 commit into
devfrom
fix/receive-window-small-buffer
Oct 27, 2026
Merged

acking-you merged 1 commit into
devfrom
fix/receive-window-small-buffer

Conversation

@acking-you

Copy link
Copy Markdown
Owner

Addresses the P2 review finding on #4 (src/stream/tcp.rs): silly-window avoidance advertised a zero window until a full MTU of receive space was free. With an MTU above TcpConfig::read_buffer_size (e.g. 32768 against the default 16384) that can never happen, so even the SYN-ACK of an empty connection carried a zero window and data never flowed. The rule came from upstream (narrowlink#95/narrowlink#99 window work).

The threshold is now min(MTU, read_buffer_size / 2), the bound RFC 1122 §4.2.3.3 gives, computed by Tcb::get_recv_window_threshold, and the comparison uses the unclamped free space. With the default MTU 1500 and 16 KiB buffer the threshold — and the behaviour — are unchanged.

Test

mtu_above_the_read_buffer_still_opens_the_receive_window opens a stream with an MTU of twice the read buffer and asserts the SYN-ACK window is non-zero; it fails on the old rule ("an empty read buffer advertised a zero window") and passes now. The open helper gained an MTU-taking variant for it.

Verified (nightly-2026-10-26)

fmt --check, clippy --all-targets --all-features -D warnings, test --all-features (43 unit + 23 doc).

🤖 Generated with Claude Code

…n the MTU

Silly-window avoidance advertised a zero window until a full MTU of space was
free. With an MTU above TcpConfig::read_buffer_size (e.g. 32768 against the
default 16384) that never happens, so even the SYN-ACK of an empty connection
carried a zero window and normal data never flowed. Bound the threshold by
half the read buffer, as RFC 1122 4.2.3.3 does; with the default MTU 1500 and
16 KiB buffer the threshold, and the behaviour, are unchanged.

Raised in review of #4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T12:55:37.765764Z 68a956a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@acking-you
acking-you merged commit e4ef686 into dev Oct 27, 2026
4 checks passed
@acking-you
acking-you deleted the fix/receive-window-small-buffer branch October 27, 2026 13:09
acking-you added a commit to acking-you/proxy-everything that referenced this pull request Oct 27, 2026
- deps/ipstack: acking-you/ipstack#5, receive window opens when the read
  buffer is smaller than the MTU.
- deps/better_mimalloc_rs: acking-you/better_mimalloc_rs#2, vendored
  mimalloc exports mi_malloc_size and mi_malloc_usable_size without the
  override (upstream f46cacf6).
- deps/kanal: acking-you/kanal#2 and #3, kanal-plus 0.2.2 with batch
  receives and sends sound when a waker panics.

Each is the commit merged on the fork's default branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acking-you added a commit to acking-you/proxy-everything that referenced this pull request Oct 27, 2026
* build: upgrade the toolchain, dependencies and every submodule

Toolchain
- nightly-2026-01-26 -> nightly-2026-10-26 (rust-toolchain.toml and both CI
  workflows). rustfmt.toml needs nightly; the newer compiler also unblocks
  sysinfo 0.39 (cfg_select).
- CI: docker/login-action v4.7.0, Windows fvm 4.1.0 -> 4.3.2.

crates.io
- sysinfo 0.38 -> 0.39, arc-swap 1.9.3, rustls 0.23.46, plist 1.10, plus a
  lockfile refresh (tokio 1.54.1, ureq 3.5, uuid 1.29, icu 2.4, ...).
- lru dropped: nothing in the workspace uses it. proxy-core also drops ureq,
  kanal and async-broadcast, which only proxy-client/server use; anyhow is a
  Windows-only dependency of proxy-updater. Cargo's new unused_dependencies
  lint flagged all of these.
- Held: libc =0.2.189 and with it parking_lot 0.12 (0.13 needs libc 0.2.191).
  nix 0.31.3 still fails on iOS against newer libc; the fix (nix#2821) is
  unreleased.
- New lints: AtomicX::fetch_update -> try_update, as_chunks for fixed-size
  chunks, saturating_sub in proxy-tui's Up handling.

Submodules
- tun2proxy: upstream v0.8.6 merged; ArgProxy -> ProxyParameters.
- ipstack: upstream main merged.
- kanal: kanal-plus 0.2.1 (upstream main merged, branches 0.5). The parent
  now uses it as kanal-plus and patches crates.io kanal-plus to the same
  checkout, so uni-stream no longer pulls a second copy whose branches 0.3
  no longer compiles on current nightlies.
- uni-stream: dependencies upgraded, parking_lot replaced by std's RwLock.
- rust-smallvec: upstream v2 (2.0.0-beta.3) merged; smallvec! is deprecated,
  so the header buffer is built with new + resize. It is now its own Cargo
  workspace, so it and better_mimalloc_rs join the exclude list like every
  other fork (both were implicit members until now).
- better_mimalloc_rs: mimalloc_rust 0.1.52 merged, vendored mimalloc v2.5.2.
- sysproxy-rs: macOS fixes landed on a branch, unmaintained interfaces crate
  replaced by nix's getifaddrs.
- ui/flutter: Flutter 3.47.8, latest pub dependencies, tray on
  tray_manager's native API.

quinn stays at quinn-proto 0.11.19 / quinn 0.11.12, its latest release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(windows): use as_chunks_mut for the icon's BGRA swap

The new nightly's clippy (chunks_exact_to_as_chunks) rejects constant-size
chunks_exact_mut under -D warnings. This Windows-only call site was not
compiled on the platforms checked locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(packet-tunnel): bind the loopback proxy before building Args

Same shape as tun.rs; the inline form left rustfmt unable to lay out the
map_err closure after the ProxyParameters rename.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin forks to their merged review fixes

- deps/ipstack: acking-you/ipstack#5, receive window opens when the read
  buffer is smaller than the MTU.
- deps/better_mimalloc_rs: acking-you/better_mimalloc_rs#2, vendored
  mimalloc exports mi_malloc_size and mi_malloc_usable_size without the
  override (upstream f46cacf6).
- deps/kanal: acking-you/kanal#2 and #3, kanal-plus 0.2.2 with batch
  receives and sends sound when a waker panics.

Each is the commit merged on the fork's default branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin the UI to its merged dependency upgrade

Proxy-UI/Proxy-UI-Flutter#39 (merge 7cd9408): Flutter 3.47.8, latest pub
dependencies, and the tray moved to tray_manager's native API with the menu
opened from Dart so it is never replaced or freed while on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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