Repository navigation
Description
Summary
fleet-udp-forward (pkgs/fleet/crates/fleet-proxy/src/udp_forward.rs) opens one CONNECT-UDP session per distinct UDP source address with no cap on concurrent peers, and the CONNECT-UDP endpoint it drives has no session cap either — so a stream of one-datagram sources turns into unbounded threads, TCP connections, and target UDP sockets on both processes.
serve_socket(udp_forward.rs:192-193) keepspeers: HashMap<SocketAddr, Peer>with no size limit; every new source address inserts an entry.open_peer(udp_forward.rs:134, thread spawn :149) gives each peer a reply thread plus aUdpProxyClientsession — one TCP connection to the endpoint and one target UDP socket there per peer.- Retention is
PEER_IDLE_TIMEOUT= 120s (udp_forward.rs:37), andreap(udp_forward.rs:180) is only called from the recv-timeout arm of the serve loop — while new datagrams keep arriving, the loop never takes that arm, so even dead/idle peers are not reaped during a sustained stream. - The endpoint side mirrors it:
serve(connect_udp.rs:538-542) spawns a thread per accepted connection with no limit, and eachserve_session(connect_udp.rs:355, :432) adds another thread plus the target UDP socket.
Evidence (verified this run, laptop, real binaries @ 266875e)
Probe: ~/git/fleet/probe-udp-peers/probe.py on the laptop — real fleet-connect-udp (opted-in FLEET_CONFIG, loopback 127.0.0.1:39141) + real fleet-udp-forward (--map 48001=127.0.0.1:48002, UDP echo target), thread counts from /proc/<pid>/status, connections from ss -tn:
- Baseline: forwarder 2 threads, endpoint 1 thread, 0 connections.
- Control — 50 datagrams from ONE source socket: forwarder 3 threads, endpoint 3 threads (exactly 1 session).
- 150 datagrams, each from a DISTINCT source socket: forwarder 153 threads, endpoint 303 threads, ~151 established sessions (302
sslines counting both ends on loopback). The echo target received the datagrams — these are real, fully-opened sessions, not half-open state.
150 small UDP packets from one ordinary host (each sendto from a fresh ephemeral port does this with no spoofing) created 150 sessions retained for at least the 120s idle horizon. Nothing bounds the count at 1,500 or 15,000 short of OS thread/socket limits, and the shim's documented use (Moonlight) is to bind it on a LAN (--bind is a flag precisely so it need not be loopback), where source addresses are not the operator's own processes.
Why it matters
This is the client shim and endpoint from the #6109 CONNECT-UDP capability that #5694's remote-desktop design builds on. A per-source session model with no ceiling is a self-inflicted amplification surface: one datagram (~a thread + a connection + a socket on two processes, held 120s) is the cheapest possible unit of work for a sender and one of the most expensive for the shim. Every sibling surface in this crate family that allocates per-peer state has needed the same conversation; this one was never capped because the spike (#6109) proved capability, and the forwarder (#6134/#6139's bin) inherited the model unexamined.
Acceptance criteria
-
fleet-udp-forwardenforces a documented maximum concurrent peer count per listen socket (and/or globally); a new source beyond the cap is refused loudly (log line naming the cap) and opens no session — existing peers are unaffected -
reap(or equivalent expiry) also runs on the datagram path at a bounded cadence, so idle/dead peers are reaped during sustained traffic, not only when a listen socket goes quiet - The CONNECT-UDP endpoint (
connect_udp::serve) enforces a documented maximum concurrent session count; connections beyond it are refused/closed without spawning unbounded threads - Pinning tests/probe: N distinct sources beyond the cap produce exactly cap sessions on both processes; the one-source-many-datagrams control still produces exactly 1; ordinary forwarding (echo round-trip) is unchanged
-
cargo test -p fleet-proxypasses
Related
- spike(proxy): CONNECT-UDP (RFC 9298) capability in fleet-proxy — capability only, no cutover #6109 — the CONNECT-UDP capability spike this ships in (capability only, no cutover)
- fleet-proxy(udp-forward): fleet-udp-forward silently overwrites duplicate scalar flags — last --target/--proxy/--bind/--ports wins #6139 / fleet-proxy(connect-udp): fleet-connect-udp ignores argv entirely — --help and typo'd flags start the CONNECT-UDP endpoint #6134 — the same bin's argument surface, fixed today; this is its session-state surface
- design: remote desktop through the fleet brokers (RustDesk transport, secrets, pre-warming, virtual desktops) #5694 — remote-desktop design that would put this shim in front of real LAN traffic
Activity
developing-today commentedon Nov 5, 2026
CODE-1779
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 5, 2026
Agent note — picked up (task 9946, lane code-y)
direct— working it in this shift.183 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
opencode(row 2550)dezren39 commentedon Nov 11, 2026
Agent note — triage confirmed complete (task 13113, lane code-v)
direct— worked in this shift (no handoff).status/needs-triage.triagednaming it.queue/9947-6152-udp-peer-caps, checks green: scripts-test 3.12/3.14 + CodeRabbit SUCCESS; PR body evidences caps at exactly 64 sessions under the 150-source probe andcargo test -p fleet-proxypassing). Merging PR fix(fleet-proxy): cap UDP peer and session growth #6585 and closing this issue belong to task 9947's terminal step, not this triage task.dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (already_done) — task 9947, lane code-c
cargo test -p fleet-proxypassing.already_donewith that evidence; no new work was needed and none was duplicated.