Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp956288lqs; Wed, 6 Mar 2024 01:45:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXdKMkqkzoj0+9y9GDpLztDHVTBqVDc16mYzG8k3lfC6KGu3Jp1lFrtUGBlKRSDU/y3yKzQTel15HXhVQB2a4cukONOPL4vIgMVO0BWg== X-Google-Smtp-Source: AGHT+IEy9Qo2ZAmZzvbxkCkt0ETKqunSuEND2A3TPcFeOLsg4k4wH1jG3JE7cscGYWy7Vl2pEUQ3 X-Received: by 2002:a17:906:ccc8:b0:a43:8468:ac0a with SMTP id ot8-20020a170906ccc800b00a438468ac0amr10694389ejb.71.1709718301706; Wed, 06 Mar 2024 01:45:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709718301; cv=pass; d=google.com; s=arc-20160816; b=NcIlNY8fnQP6lVKiufq+NEK1aeYqV7kWCXIOtyCNCgeFdDwJJw7DPhRj0S7c5zyiZQ JMKmZOAad1DidWqbWzm+41G8OTpb27WFAKTBmjd4xibKhiv90CIgGkJqqTfBaESBdfI7 6y1HQ7GUhXiunHc2nPmUZ1BqozPOAi0DwtPPhIJF2wjL5kUzBpHEJ8WzgVwZ9OEVQj6R x1bUqr9L69IjMBTX8I/KCtUTp8/R8tOyYxN/ovwoltF8FNrXDgiOCpmWYYUbnXR+yTpo kpu6ld9d+DXBZiStsNrsNI7bUgLZAQvie7jCKvm1bhsHwo41i8jnhv+vQ4YNlE0uiG7p my8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=aahFnI12MJIxLMF4unbWihhvjWOnVRoFbRuO5zx7MJM=; fh=gM1fTaWoK9TL7webZ8yB3tcO8X47vwS7DNlJ3C0B/Lk=; b=e1mwKnjNulLuO080L1P+hf5xQ58OhoOpjl/lE+4CJSRJU6SxgUNuglZ9PQYvZqhyzi GtjkrguUWrOeG8WglbKfQfUSC4U+YuFhbJTpDeevvtdl6MQ+7dvF5HVddpcAG8GHSiSA 8hvHHZgWe5EslILRZzwfkSKCNX827f6ptC4L3lphSwLqcseaDWPm6QMC9z5ggOf6TuVJ HQbLgHpTknytrHzfowHWanEmtqNxw/HsiBE9sGIlQpAY0m5oexsrdUbO3hkH86/A1DSb 82VjCIMvuSbz3SqKBAejSNgdP1alHNEm6rpEbkQqUOgkJGcoorl2IYidLF3VYwE46Cv4 lm9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eFa3EGlK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h8-20020a1709062dc800b00a446b9dc75bsi5120531eji.997.2024.03.06.01.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 01:45:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eFa3EGlK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93651-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 44A6A1F25076 for ; Wed, 6 Mar 2024 09:45:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1E2D604B6; Wed, 6 Mar 2024 09:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eFa3EGlK" 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 A206C604AD; Wed, 6 Mar 2024 09:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709718205; cv=none; b=mUc9XMVpj82YLOrvuaq0qG/jaAp0IZLod4SQIihbFm8mxrJYX5hqzkuQE/SJMdJfxcvpUaY/QWs7ysypLxXqKAwkwexqMdB0AyMCjzJKjHCdojqY6Ov/yqqYBjAJKHF3V3tXjUP8dW7XH4+ipCOlQtquLYudGA3qpQfougc//hE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709718205; c=relaxed/simple; bh=Cy5OZ0UopSJ8ayXyNJyzR01FZeyqxB46Wwi2MPX5dxY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nC3il/bi6y0pj0AuSZyfsdquc0eTaPhoTbL/3zzZF8pUr8gCiOIW7V2ePcIBjBbovs69R8Y2EvqFFhHHj4Vrqj8Uamk1hMLn9/DM/xHgc6U701Mp9B+mhNsveHa10+tOaSfDIVI4LYmqgsDk/uCz3RbgK9qL4Jknh5JrALZ2k6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eFa3EGlK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1118C43143; Wed, 6 Mar 2024 09:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709718204; bh=Cy5OZ0UopSJ8ayXyNJyzR01FZeyqxB46Wwi2MPX5dxY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eFa3EGlKW6pSwiTdL02C6NdXeeeUYSSE2Y1rBgKQUPPJzWMrmNyKb5hLGGOT8HMLi u7JNtrlf0Vk0CWo1xNtC3qr2ch+dJlJXXk7w0Uxun9oCpBuZ90SLcOvNYwBeptel5n cRYidl6ePdz2qojKMajOQPGGkWPoGwD4FgFynOCqoDkg/bUmsCe+X5eQtOg00Gf9p6 4gkomOCunAbS0ctCz3zO0E7UTMhGdpNvgnahMEnLkSeC4u75KgRtbiy0mUqDByA8uQ 8jPXpkn9f+hFTcaM0lkS6H/nG/uzhG0LfbLEPS2zbsoEKnYwthOnj18erxfkdvbvNT SMDFWJ2KXBN0g== From: "Matthieu Baerts (NGI0)" Date: Wed, 06 Mar 2024 10:42:55 +0100 Subject: [PATCH net-next v2 06/12] selftests: mptcp: add mptcp_lib_events helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-6-bc79e6e5e6a0@kernel.org> References: <20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-0-bc79e6e5e6a0@kernel.org> In-Reply-To: <20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-0-bc79e6e5e6a0@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3467; i=matttbe@kernel.org; h=from:subject:message-id; bh=LDj4VMmcr55UdujwQlhsdRt2+33t1o+1jYIS98CwZdc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl6DqmCaXRMKf7o+vUbBo3aH9myzQo2Ad2z5134 s4eilWKqKSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeg6pgAKCRD2t4JPQmmg cwyFD/44kocG4UcFCaEvVIiHMyZ8aVDuIqgH0us+Qc0WkuTL93z03BTabGtMWs1lczJfU0bBopZ icrGQcz030ToQFxz6nStAnwe93IBqyxT4o2GnygCA2aSs4Y8VXdkGvZ2E/26HcX6CHmFnweON3O Dpf8aG4RlJ2EQKsv+A+31gl1NzozxCoug6qo8g35nAvFgxNUUDWBG24nn78DGI66wP7/NgCRfJO Hct3aatpC2iAstwTunhQjn2R+H+6wlkLg/S1mtf0vamlLIXlm6D25yyJTAe4E6QXsOri9DWAx6l Bp9elTHubtAxf+JaBIfhFs7VWZJtspiVDzY9wJomcREqeCXHFC5UkiuqaEb2xc8iKMkl4R2yuy8 gADgFUzdRs7+1e66uxrHRX3tInZNXdgPYa4hoduPPICSE0KYHvVCxW4w4MXrdqR7mfOUSFX60jl 86BMfvnZo5/w2vVoQRVz0E1Gy6x25/NQOoZxbT9D5djb6q89IFPcIm50YTRV7mNol7U7tZN8zTe 1uBqdXK9fdPs2v6V7zixfeZfXjB/EbhNmYgzC4sachkMo8bOdtXC23Eko86L56V5R3T+nR9cr12 6My05sZU3iB4YhW9qCdToIvcPvGbtG1ldpBV3gOjPE7GSedHwtPYP+GAXeT7UM9/8/5swlbUgD2 M6tET1H/+1h6Ecg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang To avoid duplicated code in different MPTCP selftests, we can add and use helpers defined in mptcp_lib.sh. This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh and mptcp_join.sh into a helper mptcp_lib_events(). Define it in mptcp_lib.sh and use it in both scripts. Note that mptcp_lib_kill_wait is now call before starting 'events' for mptcp_join.sh as well, but that's fine: each test is started from a new netns, so there will not be any existing pid there, and nothing is done when mptcp_lib_kill_wait is called with 0. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++------ tools/testing/selftests/net/mptcp/mptcp_lib.sh | 12 ++++++++++++ tools/testing/selftests/net/mptcp/userspace_pm.sh | 14 ++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 2d9cf6f3bbf3..1df2d24979a0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -430,12 +430,8 @@ reset_with_events() { reset "${1}" || return 1 - :> "$evts_ns1" - :> "$evts_ns2" - ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 & - evts_ns1_pid=$! - ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 & - evts_ns2_pid=$! + mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid + mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid } reset_with_tcp_filter() @@ -608,7 +604,9 @@ wait_mpj() kill_events_pids() { mptcp_lib_kill_wait $evts_ns1_pid + evts_ns1_pid=0 mptcp_lib_kill_wait $evts_ns2_pid + evts_ns2_pid=0 } pm_nl_set_limits() diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 5f44a4ebd185..5d071b6eb780 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -398,3 +398,15 @@ mptcp_lib_ns_exit() { rm -f /tmp/"${netns}".{nstat,out} done } + +mptcp_lib_events() { + local ns="${1}" + local evts="${2}" + declare -n pid="${3}" + + :>"${evts}" + + mptcp_lib_kill_wait "${pid:-0}" + ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 & + pid=$! +} diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 6d71bf36a1b9..3200d0b96d53 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -178,21 +178,11 @@ make_connection() if [ -z "$client_evts" ]; then client_evts=$(mktemp) fi - :>"$client_evts" - if [ $client_evts_pid -ne 0 ]; then - mptcp_lib_kill_wait $client_evts_pid - fi - ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 & - client_evts_pid=$! + mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid if [ -z "$server_evts" ]; then server_evts=$(mktemp) fi - :>"$server_evts" - if [ $server_evts_pid -ne 0 ]; then - mptcp_lib_kill_wait $server_evts_pid - fi - ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 & - server_evts_pid=$! + mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid sleep 0.5 # Run the server -- 2.43.0