Skip to content

docs(command): name max_command_buffer_size as the channel wire-length bound - #1435

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
docs/command-buffer-size-bound
Sep 22, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
docs/command-buffer-size-bound

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

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 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: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
FlorentinDUBOIS force-pushed the docs/command-buffer-size-bound branch 2 times, most recently from caf3edb to 4a75efd Compare September 22, 2026 11:21
…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
FlorentinDUBOIS force-pushed the docs/command-buffer-size-bound branch from 4a75efd to 0f95fd4 Compare September 22, 2026 11:23
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 5f49716 into main Sep 22, 2026
7 of 18 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.

docs: configure_admin_ops §5.2 says the command-channel wire-length bound is command_buffer_size, but the code checks max_command_buffer_size

1 participant