Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsock: Dup() socket in newVirtioSocketConnection() #53

Closed
wants to merge 2 commits into from

Conversation

cfergeau
Copy link
Contributor

The underlying socket for VirtioSocketConnection() is currently Dup()
when NewVirtioSocketListener() is used, but not when ConnectToPort() is used.
This prevents usage of ConnecToPort() from working properly, the connection is
closed too early.

This commit moves the Dup() to newVirtioSocketConnection() so that both
codepaths benefit from it.

This is already done in the SetSocketListenerForPort case, but it's also needed in the
ConnectToPort case.
Without this, the connection gets closed immediately when the host tries
to initiate a vsock connection to the guest (for example with `nc
--listen --vsock 2 1024` running on the guest).
This error is returned whne trying to connect:
```
2022/09/23 15:09:49 tcpproxy: for incoming conn , error dialing "vsock:1024": Error Domain=NSPOSIXErrorDomain Code=54 Description="The operation couldn’t be completed. Connection reset by peer" UserInfo={
}
```
The dup/dupCh types are now badly named as they no longer contain
VirtioSocketConnections to run through Dup().
VirtioSocketConnection.dup() is no longer needed.
@Code-Hex
Copy link
Owner

Code-Hex commented Sep 24, 2022

I'm not sure what is problem. I don't know how to reproduce the errors.
Please create an issue before creating PR. Thanks.

guideline: https://github.com/Code-Hex/vz/blob/master/CONTRIBUTING.md#did-you-write-a-patch-that-fixes-a-bug

@Code-Hex Code-Hex closed this Sep 24, 2022
Repository owner locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants