Repository navigation
feat(listener): bind listeners to a network interface - #1686
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 29, 2026 14:40
FlorentinDUBOIS
force-pushed
the
feat/listener-interface
branch
2 times, most recently
from
September 29, 2026 15:54
e77af87 to
792c8b8
Compare
Add an optional `interface` key to HTTP, HTTPS, TCP and UDP listeners. The listening socket is bound to that interface with SO_BINDTODEVICE (socket2 `Socket::bind_device`) before bind(2), in `server_bind` and `udp_bind`, so Sozu can listen on an interface whose address is not known ahead, such as a WireGuard `wg0`. The interface is part of the listener identity. A new `ListenerKey` (address, optional interface) keys the ConfigState listener maps, Activate/Deactivate/RemoveListener, the SCM `Listeners` hand-off and the worker listener lookups. Its text form is the bare address for a listener without interface and `<address>%<interface>` otherwise, so the JSON ConfigState crossing a main upgrade, saved state files, the ListenersCount manifest and ListListeners keep their current format for every existing listener. Frontends and certificates still name their listener by address and apply to every listener on it: a listener added next to one already on its address takes over that listener's frontends and certificates when the worker creates it, and a removal reaches every listener even when one fails. Listeners sharing an address in the configuration file must use the same protocol. The interface is not patchable, and an Update*Listener patch matching several listeners on one address is refused. Failures are explicit: an invalid name or a non-Linux platform is refused at config load and at state dispatch, and a failed SO_BINDTODEVICE names the listener address and interface and says the interface must exist and that kernels before 5.7 require CAP_NET_RAW. The shipped systemd units run as root without a capability bounding set, so they only gain a comment. The main process and every worker must be upgraded before a listener names an interface. CLI: `--interface` on `sozu listener <protocol> add|remove|activate| deactivate`; `sozu listener list` shows it. Documented in doc/configure.md, bin/config.toml and CHANGELOG.md. Closes #719 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
feat/listener-interface
branch
from
September 29, 2026 16:13
792c8b8 to
a39cddd
Compare
This was referenced Sep 29, 2026
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
…efault (#1697) ## What A policy-carrying HTTPS frontend (tags, headers, redirect, rewrite, auth) with no `hsts` block of its own, added while its listener had **no** HSTS default, was stored with `inherits_listener_hsts = false`. Two consequences: - A listener added later on the same address (#1686, `HttpsProxy::add_listener`) copied the frontend but never applied its own HSTS default to it. - A later `sozu listener https update --hsts-*` on the frontend's own listener did not reach it either. Both contradict the documented contract (`doc/configure.md`, HSTS hot-reconfig): a frontend with no per-frontend `[hsts]` block at add time inherits the listener default. ## Fix - `HttpsProxy::add_https_frontend` (`lib/src/https.rs`) now records the frontend's own intent. If the frontend declared no `hsts`, the origin is `HstsOrigin::InheritedFromListenerDefault`, and `front.hsts` takes the listener default, which may be `None`. It no longer checks whether a default existed. - `Frontend::new` (`lib/src/router/mod.rs`) drops the `&& hsts.is_some()` condition, so `inherits_listener_hsts` reflects only that intent. - `Router::refresh_inheriting_hsts` is unchanged. It already runs on the copy in `add_listener` and on every listener HSTS patch, and it now reaches these frontends too. No new allocation, and nothing changes on the request path. The only extra work is the refresh walk, which now also rebuilds these frontends during a listener patch or a listener add. ### Behaviour change on a single listener This affects a policy-carrying frontend with no `hsts` of its own, added before the listener had an HSTS default. When a patch later enables the default, that frontend now gets the header. Before, it did not; frontends without any policy already did, through route promotion. Two cases are unchanged: - A frontend with its own `hsts` (including `enabled = false`). - A frontend added while the listener already had a default. ## Tests (`lib/src/https.rs`, `listener_sibling_tests`) - `a_copied_frontend_without_hsts_inherits_the_new_listener_default`: two HTTPS listeners on one address (the second on `interface = "lo"`). A tagged frontend without `hsts` is added while the first listener has no default, then the second listener is added with `max-age=100`. Each listener must serve its own default, including after a separate patch to each listener. - `a_frontend_with_explicit_hsts_is_never_overridden_by_a_listener_default`: guard. A frontend with explicit `hsts` keeps it on both listeners, at copy time and after patches. It is green both before and after the fix. - `a_listener_hsts_patch_refreshes_every_frontend_without_its_own_hsts`: a single listener, starting with no default and with a default. A patch that enables HSTS reaches the tagged frontend, and a patch that disables it removes the header. RED on `origin/main` (d9ce2a0) with the tests only: ``` test https::listener_sibling_tests::a_listener_hsts_patch_refreshes_every_frontend_without_its_own_hsts ... FAILED test https::listener_sibling_tests::a_copied_frontend_without_hsts_inherits_the_new_listener_default ... FAILED test https::listener_sibling_tests::a_frontend_with_explicit_hsts_is_never_overridden_by_a_listener_default ... ok assertion `left == right` failed left: None right: Some("max-age=700") assertion `left == right` failed: the listener added after the frontend must serve its own HSTS default left: None right: Some("max-age=100") test result: FAILED. 5 passed; 2 failed; 0 ignored; 0 measured; 1354 filtered out ``` GREEN with the fix: ``` test https::listener_sibling_tests::a_copied_frontend_without_hsts_inherits_the_new_listener_default ... ok test https::listener_sibling_tests::a_listener_hsts_patch_refreshes_every_frontend_without_its_own_hsts ... ok test https::listener_sibling_tests::a_frontend_with_explicit_hsts_is_never_overridden_by_a_listener_default ... ok test result: ok. 1361 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ``` ## Validation (each by its own exit code, all 0) - `cargo build --all-features` - `cargo clippy --all-features --all-targets -- -D warnings` - `cargo +nightly fmt --all -- --check` - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked` - `cargo test -p sozu-lib`: 1371 passed - `cargo test -p sozu`: 242 passed - `cargo test -p sozu-command-lib`: 210 passed - e2e `cargo test -p sozu-e2e -- <group>`: `hsts` 7, `https` 6, `tls_tests` 9, `listener` 27, all passed - `check_doc_citations.py` in all four modes: `--self-test`, `--root .`, `--base origin/main`, `--audit --root .` ## Docs - `doc/configure.md`, HSTS hot-reconfig: defines an inheriting frontend and describes how a listener added on a shared address resolves inheritance. - `CHANGELOG.md`, Unreleased / Fixed. - `doc/configure_admin_ops.md`: one line citation renumbered (`doc/configure.md:1266` becomes `:1268`), because the docs insertion moved that line. ## Not addressed (pre-existing, follow-ups) - `HttpsProxy::update_listener` finds the listener to patch by address alone (`.find(...)`). With several listeners on one address (on different interfaces), an `UpdateHttpsListenerConfig` reaches only one of them, whichever the `HashMap` order yields first. The new tests call `HttpsListener::update_config` on each listener directly. - Cluster answer templates reach only listeners that exist when the cluster is added (noted in #1691). Closes #1691 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
## Summary
Sōzu added both forwarding header families (`X-Forwarded-*` and RFC 7239 `Forwarded`) to every forwarded request, unconditionally. This PR adds a per-listener enum for HTTP and HTTPS listeners:
```toml
forwarded_headers = "both" # both (default) | x_forwarded | rfc7239 | none
```
| Mode | Sōzu adds | Client-supplied headers |
| --- | --- | --- |
| `both` (default) | `X-Forwarded-For`, `-Proto`, `-Port`, `Forwarded` | same as before, byte for byte: XFF and `Forwarded` chains extended, client `-Proto`/`-Port` kept |
| `x_forwarded` | `X-Forwarded-For`, `-Proto`, `-Port` | same handling as `both` for that family; `Forwarded` passes through |
| `rfc7239` | `Forwarded` only | `Forwarded` extended (RFC 7239 §4); `X-Forwarded-For/-Proto/-Port/-Host` **removed** |
| `none` | nothing | everything passes through untouched (documented trust caveat) |
## Design
- **Wire and config**: `enum ForwardedHeaders { BOTH = 0; X_FORWARDED; RFC7239; NONE }` (`command/src/command.proto:824`). `BOTH = 0` means an absent field, or a state file written before this change, keeps today's behaviour. The field is `optional ForwardedHeaders forwarded_headers` on `HttpListenerConfig` (36), `HttpsListenerConfig` (49), `UpdateHttpListenerConfig` (42) and `UpdateHttpsListenerConfig` (43). The TOML-side `ForwardedHeadersMode` (`command/src/config.rs:1773`) is `snake_case` and uses the `MetricDetailLevel` ↔ `MetricDetail` pattern, because `build.rs` puts `SCREAMING_SNAKE_CASE` on every prost enum.
- **Hot update**: it follows the `send_x_real_ip` path through `L7ListenerHandler::get_forwarded_headers` (`lib/src/lib.rs:661`, `lib/src/http.rs:975`, `lib/src/https.rs:1423`) and `update_config`, and is captured per stream in `Context::create_stream` (`lib/src/protocol/mux/mod.rs:1206`), like `strict_sni_binding`. An H2 stream picks up a patch at its next HEADERS, an H1 connection when it opens (`mux/LIFECYCLE.md` §2.5). Unlike `send_x_real_ip`/`elide_x_real_ip`, which `ConfigState::update_http(s)_listener` does not apply (see Residual risks), the main-process state records the patched mode. The state (`command/src/state.rs:874,999`) and the worker (`lib/src/http.rs:1460`, `lib/src/https.rs:1744`) both run `validate_forwarded_headers` (`command/src/state.rs:3226`) and refuse an unknown wire value.
- **Editor** (`lib/src/protocol/kawa_h1/editor.rs`, shared by H1 and H2 frontends): `emits_x_forwarded` / `emits_rfc7239` / `strips_x_forwarded` (L240–L254) only gate *emission*: the chain extensions (L1324), the synthesis (L1343, L1395) and the `rfc7239` elision branch (L1147). `ForwardingHop` stays mode-agnostic and renders every value once per connection. That keeps `send_x_real_ip` working in every mode, keeps the `renders()` cache and `reset()` invariants unchanged, and keeps the allocation-count tests for the default path unchanged. `X-Real-IP` is injected at the same position as before, so `both` stays byte-exact (`header_editing_output_is_byte_exact_across_keep_alive_requests` is unchanged and green). A debug postcondition (L1478) checks that `rfc7239` forwards no managed `X-Forwarded-*` header. `xff_chain` (access log) is still recorded in every mode. The `http.trusting.x_{proto,port}` counters count only in `both` and `x_forwarded`.
- **`X-Forwarded-Host` on `rewrite_host`** (`lib/src/protocol/mux/router.rs:1539`): injected, replacing a client one, only in `both` and `x_forwarded`. In `rfc7239` and `none` nothing is injected, and under `none` a client `X-Forwarded-Host` passes through as sent. Sōzu's `Forwarded` element keeps its current parameters (`proto`, `for`, `by`); adding RFC 7239 §5.3 `host=` would change the wire format for every rewrite, so it is left as a possible follow-up. As a result the pre-rewrite authority is not conveyed in `rfc7239`, which the docs state.
- **`X-Real-IP` independence**: `elide_x_real_ip` / `send_x_real_ip` are untouched by the mode. `X-Real-IP` belongs to neither family, and `send_x_real_ip = true` still injects it under `none` and `rfc7239`. Unit and e2e tests assert this.
- **H2 trailers**: no change. `pkawa::handle_trailer` already drops `X-Forwarded-For`, `Forwarded` and `X-Real-IP` from trailer blocks in every mode.
- **CLI**: `sozu listener {http,https} {add,update} --forwarded-headers <both|x_forwarded|rfc7239|none>` (clap `ValueEnum` with the TOML spellings). `listener list` shows the mode, and the patch audit diff renders it by name.
## What "strict" means for `rfc7239`
In `rfc7239` mode, client-supplied `X-Forwarded-For`, `X-Forwarded-Proto`, `X-Forwarded-Port` and `X-Forwarded-Host` (the four Sōzu itself manages) are **elided**. They are neither passed through nor converted. The reasons:
1. **RFC 7239 §8.1** (Header Validity and Integrity): the header "cannot be relied upon to be correct, as it may be modified, whether mistakenly or for malicious reasons, by every node on the way to the server, including the client making the request". Its caveat that "the chain of IP addresses listed before the request came to the proxy cannot be trusted" applies equally to `X-Forwarded-*`.
2. **Pass-through would be weaker than today.** In this mode Sōzu no longer appends its hop to `X-Forwarded-For`, so a backend still reading the rightmost `X-Forwarded-For` would trust a client-forged value with nothing Sōzu wrote after it. Elision leaves the backend one forwarding family, whose last element is Sōzu's.
3. **No §7.4 conversion.** RFC 7239 §7.4 (Transition) only *encourages* converting `X-Forwarded-*` into `Forwarded` "if it can be done in a sensible way". It warns that when several `X-Forwarded-*` fields coexist "it may not be possible to do a conversion, since it is not possible to know in which order the already existing fields were added". Converted elements would also be exactly as untrusted as the originals.
4. **RFC 7239 §4** lets a proxy remove forwarding fields ("A proxy MAY remove all "Forwarded" header fields from a request"). Removing the non-standard family in a mode that promises the standard one is within that intent. The client `Forwarded` chain itself is preserved and extended, following §4 ("append it to the last existing "Forwarded" header field after a comma separator") and §7.2 ("A directly forwarded request should preserve and possibly extend it").
5. **RFC 7239 §7.1** (HTTP Lists): a list "may be split over multiple header fields", so several `Forwarded` lines form one list. Appending Sōzu's element to the *last* client `Forwarded` line therefore extends the whole list, which is why the editor keeps only the last `Forwarded` header it sees. The same list semantics are why `rfc7239` elides *every* client `X-Forwarded-For` line, not only the last (the editor unit test sends two).
Other `X-Forwarded-*` names (for example `X-Forwarded-Prefix`) are not attestations Sōzu manages and pass through in every mode.
`none` is the RFC 7239 §8.2 (Information Leak) option of "preventing the internal nodes from updating the HTTP header field", for operators who do not want Sōzu to disclose the peer or its own address.
In `x_forwarded` mode a client `Forwarded` passes through untouched. The owner's decision was that this mode keeps exactly the current handling of the family it emits. The docs carry the same trust caveat for it as for `none`.
## Review follow-ups (folded into this commit)
1. **Malformed client `Forwarded`: MEDIUM, fixed.** In `both` and `rfc7239`, a client line such as `Forwarded: for="6.6.6.6` (unclosed quoted-string) was extended into `for="6.6.6.6, proto=http;for="10.0.0.1:54321";by=127.0.0.1`. That swallowed Sōzu's element, and I reproduced it in both modes, so the bug predates this PR in `both`. The client value is now checked against the RFC 7239 §4 grammar by `is_valid_forwarded` (`lib/src/protocol/kawa_h1/editor.rs`): a list of `;`-separated `token=value` pairs, where a value is a token or an RFC 9110 §5.6.4 quoted-string. Empty list elements and OWS around `,`/`;` are tolerated, as RFC 9110 §5.6.1 asks of recipients. A malformed line is elided, which RFC 7239 §4 permits. Sōzu's element then goes to an earlier well-formed line or into a synthesised `Forwarded`, so it is always parseable and last.
- **Also applied in `both`:** it is the other mode that extends the chain and had the same corruption. Well-formed input is byte-identical; every existing byte-exact editor test is unchanged and green.
- **Not applied in `x_forwarded` and `none`:** they do not touch `Forwarded`, so the line passes through as sent.
- **Tests:** `a_malformed_client_forwarded_is_elided_where_the_chain_is_extended` (the probe input, plus a well-formed line followed by a malformed one) and `is_valid_forwarded_follows_the_rfc7239_grammar` (unit), and `test_forwarded_headers_rfc7239_malformed_client_forwarded_h1` (e2e).
2. **H2 trailers: LOW, fixed.** `pkawa::handle_trailer` now also drops `x-forwarded-proto`, `x-forwarded-port` and `x-forwarded-host`. The drop is unconditional, matching the existing semantics there: every header the initial-HEADERS pass rewrites is dropped from trailers regardless of listener flags, and in every mode each of these three is either synthesised (`both`/`x_forwarded`) or removed (`rfc7239`), so a trailer copy is a spoof vector in all of them. Test: `handle_trailer_drops_each_spoof_header_individually`, extended.
3. **Add-path validation: LOW, fixed.** `validate_forwarded_headers` now runs on `AddHttpListener`/`AddHttpsListener` in `ConfigState::add_http(s)_listener` (before anything is stored) and in the worker's `HttpListener::new` / `HttpsListener::try_new`. Tests: `add_listener_rejects_an_unknown_forwarded_headers_value` (state), and `a_listener_with_an_unknown_forwarded_headers_value_is_refused` (http.rs and https.rs).
Follow-up RED, then GREEN:
- Editor, against a stub validator returning `true` (the pre-fix behaviour): `a_malformed_client_forwarded_is_elided_where_the_chain_is_extended ... FAILED` with left `["for=\"6.6.6.6, proto=http;for=\"10.0.0.1:54321\";by=127.0.0.1"]`, right `["proto=http;for=\"10.0.0.1:54321\";by=127.0.0.1"]`; the grammar test also FAILED. With the fix: both `ok`.
- e2e, with the validity check disabled: `test_forwarded_headers_rfc7239_malformed_client_forwarded_h1 ... FAILED`. Restored: `ok`.
- Trailer, before extending the drop list: `trailer with only x-forwarded-proto should leave no surviving block ... FAILED`. After: `ok` (all 4 `handle_trailer` tests).
- State add, before the fix: `called Result::unwrap_err() on an Ok value ... FAILED`. After: `ok`.
- Worker add, before the fix: both `a_listener_with_an_unknown_forwarded_headers_value_is_refused` FAILED (`an unknown mode must be refused`). After: `ok`.
## Tests (seen RED, then GREEN)
RED runs were produced by removing the behaviour under test (for the editor, before the gating existed; otherwise by temporarily reverting the named line), never by a compile error.
Editor, before gating (`both` passes from the start because it pins today's behaviour):
```
test ...editor::tests::forwarded_headers_survives_reset ... ok
test ...editor::tests::forwarded_headers_x_forwarded_adds_only_the_x_forwarded_family ... FAILED
test ...editor::tests::forwarded_headers_none_adds_nothing_and_passes_client_headers_through ... FAILED
test ...editor::tests::forwarded_headers_rfc7239_adds_only_forwarded_and_strips_client_x_forwarded ... FAILED
test ...editor::tests::forwarded_headers_both_adds_both_families_and_extends_client_chains ... ok
test result: FAILED. 2 passed; 3 failed
```
After gating: `test result: ok. 5 passed; 0 failed`.
Router, with `synthesises_xfh = rewriting_host` alone: `a_host_rewrite_discloses_x_forwarded_host_only_in_x_forwarded_modes ... FAILED` (left: `[b"rewrite.example.com"]`, right: `[]`). Restored: `ok`.
Config, with `to_http`/`to_tls` not setting the field: `forwarded_headers_parses_every_mode_defaults_to_both_and_rejects_others ... FAILED` (left `(None, None)`, right `(Some(0), Some(0))`). Restored: `ok`. The test also covers every spelling, the absent key (`both`) and serde's `unknown variant` error for `RFC7239`, `x-forwarded`, `forwarded` and `""`.
State, without the patch arm: `update_listener_forwarded_headers_applies_and_rejects_unknown_values ... FAILED` (left `Both`, right `Rfc7239`). Restored: `ok`.
CLI, without `#[value(name = "x_forwarded")]`: `listener_https_update_parses_forwarded_headers ... FAILED`. Restored: `ok`.
e2e, without `http_context.forwarded_headers = listener.get_forwarded_headers()` in `Context::create_stream`:
```
test tests::tests::test_forwarded_headers_none_h1 ... FAILED
test tests::tests::test_forwarded_headers_rfc7239_h1 ... FAILED
test tests::listener_update_tests::test_forwarded_headers_hot_change ... FAILED
test tests::protocol_pair_matrix::forwarded_headers_rfc7239::test_h1_h1 ... ok
test tests::protocol_pair_matrix::forwarded_headers_rfc7239::test_h2_h2 ... FAILED
test tests::protocol_pair_matrix::forwarded_headers_rfc7239::test_h1_h2 ... FAILED
test tests::protocol_pair_matrix::forwarded_headers_rfc7239::test_h2_h1 ... ok
test result: FAILED. 2 passed; 5 failed
```
The `*_h1` backend cells pass here because, as for the existing X-Real-IP matrix feature, `AsyncBackend` exposes no request bytes; those cells only check forwarding. The H2 frontend is proved by `h2_h2`. Without the worker's `update_config` arm, `test_forwarded_headers_hot_change` fails with `patch_ok=true before_ok=true after_ok=false`. Restored: `test result: ok. 7 passed; 0 failed`.
## Validation
Run on head `1076a246`, rebased onto `origin/main` `d9ce2a02` (after #1686):
- `cargo build --all-features`: exit 0
- `cargo clippy --all-features --all-targets -- -D warnings`: exit 0
- `cargo +nightly fmt --all -- --check`: exit 0
- `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked`: exit 0
- `cargo test -p sozu-lib`: exit 0 (`1368 passed; 0 failed`)
- `cargo test -p sozu`: exit 0 (`122 passed`)
- `cargo test -p sozu-command-lib`: exit 0 (`202 passed`)
- e2e groups, each exit 0: `forward` (23), `x_real_ip` (9), `listener_update` (15), `listener` (28), `protocol_pair_matrix` (28), `trailer` (5)
- `python3 .github/scripts/check_doc_citations.py` `--self-test`, `--root .`, `--base origin/main` and `--audit --root .`: all exit 0
- the full e2e suite (`508 passed; 0 failed`) was run on the previous head `a339a456`, before #1686
Rebase onto #1686 (listener `interface`):
- `command.proto`: #1686 took field numbers 35 (`HttpListenerConfig`) and 48 (`HttpsListenerConfig`) for `interface`, the numbers this PR had used. `interface` keeps them, and `forwarded_headers` moves to 36 and 49. The Update messages keep 42 and 43. No release has shipped the old numbers.
- `state.rs`: `add_http(s)_listener` keeps #1686's `validated_listener_key` and runs `validate_forwarded_headers` before it.
- `cli.rs` / `request_builder.rs`: both new CLI tests are kept, and the `add` builders chain `.with_interface(interface)` after the optional `with_forwarded_headers`.
- `CHANGELOG.md`: both new entries are kept.
- `doc/configure_admin_ops.md`: kept this PR's symbol citation in place of the renumbered `https.rs:515`.
- e2e: the new H1 helper gains `interface: None` in its `ActivateListener`, as #1686 did for the sibling helpers.
## Docs
`doc/configure.md` (new "Forwarding headers" section with the security note and trust caveat, an updatable-fields row, and the `send_proxy` paragraph), `doc/configure_admin_ops.md` (patch boundary list), `doc/lifetime_of_a_session.md`, `lib/src/protocol/kawa_h1/LIFECYCLE.md` §2 and §4, `lib/src/protocol/mux/LIFECYCLE.md` §2.5 capture table, `bin/config.toml` (both listener examples), `e2e/COVERAGE.md`, and `CHANGELOG.md` (Unreleased).
## Residual risks
- In `rfc7239` and `none`, a `rewrite_host` conveys no pre-rewrite authority. The RFC 7239 §5.3 `host=` parameter is the natural follow-up.
- The trust caveat for `none` (and for `Forwarded` under `x_forwarded`) is documented, not enforced.
- Existing gap, not changed here: H1 chunked trailers have no spoof-header filter at all (`X-Real-IP`, `X-Forwarded-For` and `Forwarded` included); only H2 trailers are filtered.
- Existing gap, not changed here: `ConfigState::update_http(s)_listener` does not apply `elide_x_real_ip` / `send_x_real_ip` patches, so after a hot update the main-process state (`listener list`, `SaveState`, upgrade replay) still shows the old values for those two knobs. `forwarded_headers` is applied there.
Closes #322
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
## Problem While Sōzu shuts down (`HttpContext::closing`, set by `Mux::shutting_down_inner`), `HttpContext::on_request_headers` and `HttpContext::on_response_headers` (`lib/src/protocol/kawa_h1/editor.rs`) overwrote every `Connection` value with `close`. That dropped the other options: a field the peer nominated as hop-by-hop (`Connection: x-custom`) was forwarded as end-to-end (RFC 9110 §7.6.1), a request's `Upgrade` field reached the backend without the `upgrade` option that must accompany it (§7.8), and, on the response side, the backend's own `close` was no longer recorded in `keep_alive_backend`. An HTTP/1.1 final response without a `Connection` line got no `close` at all. ## Fix - Both header loops now always record the `close` decision from the original value (`keep_alive_frontend` / `keep_alive_backend`); nothing is rewritten inside the loop. - The HTTP/1.0 merge from #1683 moves into `merge_connection_options_into_close`: every `Connection` line is elided and one line is pushed with the other options followed by a single `close`; `keep-alive` (and an already listed `close`) is dropped. A lone `close` stays a static value (no allocation). - Request side: under `closing`, the merge runs (it replaces the old push-if-absent), so `Connection: close` is still added when the client sent none. - Response side: the merge runs for every final response under `closing` (HTTP/1.1 as well as HTTP/1.0), and as before for a non-persistent HTTP/1.0 response. A 1xx is left alone, as the HTTP/1.0 branch already did. - Docs: `lib/src/protocol/kawa_h1/LIFECYCLE.md` (both callbacks), `CHANGELOG.md` (Unreleased / Fixed). ## Decision: a request asking for `Upgrade` during shutdown Options: (a) keep `Connection: Upgrade, close` and let the backend decide; (b) refuse the upgrade. This PR takes **(b)**: the `upgrade` option is dropped along with every `Upgrade` field (a nominated field must not go end-to-end, §7.6.1). The backend then answers in HTTP/1.1, which a server may always do (§7.8: accepting an upgrade is optional), and the client gets a normal response with `Connection: close` and can retry the upgrade on a new connection. Why not (a): `ConnectionH1::writable` (`lib/src/protocol/mux/h1.rs`) checks `stream.context.closing` **before** the `101` arm, so while draining Sōzu never completes an upgrade. Under (a), a 101 would reach the client and the connection would close right after it. Refusing is the only choice consistent with the existing drain semantics (finish in-flight work, start no long-lived work). Before this PR the request already went out as `Connection: close` + `Upgrade: websocket` (see RED below), which was broken in its own way. If you would rather keep the upgrade, `writable` has to change too; please say so on this PR. ## `lib/src/protocol/kawa_h1/answers.rs` whole-value `Connection: close` match: left as is That match (in the template parser) sets the template's own `keep_alive` flag. It reads operator-authored answer templates, not peer traffic, and every shipped default template carries a lone `Connection: close` line (checked: all 15 `Connection:` lines of the built-in default templates in `answers.rs`, outside its test module, are exactly `Connection: close`), so no default answer is affected. It is the same kind of defect as #1687 (a list such as `x, close` would read as keep-alive), but it is outside this shutdown fix. It deserves its own small follow-up that exposes `has_connection_option` to `answers.rs`. ## Tests New unit tests in `editor.rs`, run with `closing = true`: - `a_shutting_down_request_keeps_its_connection_options`: no Connection → `close`; `x-custom` → `x-custom, close`; `keep-alive, x-custom` → `x-custom, close`; `close` stays a single `close` and clears `keep_alive_frontend`; two lines merged; HTTP/1.0. - `a_shutting_down_request_does_not_upgrade`: `Upgrade` → `close` with no `Upgrade:` field; `keep-alive, Upgrade, x-custom` → `x-custom, close`. - `a_shutting_down_response_keeps_its_connection_options`: the same matrix on HTTP/1.1 responses plus a persistent HTTP/1.0 one; the backend `close` clears `keep_alive_backend`. - `a_shutting_down_interim_response_is_left_alone`: a 101 keeps `Connection: Upgrade`; a 100 gets no line. **RED** (tests added on `origin/main` 3ed6e8a before the fix, `cargo test -p sozu-lib --lib a_shutting_down`): ``` test protocol::kawa_h1::editor::tests::a_shutting_down_request_does_not_upgrade ... FAILED test protocol::kawa_h1::editor::tests::a_shutting_down_request_keeps_its_connection_options ... FAILED test protocol::kawa_h1::editor::tests::a_shutting_down_interim_response_is_left_alone ... FAILED test protocol::kawa_h1::editor::tests::a_shutting_down_response_keeps_its_connection_options ... FAILED websocket: the Upgrade field is not forwarded, got "GET /chat HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\nUpgrade: websocket\r\n..." nominated field: ... left: ["Connection: close"] right: ["Connection: x-custom, close"] 101: ... left: ["Connection: close"] right: ["Connection: Upgrade"] no Connection: ... got "HTTP/1.1 200 OK\r\nContent-Length: 4\r\nSozu-Id: ...\r\n\r\nabcd" left: [] right: ["Connection: close"] test result: FAILED. 0 passed; 4 failed; 0 ignored; 0 measured; 1349 filtered out ``` **GREEN** (`cargo test -p sozu-lib --lib kawa_h1`): ``` test protocol::kawa_h1::editor::tests::a_shutting_down_request_does_not_upgrade ... ok test protocol::kawa_h1::editor::tests::a_shutting_down_interim_response_is_left_alone ... ok test protocol::kawa_h1::editor::tests::a_shutting_down_response_keeps_its_connection_options ... ok test protocol::kawa_h1::editor::tests::a_shutting_down_request_keeps_its_connection_options ... ok test result: ok. 71 passed; 0 failed ``` ### Why there is no e2e test The request-side shutdown branch is unreachable today, and no known sequence reaches the response-side one: the fix is defensive. The e2e harness cannot reach either. `Mux::shutting_down_inner` sets `closing` only on an `Unlinked` stream, whose headers were already edited, and an idle keep-alive session is closed rather than marked (see `try_msg_close`). Measured: with an `eprintln!` probe in both merge branches, the whole `sozu-e2e` suite (fuzz skipped) got **0 probe hits** (493 passed / 7 failed; the 7 are load flakes, see below). The probe was then removed. This shows only that the harness does not reach the branches; whether production traffic can reach them (for example via a retried or H2 stream) is not established here. The unit tests are the coverage, and LIFECYCLE.md says so. ## Validation (each by its own exit code) - `cargo build --all-features` → 0 - `cargo clippy --all-features --all-targets -- -D warnings` → 0 - `cargo +nightly fmt --all -- --check` → 0 - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked` → 0 - `cargo test -p sozu-lib` → 0 (1363 passed); `-p sozu` → 0 (238); `-p sozu-command-lib` → 0 (195) - e2e: `http10` 5/5, `close_delimited` 12/12, `keep_alive` 4/4, `connection` 20/20, `upgrade` 14/14, `websocket` 4/4, `soft_stop` 2/2, all exit 0 - `check_doc_citations.py` `--self-test`, `--root .`, `--base origin/main`, `--audit --root .` → all 0 Flake triage for the 7 failures in the full probe run (host load average 43–63 from concurrent builds): `test_h1_smuggling_te_cl_trailing_tab`, `e2e_h2_flow_per_stream_idle_timeout`, `test_upgrade` and `test_upgrade_multiple_in_flight` passed on their first isolated rerun. `test_h2_graceful_shutdown_completes_large_transfer` and `test_issue_806` failed once in isolation, then passed 3 more isolated runs. `test_h1_to_h2_basic_request` (H1 client → H2 backend, `closing` never set) then went 8/8 on this branch and 8/8 on an `origin/main` worktree in interleaved runs. None of these paths enter the changed branches: the probe fired 0 times. ## Revision 2 (after review) - Rebased on `origin/main` d9ce2a0 (#1686). - MSRV clippy (1.93.1, `clippy::nonminimal_bool`) flagged the option filter in `merge_connection_options_into_close`: it is now a named `dropped` disjunction, with no `allow`. `cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings` → 0 (0 warning/error lines); stable clippy → 0. - Dropped the tautological shutdown `debug_assert!` in `on_response_headers`. - LIFECYCLE.md now states that the request-side shutdown branch is unreachable today (`Mux::shutting_down_inner` sets `closing` only on an `Unlinked`, non-quiesced stream whose heads were both edited) and that both branches are defensive. - Rerun: build, nightly fmt, doc `-D warnings`, `cargo test -p sozu-lib` (1372 passed), `kawa_h1` 71 passed, e2e `http10` 5/5, `connection` 20/20, `upgrade` 15/15, `websocket` 4/4, four citation checks → all 0. ## Residual risks - Textual conflict with #1685 (`feat/forwarded-headers`) in the `on_request_headers` header loop: adjacent lines only, trivial to resolve. The first PR to merge leaves a one-hunk rebase for the other. - The shutdown branches are covered by unit tests only (see above). Closes #1690 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Sep 29, 2026
…1694) ## Problem `UpdateHttpListenerConfig` / `UpdateHttpsListenerConfig` carry `elide_x_real_ip` and `send_x_real_ip`, and the workers apply them (`HttpListener::update_config` in `lib/src/http.rs`, and its HTTPS counterpart), but `ConfigState::update_http_listener` / `ConfigState::update_https_listener` (`command/src/state.rs`) never patched either field. On `origin/main` (`3ed6e8a6`; still true after #1686 re-keyed the listener maps): ``` $ git grep -n 'send_x_real_ip\|elide_x_real_ip' origin/main -- command/src/state.rs (no output) ``` So the main state kept the creation-time value: `sozu listener list` and `SaveState` showed it, and the state replayed to a new worker on upgrade/restart restored it, silently reverting the hot change. ## Fix Patch both flags in both functions, next to the other shared per-connection knobs (after `request_timeout`), with the same `if let Some(v)` form the worker uses. Absent fields preserve the recorded value. Control-plane only: no hot-path allocation or syscall. The insertion point is deliberately away from the tail of the two functions, where #1685 adds `forwarded_headers`, to keep rebasing trivial. ## Tests Rebased onto `05ac4f9c` (#1686 listener-by-interface, #1693). The field writes sit after `listener_key_for_update` resolves the listener, and the tests look listeners up by `ListenerKey::from(addr)`. RED/GREEN below re-run on the rebased tree. - `command/src/state.rs`: `update_http_listener_x_real_ip_patch_applied`, `update_http_listener_x_real_ip_absent_preserves_existing`, `update_https_listener_x_real_ip_patch_applied`, `update_https_listener_x_real_ip_absent_preserves_existing`, `update_listener_x_real_ip_survives_generate_requests_replay`. - `e2e/src/tests/tests.rs`: `test_x_real_ip_hot_update_survives_upgrade` — an HTTP listener starts with both flags off, a hot `UpdateHttpListener` turns both on, a spoofed `X-Real-IP: 1.2.3.4` request is checked on the old worker, then `Worker::upgrade` seeds a new worker from the harness's mirror `ConfigState` (the same `ConfigState::update_http_listener` the main process runs) and the same request is checked again. ### RED (fix reverted) ``` $ cargo test -p sozu-command-lib --locked x_real_ip test state::tests::update_https_listener_x_real_ip_patch_applied ... FAILED test state::tests::update_https_listener_x_real_ip_absent_preserves_existing ... FAILED test state::tests::update_http_listener_x_real_ip_absent_preserves_existing ... FAILED test state::tests::update_http_listener_x_real_ip_patch_applied ... FAILED test state::tests::update_listener_x_real_ip_survives_generate_requests_replay ... FAILED left: None right: Some(true) test result: FAILED. 0 passed; 5 failed; 0 ignored; 0 measured; 199 filtered out $ cargo test -p sozu-e2e --locked test_x_real_ip_hot_update_survives_upgrade test tests::tests::test_x_real_ip_hot_update_survives_upgrade ... FAILED after upgrade: spoofed X-Real-IP was not elided: left: Fail right: Success test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 506 filtered out ``` (The e2e "before upgrade" check passes on `main`: the worker applies the patch; only the upgraded worker reverts it.) ### GREEN ``` $ cargo test -p sozu-command-lib --locked x_real_ip test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 199 filtered out $ cargo test -p sozu-e2e --locked test_x_real_ip_hot_update_survives_upgrade test tests::tests::test_x_real_ip_hot_update_survives_upgrade ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 506 filtered out ``` ## Validation (each by its own exit code, all 0) - `cargo build --all-features` - `cargo clippy --all-features --all-targets -- -D warnings` - `cargo +nightly fmt --all -- --check` - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked` - `cargo test -p sozu-command-lib` (204 passed), `cargo test -p sozu` (121 passed), `cargo test -p sozu-lib` (1358 passed) - e2e: `x_real_ip` (10 passed), `listener_update` (14 passed), `upgrade` (16 passed) - `check_doc_citations.py` `--self-test`, `--root .`, `--base origin/main`, `--audit --root .` ## Docs - `doc/configure.md`: the X-Real-IP section now states that the main state records the patch, so `listener list`, `SaveState` and upgrade replay carry it. - `CHANGELOG.md`: Unreleased / Fixed entry. ## Out of scope `sozu listener http|https update` exposes no CLI flag for either knob (only the protobuf patch does); unchanged here. Closes #1688 Signed-off-by: Florentin Dubois <[email protected]>
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.
What
A listener can be bound to a network interface by name, for an interface whose address is not known ahead or not stable (a WireGuard
wg0, the case in #719):interfaceonHttpListenerConfig,HttpsListenerConfig,TcpListenerConfig,UdpListenerConfig(command/src/command.proto:530,:681,:715,:739), onActivateListener/DeactivateListener/RemoveListener(:829,:839,:848), on the TOMLListenerBuilder, and--interfaceonsozu listener <protocol> add|remove|activate|deactivate.Socket::bind_device(Some(name))beforebind(2)bybind_to_device(lib/src/socket.rs:1634), called fromserver_bind(:1667, HTTP/HTTPS/TCP) andudp_bind(:1749). Setting it beforebindis what lets two listeners share an address underSO_REUSEADDR/SO_REUSEPORT.SO_BINDTODEVICEis aSOL_SOCKEToption, soudp_bindtakes it exactly likeserver_bind. Replies to clients leave through that same listener socket. The per-flow upstream sockets (udp_connect) talk to backends, not to clients, so they are left alone: binding them would tie backend traffic to the frontend interface.Update*ListenerConfig: changing the interface needs a rebind (remove + add).Design: the interface is part of the listener identity
ListenerKey { address, interface: Option<String> }(command/src/listener_key.rs:120) replaces the bareSocketAddrwherever a listener is stored or looked up:ConfigState::{http,https,tcp,udp}_listenersBTreeMap<ListenerKey, _>(command/src/state.rs:206); add, remove, activate, deactivate, diff andgenerate_*_requestscarry the interfaceActivateListener/DeactivateListener/RemoveListenerinterfaceselector;listener_key()on each message and config (command/src/listener_key.rs)Listeners,ListenersCountmanifest)Vec<(ListenerKey, RawFd)>(command/src/scm_socket.rs:501), manifest entries parsed as keys (:622)inherited_socket_fate,activate_listener,listener_token,give_back_listener(s),remove_listenermatch on the key (HttpListener::isand siblings inlib/src/{http,https,tcp,udp}.rs);Serverbuilds the key from the request (lib/src/server.rs:2706,:3142,:3398)compute_rollbackcarries the interface (bin/src/command/requests.rs:2445)ListenersList/sozu listener list/sozu top/ audit targetsinterfacecolumn/row in the tablesBackward compatibility. The key's text form is the bare
SocketAddrtext for a listener without interface and<address>%<interface>otherwise (FromStr/Serializeatcommand/src/listener_key.rs:163,:184).%is refused in interface names (validate_interface_name,:63) and aSocketAddronly prints%inside IPv6 brackets, so parsing is unambiguous. Consequences:ConfigStateJSON crossing a main-process upgrade (UpgradeData) keeps identical map keys for every existing listener (the listener values now carry"interface": null, which an older Sōzu ignores as an unknown field); an older state withoutinterfacefields deserializes to the same state.WorkerRequestJSON) withoutinterfaceload unchanged (Optiondefaults toNone).interfacebehaves exactly as before.Frontends and certificates stay keyed by address and apply to every listener of their protocol on that address (
listeners_atinlib/src/http.rs:1134,lib/src/https.rs:2338,lib/src/tcp.rs:2905;listener_tokens_atinlib/src/udp.rs:763). This keepsRequestHttpFrontend,RequestTcpFrontend,RequestUdpFrontend,AddCertificate& co. untouched.add_listenercopies the routes of a listener already on the address when it creates the new one:Router+ tags for HTTP,Router+ tags + a deep copy of theCertificateResolverinto the new listener's own resolver (the one its rustls config already points at) + an HSTS-inheritance refresh for HTTPS, cluster/SNI routes + tags for TCP, cluster + tags + flow-managerSetClusterfor UDP (adopt_sibling_route). This coverssozu listener <protocol> add --interfaceand a configuration reload, which both send only the new listener's add/activate (reload_adding_an_interface_listener_sends_only_that_listener). I chose the worker-side copy over a main-side replay of the address's frontends/certificates: frontend and certificate requests name an address, so a replay would reach the existing siblings too, which already hold those routes (duplicate adds would fail the scatter and trigger the main's rollback). Replaying would need an interface selector on every frontend/certificate message, which is the per-interface-routing change this PR keeps out of scope.Router,TrieNodeandCertificateResolvergain#[derive(Clone)]for this.listeners_atsorts by token), so no sibling keeps a route or certificate the others dropped. TCP/UDP removals were already infallible per listener.ConfigError::ListenerProtocolMismatchOnAddress), because a file frontend finds its listener's protocol from its address. At runtime, frontend requests are typed per protocol, so I do not enforce this inConfigState: an HTTP listener onwg0and a TCP listener on the bare address are unambiguous and useful. Per-interface routing (different frontends per interface on one address) is out of scope: it would need an interface on every frontend/certificate message, state key and CLI verb.Update patches still name their listener by address only. When exactly one listener sits on that address (with or without interface) the patch applies to it; when several do, the main process refuses it with
StateError::AmbiguousListenerAddress(command/src/state.rs:139,listener_key_for_updateat:154) instead of patching an arbitrary one. If you prefer an optional key-onlyinterfaceselector on the fourUpdate*ListenerConfigmessages, that is a small follow-up; I kept them untouched per the "not part of the Update messages" decision.Mixed versions
The main process tracks no worker version (
WorkerInfocarries none), so it cannot refuse an interface listener while an older worker runs. An older worker ignores theinterfacefield and would bind on every interface, and matches Activate/Deactivate/Remove by address only.doc/configure.mdand the CHANGELOG say: upgrade the main process and every worker before usinginterface; downgrading while a listener names an interface is unsupported (an older Sōzu cannot parse<address>%<interface>keys in a saved state or an upgrade hand-off).Errors and platform
./..,/,:,%, whitespace, NUL) are refused at config load (ListenerBuilder::validated_interface,command/src/config.rs:944) and at state dispatch (validated_listener_key,command/src/state.rs:144).InterfaceError::Unsupported("… SO_BINDTODEVICE, which only Linux provides") at config load and dispatch (validate_listener_interface,command/src/listener_key.rs:90);bind_to_devicealso returnsBindToDeviceUnsupportedoff Linux.SO_BINDTODEVICEreturnsServerBindError::BindToDevice:could not bind the listener <addr> to the network interface '<iface>' (SO_BINDTODEVICE): <os error>. The interface must exist when the listener is activated, and on Linux kernels before 5.7 binding a socket to an interface requires the CAP_NET_RAW capability.os-build/systemd/sozu.serviceand[email protected]set noUser=,CapabilityBoundingSet=norAmbientCapabilities=, so Sōzu runs as root with its full capability set andSO_BINDTODEVICEworks on every kernel: no functional change. Both units gain a comment saying a drop-in that restricts capabilities on a kernel before 5.7 must keepCAP_NET_RAW;doc/configure.mdsays the same.Tests (each seen red, then green)
state::tests::listeners_on_one_address_with_different_interfaces_coexist(command/src/state.rs:6978)an HTTP listener on another interface must not collide: StateError(HttpListener with id_bytes=12 already exists; …)state::tests::listener_diff_distinguishes_interfaces(:7123)left: [None] right: [Some("eth0")]state::tests::update_listener_is_refused_when_the_address_is_ambiguous(:7162)no entry found for keyconfig::tests::listener_interface_round_trips_from_the_config_file(command/src/config.rs:5359),invalid_listener_interface_rejected_at_config_load(:5470)unknown field \interface`, expected one of `address`, …`socket::tests::bind_sets_so_bindtodevice_to_the_listener_interface(lib/src/socket.rs:2172): binds TCP and UDP tolo, reads backSocket::device(); skips with a printed reason only onEPERM(it did not skip here)the TCP listener must be bound to lo — left: Nonesocket::tests::bind_to_a_missing_interface_names_the_interface_and_the_capability(:2222)binding to a missing interface must fail: ()listener_key::tests::listener_interface_is_refused_without_bind_to_device(platform check mutated out) + cfg-gatedlistener_interface_is_refused_off_linux(compiles only off Linux, not run here)called Result::unwrap_err() on an Ok value: ()state_compat_v1_1_1::legacy_config_state_json_without_interface_deserializes(bare-address key parsing mutated out),legacy_listener_records_without_interface_load_as_bare_address_listenersa pre-#719 ConfigState must deserialize: Error("invalid listener address '127.0.0.1:8080'")tcp::sni_routing_tests::listeners_sharing_an_address_on_different_interfaces_coexist(lib/src/tcp.rs:4417): two listeners,lo+ none, in one worker; key lookups, frontend fan-out,SO_BINDTODEVICEon the handed-back sockets (fan-out mutated to first listener only)the frontend must reach the listener at Token(1) — left: None right: Some("cluster-a")scm_socket::tests::send_and_receive_listeners_keyed_by_interface(command/src/scm_socket.rs:755)test_upgrade_interface_bound_listener(e2e/src/tests/tests.rs:1374):lo-bound HTTP listener serves, worker upgrade, 8 fresh connections served (manifest mutated to drop the interface)connection 3 after the upgrade was not servedrollback_inverse_of_a_listener_add_carries_its_interface(bin/src/command/requests.rs:5288) — found in review: the rollback dropped the interfaceleft: None right: Some("wg0")cli::tests::listener_commands_parse_the_interface_flag(bin/src/cli.rs:1985)http::listener_sibling_tests::a_listener_added_next_to_a_sibling_takes_over_its_frontends(review finding 1)the listener added after the frontend must route it toohttp::listener_sibling_tests::removing_a_frontend_reaches_every_listener_and_reports_a_failure(review finding 1, removal)the failure on one listener must not spare its sibling's route(HashMap order, not every run)https::listener_sibling_tests::a_listener_added_next_to_a_sibling_takes_over_its_certificates_and_frontendsthe listener added after the certificate must serve it tootcp::sni_routing_tests::a_listener_added_next_to_a_sibling_takes_over_its_routes(no-SNI cluster and SNI routes)the listener added after the frontend must route to its cluster — left: Noneudp::listener_sibling_tests::a_listener_added_next_to_a_sibling_takes_over_its_clusterleft: None right: Some("cluster-a")test_listener_added_on_an_interface_serves_existing_frontends: bare0.0.0.0:Proutes a frontend, then alo-bound0.0.0.0:Pis added + activated at runtime (what CLI add and reload send); 4 requests through127.0.0.1(route takeover mutated out)request 0 through lo was not routed: Some("HTTP/1.1 404 Not Found …"), the reviewer's outagetcp::sni_routing_tests::traffic_through_an_interface_reaches_the_listener_bound_to_it(review finding 3): bare andlo-bound0.0.0.0:P, 8 connections through127.0.0.1, all accepted by thelolistener's token, none by the bare one (SO_BINDTODEVICEmutated out)the lo listener must accept every connection, got 4 of 8: WouldBlock(3/3 runs red)state::tests::reload_adding_an_interface_listener_sends_only_that_listenerValidation (head after the review fixes)
Verified: cargo build --all-features -> exit 0Verified: cargo clippy --all-features --all-targets -- -D warnings -> exit 0Verified: cargo +nightly fmt --all -- --check -> exit 0Verified: cargo test -p sozu-lib -> 1367 passed, 0 failed(all test binaries)Verified: cargo test -p sozu -> 242 passed, 0 failed(both test binaries)Verified: cargo test -p sozu-command-lib -> 210 passed, 0 failedVerified: cargo test -p sozu-e2e -- listener upgrade tcp_tests udp_tests tls_tests https hsts_tests command_channel_security -> 78 passed, 0 failed(the full e2e suite, 495 passed, ran on the previous head)Verified: python3 .github/scripts/check_doc_citations.py --self-test | --root . | --base origin/main | --audit --root . -> exit 0 eachFile:line references above point at the initial head; the symbols named next to them are the stable reference.
Residual risks
AddCluster.answers) are applied to the listeners that exist when the cluster is added; this PR does not change that pre-existing behaviour for later listeners.TcpProxy::fronts(cluster → listener token) records the last listener on the address only. It is write-only bookkeeping today (no reader in the proxy), so nothing changes; a future reader would need a set of tokens.interfaceis unsupported (documented): an older Sōzu fails to parse that listener's key in the state / SCM manifest; listeners without interface are unaffected.cfg(not(target_os = "linux"))test and the non-Linux branch ofbind_to_devicewere not compiled here (no non-Linux target installed).Closes #719