fix(udp): cap the payload at the server's advertised buffer - #142
Merged
Merged
Conversation
`SMPUDPTransport.max_unencoded_size` overrode the base implementation with the MSS alone, so the MCUmgr parameters that `SMPClient` reads on connect never reached the UDP transport: `initialize(buf_size)` stored the value and nothing read it. Zephyr's UDP SMP transport receives each request as a single datagram into one MCUmgr buffer of `CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE` bytes, the value advertised as `buf_size`. A request larger than that cannot be received. The defaults (2048-byte buffer, 1500-byte MTU) hide this. A build that lowers the buffer, e.g. to its 384-byte non-UDP default, does not. The payload is now `min(MSS, buf_size)`. Before the params are known, `buf_size or mtu` makes that the MSS, so nothing changes for a server that does not advertise them. Verified: `camas check` green; the new parametrized test fails on the 384-byte case without the fix. https://github.com/zephyrproject-rtos/zephyr/blob/70be2ff0b565a3313128f5577f51cfeb3ebcf602/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c#L551-L554 https://github.com/zephyrproject-rtos/zephyr/blob/70be2ff0b565a3313128f5577f51cfeb3ebcf602/subsys/mgmt/mcumgr/transport/Kconfig#L33-L58 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
JPHutchins
added a commit
that referenced
this pull request
Sep 23, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Warning
LLM Disclosure
This PR was authored by
claude-opus-5-5[1m]on behalf of @JPHutchins. A survey of Zephyr's SMP server transports for the #58 design found that smpclient's UDP transport ignores the server's advertised buffer, and @JPHutchins asked for a small fix tomain.SMPUDPTransportsized every message by the MSS alone, so the MCUmgr params thatSMPClientreads on connect never reached it. Zephyr receives each UDP request into a single buffer of the advertisedbuf_size, so a request larger than that can't be received.Non-breaking. Before params are known, or when a server doesn't advertise them, the result is still the MSS. Zephyr's defaults (2048-byte buffer, 1500-byte MTU) behave exactly as before; only builds with a smaller buffer change.
Sources and verification
buf_sizeisCONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE(os_mgmt.c). It defaults to 2048 with UDP and 384 without (Kconfig).camas checkgreen (ruff, pydoclint, mypy, pyright, tests).test_max_unencoded_size_capped_by_server_buffercoversbuf_sizebelow, equal to, and above the MSS. Without the fix, it fails on the 384-byte case.screaming-goblin) replaces this with UDP's ownAuto()sizing arm, which uses the same arithmetic.🤖 Generated with Claude Code