From nobody Sat Dec 13 23:01:57 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 01A812253EE for ; Thu, 8 May 2025 14:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746714027; cv=none; b=H/tJvDZqwljjrHV28G3pDnNwjJGOJvfkNkqDcEoipFu45i2XZSRFQ530zU42ROaUTyOuM6cmYqPHEXv2ZkTCW8yBZHP8uQqpOoRpZMZI7nF/37UJX0Ye2VPvK9b+8ARsXL3GqZ6SgCDpk8LV9A7MgFuCurSSCMoTgUEl0UCisLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746714027; c=relaxed/simple; bh=YvRNLSi/VrpoieogGKGsgCKAlWpBPuTAmyy56vB3yh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RoyRixdUtg8tYXz25UCilszdPZTxXmmyfMgcLMC1NtTxMmYFtawjhjvf/4ONqzuZ0Ylyw5IJIap57JFvJhnTEuLtRNtEGiDu4bhqaoLRKd1jj3kfZu1WXHMX44KfIoifNVs394oCJlwMTWFePht7S0rnJ5aURh1zhhQnctbLBkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YP0DPSGY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YP0DPSGY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746714024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p/inhQIAJVDlclzovizj1G424bvRWbJSy56O+ePhgtM=; b=YP0DPSGYq4TQlEjuIxYFBhPTNtVOArmcBGdc4aepgWbKmIu+gi3j9XRPqkXhA89GHd3Xj4 T1z2mVv4JBjFySGBc/pUcJJpzMz11Fk1lotA9x/QyIauFqhhPZLG+Ps4gtDHlr93dkxzne FHAIMKj9Jgix3kbTVFv0rOgQ2GBKGq8= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-BXxLdWG8Na6y6MitNaGL8w-1; Thu, 08 May 2025 10:20:23 -0400 X-MC-Unique: BXxLdWG8Na6y6MitNaGL8w-1 X-Mimecast-MFC-AGG-ID: BXxLdWG8Na6y6MitNaGL8w_1746714022 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-ac710ace217so82847466b.1 for ; Thu, 08 May 2025 07:20:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746714022; x=1747318822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p/inhQIAJVDlclzovizj1G424bvRWbJSy56O+ePhgtM=; b=W4hfx751YiI3MswnFiiJ9VRhLBiH8o8GN0jqSYT64GZjuc942g5KUyIoWWaw+Ha+9D 1Bv8lkizWgcE0tLPj773KErKHrgipWyzEOjmSsqw+W8/f3lMlw+zuB4aTlP5YBPy46xI ElZi8tHpVZ6sNyhwJdav5u2qhnR30Zq12OpOVcwLakbwPzPj6kPv1f+6rc93TvBbLZeR RVz6UHoSIi5jYt9HFtbqDDmdpYWNWZFMGplkXjg2O6aYMvHfuSCiDx7K8mIazaNN1vLd 3rLqAc1Jc7FotccCaGdkpp8JdpZtT9Y2yPxZ9+wFrA7RbNCHjbGuXY72baOc/6d2z/Jw 6PZA== X-Gm-Message-State: AOJu0YyLecss5glxa+FpnOJGQq0WD/guEBxQqONE1w/STtsaVWJP+I6x u3mnFXe8Ds2MI2biMloisVZFtOTPAqDQKMjzZLhqquOKF1+DclKHosskG18WMW30qWiGhsYMBWB Y7cyKCGh+j4toaqJeEvnkZmQNrRiijn26O49xwJJIKCnr2aWlXXBKPznqIQAVOA== X-Gm-Gg: ASbGncsfERLRx3LCAzHDfRpEkAlgD1y1cQ/+OOSEOHatW+m6oP11miwh4I61/2GMmx4 6XWwBpTtZi1pr8bEvC/wpUb6AFeKQJel8xBUwxgshg0JIu2hzvId3qtqsN4z9hKcFiYcj3wnrWn 7q8GZ9HtYBIOrGU1N90RybX50upLns3QC+sLlGvB+H2QoqNUJGZCkcYqFyvO/f8hJ/laJUvhvAo 00cmN3qgv747XhPS5YPi0q92KfNbaJxqBkk/+ZyqJHBdGjLGp31cRZ97843FAS9H/Zv4U+X5IA2 JQa+87zCPKR13HVku710Me0Z+A== X-Received: by 2002:a17:907:96a7:b0:ac7:b368:b193 with SMTP id a640c23a62f3a-ad1fe6f68b4mr342644366b.27.1746714022433; Thu, 08 May 2025 07:20:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRTgUh6IEfYQONbpJtEOHpIxAXun5putCZzRRkLB2V22yE0BXo1RjIX+rhP121YMlrUvpBiQ== X-Received: by 2002:a17:907:96a7:b0:ac7:b368:b193 with SMTP id a640c23a62f3a-ad1fe6f68b4mr342639966b.27.1746714021843; Thu, 08 May 2025 07:20:21 -0700 (PDT) Received: from localhost.localdomain ([193.207.221.155]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad189540d5bsm1096012366b.176.2025.05.08.07.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 May 2025 07:20:21 -0700 (PDT) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH net-next 1/2] vsock/test: retry send() to avoid occasional failure in sigpipe test Date: Thu, 8 May 2025 16:20:04 +0200 Message-ID: <20250508142005.135857-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250508142005.135857-1-sgarzare@redhat.com> References: <20250508142005.135857-1-sgarzare@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella When the other peer calls shutdown(SHUT_RD), there is a chance that the send() call could occur before the message carrying the close information arrives over the transport. In such cases, the send() might still succeed. To avoid this race, let's retry the send() call a few times, ensuring the test is more reliable. Signed-off-by: Stefano Garzarella --- tools/testing/vsock/vsock_test.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_t= est.c index d0f6d253ac72..7de870dee1cf 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -1064,11 +1064,18 @@ static void test_stream_check_sigpipe(int fd) =20 have_sigpipe =3D 0; =20 - res =3D send(fd, "A", 1, 0); - if (res !=3D -1) { - fprintf(stderr, "expected send(2) failure, got %zi\n", res); - exit(EXIT_FAILURE); - } + /* When the other peer calls shutdown(SHUT_RD), there is a chance that + * the send() call could occur before the message carrying the close + * information arrives over the transport. In such cases, the send() + * might still succeed. To avoid this race, let's retry the send() call + * a few times, ensuring the test is more reliable. + */ + timeout_begin(TIMEOUT); + do { + res =3D send(fd, "A", 1, 0); + timeout_check("send"); + } while (res !=3D -1); + timeout_end(); =20 if (!have_sigpipe) { fprintf(stderr, "SIGPIPE expected\n"); @@ -1077,11 +1084,12 @@ static void test_stream_check_sigpipe(int fd) =20 have_sigpipe =3D 0; =20 - res =3D send(fd, "A", 1, MSG_NOSIGNAL); - if (res !=3D -1) { - fprintf(stderr, "expected send(2) failure, got %zi\n", res); - exit(EXIT_FAILURE); - } + timeout_begin(TIMEOUT); + do { + res =3D send(fd, "A", 1, MSG_NOSIGNAL); + timeout_check("send"); + } while (res !=3D -1); + timeout_end(); =20 if (have_sigpipe) { fprintf(stderr, "SIGPIPE not expected\n"); --=20 2.49.0 From nobody Sat Dec 13 23:01:57 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 CE2A326F478 for ; Thu, 8 May 2025 14:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746714034; cv=none; b=LIOrJpxQ/yfnZay/gw1ijfTTFe+QUKll/P1NiogKDvx5hIjWo5RWCZN/BAY4e7dscajNTJ3/6uEywOCw+SSn41BC+logS+83etxutx0sO9eZBl0iNrRC8uw/M9pZfBBZ3xR/uuiu264GxlAyoLQnqJlEJLwWxSFoBvS6kZBhVj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746714034; c=relaxed/simple; bh=7YG192ZsD3WUn3drwZlMqsrENOopUzB5dGEgYOknoQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d4XPwHKnM1MfIkpfUtvBQtzBXZZU/pUxauyAPGSuGP57qNAGN5zV2rZR7QHTp2xDkNiSM+r2EWE394of1Ta9NHW9gjfWL59bQZXXd6NYQtsFE0Ak42giZ6Bnjfc+FvbLWLkT+mgDxZ2KLlZiMHCaeRqaOsdB1qwd2SWoj4sNcWY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MX40ca2o; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MX40ca2o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746714031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Egj0FQy/riyQmvL5sll8nVIB9OlbYijgnbiGu15AMX0=; b=MX40ca2ooU4dW+VGU8okDD/5KC6dtIcqTdi/3lD4SPd6r9+GvCvg7Rrc09Pg6A3mZ8QSUH aAphQJGufRGOk/XlpjQCf6wZV2tKYDLfwNBR/49WaH1aMIWzWXqQJeBwx7rAQvmha3H0Ea oav4rQK9ZUKmW3iUi8r+z9IYTGsjuSk= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-ghRCDbJFPk6F0lo9Gfh76A-1; Thu, 08 May 2025 10:20:30 -0400 X-MC-Unique: ghRCDbJFPk6F0lo9Gfh76A-1 X-Mimecast-MFC-AGG-ID: ghRCDbJFPk6F0lo9Gfh76A_1746714029 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5fbf91153c5so1044137a12.3 for ; Thu, 08 May 2025 07:20:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746714029; x=1747318829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Egj0FQy/riyQmvL5sll8nVIB9OlbYijgnbiGu15AMX0=; b=Dqr4Pwji9fvmWv2wZwnoOgLedBTdFELgMBmdNBhr47rwhZBezntPMzqmECW2DDs8QT fLYtrN06XsFOBGBPP5n23H5QnuKHPvUnnXBmA6mTQ5uLpTMigMm5nXrix3vg6cb21tcZ BjkT3HyKHsqzWmsLpapC2aW/RaM67crEvcwRDVCCFz+ItMroJIbdrtX8vnAGxXLEtUuy fn9kHRBctEizGiUe5naVPyqb48VoitVS9g+1ue7coFp9MIekcWxq4Efsxk9kqvq6KhvK KiUKuOgeMVMkQj2dsSmV205ls1/Zbitro3dGaU91UimsLVpKylpOHE3qY7/gShRThw96 2UKw== X-Gm-Message-State: AOJu0Yx8HXWrYZxhbzbyMJjGYNXxweBaXz03ttrK5otRssEFzBsHQfNM J6G3PshDeMzoAwcfGH8/lrrJw/VdzbOdpZkLrOpylmQXpH3ZM/U5dA/mORQRSh4Lo3AvbJWkAC8 yV98GP6wm85dnLiX1sOXN5BuDdRBOEqaZ45BXO1Hanr9eAIWI7RsJmMKi+wqlfw== X-Gm-Gg: ASbGncudbhsT6rwes5094jDS8w4lFu175s74If8OAtk0bEvij2WEZOCXgLGWiWq3OeD WKrNWDw+OL7UUorVJhSdERZHmX3R8CeX+2yLkc8q3AZwdEab/9S1vIXUEEWgA2pkc8zAXFHZIIN qLROipDuYqNkZsAcrlbchJG+RMLUPa3VutLjg8nyGtWMpZGKj2q6imk9xqqLc550Q8h42qRdjxx HFSEXj8taYYTsaGX5pY9xOWCtMBRQJ5I0XZDEJK/IPEsWrpC08TQXp4zQh4yZ7hjdJO5HeSsMQp bvK3MuVYz1kRJB7QqfkYI4utUA== X-Received: by 2002:a17:906:f10a:b0:ad2:15c9:9c73 with SMTP id a640c23a62f3a-ad215c9ade0mr24419466b.34.1746714028973; Thu, 08 May 2025 07:20:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/Oe8HK04stKuYdcastU9b8FffLyMB1PLqflqnugfQTg8McvY43KaFdQo960fI2h3cqw+r9g== X-Received: by 2002:a17:906:f10a:b0:ad2:15c9:9c73 with SMTP id a640c23a62f3a-ad215c9ade0mr24416866b.34.1746714028437; Thu, 08 May 2025 07:20:28 -0700 (PDT) Received: from localhost.localdomain ([193.207.221.155]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad1891a3f1asm1103005766b.64.2025.05.08.07.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 May 2025 07:20:27 -0700 (PDT) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH net-next 2/2] vsock/test: check also expected errno on sigpipe test Date: Thu, 8 May 2025 16:20:05 +0200 Message-ID: <20250508142005.135857-3-sgarzare@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250508142005.135857-1-sgarzare@redhat.com> References: <20250508142005.135857-1-sgarzare@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella In the sigpipe test, we expect send() to fail, but we do not check if send() fails with the errno we expect (EPIPE). Add this check and repeat the send() in case of EINTR as we do in other tests. Signed-off-by: Stefano Garzarella --- tools/testing/vsock/vsock_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_t= est.c index 7de870dee1cf..533d9463a297 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -1074,9 +1074,13 @@ static void test_stream_check_sigpipe(int fd) do { res =3D send(fd, "A", 1, 0); timeout_check("send"); - } while (res !=3D -1); + } while (res !=3D -1 && errno =3D=3D EINTR); timeout_end(); =20 + if (errno !=3D EPIPE) { + fprintf(stderr, "unexpected send(2) errno %d\n", errno); + exit(EXIT_FAILURE); + } if (!have_sigpipe) { fprintf(stderr, "SIGPIPE expected\n"); exit(EXIT_FAILURE); @@ -1088,9 +1092,13 @@ static void test_stream_check_sigpipe(int fd) do { res =3D send(fd, "A", 1, MSG_NOSIGNAL); timeout_check("send"); - } while (res !=3D -1); + } while (res !=3D -1 && errno =3D=3D EINTR); timeout_end(); =20 + if (errno !=3D EPIPE) { + fprintf(stderr, "unexpected send(2) errno %d\n", errno); + exit(EXIT_FAILURE); + } if (have_sigpipe) { fprintf(stderr, "SIGPIPE not expected\n"); exit(EXIT_FAILURE); --=20 2.49.0