On 21.11.2022 19:50, Arseniy Krasnov wrote:
On 21.11.2022 17:52, Stefano Garzarella wrote:Hm, seems current implementation is a little bit broken and returns ENOMEM, because any negative value, returned by
On Tue, Nov 15, 2022 at 08:52:35PM +0000, Arseniy Krasnov wrote:
This adds test for sending message, bigger than peer's buffer size.
For SOCK_SEQPACKET socket it must fail, as this type of socket has
message size limit.
Signed-off-by: Arseniy Krasnov <AVKrasnov@xxxxxxxxxxxxxx>
---
tools/testing/vsock/vsock_test.c | 62 ++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index 107c11165887..bb4e8657f1d6 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -560,6 +560,63 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts)
close(fd);
}
+static void test_seqpacket_bigmsg_client(const struct test_opts *opts)
+{
+ unsigned long sock_buf_size;
+ ssize_t send_size;
+ socklen_t len;
+ void *data;
+ int fd;
+
+ len = sizeof(sock_buf_size);
+
+ fd = vsock_seqpacket_connect(opts->peer_cid, 1234);
Not for this patch, but someday we should add a macro for this port and maybe even make it configurable :-)
+ if (fd < 0) {
+ perror("connect");
+ exit(EXIT_FAILURE);
+ }
+
+ if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE,
+ &sock_buf_size, &len)) {
+ perror("getsockopt");
+ exit(EXIT_FAILURE);
+ }
+
+ sock_buf_size++;
+
+ data = malloc(sock_buf_size);
+ if (!data) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+
+ send_size = send(fd, data, sock_buf_size, 0);
+ if (send_size != -1) {
Can we check also `errno`?
IIUC it should contains EMSGSIZE.
transport callback is always replaced to ENOMEM. I think i need this patch from Bobby:
https://lore.kernel.org/lkml/d81818b868216c774613dd03641fcfe63cc55a45.1660362668.git.bobby.eshleman@xxxxxxxxxxxxx/
May be i can include it to this patchset also fixing review comments(of course keeping Bobby as author). Or more
simple way is to check ENOMEM instead of EMSGSIZE in this test(simple, but a little bit dumb i think).