Repository navigation
docs(command): name max_command_buffer_size as the channel wire-length bound - #1435
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 22, 2026 08:52
FlorentinDUBOIS
force-pushed
the
docs/command-buffer-size-bound
branch
2 times, most recently
from
September 22, 2026 11:21
caf3edb to
4a75efd
Compare
…h bound `doc/configure_admin_ops.md` §5.2 told an operator the command channel rejects a peer-declared `message_len` exceeding `command_buffer_size`, "default `16384`". Both halves were wrong. `Channel::try_read_delimited_message` (`command/src/channel.rs`) compares `message_len` against the channel's `max_buffer_size` field, and `Channel::write_delimited_message` bounds an outgoing frame against the same field. Every production construction site — `bin/src/command/server.rs`, `bin/src/worker.rs`, `bin/src/ctl/mod.rs`, `bin/src/upgrade.rs` — fills that field from `max_command_buffer_size`, never from `command_buffer_size`. No other construction site is evidence about the shipped bound: the unit tests in `command/src/channel.rs`, `lib/src/http.rs`, `lib/src/server.rs` and `lib/src/tcp.rs`, and all three example programs under `lib/examples/` (`http.rs`, `https.rs`, `tcp.rs`), pass literal sizes; the end-to-end harness (`Worker::create_server` and `Worker::spawn_worker` in `e2e/src/sozu/worker.rs`) does build its channels from `command_buffer_size` and `max_command_buffer_size`, but from a configuration the test run assembles rather than a deployed one. `grep -rn 'Channel::new\|Channel::generate' --include='*.rs' .` enumerates every site. And `16384` is not a default: it is what three of the four configuration files shipped here override to, `os-build/config.toml` using `163_840`. The built-in defaults are `DEFAULT_COMMAND_BUFFER_SIZE` = `1_000_000` and `DEFAULT_MAX_COMMAND_BUFFER_SIZE` = `2_000_000` (`command/src/config.rs`). Under the defaults the document understated the accepted bound by a factor of two, and an operator tightening the bound against a hostile peer was pointed at the knob that does not set it. §5.2 now names `max_command_buffer_size`, tabulates what each key controls with its real default, and states that lowering `command_buffer_size` tightens nothing. The `command_buffer_size` row is scoped rather than absolute: it sizes the supervisor↔worker and CLI channels, but `CommandHub::register_client` (`bin/src/command/server.rs`) allocates the command-socket client channel at a hardcoded `4096` and takes only its ceiling from configuration. Three more instances of the same class, found by sweeping both key names across the tree: - `bin/config.toml` and `os-build/config.toml` annotated `max_command_buffer_size` as "defaults to `command_buffer_size * 2`". The TOML path resolves an omitted value to the flat `DEFAULT_MAX_COMMAND_BUFFER_SIZE` = `2_000_000` in `ConfigBuilder::new` (`command/src/config.rs`), independently of `command_buffer_size`; `ConfigBuilder::into_config` populates listeners and clusters and validates the TCP SNI/ALPN invariants, and resolves no buffer default. The doubling lives only in `resolve_max_command_buffer_size` (`bin/src/main.rs`), serving the internal `worker` / `main` re-exec subcommands its own doc comment calls "never operator-facing". - `doc/protocol.md` gave the ceiling as "2 MiB" twice. `2_000_000` bytes is 2 MB, which is how `command/src/config.rs` and `bin/src/command/server.rs` already describe it. - §5.2, `doc/protocol.md`, `bin/config.toml` and `os-build/config.toml` all asserted that an over-cap frame ends the connection — §5.2 that the supervisor "logs and drops the offending peer's session". It does not. `try_read_delimited_message` returns `ChannelError::MessageTooLarge`, `extract_messages` (`bin/src/command/sessions.rs`) discards every read error without logging it, `ClientSession::ready` then returns `ClientResult::NothingToDo`, and `WorkerSession::ready` returns `CloseSession` only for `is_error()`/`is_hup()` readiness, which a parse error never sets. The four sites no longer state a behaviour the code does not have; naming what does happen is left to #1428, which tracks the defect. Deliberately deferred to #1428 rather than fixed here: the comment at `command/src/channel.rs:551` still says the rejection is raised "so the read loop disconnects cleanly", which is false for exactly the reason the four sites above were corrected. It is a code comment in a `docs(command)` changeset, and it names neither key, so the two-key sweep that found the other instances could not have reached it. #1428's body already quotes it. Recording it here rather than passing over it in silence, because leaving it beside corrected text would otherwise read as having been checked. §5.2 cites `try_read_delimited_message` by symbol rather than by line so the text survives #1422, whose `Channel::new` doc comment shifts the rest of `channel.rs` by 33 lines. That branch also adds `ConfigError::CommandBufferSizeExceedsMax` (`command/src/config.rs`), which rejects `command_buffer_size > max_command_buffer_size` at config load, and clamps `Channel::new`'s initial capacity to `max_buffer_size`; its pull request carries `Closes #1416`. So §5.2 states the `command_buffer_size` <= `max_command_buffer_size` requirement and the reason for it — the first is the capacity a channel buffer is configured to start at and shrink back to, the second the ceiling it may never grow past — and asserts neither the state an inverted pair would produce, nor any handling of one, nor that any issue is open. It reads identically before and after #1422 lands. `git merge-tree --write-tree HEAD refs/heads/fix/channel-buffer-size-validation` (#1422 head `0ac27fc1`) exits 1 with `CONFLICT (content): Merge conflict in CHANGELOG.md`, both branches inserting a `### 🐛 Fixed` heading at the same anchor. The four documentation and configuration files edited here are not reconciled at all: #1422 touches none of them, so there is no merge to be clean or unclean. `git diff origin/main refs/heads/fix/channel-buffer-size-validation --name-only` lists only `CHANGELOG.md`, `command/src/channel.rs`, `command/src/config.rs`, `doc/configure.md` and `doc/lifetime_of_a_session.md`. Closes #1421. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
docs/command-buffer-size-bound
branch
from
September 22, 2026 11:23
4a75efd to
0f95fd4
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.
doc/configure_admin_ops.md§5.2 told an operator the command channelrejects a peer-declared
message_lenexceedingcommand_buffer_size,"default
16384". Both halves were wrong.Channel::try_read_delimited_message(command/src/channel.rs) comparesmessage_lenagainst the channel'smax_buffer_sizefield, andChannel::write_delimited_messagebounds an outgoing frame against thesame field. Every production construction site —
bin/src/command/server.rs,bin/src/worker.rs,bin/src/ctl/mod.rs,bin/src/upgrade.rs— fills that field frommax_command_buffer_size,never from
command_buffer_size. No other construction site is evidenceabout the shipped bound: the unit tests in
command/src/channel.rs,lib/src/http.rs,lib/src/server.rsandlib/src/tcp.rs, and allthree example programs under
lib/examples/(http.rs,https.rs,tcp.rs), pass literal sizes; the end-to-end harness(
Worker::create_serverandWorker::spawn_workerine2e/src/sozu/worker.rs) does build its channels fromcommand_buffer_sizeandmax_command_buffer_size, but from aconfiguration the test run assembles rather than a deployed one.
grep -rn 'Channel::new\|Channel::generate' --include='*.rs' .enumerates every site. And
16384is not a default: it is what three ofthe four configuration files shipped here override to,
os-build/config.tomlusing163_840. The built-in defaults areDEFAULT_COMMAND_BUFFER_SIZE=1_000_000andDEFAULT_MAX_COMMAND_BUFFER_SIZE=2_000_000(command/src/config.rs).Under the defaults the document understated the accepted bound by a
factor of two, and an operator tightening the bound against a hostile
peer was pointed at the knob that does not set it. §5.2 now names
max_command_buffer_size, tabulates what each key controls with its realdefault, and states that lowering
command_buffer_sizetightens nothing.The
command_buffer_sizerow is scoped rather than absolute: it sizesthe supervisor↔worker and CLI channels, but
CommandHub::register_client(
bin/src/command/server.rs) allocates the command-socket client channelat a hardcoded
4096and takes only its ceiling from configuration.Three more instances of the same class, found by sweeping both key names
across the tree:
bin/config.tomlandos-build/config.tomlannotatedmax_command_buffer_sizeas "defaults tocommand_buffer_size * 2".The TOML path resolves an omitted value to the flat
DEFAULT_MAX_COMMAND_BUFFER_SIZE=2_000_000inConfigBuilder::new(
command/src/config.rs), independently ofcommand_buffer_size;ConfigBuilder::into_configpopulates listeners and clusters andvalidates the TCP SNI/ALPN invariants, and resolves no buffer default.
The doubling lives only in
resolve_max_command_buffer_size(
bin/src/main.rs), serving the internalworker/mainre-execsubcommands its own doc comment calls "never operator-facing".
doc/protocol.mdgave the ceiling as "2 MiB" twice.2_000_000bytesis 2 MB, which is how
command/src/config.rsandbin/src/command/server.rsalready describe it.doc/protocol.md,bin/config.tomlandos-build/config.tomlall asserted that an over-cap frame ends the connection — §5.2 that
the supervisor "logs and drops the offending peer's session". It does
not.
try_read_delimited_messagereturnsChannelError::MessageTooLarge,extract_messages(
bin/src/command/sessions.rs) discards every read error withoutlogging it,
ClientSession::readythen returnsClientResult::NothingToDo, andWorkerSession::readyreturnsCloseSessiononly foris_error()/is_hup()readiness, which aparse error never sets. The four sites no longer state a behaviour the
code does not have; naming what does happen is left to command: an oversized declared frame length is neither consumed nor signalled, so the command-channel session wedges permanently instead of being dropped #1428, which
tracks the defect.
Deliberately deferred to #1428 rather than fixed here: the comment at
command/src/channel.rs:551still says the rejection is raised "so theread loop disconnects cleanly", which is false for exactly the reason
the four sites above were corrected. It is a code comment in a
docs(command)changeset, and it names neither key, so the two-keysweep that found the other instances could not have reached it. #1428's
body already quotes it. Recording it here rather than passing over it in
silence, because leaving it beside corrected text would otherwise read
as having been checked.
§5.2 cites
try_read_delimited_messageby symbol rather than by line sothe text survives #1422, whose
Channel::newdoc commentshifts the rest of
channel.rsby 33 lines. That branch also addsConfigError::CommandBufferSizeExceedsMax(command/src/config.rs),which rejects
command_buffer_size > max_command_buffer_sizeat configload, and clamps
Channel::new's initial capacity tomax_buffer_size;its pull request carries
Closes #1416. So §5.2 states thecommand_buffer_size<=max_command_buffer_sizerequirement and thereason for it — the first is the capacity a channel buffer is configured
to start at and shrink back to, the second the ceiling it may never grow
past — and asserts neither the state an inverted pair would produce, nor
any handling of one, nor that any issue is open. It reads identically
before and after #1422 lands.
git merge-tree --write-tree HEAD refs/heads/fix/channel-buffer-size-validation(#1422 head
0ac27fc1) exits 1 withCONFLICT (content): Merge conflict in CHANGELOG.md, both branches inserting a### 🐛 Fixedheading at thesame anchor. The four documentation and configuration files edited here
are not reconciled at all: #1422 touches none of them, so there is no
merge to be clean or unclean.
git diff origin/main refs/heads/fix/channel-buffer-size-validation --name-onlylists onlyCHANGELOG.md,command/src/channel.rs,command/src/config.rs,doc/configure.mdanddoc/lifetime_of_a_session.md.Closes #1421.
Signed-off-by: Florentin Dubois [email protected]