Skip to content

Commit

Permalink
Fix test_vsock failure on VMADDR_CID_LOCAL testing
Browse files Browse the repository at this point in the history
Starting from Linux 5.6, VMADDR_CID_LOCAL is supported to do local
communication (loopback device).

Before Linux 5.6 it was called VMADDR_CID_RESERVED and was not
supported, so we could expect an EADDRNOTAVAIL, but now this address
is supported and handled by the 'vsock_loopback' kernel module loaded
automatically if no other vsock transports are loaded.

Issue #1310
Issue #1403

Signed-off-by: Stefano Garzarella <[email protected]>
  • Loading branch information
stefano-garzarella authored and asomers committed Aug 14, 2021
1 parent feb8fe6 commit e266b7c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,17 +1507,11 @@ pub fn test_vsock() {
SockFlag::empty(), None)
.expect("socket failed");

// VMADDR_CID_HYPERVISOR and VMADDR_CID_LOCAL are reserved, so we expect
// an EADDRNOTAVAIL error.
// VMADDR_CID_HYPERVISOR is reserved, so we expect an EADDRNOTAVAIL error.
let sockaddr = SockAddr::new_vsock(libc::VMADDR_CID_HYPERVISOR, port);
assert_eq!(bind(s1, &sockaddr).err(),
Some(Error::Sys(Errno::EADDRNOTAVAIL)));

let sockaddr = SockAddr::new_vsock(libc::VMADDR_CID_LOCAL, port);
assert_eq!(bind(s1, &sockaddr).err(),
Some(Error::Sys(Errno::EADDRNOTAVAIL)));


let sockaddr = SockAddr::new_vsock(libc::VMADDR_CID_ANY, port);
assert_eq!(bind(s1, &sockaddr), Ok(()));
listen(s1, 10).expect("listen failed");
Expand Down

0 comments on commit e266b7c

Please sign in to comment.