Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Hi @jacobgorm , thanks for the contribution, please add the signed-off-by line in the commit message or just reply that in comments. |
The UDS vsock device advanced fwd_cnt by the full packet length as soon as it received guest->host data, and never sent a CREDIT_UPDATE back. So the guest filled its send window (the buf_alloc advertised in RESPONSE) and then stalled: whoever had opened the connection saw the first buf_alloc bytes and nothing more. That is the classic virtio-vsock credit deadlock. Buffer guest->host bytes in Connection::pending and only credit fwd_cnt for bytes the host socket actually accepted. The host side is a non-blocking UnixStream, so a full send buffer (a slow reader on the other end) is a normal, retryable event: - On WouldBlock, register WRITABLE interest and retry from the mio event loop once the socket drains (flush_conn_pending). - After each drain, send CREDIT_UPDATE with the current fwd_cnt so the guest reopens its window. A missing RX buffer only defers the update and never fails the data descriptor that triggered it. - On host hang-up, mark eof and let process_rx_data reset the connection, as before. Because fwd_cnt does not advance for bytes still queued in pending, the guest's window stays shut while the host is slow, so pending is bounded to about one window and cannot grow without limit. Update the connection test to offer an RX buffer for the credit update and assert on its op, ports, and fwd_cnt. docs(vsock): clarify flow-control lifecycles and test contract - flush_conn_pending: document that it is only reached from a WRITABLE event and depends on the READABLE|WRITABLE interest set earlier in transfer_tx_data; a WouldBlock here keeps that interest, and calling it from a path that had not registered WRITABLE would deadlock. - transfer_tx_data: note that the first flush happens inline so the common (accepting socket) path needs no event round-trip. - send_to_tx test helper: state its one-RX-irq-per-TX assumption, so a future change that emits two RX messages for one TX does not silently leak a stale irq into the next call. Signed-off-by: Jacob Gorm Hansen <jacobgorm@gmail.com>
Author
hi, I've amened the commit :) |
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.
This is an AI-generated change to a problem I noticed when running an rlogin-style connection over vsock. The same code works on crosvm, but on Alioth the pipe stalls in the VM-to-client direction after having transmitted 8192 bytes in total, until I hit a key on my keyboard to trigger sending a byte back from client-to-VM, which unblocks it. This in on MacOS.
I put an AI on the task of figuring out what was wrong, and it came up with the fix in this PR. I am not familiar with the alioth code, but the fix looks reasonable to me, and it does solve my problem. I am using custom tools to trigger this, but IIRC socat should be able to reproduce it too.
Here is the AI's description of the problem and fix:
The UDS vsock device advanced fwd_cnt by the full packet length as soon as it received guest->host data, and never sent a CREDIT_UPDATE back. So the guest filled its send window (the buf_alloc advertised in RESPONSE) and then stalled: whoever had opened the connection saw the first buf_alloc bytes and nothing more. That is the classic virtio-vsock credit deadlock.
Buffer guest->host bytes in Connection::pending and only credit fwd_cnt for bytes the host socket actually accepted. The host side is a non-blocking UnixStream, so a full send buffer (a slow reader on the other end) is a normal, retryable event:
Because fwd_cnt does not advance for bytes still queued in pending, the guest's window stays shut while the host is slow, so pending is bounded to about one window and cannot grow without limit.
Update the connection test to offer an RX buffer for the credit update and assert on its op, ports, and fwd_cnt.
docs(vsock): clarify flow-control lifecycles and test contract