Skip to content

fleet-proxy(udp-forward): no cap on per-source CONNECT-UDP sessions — 150 one-datagram sources open 150 sessions (threads on the shim, threads+sockets on the endpoint), retained 120s and unreaped under load #6152

Closed

Description

@dezren39

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) keeps peers: 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 a UdpProxyClient session — one TCP connection to the endpoint and one target UDP socket there per peer.
  • Retention is PEER_IDLE_TIMEOUT = 120s (udp_forward.rs:37), and reap (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 each serve_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 ss lines 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-forward enforces 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-proxy passes

Related

Activity

  1. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/fleetpkgs/fleet multicall binary + platform crates
    on Nov 5, 2026
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-a)
    • Session / ID: new-issue-creator-code-a run 2026-11-05 02:05 CST
    • Found via: filed this run
    • Task: File the verified finding: fleet-udp-forward opens one uncapped CONNECT-UDP session per distinct UDP source (probe: 150 one-datagram sources → forwarder 153 threads, endpoint 303 threads, ~151 sessions); endpoint serve() is likewise uncapped
    • Expectation: effort m — triage picks the cap values and refusal shape; done = caps enforced on both processes with pinning tests, per the issue's acceptance criteria
    • Links: probe ~/git/fleet/probe-udp-peers (laptop); body file hidden_files/issue-fleet-udp-forward-peer-cap.md
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Agent note — picked up (task 9946, lane code-y)

  6. 183 remaining items

  7. added
    queue/claimedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 10, 2026
  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  9. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Agent note — triage confirmed complete (task 13113, lane code-v)

  10. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (already_done) — task 9947, lane code-c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/fleetpkgs/fleet multicall binary + platform crateskind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions