Message ID | f0510949-cc97-7a01-5fc8-f7e855b80515@sberdevices.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2935921wru; Tue, 15 Nov 2022 12:54:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4E0TJCNz05arDYrHR+XnZDYjrehhD4MNOhN0CQGyGkNOC4o3Y75tnk6V3A9aOSsukadMx5 X-Received: by 2002:a17:906:5154:b0:782:7790:f132 with SMTP id jr20-20020a170906515400b007827790f132mr15367639ejc.649.1668545676434; Tue, 15 Nov 2022 12:54:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668545676; cv=none; d=google.com; s=arc-20160816; b=zcXN/SACobBqLo97KeMCSMsfEEptA+C5Vpck4foW8DaZzvYwyVGEAiulTSFjOIWa2O eikrCzXMulrVM9tEC19ML/4jjj2kft6uU1zVgfQsrEZuUqAjMIxrIWnn8jUOxgU0DmS8 +OUrKyBp5ahwWBEdgZXsFrxwR8R/6CZFFSA5k3ySpEUEVgTEiT0ECNbb9tHGaV3+log+ 5LvdcH94oC9DjKX/D/3DBW0R2PR1PHhnfZUY3LE3VjyU0Pf5fGiqSdFbtD70hv21xNaR rKpkv0egoXmSzd48pjon7sVohhjUhDY36XC36ObrvoSFfAVxoovwZPXV6Eu9NogPiRiL tKRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=W5hJi2NJ0bqPTdJKhkYCcnAEG+dDCh2qMXVB0CfPfa0=; b=i2HLqVKT4IL5dSRh6g8KM3xv/WYj/AezVLxwe9erYY0ZI58DwiWqwXDtCqz2RCxv4H 7CsalAnkJdDpldIMaoddJgwdXGhYGvDCfQBtolWpw41+b64nQIevpgcdRnZWiHRCuyny qqf63sMXaNs5mNC7Z0zIlms7noGRQPUbSQPy2EYdf0Uo+5iqR/A4rssqMWm+ZwxygPrG SIX1zpByT4vHgOlsTI8wGor54n6CEKUNEvymn6qfYQA//uxYHX8BKuF/DBlOIa/E4q0N PBsQwbFffvYaJOu9J4M/U7BtPKGgQ9DbFjAvLxAsRlwkG/rTpX9bcD+zgaw+zfjbtIaV 5YhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=XdVrPJHE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz6-20020a170906bb0600b007a8c58b51a1si10990134ejb.179.2022.11.15.12.54.13; Tue, 15 Nov 2022 12:54:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=XdVrPJHE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbiKOUw4 (ORCPT <rfc822;maxim.cournoyer@gmail.com> + 99 others); Tue, 15 Nov 2022 15:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238582AbiKOUwj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 15:52:39 -0500 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 999B930F63; Tue, 15 Nov 2022 12:52:37 -0800 (PST) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 0A6025FD07; Tue, 15 Nov 2022 23:52:36 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1668545556; bh=W5hJi2NJ0bqPTdJKhkYCcnAEG+dDCh2qMXVB0CfPfa0=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=XdVrPJHE+SfWL3SsZ40hp0Q6mfZHyev3hv9+o0WeSrNQwj4IcLwmIa5Hgy5I9PUaw 08eVwTHKZmJePvcZwJkMdVDqPm1enMMs6enQLHsc2z52AOMNqkEIw0mTWtiTcZBZQ2 dfLEFebLshv1Pb38dTrWEJ962ZatT5h5/b4kMzYbjUqJG8FBGc8jZe66exIg+6JccE fkbn54a2hoez2h6QLwNDUB5/XeIpe49YqQFiHjBgcTVN1NcidzIi7PWc+QlJ4Bz7nm xw6K0M4hQWoOTz7akNjN2Akyk/YqERufTz/cHqSzKsJ2dAY0vyC1rlusOhrRpCPEJh AwNG0CtiP/Gbw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Tue, 15 Nov 2022 23:52:35 +0300 (MSK) From: Arseniy Krasnov <AVKrasnov@sberdevices.ru> To: Stefano Garzarella <sgarzare@redhat.com> CC: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "virtualization@lists.linux-foundation.org" <virtualization@lists.linux-foundation.org>, kernel <kernel@sberdevices.ru>, Bobby Eshleman <bobby.eshleman@gmail.com>, Krasnov Arseniy <oxffffaa@gmail.com> Subject: [RFC PATCH v1 2/3] test/vsock: add big message test Thread-Topic: [RFC PATCH v1 2/3] test/vsock: add big message test Thread-Index: AQHY+TQwn9KcvFr2LUmtZTFuocc05g== Date: Tue, 15 Nov 2022 20:52:35 +0000 Message-ID: <f0510949-cc97-7a01-5fc8-f7e855b80515@sberdevices.ru> In-Reply-To: <ba294dff-812a-bfc2-a43c-286f99aee0b8@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-Type: text/plain; charset="utf-8" Content-ID: <61AB262BC80AEC438B4F4C80B53C1C7A@sberdevices.ru> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/11/15 16:23:00 #20571948 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749596951446738593?= X-GMAIL-MSGID: =?utf-8?q?1749596951446738593?= |
Series |
test/vsock: update two tests and add new tool
|
|
Commit Message
Arseniy Krasnov
Nov. 15, 2022, 8:52 p.m. UTC
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@sberdevices.ru>
---
tools/testing/vsock/vsock_test.c | 62 ++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
--
2.25.1
Comments
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@sberdevices.ru> >--- > 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. >+ fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >+ send_size); >+ } >+ >+ control_writeln("CLISENT"); >+ >+ free(data); >+ close(fd); >+} >+ >+static void test_seqpacket_bigmsg_server(const struct test_opts *opts) >+{ >+ int fd; >+ >+ fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); >+ if (fd < 0) { >+ perror("accept"); >+ exit(EXIT_FAILURE); >+ } >+ >+ control_expectln("CLISENT"); >+ >+ close(fd); >+} >+ > #define BUF_PATTERN_1 'a' > #define BUF_PATTERN_2 'b' > >@@ -832,6 +889,11 @@ static struct test_case test_cases[] = { > .run_client = test_seqpacket_timeout_client, > .run_server = test_seqpacket_timeout_server, > }, >+ { >+ .name = "SOCK_SEQPACKET big message", >+ .run_client = test_seqpacket_bigmsg_client, >+ .run_server = test_seqpacket_bigmsg_server, >+ }, I would add new tests always at the end, so if some CI uses --skip, we don't have to update the scripts to skip some tests. > { > .name = "SOCK_SEQPACKET invalid receive buffer", > .run_client = test_seqpacket_invalid_rec_buffer_client, >-- >2.25.1
On 21.11.2022 17:52, Stefano Garzarella wrote: > 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@sberdevices.ru> >> --- >> 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. > >> + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >> + send_size); >> + } >> + >> + control_writeln("CLISENT"); >> + >> + free(data); >> + close(fd); >> +} >> + >> +static void test_seqpacket_bigmsg_server(const struct test_opts *opts) >> +{ >> + int fd; >> + >> + fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); >> + if (fd < 0) { >> + perror("accept"); >> + exit(EXIT_FAILURE); >> + } >> + >> + control_expectln("CLISENT"); >> + >> + close(fd); >> +} >> + >> #define BUF_PATTERN_1 'a' >> #define BUF_PATTERN_2 'b' >> >> @@ -832,6 +889,11 @@ static struct test_case test_cases[] = { >> .run_client = test_seqpacket_timeout_client, >> .run_server = test_seqpacket_timeout_server, >> }, >> + { >> + .name = "SOCK_SEQPACKET big message", >> + .run_client = test_seqpacket_bigmsg_client, >> + .run_server = test_seqpacket_bigmsg_server, >> + }, > > I would add new tests always at the end, so if some CI uses --skip, we don't have to update the scripts to skip some tests. Ack this and all above > >> { >> .name = "SOCK_SEQPACKET invalid receive buffer", >> .run_client = test_seqpacket_invalid_rec_buffer_client, >> -- >> 2.25.1 >
On 21.11.2022 19:50, Arseniy Krasnov wrote: > On 21.11.2022 17:52, Stefano Garzarella wrote: >> 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@sberdevices.ru> >>> --- >>> 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. Hm, seems current implementation is a little bit broken and returns ENOMEM, because any negative value, returned by 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@bytedance.com/ 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). >> >>> + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >>> + send_size); >>> + } >>> + >>> + control_writeln("CLISENT"); >>> + >>> + free(data); >>> + close(fd); >>> +} >>> + >>> +static void test_seqpacket_bigmsg_server(const struct test_opts *opts) >>> +{ >>> + int fd; >>> + >>> + fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); >>> + if (fd < 0) { >>> + perror("accept"); >>> + exit(EXIT_FAILURE); >>> + } >>> + >>> + control_expectln("CLISENT"); >>> + >>> + close(fd); >>> +} >>> + >>> #define BUF_PATTERN_1 'a' >>> #define BUF_PATTERN_2 'b' >>> >>> @@ -832,6 +889,11 @@ static struct test_case test_cases[] = { >>> .run_client = test_seqpacket_timeout_client, >>> .run_server = test_seqpacket_timeout_server, >>> }, >>> + { >>> + .name = "SOCK_SEQPACKET big message", >>> + .run_client = test_seqpacket_bigmsg_client, >>> + .run_server = test_seqpacket_bigmsg_server, >>> + }, >> >> I would add new tests always at the end, so if some CI uses --skip, we don't have to update the scripts to skip some tests. > Ack this and all above >> >>> { >>> .name = "SOCK_SEQPACKET invalid receive buffer", >>> .run_client = test_seqpacket_invalid_rec_buffer_client, >>> -- >>> 2.25.1 >> >
On Mon, Nov 21, 2022 at 09:40:39PM +0000, Arseniy Krasnov wrote: >On 21.11.2022 19:50, Arseniy Krasnov wrote: >> On 21.11.2022 17:52, Stefano Garzarella wrote: >>> 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@sberdevices.ru> >>>> --- >>>> 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. >Hm, seems current implementation is a little bit broken and returns ENOMEM, because any negative value, returned by >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@bytedance.com/ >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). Maybe in this patch you can start checking ENOMEM (with a TODO comment), and then Bobby can change it when sending his patch. Or you can repost it (I'm not sure if we should keep the legacy behavior for other transports or it was an error, but better to discuss it on that patch). However, I think we should merge that patch. @Bobby, what do you think? Thanks, Stefano
On 23.11.2022 18:40, Bobby Eshleman wrote: > On Wed, Nov 23, 2022 at 7:22 AM Stefano Garzarella <sgarzare@redhat.com> > wrote: > >> On Mon, Nov 21, 2022 at 09:40:39PM +0000, Arseniy Krasnov wrote: >>> On 21.11.2022 19:50, Arseniy Krasnov wrote: >>>> On 21.11.2022 17:52, Stefano Garzarella wrote: >>>>> 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@sberdevices.ru> >>>>>> --- >>>>>> 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. >>> Hm, seems current implementation is a little bit broken and returns >> ENOMEM, because any negative value, returned by >>> 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@bytedance.com/ >>> 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). >> >> Maybe in this patch you can start checking ENOMEM (with a TODO comment), >> and then Bobby can change it when sending his patch. >> >> Or you can repost it (I'm not sure if we should keep the legacy behavior >> for other transports or it was an error, but better to discuss it on >> that patch). However, I think we should merge that patch. >> >> @Bobby, what do you think? >> >> Thanks, >> Stefano >> >> > This sounds good to me. I removed it from the last rev because I decided not > to complicate the patch by also including SO_SNDBUF support, so had no > need. I think it makes sense overall though. Ok! So I'll use Your patch(both af_vsock.c and transports related things - seems i'll split it to several patches, I think for transport patches, it is better to ask Vmware /Microsoft guys also). I'm going to send next version of my tests on this week. Thank You > > Also, sorry for the delay (I promised last week to send out new rev). I was > planning on sending out v4 with additional data for the non-nested virt > case, > but I've been having some IT troubles with the new phys box. No problem, im currently rebasing my patches for zerocopy on v3. > > Best, > Bobby > > PS. sorry if this email format comes out wacky. I'm not at my dev machine > so just using Gmail's web app directly... Hopefully there is no HTML or > anything weird. >
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); + 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) { + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", + send_size); + } + + control_writeln("CLISENT"); + + free(data); + close(fd); +} + +static void test_seqpacket_bigmsg_server(const struct test_opts *opts) +{ + int fd; + + fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); + if (fd < 0) { + perror("accept"); + exit(EXIT_FAILURE); + } + + control_expectln("CLISENT"); + + close(fd); +} + #define BUF_PATTERN_1 'a' #define BUF_PATTERN_2 'b' @@ -832,6 +889,11 @@ static struct test_case test_cases[] = { .run_client = test_seqpacket_timeout_client, .run_server = test_seqpacket_timeout_server, }, + { + .name = "SOCK_SEQPACKET big message", + .run_client = test_seqpacket_bigmsg_client, + .run_server = test_seqpacket_bigmsg_server, + }, { .name = "SOCK_SEQPACKET invalid receive buffer", .run_client = test_seqpacket_invalid_rec_buffer_client,