Repository navigation
Conversation
Track per-connection stream buffer credit (`tx_cnt`, `fwd_cnt`, `last_fwd_cnt`, `peer_buf_alloc`, and `peer_fwd_cnt`) per Virtio v1.4 Sec 5.10.6.3: - Update peer credit from incoming `REQUEST`, `RESPONSE`, `RW`, `CREDIT_UPDATE`, `CREDIT_REQUEST`, and `SHUTDOWN` headers. - Cap `RW` payload reads on the RX virtqueue to `peer_free` and resume stalled host-to-guest transfers when incoming packets replenish peer credit on edge-triggered UDS sockets, while still observing socket EOF when `peer_free` is zero. - Answer `CREDIT_REQUEST` with `CREDIT_UPDATE` (or `RST` for unknown connections), deferring `CREDIT_UPDATE` if the RX queue has no available descriptors. - Emit unsolicited `CREDIT_UPDATE` packets once unacknowledged guest TX bytes reach half of `buf_alloc` so unidirectional guest-to-host streams do not stall. Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Coverage Report for CI Build 42955384191Coverage increased (+0.5%) to 44.151%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
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.
Summary
Implement Virtio v1.4 Sec 5.10.6.3 (Buffer Space Management) stream flow-control credit accounting in
UdsVsock:tx_cnt,peer_buf_alloc,peer_fwd_cnt):peer_buf_allocandpeer_fwd_cntfrom incomingREQUEST,RESPONSE,RW,CREDIT_UPDATE,CREDIT_REQUEST, andSHUTDOWNheaders.peer_free = peer_buf_alloc.saturating_sub((tx_cnt - peer_fwd_cnt).0), cap RX virtqueueRWpayload reads topeer_free, and advancetx_cntby each transmitted payload length.process_rx_datawhenever incoming packets update peer credit so host-to-guest transfers stalled atpeer_free == 0immediately resume on edge-triggeredmiosockets, while still observing host socket EOF whenpeer_free == 0.CREDIT_REQUESThandling:VsockOp::CREDIT_REQUESTwithVsockOp::CREDIT_UPDATEcarrying currentfwd_cntandbuf_alloc(deferring until an RX descriptor is available if the RX virtqueue is temporarily empty, and replying withRSTfor unknown connections).CREDIT_UPDATEon unidirectional guest TX:last_fwd_cntacross outgoing packets and emit an unsolicitedVsockOp::CREDIT_UPDATEonce unacknowledged guest TX bytes reach half ofbuf_alloc, preventing unidirectional guest-to-host streams from stalling.Testing
cargo +nightly fmt --checkcargo test -p alioth virtio::dev::vsock(13 unit tests inuds_vsock_test.rs, including new tests forCREDIT_REQUEST, RXpeer_freeflow control & resumption, unidirectional TX >buf_alloc/ 96 KiB credit replenishment, andu32counter wrap-around)cargo clippy --all-targets -- -D warningscargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warnings