summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/sentry/socket/unix/transport/connectioned.go4
-rw-r--r--test/syscalls/linux/socket_unix_seqpacket.cc15
2 files changed, 17 insertions, 2 deletions
diff --git a/pkg/sentry/socket/unix/transport/connectioned.go b/pkg/sentry/socket/unix/transport/connectioned.go
index 809c95429..b1967fc36 100644
--- a/pkg/sentry/socket/unix/transport/connectioned.go
+++ b/pkg/sentry/socket/unix/transport/connectioned.go
@@ -364,7 +364,9 @@ func (e *connectionedEndpoint) Connect(ctx context.Context, server BoundEndpoint
e.connected = ce
// Make sure the newly created connected endpoint's write queue is updated
// to reflect this endpoint's send buffer size.
- e.connected.SetSendBufferSize(e.ops.GetSendBufferSize())
+ if bufSz := e.connected.SetSendBufferSize(e.ops.GetSendBufferSize()); bufSz != e.ops.GetSendBufferSize() {
+ e.ops.SetSendBufferSize(bufSz, false /* notify */)
+ }
}
return server.BidirectionalConnect(ctx, e, returnConnect)
diff --git a/test/syscalls/linux/socket_unix_seqpacket.cc b/test/syscalls/linux/socket_unix_seqpacket.cc
index eb373373d..d6e7031c0 100644
--- a/test/syscalls/linux/socket_unix_seqpacket.cc
+++ b/test/syscalls/linux/socket_unix_seqpacket.cc
@@ -91,7 +91,20 @@ TEST_P(SeqpacketUnixSocketPairTest, IncreasedSocketSendBufUnblocksWrites) {
setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)),
SyscallSucceeds());
- // The send should succeed again.
+ // Skip test if the setsockopt didn't increase the sendbuf. This happens for
+ // tests where the socket is a host fd where gVisor does not permit increasing
+ // send buffer size.
+ int new_buf_size = 0;
+ buf_size_len = sizeof(new_buf_size);
+ ASSERT_THAT(
+ getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &new_buf_size, &buf_size_len),
+ SyscallSucceeds());
+ if (IsRunningOnGvisor() && (new_buf_size <= buf_size)) {
+ GTEST_SKIP() << "Skipping test new send buffer size " << new_buf_size
+ << " is the same as the value before setsockopt, "
+ << " socket is probably a host backed socket." << std ::endl;
+ }
+ // send should succeed again.
ASSERT_THAT(RetryEINTR(send)(sock, buf.data(), buf.size(), 0),
SyscallSucceeds());
}