Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes to fwTPM MSSIM reply handling.
No open issues 🎉
What changed in this PR
This PR addresses #663 by removing the server-side socket behavior responsible for delayed fwTPM MSSIM replies, without changing the wire format.
Changes:
- Uses
writev()to send reply framing and payload together, retaining sequential sends for custom HALs and unsupported or disabled configurations. - Enables
TCP_NODELAYon accepted command and platform sockets. - Adds a reply-framing test shared by vectored and sequential builds.
| File | Description |
|---|---|
tests/fwtpm_unit_tests.c |
Adds assertions for reply length, payload, and zero acknowledgement. |
tests/fwtpm_io_test_adapter.c |
Exposes the reply helper to unit tests. |
src/fwtpm/fwtpm_io.c |
Adds vectored replies with partial-write handling and disables Nagle on accepted sockets. |
Review effort: Balanced
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.
Description
Every fwTPM command over the mssim socket transport paid a fixed delay.
DispatchAndRespond()sent a reply as three writes - size, response, acknowledgement - and that last four-byte write goes out while the response is still unacknowledged, so Nagle holds it until the peer's delayed-ACK timer expires. The time is spent waiting on a kernel timer, which is why a measurement taken aroundFWTPM_ProcessCommand()looked normal while the client round trip did not.The SWTPM client sets
TCP_NODELAYon the socket it connects, but that governs the client's own sends. The server never set it on the sockets it accepts.SendMssimReply()sends size, response and acknowledgement as one segment withwritev(). A custom I/O HAL has no vectored form and keeps the three sequential sends;FWTPM_NO_WRITEVselects that path, as do Windows and Zephyr.SetSocketNoDelay()disables Nagle on both accepted sockets, command and platform. The platform port frames its replies the same way.Either change removes the delay on its own. Both are kept because the fallback path still writes three times, and both are
advisory in the sense
SO_REUSEADDRhere already is: a failure costs latency, not correctness.Fixes #663. Thank you @jerohavaz
Testing
test_fwtpm_mssim_reply_framingdrivesSendMssimReply()over a socketpair and asserts the wire stream is exactly size, response, zero ack; aFWTPM_NO_WRITEVbuild covers the sequential path through the same test.make checkgreen against the fwTPM simulator,unit.testandrun_examples.shgreen against ibmswtpm2, and built over eleven configurations.