From nobody Mon Feb 9 23:15:18 2026 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8291C25B1D9; Thu, 1 May 2025 08:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746086755; cv=none; b=LmFJX4BdwjtHhgPzQNSnqPPKfPFhIioBA1LYEH7DbW4K6gvPGwIWXy9OKBM/AkqRWX01DMawNAmbXf2rmwHcy8i0KvgEx64celnkNN0w+UYphfuKy+qe/2VLaJ4Ujj12SxqbSDWXjRy8T2kPHgB9jOc2v4VxL4NvvjZd89WDoDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746086755; c=relaxed/simple; bh=bU72gZf0Mlr4a1DTEu4p6xddG7QuL34UyWY76ya9fjA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dyuNaqaLRDG0i+Tf5aqGwa9D/hZlsX9vEz0GnMZOS88mYp7PypOxPf6ApTqk7vL7zjXczk2KfbRw8gSs7dSeoCNs8/6oBARoHu5iYg6gyNJwbqK2P4UVFGaWNKKSAk2kKizYkVNzpHWb8W+e4ylDLGCP8xUvGI/Bw08ls3Yv4O4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co; spf=pass smtp.mailfrom=rbox.co; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b=X9VGX+yE; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rbox.co Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b="X9VGX+yE" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1uAOvV-009GJT-NW; Thu, 01 May 2025 10:05:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From; bh=qswCCZ7zdNCGMNQd6xheEFi5M2DI/AzAcjRQmm33v3U=; b=X9VGX+yEM8mMIFvL6YCUB/p0w4 afhAITQoo56D5rWG3BzXb0kTCKpEJIhude326jP7J5GYRUEALgnuY5jlvMypO+gCvGJbHEvt2qgX0 dhkOrlALiQMuSiSGSHdjz8cpjvYhQ9QGrKCtf+YCoGkIWCm8hYbpQY4/ckS2G7l1bGqtAhRYuZu6e P2PSTDjkCLSKy0rOW4mfPIUcETx7dQBVdyWdiWqzUt5iyrja4//QLtADHyQ64fp0q/9pHQHY2hSV3 zkZw3Cyw89XJcmyflJU/lCRmz1l4c0b5ERmrA6hJKTO+il+iheS836VvhtD5eeERdlWMMjQat5CL2 7JCOaaOg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1uAOvV-0001EG-EP; Thu, 01 May 2025 10:05:49 +0200 Received: by submission03.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1uAOvK-005lsv-HP; Thu, 01 May 2025 10:05:38 +0200 From: Michal Luczaj Date: Thu, 01 May 2025 10:05:24 +0200 Subject: [PATCH net-next v4 3/3] vsock/test: Expand linger test to ensure close() does not misbehave Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250501-vsock-linger-v4-3-beabbd8a0847@rbox.co> References: <20250501-vsock-linger-v4-0-beabbd8a0847@rbox.co> In-Reply-To: <20250501-vsock-linger-v4-0-beabbd8a0847@rbox.co> To: Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Stefan Hajnoczi Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Michal Luczaj X-Mailer: b4 0.14.2 There was an issue with SO_LINGER: instead of blocking until all queued messages for the socket have been successfully sent (or the linger timeout has been reached), close() would block until packets were handled by the peer. Add a check to alert on close() lingering when it should not. Signed-off-by: Michal Luczaj --- tools/testing/vsock/vsock_test.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_t= est.c index d0f6d253ac72d08a957cb81a3c38fcc72bec5a53..82d0bc20dfa75041f04eada1b43= 10be2f7c3a0c1 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -1788,13 +1788,16 @@ static void test_stream_connect_retry_server(const = struct test_opts *opts) close(fd); } =20 +#define LINGER_TIMEOUT 1 /* seconds */ + static void test_stream_linger_client(const struct test_opts *opts) { struct linger optval =3D { .l_onoff =3D 1, - .l_linger =3D 1 + .l_linger =3D LINGER_TIMEOUT }; - int fd; + int bytes_unsent, fd; + time_t ts; =20 fd =3D vsock_stream_connect(opts->peer_cid, opts->peer_port); if (fd < 0) { @@ -1807,7 +1810,28 @@ static void test_stream_linger_client(const struct t= est_opts *opts) exit(EXIT_FAILURE); } =20 + /* Byte left unread to expose any incorrect behaviour. */ + send_byte(fd, 1, 0); + + /* Reuse LINGER_TIMEOUT to wait for bytes_unsent =3D=3D 0. */ + timeout_begin(LINGER_TIMEOUT); + do { + if (ioctl(fd, SIOCOUTQ, &bytes_unsent) < 0) { + perror("ioctl(SIOCOUTQ)"); + exit(EXIT_FAILURE); + } + timeout_check("ioctl(SIOCOUTQ) =3D=3D 0"); + } while (bytes_unsent !=3D 0); + timeout_end(); + + ts =3D current_nsec(); close(fd); + if ((current_nsec() - ts) / NSEC_PER_SEC > 0) { + fprintf(stderr, "Unexpected lingering on close()\n"); + exit(EXIT_FAILURE); + } + + control_writeln("DONE"); } =20 static void test_stream_linger_server(const struct test_opts *opts) @@ -1820,7 +1844,7 @@ static void test_stream_linger_server(const struct te= st_opts *opts) exit(EXIT_FAILURE); } =20 - vsock_wait_remote_close(fd); + control_expectln("DONE"); close(fd); } =20 --=20 2.49.0