Repository navigation
refactor(mux-h1): render the peer address in ConnectionH1's Debug - #1542
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 25, 2026 23:06
FlorentinDUBOIS
force-pushed
the
refactor/h1-debug-peer-address
branch
from
September 25, 2026 23:18
8a520ce to
ef5f2f0
Compare
ConnectionH1's Debug was the last one in protocol/mux/ still naming the raw
socket: of the module's four debug_struct sites it alone handed
mio::net::TcpStream's own Debug a local address, a live getpeername(2) taken at
format time, and a file descriptor.
.field("socket", &self.socket.socket_ref()) becomes
.field("peer_address", &self.peer_address) — the same field name, in the same
slot, that ConnectionH2's Debug already renders. peer_address is the snapshot
Connection::new_h1_server and Connection::new_h1_client each take once from
SocketHandler::peer_addr, and it is the source every log_context! line of the
same connection already renders, so until now one session ULID rendered two
different peers depending on whether a trace carried the struct or a log line.
It drops the descriptor, which named nothing outside this process; it survives
the peer's reset, where the live lookup answers ENOTCONN on exactly the error
lines an operator reads during an incident; and on a PROXY-protocol frontend it
names the client the header advertised rather than the load balancer the
transport is connected to.
socket_ref() code reaches in h1.rs's production range go 4 to 3, and
socket_mut() stays at 0. The three survivors are the stats::socket_rtt samples
in ConnectionH1::writable: they read a round-trip time rather than an address
and are deliberately untouched. Unlike ConnectionH2, which shed its Front
parameter to H2Shell, ConnectionH1 keeps Front: SocketHandler — this is the
rendering half of that change and none of its extraction half.
Seen red before it was trusted, on the value rather than on a field name or a
count. debug_renders_the_proxy_advertised_peer_not_the_transport_socket builds a
frontend connection over a genuinely connected loopback socket whose
SessionTcpStream declares 10.0.0.42:12345, asserts first that the live lookup is
healthy and disagrees with that declaration, then asserts on what {:?} renders.
Against the pre-fix impl it fails with
socket: TcpStream { addr: 127.0.0.1:34880, peer: 127.0.0.1:33567, fd: 4 } and
the declared address nowhere in the line. sozu-lib goes 1147 to 1148 tests;
every other suite is unmoved.
doc/h2_mux_internals.md's Debug section now states the contract for both impls,
including the one reason that does not transfer to H1.
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
refactor/h1-debug-peer-address
branch
from
September 25, 2026 23:39
ef5f2f0 to
9e4f1cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The divergence, measured
ConnectionH1'sDebugrendered.field("socket", &self.socket.socket_ref()).socket_ref()returns the rawmio::net::TcpStream, so that field handed theOS type's own
Debuga local address, a livegetpeername(2)taken at formattime, and a file descriptor. Measured against
274268af, on a frontendconnection whose handler declares
10.0.0.42:12345:The declared address appears nowhere; the kernel's does, twice, beside a
descriptor that names nothing outside this process.
Swept at
274268af:lib/src/protocol/mux/holds fourdebug_structsites —
ConnectionH1(h1.rs),ConnectionH2(h2.rs),KawaandStream(
stream.rs) — andConnectionH1was the only one still naming the raw socket.ConnectionH1already carriedpeer_address: Option<SocketAddr>, snapshottedonce by
Connection::new_h1_server/Connection::new_h1_clientfromSocketHandler::peer_addr, which prefers the PROXY-protocol-declared addressand survives a peer reset. Every
log_context!line of the same connectionalready renders it, so one session ULID rendered two different peers depending
on whether a trace carried the struct or a log line.
The form retained, and why it is
ConnectionH2'sConnectionH2'sDebugwas checked first, as asked. It keeps no socket fieldat all — it renders
.field("peer_address", &self.peer_address)and nothingelse about the transport, because
ConnectionH2shed itsFrontparameter toH2Shellentirely. So the symmetric change is a straight in-place swap, samefield name, same slot between
readinessandstream, no reordering and nothird variant:
One line, and deliberately line-count-neutral:
kawa_h1/LIFECYCLE.mdandmux/LIFECYCLE.mdcarry liveh1.rs:NNNcitations, and shifting them wouldboth redden
check_doc_citations.py --baseand dragmux/LIFECYCLE.md— a fileone in-flight PR already edits — into this diff. The rationale therefore lands
in
doc/h2_mux_internals.md's existing "What theDebugimpl renders" section,which nothing cites by line, rather than in a header comment mirroring H2's.
That section's third reason is recorded there as not transferring:
ConnectionH1keepsFront: SocketHandler, so this is the rendering half ofthe H2 change and none of its extraction half.
socket_ref()code reaches inh1.rs's production range go 4 to 3;socket_mut()stays at 0. The three survivors are thestats::socket_rttsamples in
ConnectionH1::writable, still at lines 739, 791 and 814 — they reada round-trip time, not an address, and are untouched.
To SEE THIS RED
In
impl Debug for ConnectionH1(lib/src/protocol/mux/h1.rs), putback in place of
then run
The replaced literal is present in the tree at this branch's head, so the recipe
is replayable. Observed on the reverted tree:
running 1 test→test result: FAILED. 0 passed; 1 failed; 1147 filtered out, panicking onthe ConnectionH1 Debug must render the declared peer:with the struct quotedabove. Restored:
1 passed. Driven twice — red, green, red, green — with theproduction file restored by
cmp-verified copy each time, nevergit stash(the worktree is shared).
The test pins the value, not a count: it builds the connection over a
genuinely connected loopback socket, asserts first that the live lookup is
healthy and disagrees with the declared address (so it cannot pass for the wrong
reason), then asserts
{:?}carriesSome(10.0.0.42:12345)and not thetransport address. Both assertions name addresses only, so they share no literal
with the production diff — the swept
peer_address/socket_ref/debug_struct/.fieldtokens appear in this changeset's test only inside thedoc comment's recipe, never inside an assertion.
Battery
All against this branch's head, exit codes read directly rather than through a
pipe.
cargo build --locked --no-default-features --features crypto-ring,opentelemetry,splice,simdcargo +nightly fmt --all -- --checkcargo clippy --all-targets --locked --no-default-features --features crypto-ring,opentelemetry,splice,simd -- -D warningscargo test -p sozu-lib …274268af, and this diff adds exactly one#[test]and removes nonecargo test -p sozu …cargo test -p sozu-command-lib --lockedcargo test -p sozu-e2e … -- --skip tests::fuzz_tests::RUSTFLAGS="--cfg tokio_unstable" cargo test -p sozu-sim --lockedRUSTFLAGS="--cfg tokio_unstable" cargo clippy -p sozu-sim --all-targets --locked -- -D warningscheck_doc_citations.py --self-testcheck_doc_citations.py --root .check_doc_citations.py --base 274268af637c847ff8a84bb5cb57a6bc9b1a740acheck_doc_citations.py --audit --root .RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --lockedsozu-e2eran behind a three-criterion gate evaluated in the same command as thelaunch —
LOAD1=6.46(< 8),CHILD=0,PARENT=0, the parent probe anchored onrustup/toolchains/*/bin/cargoso the guard cannot count its own shell.No check was weakened: nothing skipped or ignored, no assertion relaxed, no
clippy allow, no lowered
-D warnings. Noasync fnenterslib/orbin/,and no production dependency changes.
Scope
Three files:
lib/src/protocol/mux/h1.rs(the one-line swap plus the regressiontest),
doc/h2_mux_internals.md(theDebugcontract, now stated for bothimpls),
CHANGELOG.md(entry appended at the end of[Unreleased]'s🔄 Changed, beside therefactor(mux-h2)twin, to avoid a head-insertionadjacency collision). The only expected overlap with the two
in-flight pull requests is
CHANGELOG.md— neither touchesh1.rs. Rebased on274268afand swept for conflict markers on all fourzdiff3forms.This changeset references no issue for closure.
Signed-off-by: Florentin Dubois [email protected]