From patchwork Fri Apr 5 10:52:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618893 X-Patchwork-Delegate: kuba@kernel.org 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 B908516ABF3; Fri, 5 Apr 2024 10:52: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=1712314348; cv=none; b=TFVnCZBuFwi6Pu8Ah50N7W21Xo9/p8HvnFaA4V/k+UDYPmstdLLsfVTuOS6DphTFKDP/DTOQ8X11BA3rNErnAcBtYqJ6D7CwVNzCmiEPzLa1M+cF0/QeEuNkPSkhLIcSUtS3olX1iydByrq8D22YmlKsXpRvejU7q/5OFWPbx6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314348; c=relaxed/simple; bh=UXfjZkvZut68urB9bj4+Y2yUcm70M+M+IzmNYeZgUlA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s3M0SV4TgtuiveBNKQ5MEUPV7S9X/cl2/a6QzRBLsPSmfJLwDrhoavNh0SmUN6Z9xlVP4KOkyyuNxkENaIVKXKcKHYwG92OSJl+MGMApL7oyZrLXgbl/m8cGt0oH42JXMZ3xGRTIGAmDUlWxAKso/5fMkzYPwV9+qthnk/mbFbg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RxwrsM91; 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="RxwrsM91" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABA16C43330; Fri, 5 Apr 2024 10:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314348; bh=UXfjZkvZut68urB9bj4+Y2yUcm70M+M+IzmNYeZgUlA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RxwrsM9120vrjE918Km9VXpKmSl8jkBBhoKRn21+mXfMYDD1pzPwccokyz4V8okqO ERWUq5F5BtbzTutoiIkfDUFcEVHK9ZKDEuOc8zCERlcmQcfMpQ/eZfkGads7ZvoWWp 871Fc1Y2/eoE/PeFcIJnfm4C94ov93r9UbZhipUrlZsSH1+F0sumE948lOP6ikFAtd HZ30vgoPXR5csc3oMjLjKrHMUyFSL5fXj5dSHqJOFCMQJDjLVZU+NCLxWYAWeG3ZEW YLUJ3U3z1wGFBUDjaGGSIhXjpHPKS+sMaGGhzCG0ecX8Svf68n1gF2Z7KH7Etfw77n JAbfG0EbldE9A== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:05 +0200 Subject: [PATCH net-next 01/11] selftests: mptcp: add tc check for check_tools Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-1-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=2829; i=matttbe@kernel.org; h=from:subject:message-id; bh=7cBbg2dhMoVMioQPZfDCl3TcQx85MupKC/OecHlLWlE=; b=kA0DAAgB9reCT0JpoHMByyZiAGYP1+WgO31O9a9x7v2LkGvt71BJBrLh7KVvkEe1ERsorPnTY YkCMgQAAQgAHRYhBOjLhfdodwV6bif3eva3gk9CaaBzBQJmD9flAAoJEPa3gk9CaaBzuEwP+Mtf m967ZBa/aPH3BzcIxGAh0rzXedUXTbUctd3QKYhQ/SlgUDFHhlHObU8nkyODLnZpO3OU2eZl6lb Q7xZqc6A7eMAsNiBDl/Dam/O4nHwDRrjv2eEbrHLK2t5Ei+06+58BK7MZuGBDQcVW2rh0LXYDOS BEK7G70NAgWVW/zChjDBXMqP7xW7KdqxUPC2TYl9ABiXrLt2BzTs3zCNZDn4VPx557r9Oas4IJj O5Wm+zSD8oPW7yv7WxRIJ/jB07LthGXusT0bNU8Eur4HfrlhHnXIOOxNWaMFvVZ+QklfUta8oJ9 Ksdo6WZV6cWq8k7bPb+Onyql9dcPdjqXB0jRSzHlkeoI5RNC5Bv1D2ShDBoU0Afud1CCM5H2RnP eM+3g4YElySNJS0E1uVUFXKppSvs1dbKRYPbejUKlOC9ITBGh3TCMbX1+v/nYGqnByITlLohKU+ rZ+QrSgHCm5MCHpw+nxYY27i+r9de6DyJ7zKkbK7BzVViQLcMsNR3B2ChpJLA/slaqXhEcp7Ai7 ND6v4bFFDbWOsDExLLWIYTTpxEzXc1njpVr1kUqNbkb0J9WruNzouaTgTMOyLZA1R+l1TBZpb5S 00fYho84mrv9OhvMvV365eQyNH1tPGA+1l1ZQTAs1JX78GGAGYlGYc4YxhZbfo8kDrB5pfhDPQx +jhI= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang tc are used in some test scripts: mptcp_connect.sh, mptcp_join.sh and simult_flows.sh. It makes sense to check if tc is installed before running these scripts, just like other tools. So this patch add 'tc' check for mptcp_lib_check_tools(), and check it in these test scripts. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 2 +- tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 6 ++++++ tools/testing/selftests/net/mptcp/simult_flows.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 4131f3263a48..b77fb7065bfb 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -147,7 +147,7 @@ cleanup() mptcp_lib_check_mptcp mptcp_lib_check_kallsyms -mptcp_lib_check_tools ip +mptcp_lib_check_tools ip tc 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 e4403236f655..5a95798eb40a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -142,7 +142,7 @@ init() { mptcp_lib_check_mptcp mptcp_lib_check_kallsyms - mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}" + mptcp_lib_check_tools ip tc 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 d529b4b37af8..1fa05405f65e 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -384,6 +384,12 @@ mptcp_lib_check_tools() { exit ${KSFT_SKIP} fi ;; + "tc") + if ! tc -help &> /dev/null; then + mptcp_lib_pr_skip "Could not run test without tc tool" + exit ${KSFT_SKIP} + fi + ;; "ss") if ! ss -h | grep -q MPTCP; then mptcp_lib_pr_skip "ss tool does not support MPTCP" diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 1b2366220388..497141c49ccd 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -45,7 +45,7 @@ cleanup() } mptcp_lib_check_mptcp -mptcp_lib_check_tools ip +mptcp_lib_check_tools ip tc # "$ns1" ns2 ns3 # ns1eth1 ns2eth1 ns2eth3 ns3eth1 From patchwork Fri Apr 5 10:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618894 X-Patchwork-Delegate: kuba@kernel.org 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 870E416ABC8; Fri, 5 Apr 2024 10:52:31 +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=1712314351; cv=none; b=XKCX3V05ff6CBmm0MyaAq5zHKWE2gOZO6Y6P4ASq6BPzkQFGRGF79Do0nrfHKfNOAzb4+6Ia2txbrL5B/5gOr5L9h3/milQxT1lDdhwkOSD5IdzoBiu3uazO1vC53HTMtTxoOkFxkaKP/dg9iJIsqANkwpv6c1m03gYaVfHat+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314351; c=relaxed/simple; bh=v2tpouPNyjZ1b8U4PDYegy9K1DvLXeUhvyBIxPTZtjc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eozTqajKvlBnnMH4wXbBu6SWpLSOjHrqXFrhNzsLs/f0F072lx0+UPxaZAEhRxR4lYR+OzybnA0iR9NRn/jVMhN/rv4gEs997AvaigI/8xMW044pns3O5iNKNk/HyHd6KHlzOaBs921OsloLvAVFurqX5pMYFaX3QAnT0yTeR04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K5xvw+K+; 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="K5xvw+K+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9ED1C43399; Fri, 5 Apr 2024 10:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314351; bh=v2tpouPNyjZ1b8U4PDYegy9K1DvLXeUhvyBIxPTZtjc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K5xvw+K+vFNxbn/7hr+3V0jLqG71tLIsQTp8a+BBGP4PNZKO+VnrRwf6T72T6UklM iZCjezmPJMJ+x6FHoS/WPUXKE2wZHNAQMn3Dm5ZjpDeNXMSblpdeHo3XJJdUrIv9Oe IKfMVq17Bn2023BtDrvU3ziyTUljbuVpvC5OdePoR2lWml3QXEHMP93QUX21mS+Hq0 k86+hrnFyBQCKqXRcio43EO09cKf+G/X/05bEhYDmbt70Vg5g83b9FqeIobaPPR/UZ CA53yZDCdqoWKEfv6biKZmqRWuy4M5avbOjjY2DgtRNIlM9Z8d+dYIm7ugXgjSRIkQ 9yAVxwCfYk8lA== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:06 +0200 Subject: [PATCH net-next 02/11] selftests: mptcp: add ms units for tc-netem delay Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-2-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=2219; i=matttbe@kernel.org; h=from:subject:message-id; bh=IB5nicQTGbW0wPqnxC6mBPr/+Em2SJVyWc/UESeeex4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9flQUJwVIqulu5DfBX+mevThsUesOltYArXS /+54t/PaWeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg cwfGD/wLc/g3nigR/s+Sqt83I+ZbVaJHIaAfJPaF7Xitbl5ZwxPkKZc48deHnCg4ZNxPr+MLJ1u Lb4olbkYfdFr9TvGBW++zhK7hoZPJiCJIL2NyG6dAJ8aYKTvexeRCXnBrOhuX+UEFg5ppxlYcW4 AS7K1utsBWdppVSHn4vOy5JgauieUHnxPj4Mpfs9Q0vDuL2bBD1F7mZTJxCq97GoSxhq1NPcxHP faISwUY+q3+RW5E5SB9poNku0BS1rioJfi4FZWyzat0++WB7Yp4Pnha1BVhVkd5o4+lDkcaTX69 7qrFMJAqn1wDjKdO0Sdw3Bcp20Zu19kuqRZxfUKnqgjQq868VIqbs/YbK1i0kW07rQNtAe+jJWQ FgMuJiF/rqGrT9ZczB10CdKAyAUrNbnnFywhrPIB5tOOtOombf43zLn4IZ8uU6Tpje9MWN6meSP AibBaPIToq75LVs4uQDuB3q06VUvz470vtBSMmjPOSRDHhPbL6fyF0vr5AvNeuzf5ZG13oJTAlF nlOM0YTfS3hR319V3Ig5u3zI1mnjMFJeW1gv+sXqeP49rbbxNVg+ZjZ5QutBQ+XI87+lVpaOmNq WP/ISGLHZAnWFw4ZgkonNN2MXDMbvJ0ONWVun8i7Omd4aL+Ap8z20uzO2oKGED2rtWyvSNnvhwV DuJumWowvezilBw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang 'delay 1' in tc-netem is confusing, not sure if it's a delay of 1 second or 1 millisecond. This patch explicitly adds millisecond units to make these commands clearer. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 +++--- tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 5a95798eb40a..73a2131e6da2 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -125,8 +125,8 @@ init_shapers() { local i for i in $(seq 1 4); do - tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1 - tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1 + tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1ms + tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1ms done } @@ -3212,7 +3212,7 @@ fail_tests() # multiple subflows if reset_with_fail "MP_FAIL MP_RST" 2; then - tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5 + tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5ms pm_nl_set_limits $ns1 0 1 pm_nl_set_limits $ns2 0 1 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 497141c49ccd..4e6d8fc56b38 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -216,8 +216,8 @@ run_test() shift 4 local msg=$* - [ $delay1 -gt 0 ] && delay1="delay $delay1" || delay1="" - [ $delay2 -gt 0 ] && delay2="delay $delay2" || delay2="" + [ $delay1 -gt 0 ] && delay1="delay ${delay1}ms" || delay1="" + [ $delay2 -gt 0 ] && delay2="delay ${delay2}ms" || delay2="" for dev in ns1eth1 ns1eth2; do tc -n $ns1 qdisc del dev $dev root >/dev/null 2>&1 From patchwork Fri Apr 5 10:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618895 X-Patchwork-Delegate: kuba@kernel.org 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 DC55416C687; Fri, 5 Apr 2024 10:52:34 +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=1712314355; cv=none; b=AROmmgFPFd6CLPorvbvP2YbrXwn6suHmIcuDOpuRDIG2QO7m2ptRnxPwAHqwC8Zh60/Htgn9pSfba1A7q8lO1wQ8OLKLf3xuEwEcWckFN0OfXSBhuS4/7n60DXr27BkGA+kmo/ezgONM5IxPKnHSN/w7mQb33tJ4og18SDClmS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314355; c=relaxed/simple; bh=LXsOIJ8NsONyTTN3FulDWgUH6xKocdzz/TorHovE29s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iH8bQ+rjpWxSTZKhAS7vPI3N7D9qkcaj+KHB3VY2CXabztHbsWk5omA+BohlVu+g88DiUPy1zfU8p5KNXhc8oNKiFoW1duTAMtV2eCOFyqQLgHx0ZeUitdYVdyhAcManaSWRChRSzIoZzU4tnS+ca7NMWkOigA8hNINvaGcXse4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HTJHfJG6; 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="HTJHfJG6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDCAEC433F1; Fri, 5 Apr 2024 10:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314354; bh=LXsOIJ8NsONyTTN3FulDWgUH6xKocdzz/TorHovE29s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HTJHfJG6dJW4vX6auzQLEgI2PSIdLAXJn7bOoUsYt2gzD3hNteELo/sil7H9VrRPC Cn+hvHPNlyb2JRWb/6QY+aHWcOJcEfSEgzv9E2t3hHLo/QAuURJtYyVOeEnp4Cb6nJ JHBb82Cx+teX+DgYec+mZ5nCLQ81JEBBs2MrJmh0HDlOJJNNsoxNemFarEjBOaj/T0 h2YbypUiNFMpMHWElBr/82eNLo/JJQgj8MkczVRXBi85aecyEiCXUMN5tntmCWr5ow hkgtv52GZSeMZLg8rqDSM9w3YPvJV35q0wqiZMvw19VqAC5H5Wborzi1dVUNNy3AKb +DViii7BCuaSw== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:07 +0200 Subject: [PATCH net-next 03/11] selftests: mptcp: export ip_mptcp to mptcp_lib Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-3-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=3892; i=matttbe@kernel.org; h=from:subject:message-id; bh=VtaspLDZBNzR12vEqg16R7/RqEeGwnjSqjPIkQ3di7U=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fl1+jhpBmTVDHnfbc1qQNhQPBjf8Bx+qFnL MF6uxS9IamJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg cy6yD/sH0uQbpRTPT1shdKXLkyyHXWUTQpd5wfJkhc7HdZwNrKpOl6v7QhtMbIJKE1Jbj8f4D0o CyUXwXpxtwbvMZYcMnHou+3IhGW3W/AqByxpmWlnSv1ADi74rCMPl3oLIkMiCwlFFxceEXFILU1 Ts7tw6ohqIyalnA0eYP689FZ4QbAdD3U9mPw56VEDDcOwuqkYqWDwF7qspIVlqAHubLOKIfq+X8 49/p7oO5QIE+G7OZHpbiDLVDlUrv7kT0M+px8Hpd91bgQU5Yr7Ti9IhB6Du6QgsNF2AZ3A2gI3I SVJ9iv9oyG/nW+pd9KO74uOSIC7s7FLb/yDdCo42sd/sCJ5uc54ZE+Bun9DHbP+JifKJbYSIHdq V1lwE9NN3blSbuAWYsjJdwL1G2vPoCLF1ouprHkpVNeKNTUkbQGjzK/jIpNf4AHwI8fP+VBJCfE pXtTw8qZwTIQgqRdt/x7+XSzcrNZHQBBScpCyUuCpMGdWiZu/RjGPuFrPthDhBPvqBY0x2TQx7u m8OtipDOML14VbEBBQoidILEz9HchQv3NPlrZdhh9OsuQLyt7VQJllE25ldNM12IaJotuMWZnuc Mx72tAZSxdcHNumzIG+2DxaNXfAWkHa4AbvLNOFZKZtOzYZ/ZBDPGehLwS4p1tGaC6HwK23L6sG eD2Arz/kSdyH/rA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch exports ip_mptcp into mptcp_lib.sh as a public variable, named MPTCP_LIB_IP_MPTCP. Add a helper mptcp_lib_set_ip_mptcp() to set it, and a helper mptcp_lib_is_ip_mptcp() to test whether it is set. Use these two helpers in mptcp_join.sh. This patch is prepared for coming commits. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 17 ++++++++--------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 9 +++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 73a2131e6da2..62fcfeaa3430 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -31,7 +31,6 @@ timeout_poll=30 timeout_test=$((timeout_poll * 2 + 1)) capture=false checksum=false -ip_mptcp=0 check_invert=0 validate_checksum=false init=0 @@ -610,7 +609,7 @@ pm_nl_set_limits() local addrs=$2 local subflows=$3 - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows else ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows @@ -650,7 +649,7 @@ pm_nl_add_endpoint() nr=$((nr + 1)) done - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port else ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port @@ -663,7 +662,7 @@ pm_nl_del_endpoint() local id=$2 local addr=$3 - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then [ $id -ne 0 ] && addr='' ip -n $ns mptcp endpoint delete id $id $addr else @@ -675,7 +674,7 @@ pm_nl_flush_endpoint() { local ns=$1 - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then ip -n $ns mptcp endpoint flush else ip netns exec $ns ./pm_nl_ctl flush @@ -686,7 +685,7 @@ pm_nl_show_endpoints() { local ns=$1 - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then ip -n $ns mptcp endpoint show else ip netns exec $ns ./pm_nl_ctl dump @@ -699,7 +698,7 @@ pm_nl_change_endpoint() local id=$2 local flags=$3 - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then ip -n $ns mptcp endpoint change id $id ${flags//","/" "} else ip netns exec $ns ./pm_nl_ctl set id $id flags $flags @@ -749,7 +748,7 @@ pm_nl_check_endpoint() return fi - if [ $ip_mptcp -eq 1 ]; then + if mptcp_lib_is_ip_mptcp; then # get line and trim trailing whitespace line=$(ip -n $ns mptcp endpoint show $id) line="${line% }" @@ -3702,7 +3701,7 @@ while getopts "${all_tests_args}cCih" opt; do checksum=true ;; i) - ip_mptcp=1 + mptcp_lib_set_ip_mptcp ;; h) usage diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 1fa05405f65e..ca01d949fad8 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_TEST_COUNTER=0 MPTCP_LIB_TEST_FORMAT="%02u %-50s" +MPTCP_LIB_IP_MPTCP=0 # only if supported (or forced) and not disabled, see no-color.org if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } && @@ -511,3 +512,11 @@ mptcp_lib_verify_listener_events() { mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" return "${rc}" } + +mptcp_lib_set_ip_mptcp() { + MPTCP_LIB_IP_MPTCP=1 +} + +mptcp_lib_is_ip_mptcp() { + [ "${MPTCP_LIB_IP_MPTCP}" = "1" ] +} From patchwork Fri Apr 5 10:52:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618896 X-Patchwork-Delegate: kuba@kernel.org 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 9496116C45E; Fri, 5 Apr 2024 10:52:37 +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=1712314357; cv=none; b=lObTDz195LKNcYP1nNpUlqPhaSxjBCvSvwBrM1FmeX8XPSScNVIApSlltZGTkOX6mLrdUfRG4JtHqTuZqS3LSLzYph5c/gIs9q1hLamsRGslSY4fC3sZEicN9mM3zDR9sWpnMI4MVuQonmItbGXafNT3w6YGlaLrd6H+YxkfpG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314357; c=relaxed/simple; bh=Zhj1r18k/1WzNQKbSHVFV4+dDFsQJw97dLrKAuCxQcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kU/vBFGeivSsgXurcH7mFfTFJj7beZsduyKON2Dajqljsy4QLGxE0cPcEoeXxJzxOVHuPSf9Aj2xbjwIKu3kMI+h0nx89frIEc+LyivsfX+Wnuxt5YUJIq0EVWvL3qh6ZiEDQBau6VGM4VUXBRrCxyyak5+kE2RXYkjigvnsee0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uGEifxHA; 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="uGEifxHA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB3BFC433B2; Fri, 5 Apr 2024 10:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314357; bh=Zhj1r18k/1WzNQKbSHVFV4+dDFsQJw97dLrKAuCxQcs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uGEifxHAYho7zC9y/rSr7+4zoVmHXnX7rUk76uoXWHw6+84TAVe+LnIMK1/IheiLK GqGYPWucYOoWzXrnoq/FTnzntJ3AmPXIDQANolJkWvjOWtqNVDKGqKJd5hiC9VybH+ 3fma8HSPZccOOFsF8dSzeiqnoRvTSaW6JM5uTQoSQqvvOjVzGyeEkLmbP9r8r6NIMf Rl6JwgSzLaWZzUSeCo8ES80HFEN7DyH7HGHn2+4RL+YK0uJfnbSlBcV3zmYfDCHz0T wIkrMB3vvK1kjZ/COjk1NxrmaCHczex7Qfm6pcVxcvLGxw2Ed2k2xWcl/1ncoiRzno YC/5gOeLnIxGw== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:08 +0200 Subject: [PATCH net-next 04/11] selftests: mptcp: netlink: add 'limits' helpers Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-4-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=2795; i=matttbe@kernel.org; h=from:subject:message-id; bh=nUEW5uyiDGyAzCFYUDGHkGAM2g15fOz/0B8Lus/cn9E=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9flyRr6mFf4wYKjXoutK7x6Byc1bA7LVkW2l ONdB/+Za8+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c+/oD/wNMZPAmNxVpI3SinaFWs8k25NUfxPYtTTpZN8gqnHP78AEDSttskqz0fmtAZKJD8siXRA 7H4u0dFlr1f3jk20AozTSbcIa6Ju6jz4SNY0e1QPUSrw75GVuEf6PRYCcYnjYB3lRgwS/Kb4vG1 qGnFIPwW88s/i7hwfjeYmNFA6LcrpBUadOv/DsgMeYnS2XMuBqsQPic05UFTtcUJFvcjdxfWSVH mfbJHAVAgFr9tiQ0WDl6BovHLGi6td2nNChzoIak1jkZ5YkhtXVjh9bWvJAREdDos2GmuwB6mwV 0uLJ66gB37xU05ay+BitKirzI20zQKipaTlt/0iCuYG6U5q5NiKHZugV1LON7KolF/TDYBaAd2I oqP2vU2OrB+u0o0IJQj+hxNp0w86xYwOkCXrLtR5LcHJNkcVZnMAmZTqVtT5DxHndTBzUDF+6pH tcbDjpHKWwdwWy6oaQCU2PUHpjOMZHQ1bsN5fKORrvtNMf27hBgSY3pbtuXOifCllY9ZtWM2KmA /gOvWx/e+3c71Liin9SW/iwxNzDhkPSbz37W9EFVSGWB3D+a3BT+fPH8l7qSEjwOHhqruQjF2dP wmPxSyJcTcfmDP1l0NfxmyvqckfA3CaQ4JH/+pl78tUzdQs9ucad9/sgN3pfpAF4kuBs5Xf2gpv 5S4TgBS6a3si4OA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The output format of 'ip mptcp limits' command is much different from that of 'pm_nl_ctl limits' command. This patch adds format_limits() helper to format the outputs of these two commands to hide the difference. get_limits() has been added to show the limits. Use these two helpers in pm_netlink.sh to replace all 'pm_nl_ctl limits' commands and outputs. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/pm_netlink.sh | 32 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 6ab8c5d36340..d672d1e5d470 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -46,6 +46,26 @@ trap cleanup EXIT mptcp_lib_ns_init ns1 +format_limits() { + local accept="${1}" + local subflows="${2}" + + if mptcp_lib_is_ip_mptcp; then + # with a space at the end + printf "add_addr_accepted %d subflows %d \n" "${accept}" "${subflows}" + else + printf "accept %d\nsubflows %d\n" "${accept}" "${subflows}" + fi +} + +get_limits() { + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns1}" mptcp limits + else + ip netns exec "${ns1}" ./pm_nl_ctl limits + fi +} + check() { local cmd="$1" @@ -69,10 +89,9 @@ check() check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" -default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)" +default_limits="$(get_limits)" if mptcp_lib_expect_all_features; then - check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 -subflows 2" "defaults limits" + check "get_limits" "$(format_limits 0 2)" "defaults limits" fi ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 @@ -120,14 +139,13 @@ ip netns exec $ns1 ./pm_nl_ctl flush check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null -check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "rcv addrs above hard limit" +check "get_limits" "${default_limits}" "rcv addrs above hard limit" ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null -check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "subflows above hard limit" +check "get_limits" "${default_limits}" "subflows above hard limit" ip netns exec $ns1 ./pm_nl_ctl limits 8 8 -check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8 -subflows 8" "set limits" +check "get_limits" "$(format_limits 8 8)" "set limits" ip netns exec $ns1 ./pm_nl_ctl flush ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 From patchwork Fri Apr 5 10:52:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618897 X-Patchwork-Delegate: kuba@kernel.org 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 ED8A116C84C; Fri, 5 Apr 2024 10:52:40 +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=1712314361; cv=none; b=bE3+mBi/JQVAI08ecfcuZEgzQWKsa2edmr+nCRRi9mkoVyOonk+awTM3ofAaW1RMHRoLGTH+29wf7L41M+Q5gzx+ZNQio3ihh6pGtArqiKR8zM1orCGAr+Ct2NAPZCpTB9Hih4cSGOQ7j+tpZDuj1wi+if13QGkJ9I86CXTmd9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314361; c=relaxed/simple; bh=sqEcY9subOu+shrD8qPfY1vzojQ+5OSJgB0mGYORrSQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LBOEdTkPvp3++qS4n5/rChe8t3lqXahcsICSF7+gf446xjlTzVXhc0HvC5xO3f5FAkTs5smS0CzrRwzuokS4cGLkbKzCWDmHwNb4Asil+/av741m8XbSD6rzWzNnpVeZsG6/qPIOtHmGKPs3PV3n5jp9ngusAzonY/15TkfmHL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ki+bNMTx; 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="ki+bNMTx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7CB1C43394; Fri, 5 Apr 2024 10:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314360; bh=sqEcY9subOu+shrD8qPfY1vzojQ+5OSJgB0mGYORrSQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ki+bNMTxbWVCW0odv61Sn/deuvvvFA1bmCiRGAsN+HXQhxHPnSVlDPqEKmqZ+QCoF FckvNecapYUxzdkwut3IMf2OzA3RW0ThjtCes+9yLTr2T6bTWacgoge+ewFsol3pAJ ng0RtErFTL7BO0Wgh6ND9kxr3OR1GHwH99zloQFcjhgT5StFFeMuc2EYQkIG3lrrD6 Sjjpw9edGgg4qkWdychOB8d4h2Azn+z1tn7fNCrWl7YXvTXWqL4l3cNx4FSaEBi1tx 8TNHf3S0md6qT9w7UEGvCo39SndtPdA9h+YL5PKkqj9htXogbvVpL6HwNAZtucceea ywSw1+MoxfUIg== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:09 +0200 Subject: [PATCH net-next 05/11] selftests: mptcp: add {get,format}_endpoint(s) helpers Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-5-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=11129; i=matttbe@kernel.org; h=from:subject:message-id; bh=YRoZ+sXiGSaIhqmdWi6B71t+bOturpL6AYnxqOWpiTs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9flEwtPtcLCOz7Nynjm0ZbDcboQXWV39EBUX pohWrn5k4OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c9vGEADfZVvrvLk5jLhs/7Eht4BxRNbbXWSmvRz6PmSocFxilm6ijgnALzY6os3Xe1m5BTdXtel 902IbRl1HILLvCw1BoXy8b7UbLjTZbZwB64DrAfj4RVEERmqVFgivothunPAhnkMgt5GfFgzDTT v39fw1hOsgmrqh+G37z5aicUov/c1NbphjE23DbPckEG4YyBJPoT5LoYeDjM1UnKoNbF/f2HunN r4JIXO6cRlVbZZ44PR/Ad5t7geLKlOjU+6aCiVQnR4MJ0Vwk54kmys8tuE6CcH2Vcom6r5sGVFY T8bgmIyNkFNevkNy5RouPQ8+F6tsP8vfiY2jCNVMYc8xTQja9Tk0q9OXOZUElxjm2aSS/boasZx YRMWYpCdajV3no5j8Nksj8KleOn61Sne0Kl+w6vQGJEclMQmbQv12ojxKvq8QUVKZPRk+sfM1/b fleZ7DwPPinWLTbW/DGtccr5+5LQVn/RTwjd2KbeMdZvu1lfyzFCo9axI3tFXrqYnywPzhg8DMF gcrfUwFCeFG6GMb0YrYiHZIfkClvo2RJe8KkEK+dTS3bVwKz8oO9uPQCrCJMCHVOUklCY/isyav Ib9w/aFvFrT+4Z2wGbp3mxajSH6L6EkOjkpZ/ze+YZiGh5xodoO14G0aCT/HaU81gKVoZ83yquP K5XDAyQO/ILR7fw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The output formats of 'ip mptcp' commands are much different from that of 'pm_nl_ctl' commands. This patch adds a new helper format_endpoints() to format the outputs of 'ip mptcp' and 'pm_nl_ctl' with 'endpoints' arguments to hide these differences. A new helper named get_endpoint() has also been added to show a specific endpoint identified by the given address ID, similar to mptcp_join.sh's pm_nl_show_endpoints() helper, but showing all entries. Use these two helpers in mptcp_join.sh and pm_netlink.sh to replace all 'pm_nl_ctl get' commands and outputs of 'pm_nl_ctl dump/get'. Suggested-by: Matthieu Baerts (NGI0) Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 32 ++------ tools/testing/selftests/net/mptcp/mptcp_lib.sh | 35 ++++++++ tools/testing/selftests/net/mptcp/pm_netlink.sh | 102 ++++++++++++++---------- 3 files changed, 98 insertions(+), 71 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 62fcfeaa3430..d48da81daa06 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -712,12 +712,9 @@ pm_nl_check_endpoint() local ns=$2 local addr=$3 local _flags="" - local flags local _port - local port local dev local _id - local id print_check "${msg}" @@ -725,48 +722,29 @@ pm_nl_check_endpoint() while [ -n "$1" ]; do if [ $1 = "flags" ]; then _flags=$2 - [ -n "$_flags" ]; flags="flags $_flags" shift elif [ $1 = "dev" ]; then - [ -n "$2" ]; dev="dev $2" + [ -n "$2" ]; dev="$2" shift elif [ $1 = "id" ]; then _id=$2 - [ -n "$_id" ]; id="id $_id" shift elif [ $1 = "port" ]; then _port=$2 - [ -n "$_port" ]; port=" port $_port" shift fi shift done - if [ -z "$id" ]; then + if [ -z "${_id}" ]; then test_fail "bad test - missing endpoint id" return fi - if mptcp_lib_is_ip_mptcp; then - # get line and trim trailing whitespace - line=$(ip -n $ns mptcp endpoint show $id) - line="${line% }" - # the dump order is: address id flags port dev - [ -n "$addr" ] && expected_line="$addr" - expected_line+=" $id" - [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}" - [ -n "$dev" ] && expected_line+=" $dev" - [ -n "$port" ] && expected_line+=" $port" - else - line=$(ip netns exec $ns ./pm_nl_ctl get $_id) - # the dump order is: id flags dev address port - expected_line="$id" - [ -n "$flags" ] && expected_line+=" $flags" - [ -n "$dev" ] && expected_line+=" $dev" - [ -n "$addr" ] && expected_line+=" $addr" - [ -n "$_port" ] && expected_line+=" $_port" - fi + line=$(mptcp_lib_pm_nl_get_endpoint "${ns}" "${_id}") + expected_line=$(mptcp_lib_pm_nl_format_endpoints \ + "${_id},${addr},${_flags//","/" "},${dev},${_port}") if [ "$line" = "$expected_line" ]; then print_ok else diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index ca01d949fad8..4fabb0091940 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -520,3 +520,38 @@ mptcp_lib_set_ip_mptcp() { mptcp_lib_is_ip_mptcp() { [ "${MPTCP_LIB_IP_MPTCP}" = "1" ] } + +# format: ,,, +mptcp_lib_pm_nl_format_endpoints() { + local entry id ip flags dev port + + for entry in "${@}"; do + IFS=, read -r id ip flags dev port <<< "${entry}" + if mptcp_lib_is_ip_mptcp; then + echo -n "${ip}" + [ -n "${port}" ] && echo -n " port ${port}" + echo -n " id ${id}" + [ -n "${flags}" ] && echo -n " ${flags}" + [ -n "${dev}" ] && echo -n " dev ${dev}" + echo " " # always a space at the end + else + echo -n "id ${id}" + echo -n " flags ${flags//" "/","}" + [ -n "${dev}" ] && echo -n " dev ${dev}" + echo -n " ${ip}" + [ -n "${port}" ] && echo -n " ${port}" + echo "" + fi + done +} + +mptcp_lib_pm_nl_get_endpoint() { + local ns=${1} + local id=${2} + + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns}" mptcp endpoint show id "${id}" + else + ip netns exec "${ns}" ./pm_nl_ctl get "${id}" + fi +} diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index d672d1e5d470..234b88eba0cb 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -66,6 +66,15 @@ get_limits() { fi } +format_endpoints() { + mptcp_lib_pm_nl_format_endpoints "${@}" +} + +get_endpoint() { + # shellcheck disable=SC2317 # invoked indirectly + mptcp_lib_pm_nl_get_endpoint "${ns1}" "${@}" +} + check() { local cmd="$1" @@ -97,43 +106,44 @@ fi ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup -check "ip netns exec $ns1 ./pm_nl_ctl get 1" "id 1 flags 10.0.1.1" "simple add/get addr" +check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr" check "ip netns exec $ns1 ./pm_nl_ctl dump" \ -"id 1 flags 10.0.1.1 -id 2 flags subflow dev lo 10.0.1.2 -id 3 flags signal,backup 10.0.1.3" "dump addrs" + "$(format_endpoints "1,10.0.1.1" \ + "2,10.0.1.2,subflow,lo" \ + "3,10.0.1.3,signal backup")" "dump addrs" ip netns exec $ns1 ./pm_nl_ctl del 2 -check "ip netns exec $ns1 ./pm_nl_ctl get 2" "" "simple del addr" +check "get_endpoint 2" "" "simple del addr" check "ip netns exec $ns1 ./pm_nl_ctl dump" \ -"id 1 flags 10.0.1.1 -id 3 flags signal,backup 10.0.1.3" "dump addrs after del" + "$(format_endpoints "1,10.0.1.1" \ + "3,10.0.1.3,signal backup")" "dump addrs after del" ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 2>/dev/null -check "ip netns exec $ns1 ./pm_nl_ctl get 4" "" "duplicate addr" +check "get_endpoint 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" +check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment" 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" +check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit" +check "get_endpoint 10" "" "above hard addr limit" ip netns exec $ns1 ./pm_nl_ctl del 9 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 -check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.1.1 -id 3 flags signal,backup 10.0.1.3 -id 4 flags signal 10.0.1.4 -id 5 flags signal 10.0.1.5 -id 6 flags signal 10.0.1.6 -id 7 flags signal 10.0.1.7 -id 8 flags signal 10.0.1.8" "id limit" +check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "$(format_endpoints "1,10.0.1.1" \ + "3,10.0.1.3,signal backup" \ + "4,10.0.1.4,signal" \ + "5,10.0.1.5,signal" \ + "6,10.0.1.6,signal" \ + "7,10.0.1.7,signal" \ + "8,10.0.1.8,signal")" "id limit" ip netns exec $ns1 ./pm_nl_ctl flush check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" @@ -156,14 +166,15 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8 -check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.1.1 -id 2 flags 10.0.1.2 -id 3 flags 10.0.1.7 -id 4 flags 10.0.1.8 -id 100 flags 10.0.1.3 -id 101 flags 10.0.1.4 -id 254 flags 10.0.1.5 -id 255 flags 10.0.1.6" "set ids" +check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "$(format_endpoints "1,10.0.1.1" \ + "2,10.0.1.2" \ + "3,10.0.1.7" \ + "4,10.0.1.8" \ + "100,10.0.1.3" \ + "101,10.0.1.4" \ + "254,10.0.1.5" \ + "255,10.0.1.6")" "set ids" ip netns exec $ns1 ./pm_nl_ctl flush ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1 @@ -174,36 +185,39 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8 -check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.0.1 -id 2 flags 10.0.0.4 -id 3 flags 10.0.0.6 -id 4 flags 10.0.0.7 -id 5 flags 10.0.0.8 -id 253 flags 10.0.0.5 -id 254 flags 10.0.0.2 -id 255 flags 10.0.0.3" "wrap-around ids" +check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "$(format_endpoints "1,10.0.0.1" \ + "2,10.0.0.4" \ + "3,10.0.0.6" \ + "4,10.0.0.7" \ + "5,10.0.0.8" \ + "253,10.0.0.5" \ + "254,10.0.0.2" \ + "255,10.0.0.3")" "wrap-around ids" ip netns exec $ns1 ./pm_nl_ctl flush ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags backup -check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ -subflow,backup 10.0.1.1" "set flags (backup)" +check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \ + "set flags (backup)" ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup -check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ -subflow 10.0.1.1" " (nobackup)" +check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ + " (nobackup)" # fullmesh support has been added later ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" || mptcp_lib_expect_all_features; then - check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ -subflow,fullmesh 10.0.1.1" " (fullmesh)" + check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \ + " (fullmesh)" ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh - check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ -subflow 10.0.1.1" " (nofullmesh)" + check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ + " (nofullmesh)" ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh - check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ -subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)" + check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \ + " (backup,fullmesh)" else for st in fullmesh nofullmesh backup,fullmesh; do st=" (${st})" From patchwork Fri Apr 5 10:52:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618898 X-Patchwork-Delegate: kuba@kernel.org 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 201B416C865; Fri, 5 Apr 2024 10:52:43 +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=1712314364; cv=none; b=Ki2NUq/zpvOLYuxGaFTQknYRNKIvuiFppCBTIcMNLOOGmh80BRI5pOPwfsPBUwf/G/dRadJL1wK/Z9gHcafW82eNJgJ1ViNrmDdqNgsRl0of36qKCuBr11yE8S/YErTcFxOJ3M9q/Us6s5fbSnT3pkvSo9iYNB6GoPR++kuRl0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314364; c=relaxed/simple; bh=WdRiy6HK/oka5IiC6YkmLJw1/RyysTXM95OHJrdHMHw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pr6oTlCHsRGS7mwkUsPlv/52oRHtApcqIdyeqVBddchuH9HK6A6tZCeyezRWmowPJjSfXVcPYGPJtwF5JS84jKYNdJT7Cjq4Bnt9exa//bdFUOTWdvVjMo+lxL18pp9TAjXbxu81QNLJx3DfEuIsaYPViXHJtKbPKMFvsffy7tQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ttm1skQA; 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="ttm1skQA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03ABBC43390; Fri, 5 Apr 2024 10:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314363; bh=WdRiy6HK/oka5IiC6YkmLJw1/RyysTXM95OHJrdHMHw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ttm1skQAhOeN/jOxF3z13kalmZf65wwd8fD23T0kY/2hGIDZdn9RWbW+mlDl8BVB2 RDh+16IM5qMRaOqo4kGDvT6fOq55g9Rd+FYOHaYL0yTysoHLytOzzRELcsK/sUkmEN s0suzYg5xru+DAK5W7BUamqBOBdIGO0D11Y8/YqYsdRerBaf//WKUmXjmZkfGeRoVl W/2McxGcJmIDsG2/8uFWPHaWxdwGomNyouwqa+gFVyjUOqdL684h2lRN5OcKY7ZxG8 7pwe5LGN/ftOzaJdXkiHO0KZwealT8vO3f3q8WQ7n3FkN2acXY0UUWfudqri9g5Vc/ 6zb3EaaQ+aIUA== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:10 +0200 Subject: [PATCH net-next 06/11] selftests: mptcp: netlink: add change_address helper Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-6-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=1997; i=matttbe@kernel.org; h=from:subject:message-id; bh=1mO+KsbMEu53NeIIzW9cMyK5QgtJ/nYDKgdCteaDqIc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9flBcijNdTb8U2ePotkbk8EWMG/mdX2wLjCN E3MPfzHMp2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c+6QEACHNR6j8Bnqk6AT+Ua14XQ3QHNh+nxNgBPwib5ZUcNUL5e/XPvl2hu7Yl+d9Uh3OlgNpag /y9haF+/CG+cna/LD/qYIDlW9kA29VfURIg+2AT2czHx8H8vY/vrNS1qD9KczSN7/hwmZTqZCPI Be+5rPFtGl82uiPBTmKN5akOZRTrCIr8sES2Hy6ptcX0Z5PwLIEpYSaDf1Zakgf/O5Bxi5rDPAP LH/J9jxO2KN4/TJAfmSPdHsJYofK1jfBSinb/FngvF5spnNbE5b4XEeCMEeVnRyGCppzBaCChCo IpQ5dax6rtMuu/n9Z5aty8LOy1qtc0BZbbl+G8gxaUcwyNBoJnnMTM0zFFsc66WL/t7HUc8U31P i2WvkkslSqZQfGOcbZvSkGgqoRhy0R3ahdAVFq/tqwIWFTT0fMisJb+XJzbUrf/ArCICg8qY9ih A1yb9SFQ6asldYX/w5WICPEG5SRpG82OATkzsOqUFiD5esd0280p0cB4FWDXUIi7Vrs4XQdzzb8 JYxVhy1RvIkxxRl4/SxQG1YdzWyXptjgMqQG7q8vAW8YsdGUGZDbwy26KNdlw1WkZiLPi2An0cE E1kHGWQAu6rFbrF31xwQwiL2lm3g5MWUpAufUT3wQlYjfyKd7BxF7xlzTLeNFUs4B7Y5AgFloKv ONxtboAKXPsXe+g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The output formats of 'ip mptcp' commands are much different from that of 'pm_nl_ctl' commands. A new 'change_address' helper is added here, to change the flag of an address. This is a bit similar to mptcp_join.sh's pm_nl_change_endpoint(). Usage: Address ID - pm_nl_change_endpoint $ns id $id $flags IP address - change_address $ns $addr $flags Use this new helper in pm_netlink.sh to replace all 'pm_nl_ctl set' commands. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/pm_netlink.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 234b88eba0cb..e27a731bd765 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -75,6 +75,17 @@ get_endpoint() { mptcp_lib_pm_nl_get_endpoint "${ns1}" "${@}" } +change_address() { + local addr=${1} + local flags=${2} + + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns1}" mptcp endpoint change "${addr}" "${flags}" + else + ip netns exec "${ns1}" ./pm_nl_ctl set "${addr}" flags "${flags}" + fi +} + check() { local cmd="$1" @@ -197,10 +208,10 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ ip netns exec $ns1 ./pm_nl_ctl flush ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow -ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags backup +change_address 10.0.1.1 backup check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \ "set flags (backup)" -ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup +change_address 10.0.1.1 nobackup check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ " (nobackup)" From patchwork Fri Apr 5 10:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618899 X-Patchwork-Delegate: kuba@kernel.org 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 BBF7F16D316; Fri, 5 Apr 2024 10:52:46 +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=1712314366; cv=none; b=qkAZmSZXg4iXL0i1eQXvehgJtVRPMSWR3O1mKVkzFxdBOIG0myHHbejD9NZ5d6sRhpMkHNluHT8BfhBfulhZk7waU8K2l/H81kpaBli9PYxv8YRGv5N6Ms6dND/MLJU4ZSAkQ8aBtX1XPRcv12Vnz1RyF1RssKD5SAD0FjxnmrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314366; c=relaxed/simple; bh=cklO41Gnr8RqkCP7eGl0T3qddR+iFR4uJimzzItAXao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IAmJeWPt7LLCpsMsZa6P1cOE3VkaT2SVG8unbNGc9raDUClBhkcbvi03FPZ5/bsyhGidQeOeFdBj7H5ZwL3euqkMpYuEE5y+O7I1ZAyCqFk0PFJePD1QRserFYiyB7X9QRFE8kXNboFIs13ePxAb4tEzJ/tLFiEqFtCjQp4JZE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7FOEtKT; 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="I7FOEtKT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E5E0C433C7; Fri, 5 Apr 2024 10:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314366; bh=cklO41Gnr8RqkCP7eGl0T3qddR+iFR4uJimzzItAXao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I7FOEtKTzEMEu0pZsYWX8dQUPdYd6r3dU+ikAr38R7hVYQ31vQsrE67saphXw7sSV w/t8nuvRWGzFoK8ItXAKtRFf4rJFSvh1iJBFLVCIFB0odvMJbrVZc65VW/SSw8xaDO YSzO55zK17FgMQfyMifniW+7GB34RJZ7QMvZ/nbVRP3tCVNWfIU04LrYODUp/O4ouU T5YwiAn3hE6LjlLDIwVYpg/hdAEYUG65lTDsvrIY1CIhuz3CeeQ8xyYoXxkzjZJE4Y KaXW7n4pkdjw0NkDOKDK4eQ0ELjDiiZffQw46czYOMrykXuf4Fiz1fOLUXRSRFFpCa y8ZSKk1U3HycA== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:11 +0200 Subject: [PATCH net-next 07/11] selftests: mptcp: join: update endpoint ops Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-7-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=3646; i=matttbe@kernel.org; h=from:subject:message-id; bh=9sKu4QP3l55pYCRc5lz8qgHWCijkZyX6+gKVicInu50=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fl653O5H/NmNoUNMAGsdtrT1O/VZ9YGLCbr 2ZPtO9oDceJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c0RTD/sEwyqvlwCzgdhDy6TfcPNucqi0gJ4vapixjhAnjBWQ5ObWcQB6gTvqIbq6xgdy9xy5aM2 wBwNwgio3eT+rl58dNu2MWWIm3s9BMyGC632Y0eav7poqct3sdPUoinPLLBidoyXadCUrtCaiBB Nt1CjYRYSPdouMOOHsbNHCQvyDhxvpR1Gz7vQuvtptAX/T5+a6tXQ1peG/t15+y2SziDUx7kB5o WbWSpeAH0aqPi6K2HkYhAwNoZEvfYXsIJ5Fa5fox16rHYzodCSfvyfJAawT19c3yZBxcJsDW3EK a6FI1HFb+i5SjRSUOz5ePfz6pjxSytYUFLiZnWRaUX3zp+WaOX4IyAG0+yIk6o3PwP0/RZewSgH ezF42pNQdxGiq3HJf5XDpBWd7zHpb8/RLXJdwnhC65RGiIHhtFFxmco2DUX31yQe9fHKSfI9ttx YHw+3e3o2fy1MW3CjmV+M2YGwyLLrSNO+cAfhamQVoPevkrfIpB1SxNZcyx6ailWxG/rZkQ494+ BqZGKUeOuP7HdjBKfRrCyUBDykj4FvO4duo1DOdkTwVm4u1MjD31/n3FaE+FfjiKUPh2TCETdw3 1ouVN0C8z27GAnBrFzWRE9PCOdiNFZ+yiXAWYcZmnst63/D7wl1P1XAKuoH6ypj9Ustc8Wm0Nyi ehDvjVUtCvqcL1A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch uses 'case' statements to simplify pm_nl_add_endpoint() and pm_nl_check_endpoint(). And simplify pm_nl_check_endpoint() with check_output() helper. Also update pm_nl_del_endpoint() to avoid the 'double quote' shellcheck warning. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 72 ++++++++----------------- 1 file changed, 23 insertions(+), 49 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d48da81daa06..8862b6a5caa0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -620,39 +620,27 @@ pm_nl_add_endpoint() { local ns=$1 local addr=$2 - local flags _flags - local port _port - local dev _dev - local id _id + local flags dev id port local nr=2 local p for p in "${@}" do - if [ $p = "flags" ]; then - eval _flags=\$"$nr" - [ -n "$_flags" ]; flags="flags $_flags" - fi - if [ $p = "dev" ]; then - eval _dev=\$"$nr" - [ -n "$_dev" ]; dev="dev $_dev" - fi - if [ $p = "id" ]; then - eval _id=\$"$nr" - [ -n "$_id" ]; id="id $_id" - fi - if [ $p = "port" ]; then - eval _port=\$"$nr" - [ -n "$_port" ]; port="port $_port" - fi + case "${p}" in + "flags" | "dev" | "id" | "port") + eval "${p}"=\$"${nr}" + ;; + esac nr=$((nr + 1)) done if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port + ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} else - ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port + ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} fi } @@ -664,7 +652,7 @@ pm_nl_del_endpoint() if mptcp_lib_is_ip_mptcp; then [ $id -ne 0 ] && addr='' - ip -n $ns mptcp endpoint delete id $id $addr + ip -n $ns mptcp endpoint delete id $id ${addr:+"${addr}"} else ip netns exec $ns ./pm_nl_ctl del $id $addr fi @@ -707,49 +695,35 @@ pm_nl_change_endpoint() pm_nl_check_endpoint() { - local line expected_line local msg="$1" local ns=$2 local addr=$3 - local _flags="" - local _port - local dev - local _id + local flags dev id port print_check "${msg}" shift 3 while [ -n "$1" ]; do - if [ $1 = "flags" ]; then - _flags=$2 + case "${1}" in + "flags" | "dev" | "id" | "port") + eval "${1}"="${2}" shift - elif [ $1 = "dev" ]; then - [ -n "$2" ]; dev="$2" - shift - elif [ $1 = "id" ]; then - _id=$2 - shift - elif [ $1 = "port" ]; then - _port=$2 - shift - fi + ;; + *) + ;; + esac shift done - if [ -z "${_id}" ]; then + if [ -z "${id}" ]; then test_fail "bad test - missing endpoint id" return fi - line=$(mptcp_lib_pm_nl_get_endpoint "${ns}" "${_id}") - expected_line=$(mptcp_lib_pm_nl_format_endpoints \ - "${_id},${addr},${_flags//","/" "},${dev},${_port}") - if [ "$line" = "$expected_line" ]; then - print_ok - else - fail_test "expected '$expected_line' found '$line'" - fi + check_output "mptcp_lib_pm_nl_get_endpoint ${ns} ${id}" \ + "$(mptcp_lib_pm_nl_format_endpoints \ + "${id},${addr},${flags//","/" "},${dev},${port}")" } pm_nl_set_endpoint() From patchwork Fri Apr 5 10:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618900 X-Patchwork-Delegate: kuba@kernel.org 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 CD75E16D33B; Fri, 5 Apr 2024 10:52: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=1712314369; cv=none; b=kI+YWkQtCOfg8kEeGZYBiX0+pBHa7uL4uwOzGt9ekT/n/JWgJNKZbAFLTXgOtdpHcjEZMkTfy3CowQhVd81Yc2Qg1Wvwmhg2pKph0NvuqcFmxQHKllWfSECK8XDR9lLn74zlnxqUasPmn9fX4FBqstVLI1FOPlg1NLP85f7XCvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314369; c=relaxed/simple; bh=waK6o7NL+X08D46c1Uzh5uW3FEozqw+q+E4Twh8dDSI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pb6mks1r/NGWRW0NbMzPoIwWAQw8MXu0ifVAxGW4q1UQarzd9QExUM55ilGDgMDW/EXef1oPCHjAu5/jYsZtbmH4+18eD6uH6hWbgsDAlZ/9INOICK6cBtf1AjvZSDFV7033mPmB+1sChOyBm7I7vdLfJwN4+4CwYnuQF+J8tKo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=npvk0vb9; 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="npvk0vb9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B4B9C43390; Fri, 5 Apr 2024 10:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314369; bh=waK6o7NL+X08D46c1Uzh5uW3FEozqw+q+E4Twh8dDSI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=npvk0vb9UoDYGxAQ3aOuBq2cUowzjsvcB/6AvBie3DZjG5sxqw2BfelpwQcL9+3dL fwMQy7DINIM3SL8t1JhA9gl7yA0GqF1auOhRWUK/I+ToH5LDtBKbukyR9JfKHhZhEw fmtnQVMMXSPq3vqaT7T8V3yhTidy+nflxNqhzwEZVTsAwXx9f7SXlowNpyieeOk0J8 VEC+7dc9vjeKCn+xwTdTRB9ixQnooWwFpf3JS14C7FWprVkQ9uXesLr04maTen0sQ6 zLICxm0GOfcrH5J2wiEyYfr64HzW95O/QQ3dCLEVyYqChEtpyybn/tvz7XB20zgMtN +Ydu8pOKvHyUw== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:12 +0200 Subject: [PATCH net-next 08/11] selftests: mptcp: export pm_nl endpoint ops Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-8-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=5563; i=matttbe@kernel.org; h=from:subject:message-id; bh=UCh5fgsZwb/jdM6yFmZ+1A0KHly8AqybefNoJ/KitEk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9flQu7izI5fWE0dAqPTFv1BYwRr5MSe9O0Kf JJz3rTg+nuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5QAKCRD2t4JPQmmg c2pjD/406w+NcOUr+QjJsiEj3R8zHXm6nmMPvtXeG2XMPsg+BOtAsMpeGWDGTWvBKZzcRe2w/hZ oVtUG7dcsRkNNDwwVZKNReshUnc6AlMk5VbX5l51Sk1Y4fJFA4QR55eNOUFqudgcbdy5d9mVAwB f8pAGmKrieyxBxFKHK5ZGFRy3aZwxQsuj6yw7oCN5eRC6gp/RbgJ52vzQaIbPnbn550aLW6v3Tv gBs4/ZcfU8ccy+W2N1ojw5OfIbHmWqCUw885c9pxweayhvRApomn9WCjdlX8wM1DSc6vWg1CTIs QC1W8uXBiy7uC/ZLSHEYGdLaBYYh2aOhsOb3xjfmUtN+Ww7FIQYvneSN4wv8qO797UtYXqI7UdR qGY2ahsf0IUYTAYdlgD0TMt+FmoZSBvdwZisekkvloyfTJDgsE98ZMGHtqjg5Tekh3gA6mwxt0g mLi4AIDuCCxpS7NFQPHY0r8vcM7su/yC4fCSQKSKGuyoQufGQIu3mVcJBCKhBY1vd8NfnTkXoej WTuNnlRor0f83RMOXEoxv+0eD2lZmlQ1digA1bBi4eyZ5mBpiunH1i0sFI0geEbmwvJCjEetyjm POjNO6tPchki6IzUfVrKC6ma+cQKxIMubc7ETTP/jLXjxcWbflIMxn9IPGAZcT7rY/ZEww31ZAo xrIBTGWvgyE7z4Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch exports six endpoint operation helpers with pm_nl_ prefix, pm_nl_set_limits(), pm_nl_add_endpoint(), pm_nl_del_endpoint(), pm_nl_flush_endpoint(), pm_nl_show_endpoints() and pm_nl_change_endpoint() into mptcp_lib.sh as public functions, and renamed each of them with a mptcp_lib_ prefix. Then these old pm_nl_ prefix helpers in mptcp_join.sh can be wrappers of mptcp_lib_ prefix ones. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 72 ++------------------- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 85 +++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 66 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 8862b6a5caa0..fefa9173bdaa 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -605,92 +605,32 @@ kill_events_pids() pm_nl_set_limits() { - local ns=$1 - local addrs=$2 - local subflows=$3 - - if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows - else - ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows - fi + mptcp_lib_pm_nl_set_limits "${@}" } pm_nl_add_endpoint() { - local ns=$1 - local addr=$2 - local flags dev id port - local nr=2 - - local p - for p in "${@}" - do - case "${p}" in - "flags" | "dev" | "id" | "port") - eval "${p}"=\$"${nr}" - ;; - esac - - nr=$((nr + 1)) - done - - if mptcp_lib_is_ip_mptcp; then - ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \ - ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} - else - ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \ - ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} - fi + mptcp_lib_pm_nl_add_endpoint "${@}" } pm_nl_del_endpoint() { - local ns=$1 - local id=$2 - local addr=$3 - - if mptcp_lib_is_ip_mptcp; then - [ $id -ne 0 ] && addr='' - ip -n $ns mptcp endpoint delete id $id ${addr:+"${addr}"} - else - ip netns exec $ns ./pm_nl_ctl del $id $addr - fi + mptcp_lib_pm_nl_del_endpoint "${@}" } pm_nl_flush_endpoint() { - local ns=$1 - - if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp endpoint flush - else - ip netns exec $ns ./pm_nl_ctl flush - fi + mptcp_lib_pm_nl_flush_endpoint "${@}" } pm_nl_show_endpoints() { - local ns=$1 - - if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp endpoint show - else - ip netns exec $ns ./pm_nl_ctl dump - fi + mptcp_lib_pm_nl_show_endpoints "${@}" } pm_nl_change_endpoint() { - local ns=$1 - local id=$2 - local flags=$3 - - if mptcp_lib_is_ip_mptcp; then - ip -n $ns mptcp endpoint change id $id ${flags//","/" "} - else - ip netns exec $ns ./pm_nl_ctl set id $id flags $flags - fi + mptcp_lib_pm_nl_change_endpoint "${@}" } pm_nl_check_endpoint() diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 4fabb0091940..ad2ebda5cb64 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -555,3 +555,88 @@ mptcp_lib_pm_nl_get_endpoint() { ip netns exec "${ns}" ./pm_nl_ctl get "${id}" fi } + +mptcp_lib_pm_nl_set_limits() { + local ns=${1} + local addrs=${2} + local subflows=${3} + + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns}" mptcp limits set add_addr_accepted "${addrs}" subflows "${subflows}" + else + ip netns exec "${ns}" ./pm_nl_ctl limits "${addrs}" "${subflows}" + fi +} + +mptcp_lib_pm_nl_add_endpoint() { + local ns=${1} + local addr=${2} + local flags dev id port + local nr=2 + + local p + for p in "${@}"; do + case "${p}" in + "flags" | "dev" | "id" | "port") + eval "${p}"=\$"${nr}" + ;; + esac + + nr=$((nr + 1)) + done + + if mptcp_lib_is_ip_mptcp; then + # shellcheck disable=SC2086 # blanks in flags, no double quote + ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} + else + ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \ + ${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"} + fi +} + +mptcp_lib_pm_nl_del_endpoint() { + local ns=${1} + local id=${2} + local addr=${3} + + if mptcp_lib_is_ip_mptcp; then + [ "${id}" -ne 0 ] && addr='' + ip -n "${ns}" mptcp endpoint delete id "${id}" ${addr:+"${addr}"} + else + ip netns exec "${ns}" ./pm_nl_ctl del "${id}" "${addr}" + fi +} + +mptcp_lib_pm_nl_flush_endpoint() { + local ns=${1} + + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns}" mptcp endpoint flush + else + ip netns exec "${ns}" ./pm_nl_ctl flush + fi +} + +mptcp_lib_pm_nl_show_endpoints() { + local ns=${1} + + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns}" mptcp endpoint show + else + ip netns exec "${ns}" ./pm_nl_ctl dump + fi +} + +mptcp_lib_pm_nl_change_endpoint() { + local ns=${1} + local id=${2} + local flags=${3} + + if mptcp_lib_is_ip_mptcp; then + # shellcheck disable=SC2086 # blanks in flags, no double quote + ip -n "${ns}" mptcp endpoint change id "${id}" ${flags//","/" "} + else + ip netns exec "${ns}" ./pm_nl_ctl set id "${id}" flags "${flags}" + fi +} From patchwork Fri Apr 5 10:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618901 X-Patchwork-Delegate: kuba@kernel.org 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 D9FF716D4DD; Fri, 5 Apr 2024 10:52:52 +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=1712314373; cv=none; b=XrVco6IHZRriyvNYZUjZDuuGsyU5ffe1w0Mbaf00lka0sty1HB8onpqb/jyUu06tevNM70jFlsu6HzD3K1ebHwz4flp1ejqPc8x8sM2jIbklrbxqmcXUgWfpbx6dL/iIRt5MkN1Ep5d6FMUqlenP8UD5NA5sevoeXxocSJRAvG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314373; c=relaxed/simple; bh=pTGLSwia1x5RE5RIuTY9QpArinZBbEncrL36CaVw3uw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yqs3VVk9+ink6ZIGaiq0n2FkiikK0t+gOsxqH3XU3urGJdRVPIfFGgzkMHrtucohL8eSS9xE3Gglk9qgquei54xi54bWf4Nx6bJGAzpzUSmCyqYZPqGY3hiAx9KpYYKxwEzhfl0AyBQS6LJwBId9ak3vV9wBmIMAFah55v1gjQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UY4bZt3G; 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="UY4bZt3G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2914DC433B1; Fri, 5 Apr 2024 10:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314372; bh=pTGLSwia1x5RE5RIuTY9QpArinZBbEncrL36CaVw3uw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UY4bZt3GB1fpvpe6pFrKY+B7UbTHiVU//i2GjeZPmo5FXEBXZzcrEZfEGynUS4S36 33cSvixg+zcVCSJDDU6Ve1dwEVg+Rk4b5eXbiobRLGs8avC3FHH5l5iFD/0PZyTntM yPVD2XG2KAdM7JJIe3YEbN40rq88ZGwrMcpJ3B325/czOKVoQvEwXNzB3nEWpEvKhg uHyHC6rVfX/HyFGJX0pVIiqL+o3MYibdg1ZpkBIssQ4+/WiN3Q6jLRMjGt7By7ymFv vPhuqDuyO+4Bfm+UQsB3yQgbj28SdJ4h5K9Y3tRBHoaSdCl+hRC6dB5ywyXhDAY08a XvpmJOBxRmCjQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:13 +0200 Subject: [PATCH net-next 09/11] selftests: mptcp: use pm_nl endpoint ops Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-9-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=10639; i=matttbe@kernel.org; h=from:subject:message-id; bh=SGo6zAcWNTK/FHCff6+pHMfSVpRcpIIH8pR0briaxJs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fmmwUptLYcgjWbSqsyrxo0M4h35XU4oN1iX qDm7qy5gqmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5gAKCRD2t4JPQmmg c8jWD/9QBlyD7dDra6lvtr1bJ30/AZmfYaX9Hpg6XsUonjzh79Jz3lK0dSMAho3QLj5dqrvHRH7 Hxos7oOWvL6rUgiolVVo4NAFCxcMWWvsXrda/lmHWzKJ5PJ6eks3KM8H6VJjrNIeWXZVZPDN9oG FE4gDstps4+ZFTGHg3I5BjxzYmGT/sFjfyDauMoPH6HEGEIzX0YeY1Y/liySAgxeyaikfdF0+29 sfDwmdGWzavIsmMqTbKDbvarFvj9MDkVkuRknRZ/HPbQ8ZEjoPTzt9LOMH/Oh2rB0UGpVY7Xg6u PdLuAI7BeujAplvaKRWh4qbRA6S6Avt1v1vf57dKNTypuu5LET2Fdzu3OeXWFA8Mj/C7H62BrPU Bdle4P3rriIPBnWSQIzwbocgJRz6SetWSywMu4ypTEt6tLbGDaXN7jUHE4k7o9RU7u+jYvO8t8C xuTQdHYn1GrLn1p+RWxcMqjkds3AaEYo30aRgAY/WUkG0zGUj6xC2HG/J86P/01Czd1LKkTkGG6 ff2tkWlaumxSXU93hSrkzVkWjI0XsJch8nARPjO8QVCsPn15NsT2J0QplkT/Y9B4STdK9lGZjpX 5IsqycVEFwtjPKd/sdQK42com2gdk+vYidWrSfnG23GARSx3xYwHjYPQRJLybOMcTnmKrYX0/Or xalCPrtC6f+HMxw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Use those newly added pm_nl endpoint ops helpers to replace all 'pm_nl_ctl' commands with 'limits', 'add', 'del', 'flush', 'show' and 'set' arguments in scripts mptcp_sockopt.sh and simult_flows.sh. In pm_netlink.sh, add wrappers of there helpers to make the function names shorter. Then use the wrappers to replace all 'pm_nl_ctl' commands. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 12 +- tools/testing/selftests/net/mptcp/pm_netlink.sh | 132 +++++++++++++-------- tools/testing/selftests/net/mptcp/simult_flows.sh | 6 +- 3 files changed, 89 insertions(+), 61 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index e2d70c18786e..36e81383f0e2 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -58,15 +58,15 @@ init() # let $ns2 reach any $ns1 address from any interface ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i - ip netns exec $ns1 ./pm_nl_ctl add 10.0.$i.1 flags signal - ip netns exec $ns1 ./pm_nl_ctl add dead:beef:$i::1 flags signal + mptcp_lib_pm_nl_add_endpoint "${ns1}" "10.0.${i}.1" flags signal + mptcp_lib_pm_nl_add_endpoint "${ns1}" "dead:beef:${i}::1" flags signal - ip netns exec $ns2 ./pm_nl_ctl add 10.0.$i.2 flags signal - ip netns exec $ns2 ./pm_nl_ctl add dead:beef:$i::2 flags signal + mptcp_lib_pm_nl_add_endpoint "${ns2}" "10.0.${i}.2" flags signal + mptcp_lib_pm_nl_add_endpoint "${ns2}" "dead:beef:${i}::2" flags signal done - ip netns exec $ns1 ./pm_nl_ctl limits 8 8 - ip netns exec $ns2 ./pm_nl_ctl limits 8 8 + mptcp_lib_pm_nl_set_limits "${ns1}" 8 8 + mptcp_lib_pm_nl_set_limits "${ns2}" 8 8 add_mark_rules $ns1 1 add_mark_rules $ns2 2 diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index e27a731bd765..b3adb39a7d3d 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -86,6 +86,36 @@ change_address() { fi } +set_limits() +{ + mptcp_lib_pm_nl_set_limits "${ns1}" "${@}" +} + +add_endpoint() +{ + mptcp_lib_pm_nl_add_endpoint "${ns1}" "${@}" +} + +del_endpoint() +{ + mptcp_lib_pm_nl_del_endpoint "${ns1}" "${@}" +} + +flush_endpoint() +{ + mptcp_lib_pm_nl_flush_endpoint "${ns1}" +} + +show_endpoints() +{ + mptcp_lib_pm_nl_show_endpoints "${ns1}" +} + +change_endpoint() +{ + mptcp_lib_pm_nl_change_endpoint "${ns1}" "${@}" +} + check() { local cmd="$1" @@ -107,47 +137,47 @@ check() fi } -check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" +check "show_endpoints" "" "defaults addr list" default_limits="$(get_limits)" if mptcp_lib_expect_all_features; then check "get_limits" "$(format_limits 0 2)" "defaults limits" fi -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup +add_endpoint 10.0.1.1 +add_endpoint 10.0.1.2 flags subflow dev lo +add_endpoint 10.0.1.3 flags signal,backup check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr" -check "ip netns exec $ns1 ./pm_nl_ctl dump" \ +check "show_endpoints" \ "$(format_endpoints "1,10.0.1.1" \ "2,10.0.1.2,subflow,lo" \ "3,10.0.1.3,signal backup")" "dump addrs" -ip netns exec $ns1 ./pm_nl_ctl del 2 +del_endpoint 2 check "get_endpoint 2" "" "simple del addr" -check "ip netns exec $ns1 ./pm_nl_ctl dump" \ +check "show_endpoints" \ "$(format_endpoints "1,10.0.1.1" \ "3,10.0.1.3,signal backup")" "dump addrs after del" -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 2>/dev/null +add_endpoint 10.0.1.3 2>/dev/null check "get_endpoint 4" "" "duplicate addr" -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal +add_endpoint 10.0.1.4 flags signal check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment" 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 + add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1 done check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit" check "get_endpoint 10" "" "above hard addr limit" -ip netns exec $ns1 ./pm_nl_ctl del 9 +del_endpoint 9 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 + add_endpoint 10.0.0.9 id "${i}" + del_endpoint "${i}" done -check "ip netns exec $ns1 ./pm_nl_ctl dump" \ +check "show_endpoints" \ "$(format_endpoints "1,10.0.1.1" \ "3,10.0.1.3,signal backup" \ "4,10.0.1.4,signal" \ @@ -156,28 +186,28 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ "7,10.0.1.7,signal" \ "8,10.0.1.8,signal")" "id limit" -ip netns exec $ns1 ./pm_nl_ctl flush -check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" +flush_endpoint +check "show_endpoints" "" "flush addrs" -ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null +set_limits 9 1 2>/dev/null check "get_limits" "${default_limits}" "rcv addrs above hard limit" -ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null +set_limits 1 9 2>/dev/null check "get_limits" "${default_limits}" "subflows above hard limit" -ip netns exec $ns1 ./pm_nl_ctl limits 8 8 +set_limits 8 8 check "get_limits" "$(format_limits 8 8)" "set limits" -ip netns exec $ns1 ./pm_nl_ctl flush -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 id 100 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8 -check "ip netns exec $ns1 ./pm_nl_ctl dump" \ +flush_endpoint +add_endpoint 10.0.1.1 +add_endpoint 10.0.1.2 +add_endpoint 10.0.1.3 id 100 +add_endpoint 10.0.1.4 +add_endpoint 10.0.1.5 id 254 +add_endpoint 10.0.1.6 +add_endpoint 10.0.1.7 +add_endpoint 10.0.1.8 +check "show_endpoints" \ "$(format_endpoints "1,10.0.1.1" \ "2,10.0.1.2" \ "3,10.0.1.7" \ @@ -187,16 +217,16 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ "254,10.0.1.5" \ "255,10.0.1.6")" "set ids" -ip netns exec $ns1 ./pm_nl_ctl flush -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.2 id 254 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.3 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.4 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7 -ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8 -check "ip netns exec $ns1 ./pm_nl_ctl dump" \ +flush_endpoint +add_endpoint 10.0.0.1 +add_endpoint 10.0.0.2 id 254 +add_endpoint 10.0.0.3 +add_endpoint 10.0.0.4 +add_endpoint 10.0.0.5 id 253 +add_endpoint 10.0.0.6 +add_endpoint 10.0.0.7 +add_endpoint 10.0.0.8 +check "show_endpoints" \ "$(format_endpoints "1,10.0.0.1" \ "2,10.0.0.4" \ "3,10.0.0.6" \ @@ -206,28 +236,26 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ "254,10.0.0.2" \ "255,10.0.0.3")" "wrap-around ids" -ip netns exec $ns1 ./pm_nl_ctl flush -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow +flush_endpoint +add_endpoint 10.0.1.1 flags subflow change_address 10.0.1.1 backup -check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \ +check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup")" \ "set flags (backup)" change_address 10.0.1.1 nobackup -check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ +check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \ " (nobackup)" # fullmesh support has been added later -ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null -if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" || +change_endpoint 1 fullmesh 2>/dev/null +if show_endpoints | grep -q "fullmesh" || mptcp_lib_expect_all_features; then - check "ip netns exec $ns1 ./pm_nl_ctl dump" \ - "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \ + check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \ " (fullmesh)" - ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh - check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ + change_endpoint 1 nofullmesh + check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \ " (nofullmesh)" - ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh - check "ip netns exec $ns1 ./pm_nl_ctl dump" \ - "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \ + change_endpoint 1 backup,fullmesh + check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \ " (backup,fullmesh)" else for st in fullmesh nofullmesh backup,fullmesh; do diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 4e6d8fc56b38..3ebb2fb12c8a 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -85,8 +85,8 @@ setup() ip -net "$ns1" route add default via 10.0.2.2 metric 101 ip -net "$ns1" route add default via dead:beef:2::2 metric 101 - ip netns exec "$ns1" ./pm_nl_ctl limits 1 1 - ip netns exec "$ns1" ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags subflow + mptcp_lib_pm_nl_set_limits "${ns1}" 1 1 + mptcp_lib_pm_nl_add_endpoint "${ns1}" 10.0.2.1 dev ns1eth2 flags subflow ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1 ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad @@ -108,7 +108,7 @@ setup() ip -net "$ns3" route add default via 10.0.3.2 ip -net "$ns3" route add default via dead:beef:3::2 - ip netns exec "$ns3" ./pm_nl_ctl limits 1 1 + mptcp_lib_pm_nl_set_limits "${ns3}" 1 1 # debug build can slow down measurably the test program # we use quite tight time limit on the run-time, to ensure From patchwork Fri Apr 5 10:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618902 X-Patchwork-Delegate: kuba@kernel.org 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 4EE9516D9A6; Fri, 5 Apr 2024 10:52:55 +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=1712314376; cv=none; b=konKgbxQPlvsRmf78dkQ6H7K/u8g7GJFKlpQQ1HfFHRtm0vlbm5bGqZox/RKmkd47hVfMs9s7N9xI7qKzhXOM8tECdW+obSo54ByiK3LM+OT+Ws/U0UnZxUcUEo5YA6JBdPVWEcYfQn5hT4eTqmwTPyNg0eRZA9fvj0DLL+aZM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314376; c=relaxed/simple; bh=/rTr+QTnJy+nrMoQt/f15OXgmpM5Wqn4Gt7TYRBqYSw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rm4CmYIq45W5hGtuWfJvV2eU1M+aMzWDq4PKVHyGKbILR9QmAmw7La6xwxdEf/0Sr4O3B+HPaVINY6Ts6vXcv8r69hgqcGYlvqBT11ze1gsGpWNdnXQVY1ln313s1Cld2DDHRaFaz4XhGZ2Qt0ZUUZQghUob3ARsuQn/SlpYGjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X447XcDs; 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="X447XcDs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 384B6C4166B; Fri, 5 Apr 2024 10:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314375; bh=/rTr+QTnJy+nrMoQt/f15OXgmpM5Wqn4Gt7TYRBqYSw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X447XcDsfh+2FJuGE/f5mcksm9/PT2mN/iUve9nxRiednc3gZ8velid3+k9etmMQ1 Nkxa2D8/64fk1HM6Q1L+WoBsn5KojKozePGcQ0S3O271wKVsxo4X9XHSfZfmuPBX2s Zm/e5osyyelqh8cUL68cQbO6RUBwDqlyBzktjqOz/n6tFNwCyqZkyye1QksjHlaptO hC1qtS8yTr2/8r1r3D2IPkGfutcfdNRq5utfoHZvGtBLUc4xKxDW07VT8db4ZY9u7P pcdZZjWCUcRLjlUTgLNYDEZCL6ujFGCYxoPBZlWsXGpC8DkloVwWVLuolQtpOZ9spX TAMBBHsduVD1w== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:14 +0200 Subject: [PATCH net-next 10/11] selftests: mptcp: ip_mptcp option for more scripts Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-10-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=3081; i=matttbe@kernel.org; h=from:subject:message-id; bh=7dJfIPeeIjj3sU94QMXAlNLo3Zxg9tDsg6aNaMsGiDQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fm3g0BXpZOC8lszEBHEYiMIRodGVCNXT5bX XMwMC9ldBuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5gAKCRD2t4JPQmmg c0aDD/9pQhVSDzcgjjhmdAlvu/f+f41QMN7l3SwTdaD5tyAXovaZRIpy1giASUHh95SUYjob05z FTrDUOAL78/MOjtPJSMA9rcg3LjS501a0Fy4Eo8Zo3HmmsVnSda6tQik0Ciq9t+LL1p4GuUDv0P LgOUuTlmoqnIhWMlae0mrlIkmNp18cAbcWe9N1KpwVrpiveqQOOV8MgKirxSimxIREjuLRTGc8I 63aFKhdjI5IcSciAI8VylTCw1gN/3yvy2lv2Qhn9RtDTWXzUNm6g33qbzAel4WusS28uGVUeJRk UPS5p0ZMAKe/vKVz2G2skWXQpNruAzIbgoB7AofPopaDLoExAb3DEOMz5voGZ7+T16Z/UAvuXcg OLysMbb8k6hToRN+8kf3OYxC7iVApRAzlLd2M+PAh2eF6pGGJ7mFjA+sKZJMbJu/XMkYTsT+xsB PMaFWbBNg9aJiY5Noawf4fc/wtxifZhp/GwsylTcFwteP2hjCtUkad3PHro50c79hpR35+1MKz6 Y/HF5qU0HRVPkoYrmtAWvW+vPrDD0QPQG4PXRfCvrgbrswdGggTm4l/ktGyMm6RG4aScL5KPC9y vte/BRfEmf3lQ6hx7HgyxTRP70Ux5MAY5gzOCZ+PD3Mx7G7sKfUwyHI2rMQ+kmKBCfGBlDXZkE2 zMvMU7PnvKZL84w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch adds '-i' option for mptcp_sockopt.sh, pm_netlink.sh, and simult_flows.sh, to use 'ip mptcp' command in the tests instead of 'pm_nl_ctl'. Update usage() correspondingly. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 22 ++++++++++++++++++++++ tools/testing/selftests/net/mptcp/pm_netlink.sh | 9 +++++++-- tools/testing/selftests/net/mptcp/simult_flows.sh | 8 ++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index 36e81383f0e2..68899a303a1a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -22,6 +22,28 @@ ns1="" ns2="" ns_sbox="" +usage() { + echo "Usage: $0 [ -i ] [ -h ]" + echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'" + echo -e "\t-h: help" +} + +while getopts "hi" option;do + case "$option" in + "h") + usage "$0" + exit ${KSFT_PASS} + ;; + "i") + mptcp_lib_set_ip_mptcp + ;; + "?") + usage "$0" + exit ${KSFT_FAIL} + ;; + esac +done + add_mark_rules() { local ns=$1 diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index b3adb39a7d3d..4859fa85d9a0 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -11,16 +11,21 @@ ret=0 usage() { - echo "Usage: $0 [ -h ]" + echo "Usage: $0 [ -i ] [ -h ]" + echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'" + echo -e "\t-h: help" } -optstring=h +optstring=hi while getopts "$optstring" option;do case "$option" in "h") usage $0 exit ${KSFT_PASS} ;; + "i") + mptcp_lib_set_ip_mptcp + ;; "?") usage $0 exit ${KSFT_FAIL} diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index 3ebb2fb12c8a..4b14b4412166 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -27,10 +27,11 @@ capout="" size=0 usage() { - echo "Usage: $0 [ -b ] [ -c ] [ -d ]" + echo "Usage: $0 [ -b ] [ -c ] [ -d ] [ -i]" echo -e "\t-b: bail out after first error, otherwise runs al testcases" echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)" echo -e "\t-d: debug this script" + echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'" } # This function is used in the cleanup trap @@ -259,7 +260,7 @@ run_test() fi } -while getopts "bcdh" option;do +while getopts "bcdhi" option;do case "$option" in "h") usage $0 @@ -274,6 +275,9 @@ while getopts "bcdh" option;do "d") set -x ;; + "i") + mptcp_lib_set_ip_mptcp + ;; "?") usage $0 exit ${KSFT_FAIL} From patchwork Fri Apr 5 10:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13618903 X-Patchwork-Delegate: kuba@kernel.org 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 6207016D9D5; Fri, 5 Apr 2024 10:52:58 +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=1712314379; cv=none; b=k5hRbaNmVOR3yIQoiXWoe30vBcyl42KCS8qiScnWHvD0ZhB6YDchJzFKc+CivYpUZXl5NyXoO4jNmbqMlgGc/wXT7KJwO0wigzkPzEfcXKwqmhV/fmgai9F3EIDq6BguQjdFl3cbJiRbo4uleAZvPFODHQFhnl9FAcDKo5wU7DI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712314379; c=relaxed/simple; bh=fgoj8mb7L9iIjajmasQSVS1V+GYnanZZ2dC6S1meCAs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ckJMu/1jNayXCsSHEBvIPR2KUASU5toMxPPFGNfCGiuz29ghjMSoSWqatmEJ8cciCgEw66Oknk9jq8KI0mosRCznK6aJG6KcnWY1IHUYEo6uFzPtkv1CBmGXnQPFErqooyv2on8lSLSIm7//fQz+7yC2NMC9Rh750SRzsi+dGtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hbqyZprg; 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="hbqyZprg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 444E0C433C7; Fri, 5 Apr 2024 10:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712314378; bh=fgoj8mb7L9iIjajmasQSVS1V+GYnanZZ2dC6S1meCAs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hbqyZprgjdHYpN9ZXwzmxzj3feL/kC5fOzHQc1AfCkwK2OdoGpqe+aHKzwvvPDj3J uLdnXvIglqQoP9UYbKIHgUd+BAg6HfIvaOOPv8QP3ghKIlsbEYTBLgRDP3huiv03ce HgyBEgSkLvJB5QUlMLH66iTSeRFrrLUKjECTxdi+1LmFCn78byLzepphDWeB+Ocqhw 9DRuzTbpX/KthsEMHSkZvQdM+3LF7T0yNqVUlNPPYiujhfeqIGPBImtq2rzcUg1as0 /Z9+8DN5521lxqrzOsSlTjxTc0dJerUXA4k3g2QqoMmEyhnG4W12El0O/Lwr2LOOBC Ws7A8Kso6KW0w== From: "Matthieu Baerts (NGI0)" Date: Fri, 05 Apr 2024 12:52:15 +0200 Subject: [PATCH net-next 11/11] selftests: mptcp: netlink: drop disable=SC2086 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-11-eabc9b960966@kernel.org> References: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@kernel.org> In-Reply-To: <20240405-upstream-net-next-20240405-mptcp-selftests-refactoring-v1-0-eabc9b960966@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=1495; i=matttbe@kernel.org; h=from:subject:message-id; bh=xlQkfbCL4ErvHSP5FwwmBIYPnN6FGH51Kb3aZGA8ojk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmD9fmcHa6BiI0wi6rGAw8wxUcdYt3P3gbi4rnv pZoILgfM5eJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZg/X5gAKCRD2t4JPQmmg cwneD/95yyx0OfnYUP9IrQ29KInbqFdl7JhdnjHOfWsBwn9kgblNW3kDztkzOGqNQCqBbMtMg4Q Yxh7Slbcq/nA5KvwNcvwtD/sntLL1vczQNK7tpheGwwbju/iAjxDLnUv+fhQtnPOG+oCWtNG4Q5 noWvfNx9RAQzVgfp9TAOaZkqZSK6fkn5uppPDdet5eM45IAJGZZTWuyQuPcF0XxI9cMObnBlQlj 4PcsMOGtx46OQz5gm3dmJlMfVxnIdzdotlIZhUx4ojidKwm35ftWaBuxw8n+53tkH13oor5rujG peNnt5mLAlulFQLoLTETeagGwkV6Ski5AMzDvhOcaB8mB7ATTJME9pSGDcJ9jrUvkIdV6jZCPbu b/Qd9JyvuuqAz0C/2SPqfLBAfOVlCRr/LEcTtDbIXkjcNQoFNE8sWYlnMxNTl4Cb8M1BghCekup 8/KX0hpQW7vcFxHC4ic+hSMLnw/diUrhr4j6RV7jiTtCSwNYuB9QoPzJGQBAE2vS2ddbNicz6xC QlP8jXKkpyCa6VPRegrkdLhPiOpTkOcrMLiJXji1BOB3wctQ4Zq9bZucVXB249NtSyJ9WJLH/c0 qhsplxn+AXFu4mTR/NuHd2ItS//H420JrDZbgtmiI/krE+ldfDleZPz55sRutUz3cbhF+4YdUdf zbNuAHCZSkOxFGQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Now there are only a few of variables are not using double quotes. Modifying them, then "shellcheck disable=SC2086" can be dropped. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/pm_netlink.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 4859fa85d9a0..2757378b1b13 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -1,11 +1,6 @@ #!/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 @@ -20,14 +15,14 @@ optstring=hi while getopts "$optstring" option;do case "$option" in "h") - usage $0 + usage "$0" exit ${KSFT_PASS} ;; "i") mptcp_lib_set_ip_mptcp ;; "?") - usage $0 + usage "$0" exit ${KSFT_FAIL} ;; esac @@ -40,7 +35,7 @@ err=$(mktemp) #shellcheck disable=SC2317 cleanup() { - rm -f $err + rm -f "${err}" mptcp_lib_ns_exit "${ns1}" }