From patchwork Sat Jun 10 16:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 105988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1635510vqr; Sat, 10 Jun 2023 09:34:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SU0iMsOHr6ytSggd2WSR3ZPuR328+3DuTmFsUlCE3qsbpKGrVWbTpO4Tfb641TBsQUyIC X-Received: by 2002:a17:906:d54f:b0:973:d80f:ea69 with SMTP id cr15-20020a170906d54f00b00973d80fea69mr4842034ejc.29.1686414893480; Sat, 10 Jun 2023 09:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686414893; cv=none; d=google.com; s=arc-20160816; b=kGdiRHFtxQkCXcGf1EBa+8dUVoEUN5UmYc94x3s9kiDvIdfEDzAkyporpytPWEZWpE t5AVyIAtoFpU5FxBV7mg/MKA1BF9gLL2Ii8niGw0gu4ClRuXYBvy/ztudN9AH0RdDsrq HBgVSVtQROn5Ui4kKDQ88dGXWH0RyAKYYkHPDwOm/Y5il3o3byU4C/xNCJ36k98HMhwB EkC75EG30s9Zz+341HGcQk+mSKLzwVEMU3sCmln5nG7MH20qY/efXwH+h64rhyrV3AxF ItUpcW1thGhDTYnBrhPofWwX65ZQzNPTCnEnA5G3BOZfr16PEG/ioxMYd0pIl63JKw71 0bDQ== 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=ebzCN2e3LmW/09+X000OqYT8+BgOfE8XFgbNZ00sNHo=; b=aXlayR9SWmVdL5toJpnvKk9HcEX7Zvwq3APXqqn0pQ7fYGbU84rwKBEfKb134YYhkg gYpArMqXczni/HzAv9W3xSdHarcMODCJ1Q5NcAiBGExzgGyajoDZb+1/KDS2YcrSiIkQ UheXCyeepbnoLhqfSEb4gftpyoq/a6F3RpVffhmQfjmlH9g5abxqul+D7+Rv44tWNhRM JFhuJo8NKmlLx0FFC2+IpBdyTdlDYdszPZd4jumFKoKy1/SBp+j0MC618Wo2ti0mZhWI lklNNHuXunNR/u46NZwxbnJgtvhZMLmF8m35y52vs/76MtIv956gFhOwHn9NTM8cue+j 1rSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=qZyygywp; 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 l8-20020a1709065a8800b009788c7dc3acsi3167247ejq.319.2023.06.10.09.34.29; Sat, 10 Jun 2023 09:34:53 -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=qZyygywp; 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 S230177AbjFJQMS (ORCPT + 99 others); Sat, 10 Jun 2023 12:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjFJQL5 (ORCPT ); Sat, 10 Jun 2023 12:11:57 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F8F43596 for ; Sat, 10 Jun 2023 09:11:53 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso28090705e9.2 for ; Sat, 10 Jun 2023 09:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1686413512; x=1689005512; 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=ebzCN2e3LmW/09+X000OqYT8+BgOfE8XFgbNZ00sNHo=; b=qZyygywpDh1p68o5FlXbw/1HYBnyeEWRQsQeQRdaA5WNu7f/gvtgJsPRrutFm83c8n Qu0SJquCECm4zL2Qwq2dJ1ywUZiWgeeuYM15fnjeEEagRvejvwv4D4+OAIaUgDH8naiv 0QyMzr5jUFllEynf0CapLOeg212lSar2OY4K6/9L+PaxPYSJJGgLPLlk7weSRt3hlOMP bfx4d7hmbpaPAbZHcfFP355nJXv1VouwMEsFtX0+CTOHz5QnVcQtDFP3Q9X7TdX2glPV 0Ghun2EPN4xKxauK+LRskL4FHyb08c1vOb6T3R9BUnjmyWbIAIqlzmAkuyTyDMoqgWjZ wgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686413512; x=1689005512; 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=ebzCN2e3LmW/09+X000OqYT8+BgOfE8XFgbNZ00sNHo=; b=ca2hNoy08RhiX6N/1od/yXeR8XEP8FQm5Br5CvS7Vlm0srtmK/20i9kjm4qE5dTsAM PzDkGQxKPqyW1AAuxb1uoKUkcnoiyEZaoQG/O5IsNz9vdp3PU2EMnAo5izQpXw8rNDwI 5BrqKRP6eIty8o+4APP6BbA25nzhpAGKohSpzqYeKzY47qB0+msyAJt5X8SeO/84Uc8K u7TXAlE1ozzYFFRV8PluRQSBvUHvrccdr+LCea1no72ZWocW7nzlgdwxiYbtoUD28Na8 8MTHc+D9mB09bxITBr9of5fpPsEkCrd9ttFRnv8rjwtqSGSuGpzU25pu+aJf00PCmGsX tUKg== X-Gm-Message-State: AC+VfDwl0Si7uP8xzy0S3YxPOIc9rGylIYdolSXhgv/9dtsAbo5s1OK9 MwNkitpo6qNZ5sYKJwl31XVIhQ== X-Received: by 2002:adf:ec4b:0:b0:309:1532:87e with SMTP id w11-20020adfec4b000000b003091532087emr1744525wrn.31.1686413511996; Sat, 10 Jun 2023 09:11:51 -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 u9-20020a5d4349000000b003079c402762sm7431145wrr.19.2023.06.10.09.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jun 2023 09:11:51 -0700 (PDT) From: Matthieu Baerts Date: Sat, 10 Jun 2023 18:11:40 +0200 Subject: [PATCH net 05/17] selftests: mptcp: join: skip test if iptables/tc cmds fail MIME-Version: 1.0 Message-Id: <20230609-upstream-net-20230610-mptcp-selftests-support-old-kernels-part-3-v1-5-2896fe2ee8a3@tessares.net> References: <20230609-upstream-net-20230610-mptcp-selftests-support-old-kernels-part-3-v1-0-2896fe2ee8a3@tessares.net> In-Reply-To: <20230609-upstream-net-20230610-mptcp-selftests-support-old-kernels-part-3-v1-0-2896fe2ee8a3@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Florian Westphal , Davide Caratti , Christoph Paasch , Geliang Tang , Geliang Tang Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5942; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ikkDavS1p6kc/V5BA9I5ZZiKDslgeSsXhbwNygCFAjw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkhKC+49ffDzzJivGJbPD00PzWgfLoS/qsQ040z fDv9sepS5WJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZISgvgAKCRD2t4JPQmmg c71/D/4+XvdHcSoQODxaQYHwmJPtDwA3VDu4wzTJCAuJ6EGvhzmRjzcyfonr/93wVkI84G++f/v c2ow8e25QjKV34fUbo2MSsUlTpaPXIW4blTt1jJ8L4wWMU9178mlTwyB5KOXYHO4N7TEwEE600R kpp0K6wuf0jcQARpw9j+0fimzQdnSEbENozHAGiY7TiAnrVCC3kcEd+T3nUdxcEsSR/pUTNf11k AIUHIOiagftB7n8ZuU0jz2QDB70oltxuBmZLU4s/s+xjWA/+Af1g040SC0yi4JSACmB/1yGaLt8 VAM661e2gd5B7hCtXKSYXia0Vp5usd5V7+JA9VAwJRgFj523jC2nyp1zekmkS1Am5fBjh8LoZpU ZirgQDXp4SFCdmMgs7IaVIqwraz/XMP4yf5cYb9ndAIE3sM3ImhOiFsj1afW8QVhGCkrdnBMMAA SJ+7j/6Ny6ZutOhmBdMJomTYZzoDVbiUUqB9tdsslgGMLFHPG6S1O8aQS/hwuDd3x5k+XCXZcew BglKQmttPDBugCvxAzY6nHkUuaFnbGJ81FF62KSgE7JfMr+2Y0DqwQQhVd/ITDZEmZ5uq8T8+D7 3vmp57mi1q5r2P1uQlVnhcZSvPFioM4xiDbm34WI0gXYRxkwcOqgElHHh2U+xuMtRicGKpgnaaR SWa3uajbHYY6Cog== 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,URIBL_BLOCKED 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?1768334183232236349?= X-GMAIL-MSGID: =?utf-8?q?1768334183232236349?= Selftests are supposed to run on any kernels, including the old ones not supporting all MPTCP features. Some tests are using IPTables and/or TC commands to force some behaviours. If one of these commands fails -- likely because some features are not available due to missing kernel config -- we should intercept the error and skip the tests requiring these features. Note that if we expect to have these features available and if SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var is set to 1, the tests will be marked as failed instead of skipped. This patch also replaces the 'exit 1' by 'return 1' not to stop the selftest in the middle without the conclusion if there is an issue with NF or TC. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 Fixes: 8d014eaa9254 ("selftests: mptcp: add ADD_ADDR timeout test case") Cc: stable@vger.kernel.org Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 88 ++++++++++++++++--------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 276396cbe60c..c471934ad5e0 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -286,11 +286,15 @@ reset_with_add_addr_timeout() fi ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 - ip netns exec $ns2 $tables -A OUTPUT -p tcp \ - -m tcp --tcp-option 30 \ - -m bpf --bytecode \ - "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ - -j DROP + + if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \ + -m tcp --tcp-option 30 \ + -m bpf --bytecode \ + "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \ + -j DROP; then + mark_as_skipped "unable to set the 'add addr' rule" + return 1 + fi } # $1: test name @@ -334,17 +338,12 @@ reset_with_allow_join_id0() # tc action pedit offset 162 out of bounds # # Netfilter is used to mark packets with enough data. -reset_with_fail() +setup_fail_rules() { - reset "${1}" || return 1 - - ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 - ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1 - check_invert=1 validate_checksum=1 - local i="$2" - local ip="${3:-4}" + local i="$1" + local ip="${2:-4}" local tables tables="${iptables}" @@ -359,15 +358,32 @@ reset_with_fail() -p tcp \ -m length --length 150:9999 \ -m statistic --mode nth --packet 1 --every 99999 \ - -j MARK --set-mark 42 || exit 1 + -j MARK --set-mark 42 || return ${ksft_skip} - tc -n $ns2 qdisc add dev ns2eth$i clsact || exit 1 + tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip} tc -n $ns2 filter add dev ns2eth$i egress \ protocol ip prio 1000 \ handle 42 fw \ action pedit munge offset 148 u8 invert \ pipe csum tcp \ - index 100 || exit 1 + index 100 || return ${ksft_skip} +} + +reset_with_fail() +{ + reset "${1}" || return 1 + shift + + ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 + ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1 + + local rc=0 + setup_fail_rules "${@}" || rc=$? + + if [ ${rc} -eq ${ksft_skip} ]; then + mark_as_skipped "unable to set the 'fail' rules" + return 1 + fi } reset_with_events() @@ -382,6 +398,25 @@ reset_with_events() evts_ns2_pid=$! } +reset_with_tcp_filter() +{ + reset "${1}" || return 1 + shift + + local ns="${!1}" + local src="${2}" + local target="${3}" + + if ! ip netns exec "${ns}" ${iptables} \ + -A INPUT \ + -s "${src}" \ + -p tcp \ + -j "${target}"; then + mark_as_skipped "unable to set the filter rules" + return 1 + fi +} + fail_test() { ret=1 @@ -745,15 +780,6 @@ pm_nl_check_endpoint() fi } -filter_tcp_from() -{ - local ns="${1}" - local src="${2}" - local target="${3}" - - ip netns exec "${ns}" ${iptables} -A INPUT -s "${src}" -p tcp -j "${target}" -} - do_transfer() { local listener_ns="$1" @@ -1975,23 +2001,23 @@ subflows_error_tests() fi # multiple subflows, with subflow creation error - if reset "multi subflows, with failing subflow"; then + if reset_with_tcp_filter "multi subflows, with failing subflow" ns1 10.0.3.2 REJECT && + continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 0 2 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow - filter_tcp_from $ns1 10.0.3.2 REJECT run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow chk_join_nr 1 1 1 fi # multiple subflows, with subflow timeout on MPJ - if reset "multi subflows, with subflow timeout"; then + if reset_with_tcp_filter "multi subflows, with subflow timeout" ns1 10.0.3.2 DROP && + continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 0 2 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow - filter_tcp_from $ns1 10.0.3.2 DROP run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow chk_join_nr 1 1 1 fi @@ -1999,11 +2025,11 @@ subflows_error_tests() # multiple subflows, check that the endpoint corresponding to # closed subflow (due to reset) is not reused if additional # subflows are added later - if reset "multi subflows, fair usage on close"; then + if reset_with_tcp_filter "multi subflows, fair usage on close" ns1 10.0.3.2 REJECT && + continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then pm_nl_set_limits $ns1 0 1 pm_nl_set_limits $ns2 0 1 pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow - filter_tcp_from $ns1 10.0.3.2 REJECT run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow & # mpj subflow will be in TW after the reset