Repository navigation
Description
Summary
Add a first-class UDP listener type to Sōzu, alongside the existing tcp/http/https listeners, so
Sōzu can load-balance datagram services (DNS, syslog, NTP, generic UDP) without a second load balancer in
front of it. The design preserves Sōzu's architecture — userland, single-threaded mio per worker,
hot-reconfig via protobuf IPC + SCM fd-passing, slab sessions, the e2e harness — and introduces a two-level
sans-io UDP core (a pure flow state machine, I/O at the edges) for testability.
This is an RFC + master plan. Phase 1 is everything functional; Phase 2 is an optional performance pass;
heavier features are explicit non-goals.
Motivation
Datagram workloads (DNS first) are a large, growing class Sōzu cannot serve today; operators must run
IPVS/HAProxy/nginx-stream/Envoy alongside Sōzu purely for UDP. First-class UDP makes Sōzu the single
hot-reconfigurable edge for an operator's whole L4/L7 surface, reusing its control plane, metrics/logging,
and tests. A UDP LB is also security-sensitive (an amplification/DoS vector with no backpressure) — why we
want it inside Sōzu's conservative, no-panic-on-network-input model rather than bolted on.
Goals (phase 1)
udplistener type with full hot-reconfig + CLI parity.- Userland datapath in the existing single-threaded mio loop, with static per-listener worker
ownership: each UDP listener is served by exactly one worker; scale by running multiple listeners. - Virtual 4-tuple flow sessions with a three-knob teardown (
responses/ idletimeout/
requests); symmetric NAT return via a per-flow connected upstream socket. - Load balancing: round-robin (reuse) + source-hash affinity — both HRW/rendezvous (default) and
Maglev selectable per cluster. - Sans-io core with a two-level split: a
UdpManager(admission, flow-key extraction, LB request,
timer-wheel scheduling with generation tokens) over per-flowUdpFlowmachines —
handle_input/handle_timeout/poll_transmit/poll_timeout, property-tested + cargo-fuzz'd. - PROXY protocol v2 to backend (first datagram, per-cluster) — Sōzu defines this; no reference ships it.
- Active health checks bound to the endpoint: companion TCP-probe (primary) + app-level UDP
probe (secondary), with rise/fall hysteresis and fail-open. - Metrics + access logs parity (new
UDP/UDP-FLOWlog tag,udp.*metrics). - Plaintext only.
Non-goals (not planned)
- Single-listener multi-core by any means — no eBPF
SK_REUSEPORT, no userland master-dispatcher,
no SO_REUSEPORT-as-balancer (it skews few-and-fat sources to one worker and reshuffles live flows on
hot-upgrade). Scale across cores by running multiple UDP listeners (one worker each). - UDP flow-state migration across hot-upgrade (flows reset on upgrade — see below).
- DSR · io_uring / XDP · DTLS · QUIC / HTTP3 CID routing · UDP-over-HTTP tunneling ·
inbound UDP PROXY-protocol decode ·IP_TRANSPARENT/transparent return.
Proposed design
Two layers (per Google's Maglev): a per-worker flow table (4-tuple → backend, fast path) +
consistent hashing as the resilience fallback when a flow is cold/evicted or the backend set changes.
Two-level sans-io core (shape validated by quinn-proto / quiche / Firezone snownet / Sōzu's own kawa):
// UdpManager: admission, flow-key, LB request, timer wheel. UdpFlow: per-flow teardown + forward/return.
enum ManagerInput<'a> { ClientDatagram{src,payload}, BackendDatagram{flow,payload}, Config(..), BackendResolved{..} }
enum Output { SelectBackend{flow,cluster,hash}, SendToBackend(Transmit), SendToClient(Transmit),
OpenUpstream{flow,backend}, ArmTimer(Instant), Metric(..), CloseFlow(flow), Drop(reason) }
fn handle_input(&mut self, ManagerInput, now: Instant);
fn handle_timeout(&mut self, now: Instant); // fire due flows; reap; check timer generations
fn poll_output(&mut self) -> Option<Output>;
fn poll_timeout(&self) -> Option<Instant>; // MUST strictly advance — the #1 busy-loop bugNo socket / Instant::now / rand / Arc<Mutex> inside the core — time and the hash seed are injected;
idle timers use generation tokens so a reset timer can't close an active flow. The I/O shell owns
batched recvmmsg/sendmmsg, the flow table, per-flow connected upstream UdpSockets (the kernel
demuxes replies → NAT return; the socket fd is the return key), the timer wheel, bounded write queues, and
the buffer pool — the only place syscalls happen.
Three-knob teardown (responses/timeout/requests) parameterizes DNS (responses=1), syslog
(responses=0, fire-and-forget), NTP/RADIUS with no protocol-specific code.
DoS-first defaults (UDP has no backpressure): allocate nothing for unknown datagrams ("silence is a
virtue"), bound the flow table (max_flows auto-derived from RLIMIT_NOFILE = fd cap), shed new flows when
full (protect existing), per-source fairness, fail-open health.
Load balancing: reuse lib/src/load_balancing.rs + BackendMap (lib/src/backends.rs:498-564); the one
load-bearing change is threading a key: Option<u64> through next_available_backend. HRW/rendezvous
(default) needs no precomputed table (no rebuild stall on hot-reconfig, minimal disruption; O(N) over a
small, bounded backend set); Maglev (opt-in) gives O(1) lookup + near-perfect balance for large N at
the cost of a (control-plane, ~ms) table rebuild on backend changes.
Health: companion-TCP-port probe is the industry-standard signal (IPVS/Keepalived, HAProxy check port,
Envoy health_check_config.port_value, nginx port=) because bare UDP has no reliable liveness signal;
plus an app-level UDP probe. Probes are timer-driven and non-blocking (no worker background threads);
rise/fall hysteresis; fail-open runs LB over the full configured set when all backends read unhealthy.
Worker model & hot-upgrade: one worker owns a UDP listener. On upgrade, SCM_RIGHTS hands off the
listener socket but not the flow table / per-flow upstream sockets — so in-flight flows reset
(old worker drains, new worker serves new flows). For DNS-class short flows this is near-invisible (a caught
flow loses at most a datagram; the client retries). This is a deliberate phase-1 limitation.
Prior art (how IPVS / HAProxy / nginx / Envoy / Pingora do UDP)
- Envoy
udp_proxyis the closest analogue: 4-tuple session, sticky from the first datagram, each
session owns its upstream socket (the NAT-return key),idle_timeout, a max-session circuit breaker,
ring-hash + Maglev LB, GRO batch reads. Its "decide the upstream before opening a socket" ordering
maps cleanly onto a sans-io core. - IPVS/LVS (kernel): 4-tuple conns + OPS stateless mode; schedulers
rr/wrr/lc/wlc,shandmh
(Maglev); health lives in Keepalived (the canonical companion-TCP-port signal). Clean
datapath/control-plane split. - nginx
stream: per-first-datagram session, one connected upstream socket per session,
proxy_responses/proxy_timeoutteardown, ketama consistent hash, active health is commercial-only;
writes only PROXY v1 to backends (no PROXY-v2-over-UDP). - HAProxy (commercial UDP module): client-4-tuple flow,
proxy-requests/proxy-responsesteardown,
consistent hash,check port <P>companion-port health,option udp-check= ICMP only (weak). - Pingora: no plain-UDP datapath — useful only for Rust LB ergonomics and SCM-fd graceful-upgrade
validation; its tokio work-stealing / interwoven-async model is the opposite of Sōzu's constraints.
Takeaways: Envoy's per-worker shared-nothing flow table is the model; the three-knob teardown is
universal; the companion-TCP-port health probe is industry-standard by necessity (no reliable native UDP
health anywhere); and no system ships PROXY-v2-over-UDP — Sōzu would define it (the v2 DGRAM encoding is
the 14th header byte: 0x12=UDP/IPv4, 0x22=UDP/IPv6).
Security & protocol impact
- New network-facing parser/datapath → no panic on input; invalid/truncated datagram ⇒ drop + metric + log.
- Amplification/DoS surface → bounded allocation, shedding, per-source fairness, fail-open health.
- New cargo-fuzz target (
fuzz_udp_flow) +propteststate-machine tests; conservative review of flow-key
extraction + PPv2 framing. - Gauge correctness (
udp.active_flowsmust not underflow on error/shutdown).
Phasing
- Phase 1 (MVP — everything functional) — listener type + control-plane parity; static per-listener
datapath; 4-tuple flows + three-knob teardown + NAT return; RR + HRW (default) + Maglev (opt-in);
PPv2 (first-datagram); health (tcp/udp probe, hysteresis, fail-open); metrics + logs; two-level sans-io
core + proptest/fuzz/e2e. - Phase 2 (optional — performance) —
recvmmsg/sendmmsgbatching; UDP GSO/GRO on the connected
upstream socket (Linux-version-gated). No functional change; sans-io core untouched.
Not planned: single-listener multi-core / eBPF / dispatcher · DSR · io_uring/XDP · DTLS · QUIC/HTTP3 ·
tunneling · flow-state migration on upgrade.
Control-plane impact
proto (ListenerType::UDP, UdpListenerConfig, oneof fields 56+, LB enum SOURCE_HASH/HRW/MAGLEV,
ListenersList/Count) → config (ListenerProtocol::Udp) → state (udp_listeners + diff/generate/activate
together) → lib (Protocol::{UDP,UDPListen}, new lib/src/protocol/udp/) → server wiring → SCM
(Listeners.udp, listener-fd hand-off across upgrade) → CLI (ListenerCmd::Udp). One load-bearing LB-trait
change: thread key: Option<u64> through next_available_backend. UDP needs a separate
listener-ingest/readiness path — not the TCP accept()/create_session model (ProxyConfiguration::accept()
returns TcpStream). Every match ListenerType/Protocol gains a UDP arm (compiler-enforced). Riskiest:
state-replay symmetry, proto field-number allocation, SCM listener-fd hand-off.
Testing
proptest state-machine tests on the sans-io core (timeouts with generation tokens, eviction, three-knob
teardown, HRW & Maglev affinity stability, shedding, fail-open; injected clock) · fuzz_udp_flow · e2e
udp_tests.rs + mock UDP backend (RR, HRW & Maglev affinity, NAT return, teardown, truncation, PPv2, health
failover + fail-open + hysteresis, hot reconfig, listener-fd hand-off across upgrade) · state round-trip
test. DNS is the natural real-payload e2e.
Resolved decisions
- Buffer pool: reuse the existing pool (no dedicated UDP class);
max_rx_datagram_sizecapped at
buffer_size(≥16393); larger datagrams truncate → drop + metric. - PPv2 v2: first-datagram-only by default, per-cluster opt-in for every-datagram.
- UDP ingest: a separate UDP listener-ingest/readiness path, kept out of the TCP
accept()abstraction. - Upstream socket: one connected socket per flow (the connected fd is the NAT-return demux key).
- Flow cap:
max_flowsauto-derives from ~70% of the softRLIMIT_NOFILE(overridable per listener);
shed new flows on cap. - SCM listener-fd hand-off: verified fd-type-agnostic — a
UdpSocketfd rides the same SCM_RIGHTS path as
aTcpListenerfd; onlymio::net::UdpSocket::from_raw_fdis UDP-specific; locked by an upgrade e2e test.
Deliverables checklist (phase 1)
- proto + regenerated bindings (incl.
HRW/MAGLEV/SOURCE_HASHLB enum) - config parsing + validation
- state model + replay symmetry + round-trip test
-
lib/src/protocol/udp/two-level sans-io core + I/O shell (single-worker per listener) - server wiring + separate UDP listener-ingest path
- SCM UDP listener-fd hand-off (verified across upgrade)
- CLI parity
-
key: Option<u64>LB-trait change + HRW (default) + Maglev (opt-in) - health checks (tcp/udp probe, hysteresis, fail-open, endpoint-bound)
- PROXY protocol v2 (first-datagram)
- metrics + access logs +
doc/configure.md+ CHANGELOG - proptest + fuzz + e2e tests
Activity
FlorentinDUBOIS commentedon Jun 3, 2026
Master plan — part 1/4 · motivation · goals · architecture & worker model.
Master Plan — UDP Load Balancing in Sōzu
1. Motivation & rationale
Sōzu load-balances TCP, HTTP/1, HTTP/2 and TLS today, but has no UDP datapath. A large and growing
class of services are datagram-based — DNS, syslog, NTP, generic UDP — and must currently be fronted by
a second load balancer (IPVS, HAProxy, nginx
stream, Envoy). First-class UDP lets Sōzu be the singlehot-reconfigurable edge for an operator's whole L4/L7 surface, reusing its control plane (protobuf IPC,
hot-reconfig, SCM fd-passing), metrics/logging, and e2e harness. A UDP LB is security-sensitive (an
amplification/DoS vector with no backpressure), which is why we want it inside Sōzu's conservative
no-panic-on-input model rather than bolted on.
The work lands in one functional phase (generic UDP + DNS, plaintext, userland) with an optional
perf follow-up; everything heavier (DSR, io_uring/XDP, DTLS, QUIC, eBPF steering) is an explicit non-goal.
2. Goals / non-goals
Phase-1 goals:
udplistener type, first-class alongsidetcp/http/https, with full hot-reconfig + CLI parity.ownership (§3): each UDP listener is served by exactly one worker; scale by running multiple listeners.
responses/ idletimeout/requests); symmetric NAT return via a per-flow connected upstream socket.(default) and Maglev selectable per cluster.
UdpManager(admission, flow-key, LB request, timer wheel) over per-flowUdpFlowmachines — pure, property-tested + fuzzable.probe (secondary), with rise/fall hysteresis and fail-open.
UDP/UDP-FLOWlog tag,udp.*metrics).Phase-2 (optional, performance only):
recvmmsg/sendmmsgbatching; UDP GSO/GRO on the connectedupstream socket (Linux-version-gated).
Non-goals (not planned — design must not preclude, but we are not building them):
SK_REUSEPORT, no userland master-dispatcher,no SO_REUSEPORT-as-balancer. Scale across cores by running multiple UDP listeners (one worker each).
expect_proxyon a UDP listener);IP_TRANSPARENT/transparent-return (privileged, port-lossy, fights the connected-socket primitive).3. Architecture overview
recvmmsg/sendmmsg, the flow table, per-flow connectedupstream sockets, the timer wheel, bounded write queues, the buffer pool, the hash seed, and the
BackendMap/health/metrics edges.unit-testable/fuzzable and keeps the I/O policy swappable without touching logic.
3.1 Why this preserves Sōzu's benefits
Arc<Mutex>: flow table + hash seed are per-worker, owned, not shared.recvtoWouldBlock(one event = many datagrams = many flowtransitions — relaxes
lib/src/server.rs's one-event-one-session assumption); on a queued return itregisters writable interest + calls
signal_pending_write, and onWouldBlockfromsendit re-arms(a bounded write queue per flow/listener —
signal_pending_writealone is necessary-but-insufficient).3.2 Worker model & hot-upgrade semantics
Sharing one UDP fd across workers breaks flow affinity (any worker may
recva flow's packet, but itsconnected upstream socket lives in one worker). Phase-1 model: static per-listener worker ownership —
each UDP listener is bound/served by exactly one worker (assignable; may start with all UDP listeners on one
designated worker and add per-listener round-robin assignment as a cheap follow-up). No shared UDP fd, no
cross-worker flow state. Throughput per listener is one core; aggregate scale comes from running multiple
listeners. Single-listener multi-core is a non-goal (see §3.3).
Hot-upgrade: SCM_RIGHTS hands the listener socket to the new worker — but not the flow table or
per-flow upstream sockets (those live in the old worker's heap). So in-flight UDP flows are not
migrated: the old worker drains/closes its flows (bounded by idle timeout) while the new worker serves
new flows on the handed-off listener. For short datagram flows (DNS = one request+reply, ms-lived) this is
near-invisible; a caught-in-flight flow loses at most a datagram and the client retries. This is a
deliberate phase-1 limitation, not "flows survive re-exec."
3.3 Why static per-listener (and not the alternatives)
For the record, since reviewers will ask "why not SO_REUSEPORT / eBPF?":
resolvers, syslog relays) to one worker (skew), and
socket(7)moves "the last socket into the closedsocket's position", so a hot-upgrade re-exec reshuffles live flows.
SK_REUSEPORTand a userland master-dispatcher are out of scope. Both could give single-listenermulti-core (eBPF in-kernel; the dispatcher portably, and especially well for long-lived flows via per-flow
socket handoff) — but eBPF is unwanted (Linux-only, operationally heavy) and the dispatcher's sweet spot
(media/QUIC long flows) is itself out of scope, leaving it a single-core bottleneck for DNS-class traffic.
already binds listeners with
SO_REUSEADDR + SO_REUSEPORT(lib/src/socket.rs:1015-1038) and SCM-passesfds to workers (
command/src/scm_socket.rs:279), so the primitives exist if this is ever revisited.FlorentinDUBOIS commentedon Jun 3, 2026
Master plan — part 2/4 · sans-io core · datapath · load balancing · health · PROXY protocol v2.
4. The sans-io UDP core (centerpiece) — two-level split
A single per-flow machine cannot own admission ("allocate nothing for unknown datagrams") and select a
backend before a flow exists. So the sans-io core is two levels (mirrors the H2
ConnectionH2/Contextsplit inlib/src/protocol/mux/):UdpManager(sans-io): owns the flow table keyed byFlowKey, admission + flow-table cap +shedding, pluggable flow-key extraction, the LB-selection request for new flows, and timer-wheel
scheduling (one armed deadline for the whole manager).
UdpFlow(sans-io, per admitted flow): the three-knob teardown counters (responses/requests),idle/lifetime timers, PPv2-first-datagram bookkeeping, and the forward/return decisions.
Shape validated by quinn-proto / quiche / Firezone snownet / Sōzu's own kawa. No socket, no
Instant::now, norand, noArc<Mutex>inside either level; time and the hash seed are injected.Datagram payloads are copied into a pool-owned
Bufat admission (one copy) so outputs may outlive theborrowed recv buffer; zero-copy
IoSliceprefixing is a later optimization.each flow carries a
timer_gen; an expiry only closes the flow if its generation matches.poll_timeoutstrict-advance alone is necessary-but-insufficient (the Allow to close connections for a given app in the TCP proxy #1 busy-loop bug in sans-io designs).
responses(DNS=1, syslog=0 fire-and-forget), idletimeout,requests. Purecounts + a clock → DNS/syslog/NTP/RADIUS with no protocol-specific code.
datagrams before any flow/buffer/socket is allocated.
SelectBackend(RR, HRW, or Maglev per cluster). Flow-table-full ⇒
Drop(shed) with zero per-packet allocation.fn flow_key(datagram, cfg) -> FlowKey) — the 4-tuple is theonly implementation in scope; the seam just keeps a fragmentation 2-tuple fallback (§5) clean. (QUIC-CID
keying is a non-goal; the trait costs nothing and doesn't commit us to it.)
propteststate-machine testing (dropped datagrams, idle-timeout races, reconfigmid-flow, reaper drains to zero / no fd leak) with zero sockets; plus a cargo-fuzz target
fuzz_udp_flow.5. Datapath details (the I/O shell)
recvmmsg(MSG_WAITFORONE)per readable event untilWouldBlock; copy each datagram intoa pool
Buf;handle_input.max_rx_datagram_size(default 1500) bounds the read; raise for large DNS.mio::UdpSocketdelivers fully reassembled UDP datagrams (the kernel reassemblesIP fragments before delivery to a UDP socket) — there is no non-first-fragment-without-ports problem at
this layer. The real concerns: a datagram larger than the recv buffer is truncated (
MSG_TRUNC) →drop + metric, never panic; size
max_rx_datagram_sizefor EDNS0/large DNS; recommend operators keepresponses within PMTU.
mio::UdpSocketto the chosen backend — aconnected socket "only receives from the connected address", so its fd is the return demux key.
upstream_token → FlowId; reply → client.connect()pins the return 4-tuple.max_flowsdefaults to~70% of the soft
RLIMIT_NOFILE(overridable per listener), so the fd budget adapts to the host withouthand-tuning; DNS-friendly idle timeout; close-on-
responses-reached (a DNS flow closes after itssingle reply, not on idle); and on
EMFILE/ENFILEormax_flows→ shed new flow (drop +udp.flows.shed+ log), protect existing, never panic. DNS flows can live milliseconds and churn atpacket rate, so reaping must be O(1)-amortized via the timer wheel, not a per-flow scan.
sendcan returnWouldBlock(socket buffer full). Queue into a boundedper-flow/per-listener write queue, register writable interest, rearm on the writable event; drop +
metric when the queue is full. Batch with
sendmmsg(phase 2).udp.active_flowsmust never underflow on close/timeout/shed/error paths.lib/src/pool.rs) — no dedicated UDPclass. Consequence:
max_rx_datagram_sizeis capped at the configuredbuffer_size(≥16393); adatagram exceeding it is truncated (
MSG_TRUNC) → drop + metric. DNS (incl. typical EDNS0) fitscomfortably; document the cap for operators expecting very large datagrams.
6. Load balancing & affinity
lib/src/load_balancing.rsRoundRobin/Random/LeastLoaded/PowerOfTwo+BackendMap(
lib/src/backends.rs:498-564).next_available_backend(&mut self, backends)takes no keyand can't express a hash LB → thread a
key: Option<u64>through it (Nonefor the existingRR/Random/LeastLoaded/PoT).
hash(key, backend), pick max. No precomputed table → no rebuildstall on hot-reconfig, provably-minimal disruption, exact weighting.
O(N)per selection — finebecause UDP cluster backend counts are small; validate/document a max-backends bound per cluster.
near-perfect balance — for large N / high pps. Costs: the table is rebuilt on backend-set change
(~ms, in the control-plane reconcile step, not per-packet) and remaps ~2× more keys than HRW on churn.
src_ipby default (src_ip+src_portopt-in), from flow state.Hash seed injected once per worker at construction, persisted across reconfig (stable affinity).
Backend::try_connectis TCP-specific (lib/src/backends.rs:119-257) — reuse the selection, add UDPsend in the shell.
7. Health checks
Layered, bound to the endpoint not the listener:
tcp_probe_port(default = data port). The industry-standard signal (IPVS/Keepalived, HAProxy
check port, Envoyhealth_check_config.port_value, nginxport=), because bare UDP has no reliable liveness signal. It isa hint, not proof of UDP reachability — documented as such.
a timeout; silence ⇒ unhealthy.
threads); results feed a
Config(UpdateBackend)input. Never block the loop.stay pinned via the flow table until idle-timeout.
(HRW/Maglev/RR) over the full configured backend set, ignoring health (deterministic, testable),
rather than black-holing. Configurable.
8. PROXY protocol v2 — Sōzu defines this
No reference ships PPv2-over-UDP (nginx writes only PROXY v1 to backends; Envoy closed its requests
unimplemented; HAProxy punts to TPROXY). The v2 spec does have a DGRAM encoding: the 14th byte
(offset 13) of the v2 header is family+transport —
0x12=UDP-over-IPv4,0x22=UDP-over-IPv6 (offset 12 isversion+command
0x21). Design:SocketAddrfrom flow state) to the first upstream
Transmit, reusinglib/src/protocol/proxy_protocol/. Since thepayload is already a pool
Buf(§4), the header is a cheap prefix.per-cluster knob (a flow re-created after idle eviction loses client context with first-only).
FlorentinDUBOIS commentedon Jun 3, 2026
Master plan — part 3/4 · metrics & logs · control-plane changes · config schema · testing.
9. Metrics & access logs
incr!/count!/gauge!/time!inlib/src/metrics/):udp.datagrams.{in,out},udp.bytes.{in,out},udp.active_flows(gauge — no underflow),udp.flows.{created,evicted,shed},udp.datagrams.dropped(by reason: invalid/truncated/no-backend/shed/wq-full),udp.backend.health,udp.flow.duration(time!).log_context!envelope; new module log tagUDP/UDP-FLOW(regression-guarded bylib/tests/log_layout.rs).doc/configure.mdfor every public metric (docs-are-code).10. Control-plane changes
Ordered: proto → config → state → lib → server wiring → SCM → CLI → tests → docs.
command/src/command.proto):ListenerType::UDP=3;UdpListenerConfig+UpdateUdpListenerConfig;add_udp_listener/update_udp_listeneroneof fields (numbers 56+);ListenersList.udp_listeners;ListenersCount.udp; LB enumSOURCE_HASH/HRW/MAGLEV. (Never hand-editthe generated
command/src/proto/command.rs.)command/src/config.rs):ListenerProtocol::Udp,FileUdpListenerConfig,push_udp_listenermax_flows, RLIMIT headroom warning).command/src/state.rs):udp_listenersmap; dispatch/activate/deactivate arms;add/remove/update methods;
diff+generate_requests+generate_activate_requestsupdatedtogether (replay symmetry — round-trip test mandatory, the top asymmetry risk);
list_listeners.lib/src/lib.rs):Protocol::{UDP,UDPListen}; newlib/src/protocol/udp/(manager + per-flow +shell).
lib/src/server.rs):udpproxy field + constructor;notify_add/update/activate/ deactivate_udp;ListenerType::Udparms; a UDP listener-ingest/readiness path that is NOT routedthrough the TCP
accept()/create_sessionmodel (UDP is one-socket-many-flows; prefer a separatelistener-ingest trait over forcing
ProxyConfiguration::accept()— which returnsTcpStream— to carryUDP cases).
command/src/scm_socket.rs):Listeners.udp,get_udp, close logic. Verified (Q-6): theSCM_RIGHTS transport (
send_listeners/receive_listeners/send_msg_and_fds) is fd-type-agnostic — aUdpSocketraw fd passes exactly like aTcpListenerfd. The only UDP-specific step is re-wrapping withmio::net::UdpSocket::from_raw_fdin the UDP activation arm (TCP usesMioTcpListener::from_raw_fd,lib/src/server.rs:2104/2127/2153).O_NONBLOCK+SO_REUSE*are file-description flags preserved acrossSCM + exec. Locked by an upgrade e2e test. Flow state is not transferred (§3.2).
bin/src/cli.rs,bin/src/ctl/):ListenerCmd::Udp+UdpListenerCmd; request-builder methods.match ListenerType/Protocolneeds a UDP arm (compiler-enforced).11. Configuration schema (illustrative)
12. Testing strategy
UdpManager+UdpFlowviapropteststate-machine testing — timeouts (with timergenerations), eviction, three-knob teardown, affinity stability across backend add/remove (HRW and
Maglev disruption bounds), flow-table-full shedding, write-queue-full drop, fail-open selection, reaper
drains to zero / no fd leak. Injected
Instants;debug_assertpoll_timeoutstrictly advances.fuzz/targetfuzz_udp_flowover flow-key extraction + PPv2 framing (H2-parity discipline).e2e/): newudp_tests.rs+ mock UDP backend + UDP client. RR distribution, HRW & Maglevaffinity, NAT return, idle/
responses/requeststeardown, truncation handling, PPv2 to backend, healthfailover + fail-open + hysteresis, hot add/remove/activate UDP listener, listener fd hand-off across
upgrade (flows reset, new flows served). Ports via the e2e port registry; DNS is the natural real-payload
test.
generate_requests→diffreplay.FlorentinDUBOIS commentedon Jun 3, 2026
Master plan — part 4/4 · phasing · risks · resolved decisions.
13. Phasing
userland datapath; 4-tuple flows + three-knob teardown + NAT return (per-flow connected socket);
RR + HRW (default) + Maglev (opt-in); PPv2 (first-datagram); health (tcp/udp probe, hysteresis,
fail-open); metrics + logs; two-level sans-io core + proptest/fuzz/e2e. Flows reset on hot-upgrade.
recvmmsg/sendmmsgbatching; UDP GSO/GRO on the connected upstreamsocket (Linux-version-gated). No functional change; the sans-io core is untouched.
Explicit non-goals (not planned): single-listener multi-core / eBPF
SK_REUSEPORT/ userlandmaster-dispatcher · DSR · io_uring / XDP · DTLS · QUIC / HTTP3 · UDP-over-HTTP tunneling · flow-state
migration across upgrade · inbound UDP PROXY decode · transparent return.
14. Risks & mitigations
max_flows, shed new flows, per-source fairness (per-IP rate-limit), fail-openmax_flows= fd cap; RLIMIT headroom; close-on-responses; idle reaping; EMFILE/ENFILE → shed, never panicsignal_pending_write+ writable rearm + bounded write queues; drain toWouldBlock;poll_timeoutstrict-advance assertionbuffer_sizemax_rx_datagram_sizeatbuffer_size; over-size → truncate, drop + metric15. Resolved decisions (interview, 2026-06-03)
All six former open questions are now decided:
max_rx_datagram_sizeis capped atbuffer_size(≥16393); larger datagrams truncate → drop + metric (§5).accept()/create_sessionabstraction (§10).shared-socket/connection-table mode.
max_flowsauto-derives from ~70% of the softRLIMIT_NOFILE(overridable perlistener); shed new flows on cap (§5).
mio::net::UdpSocket::from_raw_fdisUDP-specific; locked by an upgrade e2e test (§10).
Earlier decisions: worker model = static per-listener ownership; LB = HRW default + Maglev opt-in (both
phase 1); encryption = plaintext only; multi-core/eBPF/dispatcher/DSR/io_uring/DTLS/QUIC/tunneling = non-goals.
feat(udp): add first-class UDP load balancing (#1273)
FlorentinDUBOIS commentedon Jun 5, 2026
Implemented and merged via #1274 — the full RFC shipped: sans-io UDP core (
lib/src/protocol/udp/), first-classprotocol = "udp"listeners, HRW/Maglev flow-affine balancing, PROXY v2 to backends, UDP/TCP health probing, and operator docs (doc/configure.md, "UDP clusters" section).fix(udp): key flows on the client source address, not on the affinity…
fix(udp): key flows on the client source address, not on the affinity…
fix(udp): key flows on the client source address, not on the affinity…
fix(udp): key flows on the client source address, not on the affinity…