From nobody Fri Oct 11 21:01:31 2024 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 1CEB619B5A1; Fri, 7 Jun 2024 16:31:17 +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=1717777878; cv=none; b=MhgSCXg9aSE3XkiwX+A5mLOu6VSqn0wcijGLC/4RxbpfjFm+Db8h7eL3WKXWylJSIkuAZqvlq77kqM750S0+AdzCTVugAfs0PFkx0wwX9PaKFFyQ04YWj0JHQX1wwYjzKDYgqojvFSjrReKOyg1GVH1XdAnSJ2iJ3XmX2OZTp2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777878; c=relaxed/simple; bh=fYt4PaaC7RD7kCNYM/oIuTd6c2zrPeCtLWUrgb6Sp+Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=guTM443aty7A/jtQz294uWsKG9lR4KBsWrksZgjkkyM9V132p/6yE2DbHglfbBDx8n3vHpqrNqHLGBLnUffe9DqRlIWmWcrbDiNY3/APgyoQMHGPRXMXTkMpMJCJqC0/9MwF5AgWrK7dmUFfxKRpqqdFrFS2pc0ia/UKpLWNZzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NZeJOwBn; 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="NZeJOwBn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ECD2C32786; Fri, 7 Jun 2024 16:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777877; bh=fYt4PaaC7RD7kCNYM/oIuTd6c2zrPeCtLWUrgb6Sp+Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NZeJOwBnq9zEi4m8mJltGqaxIoLEWvUblXilotDN9VEJfkIpoB6tEzsI3naIeUc+c 8MU2pDz6npKH4aMyrb4QIceX0Typm+GUSFYfd4PQ9ziUQAwEGQzr5LTO3wpRt8qgA0 KL5P+lJjN7FC4BC1sWkJSmzKaRqdpXf5SQST/wu6Bp70HRbVwd93xYy0fHzCoy1Bf5 SQShnaybj1814IwDfOhhuTctAE3oRBflstZBkc2jbepBQbAS5NwGdmtKawdpjFGuv9 HWeWSelwsou99pR3PIumQ22qrqTj3A0DP7HyhCfHWV6VGdXQl6nH4pirwm3G18zTD7 3ga8FbflmH2MQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:02 +0200 Subject: [PATCH net-next 1/6] selftests: net: lib: ignore possible errors Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-1-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=1114; i=matttbe@kernel.org; h=from:subject:message-id; bh=fYt4PaaC7RD7kCNYM/oIuTd6c2zrPeCtLWUrgb6Sp+Y=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYzXP4whqHAe8UikCsoFniIMddqS3mBG3zRfPh Nd796vYCEGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmM1zwAKCRD2t4JPQmmg c4XbEACZ/DkVHJ1xmqNVx8QUpeZX8p8Ekv7RWcll48q8DiyMGuCra1qj+grt5urv3UdudUc7OWV KIheHt8qEiQBkKY5+ulcObRpKcwVcXsE6OkhmPUNNHz60DrXLW3/XaKqnKCWHv2PZSQgWY8wxEb 9XmgMby/VfKUIVgsrGiXyH3+opVa8j6il4wA+73EAW9u6RaY0TJHb7oRPvO1AghpZZrcC58qnil 4inqeX91s9cXYdk0+fVvO++TMXeaD73H/Bj3uEt7Be1yXoi1lCzdL2lMD4UChQtwphe2GesZPd4 n79JtyQqyBmPWDJP6Frb0sKc0mwldTTw1tNaq/kmY4xnJyLV5FnRHhhSTddWj2rnf1Ps76eJuks y+ldr9yJj+a80I1h+2MpNsW7Rn1Cu8ueCcovULccdnldOeyG+RK3jTaUmGvGsMTV87GnV8XMgu6 5hWcNqgLPh7hbKr69UjcAo+1NqzE0TwccCEvgZpWjwirGchx7Oevg5XUcoGwnFc03WIBEymCGbJ K7gj3K0TmxJpAMWQhmlvkrF6GXktTN0KUmWbpjIXvYtP+5b3Q0KUJl0nfsqEd6LwfQC9kJ5r/+1 2jGZtzaml70V40DtHKgoYMnGLicq7XuwdT2T4uSJ8fnCjXkKcsgbHalx4YNjlyikaatLSmT1k0/ amfNEKFPa+ZoaXQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 No need to disable errexit temporary, simply ignore the only possible and not handled error. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/lib.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index 9155c914c064..b2572aff6286 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -128,25 +128,17 @@ slowwait_for_counter() cleanup_ns() { local ns=3D"" - local errexit=3D0 local ret=3D0 =20 - # disable errexit temporary - if [[ $- =3D~ "e" ]]; then - errexit=3D1 - set +e - fi - for ns in "$@"; do [ -z "${ns}" ] && continue - ip netns delete "${ns}" &> /dev/null + ip netns delete "${ns}" &> /dev/null || true if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /de= v/null; then echo "Warn: Failed to remove namespace $ns" ret=3D1 fi done =20 - [ $errexit -eq 1 ] && set -e return $ret } =20 --=20 2.43.0 From nobody Fri Oct 11 21:01:31 2024 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 D0B3219CD09; Fri, 7 Jun 2024 16:31: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=1717777880; cv=none; b=B8ddteLRdaql40z1KBV0bbJ1Z5j3qksVzWPhA0ktBRlBcsPMKrPR6uPWCKpms2gapqSlpH6AS7XPr51X16FH4Y4CW3Ag2MXNcM+HHxyXslb4QkrIghGebOVZE+nwav0eSVT9GDAHzEABcTYz4V1KIY6H3ycQIasj7OLarK4jgoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777880; c=relaxed/simple; bh=6RbGhN+bMcZIq2/c1ke5bRnZvFJErPXvE+YV49BWdw8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qP1W2C4lK/5a8CveLP5ZfH7KTFrIpSPaulEv7tU1n7XROpFbqHOwEzu10RwxkFislSYRoRc2Tf0HQJDAox/7y/7BdvPPBag3kmXH9QR8oSTnbzxccQyr3+fUO3/3Z4fH2ZuvN4qiUREiawVLEkp8FqsJiGDuLefxbHPhoy1ZfkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MH3KD0JZ; 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="MH3KD0JZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11AF9C4AF07; Fri, 7 Jun 2024 16:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777880; bh=6RbGhN+bMcZIq2/c1ke5bRnZvFJErPXvE+YV49BWdw8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MH3KD0JZQ7GSmKO66p3wQIZj+HD/W+UQYq2R3rr62t2FfopSDhclXelkVoyPsesql 5feMll8PGliWXsiDZkVRAP0a/f7n/hMgZDQCOD1bi8R508BToVkuQNM+jZwldhU5m3 Q4ZEbFryCiOzED2Ux2en3K5F/0inf650+Amyexmj5DVkqBx8Bq1csF0b0oh8fs9WDk zLt/gkSJOH0WYZnqjIZscsPbL1w4X2nRWRMnWbFMIs5syi0e3dgruuaQO+Wgr60lS3 243uUoZZ+AnuzJ5wF80BHuLKINHsmnapGkJDg5IsrN8LlIoErq7WGYzcHoj9JZfgR3 9pH5mqPKmD+zw== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:03 +0200 Subject: [PATCH net-next 2/6] selftests: net: lib: remove ns from list after clean-up Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-2-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=1913; i=matttbe@kernel.org; h=from:subject:message-id; bh=6RbGhN+bMcZIq2/c1ke5bRnZvFJErPXvE+YV49BWdw8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYzXPn31eceTTnBcod8YZ+ik811HIoVAJkhvyb 1w0KPrwq2yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmM1zwAKCRD2t4JPQmmg c/ioEADulHeuQZQ3bKc1CTRM6WTJSmbbMWKj/7+qydn4avmXXYV3yiVP4kns3MDInMcONoNg6by 1jPLyJvcfR7t5Y2ldOnYj0YWG2MTh31o+aV2/QFarCk2Vucf8Ytm/YgCCRfwphIR823Km0hnWth L2zGnAELs/fu1GMC3cbM2D9U5tdzl3RZhfGIcPeQ31mk+EilMVOfuo3R+LJyUf5vA9gi+SuJN75 i2WPjR5F1NbiImX7eDmeRaw+kp41RO4YGbjVJ5H1iVC9Xnlk2ikQvx89a7VS2Lze8E5BNdtrjI2 Ogvc/OsEpEU56xD95oNkecPD6niJM0Z9kZM1txKS9H+V8VEdd5CFN8kIDKSa07yDAoKpTWrZZ3b KrTZzVCzLOzlPRjHUzr02AmfOMViUIa3zcxHfZInQpPCYRIYiatxQcTGuepuLk6l5zG9gzNyQhF 49abufmBSE8FRrNbDTKVMYOoUeSHQ/Ne0OolOo64xSQ/YxRGocwsD1FBsiEUD2bzePLQqHZ5B2V LB4NYuYQDwWqBATOMFrJHzKucR8Mi3UDt4qLGfaXR4/PI42AZEUvVBw4xo4FYx6ff7sCCPVQ8Vl VZ0ITURh8XgS3KiwYp/XwrvAXS9uZRrGTzT6dH6tLXqrkCK+RNeQqdEE1FkIERyNJwtrYDU4kDm Hv7mJV+J5zJeE/A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Instead of only appending items to the list, removing them when the netns has been deleted. By doing that, we can make sure 'cleanup_all_ns()' is not trying to remove already deleted netns. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/lib.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index b2572aff6286..c7a8cfb477cc 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -125,6 +125,20 @@ slowwait_for_counter() slowwait "$timeout" until_counter_is ">=3D $((base + delta))" "$@" } =20 +remove_ns_list() +{ + local item=3D$1 + local ns + local ns_list=3D("${NS_LIST[@]}") + NS_LIST=3D() + + for ns in "${ns_list[@]}"; do + if [ "${ns}" !=3D "${item}" ]; then + NS_LIST+=3D("${ns}") + fi + done +} + cleanup_ns() { local ns=3D"" @@ -136,6 +150,8 @@ cleanup_ns() if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /de= v/null; then echo "Warn: Failed to remove namespace $ns" ret=3D1 + else + remove_ns_list "${ns}" fi done =20 @@ -154,17 +170,14 @@ setup_ns() local ns=3D"" local ns_name=3D"" local ns_list=3D() - local ns_exist=3D for ns_name in "$@"; do # Some test may setup/remove same netns multi times if unset ${ns_name} 2> /dev/null; then ns=3D"${ns_name,,}-$(mktemp -u XXXXXX)" eval readonly ${ns_name}=3D"$ns" - ns_exist=3Dfalse else eval ns=3D'$'${ns_name} cleanup_ns "$ns" - ns_exist=3Dtrue fi =20 if ! ip netns add "$ns"; then @@ -173,7 +186,7 @@ setup_ns() return $ksft_skip fi ip -n "$ns" link set lo up - ! $ns_exist && ns_list+=3D("$ns") + ns_list+=3D("$ns") done NS_LIST+=3D("${ns_list[@]}") } --=20 2.43.0 From nobody Fri Oct 11 21:01:31 2024 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 B4C1619D086; Fri, 7 Jun 2024 16:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777883; cv=none; b=aAEH9OSQ5GM49CPxhYKAYYBVvhV2U8VjYElrZsygZ5scEN9UwDNlnzkVxQ6RzxRHJ+wl43xvjPaOuoyduj9M4zgixoO+nEjm4PtU34sgQJOc/tHw0OKa1sP8d/xTiYXNcaGMLmWNd594FUXMuVJvjZZ4iR2pzbnuVnidHG0k0hI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777883; c=relaxed/simple; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WgCos98DK9yJUPtHRMZIIqW/uDU+aYiN/cLTOZoUKUJXHCcJi+lVElNexD1xlRJ6XImTa7LCaRitjJgZDVMWjBgfKyZG4O/A5Jk19ife+KGnnv+f9mESe8qoch2RlUnIIGA6e+K1t7oB1IFKj7LQEXEWVrpuLkZvcUd13nAuRYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SzKgewzc; 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="SzKgewzc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E49FDC3277B; Fri, 7 Jun 2024 16:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777883; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SzKgewzcFNF32RlgUw6Umri7LeDgOGpHE6JurGv11qO0PQ7tlpHuXGZpMfKJGBJol rDaAQ0eNuAD8ixbfc9wWFr1eLLRdr4Z84u4conjQVIjHtO9Zf9eGVbh+L6fYlBToJ/ 4hO0G2ZUz/XQ0d8marXn3xoZEZaznnoJT7sRyueHJgUBeOGGN1F4RfESfGh5z88KN9 weZPmNst9snwy4/lLUMyhY0Y/x4av1b7E4UL7e6YyFQIL+o7da9gMzPMrBnjhRHkJu JwZ5d540XXyj+DG8TU5UQ9aXKPkNcNd1QXDvSFtI1nv1FEWEk6dgpTZax2GeAFxCkZ sWxzLzBSfP+ag== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:04 +0200 Subject: [PATCH net-next 3/6] selftests: net: lib: do not set ns var as readonly Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-3-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=1425; i=matttbe@kernel.org; h=from:subject:message-id; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; b=kA0DAAgB9reCT0JpoHMByyZiAGZjNc+g+wpgVr54enYiE3MSQI9jbS1MMPC63CqfS0ScQ0nvy YkCMwQAAQgAHRYhBOjLhfdodwV6bif3eva3gk9CaaBzBQJmYzXPAAoJEPa3gk9CaaBzkcYP/Rzh 85Zlt1I6xcrSsf3+TPwS7H/AxPlVAV5RGb3na/7sbAx2SmbZPvjhjAqv1wPQ0g370JZnJ0bL6aD /NSCQQ/Us5lx05oJc7rI5uSrEyIbdAwXS4jgwaSMA7RSPmVMVN+rz8WgSe7HUU4NqY9P2q2Yrtb z+pBx7PP154tYLkoGUNupj94PCaE3jbkNXGLAxQv7bGJGfJyZvCu0VFF6n+nPmfWcad6sFMw959 BlZLyxZQcBTQ04J7TKs6Hjv3fUvcf+JqjP615+pKWp1mRNZJIwZppRyF1llO4Od2O54f01Agxsw bclkHb3CZ1eYKxJP1619yomF6F3+O4olglcI5vRk4bx9JZGxL36DR1sb2tbYqhw/DUtrwkO8HCU z+YILY+09zrEg92v01XS+/N/v82PB9xuFJcGID7lKN0jc3P7HHBe2bFAJGcx9R7cKL2vB8EYKk+ dte8g4xkqqrREJ11X2FcemVjQbNhLxsJws9szYnt7iBtS2LydgR8rg7Ws+ffNNLGMpE0X17ZkFX cQ0Iqtb55seWu4vfsRTCFV1OcGuhq1Qzznu+OoYpYEKmKiBgbcW2fYiAPHD5Bgjns6cCRkcQ/VG ftFDDPDQiWGMEPHSSNbWAPJdBb6sPI1biTwqhrIDp9Kqs0vhQeJgrkhCP6seRNuzxP1xWV3VqyY T4Wuh X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 It sounds good to mark the global netns variable as 'readonly', but Bash doesn't allow the creation of local variables with the same name. Because it looks like 'readonly' is mainly used here to check if a netns with that name has already been set, it sounds fine to check if a variable with this name has already been set instead. By doing that, we avoid having to modify helpers from MPTCP selftests using the same variable name as the one used to store the created netns name. While at it, also avoid an unnecessary call to 'eval' to set a local variable. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index c7a8cfb477cc..114b927fee25 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -172,11 +172,11 @@ setup_ns() local ns_list=3D() for ns_name in "$@"; do # Some test may setup/remove same netns multi times - if unset ${ns_name} 2> /dev/null; then + if [ -z "${!ns_name}" ]; then ns=3D"${ns_name,,}-$(mktemp -u XXXXXX)" - eval readonly ${ns_name}=3D"$ns" + eval "${ns_name}=3D${ns}" else - eval ns=3D'$'${ns_name} + ns=3D"${!ns_name}" cleanup_ns "$ns" fi =20 --=20 2.43.0 From nobody Fri Oct 11 21:01:31 2024 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 B252D19DF64; Fri, 7 Jun 2024 16:31:26 +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=1717777886; cv=none; b=Jhov5XR0F+GELwkl5PKtDfrBgc8tZkmC1y/zmiSLPqiFzghEJP7mZ1wvBG2+9S5nGCWw6//+B7w5pkl9ebxY4K/JCaVH49WU6jFOPfATUGPuMzQuKyO8uIy5mIQyqCwRlTdTQeSuTrFTO17Mv3BcC6KCIjicLZo+jpON2DCxQBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777886; c=relaxed/simple; bh=nRfiESxrDrocYFxIB1Kip5qknfzCi1RIKTdtLiW5IyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kKJITFjbzbaOMWFfUBoo9AwqCqwQMlDl3DrPDccXj0JgxRwOQuXDjsYisdRthiEPmRp/9yTYg+2tIYuothJV0wCANwGkcHtAO97A/LPtTeKH2V/YwhlIaX+mvl27sd47ynLDqqdt6NfMBCSQbYUXqiSAgoyKg3GrxsSyWYkXo3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=inonHEeP; 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="inonHEeP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C37F2C2BBFC; Fri, 7 Jun 2024 16:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777886; bh=nRfiESxrDrocYFxIB1Kip5qknfzCi1RIKTdtLiW5IyQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=inonHEePc+NHcnQjqw5EDTyY0s73WTWaRkNKYqjSXgjOYTsZ6FprzAEbazKATXg/T Tr9TfeKLT1iVy1m4Io5Bzn9ghESpiGI8hRDeG03bXbJSyJkZ2/qxSLw7VnSH9Oywzl IjyLBloBy+lOxDhCZb7Up6YiLPIwT3tDMMBZ2YRrcTCrJZxPNanFHtrU9B2SoPo2/w 91D90jTham1EdskAI/2OHlqa6EPXjAHZfckhgdSMsaMKoRyZiommY4I3yhWVsL0/4H 9jurhfWtxTQixGgi5NPoAbTqGaiK5B+nq/2Qh373y4iMjBg/rByqENSRCn5vClG7bo o6UqlNaGlWoOQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:05 +0200 Subject: [PATCH net-next 4/6] selftests: net: lib: remove 'ns' var in setup_ns Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-4-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=2629; i=matttbe@kernel.org; h=from:subject:message-id; bh=D5c13u12Kl+XtHG594jjGwtSMgGPVSAdcvwWA/5a7+c=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYzXP/WyzHPrzjKKmcs/2bAAkzs5CbEkwMjgdY GjVU4Y55OOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmM1zwAKCRD2t4JPQmmg cxeND/9R9n+RCtk1TFBbtn3+MBYBxI7UZXr/eIomrFauiqYlnPcFWOZy5dbhdSAjVALGRvXN/J1 9Jg43pncrub9Itx3OOZ4bj+R/8snftZWwYJyN1/VoBYOXexOSsyZf29eKKXKC0nSw0OGHm0wK8g MoXkic3MB5jtjagA7AYOGKwiPErE5VBMFQino9oMHkf24R7Ep80MeZ7rZchVApT0xrVHpByewVF 4VDVCYYV+XsudJI6XrupwZsM7i26YLH79I6MEtwBtXAlckbJNVTlXxMJJKI5Ehg75uy1bb/8OCm mruWWIvhaAeYX9wku5Wx4MFAU6ZeYqY68vdA+HWaOXfVpJOuPYDSjJ6bn0+CQuThWM7jX8e5VD7 KDbPALA9U0QMP+6nifCKtwIGIdLezyQdIVnuDOVYFK8PPK4uHs2nwvYUuL3hMdtVeyEx104D0gb DCHazYlB5oYEI8VyKXLVfKHmnweJ262y+u2KvEfktJnio33mgPJIuJmQDI5A8JCS11jb/x4hth5 cK1k9lz62pq207bTKpbXz3W1FmQ6m/3Lt6MK3auCBbylKXlf9wQj5xxr91o9cCsBPWxC3yB9oNH EjadmKoI8BdTwQiSYRcY1GgDxhnIjsCnOyPl61CpGgYJAB8neAyv2m6ykz3+WbSxAdPN4LrX7DH n9EPj7hnF5sgcPw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang The helper setup_ns() doesn't work when a net namespace named "ns" is passed to it. For example, in net/mptcp/diag.sh, the name of the namespace is "ns". If "setup_ns ns" is used in it, diag.sh fails with errors: Invalid netns name "./mptcp_connect" Cannot open network namespace "10000": No such file or directory Cannot open network namespace "10000": No such file or directory That is because "ns" is also a local variable in setup_ns, and it will not set the value for the global variable that has been giving in argument. To solve this, we could rename the variable, but it sounds better to drop it, as we can resolve the name using the variable passed in argument instead. The other local variables -- "ns_list" and "ns_name" -- are more unlikely to conflict with existing global variables. They don't seem to be currently used in any other net selftests. Co-developed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/lib.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index 114b927fee25..915f319bcc8b 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -167,26 +167,30 @@ cleanup_all_ns() # setup_ns local remote setup_ns() { - local ns=3D"" local ns_name=3D"" local ns_list=3D() for ns_name in "$@"; do - # Some test may setup/remove same netns multi times - if [ -z "${!ns_name}" ]; then - ns=3D"${ns_name,,}-$(mktemp -u XXXXXX)" - eval "${ns_name}=3D${ns}" - else - ns=3D"${!ns_name}" - cleanup_ns "$ns" + # avoid conflicts with local var: internal error + if [ "${ns_name}" =3D "ns_name" ]; then + echo "Failed to setup namespace '${ns_name}': invalid name" + cleanup_ns "${ns_list[@]}" + exit $ksft_fail fi =20 - if ! ip netns add "$ns"; then + # Some test may setup/remove same netns multi times + if [ -z "${!ns_name}" ]; then + eval "${ns_name}=3D${ns_name,,}-$(mktemp -u XXXXXX)" + else + cleanup_ns "${!ns_name}" + fi + + if ! ip netns add "${!ns_name}"; then echo "Failed to create namespace $ns_name" cleanup_ns "${ns_list[@]}" return $ksft_skip fi - ip -n "$ns" link set lo up - ns_list+=3D("$ns") + ip -n "${!ns_name}" link set lo up + ns_list+=3D("${!ns_name}") done NS_LIST+=3D("${ns_list[@]}") } --=20 2.43.0 From nobody Fri Oct 11 21:01:31 2024 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 8AA9319FA6D; Fri, 7 Jun 2024 16:31:29 +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=1717777889; cv=none; b=kiz+QmExXEO/4jNV9D4H0txG9QbQVHn3QUTpeGrRlSFJmqjQQHHObsnYwhXog2PO+/ntCTAW/WtecjL55AnLAEVA7ERT5jnusbXEG5XaqCeMR3wpXsMdceb0oSRa3kDrZOEdWojgDcqI5JbUFvz/CETyKCN4hqWN49OQzzbUPwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777889; c=relaxed/simple; bh=sw4QEfs+KCb/A6DQwxdbwqcDsSwr0+kHnEmigoHWK0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ursgohw5/UFNU4gger3sfymtdfgCkmOpvvX8a8rjnE+l0pO2MmNcYPoqPnCwlPStiE5aO3SI60wRNjMLsXQSa/0mmjnB8RaTAqg29hHAR9QurvovkguXVeGqle8MyCqUaG4QRutlDmBmJoUZDKP6udNOP0hcCoUw7HacDVrbjN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XXap2/9+; 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="XXap2/9+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0A12C3277B; Fri, 7 Jun 2024 16:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777889; bh=sw4QEfs+KCb/A6DQwxdbwqcDsSwr0+kHnEmigoHWK0w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XXap2/9+6Mgpz4rsZQiP4U3wn9Ji3aZAbetmDgQHwODsMvA7Y9O21h5mktPaQngyd UdyoHfg5yWkJkOF3lWOPeYvhcF+OqsOpigsoN7mUtWH5TolhHMAEIhGXgdehL+LqZN 09te+3ANUEuxvv1OYueodVhHsX4HXBxbB30PQDERyesS7P5LyDTqsm1jjBAQFJUAdp qqzxY4skgM47VijjOL6t6NO9nLRLOT3nDoTHIcDaXwZM0msD/yRCfjyb+9Rfb1i3pF swrIbFbOdZw+UtYZwLABYzUQ/i3jZDiWT7xMCwHp6jK9G5kArRj+eTAywjodhgReKQ wYTS2TSvAGpSA== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:06 +0200 Subject: [PATCH net-next 5/6] selftests: mptcp: lib: use setup/cleanup_ns helpers Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-5-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=1831; i=matttbe@kernel.org; h=from:subject:message-id; bh=NgawBoCahqER20tDcfL15sESUXbmBfp0LJKw9SYNUQU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYzXPcU79zATimLx8e8BE3yaqIrwbD4vU/8c0u QxmVuccgmmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmM1zwAKCRD2t4JPQmmg c+XhD/44k2j3T/a7mrWv6mIOlgf/w6xvhret4faFIeRyGsODmr2o//NqM1j18Vx2Nq0CtA8tsNu +BK4ukFQagb4+X2vZ3/1agDb03/P+L5Qoqv0Zz7Cu9ZREd+/Kl7PoHIQhRF8JnmRZ4tR3WxP9oJ QWuZC9WmYqxPEgzKjTNkR7f6qVYOZ/MK2MJzCQIDyZ/KCPBb6xsgGY6zjvs1uTFEzk9pn4dURty EYiq6jANo8GhDWnpc7ijg8TLygOTnjg9e7aXM+KNArxmf07Kr4sFtgApqceS9x/hOfF9PDw/TGy XfJ8884DaKSt02N7kLy5Y7cwTIRg4QfrHW1o0QBe0BOvVj7ktUAOSHo+ZZ+ms+ikYeRV1ZNLrCW 5Ys2/ZOsH2SKdSFn4ijcPF0fQAlgo9HFbh0lwUMBEuhVdeM1hyCaDkqb1x2P2FiEDGVjxcADpgD Z8agqDzVvrRaKzx7hARrpuZYBhCiorj0l7hu1N/+OlII6TTV6TE421K7hMTcc07lEeY9s79E9GD ZxnpkdAdv30k9iW9l06LFR/kAMscyqMTBP0IuXw1i52eo+La1IWRgLX2YGApfzTsDO1nMz0yorW s7yPPdr2w5mb2yfAuuQiRl/RpCpW75u1Hy75MIxCXuxiT9WHUJbtiuupVKfsiq1oAn3IHn8MRYw FyYbxId/f9bCTgA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch includes lib.sh into mptcp_lib.sh, uses setup_ns helper defined in lib.sh to set up namespaces in mptcp_lib_ns_init(), and uses cleanup_ns to delete namespaces in mptcp_lib_ns_exit(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 6ffa9b7a3260..d9e30516dc72 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -1,6 +1,8 @@ #! /bin/bash # SPDX-License-Identifier: GPL-2.0 =20 +. "$(dirname "${0}")/../lib.sh" + readonly KSFT_PASS=3D0 readonly KSFT_FAIL=3D1 readonly KSFT_SKIP=3D4 @@ -438,17 +440,13 @@ mptcp_lib_check_tools() { } =20 mptcp_lib_ns_init() { - local sec rndh - - sec=3D$(date +%s) - rndh=3D$(printf %x "${sec}")-$(mktemp -u XXXXXX) + if ! setup_ns ${@}; then + mptcp_lib_pr_fail "Failed to setup namespace ${@}" + exit ${KSFT_FAIL} + fi =20 local netns for netns in "${@}"; do - eval "${netns}=3D${netns}-${rndh}" - - ip netns add "${!netns}" || exit ${KSFT_SKIP} - ip -net "${!netns}" link set lo up ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=3D1 ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=3D0 ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=3D0 @@ -456,9 +454,10 @@ mptcp_lib_ns_init() { } =20 mptcp_lib_ns_exit() { + cleanup_ns "${@}" + local netns for netns in "${@}"; do - ip netns del "${netns}" rm -f /tmp/"${netns}".{nstat,out} done } --=20 2.43.0 From nobody Fri Oct 11 21:01:31 2024 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 CF3DA19FA96; Fri, 7 Jun 2024 16:31: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=1717777892; cv=none; b=Kp+DSgwjJBgbs7HYlxRtCeSnjbLGxm2GWP92j5gnyemovnTBPsiw1tnJ9gk3VTziFGbjRTi3s9AIzOu5j2xBxZAgZ9A1NHIG51gUOffSex4x5zxHb38R81TOpmxZTopDgQtZAyJNmkzQTFg947zSRuA2EI5VzFJj8LBAxVuUzNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777892; c=relaxed/simple; bh=wQfj7qGRvIbdxyBHMllxfwfWwHu6K8la+zAXvBAGPhw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dfPbIHWSxlkUboUbx/idZeWmOTwAvQNYdilMqggz9GFmFZZ8UczQru4aWp0NEH8A5Ie00xeH67S0q9NAMjhYwXjNukG5sRsgQmdvdGpOc6qhLmSWbUU7DzchbuPQPTjvByJE2zQlhQ+XKZOm8zlXw+iiNTCAryBLhFFw1V31L0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u6rxhvIF; 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="u6rxhvIF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCE4FC2BBFC; Fri, 7 Jun 2024 16:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777892; bh=wQfj7qGRvIbdxyBHMllxfwfWwHu6K8la+zAXvBAGPhw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u6rxhvIFAWPwvagwDcc3jbZfhN2UdYverQrMmjDQ2Q51Gmd2QFlaLqdnLrpssza8d CKMG/v6KwfjmjmugdNW2Lb+T6qPMi9kIoKHNtXcTi2FrTNlfn2j1YMUtsamT6xM0+C S6GmSWvm5bsd5nuprq7t/N/KNIyRJ+9E3pNAZz1Hv/FfhWTzCd9kxVi3XkrmPwwLGH 26oxhX4SaqDjJEyoLz0XlOeUvvTR9Z0gB+XrUpPI2AngsxyBB98XzlxrP0oMS90sbK b5WAP+awRlCYEhmkvjzziJRGRwtKHFfJq5y6+538n0DTVEMG7XDo8cjwsHL0MHWzI0 wJTHVgZmriiaw== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:07 +0200 Subject: [PATCH net-next 6/6] selftests: mptcp: lib: use wait_local_port_listen helper Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-6-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang 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=1644; i=matttbe@kernel.org; h=from:subject:message-id; bh=hTVnbzEs/VsxAGCcCO2AuB217Q1JKbIP3pRwVKJ7PZs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmYzXPBcA4sCxBfarG1xUmQxlXn00WagQs+0cnG Bvz5J5yA4aJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZmM1zwAKCRD2t4JPQmmg c9mkEACVy5tLLQfLIZnrOaRPz5yK4BDZvZJWeWO4rxg4yBH/tdAIZSqGzWmefLVbg0x1wJVj4sj KiVB+sFZdDX3a/WITR6wU5ze5HveNiRBRDbFjLYe0ALNNxvRna6WL/nfk/1o1wZl/Y0mrHJg13K l0d6ZR1IRynKefzs6xAv8dtwDik6KA7h/EWbyefIZd56PHmM3SwHffiQG0tD/mBAhrT/XvQ5V8e 3kF/ANYpGmnlfJdAcQY+0gpMC6PIc8LkbcJLmQRjGgnaGA7Nk1O8v7diEf5Nz6hVkvoA/CloFGU eYcM/SpYR2jtb2Cqa/v9IKOHMaDXX9Vnr/K61G/0rQHjfhiOj0a8vNw1xKtU/eT2aG6Sv3M8uN7 uTdEE9mPGVC1RHF86ZB80KQ05G9gN9NBlQOx7W1H+hjzrSCPEa7lwpTGcRZWBzD4PC2nbt7MNn8 LAtkCx+me0kyE17XYT7nlCVNBIX3zdn7HmtzxlvDVM8BdplCDxBqj6zGH3GtPsd8aZlfwwsFx97 efUL/9qfZ3qn+DUvi6UlWOGEv8q4ildvas/qo6UrNT5VEw5ovZLb1N6klRLVs9uy653HttvAnde trzopBm5hHZcgeKjBlAITSmgsF4O4SNL4pC5COQGZlZaum9Oq3TdEol7O0OOJSshDz8Ji5pLNBd VcX9eTKX5m1K0nQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch includes net_helper.sh into mptcp_lib.sh, uses the helper wait_local_port_listen() defined in it to implement the similar mptcp helper. This can drop some duplicate code. It looks like this helper from net_helper.sh was originally coming from MPTCP, but MPTCP selftests have not been updated to use it from this shared place. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index d9e30516dc72..194c8fc2e55a 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 =20 . "$(dirname "${0}")/../lib.sh" +. "$(dirname "${0}")/../net_helper.sh" =20 readonly KSFT_PASS=3D0 readonly KSFT_FAIL=3D1 @@ -363,20 +364,7 @@ mptcp_lib_check_transfer() { =20 # $1: ns, $2: port mptcp_lib_wait_local_port_listen() { - local listener_ns=3D"${1}" - local port=3D"${2}" - - local port_hex - port_hex=3D"$(printf "%04X" "${port}")" - - local _ - for _ in $(seq 10); do - ip netns exec "${listener_ns}" cat /proc/net/tcp* | \ - awk "BEGIN {rc=3D1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) \ - {rc=3D0; exit}} END {exit rc}" && - break - sleep 0.1 - done + wait_local_port_listen "${@}" "tcp" } =20 mptcp_lib_check_output() { --=20 2.43.0