Skip to content

Server sessions: keep our side open after the peer's EOF; larger windows with alloc - #77

Open
neit-16 wants to merge 2 commits into
mkj:mainfrom
neit-16:eof-exit-window
Open

neit-16 wants to merge 2 commits into
mkj:mainfrom
neit-16:eof-exit-window

Conversation

@neit-16

@neit-16 neit-16 commented Nov 20, 2026 •

Copy link
Copy Markdown

Two small changes found while running a sunset server (seOS, an OS on seL4) against OpenSSH 9.9. Each is its own commit.

  1. Don't answer a channel EOF with our own EOF. RFC 4254 5.3: EOF ends only the sender's direction. handle_eof() replied with an EOF straight away, ending our direction too. With ssh host cmd < /dev/null, OpenSSH sends EOF right after the exec request, sunset replied with EOF, and OpenSSH dropped the command's output that followed: in ssh -vvv, "rcvd eof" comes right after "exec request accepted". Our side now stays open until the application closes the channel; close_channel() already sends EOF then.

  2. Larger channel window and packets with alloc. The 1000-byte window made the client wait for a window adjustment after every packet. With alloc, packet buffers hold SSH_MAX_PACKET, so this uses 32 KiB packets and a 256 KiB window. scp to the server went from 15 MB/s to 24 MB/s. Without alloc the sizes are unchanged. If you would rather make these configurable, I can rework it.

The exit status change this PR first had is dropped: it is in #75.

Tests: cargo test --lib, cargo test --lib --all-features, cargo test --features std,tokio in async/, cargo clippy --all-targets clean, cargo fmt applied.

RFC 4254 5.3: EOF only ends the sender's direction. Replying to the
peer's EOF with an EOF straight away ended our direction too, so a
server could no longer send output after the client's stdin ended.

Seen with OpenSSH: `ssh host cmd < /dev/null` sends EOF right after
the exec request, sunset replied with EOF, and the client dropped the
command's output that followed ("rcvd eof" in ssh -vvv right after
"exec request accepted").
@korbin

korbin commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

I added point 2 in - #75 (isolated)

The 1000-byte window and packet sizes made a client wait for a window
adjustment after every packet. With `alloc` the packet buffers hold
SSH_MAX_PACKET (35000), so use 32 KiB packets and a 256 KiB window.

Measured on a sunset-based server (seOS, an seL4 OS) receiving with
OpenSSH scp 9.9: 15 MB/s before, 24 MB/s after. Without `alloc` the
sizes are unchanged.
@neit-16 neit-16 changed the title Server sessions: keep our side open after the peer's EOF, send exit status, larger windows with alloc Server sessions: keep our side open after the peer's EOF; larger windows with alloc Nov 20, 2026
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.

2 participants