From patchwork Sun Jul 30 08:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 128210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1449122vqg; Sun, 30 Jul 2023 04:23:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtteNpYDtAwQ201XY39OmNhCXHF8kAYVpBydOsAZPLjuM1oSw940863jvuBLS0S+1JwZ0l X-Received: by 2002:a17:906:5d:b0:99b:4b4f:c9de with SMTP id 29-20020a170906005d00b0099b4b4fc9demr4614548ejg.36.1690716207876; Sun, 30 Jul 2023 04:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690716207; cv=none; d=google.com; s=arc-20160816; b=QWomSczWLTkMsy4agtIJavB+Oom8NH4rLpRvBs1wMrQ2HjMr8CyNizmbqzivh2jMyx 5LbvdZgQuzkA4qgp5i40YMYLR8aWWSvRPzC2JuDNx1rsJJdDlw+qDGFQdIQ6AOvAZyZe YLg+uHTeQbcF3I0zIoPVSB29OfPSenq1edEVwTB/fYS2hhwoKNI+0FTUvPKWLHMI0cgc GjAv1czvN8mpEXoSOhqWBXBD2lcX87uSWs7HFT1xjMLSAqQdFpc8M7eh2odzpTZ3KwC3 fhDrw8kybiLLBr0ZB1ukIX/JuaG+XFHNgDH4XTDqowiNVGLFEGr+TC0IVKcR4jO6kVsd 3lRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=W7Pt2k34U0wophnqJEyN0+qD7Lu+02LNrcd4drHqjcQ=; fh=9UgnUdzL30oFh+UbzKj4E7u1+buBgKOqdJJe+xVkJ8Q=; b=b4x7NY6P5QL+aVH9p5jCZWqz3PejynYd40mphwrWUiB8Ryb9cQomoPaKLzFMp0L4zV z0VvO05KVsglPjd0A26A33Ze8SlVy7LEBjNScNe4+jjkAPFzN/G7TZQD0bPJkzJ0h1ET xVbOOV/LT0FobzpWz/xc+TVmqIzmLSmTPrPJWsVPujgj72+Ls9ZJiBoMLr43cbyuZ08B opiCUcEh+3JnNWQL+GuKAMO80LhKegN32K87K5j/mdeTKNr4nGXvnQizaRm8AZ1kFrm/ tMQN8EA2IKihq8rNNVh6EHogUDT1JTPaT6O61J9h0SP0w157KJ3j/16KJ+GHA0WeKchp QRJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=UgqHsoAx; 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=REJECT sp=REJECT 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 e25-20020a056402089900b0052237401c5csi5523996edy.153.2023.07.30.04.23.03; Sun, 30 Jul 2023 04:23:27 -0700 (PDT) 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=UgqHsoAx; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbjG3IFk (ORCPT + 99 others); Sun, 30 Jul 2023 04:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbjG3IFg (ORCPT ); Sun, 30 Jul 2023 04:05:36 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0319E1FDA for ; Sun, 30 Jul 2023 01:05:32 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3174aac120aso3249561f8f.2 for ; Sun, 30 Jul 2023 01:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1690704331; x=1691309131; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W7Pt2k34U0wophnqJEyN0+qD7Lu+02LNrcd4drHqjcQ=; b=UgqHsoAxgaXhz/CXQVs35jlUiuLC0URjA5Ou1P+Mrr+xyW5KUEZG5QIsaxlYZWi9VQ P9PMnaRVXKajH2I9o1VWLZz82LxBzD0MraxG+3tWH4yxGMsrV2Z16ek2nCBCYed03Bc3 YDpt9/Z7xKR+zGwDwudJRZKjx6mq32XwA34KzApzt8n16om1jHbEZ5Q0a5vDttA68L5v mzMvgnF6C7uaePh3JcNb1QXWYlmV1faB1SqfOnt5lCLvkSoIigyar3CdP0aVCmT5mEf6 UIWHdN6b8+gjcP1NL6at6AegoYN/r89GQnt2emdBMfJcoO8X+TgEKeJzG3CGeQYAv+oF WxKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690704331; x=1691309131; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W7Pt2k34U0wophnqJEyN0+qD7Lu+02LNrcd4drHqjcQ=; b=ACrB3vRhU3dusAXKPh48qsvzORSmSpBGMGmJUC4N9PDuwTMtBdG8XR1si22H/OlzXU YTUGTVdjHc7KDfA0DgHQ7nVHTawT6LKCBbtX3dFBFuYymI/Uf48RhtzvZmG6dr0T68Vi AWhnBVEZRbON7WR1rmbBlDs5OMWwFebhziQrnIeJemD4utWhdQ7S2lDuZn3W8UNTrmvc FSgN5vy4dzlyMn6QZhJUqgpy7fqv83sVcPGE5c7yvTRML2yc4+fLqFxoQzBGJCEtgIhu NC81JYsCFYBpXR+LDoyc6tjE5gyZL1Oi7UJqUwJScdH19lSWV2DtAEbIydwWZ0sQMsuD QWYQ== X-Gm-Message-State: ABy/qLbQgY4QuxYVBcAnr8NN0wLK/i3eVbLPRCj5S78uZY6JXM9vrBp8 Yw97aflN8525dg1C6vDQbgLd7w== X-Received: by 2002:a05:6000:1289:b0:317:5ddb:a8bf with SMTP id f9-20020a056000128900b003175ddba8bfmr4005614wrx.29.1690704331341; Sun, 30 Jul 2023 01:05:31 -0700 (PDT) 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 z7-20020a5d4407000000b0031766e99429sm9338684wrq.115.2023.07.30.01.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 01:05:31 -0700 (PDT) From: Matthieu Baerts Date: Sun, 30 Jul 2023 10:05:15 +0200 Subject: [PATCH net-next 1/4] selftests: mptcp: join: rework detailed report MIME-Version: 1.0 Message-Id: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-1-7e9cc530a9cd@tessares.net> References: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> In-Reply-To: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=29528; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=tuU3EDd607pHo9ibiMQL4HfGpUYH6rRelVYghja4qRI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkxhnJgvxAtW+BXwR4ydzOSorb8nHqmZFjTiHT8 wp84Un32nKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZMYZyQAKCRD2t4JPQmmg c+VcD/950P1bKD2WBDzg/i2NhGFJn09bMPD/WVA7qkCc1guO39kF2lMFKnwCQ2+/E0pWp9ZJ8rv h3LP3ipf9BgXOwxT6bmkuLCeiip2razdGaA0n85jkbcEdCjfICwXWzlg3Uewkz6GaXTaGqsdgBq /AUpiTWauMmtKb5fi8Ubnf0B53pCQQTtlGY1AriVrXcGvw+TjNN4JHH5O1rJgeIKfd3AK8kiMyj jHSl+PpeKmX8hRv3IbhVZHWxglXtfIn1BxRdeakXeBQx4iQfemETDGFC3Et3QM8hj7HIPbyanLD FnlFGTbVL8hslBJBF5f4Bpo7k3xFBj1oVKomkBxI4BrwHeE1kh896ayUlU2Li+juOz011QwykwN Gwpq0BqlndxTD4DyhUQzkBJFgczwOK4RZlfwAkvAwHChBUi263elQGnzizpweLTOie1k5j2W11X nnkTdEZwaNz3eN4YVH2TxIorCL8usk/W0c8DKnQRJhx16/g0z0haERi57/quGFQ0Cg8a/XXTcgB FtX1oQrmAxJW7sOzXdjL7tMu9zuGiwn/e1WsnlQObwdNKZHG63y2AWORrn6Fz5+j6KFra6xxXuF FKhb8H61j3AONlTUEhyzoUgWa1xNLl0dbteN3gm+IJaL7Hrn6IbpTo535YKDATbXDF0ES0/iFIe S7faEccUrTT/HtA== 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,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772844438222812768 X-GMAIL-MSGID: 1772844438222812768 This patch modifies how the detailed results are printed, mainly to improve what is displayed in case of issue: - Now the test name (title) is printed earlier, when starting the test if it is not intentionally skipped: by doing that, errors linked to a test will be printed after having written the test name and then avoid confusions. - Due to the previous item, it is required to add a new line after having printed the test name because in case of error with a command, it is better not to have the output in the middle of the screen. - Each check is printed on a dedicated line with aligned status (ok, skip, fail): it is easier to spot which one has failed, simpler to manage in the code not having to deal with alignment case by case and helpers can be used to uniform what is done. These helpers can also be useful later to do more actions depending on the results or change in one place what is printed. - Info messages have been reduced and aligned as well. And info messages about the creation of the default test files of 1 KB are no longer printed. Example: 001 no JOIN syn [ ok ] synack [ ok ] ack [ ok ] Or with a skip and a failure: 001 no JOIN syn [ ok ] synack [fail] got 42 JOIN[s] synack expected 0 Server ns stats (...) Client ns stats (...) ack [skip] Or with info: 104 Infinite map Test file (size 128 KB) for client Test file (size 128 KB) for server file received by server has inverted byte at 169 5 corrupted pkts syn [ ok ] synack [ ok ] While at it, verify_listener_events() now also print more info in case of failure and in pm_nl_check_endpoint(), the test is marked as failed instead of skipped if no ID has been given (internal selftest issue). Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 450 +++++++++++------------- 1 file changed, 214 insertions(+), 236 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 1640749750d4..6da3a6c98ba7 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -49,7 +49,7 @@ declare -a only_tests_names declare -A failed_tests TEST_COUNT=0 TEST_NAME="" -nr_blank=40 +nr_blank=6 # These var are used only in some tests, make sure they are not already set unset FAILING_LINKS @@ -187,8 +187,8 @@ init() { trap cleanup EXIT - make_file "$cin" "client" 1 - make_file "$sin" "server" 1 + make_file "$cin" "client" 1 >/dev/null + make_file "$sin" "server" 1 >/dev/null } cleanup() @@ -200,10 +200,37 @@ cleanup() cleanup_partial } -# $1: msg print_title() { - printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${1}" + printf "%03u %s\n" "${TEST_COUNT}" "${TEST_NAME}" +} + +print_check() +{ + printf "%-${nr_blank}s%-36s" " " "${*}" +} + +print_info() +{ + # It can be empty, no need to print anything then + [ -z "${1}" ] && return + + printf "%-${nr_blank}sInfo: %s\n" " " "${*}" +} + +print_ok() +{ + echo "[ ok ]${1:+ ${*}}" +} + +print_fail() +{ + echo "[fail]${1:+ ${*}}" +} + +print_skip() +{ + echo "[skip]${1:+ ${*}}" } # [ $1: fail msg ] @@ -213,8 +240,8 @@ mark_as_skipped() mptcp_lib_fail_if_expected_feature "${msg}" - print_title "[ skip ] ${msg}" - printf "\n" + print_check "${msg}" + print_skip last_test_skipped=1 } @@ -278,6 +305,8 @@ reset() return 1 fi + print_title + if [ "${init}" != "1" ]; then init else @@ -458,10 +487,13 @@ reset_with_tcp_filter() fi } +# $1: err msg fail_test() { ret=1 + print_fail "${@}" + # just in case a test is marked twice as failed if [ ${last_test_failed} -eq 0 ]; then failed_tests[${TEST_COUNT}]="${TEST_NAME}" @@ -482,7 +514,7 @@ get_failed_tests_ids() print_file_err() { ls -l "$1" 1>&2 - echo "Trailing bytes are: " + echo -n "Trailing bytes are: " tail -c 27 "$1" } @@ -500,8 +532,7 @@ check_transfer() # when truncating we must check the size explicitly out_size=$(wc -c $out | awk '{print $1}') if [ $out_size -ne $bytes ]; then - echo "[ FAIL ] $what output file has wrong size ($out_size, $bytes)" - fail_test + fail_test "$what output file has wrong size ($out_size, $bytes)" return 1 fi @@ -516,14 +547,13 @@ check_transfer() cmp -l "$in" "$out" | while read -r i a b; do local sum=$((0${a} + 0${b})) if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then - echo "[ FAIL ] $what does not match (in, out):" + fail_test "$what does not match (in, out):" print_file_err "$in" print_file_err "$out" - fail_test return 1 else - echo "$what has inverted byte at ${i}" + print_info "$what has inverted byte at ${i}" fi done @@ -537,8 +567,7 @@ do_ping() local connect_addr="$3" if ! ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null; then - echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 - fail_test + fail_test "$listener_ns -> $connect_addr connectivity" fi } @@ -776,10 +805,9 @@ pm_nl_change_endpoint() pm_nl_check_endpoint() { local line expected_line - local need_title=$1 - local msg="$2" - local ns=$3 - local addr=$4 + local msg="$1" + local ns=$2 + local addr=$3 local _flags="" local flags local _port @@ -788,13 +816,9 @@ pm_nl_check_endpoint() local _id local id - if [ "${need_title}" = 1 ]; then - printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${msg}" - else - printf "%-${nr_blank}s %s" " " "${msg}" - fi + print_check "${msg}" - shift 4 + shift 3 while [ -n "$1" ]; do if [ $1 = "flags" ]; then _flags=$2 @@ -817,7 +841,7 @@ pm_nl_check_endpoint() done if [ -z "$id" ]; then - echo "[skip] bad test - missing endpoint id" + test_fail "bad test - missing endpoint id" return fi @@ -840,10 +864,9 @@ pm_nl_check_endpoint() [ -n "$_port" ] && expected_line="$expected_line $_port" fi if [ "$line" = "$expected_line" ]; then - echo "[ ok ]" + print_ok else - echo "[fail] expected '$expected_line' found '$line'" - fail_test + fail_test "expected '$expected_line' found '$line'" fi } @@ -1058,8 +1081,7 @@ do_transfer() local trunc_size="" if [ -n "${fastclose}" ]; then if [ ${test_linkfail} -le 1 ]; then - echo "fastclose tests need test_linkfail argument" - fail_test + fail_test "fastclose tests need test_linkfail argument" return 1 fi @@ -1074,8 +1096,7 @@ do_transfer() extra_srv_args="-f ${test_linkfail}" extra_cl_args="-f -1" else - echo "wrong/unknown fastclose spec ${side}" - fail_test + fail_test "wrong/unknown fastclose spec ${side}" return 1 fi fi @@ -1136,7 +1157,7 @@ do_transfer() nstat | grep Tcp > /tmp/${connector_ns}.out if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then - echo " client exit code $retc, server $rets" 1>&2 + fail_test "client exit code $retc, server $rets" echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2 ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port" cat /tmp/${listener_ns}.out @@ -1145,7 +1166,6 @@ do_transfer() cat /tmp/${connector_ns}.out cat "$capout" - fail_test return 1 fi @@ -1180,7 +1200,7 @@ make_file() dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name" - echo "Created $name (size $size KB) containing data sent by $who" + print_info "Test file (size $size KB) for $who" } run_tests() @@ -1261,36 +1281,34 @@ chk_csum_nr() csum_ns2=${csum_ns2:1} fi - printf "%-${nr_blank}s %s" " " "sum" + print_check "sum" count=$(get_counter ${ns1} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns1" ]; then extra_msg="$extra_msg ns1=$count" fi if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } || { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then - echo "[fail] got $count data checksum error[s] expected $csum_ns1" - fail_test + fail_test "got $count data checksum error[s] expected $csum_ns1" else - echo -n "[ ok ]" + print_ok fi - echo -n " - csum " + print_check "csum" count=$(get_counter ${ns2} "MPTcpExtDataCsumErr") if [ "$count" != "$csum_ns2" ]; then extra_msg="$extra_msg ns2=$count" fi if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } || { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then - echo "[fail] got $count data checksum error[s] expected $csum_ns2" - fail_test + fail_test "got $count data checksum error[s] expected $csum_ns2" else - echo -n "[ ok ]" + print_ok fi - echo "$extra_msg" + print_info "$extra_msg" } chk_fail_nr() @@ -1308,7 +1326,7 @@ chk_fail_nr() if [[ $ns_invert = "invert" ]]; then ns_tx=$ns2 ns_rx=$ns1 - extra_msg=" invert" + extra_msg="invert" fi if [[ "${fail_tx}" = "-"* ]]; then @@ -1320,37 +1338,35 @@ chk_fail_nr() fail_rx=${fail_rx:1} fi - printf "%-${nr_blank}s %s" " " "ftx" + print_check "ftx" count=$(get_counter ${ns_tx} "MPTcpExtMPFailTx") if [ "$count" != "$fail_tx" ]; then extra_msg="$extra_msg,tx=$count" fi if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } || { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then - echo "[fail] got $count MP_FAIL[s] TX expected $fail_tx" - fail_test + fail_test "got $count MP_FAIL[s] TX expected $fail_tx" else - echo -n "[ ok ]" + print_ok fi - echo -n " - failrx" + print_check "failrx" count=$(get_counter ${ns_rx} "MPTcpExtMPFailRx") if [ "$count" != "$fail_rx" ]; then extra_msg="$extra_msg,rx=$count" fi if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } || { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then - echo "[fail] got $count MP_FAIL[s] RX expected $fail_rx" - fail_test + fail_test "got $count MP_FAIL[s] RX expected $fail_rx" else - echo -n "[ ok ]" + print_ok fi - echo "$extra_msg" + print_info "$extra_msg" } chk_fclose_nr() @@ -1361,39 +1377,37 @@ chk_fclose_nr() local count local ns_tx=$ns2 local ns_rx=$ns1 - local extra_msg=" " + local extra_msg="" if [[ $ns_invert = "invert" ]]; then ns_tx=$ns1 ns_rx=$ns2 - extra_msg=${extra_msg}"invert" + extra_msg="invert" fi - printf "%-${nr_blank}s %s" " " "ctx" + print_check "ctx" count=$(get_counter ${ns_tx} "MPTcpExtMPFastcloseTx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$fclose_tx" ]; then extra_msg="$extra_msg,tx=$count" - echo "[fail] got $count MP_FASTCLOSE[s] TX expected $fclose_tx" - fail_test + fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx" else - echo -n "[ ok ]" + print_ok fi - echo -n " - fclzrx" + print_check "fclzrx" count=$(get_counter ${ns_rx} "MPTcpExtMPFastcloseRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$fclose_rx" ]; then extra_msg="$extra_msg,rx=$count" - echo "[fail] got $count MP_FASTCLOSE[s] RX expected $fclose_rx" - fail_test + fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx" else - echo -n "[ ok ]" + print_ok fi - echo "$extra_msg" + print_info "$extra_msg" } chk_rst_nr() @@ -1409,32 +1423,30 @@ chk_rst_nr() if [[ $ns_invert = "invert" ]]; then ns_tx=$ns2 ns_rx=$ns1 - extra_msg=" invert" + extra_msg="invert" fi - printf "%-${nr_blank}s %s" " " "rtx" + print_check "rtx" count=$(get_counter ${ns_tx} "MPTcpExtMPRstTx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ $count -lt $rst_tx ]; then - echo "[fail] got $count MP_RST[s] TX expected $rst_tx" - fail_test + fail_test "got $count MP_RST[s] TX expected $rst_tx" else - echo -n "[ ok ]" + print_ok fi - echo -n " - rstrx " + print_check "rstrx" count=$(get_counter ${ns_rx} "MPTcpExtMPRstRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" -lt "$rst_rx" ]; then - echo "[fail] got $count MP_RST[s] RX expected $rst_rx" - fail_test + fail_test "got $count MP_RST[s] RX expected $rst_rx" else - echo -n "[ ok ]" + print_ok fi - echo "$extra_msg" + print_info "$extra_msg" } chk_infi_nr() @@ -1443,26 +1455,24 @@ chk_infi_nr() local infi_rx=$2 local count - printf "%-${nr_blank}s %s" " " "itx" + print_check "itx" count=$(get_counter ${ns2} "MPTcpExtInfiniteMapTx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$infi_tx" ]; then - echo "[fail] got $count infinite map[s] TX expected $infi_tx" - fail_test + fail_test "got $count infinite map[s] TX expected $infi_tx" else - echo -n "[ ok ]" + print_ok fi - echo -n " - infirx" + print_check "infirx" count=$(get_counter ${ns1} "MPTcpExtInfiniteMapRx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$infi_rx" ]; then - echo "[fail] got $count infinite map[s] RX expected $infi_rx" - fail_test + fail_test "got $count infinite map[s] RX expected $infi_rx" else - echo "[ ok ]" + print_ok fi } @@ -1479,51 +1489,47 @@ chk_join_nr() local corrupted_pkts=${9:-0} local count local with_cookie - local title="${TEST_NAME}" if [ "${corrupted_pkts}" -gt 0 ]; then - title+=": ${corrupted_pkts} corrupted pkts" + print_info "${corrupted_pkts} corrupted pkts" fi - printf "%03u %-36s %s" "${TEST_COUNT}" "${title}" "syn" + print_check "syn" count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$syn_nr" ]; then - echo "[fail] got $count JOIN[s] syn expected $syn_nr" - fail_test + fail_test "got $count JOIN[s] syn expected $syn_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - synack" + print_check "synack" with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies) count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$syn_ack_nr" ]; then # simult connections exceeding the limit with cookie enabled could go up to # synack validation as the conn limit can be enforced reliably only after # the subflow creation if [ "$with_cookie" = 2 ] && [ "$count" -gt "$syn_ack_nr" ] && [ "$count" -le "$syn_nr" ]; then - echo -n "[ ok ]" + print_ok else - echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr" - fail_test + fail_test "got $count JOIN[s] synack expected $syn_ack_nr" fi else - echo -n "[ ok ]" + print_ok fi - echo -n " - ack" + print_check "ack" count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$ack_nr" ]; then - echo "[fail] got $count JOIN[s] ack expected $ack_nr" - fail_test + fail_test "got $count JOIN[s] ack expected $ack_nr" else - echo "[ ok ]" + print_ok fi if [ $validate_checksum -eq 1 ]; then chk_csum_nr $csum_ns1 $csum_ns2 @@ -1548,22 +1554,21 @@ chk_stale_nr() local stale_nr local recover_nr - printf "%-${nr_blank}s %-18s" " " "stale" + print_check "stale" stale_nr=$(get_counter ${ns} "MPTcpExtSubflowStale") recover_nr=$(get_counter ${ns} "MPTcpExtSubflowRecover") if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then - echo "[skip]" + print_skip elif [ $stale_nr -lt $stale_min ] || { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } || [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then - echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ + fail_test "got $stale_nr stale[s] $recover_nr recover[s], " \ " expected stale in range [$stale_min..$stale_max]," \ - " stale-recover delta $stale_delta " - fail_test + " stale-recover delta $stale_delta" dump_stats=1 else - echo "[ ok ]" + print_ok fi if [ "${dump_stats}" = 1 ]; then @@ -1588,103 +1593,93 @@ chk_add_nr() timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) - printf "%-${nr_blank}s %s" " " "add" + print_check "add" count=$(get_counter ${ns2} "MPTcpExtAddAddr") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip # if the test configured a short timeout tolerate greater then expected # add addrs options, due to retransmissions elif [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then - echo "[fail] got $count ADD_ADDR[s] expected $add_nr" - fail_test + fail_test "got $count ADD_ADDR[s] expected $add_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - echo " + print_check "echo" count=$(get_counter ${ns1} "MPTcpExtEchoAdd") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$echo_nr" ]; then - echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" - fail_test + fail_test "got $count ADD_ADDR echo[s] expected $echo_nr" else - echo -n "[ ok ]" + print_ok fi if [ $port_nr -gt 0 ]; then - echo -n " - pt " + print_check "pt" count=$(get_counter ${ns2} "MPTcpExtPortAdd") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$port_nr" ]; then - echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" - fail_test + fail_test "got $count ADD_ADDR[s] with a port-number expected $port_nr" else - echo "[ ok ]" + print_ok fi - printf "%-${nr_blank}s %s" " " "syn" + print_check "syn" count=$(get_counter ${ns1} "MPTcpExtMPJoinPortSynRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$syn_nr" ]; then - echo "[fail] got $count JOIN[s] syn with a different \ - port-number expected $syn_nr" - fail_test + fail_test "got $count JOIN[s] syn with a different \ + port-number expected $syn_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - synack" + print_check "synack" count=$(get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$syn_ack_nr" ]; then - echo "[fail] got $count JOIN[s] synack with a different \ - port-number expected $syn_ack_nr" - fail_test + fail_test "got $count JOIN[s] synack with a different \ + port-number expected $syn_ack_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - ack" + print_check "ack" count=$(get_counter ${ns1} "MPTcpExtMPJoinPortAckRx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$ack_nr" ]; then - echo "[fail] got $count JOIN[s] ack with a different \ - port-number expected $ack_nr" - fail_test + fail_test "got $count JOIN[s] ack with a different \ + port-number expected $ack_nr" else - echo "[ ok ]" + print_ok fi - printf "%-${nr_blank}s %s" " " "syn" + print_check "syn" count=$(get_counter ${ns1} "MPTcpExtMismatchPortSynRx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$mis_syn_nr" ]; then - echo "[fail] got $count JOIN[s] syn with a mismatched \ - port-number expected $mis_syn_nr" - fail_test + fail_test "got $count JOIN[s] syn with a mismatched \ + port-number expected $mis_syn_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - ack " + print_check "ack" count=$(get_counter ${ns1} "MPTcpExtMismatchPortAckRx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$mis_ack_nr" ]; then - echo "[fail] got $count JOIN[s] ack with a mismatched \ - port-number expected $mis_ack_nr" - fail_test + fail_test "got $count JOIN[s] ack with a mismatched \ + port-number expected $mis_ack_nr" else - echo "[ ok ]" + print_ok fi - else - echo "" fi } @@ -1697,28 +1692,26 @@ chk_add_tx_nr() timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) - printf "%-${nr_blank}s %s" " " "add TX" + print_check "add TX" count=$(get_counter ${ns1} "MPTcpExtAddAddrTx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip # if the test configured a short timeout tolerate greater then expected # add addrs options, due to retransmissions elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then - echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr" - fail_test + fail_test "got $count ADD_ADDR[s] TX, expected $add_tx_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - echo TX " + print_check "echo TX" count=$(get_counter ${ns2} "MPTcpExtEchoAddTx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$echo_tx_nr" ]; then - echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" - fail_test + fail_test "got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" else - echo "[ ok ]" + print_ok fi } @@ -1746,24 +1739,23 @@ chk_rm_nr() elif [ $invert = "true" ]; then addr_ns=$ns2 subflow_ns=$ns1 - extra_msg=" invert" + extra_msg="invert" fi - printf "%-${nr_blank}s %s" " " "rm " + print_check "rm" count=$(get_counter ${addr_ns} "MPTcpExtRmAddr") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$rm_addr_nr" ]; then - echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" - fail_test + fail_test "got $count RM_ADDR[s] expected $rm_addr_nr" else - echo -n "[ ok ]" + print_ok fi - echo -n " - rmsf " + print_check "rmsf" count=$(get_counter ${subflow_ns} "MPTcpExtRmSubflow") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ -n "$simult" ]; then local cnt suffix @@ -1775,34 +1767,31 @@ chk_rm_nr() [ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" if [ $count -ge "$rm_subflow_nr" ] && \ [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then - echo -n "[ ok ] $suffix" + print_ok "$suffix" else - echo "[fail] got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]" - fail_test + fail_test "got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]" fi elif [ "$count" != "$rm_subflow_nr" ]; then - echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" - fail_test + fail_test "got $count RM_SUBFLOW[s] expected $rm_subflow_nr" else - echo -n "[ ok ]" + print_ok fi - echo "$extra_msg" + print_info "$extra_msg" } chk_rm_tx_nr() { local rm_addr_tx_nr=$1 - printf "%-${nr_blank}s %s" " " "rm TX " + print_check "rm TX" count=$(get_counter ${ns2} "MPTcpExtRmAddrTx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$rm_addr_tx_nr" ]; then - echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr" - fail_test + fail_test "got $count RM_ADDR[s] expected $rm_addr_tx_nr" else - echo "[ ok ]" + print_ok fi } @@ -1812,52 +1801,44 @@ chk_prio_nr() local mp_prio_nr_rx=$2 local count - printf "%-${nr_blank}s %s" " " "ptx" + print_check "ptx" count=$(get_counter ${ns1} "MPTcpExtMPPrioTx") if [ -z "$count" ]; then - echo -n "[skip]" + print_skip elif [ "$count" != "$mp_prio_nr_tx" ]; then - echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" - fail_test + fail_test "got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" else - echo -n "[ ok ]" + print_ok fi - echo -n " - prx " + print_check "prx" count=$(get_counter ${ns1} "MPTcpExtMPPrioRx") if [ -z "$count" ]; then - echo "[skip]" + print_skip elif [ "$count" != "$mp_prio_nr_rx" ]; then - echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" - fail_test + fail_test "got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" else - echo "[ ok ]" + print_ok fi } chk_subflow_nr() { - local need_title="$1" - local msg="$2" - local subflow_nr=$3 + local msg="$1" + local subflow_nr=$2 local cnt1 local cnt2 local dump_stats - if [ -n "${need_title}" ]; then - printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${msg}" - else - printf "%-${nr_blank}s %s" " " "${msg}" - fi + print_check "${msg}" cnt1=$(ss -N $ns1 -tOni | grep -c token) cnt2=$(ss -N $ns2 -tOni | grep -c token) if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then - echo "[fail] got $cnt1:$cnt2 subflows expected $subflow_nr" - fail_test + fail_test "got $cnt1:$cnt2 subflows expected $subflow_nr" dump_stats=1 else - echo "[ ok ]" + print_ok fi if [ "${dump_stats}" = 1 ]; then @@ -1877,7 +1858,7 @@ chk_mptcp_info() local cnt2 local dump_stats - printf "%-${nr_blank}s %-30s" " " "mptcp_info $info1:$info2=$exp1:$exp2" + print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" | sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q') @@ -1888,11 +1869,10 @@ chk_mptcp_info() [ -z "$cnt2" ] && cnt2=0 if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then - echo "[fail] got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2" - fail_test + fail_test "got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2" dump_stats=1 else - echo "[ ok ]" + print_ok fi if [ "$dump_stats" = 1 ]; then @@ -1914,13 +1894,12 @@ chk_link_usage() local tx_rate=$((tx_link * 100 / tx_total)) local tolerance=5 - printf "%-${nr_blank}s %-18s" " " "link usage" + print_check "link usage" if [ $tx_rate -lt $((expected_rate - tolerance)) ] || \ [ $tx_rate -gt $((expected_rate + tolerance)) ]; then - echo "[fail] got $tx_rate% usage, expected $expected_rate%" - fail_test + fail_test "got $tx_rate% usage, expected $expected_rate%" else - echo "[ ok ]" + print_ok fi } @@ -2835,15 +2814,15 @@ verify_listener_events() if [ $e_type = $LISTENER_CREATED ]; then name="LISTENER_CREATED" elif [ $e_type = $LISTENER_CLOSED ]; then - name="LISTENER_CLOSED" + name="LISTENER_CLOSED " else name="$e_type" fi - printf "%-${nr_blank}s %s %s:%s " " " "$name" "$e_saddr" "$e_sport" + print_check "$name $e_saddr:$e_sport" if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then - printf "[skip]: event not supported\n" + print_skip "event not supported" return fi @@ -2860,11 +2839,10 @@ verify_listener_events() [ $family ] && [ $family = $e_family ] && [ $saddr ] && [ $saddr = $e_saddr ] && [ $sport ] && [ $sport = $e_sport ]; then - echo "[ ok ]" + print_ok return 0 fi - fail_test - echo "[fail]" + fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport" } add_addr_ports_tests() @@ -3469,17 +3447,17 @@ endpoint_tests() run_tests $ns1 $ns2 10.0.1.1 2>/dev/null & wait_mpj $ns1 - pm_nl_check_endpoint 1 "creation" \ + pm_nl_check_endpoint "creation" \ $ns2 10.0.2.2 id 1 flags implicit chk_mptcp_info subflows 1 subflows 1 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 pm_nl_add_endpoint $ns2 10.0.2.2 id 33 - pm_nl_check_endpoint 0 "ID change is prevented" \ + pm_nl_check_endpoint "ID change is prevented" \ $ns2 10.0.2.2 id 1 flags implicit pm_nl_add_endpoint $ns2 10.0.2.2 flags signal - pm_nl_check_endpoint 0 "modif is allowed" \ + pm_nl_check_endpoint "modif is allowed" \ $ns2 10.0.2.2 id 1 flags signal kill_tests_wait fi @@ -3493,17 +3471,17 @@ endpoint_tests() run_tests $ns1 $ns2 10.0.1.1 2>/dev/null & wait_mpj $ns2 - chk_subflow_nr needtitle "before delete" 2 + chk_subflow_nr "before delete" 2 chk_mptcp_info subflows 1 subflows 1 pm_nl_del_endpoint $ns2 2 10.0.2.2 sleep 0.5 - chk_subflow_nr "" "after delete" 1 + chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow wait_mpj $ns2 - chk_subflow_nr "" "after re-add" 2 + chk_subflow_nr "after re-add" 2 chk_mptcp_info subflows 1 subflows 1 kill_tests_wait fi From patchwork Sun Jul 30 08:05:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 128208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1448454vqg; Sun, 30 Jul 2023 04:21:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKdlNRQrF7aQ0OXN5iofuJmtrmggjRp4GCEpLQD4tutDVd81/VfL2GRYigZuacVP72xRpH X-Received: by 2002:a17:902:da81:b0:1b8:36a8:faf9 with SMTP id j1-20020a170902da8100b001b836a8faf9mr8322535plx.38.1690716101730; Sun, 30 Jul 2023 04:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690716101; cv=none; d=google.com; s=arc-20160816; b=Jve9WF6pSDSBodTHHz2z3o3AmbuvAEU8dBz/TOIMDm93BGzB88/srFpQOQhbuZiJDx AyjSh9NtVs7nD/S5Y3UQEQ43IkFxrZZmaJPTu/fLjqLIpqgl6/l3YwzuYbba9ZC3Zsc4 1cMfwb8prIv7vB4t4CZrFGsNJV3R1+3hC8GwJntAMO3RzLR6FlZg4nUislucJL4pVyL2 hwBRbrwxTLobdIjf2JjSc6LklxtIq+dkWkrq6iQoTuwXuJMtdA8F+Pynx8PTEU2Yo8Fr WwAdLVf4MrVwS2NeX0LfKI0mO6hdI+/GKWGtghwmAWgsUgVkLUjz6VwKtnnHZs9H6RUU EcBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=kQqVrg2AxkeCUd4RFlnJm2NAddhvnsPrl7tjyYt2XYM=; fh=9UgnUdzL30oFh+UbzKj4E7u1+buBgKOqdJJe+xVkJ8Q=; b=HMvTmYM75g/CALFeEk96yTd7T6ipSEcmVqr3o+Cb0zydEB2GHNAXOUJrgR22uy8YHM XIZGiJja0V+3bugE+fmJ6Hw0GkaG+FH07VekACKKbgaw5xakJ9t2pjCtvrV7vpEwhYPa 6Ls+o8yTP1GK1SUMXVVVmPIMcUgkQNChmgTgegSrpJ4zdjH728K6s+8OlNt41B7sZCy/ zSKEp1H7aO0vF1UCKEYlNRT1G94LsrOrxeBb+xj032CFMQGC4lLdfg59fhtBN/OaLW4J 9DH2KYB3K4eEmwAoXpbQ19eayzd+2g+GMR5VUr5CYdhCqqEEU66EQQ0kepCIQMFpRd4r JOAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=5okC5Aj5; 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=REJECT sp=REJECT 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 lb12-20020a170902fa4c00b001b89ce303e4si5594011plb.195.2023.07.30.04.21.26; Sun, 30 Jul 2023 04:21:41 -0700 (PDT) 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=5okC5Aj5; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbjG3IFi (ORCPT + 99 others); Sun, 30 Jul 2023 04:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjG3IFg (ORCPT ); Sun, 30 Jul 2023 04:05:36 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F19BC1FDD for ; Sun, 30 Jul 2023 01:05:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-317716a4622so3253169f8f.1 for ; Sun, 30 Jul 2023 01:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1690704332; x=1691309132; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kQqVrg2AxkeCUd4RFlnJm2NAddhvnsPrl7tjyYt2XYM=; b=5okC5Aj5PW/3arYaXCw8luJS22Yb5F6prA74ByuC2wrv64Nul77hf1IiiKHS+AHfHv pwzEpdsZzeTTUl4h5YJJY+JXF+pVkN6HGor5AR84ZVYKB/pyahJwFxeVoK86OsQnmRxQ uIBgIAiA1ZSm2zPtAuRjrO++fNIa8HqbvAwEUAURfjL3w8o8G8IVpnv8z+ob3cJLnifw LMb/EVXGuUYXQVIdlBKwGFCYIRzJDgF+l6X9G+iahb3o0DbrWKUWCnNZfx+NVhFXzqpz kOnOXVeSo3AHMjmKaJnm0qr+zIGfCVTYUvHWQ1sBUsbj+ARrYj2A06X7lwjUIsZBJRjp YH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690704332; x=1691309132; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kQqVrg2AxkeCUd4RFlnJm2NAddhvnsPrl7tjyYt2XYM=; b=VMQBzZ6rnd83Qxv872+DCncvu6QPWxgnBJbSwh5UdBINF8+1suppq6tiRwkl4/eSfj 8DLc1V5jqpw1YLqIWP+ieGvBxT04IO+R8GCT76/YqHYEUHRSKD8iocUZTG2XX1tde1re jkwnL8XnMOlsxBNWVvRSElDgAIDwECIp5/1x1i1MwOV/Sd0vgA9N/nPf7RTcB3Z2KVZG v+HHVY+xr/vNERDfoZ52lPBBnxDalw1iUVAAUeZX1NCVGdU0jQYupfoOlkxwLd4Ho+Au NXERZeeHnPD7Eg199hrSLXln07zM/5iO+AuJxmscIXvoiGOJ2/H/pqCsjLXrrNSSFy9D c9Ew== X-Gm-Message-State: ABy/qLYJnSfk2hH5aVCgoNdH26LVOwZiesSR4YhuCTVJoEdAeQX74V+V t2vBVi3DACVvGrCxGfxK7llA7Q== X-Received: by 2002:a05:6000:10cc:b0:314:5376:f0d6 with SMTP id b12-20020a05600010cc00b003145376f0d6mr4543789wrx.52.1690704332551; Sun, 30 Jul 2023 01:05:32 -0700 (PDT) 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 z7-20020a5d4407000000b0031766e99429sm9338684wrq.115.2023.07.30.01.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 01:05:32 -0700 (PDT) From: Matthieu Baerts Date: Sun, 30 Jul 2023 10:05:16 +0200 Subject: [PATCH net-next 2/4] selftests: mptcp: join: colored results MIME-Version: 1.0 Message-Id: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-2-7e9cc530a9cd@tessares.net> References: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> In-Reply-To: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3273; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=GmVKWSiJ8DZnxhxB0kl8fOaIodE+Lir7/6qs2cskk90=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkxhnJl4WfzchoILJExO3108dVUOzhC417y4x41 Ms9Sy1JJvCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZMYZyQAKCRD2t4JPQmmg c0RfD/9bXbfjLoHS4Im02miuggaUqtrL3Z7WfbT1oFymNnIWy/X85nEcnYNv1zPYiME1rwqEvkP 4ASfCChFQ+JMjeTLm/6O8BNxxskGEie73qKVJxMzXWmyTT5Lxm+Hd2lXUGAgBkz0G5+KMy7eHWQ POjXUE49nIWQL8kRcczytUnHao6U+5hPVm8wjOyYOXzqBDfBIjzxA2LAueyCUiQCeEduLyQo7vI PT22O3CarBhZSrQ73E1SJWCICA4YX03+jqlxwupX7MQuQ8KyMQPNMt9EU6rQ0RDaGRvDzlxIE/E quhGBCBpC3Nae6cFyvaR5pBZD4ZbvUxBhucdHwywe2aRH7n18ZIjUv55oLgL8ZuJIy1x93C/eJO O0Ykqjn+xneDH0udWn1a406WP/m5GjkIDQP+YSjkVE/hLy1Sui3puJjPnxh+bdEIB1WScbi0MQm bUKVx8bToJ+TKrZK1YK3tDRd7iq3cRMwHmPVFzFED7pgMvudwoHY30pM1yJCavGmN87zQigCHMT IrzY/n8bPD7MFOrad9EpLPZBdjrUfGyOzlLCld+BsgSOUavc3NLc/+WHLV6QLA3UOtNvWQKoQd5 H8cdRALxxUSW8f2GCnL7vBT8ruaI/VHJrhgdxMXnOgzhYaKBM5Ps0Lkh6n5PvoJk46/MSIgjzVr cVDX3+YVlI8n+Mg== 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,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1772844327245900900 X-GMAIL-MSGID: 1772844327245900900 Thanks to the parent commit, it is easy to change the output and add some colours to help spotting issues. The colours are not used if stdout is redirected or if NO_COLOR env var is set to 1 as specified in https://no-color.org. It is possible to force displaying the colours even if stdout is redirected by setting this env var: SELFTESTS_MPTCP_LIB_COLOR_FORCE=1 Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 8 ++--- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 39 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 6da3a6c98ba7..136d20641fce 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -215,22 +215,22 @@ print_info() # It can be empty, no need to print anything then [ -z "${1}" ] && return - printf "%-${nr_blank}sInfo: %s\n" " " "${*}" + mptcp_lib_print_info " Info: ${*}" } print_ok() { - echo "[ ok ]${1:+ ${*}}" + mptcp_lib_print_ok "[ ok ]${1:+ ${*}}" } print_fail() { - echo "[fail]${1:+ ${*}}" + mptcp_lib_print_err "[fail]${1:+ ${*}}" } print_skip() { - echo "[skip]${1:+ ${*}}" + mptcp_lib_print_warn "[skip]${1:+ ${*}}" } # [ $1: fail msg ] diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index b1a0fdd0408b..92a5befe8039 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -4,10 +4,49 @@ readonly KSFT_PASS=0 readonly KSFT_FAIL=1 readonly KSFT_SKIP=4 + +# shellcheck disable=SC2155 # declare and assign separately readonly KSFT_TEST=$(basename "${0}" | sed 's/\.sh$//g') MPTCP_LIB_SUBTESTS=() +# only if supported (or forced) and not disabled, see no-color.org +if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } && + [ "${NO_COLOR:-}" != "1" ]; then + readonly MPTCP_LIB_COLOR_RED="\E[1;31m" + readonly MPTCP_LIB_COLOR_GREEN="\E[1;32m" + readonly MPTCP_LIB_COLOR_YELLOW="\E[1;33m" + readonly MPTCP_LIB_COLOR_BLUE="\E[1;34m" + readonly MPTCP_LIB_COLOR_RESET="\E[0m" +else + readonly MPTCP_LIB_COLOR_RED= + readonly MPTCP_LIB_COLOR_GREEN= + readonly MPTCP_LIB_COLOR_YELLOW= + readonly MPTCP_LIB_COLOR_BLUE= + readonly MPTCP_LIB_COLOR_RESET= +fi + +# $1: color, $2: text +mptcp_lib_print_color() { + echo -e "${MPTCP_LIB_START_PRINT:-}${*}${MPTCP_LIB_COLOR_RESET}" +} + +mptcp_lib_print_ok() { + mptcp_lib_print_color "${MPTCP_LIB_COLOR_GREEN}${*}" +} + +mptcp_lib_print_warn() { + mptcp_lib_print_color "${MPTCP_LIB_COLOR_YELLOW}${*}" +} + +mptcp_lib_print_info() { + mptcp_lib_print_color "${MPTCP_LIB_COLOR_BLUE}${*}" +} + +mptcp_lib_print_err() { + mptcp_lib_print_color "${MPTCP_LIB_COLOR_RED}${*}" +} + # SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all # features using the last version of the kernel and the selftests to make sure # a test is not being skipped by mistake. From patchwork Sun Jul 30 08:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 128194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1395924vqg; Sun, 30 Jul 2023 01:27:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmFuVzj4EC/CJQfD8IRY45+xjilqFU7GnEKU5QdivUeDvgvLEWNOPmUrrReh/qSXlLMT7U X-Received: by 2002:a05:6a21:7782:b0:131:eeba:184b with SMTP id bd2-20020a056a21778200b00131eeba184bmr7094730pzc.25.1690705677642; Sun, 30 Jul 2023 01:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690705677; cv=none; d=google.com; s=arc-20160816; b=QR/f6wQhH1J/joiLIRqD49ofg7K/jRwomyoExseuZy+9ZgFBG1fCUiPFAop81agFv6 lvFxAZgpsrX/gzU+36Lhlu8bgd13KidGtQ7lCwuSRGprOoQQNUIqsMfY7oX9TXAfVXIo F7C+MfA2BdKtYMxYqIkiZ6SmjBAjsfcHmYdgRFzNuxBXieTThsHFVUBne4zEcwgU7V5Y 7mRoNtpxqOPfl0Gx1l1B2OFd1cs2rVuZoSn6paMyFJEMbzBQZf93p8MIslXPHmU/zFdW ok6bE6cpAFlvY7DG01fAo5DX8foLw3mSl/pNVzVmEZTSUgVu/y6SsiQXXpaqfFmTuppe Ex/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=1dzYnsVvpxbgyrd/hUa2HAaITPH/B+5u9jr/h+TX8qQ=; fh=9UgnUdzL30oFh+UbzKj4E7u1+buBgKOqdJJe+xVkJ8Q=; b=a2/S9VwRhXhmY1H6MB3xDI0Mz32zoJbzA4g3aIn7HgRiHwmycA0E3xpDZr9mutxhFz +BckIF5kw9lAbs0aUrNZXKWbidDxrgZgC2FVodkwW0YgWPsq7eiZgC1NMq9VQrXj5ehW 1AztAdILC+ooCd8j2o8rO/NGBLIvu3bWvAePqbs1zwgaauk+oh8wCiAx2nbNkz3R1hdF /bsJwkfTp37CO6Q6tFwc5J/e1aGK17DOBFhksaeonUsA+O6ENLj//PMJMo9Qm3dWt7h+ iyR8BwugluF4zhuinyV8kJMQl2x2uVdrXAz9LPtHZJL6/YwdEVfdtEl1+KvWoEkfMdBt nlVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="U+Wx0/zt"; 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=REJECT sp=REJECT 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 u64-20020a638543000000b00553ebb05d14si5632977pgd.111.2023.07.30.01.27.44; Sun, 30 Jul 2023 01:27:57 -0700 (PDT) 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="U+Wx0/zt"; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjG3IFn (ORCPT + 99 others); Sun, 30 Jul 2023 04:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbjG3IFh (ORCPT ); Sun, 30 Jul 2023 04:05:37 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A0D1710 for ; Sun, 30 Jul 2023 01:05:35 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-314417861b9so2923045f8f.0 for ; Sun, 30 Jul 2023 01:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1690704334; x=1691309134; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1dzYnsVvpxbgyrd/hUa2HAaITPH/B+5u9jr/h+TX8qQ=; b=U+Wx0/zt83OdlYR7ItjD8uQOEX4px6Tl7Kg5dfRmI3ByHt0+F9KA7yKMzaIAf6J2tx l4Lr1RVSbbSo5+fSgUoJjiS8ZlubOIflWkuAn5vzbuNGtOwSxoCsbgiQhUhLqPr4rZFy h8hebEp4FljT97Fva1xQOBkRqSjBkC04vj5feUdNJEk0PKisoUqubCKarqHOci3IdPwc JObDxJAeNayGh2zLt0WbDzP3by2rJTqdo6En1qzLksYT8vEjcZ4HNFIRg5IPt1RgwDjk zIWgf3IO9DY6+FJI0RxdN53IGdN51vi+N6kMKrgzkAkx6ghwR97lVtW3ca3yjm/cvSsm +FCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690704334; x=1691309134; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1dzYnsVvpxbgyrd/hUa2HAaITPH/B+5u9jr/h+TX8qQ=; b=SGW2FBltdg5tcjiObBk3ZKyz1WaPAW7wvrYqcGVuzb4HxsGwZjDohPcyy2hGKeDF2r 2k8rIhWx/AFjqMQpNHO3aYXBD12MxCe+UnfcJd4H1IwJjopsH7j0942FXRqnk8V1eNs9 z9ke7yFilRl1pM8FE/JGNt+3IvEa2dLfhHZ1DQ3tEZ4+Urx4i39Zkc5HSUeG3cfbYfKY E5m1cLapUEDNPQo62THUspBeiY0tHbYLGIxf0mjrFTBqjduN/a259O9Zb4D4el4EdHOH K1tMXEYeGpDL3hukTbUlvlRL2EGqgWXhL9AG/8z1kct8nLMzq31Fwah5C594MXtbz1My Obkg== X-Gm-Message-State: ABy/qLat3MfdNUiLZ1q4PjxF35zpXmlhm9cw2m+61MJ0CMg+MXeUwjq6 5b7FXKmo0OXoBt/VCoPy9XNT0Q== X-Received: by 2002:adf:e4d0:0:b0:317:64f4:5536 with SMTP id v16-20020adfe4d0000000b0031764f45536mr5678173wrm.44.1690704333580; Sun, 30 Jul 2023 01:05:33 -0700 (PDT) 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 z7-20020a5d4407000000b0031766e99429sm9338684wrq.115.2023.07.30.01.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 01:05:33 -0700 (PDT) From: Matthieu Baerts Date: Sun, 30 Jul 2023 10:05:17 +0200 Subject: [PATCH net-next 3/4] selftests: mptcp: pm_nl_ctl: always look for errors MIME-Version: 1.0 Message-Id: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-3-7e9cc530a9cd@tessares.net> References: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> In-Reply-To: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5804; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=zt5ouxkb3s6zxzf7rDQx31R6QrrKJoR33HG4bTNCNOY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkxhnJRf1S/opybvBh9hwDX4s2576g78dNizyfx AnaaAJgN1GJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZMYZyQAKCRD2t4JPQmmg c5JqD/9Y4sHtT8a9AUwvtB6spBWjAyojPchT3SPEC3W/ROPd5+X38lKc/vo98dzsO+ArsDAVUhQ NgN+wLLS/zauoPt83gVj+lHEuTO4KJRuCpw6RDK7I/pu7FrlhS1QCexsfgC79dyQlGfUd39KorJ q1nyF2zxNfozxjgYmgANMAW7a2tbiDsWx155elIfiXF+jD02lJAKX+vQ0uqoBx6998tbGQga/+v gIofDnmuV6JFtSsYHunz3gC0bMh1YneDWXVqwF80+D2wEdU05FgY8zvmMY6DPmLjsu8EYIraJnx ny61bBH1MZQ8+0quTcDgChCLulb0hEfoZzUMIGU0TJxEI0G5GkTJQqz4iCvH6pQd25/11lfkS7Z usiuFVnefEXabU1gzyV1cqvD5eV1dwhUrwrMuCwxGtMfye0fECUeAEiMwsA5MF1K2nezKB6pli9 rB7o8wmxr8Rq7PIi5126bp+9L3nr2kbtdOui1sSJNBvW/Rfy+Stt1+RvLQYpDUjiQhIARwWqO/M M8rF90Qt4bhTEaCK3V0Q6d3MHFHb3WxT4o6XXkuFIkX2J+Pvi1FkIffg5IHsEybtPI2Lo1gV4zi MUOu3fr0A8GU/U1d6bBboVsqzWzF66q2DWcL8iNN1f7S/QR7B/g5Yrw1+qawqPjGloy9peg2JaU IqlOgDGYm2/1XrA== 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1772833396816669669 X-GMAIL-MSGID: 1772833396816669669 If a Netlink command for the MPTCP path-managers is not valid, it is important to check if there are errors. If yes, they need to be reported instead of being ignored and exiting without errors. Now if no replies are expected, an ACK from the kernelspace is asked by the userspace in order to always expect a reply. We can use the same buffer that is currently always >1024 bytes. Then we can check if there is an error (err->error), print it if any and report the error. After this modification, it is required to mute expected errors in mptcp_join.sh and pm_netlink.sh selftests: - when trying to add a bad endpoint, e.g. duplicated - when trying to set the two limits above the hard limit Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +- tools/testing/selftests/net/mptcp/pm_netlink.sh | 6 ++--- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 33 ++++++++++++++++--------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 136d20641fce..63658b0416fb 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3452,7 +3452,7 @@ endpoint_tests() chk_mptcp_info subflows 1 subflows 1 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 - pm_nl_add_endpoint $ns2 10.0.2.2 id 33 + pm_nl_add_endpoint $ns2 10.0.2.2 id 33 2>/dev/null pm_nl_check_endpoint "ID change is prevented" \ $ns2 10.0.2.2 id 1 flags implicit diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index f32038fe1ee5..8f4ff123a7eb 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -99,7 +99,7 @@ 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" -ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 +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" ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal @@ -127,10 +127,10 @@ id 8 flags signal 10.0.1.8" "id limit" 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 +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" -ip netns exec $ns1 ./pm_nl_ctl limits 1 9 +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" ip netns exec $ns1 ./pm_nl_ctl limits 8 8 diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c index 1887bd61bd9a..49369c4a5f26 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -66,20 +66,25 @@ static int init_genl_req(char *data, int family, int cmd, int version) return off; } -static void nl_error(struct nlmsghdr *nh) +static int nl_error(struct nlmsghdr *nh) { struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(nh); int len = nh->nlmsg_len - sizeof(*nh); uint32_t off; - if (len < sizeof(struct nlmsgerr)) + if (len < sizeof(struct nlmsgerr)) { error(1, 0, "netlink error message truncated %d min %ld", len, sizeof(struct nlmsgerr)); + return -1; + } - if (!err->error) { + if (err->error) { /* check messages from kernel */ struct rtattr *attrs = (struct rtattr *)NLMSG_DATA(nh); + fprintf(stderr, "netlink error %d (%s)\n", + err->error, strerror(-err->error)); + while (RTA_OK(attrs, len)) { if (attrs->rta_type == NLMSGERR_ATTR_MSG) fprintf(stderr, "netlink ext ack msg: %s\n", @@ -91,9 +96,10 @@ static void nl_error(struct nlmsghdr *nh) } attrs = RTA_NEXT(attrs, len); } - } else { - fprintf(stderr, "netlink error %d", err->error); + return -1; } + + return 0; } static int capture_events(int fd, int event_group) @@ -198,7 +204,7 @@ static int capture_events(int fd, int event_group) return 0; } -/* do a netlink command and, if max > 0, fetch the reply */ +/* do a netlink command and, if max > 0, fetch the reply ; nh's size >1024B */ static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max) { struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK }; @@ -207,12 +213,16 @@ static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max) int rem, ret; int err = 0; + /* If no expected answer, ask for an ACK to look for errors if any */ + if (max == 0) { + nh->nlmsg_flags |= NLM_F_ACK; + max = 1024; + } + nh->nlmsg_len = len; ret = sendto(fd, data, len, 0, (void *)&nladdr, sizeof(nladdr)); if (ret != len) error(1, errno, "send netlink: %uB != %uB\n", ret, len); - if (max == 0) - return 0; addr_len = sizeof(nladdr); rem = ret = recvfrom(fd, data, max, 0, (void *)&nladdr, &addr_len); @@ -221,10 +231,11 @@ static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max) /* Beware: the NLMSG_NEXT macro updates the 'rem' argument */ for (; NLMSG_OK(nh, rem); nh = NLMSG_NEXT(nh, rem)) { - if (nh->nlmsg_type == NLMSG_ERROR) { - nl_error(nh); + if (nh->nlmsg_type == NLMSG_DONE) + break; + + if (nh->nlmsg_type == NLMSG_ERROR && nl_error(nh)) err = 1; - } } if (err) error(1, 0, "bailing out due to netlink error[s]"); From patchwork Sun Jul 30 08:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 128196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1396238vqg; Sun, 30 Jul 2023 01:29:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGtgWwzvj5zKp76LjMGEC6pEx3pcM4WOZ1lAlgX0rDsffmn/Mtaf7cKaVTo2juQvtm2suhE X-Received: by 2002:a05:6a21:6da7:b0:11f:c1a1:8c with SMTP id wl39-20020a056a216da700b0011fc1a1008cmr9479446pzb.54.1690705759982; Sun, 30 Jul 2023 01:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690705759; cv=none; d=google.com; s=arc-20160816; b=bchyXNaBo0l8hMb2Nv1Hwq0cmHQdb1m+LlvjwldwSpsaMR+DHwqeI6iqz1cpTrE/Q9 PxvZWLCDZrQQs99BKZJn1iHl+cnhzsq/8psUVM/x6gKRLXV68qJGMilVOpPX3n2RDAl1 JFZIu9AIh0NOZDnHoCn5mKE6Pst0I0aX2pmtnDIPvNTgue4dH4iwoF4EUcWdTJuKAwRV /BWfjg2qb3/YVt4VEozcvUppLjv0F4Y49HFw3ziX07K7eWUTSUCAuHQSQXoipJy3syon NUeTu0+mwnhZWXhVISUoHFs0sluIwFJ/EMCzU/sE85MTW26G4bqBq6yqdwLFkpjb2eUW gBJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=TCqeCrU2BUMxCmMmdaeVjNV60zHyKZc+fhAxY8XjBeU=; fh=9UgnUdzL30oFh+UbzKj4E7u1+buBgKOqdJJe+xVkJ8Q=; b=ecr4zFSF6RrPgSSw9chRvaHUhqgwNLfdPqSlfVeJE9vC6UCIlrE6CYAxFuB0BzFHI9 TCMHOvmY6eej8M5qX5nv6lK4YmdbbNtZwy8BqFymn8DLMiiKbF5uziJUV+aY/bbCsz4J jtPHGlNhdUJMC3h+SEZouJhK7UVwCRYcmKblZPJbCsu9AyT36kjQ8ra3xgYWFfOuAJZv K9U+9hvmQBSSgH8YmekYIJCjbPZjSwsfgesZpyGXOYA5IVnjB9Oh01tpuDY5UhdBNHYn Zp5aPZcw89c+x/aALoXh6b8JcMxsgJtEesSZ+NEcmEv53WhVSiPrpnqam3nvoefqRA1D A6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=VHrrFm9h; 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=REJECT sp=REJECT 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 bv127-20020a632e85000000b00543a89c95c2si5502311pgb.207.2023.07.30.01.29.07; Sun, 30 Jul 2023 01:29:19 -0700 (PDT) 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=VHrrFm9h; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjG3IFr (ORCPT + 99 others); Sun, 30 Jul 2023 04:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjG3IFi (ORCPT ); Sun, 30 Jul 2023 04:05:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4235B1FE7 for ; Sun, 30 Jul 2023 01:05:36 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fd190065a8so40416885e9.3 for ; Sun, 30 Jul 2023 01:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1690704335; x=1691309135; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TCqeCrU2BUMxCmMmdaeVjNV60zHyKZc+fhAxY8XjBeU=; b=VHrrFm9h1bH0Fa9QZgFGcYoLawQmLPjdabDyJZ7nxZJwnfeH9bQgILDFCp0d83jB7Q EAXmG5b9uT/86Igj/oYHgUfrff0wLs+fFJ+Vlvo3jDksPdLUnwh6t4j60uK2aIDfXw6Q +ocSCQTkbby0co6GhFa4K2Vz31GLq9FAkYvD7w20SS6Z/O9HCklDpw+NuceIhlKSbKM9 dSJoCc1yn7lDyF1jlkqe3J+NDf2h76MsGgZ4PZGFFCJ4kYSwCkrqPQVBVxpWMb0+zeRy u11uMXMr+87PC3Vn9Wz7JKliN+IUotcXtTQicj2MqwEwuTVbHtqkQTCs8hclkIQY7rcw ilPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690704335; x=1691309135; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TCqeCrU2BUMxCmMmdaeVjNV60zHyKZc+fhAxY8XjBeU=; b=X0Sxlr7eWlK55eGWi/vORvSFEGM+y0eCYpU1TP9ohyN3Jq0KFAG2ajw4oBDPNMxGFb bx6xhutOEzFN75cEiQhLsXP5GILlZgRlIf47/4QTUE2QCpaouzyBMqPNW7AVlXm9OwJB +VIGVFhSRhF5xC6u4dWHu3c/PSdJlNaBjFme4c9f9ceMndsqr3eb8vJ6uU7hwF/+piiE SsbdWCajpx3NxTFvh/h0L3kfLgHz57GiEg0zy9vQG7MccB0kHWGzu4Pv6A9+dmLDEt2a 0GyRT5iloUExZbgRWFoYKz4oUC+KO+nbNQiQjfjo8GpLiSqZUi5djUxtwoEYcFeDM0HQ 6Y1g== X-Gm-Message-State: ABy/qLZHBiLZJX6c4hzzUg/OKll4fvR3o5zCqcHxoK4qjJESTQXyr5HD NYgh63ITv741aQwI8RG7+pR2VE/klj6hILj//UTUFebO X-Received: by 2002:a7b:c8ca:0:b0:3fe:1deb:86 with SMTP id f10-20020a7bc8ca000000b003fe1deb0086mr686260wml.28.1690704334598; Sun, 30 Jul 2023 01:05:34 -0700 (PDT) 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 z7-20020a5d4407000000b0031766e99429sm9338684wrq.115.2023.07.30.01.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 01:05:34 -0700 (PDT) From: Matthieu Baerts Date: Sun, 30 Jul 2023 10:05:18 +0200 Subject: [PATCH net-next 4/4] selftests: mptcp: userspace_pm: unmute unexpected errors MIME-Version: 1.0 Message-Id: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-4-7e9cc530a9cd@tessares.net> References: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> In-Reply-To: <20230730-upstream-net-next-20230728-mptcp-selftests-misc-v1-0-7e9cc530a9cd@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=18032; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=H1E8l+IoCAAhEaKmjavXydAmcpLI1bfzXzQFw7v9eF0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkxhnJZCwoyc0XVy636KturOG4/ISQaXMiF8xKu XJ12gbqoiOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZMYZyQAKCRD2t4JPQmmg czhmEADvYmhoAktbkVJ/mwqGZ3oWHGRafcSdxYZsE/KZYF4LxgLao7Ctaf17vTniPNnuH9ymOn8 gUTZO3f6qsafnV4GEbmnrqri4n2E2mQIRsQGGsv1O8NluIZvk59mO/NvoWE0qMewNd48k6VrMl4 D/BJvZtq0tOs1/Ju74GodHmyW/AVNg4p0rt8fsPDswUYR6Ga7s6oXifBSRH7Y5zGfUFsnLkgnd4 OaSEXn5PbKZj3hFILrI445Co9v5/fBK4dViam5SU8ePIVOKWYj1/fQmVE+/TLexZ7QUiMb5AsKL OyZAVU/Bh5u56eQ46UpGq1hxoCTy+DvHd+A5HT9A1aG0zrTDdZkAyj/6mqi/r5UuXEc2Y7p8XjG /2JFohLLvRyVIP800sfksNsY13El83NV3t8Kx8TK4lorE2fPSitiHvOGBUD15WjWxDqcc0UStyC 8XMMoBuINzXM5jAE3IxuhUbWaUl8UrPovamIu0PB7qJH/l3BlajdDeCBhnnE27or4OhW+ErdlxN 3fo7lcypOJs74Hdlwmgme6QNDjP7pdqBEOqqBKv2FVFDqgIotLWv5px5kiKIIJgafVw7sNJ0i5I jASS2vAkSUbLtmWfh9+Y4n5RAhDHI3L6O6V1/QiDGg64KyWXasFcpmtMS7AsycvHol8/gcoOAFW 4JxXdknZzbOU20Q== 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1772833482786026646 X-GMAIL-MSGID: 1772833482786026646 All pm_nl_ctl commands were muted. If there was an unexpected error with one of them, this was simply not visible in the logs, making the analysis very hard. It could also hide misuse of commands by mistake. Now the output is only muted when we do expect to have an error, e.g. when giving invalid arguments on purpose. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 100 +++++++++++----------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 23f8959a8ea8..b25a3e33eb25 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -380,7 +380,7 @@ test_announce() :>"$server_evts" ip netns exec "$ns2"\ ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id $client_addr_id dev\ - ns2eth1 > /dev/null 2>&1 + ns2eth1 print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) => ns1, reuse port" sleep 0.5 verify_announce_event $server_evts $ANNOUNCED $server4_token "10.0.2.2" $client_addr_id \ @@ -389,7 +389,7 @@ test_announce() # ADD_ADDR6 from the client to server machine reusing the subflow port :>"$server_evts" ip netns exec "$ns2" ./pm_nl_ctl ann\ - dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1 > /dev/null 2>&1 + dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1 print_test "ADD_ADDR6 id:${client_addr_id} dead:beef:2::2 (ns2) => ns1, reuse port" sleep 0.5 verify_announce_event "$server_evts" "$ANNOUNCED" "$server6_token" "dead:beef:2::2"\ @@ -399,7 +399,7 @@ test_announce() :>"$server_evts" client_addr_id=$((client_addr_id+1)) ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\ - $client_addr_id dev ns2eth1 port $new4_port > /dev/null 2>&1 + $client_addr_id dev ns2eth1 port $new4_port print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) => ns1, new port" sleep 0.5 verify_announce_event "$server_evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\ @@ -410,7 +410,7 @@ test_announce() # ADD_ADDR from the server to client machine reusing the subflow port ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ - $server_addr_id dev ns1eth2 > /dev/null 2>&1 + $server_addr_id dev ns1eth2 print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) => ns2, reuse port" sleep 0.5 verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\ @@ -419,7 +419,7 @@ test_announce() # ADD_ADDR6 from the server to client machine reusing the subflow port :>"$client_evts" ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\ - $server_addr_id dev ns1eth2 > /dev/null 2>&1 + $server_addr_id dev ns1eth2 print_test "ADD_ADDR6 id:${server_addr_id} dead:beef:2::1 (ns1) => ns2, reuse port" sleep 0.5 verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "dead:beef:2::1"\ @@ -429,7 +429,7 @@ test_announce() :>"$client_evts" server_addr_id=$((server_addr_id+1)) ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ - $server_addr_id dev ns1eth2 port $new4_port > /dev/null 2>&1 + $server_addr_id dev ns1eth2 port $new4_port print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) => ns2, new port" sleep 0.5 verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\ @@ -490,7 +490,7 @@ test_remove() # RM_ADDR from the client to server machine :>"$server_evts" ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id print_test "RM_ADDR id:${client_addr_id} ns2 => ns1" sleep 0.5 verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id" @@ -499,7 +499,7 @@ test_remove() :>"$server_evts" client_addr_id=$(( client_addr_id - 1 )) ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id print_test "RM_ADDR id:${client_addr_id} ns2 => ns1" sleep 0.5 verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id" @@ -507,7 +507,7 @@ test_remove() # RM_ADDR6 from the client to server machine :>"$server_evts" ip netns exec "$ns2" ./pm_nl_ctl rem token "$client6_token" id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id print_test "RM_ADDR6 id:${client_addr_id} ns2 => ns1" sleep 0.5 verify_remove_event "$server_evts" "$REMOVED" "$server6_token" "$client_addr_id" @@ -517,7 +517,7 @@ test_remove() # RM_ADDR from the server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\ - $server_addr_id > /dev/null 2>&1 + $server_addr_id print_test "RM_ADDR id:${server_addr_id} ns1 => ns2" sleep 0.5 verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id" @@ -526,7 +526,7 @@ test_remove() :>"$client_evts" server_addr_id=$(( server_addr_id - 1 )) ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\ - $server_addr_id > /dev/null 2>&1 + $server_addr_id print_test "RM_ADDR id:${server_addr_id} ns1 => ns2" sleep 0.5 verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id" @@ -534,7 +534,7 @@ test_remove() # RM_ADDR6 from the server to client machine :>"$client_evts" ip netns exec "$ns1" ./pm_nl_ctl rem token "$server6_token" id\ - $server_addr_id > /dev/null 2>&1 + $server_addr_id print_test "RM_ADDR6 id:${server_addr_id} ns1 => ns2" sleep 0.5 verify_remove_event "$client_evts" "$REMOVED" "$client6_token" "$server_addr_id" @@ -610,18 +610,18 @@ test_subflows() # Attempt to add a listener at 10.0.2.2: ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\ - "$client4_port" > /dev/null 2>&1 & + "$client4_port" & local listener_pid=$! # ADD_ADDR from client to server machine reusing the subflow port ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id sleep 0.5 # CREATE_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\ - rport "$client4_port" token "$server4_token" > /dev/null 2>&1 + rport "$client4_port" token "$server4_token" sleep 0.5 verify_subflow_events $server_evts $SUB_ESTABLISHED $server4_token $AF_INET "10.0.2.1" \ "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" @@ -635,31 +635,31 @@ test_subflows() # DESTROY_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\ - "$client4_port" token "$server4_token" > /dev/null 2>&1 + "$client4_port" token "$server4_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\ "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" # RM_ADDR from client to server machine ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ - "$client4_token" > /dev/null 2>&1 + "$client4_token" sleep 0.5 # Attempt to add a listener at dead:beef:2::2: ip netns exec "$ns2" ./pm_nl_ctl listen dead:beef:2::2\ - "$client6_port" > /dev/null 2>&1 & + "$client6_port" & listener_pid=$! # ADD_ADDR6 from client to server machine reusing the subflow port :>"$server_evts" ip netns exec "$ns2" ./pm_nl_ctl ann dead:beef:2::2 token "$client6_token" id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id sleep 0.5 # CREATE_SUBFLOW6 from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl csf lip dead:beef:2::1 lid 23 rip\ - dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1 + dead:beef:2::2 rport "$client6_port" token "$server6_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server6_token" "$AF_INET6"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ @@ -673,7 +673,7 @@ test_subflows() # DESTROY_SUBFLOW6 from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" rip\ - dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1 + dead:beef:2::2 rport "$client6_port" token "$server6_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server6_token" "$AF_INET6"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ @@ -681,24 +681,24 @@ test_subflows() # RM_ADDR from client to server machine ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ - "$client6_token" > /dev/null 2>&1 + "$client6_token" sleep 0.5 # Attempt to add a listener at 10.0.2.2: ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\ - $new4_port > /dev/null 2>&1 & + $new4_port & listener_pid=$! # ADD_ADDR from client to server machine using a new port :>"$server_evts" ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\ - $client_addr_id port $new4_port > /dev/null 2>&1 + $client_addr_id port $new4_port sleep 0.5 # CREATE_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2 rport\ - $new4_port token "$server4_token" > /dev/null 2>&1 + $new4_port token "$server4_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server4_token" "$AF_INET"\ "10.0.2.1" "10.0.2.2" "$new4_port" "23"\ @@ -712,32 +712,32 @@ test_subflows() # DESTROY_SUBFLOW from server to client machine :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\ - $new4_port token "$server4_token" > /dev/null 2>&1 + $new4_port token "$server4_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\ "10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2" # RM_ADDR from client to server machine ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ - "$client4_token" > /dev/null 2>&1 + "$client4_token" # Capture events on the network namespace running the client :>"$client_evts" # Attempt to add a listener at 10.0.2.1: ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\ - $app4_port > /dev/null 2>&1 & + $app4_port & listener_pid=$! # ADD_ADDR from server to client machine reusing the subflow port ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ - $server_addr_id > /dev/null 2>&1 + $server_addr_id sleep 0.5 # CREATE_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\ - $app4_port token "$client4_token" > /dev/null 2>&1 + $app4_port token "$client4_token" sleep 0.5 verify_subflow_events $client_evts $SUB_ESTABLISHED $client4_token $AF_INET "10.0.2.2"\ "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" @@ -750,31 +750,31 @@ test_subflows() # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ - $app4_port token "$client4_token" > /dev/null 2>&1 + $app4_port token "$client4_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" # RM_ADDR from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ - "$server4_token" > /dev/null 2>&1 + "$server4_token" sleep 0.5 # Attempt to add a listener at dead:beef:2::1: ip netns exec "$ns1" ./pm_nl_ctl listen dead:beef:2::1\ - $app6_port > /dev/null 2>&1 & + $app6_port & listener_pid=$! # ADD_ADDR6 from server to client machine reusing the subflow port :>"$client_evts" ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\ - $server_addr_id > /dev/null 2>&1 + $server_addr_id sleep 0.5 # CREATE_SUBFLOW6 from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl csf lip dead:beef:2::2 lid 23 rip\ - dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1 + dead:beef:2::1 rport $app6_port token "$client6_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\ "$AF_INET6" "dead:beef:2::2"\ @@ -789,31 +789,31 @@ test_subflows() # DESTROY_SUBFLOW6 from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" rip\ - dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1 + dead:beef:2::1 rport $app6_port token "$client6_token" sleep 0.5 verify_subflow_events $client_evts $SUB_CLOSED $client6_token $AF_INET6 "dead:beef:2::2"\ "dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1" # RM_ADDR6 from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ - "$server6_token" > /dev/null 2>&1 + "$server6_token" sleep 0.5 # Attempt to add a listener at 10.0.2.1: ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\ - $new4_port > /dev/null 2>&1 & + $new4_port & listener_pid=$! # ADD_ADDR from server to client machine using a new port :>"$client_evts" ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ - $server_addr_id port $new4_port > /dev/null 2>&1 + $server_addr_id port $new4_port sleep 0.5 # CREATE_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\ - $new4_port token "$client4_token" > /dev/null 2>&1 + $new4_port token "$client4_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client4_token" "$AF_INET"\ "10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" @@ -826,14 +826,14 @@ test_subflows() # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ - $new4_port token "$client4_token" > /dev/null 2>&1 + $new4_port token "$client4_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" # RM_ADDR from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ - "$server4_token" > /dev/null 2>&1 + "$server4_token" } test_subflows_v4_v6_mix() @@ -842,14 +842,14 @@ test_subflows_v4_v6_mix() # Attempt to add a listener at 10.0.2.1: ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\ - $app6_port > /dev/null 2>&1 & + $app6_port & local listener_pid=$! # ADD_ADDR4 from server to client machine reusing the subflow port on # the established v6 connection :>"$client_evts" ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server6_token" id\ - $server_addr_id dev ns1eth2 > /dev/null 2>&1 + $server_addr_id dev ns1eth2 print_test "ADD_ADDR4 id:${server_addr_id} 10.0.2.1 (ns1) => ns2, reuse port" sleep 0.5 verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "10.0.2.1"\ @@ -858,7 +858,7 @@ test_subflows_v4_v6_mix() # CREATE_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\ - $app6_port token "$client6_token" > /dev/null 2>&1 + $app6_port token "$client6_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\ "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ @@ -872,7 +872,7 @@ test_subflows_v4_v6_mix() # DESTROY_SUBFLOW from client to server machine :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ - $app6_port token "$client6_token" > /dev/null 2>&1 + $app6_port token "$client6_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client6_token" \ "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ @@ -880,7 +880,7 @@ test_subflows_v4_v6_mix() # RM_ADDR from server to client machine ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ - "$server6_token" > /dev/null 2>&1 + "$server6_token" sleep 0.5 } @@ -965,7 +965,7 @@ test_listener() # Attempt to add a listener at 10.0.2.2: ip netns exec $ns2 ./pm_nl_ctl listen 10.0.2.2\ - $client4_port > /dev/null 2>&1 & + $client4_port & local listener_pid=$! sleep 0.5 @@ -973,12 +973,12 @@ test_listener() # ADD_ADDR from client to server machine reusing the subflow port ip netns exec $ns2 ./pm_nl_ctl ann 10.0.2.2 token $client4_token id\ - $client_addr_id > /dev/null 2>&1 + $client_addr_id sleep 0.5 # CREATE_SUBFLOW from server to client machine ip netns exec $ns1 ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\ - rport $client4_port token $server4_token > /dev/null 2>&1 + rport $client4_port token $server4_token sleep 0.5 # Delete the listener from the client ns, if one was created