From patchwork Wed Nov 30 14:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 27832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp945805wrr; Wed, 30 Nov 2022 06:10:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gLJ1FLVkV7XYrtncdE1NEhM3PSbHap0P/Z+ZhI19xfRSfKwaMRbZp4T75nzTFJQk0fba3 X-Received: by 2002:a17:90b:2810:b0:213:ecb6:b690 with SMTP id qb16-20020a17090b281000b00213ecb6b690mr71844773pjb.244.1669817451361; Wed, 30 Nov 2022 06:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669817451; cv=none; d=google.com; s=arc-20160816; b=aY0ZhjhyHeyU5mpFqc/gyZMCylA83o5GD+epKEN3XKmOwgPfX6q+oE6rNzt4pr/wrJ 8k5Jz7lvvY59o7tUSQnZHzr0BVqE27L7lcFLuYQFJvQGyfTnFkjLN2gaxAGNep7746TK pvAjbk60uwY2qqN+flTvfIn1kURT5QucXBcb/rfNCAYC+hTrEzLKUoW+t/3G4hPSrofl MSGUAoGsijYoiVxJw7fJhZH217nwGfE/RJddcWryzp1WDbi6qwFaMp1EE8+Jdysvrq4P dwkNgDP/F2iYy2+0EPFKTmreGb4LfjHMOg9Bmm41TM2bXEFZdHz8xTjbJDVtUOYP7rNV Fxbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sr2PpWhxUJjRYOqYBbe/QkQ7A3T0Cv15MkXyo/pb3Ys=; b=COmJAiIVHKm9x1wT6tCRqYteVMHohQ35O0Bv8DbcJGVMVrqfNhnm8DEmHFC4yij+q5 bKAL/Rtzy9wFJI72zxpY4Xy3XbgnB2Biw2JAtupN1R7XUIbPWuVXgJn4M7vk5da4CzAl GkxG5sdkboGFFIDDqSfLuRp3dR5Sb1a3Col9tsvl/oAtimQAAlKmC0F/XkpVMp/2EXOy 7xwWLgpgcYwNKAhmRQQY8ks7z4FPxpZL4VFbQLEBEUha+RRzX2uzAK9HiFZv6BT31wDF wHUqitMiTUzAE5lo7G1RqQUzbr+yw73Px1ojEeBvs9h+4D3sPpMTpvA+F5XPTJ3ScgtJ jksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="te/8XCVv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b21-20020a63eb55000000b004600f27528fsi1303431pgk.175.2022.11.30.06.10.35; Wed, 30 Nov 2022 06:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="te/8XCVv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbiK3OJE (ORCPT + 99 others); Wed, 30 Nov 2022 09:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiK3OHk (ORCPT ); Wed, 30 Nov 2022 09:07:40 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F183C8BD1F for ; Wed, 30 Nov 2022 06:07:12 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id bj12so41519126ejb.13 for ; Wed, 30 Nov 2022 06:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sr2PpWhxUJjRYOqYBbe/QkQ7A3T0Cv15MkXyo/pb3Ys=; b=te/8XCVvFXgYoOZPqtT6lepLDkAOy8Joc7cozwgOc9XRuZeM7N3ZCJIBspLoRYMQgB eb7WfhG65rUQU3tTORxGrb5Y38kFk4EsB5UmxHUGqZ6wi+0FM/4xMPQVwz2tWLmsb7/9 Rol/LXdBCSR1vBCQYFbJfa1mJ3qu2mkZ6v1JtfHT80tF47TC0/GmjFoJamIS1ZIb2TWz /qWJcSRLTEPZM/ClqTh41vPN/4oV+BVkDh77ifob5Wr1nON2aC1YPXBD8o7k2ClMfsO5 wWi3pjKHI1F9baAHUJB29n9UpTU5t4elkq05VUekZ0+mc1HYWJ20E6drQpLmyRuY65pW Guyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sr2PpWhxUJjRYOqYBbe/QkQ7A3T0Cv15MkXyo/pb3Ys=; b=3SJaBeYLeDSOtvvehAuXpr9TyxZzWUbkppUyz1hF3J3voI2uLU/nNsG6A7WDCH0gfO E1lfgYpshLvojNihEZlxItygfC8fUoTVslmnODdTErIuv+PIPw391tntk0+mtYjakfbg Mmzz5pfomxGTbgwN1gbpSMbu+kkXK29kK4UrtTlDgvncmFmVkbZcE6uIuFFGMK6ic4t5 FyVPyQfTj9/H6bPqPFRbiI2gBqAkqBXZnucDBMN7Kl9nsdRVwLWsWlNn/I4XxpY7PCNw B9voCvnsTSwgz5z+ldjwX/K6LOj1kogbMa5n2+Bo1sQtT5PG57IPJtqWXNibBh52GAjW IADA== X-Gm-Message-State: ANoB5pl4QgYqPFVEAoit3aWlaGWINjryprJnrVBHJJQTyVcMHYGSlSuD AquzWHKVa7EnaVd6E9omzBkGgQ== X-Received: by 2002:a17:906:8d86:b0:78d:4742:bb62 with SMTP id ry6-20020a1709068d8600b0078d4742bb62mr40839749ejc.43.1669817231344; Wed, 30 Nov 2022 06:07:11 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id mh1-20020a170906eb8100b0073d83f80b05sm692454ejb.94.2022.11.30.06.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 06:07:11 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 10/11] selftests: mptcp: make evts global in mptcp_join Date: Wed, 30 Nov 2022 15:06:32 +0100 Message-Id: <20221130140637.409926-11-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221130140637.409926-1-matthieu.baerts@tessares.net> References: <20221130140637.409926-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3931; i=matthieu.baerts@tessares.net; h=from:subject; bh=jy0B03U7SrhLzNlNUKrDAPk8Nk4bPwGVN5x25PhFK6c=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjh2NpnOwKZdKU09wPqiAzSf1DGh69laqfo7KTdlqS 1JBirrqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4djaQAKCRD2t4JPQmmgcwRbEA C5T21uKknBYwWFEyvIRWOP3qoh4GQvKVV2C2moqK67KLl4CW36OmjAGDfAm3tgAq6x6sxPlfaHhN1o Jod7ick/pd/wqfXqocyrPx/Yorf0TbjrpySKuwqMh5NmcHMVxgenYtS18TzG3AvgcMwYcx/Ijo7yGn QajMkTgEUQA0rEql5my1622INoY52AB6wLGw/Rwp0WdjyAWFAUl1sshcDBW6UGAkRX9jhJWEErB7ow zD4J/wxjADbYKMc5X78wvmUZumsLyDw8ieUYSLPuXyfeTVzWXIfd36viX3MJjboKsnOvpf6Mqy6pfb E7jHpOedyZ943qfZ8d5ZTdA3fFMJAdhsWyoPTvaLeKm6czjzcXaOqcaXEiIDEwFmwqTVCRfhBMAbPc e4VMvWedTkkF6/7j+GsFZ8AGXdcsw55NhY7paYdC9JCxg7UNhO1ftWzZIERMVzcF3oznpCsQZz1tZj pyBHEc85D0tukQoSFOGpNsxu4jEwgkJoVB5L51zkMy1iI399OPRWj5zZgWwmCmJeQwbixclLsvSKjo nHQ5HS8kgKFjECtXX4KzixYb6P7G+cjX4SZ+ne7UuUQciOo3/+JhcTgQI16CX4O//G7eFNwIWuUSra Caf9qXPQ1rE3N3nN7y2BVKk5bWVDBhNO7Mi7IAhe4HvJ9WOKbY5VXDsGTEmg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750930503782652085?= X-GMAIL-MSGID: =?utf-8?q?1750930503782652085?= From: Geliang Tang This patch moves evts_ns1 and evts_ns2 out of do_transfer() as two global variables in mptcp_join.sh. Init them in init() and remove them in cleanup(). Add a new helper reset_with_events() to save the outputs of 'pm_nl_ctl events' command in them. And a new helper kill_events_pids() to kill pids of 'pm_nl_ctl events' command. Use these helpers in userspace pm tests. Suggested-by: Paolo Abeni Signed-off-by: Geliang Tang Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- .../testing/selftests/net/mptcp/mptcp_join.sh | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index f10ef65a7009..32a3694c57fb 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -26,6 +26,10 @@ ip_mptcp=0 check_invert=0 validate_checksum=0 init=0 +evts_ns1="" +evts_ns2="" +evts_ns1_pid=0 +evts_ns2_pid=0 declare -A all_tests declare -a only_tests_ids @@ -154,6 +158,8 @@ init() { cin=$(mktemp) cinsent=$(mktemp) cout=$(mktemp) + evts_ns1=$(mktemp) + evts_ns2=$(mktemp) trap cleanup EXIT @@ -165,6 +171,7 @@ cleanup() { rm -f "$cin" "$cout" "$sinfail" rm -f "$sin" "$sout" "$cinsent" "$cinfail" + rm -rf $evts_ns1 $evts_ns2 cleanup_partial } @@ -320,6 +327,18 @@ reset_with_fail() index 100 || exit 1 } +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=$! +} + fail_test() { ret=1 @@ -473,6 +492,12 @@ kill_wait() wait $1 2>/dev/null } +kill_events_pids() +{ + kill_wait $evts_ns1_pid + kill_wait $evts_ns2_pid +} + pm_nl_set_limits() { local ns=$1 @@ -673,10 +698,6 @@ do_transfer() local port=$((10000 + TEST_COUNT - 1)) local cappid local userspace_pm=0 - local evts_ns1 - local evts_ns1_pid - local evts_ns2 - local evts_ns2_pid :> "$cout" :> "$sout" @@ -753,17 +774,6 @@ do_transfer() addr_nr_ns2=${addr_nr_ns2:9} fi - if [ $userspace_pm -eq 1 ]; then - evts_ns1=$(mktemp) - evts_ns2=$(mktemp) - :> "$evts_ns1" - :> "$evts_ns2" - ip netns exec ${listener_ns} ./pm_nl_ctl events >> "$evts_ns1" 2>&1 & - evts_ns1_pid=$! - ip netns exec ${connector_ns} ./pm_nl_ctl events >> "$evts_ns2" 2>&1 & - evts_ns2_pid=$! - fi - local local_addr if is_v6 "${connect_addr}"; then local_addr="::" @@ -982,12 +992,6 @@ do_transfer() kill $cappid fi - if [ $userspace_pm -eq 1 ]; then - kill_wait $evts_ns1_pid - kill_wait $evts_ns2_pid - rm -rf $evts_ns1 $evts_ns2 - fi - NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ nstat | grep Tcp > /tmp/${listener_ns}.out NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \ @@ -2961,22 +2965,24 @@ userspace_tests() fi # userspace pm add & remove address - if reset "userspace pm add & remove address"; then + if reset_with_events "userspace pm add & remove address"; then set_userspace_pm $ns1 pm_nl_set_limits $ns2 1 1 run_tests $ns1 $ns2 10.0.1.1 0 userspace_1 0 slow chk_join_nr 1 1 1 chk_add_nr 1 1 chk_rm_nr 1 1 invert + kill_events_pids fi # userspace pm create destroy subflow - if reset "userspace pm create destroy subflow"; then + if reset_with_events "userspace pm create destroy subflow"; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 run_tests $ns1 $ns2 10.0.1.1 0 0 userspace_1 slow chk_join_nr 1 1 1 chk_rm_nr 0 1 + kill_events_pids fi }