From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AFD3EFBEF; Tue, 25 Jun 2024 09:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719308123; cv=none; b=sn9fEqahtP8wuVonBcX5rQ/hdKM3Ae1RsZ9nobGet2IsA3hF6zteA4i6fmK7WB1acZNpG8XqDSgrufMkVd38bXWm+rpe+XHwp1t4aqGr7PItrP4m6syiQDI+iCqylFLH7j2veV+AOpzlpcJtn9FZB11eDCXALjupAXJN48WgBdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719308123; c=relaxed/simple; bh=GVMfLcqjqSouWW5vQvkI2iERWQ1Z/K8aF0k/7UHClSY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=my0MvoYrjQM9Y9p4nz0eCbqKlkLP/0s974mXGn+50zqyeGI9TJ5ct953NytQ7XXuNMXISvolXV8sf4lnzzs+f9jxgUBe7M4T7/DT45DBliaxXTwxlfzqx620ymGs3W/sEM1XRTg4UlAwxUYBNf+kt9bhlXawj7U9WEWjrmsJknw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kFOjhsZP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kFOjhsZP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33E09C32781; Tue, 25 Jun 2024 09:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719308123; bh=GVMfLcqjqSouWW5vQvkI2iERWQ1Z/K8aF0k/7UHClSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kFOjhsZPgZHyBFIx9y9tzmz1ocaxXf8H2C/kGQ5Eouf6dU76P5FXheHL+W1esxuSt Fhm+3NmzvoDIvEfYvPNl3fZ3ncF5A+k8mJ4w19xX9/NtOODHo6wFMfhkmmtBsHJzst 6uY5pyJ81uwc8NTKG8WkPbQvvBp3HS3qPGKIbo+g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Alessandro Carminati (Red Hat)" , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.9 015/250] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh Date: Tue, 25 Jun 2024 11:29:33 +0200 Message-ID: <20240625085548.632898041@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240625085548.033507125@linuxfoundation.org> References: <20240625085548.033507125@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alessandro Carminati (Red Hat) [ Upstream commit f803bcf9208a2540acb4c32bdc3616673169f490 ] In some systems, the netcat server can incur in delay to start listening. When this happens, the test can randomly fail in various points. This is an example error message: # ip gre none gso # encap 192.168.1.1 to 192.168.1.2, type gre, mac none len 2000 # test basic connectivity # Ncat: Connection refused. The issue stems from a race condition between the netcat client and server. The test author had addressed this problem by implementing a sleep, which I have removed in this patch. This patch introduces a function capable of sleeping for up to two seconds. However, it can terminate the waiting period early if the port is reported to be listening. Signed-off-by: Alessandro Carminati (Red Hat) Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20240314105911.213411-1-alessandro.carminati@gmail.com Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_tc_tunnel.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_tc_tunnel.sh b/tools/testing/selftests/bpf/test_tc_tunnel.sh index 910044f08908a..7989ec6084545 100755 --- a/tools/testing/selftests/bpf/test_tc_tunnel.sh +++ b/tools/testing/selftests/bpf/test_tc_tunnel.sh @@ -72,7 +72,6 @@ cleanup() { server_listen() { ip netns exec "${ns2}" nc "${netcat_opt}" -l "${port}" > "${outfile}" & server_pid=$! - sleep 0.2 } client_connect() { @@ -93,6 +92,16 @@ verify_data() { fi } +wait_for_port() { + for i in $(seq 20); do + if ip netns exec "${ns2}" ss ${2:--4}OHntl | grep -q "$1"; then + return 0 + fi + sleep 0.1 + done + return 1 +} + set -e # no arguments: automated test, run all @@ -193,6 +202,7 @@ setup # basic communication works echo "test basic connectivity" server_listen +wait_for_port ${port} ${netcat_opt} client_connect verify_data @@ -204,6 +214,7 @@ ip netns exec "${ns1}" tc filter add dev veth1 egress \ section "encap_${tuntype}_${mac}" echo "test bpf encap without decap (expect failure)" server_listen +wait_for_port ${port} ${netcat_opt} ! client_connect if [[ "$tuntype" =~ "udp" ]]; then -- 2.43.0