From patchwork Tue Mar 5 10:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582041 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 E3F015C61A; Tue, 5 Mar 2024 10:42:45 +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=1709635366; cv=none; b=k/tu9wsReaXT9EWCxGNBU54MqqdynD/N5vhhzchyVVacD8GFRjsGutGt5GzSCbBe1CdlUDrKHScMY9O2HC9ABAHRlOFnDHj+Q0eViGgW2pawHHe+yAFQOlkSVHLm5paZfAKUN95bx3gwAnjoAR8HxW736xtUsLbH3u1ljrsZlM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635366; c=relaxed/simple; bh=+5YCsCdGmLcwpGBEkiByA48Y8GO6L2mQsOcRmzA3CTA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WqekNcRYQyr/xs6LnV1U5PDna4+BF2x/P7WZI4mKCl17PEJgAkMsxnxvG2FNM0pdFsSWl1xsOSG08+GQPp+eltFvGxOB6/ulKwbMq+Nwy49GJon1n6DNpQVcWHx4ARuYkddJjRb2AKlNN0yDDywXz43gHKVDNdg0tcO+nu/gPyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uLGQ8hdk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uLGQ8hdk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02E52C43390; Tue, 5 Mar 2024 10:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635365; bh=+5YCsCdGmLcwpGBEkiByA48Y8GO6L2mQsOcRmzA3CTA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uLGQ8hdkVHSRAmw5/bg+B/xrG+FvkKHy2FO5hcJXw54GBTWJ6ODnV8qp8hqoZX7lj FQc7mcgNJTGs01PYD8XUet5shrU5aYr9RG398QKu/zmjldv7clchF/dhwWr4HDDfBr mPpC0mzww9CVV3KoVyE86azbt2HQbzC0wPX6I2dsH829LCac4wzyzO70HM7sBwmps8 KUCt5wGiO6+OI1QRJ+7bqdjf+eyJ8IY4+PH7Iqq3H963pluptUMz3nxHnfLcadZMfP 0e6pDD3ngKzyU6cVUvY/n8elG3rkzD8TL5drjAK+k2Lp3Qhrm0MLmBSwNcAcQjesZ2 L6Pi9J/gPCR3g== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:31 +0100 Subject: [PATCH net-next 01/13] selftests: mptcp: stop forcing iptables-legacy Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-1-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Pablo Neira Ayuso X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3156; i=matttbe@kernel.org; h=from:subject:message-id; bh=+5YCsCdGmLcwpGBEkiByA48Y8GO6L2mQsOcRmzA3CTA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vccSvSrU+ujR23th9KSJFboEjj7Le0vuAycJ Q5+SLY1sgCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg c+fzD/9Zmfz2HPVhcCwZlSZxioFRKS0QIJ7wX4386X5KLvE5ucYmkkNvKZK+hq6A69ZVTID4nkb qIgErlxlqd6Pc0bMGJ70UbThL7ogsSTSO43dMtUSDEWtjzm2EAg2c0L4a08CllUjwgDZZsudpXp xK/83j9sfSzgBGDaKBTIOVuQik7K25cBog39omgry7oUvuLln5/VTycEAmKhOUcXLfaUCbxDROO RnlsyZHH34ZSSfEHCD1ExAl2RFMw2bpTuTV70IVlgb8faCjYhWwS1pNl+N3O3lH1E0FGeOPTwF4 HX8O8V4w/Xgq0F7qZlML52v3e4YZHDWZxNX83ZHNzsNYh1gNfEBJ7TegBV0f0avk1dDOlY4VrCu dYMQkNbmzv9Og3EWXDd7YxzdKawMBvmtO7ziHdr/SWfjLaFWGBxKJDYjzxHdDtA18+ddS0FVuh2 w+8upiPn2wdmjJiNImazX7nmRruU4H3ek7WVnV+N+nzsraz4e5nLtmvX8vieBSlCSDkEKWVpUi5 IwNo4B/AEBKaZezOrhNFNTHJrBn6V/RAGX2gizoroYd9PmM1KWRBlC26Fv6cYUVypqJoXJXKjZM HS3/p6IIItbzBAUDUrbbAGQwYF1Xc6GtC1F1MHhJ7hs6BlokKdPWFrEjBv7fjlocIw6RgglzFiY zLW8cusHxXASk1g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Commit 0c4cd3f86a40 ("selftests: mptcp: join: use 'iptables-legacy' if available") and commit a5a5990c099d ("selftests: mptcp: sockopt: use 'iptables-legacy' if available") forced using iptables-legacy if available. This was needed because of some issues that were visible when testing the kselftests on a v5.15.x with iptables-nft as default backend. It looks like these errors are no longer present. As mentioned by Pablo [1], the errors were maybe due to missing kernel config. We can then use iptables-nft if it is the default one, instead of using a legacy tool. We can then check the variables iptables and ip6tables are valid. We can keep the variables to easily change it later or add options. Link: https://lore.kernel.org/netdev/ZbFiixyMFpQnxzCH@calendula/ [1] Suggested-by: Pablo Neira Ayuso Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++-------- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 955ee651dcd5..6a4af95cd4c3 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -167,15 +167,11 @@ check_tools() exit $ksft_skip fi - # Use the legacy version if available to support old kernel versions - if iptables-legacy -V &> /dev/null; then - iptables="iptables-legacy" - ip6tables="ip6tables-legacy" - elif ! iptables -V &> /dev/null; then - echo "SKIP: Could not run all tests without iptables tool" + if ! "${iptables}" -V &> /dev/null; then + echo "SKIP: Could not run all tests without ${iptables} tool" exit $ksft_skip - elif ! ip6tables -V &> /dev/null; then - echo "SKIP: Could not run all tests without ip6tables tool" + elif ! "${ip6tables}" -V &> /dev/null; then + echo "SKIP: Could not run all tests without ${ip6tables} tool" exit $ksft_skip fi } diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index c643872ddf47..dac8e1fc7143 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -96,15 +96,11 @@ if [ $? -ne 0 ];then exit $ksft_skip fi -# Use the legacy version if available to support old kernel versions -if iptables-legacy -V &> /dev/null; then - iptables="iptables-legacy" - ip6tables="ip6tables-legacy" -elif ! iptables -V &> /dev/null; then - echo "SKIP: Could not run all tests without iptables tool" +if ! "${iptables}" -V &> /dev/null; then + echo "SKIP: Could not run all tests without ${iptables} tool" exit $ksft_skip -elif ! ip6tables -V &> /dev/null; then - echo "SKIP: Could not run all tests without ip6tables tool" +elif ! "${ip6tables}" -V &> /dev/null; then + echo "SKIP: Could not run all tests without ${ip6tables} tool" exit $ksft_skip fi From patchwork Tue Mar 5 10:42:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582042 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 9764A5BADB; Tue, 5 Mar 2024 10:42:49 +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=1709635369; cv=none; b=Or4XiKzmpK0TWP9AnaUyHrIxOxdjZC0b7xj5QdqvVyO2qOG0aOhk6agdIUVVxpupqdCoug65o/yGtlVdow879F/C7GFCqUXQ7SV2iFc9s7jGbeta5KrqRmmmcTWx5mhxyPEHgVyMYHUbe/aMkBQkqFfSTVcROebSfD/jwaPfy4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635369; c=relaxed/simple; bh=fNW62RoqvlgK4DVt6pDg+5T3KJXI1LsQBl9zqq5p39E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H3sV5bCYBuxXq8HYOsttm7SCt7vIuU2GLW2ymGCeFq2fHIolU0tBXKU5BgHKoBCbXK9HoISQQrGrXNzhHXJSJMbpSAcrvLnJamf4HS7+CQnBSpO1DdQkjq+EPzLHuLDG5EGWU7PpCcNQwQe8T6+BImhOQuqB3ckIjKehIg8SsBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PVgJkqgZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PVgJkqgZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D1D6C43390; Tue, 5 Mar 2024 10:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635369; bh=fNW62RoqvlgK4DVt6pDg+5T3KJXI1LsQBl9zqq5p39E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PVgJkqgZo3NLdB/u8jPtt6VRHx0Y5WGXM7mU0bfpW8IWputmPvjX4RkY0XeV82J1s +5BOFNkrplVgEne3Eau47VGOYeX+LIpznVU4wF/EjBXy75iivHF0kRakpN6TbU2ulO H2QqI+H5AEyRtLvDzojGrzTiH5lIPV2lkJKqAOavt7Wa2g5RJ9bMoBOIZpGzsPTkHI MAk6N2P1qk6FaH8SRg+LRg8wPheukWBVDG18ZqhouvQheTl3FVcwMd6tifENqqnt4Z DIgYfF4+D8NrzT05IHnipVdgo1vTcijBts/kJXNbDTD4NVfQSzKP3JBi6GBu8sfixJ ZYZOZa2UEY6ng== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:32 +0100 Subject: [PATCH net-next 02/13] selftests: mptcp: add mptcp_lib_check_tools helper Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-2-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7064; i=matttbe@kernel.org; h=from:subject:message-id; bh=mNejHG+IpDCqO0G/yGU/BV55iutt/FWjzIkbjGVpe0w=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vccO9iGAssj2JBuBkHWIPpkah707av0qkMt0 YBrk/vbHx6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg c5FKD/wKIf8Eow2hXgEms7ZhEBfhUvDz5ZaMZA+3V8X9DXabpF1Qwc15ct9ZOM7vtVJQhlaGAjc vZYEr9RXdBkzg34bAukFpyfeY8BBF9KCM+bDQfDXRstWBwxU2pK7CBoMaVBvlrJb2Q2PiOh4qVb cHpQHsPPWFc1KaIvcF78Tu5PXQEE2MzabDiWfmSm7vym3DZj1t1GKfvW37svWojNi4j2Lna8Ri7 574CNRVSdrd1ccJi0h/z8Hi197RKkpZtruyNY+eUb3LEFBhhpaMfUqvjEWvgxa2LMQUHN8gDgOX BrNBo1V2Fvqp/WATupA4lfp6Y9sPggSAEeWOT6nDAfF/Fa5iaawGVWHjMRSWj6/g8a74X+Hh0IG ntQBxuYFky0veHDsw6ecxU4KZzgqV9UL6lWluV6BZxbjMVhnSrc3wfiJEwhZ66JfS1XJeWwZ0Cl 4mgvAF/U31ZxM+DkjGUMiw6u5JMSJ1rqsdeyEZuoLnecPhedzYIeFScyDeI5xlGqBPyqrkK/rnH uBrdd2FBaE6l7r1TqL108kfDLNK1YCW32BpS4MpzVfPoFHgNi4bks6agGyAZsfndqG0qUC9NNBO 7bXfW/0TuLoe+Bxftvi7xL8MX/BKrPX5cGkddqZ3CuUlvnRJgDv2Th5+TjtgvS79ZzgoOw14f9T bnMr240CTZczM0A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch exports check_tools() helper from mptcp_join.sh into mptcp_lib.sh as a public one mptcp_lib_check_tools(). The arguments "ip", "ss", "iptables" and "ip6tables" are passed into this helper to indicate whether to check ip tool, ss tool, iptables and ip6tables tools. This helper can be used in every scripts. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 12 +-------- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 7 +---- tools/testing/selftests/net/mptcp/mptcp_join.sh | 28 +++---------------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 31 ++++++++++++++++++++++ tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 15 +---------- tools/testing/selftests/net/mptcp/pm_netlink.sh | 7 +---- tools/testing/selftests/net/mptcp/simult_flows.sh | 7 +---- tools/testing/selftests/net/mptcp/userspace_pm.sh | 6 +---- 8 files changed, 40 insertions(+), 73 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index e87cf76b3e4a..e42603be03f3 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -34,17 +34,7 @@ cleanup() } mptcp_lib_check_mptcp - -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi -ss -h | grep -q MPTCP -if [ $? -ne 0 ];then - echo "SKIP: ss tool does not support MPTCP" - exit $ksft_skip -fi +mptcp_lib_check_tools ip ss get_msk_inuse() { diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 7898d62fce0b..ea52110c3fbc 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -147,12 +147,7 @@ cleanup() mptcp_lib_check_mptcp mptcp_lib_check_kallsyms - -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi +mptcp_lib_check_tools ip sin=$(mktemp) sout=$(mktemp) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 6a4af95cd4c3..aedc5698f26a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -152,34 +152,12 @@ cleanup_partial() done } -check_tools() -{ - mptcp_lib_check_mptcp - mptcp_lib_check_kallsyms - - if ! ip -Version &> /dev/null; then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip - fi - - if ! ss -h | grep -q MPTCP; then - echo "SKIP: ss tool does not support MPTCP" - exit $ksft_skip - fi - - if ! "${iptables}" -V &> /dev/null; then - echo "SKIP: Could not run all tests without ${iptables} tool" - exit $ksft_skip - elif ! "${ip6tables}" -V &> /dev/null; then - echo "SKIP: Could not run all tests without ${ip6tables} tool" - exit $ksft_skip - fi -} - init() { init=1 - check_tools + mptcp_lib_check_mptcp + mptcp_lib_check_kallsyms + mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}" sin=$(mktemp) sout=$(mktemp) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 438f557aac90..b1fe354cfe96 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -342,3 +342,34 @@ mptcp_lib_check_output() { return 1 fi } + +mptcp_lib_check_tools() { + local tool + + for tool in "${@}"; do + case "${tool}" in + "ip") + if ! ip -Version &> /dev/null; then + mptcp_lib_print_warn "SKIP: Could not run test without ip tool" + exit ${KSFT_SKIP} + fi + ;; + "ss") + if ! ss -h | grep -q MPTCP; then + mptcp_lib_print_warn "SKIP: ss tool does not support MPTCP" + exit ${KSFT_SKIP} + fi + ;; + "iptables"* | "ip6tables"*) + if ! "${tool}" -V &> /dev/null; then + mptcp_lib_print_warn "SKIP: Could not run all tests without ${tool}" + exit ${KSFT_SKIP} + fi + ;; + *) + mptcp_lib_print_err "Internal error: unsupported tool: ${tool}" + exit ${KSFT_FAIL} + ;; + esac + done +} diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index dac8e1fc7143..fd7de1b3dc55 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -89,20 +89,7 @@ cleanup() mptcp_lib_check_mptcp mptcp_lib_check_kallsyms - -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi - -if ! "${iptables}" -V &> /dev/null; then - echo "SKIP: Could not run all tests without ${iptables} tool" - exit $ksft_skip -elif ! "${ip6tables}" -V &> /dev/null; then - echo "SKIP: Could not run all tests without ${ip6tables} tool" - exit $ksft_skip -fi +mptcp_lib_check_tools ip "${iptables}" "${ip6tables}" check_mark() { diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 705106d60db5..1ec9d8622fc9 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -36,12 +36,7 @@ cleanup() } mptcp_lib_check_mptcp - -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi +mptcp_lib_check_tools ip trap cleanup EXIT diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index ed0165c15a24..dbbb13d1d74e 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -43,12 +43,7 @@ cleanup() } mptcp_lib_check_mptcp - -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi +mptcp_lib_check_tools ip # "$ns1" ns2 ns3 # ns1eth1 ns2eth1 ns2eth3 ns3eth1 diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 1b94a75604fe..629fc5d0ecc5 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -17,11 +17,7 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then echo "userspace pm tests are not supported by the kernel: SKIP" exit ${KSFT_SKIP} fi - -if ! ip -Version &> /dev/null; then - echo "SKIP: Cannot not run test without ip tool" - exit ${KSFT_SKIP} -fi +mptcp_lib_check_tools ip ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED REMOVED=7 # MPTCP_EVENT_REMOVED From patchwork Tue Mar 5 10:42:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582043 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 D76405CDE2; Tue, 5 Mar 2024 10:42:53 +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=1709635374; cv=none; b=OMJSFxHLlUdqOzqAZyPjfg87jLR+yGxTnyKhM0DX8Bnaf4OitZK8KX1Lx2adsao9qQukDcJT2q+DSwbOEmBHYgnEwGgOBqHW6/ZF06jpUqx4uxTyPxz7ogjWmc+VnRYvaJunJSJeNhQ3KE/hs9DzbyEScoRePYtSqTdZrwRAo/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635374; c=relaxed/simple; bh=JN2dNESh/y3tfb0TsFQ2avl51emLgu5m25nFtJpTifo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pB26cyLLorLgx62ihAGa3xB7lTeUooD8V0U/9kLRTD2327s45vBKYGPnMQ7xEQv/Vtt3lG4dLkd2OL8E3Rs9e3t7U3JwZjQ6bMAHPU8J+BlDzOcD0c4ew9IlgDMNM6qG1fTAxUzwAdm07cmMA94n27QNbo00PYZ/YibK7jaepYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L5MpYPos; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L5MpYPos" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6016C433C7; Tue, 5 Mar 2024 10:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635373; bh=JN2dNESh/y3tfb0TsFQ2avl51emLgu5m25nFtJpTifo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L5MpYPosyRXNolZOet8a+ciMnpda+ZzNAs9DfQSQ/qlwcWSm5kqw+QIlk7EiAIiLZ kw3v27npw2QhlXWcZeQjA0uIqDlT5L5Td9JZrJpIiajkVHs88KA4DfINqG/Vey3nif hRthsTXXSYlYyauk8Yme94l5Sb0guziUfgzPAxF01IqA91r8+EVnXHmd/qykgYIZuZ agmABV/uFoGztuv97AwtpwH+XXWfTMyCxNI1FwGn0Vmd5djQk17Z59ED18Xe1ueKhL VB0w9HOO0a3CbFkflifWVKtFRsNUUQXQirPTTwdk1o30FuiA6ukVztEFm47vCN/twd vfioCAuroaKcQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:33 +0100 Subject: [PATCH net-next 03/13] selftests: mptcp: add mptcp_lib_check_output helper Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-3-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1473; i=matttbe@kernel.org; h=from:subject:message-id; bh=nZs0x809wzr+eJddUt9MlJGJF47PT8cW7Q1w0vMKvSs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vccRBX23YStuLEegcwd5kODJJ0cB6NBjHla5 hSM+45062yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg cwkSEAC7l+udkR6ZJEU8Uc0QWmX9JHZO+S59qOkADmlikuTekT+1y1xstVxwn3eEp+HU85aA9ti YB9UEIeLGl7pPR7bG/CJxwSCvsLBFcbfQIc1e0g8hxgxW03qA7H35FqRChb9Q5rLMW+IlTp7Mcw Bo9euarfevIHqhScSJliohAxv/kXhxACF5P5uZupd3kHbKDiw6bmmYEVIKv64goTfpLXyKXKlt2 NM8kqnaZbwAYAB0OT8ADAleCIncBvHFP/3MUj55r4OWXVFE6Ht0wWw8g+bd9KYtpxUJT+2FY/iH m8KYnwL684jNoufB4kHked6PyOQziJge64xBhmHBUWoSb+vL3ffXjmVnT4ekU5NebbGTFC4vXjY ss9K75epheEiZj6P/vtisHagfuY3QBkQRj4sOWoC5J30Z9fWZ2mYwpEOLLcIAWoiN3qJjU9ah57 /mAtlAVnCTLJvyzQXWu39wo4Xpz3/17GVoSkIZ26xWPk5VitVYNcEbTH06IEip4UktiXMUgG1r2 Urd4X7JdcOUdXbksJAe5IginpdN9STEQN7X+n34a41BXlROGFnC72au2nUpIKqYV825p8sv7zUR Ss4bqNtA/SVvc+NFm7Brdr/dtrB65dj9ucyRTJHl4TPpVbL1bW8vYSi73cCbaLUR9tXw8ePZiJE cLXluGV2PUyY+xw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Extract the main part of check() in pm_netlink.sh into a new helper named mptcp_lib_check_output in mptcp_lib.sh. This helper will be used for userspace dump addresses tests. Co-developed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index b1fe354cfe96..ed86bb0bab49 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -373,3 +373,26 @@ mptcp_lib_check_tools() { esac done } + +mptcp_lib_check_output() { + local err="${1}" + local cmd="${2}" + local expected="${3}" + local cmd_ret=0 + local out + + if ! out=$(${cmd} 2>"${err}"); then + cmd_ret=${?} + fi + + if [ ${cmd_ret} -ne 0 ]; then + mptcp_lib_print_err "[FAIL] command execution '${cmd}' stderr" + cat "${err}" + return 2 + elif [ "${out}" = "${expected}" ]; then + return 0 + else + mptcp_lib_print_err "[FAIL] expected '${expected}' got '${out}'" + return 1 + fi +} From patchwork Tue Mar 5 10:42:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582044 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 9FDAB5D47B; Tue, 5 Mar 2024 10:42:57 +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=1709635377; cv=none; b=qCZh9QYtwF++7nT3iLKgu56zEfJ9H49YGnRTvVWSmyKjOCbrQxmp0yJSgEwQC3bMrDupVgcFW6IwFtakJZyha7+5eRPM7luFrj9CE/8CBofa+GjqgewNtP6nnU3B6ZhksRaeSFFYijfXp9DD3cJc8LbK9ExacJjpNvS1oFRD+UU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635377; c=relaxed/simple; bh=NwaGraVY2orMRXPc4dj4/mlBtx6flfWWyqqm+KZIYZA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T9WO/4/IJJRNam1EwlzN/9+6jC703QSBGoh88K5aTdiG3bdC4H4ZaUpadmKxEXTUvqPocqCXoDKTVyXYFS+hlCOwN040ZOQ1zy9633+T3xQYh7ryowfn8vJwHuj2whCvB4b1d79w9oJN2NTRyVAW/1U/LWvK2wpoP9DB8ZpKe9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CA4lRqOl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CA4lRqOl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8357C43390; Tue, 5 Mar 2024 10:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635377; bh=NwaGraVY2orMRXPc4dj4/mlBtx6flfWWyqqm+KZIYZA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CA4lRqOlXOr3a6i2U6GCtUnowoCK+rEo0Q/5rEfsXIt9PG+SetBisgIkZQ+cr4DEX DVxE1k6Q2tmGpJnufqbqCabE1Y1A0kapwWxF4+N/bAoH8WI8BJMr/CaNM+DrfnjSgD 0lUBP48pW9imqsW6h0xDWTc0ktNl773Fjy05AXjjg356zGkeGzfR6Ce44il32wA5Cx 4Oito7jmuL5cbJNdgWHgMvPhT3g0hzDzBd4Wwv0dUP1kZqKnrfa2qzLtxsyIqwkuIi lpaXmZqklPBBxsTCKD3u2/pQ7DrQj9iIb3si859VYIELgUbO6EKSk5C33rp7CdawRZ gYfyIQVN8F7og== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:34 +0100 Subject: [PATCH net-next 04/13] selftests: mptcp: add local variables rndh Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-4-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1438; i=matttbe@kernel.org; h=from:subject:message-id; bh=rR83I8+9RuJUsNHRpTCHk6/7gRGCW52wxZZeqhezDd0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcctx8rBdjKkea/BSXnmiIO9Q/gwbNNqgI36 bMV7Q4C/pyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg cwDyEACqvyfCv1JuWAQFsM8rHRSuGs4sxxbWjsiSDRZZvHeohxK5iiAIftryNbvAnGizVQT5/D/ W2IrRd6YnpLWTRBt940afAihg1+Gz3ruFi6os4ngK8wQMRC1QmfwNZl7Diyw82RlMJAOHYwjZbr QoYYOfysJ45E5otqSyyBseDJYu5lj8IYWgoZ5E0blcSpOuSeWvfLMEq+YI1jJ1LG64Xe4PJpytE hEoCrXfIB0VvRAVGTuxBKKJFOtBpKaTV0mbfV9UN3b8jkaGYzK7g2T0Xgm8XoCOwijASIKR6xNi Hg9Oc2Wb1b+onpT8C/1qHmXSkI+q9ROw2+ziZHWblUXSiqc+IbPVed6Nqkss4Wc1uGKH6LGjMms tlxisz0e3Y/AJiSzGMtjxxYspi1Iot1A/MYykoV1/0/41jhgkqB3q61gZIdyw2cCm4zoBN7nzzF SVywLBBk09ZGAOPUt2NCv4EJuh7AGsC1oAUCqnGHad/HtHxWBmJnxwNbTOj5oba4HtRZEBo9k9W +hBFtUubw/Yfd1Ke7U8Y/NsosF/gH7opbGgDQGmW9vzJMo5y7h5pLLyhbJ72O8UbYTqzB+DULVQ VCMetI2kZKPBnkRi4ku/dDFPgkQjGCk1zD91tQLV9BJT66bcXsDVEArzCXC75HzNyy+u6hHIuuw Vj2meyzOySeiT9g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch adds local variables rndh in do_transfer() functions both in mptcp_connect.sh and simult_flows.sh, setting it with ${ns1:4}, not the global variable rndh. The global one is hidden in the next commit. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 1 + tools/testing/selftests/net/mptcp/simult_flows.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index ea52110c3fbc..b609649311f6 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -348,6 +348,7 @@ do_transfer() if $capture; then local capuser + local rndh="${connector_ns:4}" if [ -z $SUDO_USER ] ; then capuser="" else diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index dbbb13d1d74e..3d08116500a4 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -139,6 +139,7 @@ do_transfer() if $capture; then local capuser + local rndh="${ns1:4}" if [ -z $SUDO_USER ] ; then capuser="" else From patchwork Tue Mar 5 10:42:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582045 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 F24F55D47B; Tue, 5 Mar 2024 10:43:00 +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=1709635381; cv=none; b=qcT7QTOTk1TkPa8chXyV1wT7nKghtET8/CXiPqlMXK66Xi4jia8a6MIZ+rB+e0HdM76SZTqdL9y0/KegkiOgh8zOyaGibHaqRI+R+D6Cj1JRCwge67MCeS+txJM/eHh1f/qk0Au0C9/9bT1U6JvtkPVhLo3YnZ43N9CRRCT7phU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635381; c=relaxed/simple; bh=wW8p8oB3gTE6slrGFZ/w3mTgo4yTKJtX7Hrikeg1Iwk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NXRKDyrR4Kh4HDbPqD08y0TsQP/PtKhOncpHqPX3OnTHyn7zFm+qqyDhQXkcHHtDRfSjvBkmoDWkKZJ5sqOxmFRO5AxP2ZH391wT5+0BtFaIAYs3gHbZNJHWcda2fbtOCGSZhtGoHHtlSVcoqyAM8XeTWsDWSaVS5KAzLCLW76A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RbAg9mAq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RbAg9mAq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29EBC43394; Tue, 5 Mar 2024 10:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635380; bh=wW8p8oB3gTE6slrGFZ/w3mTgo4yTKJtX7Hrikeg1Iwk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RbAg9mAqO6vdWIFSOloHNZJXgsqqtas5ZcWtp/VtfrcbTCEE/+S4yMP9IzqjiwRSj QLrIVuq0NnEljP6UOHG9p2c/uMk8wfTIni0WLUCTFTvxQJ8a4axQVYekR93W4XzkuA d5jSP+mpwUsPzyCrm54zFXiVeg2gtdaWfgnU0laVgyLBg3N91k5vdbt7le1oOwwuCX 7EV6KZyn+PKJ92mmCclNCTOHdxUN+chmGqsjFTXIFz8P+JYjyhgY60Z1RNeaZRqW9U Vzb22/iZdTiaNrZBOCQrbRh6RTvHaJxQqUC4rM6UXwPw3g+r7+DFfElqcyRevoObXe 2Nu3bNmapSZTQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:35 +0100 Subject: [PATCH net-next 05/13] selftests: mptcp: add mptcp_lib_ns_init/exit helpers Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-5-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9784; i=matttbe@kernel.org; h=from:subject:message-id; bh=Bg5ox4Jc4FZkVFd+s/ohOUxx5S47ZL35oo6wIvq4SDg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vccIC1hR8S52sHLC5oC3U00ggBDNvoYX6CMv aqp8QEJaYqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg c5jlD/9gTPkcwQOdks2C2b9alx2sVJge+ZJqauy8y/obPDj05Py8iQG3cXDuY62NxPPYdvrWg0k FqDUU8Rf6yusVXRYYmuOltikphW0m/zxxtptG2auHd3kSNTR4tAGriBxuugh16b/vYcVngX6Vy8 5tt0+9fDdrxg42vTgCi6VkgF6Vu041GqBNY5+m6B3/JcReGOcTvs2P8YA5qRUh+BW81dXjOlNO5 ijaQAgLw9hFumrYemfiNN9vE7q8eW43WzrLaCvqMr/Ge33X6RSKyVyH/FqoSeWubvszAgq9OZGY yMcMD0M28Qj0KHdy3T0szweZAQU+/DcKbz4pw3KFITt7XZT1HnK7pkldBlZzmqWN8a2Y5G7MtGd pHKJrf+JG3lysZ3P0crPFyEJXuLCh8fpn+EeVxl9FQmzOaOHJk5dq3j6jzi7bWeiehdalBbyQKQ yiabvFU0qTji350pJgBLF49xRkOfcLJiGghfRWlDnnFBWedMXgUe5UGQwhEkXlaQ3sUCq/xAtlA Y5hI04NB3yU4I/rlyXVlzDZEJLVE/ckrCeGaQwv1zO1zgbMswyXR3gKZvc7hxc2ME26We9D9AdU Euf3Irp9LoYxE4CtlOVxZ3LJUVN6QQrXb3LLMPcD35jGG+MoX1Un3NWk8nO/7IG8tcpNHzORbqW E7tjgae4xG4dkXA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Add helpers mptcp_lib_ns_init() and mptcp_lib_ns_exit() in mptcp_lib.sh to initialize and delete the given namespaces. Then every test script can invoke these helpers and use all namespaces. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 9 +++------ tools/testing/selftests/net/mptcp/mptcp_connect.sh | 23 +++++++++------------- tools/testing/selftests/net/mptcp/mptcp_join.sh | 11 ++--------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 22 +++++++++++++++++++++ tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 17 ++++++---------- tools/testing/selftests/net/mptcp/pm_netlink.sh | 9 +++------ tools/testing/selftests/net/mptcp/simult_flows.sh | 16 +++++---------- tools/testing/selftests/net/mptcp/userspace_pm.sh | 14 ++++--------- 8 files changed, 54 insertions(+), 67 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index e42603be03f3..0ee93915bccb 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -3,9 +3,7 @@ . "$(dirname "${0}")/mptcp_lib.sh" -sec=$(date +%s) -rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) -ns="ns1-$rndh" +ns="" ksft_skip=4 test_cnt=1 timeout_poll=30 @@ -30,7 +28,7 @@ cleanup() { ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null - ip netns del $ns + mptcp_lib_ns_exit "${ns}" } mptcp_lib_check_mptcp @@ -214,8 +212,7 @@ wait_connected() } trap cleanup EXIT -ip netns add $ns -ip -n $ns link set dev lo up +mptcp_lib_ns_init ns echo "a" | \ timeout ${timeout_test} \ diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index b609649311f6..92f6260ba9f3 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -121,12 +121,10 @@ while getopts "$optstring" option;do esac done -sec=$(date +%s) -rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) -ns1="ns1-$rndh" -ns2="ns2-$rndh" -ns3="ns3-$rndh" -ns4="ns4-$rndh" +ns1="" +ns2="" +ns3="" +ns4="" TEST_COUNT=0 TEST_GROUP="" @@ -140,9 +138,9 @@ cleanup() local netns for netns in "$ns1" "$ns2" "$ns3" "$ns4";do - ip netns del $netns rm -f /tmp/$netns.{nstat,out} done + mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}" } mptcp_lib_check_mptcp @@ -158,10 +156,7 @@ cin_disconnect="$cin".disconnect cout_disconnect="$cout".disconnect trap cleanup EXIT -for i in "$ns1" "$ns2" "$ns3" "$ns4";do - ip netns add $i || exit $ksft_skip - ip -net $i link set lo up -done +mptcp_lib_ns_init ns1 ns2 ns3 ns4 # "$ns1" ns2 ns3 ns4 # ns1eth2 ns2eth1 ns2eth3 ns3eth2 ns3eth4 ns4eth3 @@ -251,8 +246,8 @@ fi check_mptcp_disabled() { - local disabled_ns="ns_disabled-$rndh" - ip netns add ${disabled_ns} || exit $ksft_skip + local disabled_ns + mptcp_lib_ns_init disabled_ns # net.mptcp.enabled should be enabled by default if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then @@ -266,7 +261,7 @@ check_mptcp_disabled() local err=0 LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \ grep -q "^socket: Protocol not available$" && err=1 - ip netns delete ${disabled_ns} + mptcp_lib_ns_exit "${disabled_ns}" if [ ${err} -eq 0 ]; then echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]" diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index aedc5698f26a..612470244c58 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -86,17 +86,10 @@ init_partial() { capout=$(mktemp) - local sec rndh - sec=$(date +%s) - rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) - - ns1="ns1-$rndh" - ns2="ns2-$rndh" + mptcp_lib_ns_init ns1 ns2 local netns for netns in "$ns1" "$ns2"; do - ip netns add $netns || exit $ksft_skip - ip -net $netns link set lo up ip netns exec $netns sysctl -q net.mptcp.enabled=1 ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 @@ -147,9 +140,9 @@ cleanup_partial() local netns for netns in "$ns1" "$ns2"; do - ip netns del $netns rm -f /tmp/$netns.{nstat,out} done + mptcp_lib_ns_exit "${ns1}" "${ns2}" } init() { diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index ed86bb0bab49..2fcf31277e28 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -396,3 +396,25 @@ mptcp_lib_check_output() { return 1 fi } + +mptcp_lib_ns_init() { + local sec rndh + + sec=$(date +%s) + rndh=$(printf %x "${sec}")-$(mktemp -u XXXXXX) + + local netns + for netns in "${@}"; do + eval "${netns}=${netns}-${rndh}" + + ip netns add "${!netns}" || exit ${KSFT_SKIP} + ip -net "${!netns}" link set lo up + done +} + +mptcp_lib_ns_exit() { + local netns + for netns in "${@}"; do + ip netns del "${netns}" + done +} diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index fd7de1b3dc55..5fa5fa8cab71 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -14,11 +14,9 @@ timeout_test=$((timeout_poll * 2 + 1)) iptables="iptables" ip6tables="ip6tables" -sec=$(date +%s) -rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) -ns1="ns1-$rndh" -ns2="ns2-$rndh" -ns_sbox="ns_sbox-$rndh" +ns1="" +ns2="" +ns_sbox="" add_mark_rules() { @@ -40,10 +38,10 @@ add_mark_rules() init() { + mptcp_lib_ns_init ns1 ns2 ns_sbox + local netns for netns in "$ns1" "$ns2" "$ns_sbox";do - ip netns add $netns || exit $ksft_skip - ip -net $netns link set lo up ip netns exec $netns sysctl -q net.mptcp.enabled=1 ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 @@ -79,10 +77,7 @@ init() cleanup() { - local netns - for netns in "$ns1" "$ns2" "$ns_sbox"; do - ip netns del $netns - done + mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns_sbox}" rm -f "$cin" "$cout" rm -f "$sin" "$sout" } diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 1ec9d8622fc9..30ec0ec3d68f 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -24,15 +24,13 @@ while getopts "$optstring" option;do esac done -sec=$(date +%s) -rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) -ns1="ns1-$rndh" +ns1="" err=$(mktemp) cleanup() { rm -f $err - ip netns del $ns1 + mptcp_lib_ns_exit "${ns1}" } mptcp_lib_check_mptcp @@ -40,8 +38,7 @@ mptcp_lib_check_tools ip trap cleanup EXIT -ip netns add $ns1 || exit $ksft_skip -ip -net $ns1 link set lo up +mptcp_lib_ns_init ns1 ip netns exec $ns1 sysctl -q net.mptcp.enabled=1 check() diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 3d08116500a4..2aeebb80da07 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -3,11 +3,9 @@ . "$(dirname "${0}")/mptcp_lib.sh" -sec=$(date +%s) -rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) -ns1="ns1-$rndh" -ns2="ns2-$rndh" -ns3="ns3-$rndh" +ns1="" +ns2="" +ns3="" capture=false ksft_skip=4 timeout_poll=30 @@ -36,10 +34,7 @@ cleanup() rm -f "$large" "$small" rm -f "$capout" - local netns - for netns in "$ns1" "$ns2" "$ns3";do - ip netns del $netns - done + mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" } mptcp_lib_check_mptcp @@ -65,9 +60,8 @@ setup() trap cleanup EXIT + mptcp_lib_ns_init ns1 ns2 ns3 for i in "$ns1" "$ns2" "$ns3";do - ip netns add $i || exit $ksft_skip - ip -net $i link set lo up ip netns exec $i sysctl -q net.ipv4.conf.all.rp_filter=0 ip netns exec $i sysctl -q net.ipv4.conf.default.rp_filter=0 done diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 629fc5d0ecc5..e3092696d2de 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -50,10 +50,8 @@ app6_port=50004 client_addr_id=${RANDOM:0:2} server_addr_id=${RANDOM:0:2} -sec=$(date +%s) -rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX) -ns1="ns1-$rndh" -ns2="ns2-$rndh" +ns1="" +ns2="" ret=0 test_name="" @@ -118,10 +116,7 @@ cleanup() mptcp_lib_kill_wait $pid done - local netns - for netns in "$ns1" "$ns2" ;do - ip netns del "$netns" - done + mptcp_lib_ns_exit "${ns1}" "${ns2}" rm -rf $file $client_evts $server_evts @@ -131,9 +126,8 @@ cleanup() trap cleanup EXIT # Create and configure network namespaces for testing +mptcp_lib_ns_init ns1 ns2 for i in "$ns1" "$ns2" ;do - ip netns add "$i" || exit 1 - ip -net "$i" link set lo up ip netns exec "$i" sysctl -q net.mptcp.enabled=1 ip netns exec "$i" sysctl -q net.mptcp.pm_type=1 done From patchwork Tue Mar 5 10:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582046 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 447385D8F5; Tue, 5 Mar 2024 10:43:04 +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=1709635385; cv=none; b=Z1euVMT7Rx8CCE3dsY39oKhGwWflZxS60efCFh3wnR1v7g2/Sygsyy/mLkxKRuKsIeaMSqlcryHRApiAeVNq82nhS+aE/5tHIJKVsMV6QQg6CN0BVTCn4NvJXcG+GldvsT97xApYQ7nnncuMDJG41/ZO+HfNdGgp12MH+4uqUl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635385; c=relaxed/simple; bh=mQN6XlPwVxQ5NRezeDFYuyVoqaHwuvLxF4rT4+vnbxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=scuTAxQJHh0d7MaGxfw11YgnBzUGEAjqHzDqgK0L6mgY35JX1hIFJoqKODB9mNVSgU/gjaE6i9NE6zx8FzabWScLz9ecdNgqn2rJx3Vk1MYBsLv5pZSrpjxYqhLslL8oUtko3nEjQbdtXZ0Qcs5LiHF2n3um1S6cSDXCaiJjMCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gp5B0KJm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gp5B0KJm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C02CC433B2; Tue, 5 Mar 2024 10:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635384; bh=mQN6XlPwVxQ5NRezeDFYuyVoqaHwuvLxF4rT4+vnbxw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Gp5B0KJmNw4IKIkcOFW7zpXBrXcXyGQnIlrbi2qV4y30CoWJPZ2+kTrX3V6lbGqae NGJPeC8pkSl1EDj85ezP89WMBAtCT6KukZHlezEB0HGoWyg6TGWlY/zCmVO4VF5w0u MQuT88etMnrbdRVEJJHLrRTpIluZFe+OoSDaI1yMQ/PJj6waiwSUCGOvszUWprD1mk ZGH1H7MwudUilCXZKiPT1BLsWTmkRE3l6AnxHvLDXcApNwYgWJvVjcnBQcbLee1ECu O2vcpDFToX66enG8fHuUjbXTN62IltPazxqgKrzldRLs7JjWnOmOCUyMbZN3tLMJWR gHA20JvQcSrRw== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:36 +0100 Subject: [PATCH net-next 06/13] selftests: mptcp: more operations in ns_init/exit Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-6-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5583; i=matttbe@kernel.org; h=from:subject:message-id; bh=JRlHi1Rxu31mh34RN165okAY3Ztwk7nlrHRPOjoBqLc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vccDf+kGzO7UzgxLAKP0a126AV/sKkNdY+ov 15uzP+/7xuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg cy+bEADvx78vO+j1Ox0a3/BHNmkbUkJD0qUicBb1tnmRsQq1nozcJhDJ5uIEqRdOOPH1KgXBR9B k1IYrASKSvHeyNpYVvLZ1dnrI5jUjr7aAbHl9pK7MhiPY0Gt8n6dh1YUUTnhY4+yIVF+Q8kqeiV JSupfaburleM4Shm4J/zjH9Igdl0+gFAa86/58v4+oLBj4QgKgTgvcJBk4QBgYplpcwj3RdKLbP 0utCdFxUlSBc/jJQzTU6al8Ehw8LXWNmS6AWuOBDSDytj5QP+G7JCm+zueT31MQPPdVt2BHBreX dFaHVrS0QeUzmEWycuN9anHRPSZSy1T7xKoZkyHpfkZGm1vTUWXnzmYEbJA9E5P7YC8WGVNTvIZ wueI/RTF5gkgwJrET1S5krJg+xVEGmuI9Esd7OdBbGRbjeU/avjL12M/3enr/mlUV9ZYeu3KgvM qoicOINVIzGe3tUTJZkxnCSLWOgawPjLTDKlea5xQhTphOqZwqqIrc1l+FS9xg9vf0f/r3/zPh5 0lk/V6fAiN5qZUzcz23Gg18RRBJRYMcqZHMBEHGC7aKyDPEh3+qE8cDp39lBDTLRPHlBmBCVqSf /OsKrYN0gX/8ih4es3lPR6dpraJ5rQttklnedn5Id8u0NqQjtgI3uOyp1Ed46GBw18SMn4R017M cSlMTnubmHgueVg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Set more the default sysctl values in mptcp_lib_ns_init(). It is fine to do that everywhere, because they could be overridden latter if needed. mptcp_lib_ns_exit() now also try to remove temp netns files used for the stats even for selftests not using them. That's fine to do that because these files have a unique name. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 4 ---- tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 ------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++++ tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 7 ------- tools/testing/selftests/net/mptcp/pm_netlink.sh | 1 - tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ---- tools/testing/selftests/net/mptcp/userspace_pm.sh | 1 - 7 files changed, 4 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 92f6260ba9f3..b53ae64ec08c 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -136,10 +136,6 @@ cleanup() rm -f "$sin" "$sout" rm -f "$capout" - local netns - for netns in "$ns1" "$ns2" "$ns3" "$ns4";do - rm -f /tmp/$netns.{nstat,out} - done mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}" } diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 612470244c58..2d9cf6f3bbf3 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -90,10 +90,7 @@ init_partial() local netns for netns in "$ns1" "$ns2"; do - ip netns exec $netns sysctl -q net.mptcp.enabled=1 ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true - ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 - ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 if $checksum; then ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 fi @@ -138,10 +135,6 @@ cleanup_partial() { rm -f "$capout" - local netns - for netns in "$ns1" "$ns2"; do - rm -f /tmp/$netns.{nstat,out} - done mptcp_lib_ns_exit "${ns1}" "${ns2}" } diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 2fcf31277e28..f98cde130869 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -409,6 +409,9 @@ mptcp_lib_ns_init() { ip netns add "${!netns}" || exit ${KSFT_SKIP} ip -net "${!netns}" link set lo up + ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=1 + ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=0 + ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=0 done } @@ -416,5 +419,6 @@ mptcp_lib_ns_exit() { local netns for netns in "${@}"; do ip netns del "${netns}" + rm -f /tmp/"${netns}".{nstat,out} done } diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 5fa5fa8cab71..7dd0e5467d35 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -40,13 +40,6 @@ init() { mptcp_lib_ns_init ns1 ns2 ns_sbox - local netns - for netns in "$ns1" "$ns2" "$ns_sbox";do - ip netns exec $netns sysctl -q net.mptcp.enabled=1 - ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 - ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 - done - local i for i in `seq 1 4`; do ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 30ec0ec3d68f..c7c46152f6fd 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -39,7 +39,6 @@ mptcp_lib_check_tools ip trap cleanup EXIT mptcp_lib_ns_init ns1 -ip netns exec $ns1 sysctl -q net.mptcp.enabled=1 check() { diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 2aeebb80da07..5a4b83cdaaa9 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -61,10 +61,6 @@ setup() trap cleanup EXIT mptcp_lib_ns_init ns1 ns2 ns3 - for i in "$ns1" "$ns2" "$ns3";do - ip netns exec $i sysctl -q net.ipv4.conf.all.rp_filter=0 - ip netns exec $i sysctl -q net.ipv4.conf.default.rp_filter=0 - done ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2" ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth2 netns "$ns2" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index e3092696d2de..6d71bf36a1b9 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -128,7 +128,6 @@ trap cleanup EXIT # Create and configure network namespaces for testing mptcp_lib_ns_init ns1 ns2 for i in "$ns1" "$ns2" ;do - ip netns exec "$i" sysctl -q net.mptcp.enabled=1 ip netns exec "$i" sysctl -q net.mptcp.pm_type=1 done From patchwork Tue Mar 5 10:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582047 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 22EE35DF0D; Tue, 5 Mar 2024 10:43:09 +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=1709635390; cv=none; b=j94xffIu5MPIQoB3s1QF0zwuje65KGpqgszKPNGHyU4R1umJY7c0efjNyRmxf2n0EV5PB4gYCUqG2Qc+6CNSFTZwADTlJdvf/AZIw+Mrp1dj3egpzqRiDSKUzJ/xaOPdebnkL+4RIlBeMu3YqsOCO7lhISghpZLYGsXcBhIP/Q0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635390; c=relaxed/simple; bh=7MuoN5+40TBUchfvIOx0MBwidvrH7l5RkAVhK7k1HtE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ljooETCmo8T4fJoQXvOHXJDs6+b65XpehYqj5Pl9FzvdB7J50+9KAxhtibE0nSdKnTrjtyFa8gRdOtopBOlBs4iVlaMIYqLj4BhGYL38Cq6Q0ARjXFDhES8SyM3p8EtdvZyfNPuj+aYNuOM71aya9dwVjatWlgrUC0Wqvt/dzxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tVWRJHS+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tVWRJHS+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3552FC433F1; Tue, 5 Mar 2024 10:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635389; bh=7MuoN5+40TBUchfvIOx0MBwidvrH7l5RkAVhK7k1HtE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tVWRJHS+L9Bjz/DQLo3UhB1Vn3rM8Z4CFhPeiri0JAFBaxSjw0H6djCUUsN2VGuPe I/asD4s4i1fG3kflNefJ7mnRP8PtB5yDWVS8J0/ZEc72fee8DiDvO0yRn4kbbV+2fM 4W7PlNOr40rUdtk7nBohffV2eARKLWe0WxI8oZKIqk7W2LZ1zSAWkDpQLwlHuE+k/w k/fQ9a3W/3wPMP6CFOUVq3Zj185pteX+6Zn1gzCdzzGpBIZhf1Y+8shlWMqoaNIuT3 XacGkND9Z5DsfOwY5TWEu7euhUv6h+SfezivqYbvgSQa4IOrxEF6+R5CrKeYg1YDU6 8SIwjEbcTy+JQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:37 +0100 Subject: [PATCH net-next 07/13] selftests: mptcp: add mptcp_lib_events helper Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-7-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3467; i=matttbe@kernel.org; h=from:subject:message-id; bh=2RK9Mv0/VX8CgX8AP4PwJg4uzfuEN7SHfxg0Gz+tvmU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcctpe9yIoLdlZI++yeZAQNd6V9UaCh+LWZ5 e4CcmqSw4uJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HAAKCRD2t4JPQmmg cz2hD/0beHDIW3LjTJav6xuWQrvvWpal91JrAoQF9jEBW5YSAlLZU/xfjH61FiAIMPrCY3ZW+nq elF9s9+i3m59321oIR/ndsB7RJd23GyrQwDGtDaKRwAQTQRfoFfT4BR4l9rCMAbT3Ezl/wT4dRi 1Dj7zVw/9CWKF3wd7UuTEKrb6CKmcP6sD500cEt4q5oNSQ7D4davEkJOWssQcb2LSOUYJswZDU5 rIDn/NGxqc6E4LVmTGNbtxEvdwDu/rBNtNhDW5Y+sI0pSHhBXqzFppiq8GIhUVfgaEil8uboUkH AR3mRidaJBjGnZ3dONP7cYdWFxhbm+A0gfjQiFhHBBC8EdYGNMO7Y7GOKhjr17HEoVVJOuJ9oDN /fDGcUp6e6UKNK9Tju1Jf8qftcnOArTrt9yHQrSVVEwbtqlmsg6vcMkoNFEPN1S+XOKiYH/Qtp7 yApkYFLEaQ018trhPzCvv8WX7JaDr5gMLd4c5C1j3MoTfAJ46C8NKClC705Vvq3kuWFwAY6BDwG yuvUBTTK45exS/wqEfLHv03foB4GwcPav/xysBu51q4/YFHjSz6i11CzdfKKZN3RbD4MSSU7iUR JaBpUgxDiAhrKAQqV3l5Qns48F1iLwEA5TPxltrNC9wnI1JkP0F7RN7c53OpHxgMiD53nbaZ+19 rMC+hLLUHlKi+gw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh. This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh and mptcp_join.sh into a helper mptcp_lib_events(). Define it in mptcp_lib.sh and use it in both scripts. Note that mptcp_lib_kill_wait is now call before starting 'events' for mptcp_join.sh as well, but that's fine: each test is started from a new netns, so there will not be any existing pid there, and nothing is done when mptcp_lib_kill_wait is called with 0. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++------ tools/testing/selftests/net/mptcp/mptcp_lib.sh | 12 ++++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 14 ++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 2d9cf6f3bbf3..1df2d24979a0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -430,12 +430,8 @@ reset_with_events() { reset "${1}" || return 1 - :> "$evts_ns1" - :> "$evts_ns2" - ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 & - evts_ns1_pid=$! - ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 & - evts_ns2_pid=$! + mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid + mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid } reset_with_tcp_filter() @@ -608,7 +604,9 @@ wait_mpj() kill_events_pids() { mptcp_lib_kill_wait $evts_ns1_pid + evts_ns1_pid=0 mptcp_lib_kill_wait $evts_ns2_pid + evts_ns2_pid=0 } pm_nl_set_limits() diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index f98cde130869..5e8a3c4700e4 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -422,3 +422,15 @@ mptcp_lib_ns_exit() { rm -f /tmp/"${netns}".{nstat,out} done } + +mptcp_lib_events() { + local ns="${1}" + local evts="${2}" + declare -n pid="${3}" + + :>"${evts}" + + mptcp_lib_kill_wait "${pid:-0}" + ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & + pid=$! +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 6d71bf36a1b9..3200d0b96d53 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -178,21 +178,11 @@ make_connection() if [ -z "$client_evts" ]; then client_evts=$(mktemp) fi - :>"$client_evts" - if [ $client_evts_pid -ne 0 ]; then - mptcp_lib_kill_wait $client_evts_pid - fi - ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 & - client_evts_pid=$! + mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid if [ -z "$server_evts" ]; then server_evts=$(mktemp) fi - :>"$server_evts" - if [ $server_evts_pid -ne 0 ]; then - mptcp_lib_kill_wait $server_evts_pid - fi - ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 & - server_evts_pid=$! + mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid sleep 0.5 # Run the server From patchwork Tue Mar 5 10:42:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582048 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 4859A5DF3A; Tue, 5 Mar 2024 10:43:13 +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=1709635393; cv=none; b=htnzt+n5tgAGt/zA7tCQBQSX6fH1VURD7zw3kPclY8BPzuCvj/jaTKcXrIQ0n+dD3nhcXwj95+1ERAD0UYxhmTGQG3vE1zrZBUwE9j4yBEpVZ2n1A+36RmeCMPB09KHWhSAMTG7dPClKPB7HI0Mi/UgmohLOhikkvzif5H9BBYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635393; c=relaxed/simple; bh=nj5zy96gmKnlenBRjur2RORmXzndyrMua5IHgdDEcu8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=amHoTYXkR770RHMi8o8AQTztTo798yzZw+COQpbMmV8aQEYpCKW1/5WVqK/ghyPJFeux4k07Lj/8P10EI3pCXDUX9ew1KwjmIv9WbNxkO5htgI6UadLfd2Hm1Ob9PqpRZ2h4R6A2R95UYypdmju0Hh/5THn/UthLf7x1hcJ9mZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kdhUdp+r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kdhUdp+r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAA69C433C7; Tue, 5 Mar 2024 10:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635393; bh=nj5zy96gmKnlenBRjur2RORmXzndyrMua5IHgdDEcu8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kdhUdp+rMqncstTrSXPCSRREM+PVrl6uuaQtHSd4OE+SG4ygsjh3ugdrMITenWMNc 4PXzHs315uK1lRBoOTgali5+Eq+G9aGCb7iFZsTIJt9t/l7QCo4bm7d5MsNsFN5pDA 0UpIBsNzl57YqNNTkvTB9UQ/veDuYgXQ4Cp6dATOpR8j514VyZrrgrbUMwzubZOyoV 8lZDy9fNUn8bsE1m1bPm7OGYEx6PXcECN1dqKYpBmGuBVaKoaZ1krUPpzIMQl+1QW7 xtKkTKzW2fYRjv5MshBuNWusSeUQ5bKN1rTZOrV0An4JMzqOWP+deKq6GyQ6lg2pme tT5YPmc5dM8FA== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:38 +0100 Subject: [PATCH net-next 08/13] selftests: mptcp: diag: fix shellcheck warnings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-8-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2683; i=matttbe@kernel.org; h=from:subject:message-id; bh=nj5zy96gmKnlenBRjur2RORmXzndyrMua5IHgdDEcu8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcd3LGWePGSG1Mlb2jC+Tsdb0YBuRXuGfR2p 6dNoqyyEVGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg c4XrEACUAERJjxSzeSF/rv5EhpTrCB2Uw22Mb0Qf+8BQ5w6lfDaHTgyQvabGgYXT7wwZqOScVrF yXwprARTG7u498tTyHTRPodty+9iYcO9AenM1M5Ub7YS4RT0A+VDf/BEOq2karzMsxaAq4cGWh0 qnQttttmrKC91fyIKdWZ9bkTnLgDTB54EOVHcoaHzz+xPWhF7pD4sot2jC4I6oBTzvA6r4ECQpe MSMRuHRVhFsArqu+5GsbcN5FfhP7hCYdjH6AcENeJSm/jeIOhiMKEPpB+SoT5bsXPgurF696lKv aLWtLSjo5UVAL4aSmYXaGWbjrlAQOvFqwHJGeCQaSGWReGl563J1+5TnExgTDbU2NKILYYSWQvs SUWdA+Yk6EpYFqhAFW9KPD0pXtBfPau9g5MyUA876KeLaVQWrPyDmzopq7Bnj2QhfO1qjSz3fk9 PaoIJL/qwVA7URyP5sOTfgsuGv26FhenkYbaG67u0zY9/1rOmt2JghLbG0Hd2LdObIm3WkQnqT9 kFI1DmwZa94qBERCe/NEzXuJmt++hwbOxfnscd4XYVAUrMIyfZYBzwUWs0l1CEP/tZmgFIvMdmG KyepIZ9ytiFIe3+nRD+/Ewls8gBpfsqGXGZOr3dCqKC69SC4rH5E4hbfC/d7RZ7333LmbnFhnaA 7BABTbNVdEw5t9w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 shellcheck recently helped to prevent issues. It is then good to fix the other harmless issues in order to spot "real" ones later. Here, two categories of warnings are now ignored: - SC2317: Command appears to be unreachable. The cleanup() function is invoked indirectly via the EXIT trap. - SC2086: Double quote to prevent globbing and word splitting. This is recommended, but the current usage is correct and there is no need to do all these modifications to be compliant with this rule. For the modifications: - SC2034: ksft_skip appears unused. - SC2046: Quote '$(get_msk_inuse)' to prevent word splitting. - SC2006: Use $(...) notation instead of legacy backticks `...`. Now this script is shellcheck (0.9.0) compliant. We can easily spot new issues. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/diag.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index 0ee93915bccb..d8f080f934ac 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -1,10 +1,14 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +# Double quotes to prevent globbing and word splitting is recommended in new +# code but we accept it, especially because there were too many before having +# address all other issues detected by shellcheck. +#shellcheck disable=SC2086 + . "$(dirname "${0}")/mptcp_lib.sh" ns="" -ksft_skip=4 test_cnt=1 timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) @@ -24,6 +28,8 @@ flush_pids() done } +# This function is used in the cleanup trap +#shellcheck disable=SC2317 cleanup() { ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null @@ -174,7 +180,7 @@ chk_msk_inuse() expected=$((expected + listen_nr)) for _ in $(seq 10); do - if [ $(get_msk_inuse) -eq $expected ];then + if [ "$(get_msk_inuse)" -eq $expected ]; then break fi sleep 0.1 @@ -260,7 +266,7 @@ chk_msk_inuse 0 "1->0" chk_msk_cestab 0 "1->0" NR_CLIENTS=100 -for I in `seq 1 $NR_CLIENTS`; do +for I in $(seq 1 $NR_CLIENTS); do echo "a" | \ timeout ${timeout_test} \ ip netns exec $ns \ @@ -269,7 +275,7 @@ for I in `seq 1 $NR_CLIENTS`; do done mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001)) -for I in `seq 1 $NR_CLIENTS`; do +for I in $(seq 1 $NR_CLIENTS); do echo "b" | \ timeout ${timeout_test} \ ip netns exec $ns \ From patchwork Tue Mar 5 10:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582049 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 0F6E65EE9D; Tue, 5 Mar 2024 10:43:16 +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=1709635397; cv=none; b=l42YLZF/jIMz9yVzobNcWGuBsqZbkUm0HwXsaXQcRYnLSNai2to/yYeT3fC/e+cowaMCiqAXSmIzMFMRvq1fOZe6899J8fs0ujvuQUCdx9mJCYoK5P7ldLddesAiHNSEjM5R7koOmwH7t+dbVAoPkq0b68zLLDuZTnPrgOD9DbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635397; c=relaxed/simple; bh=mhEfkC/t/wPrEz+EOr1rK/8ja/vlTW/cYAWnHPnxTiU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ApizjUc8KPF8Job4lK/UZj5/BXC1pdMBK4g5RqmyRorPtny68qBoXD95EPD7LJ6q/dOXhrDHMZrgq4DpA2/aYy5tL3I3LHTfRdO8hBQj2G/B/1yEypIoC71pyMJwcpLc8BVgc9DzAMSX3fFjbK2jAVGkZufnD3Xn5fnKLoLv3Gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dUs2RpwV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dUs2RpwV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B456FC43394; Tue, 5 Mar 2024 10:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635396; bh=mhEfkC/t/wPrEz+EOr1rK/8ja/vlTW/cYAWnHPnxTiU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dUs2RpwVPluC3v2nQLtFMSD1LzEkTToNs14rk3yxqG/58IM7xjq/JpuKLp2pebVKd qGIWQWDcvJQVnQ4yzoqvpurVRU2HmmruvF9yq5gdi99HoJ9kP51OR3Xcy4rCOwv/eX hZM5/Hb5iLCgoK7sVoleD0pZhV7Sk9S4I+ZqHFSd1vKI1mrqCZd4tkXiinaVQQLGvu 4Ja9f1A9fbPLj78dL9ZoTm6Oixmg+/TasfA3xpVnQS9MnWMliE0oTgvBA4W68qBivd HWtEueaXSSBlFJVRFJAHtGQJiZpSThbvqeEYWw5//8JYCuRa6ZgZzB93Ckpyx93HFG ginEqjBGfCqnw== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:39 +0100 Subject: [PATCH net-next 09/13] selftests: mptcp: connect: fix shellcheck warnings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-9-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8890; i=matttbe@kernel.org; h=from:subject:message-id; bh=mhEfkC/t/wPrEz+EOr1rK/8ja/vlTW/cYAWnHPnxTiU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcdgEurjfbnQKQLryjP1a9CVEg3Om3P7ySvs sRaqFKUQ0uJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg c5ueD/9/0p9NqkHWcrVooeck2APBzjFYUe60AVj/8GuZM8sSrvPqAmF4Dpje9dU7Beh5l5SyDVN qdsPgyxepW3PLrhr0Wl6eaj0MHIdVas45LgPa/GaGAXAcM4YRoBYiYroA6CEHHXiMEIs6PQu3Bd H0NR9vJa01oqBLLOHeqgjDygLaYfBZ1jKAR9QHR2jxMCNcnJKYHB7eeYOqYf/PTCIUA1T0neuiv oEOza7fK9J8DYv/2sjyh97Re/DGhoHQEoTd+tsAb3rSdgLk3G3F+HK1lQsQCP/RYQ5uzkoIJRIK kE6eM9O0wyg919OEj+43MJz7R5DUN7zmXY0ANNM8m6Rqdn9iyzHBu39w2Tv48h8DDT59YNBVcE4 byx7huVrap/B7nOEALNyKeVFlnwyuOeuUCvY5kS/PTkq3HFuu6Orjh9d5s4KH0dEglr+ze1SwKk qfeVkegLEqAEN6PB+B4njub6AptDYmcGHhsZ/A2/80f2j/x//ROVStUuN0nIHL0SGvxYpMOfN+L mEvwPHCGiamIrXqIP76oEvpeQWj8tn9O0OC6ebFnJRjhYti/TW7XHm6lCAur07Wz1pZ7FxjcgSZ QQVwRZfOHB1FNbBulc1vwap8vzFi/Q8JfmzZKqbSvGLv0mfwECKN60tS3sGVaTnWrW48RKHwY3t 0gU/ndFd8b+QJqg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 shellcheck recently helped to prevent issues. It is then good to fix the other harmless issues in order to spot "real" ones later. Here, two categories of warnings are now ignored: - SC2317: Command appears to be unreachable. The cleanup() function is invoked indirectly via the EXIT trap. - SC2086: Double quote to prevent globbing and word splitting. This is recommended, but the current usage is correct and there is no need to do all these modifications to be compliant with this rule. For the modifications: - SC2034: ksft_skip appears unused. - SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. - SC2004: $/${} is unnecessary on arithmetic variables. - SC2155: Declare and assign separately to avoid masking return values. - SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. - SC2059: Don't use variables in the printf format string. Use printf '..%s..' "$foo". Now this script is shellcheck (0.9.0) compliant. We can easily spot new issues. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 76 +++++++++++++--------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index b53ae64ec08c..0ca2960c9099 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -1,6 +1,11 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +# Double quotes to prevent globbing and word splitting is recommended in new +# code but we accept it, especially because there were too many before having +# address all other issues detected by shellcheck. +#shellcheck disable=SC2086 + . "$(dirname "${0}")/mptcp_lib.sh" time_start=$(date +%s) @@ -13,7 +18,6 @@ sout="" cin_disconnect="" cin="" cout="" -ksft_skip=4 capture=false timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) @@ -129,6 +133,8 @@ ns4="" TEST_COUNT=0 TEST_GROUP="" +# This function is used in the cleanup trap +#shellcheck disable=SC2317 cleanup() { rm -f "$cin_disconnect" "$cout_disconnect" @@ -211,8 +217,9 @@ set_ethtool_flags() { local dev="$2" local flags="$3" - ip netns exec $ns ethtool -K $dev $flags 2>/dev/null - [ $? -eq 0 ] && echo "INFO: set $ns dev $dev: ethtool -K $flags" + if ip netns exec $ns ethtool -K $dev $flags 2>/dev/null; then + echo "INFO: set $ns dev $dev: ethtool -K $flags" + fi } set_random_ethtool_flags() { @@ -307,7 +314,7 @@ do_transfer() local extra_args="$7" local port - port=$((10000+$TEST_COUNT)) + port=$((10000+TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1)) if [ "$rcvbuf" -gt 0 ]; then @@ -365,12 +372,18 @@ do_transfer() nstat -n fi - local stat_synrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX") - local stat_ackrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") - local stat_cookietx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent") - local stat_cookierx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv") - local stat_csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr") - local stat_csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr") + local stat_synrx_last_l + local stat_ackrx_last_l + local stat_cookietx_last + local stat_cookierx_last + local stat_csum_err_s + local stat_csum_err_c + stat_synrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX") + stat_ackrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") + stat_cookietx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent") + stat_cookierx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv") + stat_csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr") + stat_csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr") timeout ${timeout_test} \ ip netns exec ${listener_ns} \ @@ -433,11 +446,16 @@ do_transfer() mptcp_lib_check_transfer $cin $sout "file received by server" rets=$? - local stat_synrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX") - local stat_ackrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") - local stat_cookietx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent") - local stat_cookierx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv") - local stat_ooo_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtTCPOFOQueue") + local stat_synrx_now_l + local stat_ackrx_now_l + local stat_cookietx_now + local stat_cookierx_now + local stat_ooo_now + stat_synrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX") + stat_ackrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") + stat_cookietx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent") + stat_cookierx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv") + stat_ooo_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtTCPOFOQueue") expect_synrx=$((stat_synrx_last_l)) expect_ackrx=$((stat_ackrx_last_l)) @@ -446,8 +464,8 @@ do_transfer() cookies=${cookies##*=} if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then - expect_synrx=$((stat_synrx_last_l+$connect_per_transfer)) - expect_ackrx=$((stat_ackrx_last_l+$connect_per_transfer)) + expect_synrx=$((stat_synrx_last_l+connect_per_transfer)) + expect_ackrx=$((stat_ackrx_last_l+connect_per_transfer)) fi if [ ${stat_synrx_now_l} -lt ${expect_synrx} ]; then @@ -455,7 +473,7 @@ do_transfer() "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 retc=1 fi - if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} -a ${stat_ooo_now} -eq 0 ]; then + if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ] && [ ${stat_ooo_now} -eq 0 ]; then if [ ${stat_ooo_now} -eq 0 ]; then printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 @@ -466,18 +484,20 @@ do_transfer() fi if $checksum; then - local csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr") - local csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr") + local csum_err_s + local csum_err_c + csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr") + csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr") local csum_err_s_nr=$((csum_err_s - stat_csum_err_s)) if [ $csum_err_s_nr -gt 0 ]; then - printf "[ FAIL ]\nserver got $csum_err_s_nr data checksum error[s]" + printf "[ FAIL ]\nserver got %d data checksum error[s]" ${csum_err_s_nr} rets=1 fi local csum_err_c_nr=$((csum_err_c - stat_csum_err_c)) if [ $csum_err_c_nr -gt 0 ]; then - printf "[ FAIL ]\nclient got $csum_err_c_nr data checksum error[s]" + printf "[ FAIL ]\nclient got %d data checksum error[s]" ${csum_err_c_nr} retc=1 fi fi @@ -645,7 +665,7 @@ run_test_transparent() return fi -ip netns exec "$listener_ns" nft -f /dev/stdin <<"EOF" + if ! ip netns exec "$listener_ns" nft -f /dev/stdin <<"EOF" flush ruleset table inet mangle { chain divert { @@ -656,7 +676,7 @@ table inet mangle { } } EOF - if [ $? -ne 0 ]; then + then echo "SKIP: $msg, could not load nft ruleset" mptcp_lib_fail_if_expected_feature "nft rules" mptcp_lib_result_skip "${TEST_GROUP}" @@ -671,8 +691,7 @@ EOF local_addr="0.0.0.0" fi - ip -net "$listener_ns" $r6flag rule add fwmark 1 lookup 100 - if [ $? -ne 0 ]; then + if ! ip -net "$listener_ns" $r6flag rule add fwmark 1 lookup 100; then ip netns exec "$listener_ns" nft flush ruleset echo "SKIP: $msg, ip $r6flag rule failed" mptcp_lib_fail_if_expected_feature "ip rule" @@ -680,8 +699,7 @@ EOF return fi - ip -net "$listener_ns" route add local $local_addr/0 dev lo table 100 - if [ $? -ne 0 ]; then + if ! ip -net "$listener_ns" route add local $local_addr/0 dev lo table 100; then ip netns exec "$listener_ns" nft flush ruleset ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100 echo "SKIP: $msg, ip route add local $local_addr failed" @@ -844,7 +862,7 @@ stop_if_error "Could not even run ping tests" echo -n "INFO: Using loss of $tc_loss " test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " -reorder_delay=$(($tc_delay / 4)) +reorder_delay=$((tc_delay / 4)) if [ -z "${tc_reorder}" ]; then reorder1=$((RANDOM%10)) From patchwork Tue Mar 5 10:42:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582050 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 0FBE85F548; Tue, 5 Mar 2024 10:43:20 +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=1709635400; cv=none; b=NptnbmcETa/PjscLJlUBNgO3A878i9W50RBNItbNc+4JfZWgRRE0hEKsGAPIFfueWtEM/N6nrnO3/km9px/0HGickPE7LXCHcIKZ/Xl8ekQ4HDCRXpU1WxRIWe27JNS2E5tAjOsh/jxF0g7pZD4R8VgtAQo4LEDKHkbjwLAdQHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635400; c=relaxed/simple; bh=NwkktJOVOyOm11rJZM5DvBJM453FEZ9/E/K3un3haFI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N7mZrMT2zpGArkTXyw99Ymyl0pj4xQKWXm8dh0/o2Ftk0KWQ0iLs7FYqfjgrPPdFHn4+NJO4NV+Q7TOHhrLL/2v5YS8/Eh/9IuwYzyBAD0oVG8lonp7i7yonnu2/10axdpZ7m0F/oVgXMO50XyG99x0FvTmHuGOCQMm4EP1hmrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gSTaQOpL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gSTaQOpL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07DAEC43390; Tue, 5 Mar 2024 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635399; bh=NwkktJOVOyOm11rJZM5DvBJM453FEZ9/E/K3un3haFI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gSTaQOpLbM2m9FnXoiHtFSXIPYIt4OdLankiCwkXMWdRVy27AaWtrk1Eq3P283i3O JCcQnCwMMB+sVJk4A2lQ0QgnDTCv3t4d/oOhitjPCNJK5ruEm5rD8o2KygZbOSR2Fh sXToWEr0GFX0hX+i3BvgqBD4WIxMpELymhOFNZ3Bi9pLB6MjNVfwQm59dw454sv1fS u55gWslwr9SqoSfy5SF+D3wBQR78Ru7ZWBwppjW2pZ+LaVojwhoxSpvb92hnIxsqCy /Ayta7zjzBICdAIXQQVkLlTADDx0htkRnDJePQ3kPfJJCPUt0vfBa6dDjiJ0mrMwSE OggQ4LTRlmz7w== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:40 +0100 Subject: [PATCH net-next 10/13] selftests: mptcp: sockopt: fix shellcheck warnings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-10-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2750; i=matttbe@kernel.org; h=from:subject:message-id; bh=NwkktJOVOyOm11rJZM5DvBJM453FEZ9/E/K3un3haFI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcdWuaAlevIvO3ifWFKv9tGrfikFIKMdj4wt f0fW7Fz4lGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg czWVEACCKYZ+tBpEoaIRq1Z2Y+/SjIK6yEtcaJzJn5VKSfVoNs9EH/lxNN7qE6iYjGs9apkSQxp Y855JIRJwfDb+qoxQWot6kHIV7gSXvGBNuRj3tWs5hGnt8JJIEiy4kZnB3NKTMHDwgFU4ji/nHb ZCSNVr76zJP/+mIc03Jxlaug0J6th60CWwn4iHeoiU6BnLeBjt9DY0gi24rogm9hZ76/7M92sLG 8fZwf8qmLc2N8Y2ULDzK25jFEbqAJnFyR1fyrMf2vt1qiXshX+11FaR1KCsQCkGNKJ+RX3MCAME rw7nrpuUvs0MVEB7s0FgoQhD3Pz2OmVyu58C5zSGO0kNhHFntMFYZkdOR5dIwhoAZBLl6KuKAeH jlJB9CDAVCsHavRJGZBBjnBLdkiOSTnkAI6cIBgZBSCGrbDi9uaMwrgHwN1MEQemptP+JUa7zOp m1zJxo54PcZI/KsM1V8f01M+z5+G81yUodLE6idzqD83p1Std4p6R5Z9zESMVgM5ND2/NCQleyD ArHWyqoOjy0/XLTI9lIhMx9XD0RsXHgLkxKPNLwPaEUGxX6Ix0w3JpBbdMtKwbmRI4kJQhA2068 3chMa396dymrTOw8DTtQNTwTm+g8H1LBtbgff49NI2ZofAB8lhpMy9aKn8hc6dXp7URgmbvRvv4 LWCs+Og5hHlmhGg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 shellcheck recently helped to prevent issues. It is then good to fix the other harmless issues in order to spot "real" ones later. Here, two categories of warnings are now ignored: - SC2317: Command appears to be unreachable. The cleanup() function is invoked indirectly via the EXIT trap. - SC2086: Double quote to prevent globbing and word splitting. This is recommended, but the current usage is correct and there is no need to do all these modifications to be compliant with this rule. For the modifications: - SC2034: ksft_skip appears unused. - SC2006: Use $(...) notation instead of legacy backticks `...`. - SC2145: Argument mixes string and array. Use * or separate argument. Now this script is shellcheck (0.9.0) compliant. We can easily spot new issues. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 7dd0e5467d35..6ed4aa32222f 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -1,6 +1,11 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +# Double quotes to prevent globbing and word splitting is recommended in new +# code but we accept it, especially because there were too many before having +# address all other issues detected by shellcheck. +#shellcheck disable=SC2086 + . "$(dirname "${0}")/mptcp_lib.sh" ret=0 @@ -8,7 +13,6 @@ sin="" sout="" cin="" cout="" -ksft_skip=4 timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) iptables="iptables" @@ -41,7 +45,7 @@ init() mptcp_lib_ns_init ns1 ns2 ns_sbox local i - for i in `seq 1 4`; do + for i in $(seq 1 4); do ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad @@ -68,6 +72,8 @@ init() add_mark_rules $ns2 2 } +# This function is used in the cleanup trap +#shellcheck disable=SC2317 cleanup() { mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns_sbox}" @@ -257,12 +263,12 @@ do_tcpinq_test() local lret=$? if [ $lret -ne 0 ];then ret=$lret - echo "FAIL: mptcp_inq $@" 1>&2 + echo "FAIL: mptcp_inq $*" 1>&2 mptcp_lib_result_fail "TCP_INQ: $*" return $lret fi - echo "PASS: TCP_INQ cmsg/ioctl $@" + echo "PASS: TCP_INQ cmsg/ioctl $*" mptcp_lib_result_pass "TCP_INQ: $*" return $lret } From patchwork Tue Mar 5 10:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582051 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 CD7095F856; Tue, 5 Mar 2024 10:43:24 +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=1709635404; cv=none; b=bxBswG+oA1c/EUp02F8gtWYGg0C2FgHrLG+9T4KzBVqhYxVBoo1zwdb7OEp0ZDWzQSBMGEFJ3GlGtH1SXsQiPeGjsMnpxw4+DGEm4pQzm2ZydSVJ5GrTbRkihJ+jmpAgYg1bv1lc6XLuwPjOEmgUwlsriiB9xxO6SEAfyUIDl/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635404; c=relaxed/simple; bh=jTLgdGpKQfPiNeklV9atb8fDhX9KNQWViIOBx/XoGv0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mKtMTpxVDafWpEttanJBjBGbogk7ewK7WTMWinXv+ydYtXXYTFa9vkDULl7ZbGqM46J1O43TlLaR61A9HXffSW+JuyMDf/tH9kXF0o6NK7UaN6Ip8MqTE/mCEfsxk816NOts+nuGJl1+Tm2NRXZku4YsYrDQeKf4FNuHLksBiXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TkX4hHEA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TkX4hHEA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A6DC433B1; Tue, 5 Mar 2024 10:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635404; bh=jTLgdGpKQfPiNeklV9atb8fDhX9KNQWViIOBx/XoGv0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TkX4hHEAMClVUn5nkuG5bKcrNOWmUZP7Qk64sESHK0pPhjNrzXUoh0WG6V6GZizZo fUYHbEI0jtC8x3B66nQ9TLDm+GbtX4dl5ajCSNQHOKKgH6FBJgGf+dOeREJCefcMr7 G4v6WTrzon3H4QQgMIO35XBv5dlWSNArRAHFJ/PyjdPHQa1J1PgD4KPc6syje8Ur4N MIXKJiTRyewLqzRnsOopGfmycONRuypVOSWLLamCC3HtRYELFJSuFD1PjtJumO2LdZ x/kHR3rVZHxV/6bEeD3QrIFo/KIpj9qv9gKlzyDIBOE2JJYVXWrHps+JzTYhJa98J+ R+2NLfqV02ZcA== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:41 +0100 Subject: [PATCH net-next 11/13] selftests: mptcp: pm netlink: fix shellcheck warnings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-11-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2721; i=matttbe@kernel.org; h=from:subject:message-id; bh=jTLgdGpKQfPiNeklV9atb8fDhX9KNQWViIOBx/XoGv0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcd0nNYXiB6l2gK9AMj8z81KZJvYD2h/Kcwp o8JFWhK546JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg c1/xEACpHrO9MASyiQCrywtvnuF8Lo5h4lBmRPGQcbLqVmrLGLVKzjADDr1QbIuavPw77HxnGPT KB1+v8cQ2BM0YlQ+/tAemy9vy+0yVJ+25UPbyesNf5bjnllSzYvzbliC2WkDZnB0DO6Xk+SRCtd 0P5Rea6iJMK2y/fKMS/SbD6jNEDBKWh0KN0kERmjJMpGrBa9u5pMM/DaQKZ+M1BJ51uCNHPHBx0 tFbc+JxqqhgsZsRrM3/OVr+isEpl/D/dzOk5PT2vtMEgKdQ1LDb2W5uxliW4c6/zP2UWqLqiOiz 4IxcmcCb/mDeXSNn9VP4Q5PkTnuAcVj3bwzba4O1AE5M4Vdsah9Zs08UWET41MPUF8KU/6pqa2x N+3jrL6gDWZZyiPqbkfuUzwiQo07m+s4tnQJN6lDIfNQz76ugJ12nFii8PlqS9cLB1HXqWlkN1S aeoCi5RzewaFbBFjZHd6ob5gopZ6e6uzbAIuhbUZtNHPGFURn2bRvh1+keDaDjTQ361WICPbfoY ZaAznn+nY5B3oT0XvN7cblT+gZSfvCyQ1SYIj6Nxd8I6WQZda9Tmdo5dA6J2IprQJ7Kc38vtSCM 0xY9u/+b+M7aS2JKBTNuhIQOBL5VUm6TJ9QGa3djffgkEjkq4kLRLOGuiU8JxjTTnkhprKtf+hO 8tuXecsCBFGyzmQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 shellcheck recently helped to prevent issues. It is then good to fix the other harmless issues in order to spot "real" ones later. Here, two categories of warnings are now ignored: - SC2317: Command appears to be unreachable. The cleanup() function is invoked indirectly via the EXIT trap. - SC2086: Double quote to prevent globbing and word splitting. This is recommended, but the current usage is correct and there is no need to do all these modifications to be compliant with this rule. For the modifications: - SC2034: ksft_skip appears unused. - SC2154: optstring is referenced but not assigned. - SC2006: Use $(...) notation instead of legacy backticks `...`. Now this script is shellcheck (0.9.0) compliant. We can easily spot new issues. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/pm_netlink.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index c7c46152f6fd..427fc5c70b3c 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -1,16 +1,20 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +# Double quotes to prevent globbing and word splitting is recommended in new +# code but we accept it, especially because there were too many before having +# address all other issues detected by shellcheck. +#shellcheck disable=SC2086 + . "$(dirname "${0}")/mptcp_lib.sh" -ksft_skip=4 ret=0 usage() { echo "Usage: $0 [ -h ]" } - +optstring=h while getopts "$optstring" option;do case "$option" in "h") @@ -27,6 +31,8 @@ done ns1="" err=$(mktemp) +# This function is used in the cleanup trap +#shellcheck disable=SC2317 cleanup() { rm -f $err @@ -91,14 +97,14 @@ check "ip netns exec $ns1 ./pm_nl_ctl get 4" "" "duplicate addr" ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal check "ip netns exec $ns1 ./pm_nl_ctl get 4" "id 4 flags signal 10.0.1.4" "id addr increment" -for i in `seq 5 9`; do +for i in $(seq 5 9); do ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.$i flags signal >/dev/null 2>&1 done check "ip netns exec $ns1 ./pm_nl_ctl get 9" "id 9 flags signal 10.0.1.9" "hard addr limit" check "ip netns exec $ns1 ./pm_nl_ctl get 10" "" "above hard addr limit" ip netns exec $ns1 ./pm_nl_ctl del 9 -for i in `seq 10 255`; do +for i in $(seq 10 255); do ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.9 id $i ip netns exec $ns1 ./pm_nl_ctl del $i done From patchwork Tue Mar 5 10:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582052 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 EABCA627FA; Tue, 5 Mar 2024 10:43:28 +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=1709635409; cv=none; b=dCX1RmAbdmcz1uFvCyXRV+/oVMo3MT8yf7da7Z9ne5ZKTYFPD1/bi2c7lGUa6CH9w3MVl7UVt4GXi5IvzsGOTMdlYbTQ4mdgnyGZNPBH6flkcAxkINNehaPHC0bkc+KnScaorxOvI3Z7xntYBWO+3WKh7tsNnn/aSpBpnkz3ZsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635409; c=relaxed/simple; bh=QtfJT5E6kufllfcFPKcwgPK1Il9pci90VCMQW43RTRo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MpdvxPE32xLD1x1CH4+LQBe+Xk+sDlCXIq62jy1Ifvgpv07l538Cw93UIp4pVA5IwTMqvrbtGQPeSCCBxqtQB/pdc1B3z7U0rQkAMc3wvUrBdPApqh8gq+9gd41wAWCCdrAvJZndd1XWopghi+FmCFa5N2/JL8RpddzD00TTXuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZCwGM0XE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZCwGM0XE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E372C433A6; Tue, 5 Mar 2024 10:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635408; bh=QtfJT5E6kufllfcFPKcwgPK1Il9pci90VCMQW43RTRo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZCwGM0XEt6P62ijtQFD8qpzWeflGR/wBtGc5n2PgR4pYkpO7vjPambe44QKg5bDmE 0dyeDR/65PiMgWBPoG5f5fq0heVKmJ/QYLuB1+Cnr7SgQfEa1MabbfKOWvtZQLW4Nb pYssD51obEpexmryr0xBUcA0CctHkl6gzxvXIKphPhDzb4Jz/jrVUp0q81jr2vO1g0 d4s8GGmOIieMwvbmUWQo51AIuOBXkWdyRMPcOzhmqW+plJ4Sad23/Px/cKftOYYtXn 5tp2vXbE0af4qu1j1boRpzOXKjMALNfHG+F7Il932Pwn20z8Mtucq04RQiJ3t8riVh 5qhZuCckbmfmQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:42 +0100 Subject: [PATCH net-next 12/13] selftests: mptcp: simult flows: fix shellcheck warnings Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-12-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2107; i=matttbe@kernel.org; h=from:subject:message-id; bh=QtfJT5E6kufllfcFPKcwgPK1Il9pci90VCMQW43RTRo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcdd5How8Yc22x+ON6/6wV9gS4fvwjKhJb8w b4wUPFNineJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg c2X6EACgvvfo2GzCA1eyXyCLnYa2KLuKWCUIe9KChl3U5IBG+sTXrOhaGYmVOs/YyuPeHK9KPtT Iv8sE0cOpWJluKhyYIlAq/aXSm6BDgY1rjUZdGsgQEeIleCPN95yY5/6ZSHDXH3eMDuEfp16sbM oS6imX2b6zrlQG1ZGKfewzp4JTfJVDm7vZluuzmZzJJeBtPEhs3UAe8Lu+IMAsrgZvP+9I5YxB3 PTCBTZU8CCiGSltb1nXtN6VB08f6lh9g/iapSKeLobBWLfBu/mtAZzl7NkGiCJqFMKPmdNpgIo6 z6PK0S+PK2oN5paChr2/Lk7RoTxgpvxqar3m8OBITWjlBqNQeR0GYK5ETw1JtPLnj3sCCfgucEB qBNag5JZz4/1inIhYSkq9q+WsI3TWe67FvtiYRAwH6tA3QXSS8FTTernqB6KsIaHWEG8FiN4pKS v6KI61DeV6ciPxPeiwkoanBpk7FJzbdJMP791CEXKAlOQ9TJrEp65UV43/82uxc6HJN1lK4H01A yxty8P9sKLB1oBs+zKnR5bLN00k1AupwOA6r7a1m+VqkI4aY80+nvWdiXoc2n+twTpcYxXSEuNx pF4GoOu+iWTbXxYEfZaw0m8393AADgbdrEaVEcx81bn2d/MPWO+HHY8lPnyGuCj8//j8ly78jVT J5Ahl5qupPIEr6A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 shellcheck recently helped to prevent issues. It is then good to fix the other harmless issues in order to spot "real" ones later. Here, two categories of warnings are now ignored: - SC2317: Command appears to be unreachable. The cleanup() function is invoked indirectly via the EXIT trap. - SC2086: Double quote to prevent globbing and word splitting. This is recommended, but the current usage is correct and there is no need to do all these modifications to be compliant with this rule. For the modifications: - SC2034: ksft_skip appears unused. - SC2004: $/${} is unnecessary on arithmetic variables. Now this script is shellcheck (0.9.0) compliant. We can easily spot new issues. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/simult_flows.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 5a4b83cdaaa9..365fb3d6ef55 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -1,13 +1,17 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +# Double quotes to prevent globbing and word splitting is recommended in new +# code but we accept it, especially because there were too many before having +# address all other issues detected by shellcheck. +#shellcheck disable=SC2086 + . "$(dirname "${0}")/mptcp_lib.sh" ns1="" ns2="" ns3="" capture=false -ksft_skip=4 timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) test_cnt=1 @@ -28,6 +32,8 @@ usage() { echo -e "\t-d: debug this script" } +# This function is used in the cleanup trap +#shellcheck disable=SC2317 cleanup() { rm -f "$cout" "$sout" @@ -120,7 +126,7 @@ do_transfer() local sin=$2 local max_time=$3 local port - port=$((10000+$test_cnt)) + port=$((10000+test_cnt)) test_cnt=$((test_cnt+1)) :> "$cout" From patchwork Tue Mar 5 10:42:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13582053 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 AAFC262A0F; Tue, 5 Mar 2024 10:43:32 +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=1709635412; cv=none; b=feUXBZQIyGh7rAMk66Rc6W/bPbotj8awzTeYs1h00BkSerxq9Tty4ifY9Dr4yLl/KYii4E3MbEoyARN6HGfyNHZ4brsKgWmT1CwtLEeatVSSDt+y5xBRSHY0t/J+Ih5bGh4v3puTo7baD/cc0JwCfhpANyjeQIpsOiIjYnJqZMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709635412; c=relaxed/simple; bh=TXr6T5gctPLk+weuAPDK0CvjU5ZW8VNUAi1/4q57pf4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X5HmHNeYjad11w9aADxzAHtVI1tiYOAicIrNYcetS3t3lCpSooUJ0oKeGlkZGFdW9DSKhTtICIAXE5Uis8526Wfn4CxwXL+lbPeUcQFpz50Zb5q46l7HpmqU4BjWrz82Uij6nra7SJI2KEEVWfMV+KZx1zv4fRl+cqKdKXljDzM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z3xr6nd8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z3xr6nd8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0665C43390; Tue, 5 Mar 2024 10:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709635412; bh=TXr6T5gctPLk+weuAPDK0CvjU5ZW8VNUAi1/4q57pf4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z3xr6nd8OG2diHS35Sun6lQrVCP54cyxSEd4HvDucM4XZ7Lr8zqeqJ02UZpl2Md/x hmiIaKDefnhqvqd5uDoIsrdm+iSYJWI6HLTIey2yhv8i3sddQ0727t8qptOFucttNU e38+geUzX8IgZ0+q6POWx9Ws+b4rVsY2ildKn7Zw4wmdewBqvlNck5Y2VV5yal875O twJhRpKX52VrlX5id37RwaJQZDzXXFh+9bVPcIdIrB9vpT/vEPWNXw7/5WkW2mbto7 sOLHHTw6m2LjCLDJZ5FhtV2mnicq5ZhYCjn1xm07bQzrUByaH7/dkl29wWtf+GVbsm nnpc8UlDMPZoA== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 11:42:43 +0100 Subject: [PATCH net-next 13/13] selftests: userspace pm: avoid relaunching pm events Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-13-66618ea5504e@kernel.org> References: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v1-0-66618ea5504e@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2205; i=matttbe@kernel.org; h=from:subject:message-id; bh=TXr6T5gctPLk+weuAPDK0CvjU5ZW8VNUAi1/4q57pf4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vcdWvZOlF2dPM/bD8EnzbOzzLBJwJOoByS1P 3r1cAhJyQ+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb3HQAKCRD2t4JPQmmg c4+5EADm9uVDUc6EJ98F/z11Xr2mgCzFqi6CL43XvSyGOX2H9WUjRqBpXarILE96pJKA0UqTBud 4HmdnxUonGh90yAdafBjv1euH4YvmFcXytveabyynQGhCiTlzBLYivAzRosBvMualqwYleGuyRG 9zidzrEbtrX/7veysAJKcmt/FL+bhPevPZiluISaVG+4RAyPcg9+t6WXOX4VEYzJoXz/3bfyWsv dkjliFqmtY48uUDXNo4mSZtmosKYw/T9Nc7JbkvxKYIeEUp7MnhADjl7NMUU+Og0ekR4Nilz5Ms jJgVfeZDqgGBsG8UFCQKlIWugY2N0VTmztjNSxc9L2XZZawoRo5kjwRab5Pnu4oLLbmPUH9AmJk iyMrZS81zhAAIndOYMMyihupT8qtainXlGsR23p9Ob79Kc8scwwNFO3TF3agFrBlnDM6v2bMrof qNBr/EYSSRyCxVZT57pijkWzAzN3wKWCkqMt+QN5VQSDvwrNYKSLNZAsgxBqpsADyYo/0fx49oR pJD3aU2Xm0MMooFItelhJ9TB+5tVY4qVj/g8UYwiY0iKwRe/5F6TZDmf7phc9moYHeSTcfBh61I K5j1PWe+gcLNGDXfPgKDGEpPlhf43E9YJLBSjgzM0YbXcxcSDFHJJmRuU91EeetOukvKlRtTEiQ AmeOZFiLFh7j2RA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 'make_connection' is launched twice: once for IPv4, once for IPv6. But then, the "pm_nl_ctl events" was launched a first time, killed, then relaunched after for no particular reason. We can then move this code, and the generation of the temp file to exchange, to the init part, and remove extra conditions that no longer needed. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 3200d0b96d53..b0cce8f065d8 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -149,17 +149,23 @@ ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad ip -net "$ns2" addr add dead:beef:2::2/64 dev ns2eth1 nodad ip -net "$ns2" link set ns2eth1 up +file=$(mktemp) +mptcp_lib_make_file "$file" 2 1 + +# Capture netlink events over the two network namespaces running +# the MPTCP client and server +client_evts=$(mktemp) +mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid +server_evts=$(mktemp) +mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid +sleep 0.5 + print_title "Init" print_test "Created network namespaces ns1, ns2" test_pass make_connection() { - if [ -z "$file" ]; then - file=$(mktemp) - fi - mptcp_lib_make_file "$file" 2 1 - local is_v6=$1 local app_port=$app4_port local connect_addr="10.0.1.1" @@ -173,17 +179,8 @@ make_connection() is_v6="v4" fi - # Capture netlink events over the two network namespaces running - # the MPTCP client and server - if [ -z "$client_evts" ]; then - client_evts=$(mktemp) - fi - mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid - if [ -z "$server_evts" ]; then - server_evts=$(mktemp) - fi - mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid - sleep 0.5 + :>"$client_evts" + :>"$server_evts" # Run the server ip netns exec "$ns1" \