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 9BA3FC636CC for ; Tue, 31 Jan 2023 20:57:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjAaU5g (ORCPT ); Tue, 31 Jan 2023 15:57:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbjAaU5M (ORCPT ); Tue, 31 Jan 2023 15:57:12 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2939274BD for ; Tue, 31 Jan 2023 12:56:46 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id A5B8A442FE for ; Tue, 31 Jan 2023 20:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675198588; bh=L9NG4EbGXg9Qd+NeBO29yIJT8Su4mY75m3fPbmvR2Jg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bxxpp32kpWO+p2/SxEIp/2unz7YQikf0KIQqzQK7CUKCNIEjQQqY6+e1/C4V8H3ps APLm4fdT1A70l3bd4zE455SDopwqzKVl1ztzW+HD+/c7cJzgO+Am3DGOoVNk58Fyd+ UG6NVVjAO2vC29/X+jem7uP/HCvwcV7R7h6UdaVJTVzxJ8GnZpdDaPNDOEc5sosdT5 aNHk0wDShZf/mWqLUz+Kb3HY6lOGi31elRs/A/xdIFFdaknd/uIVTtBAYY405K+RW5 CSQ0gBoVqFdKH2au7gcYhXu1s6QcQCod94qf9DbnUPHxLufZ/mOY2l2T3P0KTidavv QgwDJVlFXX9qg== Received: by mail-wm1-f72.google.com with SMTP id o2-20020a05600c510200b003dc51c95c6aso889210wms.0 for ; Tue, 31 Jan 2023 12:56:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=L9NG4EbGXg9Qd+NeBO29yIJT8Su4mY75m3fPbmvR2Jg=; b=WePZdwPqOIU51XgYQ5cYmypl63JVVXND7cLME4kspuSwmhzk6NG/ZTRBmSoxhsEb27 oW7pxTPCB9URTDBKkxnTCKyh7dgMrfmFPoows48ByAFtnDf/kuaWKycu49V8Q5shDbSs XsCnbc61Qq/Zo0LI/qL2YF5qevC3DiuQnGRAXDnXmoMpzxlwL52tzUYB09mFHeAznqwo S4rRZ5HdvEQnTPRLUREfE/uVXTMGIS1J1xPJo4n/42+hTS+8z+lRBtgxuMggf+uAmZ51 hFLufM7F7T1llwX9IviOIbQNxYaPpifrENwFlJ2dFyETPRG22PH3LN7nFFUgopTQXx8z jLIA== X-Gm-Message-State: AO0yUKVafmAcNQfrvqeGJLgDM0qbMroNVihnrrXDw0nHbFdjlkKHhYoJ R14XqTJHt/73mhQk63fpILBoHSheULdkNdH5X0B4X3qnuGFmMvcEXIgtRwkHpGKpK+xYsmXq7ea VSPIP7u/X0IHtHERhXNOhtoUsCv5vFO9N3k6ic4sh7w== X-Received: by 2002:a05:600c:1d88:b0:3d1:caf1:3f56 with SMTP id p8-20020a05600c1d8800b003d1caf13f56mr5264264wms.9.1675198587959; Tue, 31 Jan 2023 12:56:27 -0800 (PST) X-Google-Smtp-Source: AK7set8roATM561UQyxsVNW2wm8I8l+avaE281Q660e39LKDsxSG4Kz4Cg8SfMm4SW+xymKyplyr4g== X-Received: by 2002:a05:600c:1d88:b0:3d1:caf1:3f56 with SMTP id p8-20020a05600c1d8800b003d1caf13f56mr5264250wms.9.1675198587790; Tue, 31 Jan 2023 12:56:27 -0800 (PST) Received: from qwirkle.internal ([81.2.157.149]) by smtp.gmail.com with ESMTPSA id bd16-20020a05600c1f1000b003d1f3e9df3csm21316535wmb.7.2023.01.31.12.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 12:56:27 -0800 (PST) From: Andrei Gherzan To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Willem de Bruijn Cc: Andrei Gherzan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 3/4] selftests: net: udpgso_bench: Fix racing bug between the rx/tx programs Date: Tue, 31 Jan 2023 20:53:20 +0000 Message-Id: <20230131205318.475414-3-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131205318.475414-1-andrei.gherzan@canonical.com> References: <20230131205318.475414-1-andrei.gherzan@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "udpgro_bench.sh" invokes udpgso_bench_rx/udpgso_bench_tx programs subsequently and while doing so, there is a chance that the rx one is not ready to accept socket connections. This racing bug could fail the test with at least one of the following: ./udpgso_bench_tx: connect: Connection refused ./udpgso_bench_tx: sendmsg: Connection refused ./udpgso_bench_tx: write: Connection refused This change addresses this by making udpgro_bench.sh wait for the rx program to be ready before firing off the tx one - up to a 10s timeout. Fixes: 3a687bef148d ("selftests: udp gso benchmark") Signed-off-by: Andrei Gherzan CC: Paolo Abeni CC: Willem de Bruijn --- tools/testing/selftests/net/udpgso_bench.sh | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testing/selftests/net/udpgso_bench.sh index dc932fd65363..640bc43452fa 100755 --- a/tools/testing/selftests/net/udpgso_bench.sh +++ b/tools/testing/selftests/net/udpgso_bench.sh @@ -7,6 +7,7 @@ readonly GREEN='\033[0;92m' readonly YELLOW='\033[0;33m' readonly RED='\033[0;31m' readonly NC='\033[0m' # No Color +readonly TESTPORT=8000 readonly KSFT_PASS=0 readonly KSFT_FAIL=1 @@ -56,11 +57,26 @@ trap wake_children EXIT run_one() { local -r args=$@ + local nr_socks=0 + local i=0 + local -r timeout=10 + + ./udpgso_bench_rx -p "$TESTPORT" & + ./udpgso_bench_rx -p "$TESTPORT" -t & + + # Wait for the above test program to get ready to receive connections. + while [ "$i" -lt "$timeout" ]; do + nr_socks="$(ss -lnHi | grep -c "\*:${TESTPORT}")" + [ "$nr_socks" -eq 2 ] && break + i=$((i + 1)) + sleep 1 + done + if [ "$nr_socks" -ne 2 ]; then + echo "timed out while waiting for udpgso_bench_rx" + exit 1 + fi - ./udpgso_bench_rx & - ./udpgso_bench_rx -t & - - ./udpgso_bench_tx ${args} + ./udpgso_bench_tx -p "$TESTPORT" ${args} } run_in_netns() { -- 2.34.1