summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux
diff options
context:
space:
mode:
authorGhanan Gowripalan <ghanan@google.com>2021-09-15 12:18:00 -0700
committergVisor bot <gvisor-bot@google.com>2021-09-15 12:20:51 -0700
commit149ca009678edc580de9f0b1d54f551d376742cb (patch)
tree648e02a87b55617196e68474aa4a07b49d586c0f /test/syscalls/linux
parent2d9883e4f1355677f986fc9a387fb70b6e438611 (diff)
[bind] Return EINVAL for under sized address
...and EAFNOSUPPORT for unexpected address family. To comply with Linux. Updates #6021, #6575. PiperOrigin-RevId: 396893590
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r--test/syscalls/linux/ping_socket.cc10
-rw-r--r--test/syscalls/linux/udp_socket.cc8
2 files changed, 4 insertions, 14 deletions
diff --git a/test/syscalls/linux/ping_socket.cc b/test/syscalls/linux/ping_socket.cc
index 7ec1938bf..684983a4c 100644
--- a/test/syscalls/linux/ping_socket.cc
+++ b/test/syscalls/linux/ping_socket.cc
@@ -155,43 +155,33 @@ std::vector<std::tuple<SocketKind, BindTestCase>> ICMPTestCases() {
.bind_to = V4AddrStr("IPv4UnknownUnicast", "192.168.1.1"),
.want = EADDRNOTAVAIL,
},
- // TODO(gvisor.dev/issue/6021): Remove want_gvisor from all the test
- // cases below once ICMP sockets return EAFNOSUPPORT when binding to
- // IPv6 addresses.
{
.bind_to = V6Any(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6Loopback(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6Multicast(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6MulticastInterfaceLocalAllNodes(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6MulticastLinkLocalAllNodes(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6MulticastLinkLocalAllRouters(),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
{
.bind_to = V6AddrStr("IPv6UnknownUnicast", "fc00::1"),
.want = EAFNOSUPPORT,
- .want_gvisor = EINVAL,
},
});
}
diff --git a/test/syscalls/linux/udp_socket.cc b/test/syscalls/linux/udp_socket.cc
index b9af5cbdd..0c0a16074 100644
--- a/test/syscalls/linux/udp_socket.cc
+++ b/test/syscalls/linux/udp_socket.cc
@@ -643,12 +643,12 @@ TEST_P(UdpSocketTest, DisconnectAfterBindToUnspecAndConnect) {
sockaddr_storage unspec = {.ss_family = AF_UNSPEC};
int bind_res = bind(sock_.get(), AsSockAddr(&unspec), sizeof(unspec));
- if (IsRunningOnGvisor() && !IsRunningWithHostinet()) {
- // TODO(https://gvisor.dev/issue/6575): Match Linux's behaviour.
- ASSERT_THAT(bind_res, SyscallFailsWithErrno(EINVAL));
- } else if (GetFamily() == AF_INET) {
+ if ((!IsRunningOnGvisor() || IsRunningWithHostinet()) &&
+ GetFamily() == AF_INET) {
// Linux allows this for undocumented compatibility reasons:
// https://github.com/torvalds/linux/commit/29c486df6a208432b370bd4be99ae1369ede28d8.
+ //
+ // TODO(https://gvisor.dev/issue/6575): Match Linux's behaviour.
ASSERT_THAT(bind_res, SyscallSucceeds());
} else {
ASSERT_THAT(bind_res, SyscallFailsWithErrno(EAFNOSUPPORT));