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: 778161 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: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: 778160 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: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: 778159 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: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: 778158 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: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: 778157 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: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: 778156 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"