Skip to content

[net] Change meaning of SO_RCVBUF to set connect/accept buffer size - #2814

Merged
ghaerr merged 1 commit into
masterfrom
netfix4
Aug 12, 2026
Merged

[net] Change meaning of SO_RCVBUF to set connect/accept buffer size#2814
ghaerr merged 1 commit into
masterfrom
netfix4

Conversation

@ghaerr

@ghaerr ghaerr commented Aug 12, 2026

Copy link
Copy Markdown
Owner

This enhancement allows tuning ELKS network applications to use less memory than was otherwise possible from ktcp's heap, while still maximizing efficiency. Programs now have total control over their TCP/IP receive buffer sizes during both passive listen, active connect, and accept sockets.

Previously, SO_RCVBUF set the buffer size for connect and listen sockets. Most ELKS network applications used this to set a small receive buffer for listen using SO_LISTEN_BUFSIZE, which was 128. The buffer size for new sockets from accept always defaulted to CB_NORMAL_BUFSIZ (=4380 = 3*(MTU-40)).

Now, SO_RCVBUF additionally sets the receive buffer size for accepted sockets, allowing applications to set a smaller (or larger) buffer size for efficiency as well as better use of ktcp's heap.

Adds non-standard setsockopt option SO_NOBUFFER which replaces previous SO_RCVBUF to eliminate any listen socket buffer completely.

ftpd has been experimentally enhanced to use a 2920 byte buffer (=2*(MTU-40)). Testing with QEMU showed a small decrease in throughput but using 1/3 less heap per connection in ktcp. This may also want to be performed for the other network applications, to enable more connections in ELKS without running out of ktcp heap.

All network applications in elkscmd/inet have been updated. External applications which used SO_LISTEN_BUFSIZ to eliminate a listen socket buffer will have to be recompiled, or their receive buffer size will be set to a very small 128.

Partly based off ideas from code in #2801 which didn't work properly for listen sockets.

Adds SO_NOBUFFER which replaces previous SO_RCVBUF to eliminate listen socket buffer
@ghaerr
ghaerr merged commit 2cf49fa into master Aug 12, 2026
1 check passed
@ghaerr
ghaerr deleted the netfix4 branch August 12, 2026 03:54
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.

1 participant