-
Notifications
You must be signed in to change notification settings - Fork 682
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
socket: add support for AF_VSOCK #1091
Conversation
3a23e41
to
ed495c0
Compare
I added an entry in the CHANGELOG, more description in the commit message and forced push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch looks good so far. But could you please add some tests for the functionality?
Sure, I'll add some tests for VSOCK. |
@asomers I add a test. Unfortunately, the current VSOCK implementation in Linux doesn't support loopback devices, so, for now, I add a simple test that tries to bind forbidden address and tries to connect, receiving an error. For the 'AddressFamily' I think it is enough, what do you think? |
All the test needs to do is ensure that Nix is binding correctly; we don't need a full regression test for vsock. So if |
@asomers Okay, so what I tried in the second patch that I pushed on this PR is exactly what you said, because a bind on reserved address should return EADDRNOTAVAIL. |
src/sys/socket/addr.rs
Outdated
#[derive(Copy, Clone)] | ||
pub struct VsockAddr(pub sockaddr_vm); | ||
|
||
// , PartialEq, Eq, Debug, Hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does this comment mean, and why the leading comma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry about that! I think was a line copied by struct AlgAddr that I used as a template for VsockAddr. I'll remove this line.
deb9d66
to
e9b20ad
Compare
@asomers I removed the useless comment line that you pointed out and added few comments on VsockAddr to explain cid and port fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think this PR is finally ready!
bors r+
Merge conflict |
Please rebase to fix the merge conflict. |
This patch adds AF_VSOCK support to AddressFamily in order to use VSOCK socket. Signed-off-by: Stefano Garzarella <[email protected]>
The current VSOCK implementation does not support loopback devices, so, for now, we expect a failure in the spawned thread when it tries to connect. Signed-off-by: Stefano Garzarella <[email protected]>
e9b20ad
to
db72b7e
Compare
@asomers done! Thanks, |
bors r+ |
1091: socket: add support for AF_VSOCK r=asomers a=stefano-garzarella This patch adds the support of AF_VSOCK in the socket module. VSOCK is present since Linux 3.9. Co-authored-by: Stefano Garzarella <[email protected]>
Build succeeded
|
This patch adds the support of AF_VSOCK in the socket module.
VSOCK is present since Linux 3.9.