Skip to content

feat(backends): dial backends over UNIX domain sockets - #1892

Merged
FlorentinDUBOIS merged 8 commits into
mainfrom
feat/unix-socket-backends
Oct 16, 2026
Merged

FlorentinDUBOIS merged 8 commits into
mainfrom
feat/unix-socket-backends

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Support stream backends over UNIX domain sockets, including Linux abstract sockets (@name), while retaining existing IP backend behavior. Configuration carries the socket path through state and workers; UDP rejects UNIX stream targets before mutation. Canonical UNIX-backend requests use protobuf verb 72 so older decoders cannot accidentally dial the identity IP address.

Validation: focused UNIX/abstract-socket end-to-end tests, state/command tests, old-decoder and UDP refusal RED/GREEN checks, formatting and Clippy. Independent source and final documentation reviews approved the current head. The full GitHub Actions matrix must succeed before merge.

Closes #152

A backend can now declare `unix_path`: an absolute filesystem path, or
`@name` for a Linux abstract-namespace socket. HTTP, HTTPS and TCP
clusters dial that socket instead of `address`, which stays the
backend's identity (removal, retry exclusion, hash and shard placement,
events) and must be unique in its cluster. UDP clusters refuse it.

The field is additive everywhere: `AddBackend.unix_path` (proto field
7), the `response::Backend` state record so replays and saved states
keep it, `BackendConfig.unix_path` in the configuration file, and
`sozu backend add --unix-path`. `parse_backend_unix_path` is the one
validator used at config load, by the main process state and by every
worker.

`connect_backend` dials the UNIX stream with mio and hands its
descriptor to the pipeline as a `mio::net::TcpStream`, so the H1, H2,
TCP and WebSocket paths take it without a generic stream type. Every
syscall they make on a backend socket answers the same way on AF_UNIX,
except std's `peer_addr`, which refuses a non-INET peer: the two
connect-completion checks (`connect_outcome`, `tcp_connect_outcome`)
now use `socket2`'s family-agnostic `getpeername`, and TCP_NODELAY is
skipped for unix backends. Health checks probe through the same dial.

Tests: unit tests for the parser, the config and state round trip, the
dial and both connect-outcome checks (red with std `peer_addr`, green
with the fix), and e2e tests for HTTP over a path and an abstract
socket and for TCP passthrough over a path socket.

Closes #152

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS marked this pull request as ready for review October 15, 2026 14:59
@FlorentinDUBOIS
FlorentinDUBOIS marked this pull request as draft October 15, 2026 15:36
@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator Author

Heads-up from #1899, which adds an optional probe port to HealthCheckConfig: the probe now collects (backend_id, probed_address, incarnation), where probed_address may differ from the backend's data address. This PR's backend.borrow().connect_socket() in lib/src/health_check.rs dials the backend's own address, so whichever lands second must dial the probed address instead (e.g. connect_backend(address, backend.unix_path.as_deref())). #1899's four probe-port e2e tests catch the regression. Open point for this PR: should a port on a unix_path backend be ignored or refused at validation?

@FlorentinDUBOIS
FlorentinDUBOIS marked this pull request as ready for review October 15, 2026 17:11
Merge the current backend ownership, close-session, and DNS configuration changes into UNIX socket backends. Preserve unix_path through literal and expanded backend configuration, validate identities after resolution, and cover a real DNS-named backend that dials only its UNIX socket.

Refs #152

Signed-off-by: Florentin Dubois <[email protected]>
Preserve the fail-closed wire verbs and canonical request handling from
header routing while carrying UNIX socket transports through DNS-expanded
configuration.

Refs #152

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit ffb5368 into main Oct 16, 2026
37 checks passed
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.

Support backends listening on UNIX domain sockets

1 participant