From patchwork Tue Nov 15 20:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 20561 Return-Path: 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 + 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 ); 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 To: Stefano Garzarella CC: "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , kernel , Bobby Eshleman , Krasnov Arseniy 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: In-Reply-To: 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-ID: <61AB262BC80AEC438B4F4C80B53C1C7A@sberdevices.ru> 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: 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?= 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 --- tools/testing/vsock/vsock_test.c | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) -- 2.25.1 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,