From patchwork Thu Mar 10 12:35:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12776921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF67C433F5 for ; Thu, 10 Mar 2022 12:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242048AbiCJMhJ (ORCPT ); Thu, 10 Mar 2022 07:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242041AbiCJMhI (ORCPT ); Thu, 10 Mar 2022 07:37:08 -0500 X-Greylist: delayed 110 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 10 Mar 2022 04:36:05 PST Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95BC5141E0A; Thu, 10 Mar 2022 04:36:05 -0800 (PST) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 5F84F5FD0B; Thu, 10 Mar 2022 15:36:03 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1646915763; bh=sAYFudhND3JlipbN3vSkDC50/DPj1pm3r26FdfVkax4=; h=From:To:Subject:Date:Message-ID:Reply-To:Content-Type: MIME-Version; b=dsTdKg7P9XYY0xTqRk9ZJ2V+xj0OHIYXQVcgFO3MBFH0LsqwBFmjtfq1yTnOPWBOH ezCI1mn7LRQiZGBmgxhRb6adWdpgkx7lkewq1oY8b/3YbAbSp0RqNq33fhN13F7ui3 FJGhM2VHhnr8dzZ4YtgqCvhQ2uP9lKVgwaWQMfv8YRmbT+P8+WgcCLV6jICiGijAyr s32lmCAgcdqJongEeF7rc2L74NJoxYJmT7wnIN6FduTEXHJ6rclv1qHWysB6jJfGcc P9gQHbF977Ny8Qy88SLufkm5T9B/SigrwHKMTqEfPuMsToZFdFDHBew1LU67KIC2Nc uSSAvoQ1SJjmA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Thu, 10 Mar 2022 15:36:03 +0300 (MSK) From: =?utf-8?b?0JrRgNCw0YHQvdC+0LIg0JDRgNGB0LXQvdC40Lkg0JLQu9Cw0LTQuNC80Lg=?= =?utf-8?b?0YDQvtCy0LjRhw==?= To: Stefano Garzarella CC: "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Krasnov Arseniy , =?utf-8?b?0KDQvtC60L7RgdC+0LIg0JQ=?= =?utf-8?b?0LzQuNGC0YDQuNC5INCU0LzQuNGC0YDQuNC10LLQuNGH?= Subject: Thread-Index: AQHYNHtecbA/6LWnrk+GBWwyAuzxZQ== Date: Thu, 10 Mar 2022 12:35:53 +0000 Message-ID: <1a92beea-6c77-69b6-07e0-1e8f0242d898@sberdevices.ru> Reply-To: "17514ec6-6e04-6ef9-73ba-b21da09f0f6f@sberdevices.ru" <17514ec6-6e04-6ef9-73ba-b21da09f0f6f@sberdevices.ru> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: 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/03/10 08:46:00 #18933400 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From 3d7fa2a57a2dd60a18b201f8537b717b5fc43cf3 Mon Sep 17 00:00:00 2001 From: Arseniy Krasnov Date: Mon, 3 Jan 2022 14:44:02 +0300 Subject: [RFC PATCH v1 2/3] af_vsock: SOCK_SEQPACKET receive timeout test Test for receive timeout check: connection is established, receiver sets timeout, but sender does nothing. Receiver's 'read()' call must return EAGAIN. Signed-off-by: Arseniy Krasnov --- tools/testing/vsock/vsock_test.c | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index 2a3638c0a008..aa2de27d0f77 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -391,6 +391,50 @@ static void test_seqpacket_msg_trunc_server(const struct test_opts *opts) close(fd); } +static void test_seqpacket_timeout_client(const struct test_opts *opts) +{ + int fd; + struct timeval tv; + char dummy; + + fd = vsock_seqpacket_connect(opts->peer_cid, 1234); + if (fd < 0) { + perror("connect"); + exit(EXIT_FAILURE); + } + + tv.tv_sec = 1; + tv.tv_usec = 0; + + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)) == -1) { + perror("setsockopt 'SO_RCVTIMEO'"); + exit(EXIT_FAILURE); + } + + if ((read(fd, &dummy, sizeof(dummy)) != -1) || + (errno != EAGAIN)) { + perror("EAGAIN expected"); + exit(EXIT_FAILURE); + } + + control_writeln("WAITDONE"); + close(fd); +} + +static void test_seqpacket_timeout_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("WAITDONE"); + close(fd); +} + static struct test_case test_cases[] = { { .name = "SOCK_STREAM connection reset", @@ -431,6 +475,11 @@ static struct test_case test_cases[] = { .run_client = test_seqpacket_msg_trunc_client, .run_server = test_seqpacket_msg_trunc_server, }, + { + .name = "SOCK_SEQPACKET timeout", + .run_client = test_seqpacket_timeout_client, + .run_server = test_seqpacket_timeout_server, + }, {}, };