From patchwork Tue Dec 19 09:48:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498099 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4BF613FE5; Tue, 19 Dec 2023 09:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XJSnUBdV" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-28ba18740d6so1174304a91.1; Tue, 19 Dec 2023 01:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979352; x=1703584152; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FkMZMH3Iw0DBwphNefyafQMICe6Pnez2GwihrP7r9/E=; b=XJSnUBdVFyPI3FgOZ2OTGR4CssfxE2vbZ+3JKoDdRo15BxSIfwLkinBK3Y0o0ZD58y 8YdxSarcfukRTSm0HkEQKMoyuEdiv/nczW2mYGyYvugoxqT/VQQHEfSNMpHW2eys3Iif MnbIF2M2aqbTMEI/mSvKHjzmperL2gKuYjhKECxKA6qeA9JmOTFkGRAEL9BnfRn4MwGO DTQ9/GEN1oNc2CxbbhzlBtfL+5c+wEnpAxDo89WznqQ6R0XJ0swI3LYcrfgcWWtEzADh /xtYqspTI5RGlmE3kdiDf24RVA/ZKvv8Rt5LENslGjS+AfIOqKdAPbpoXJsAhmJiZPiz Q+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979352; x=1703584152; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FkMZMH3Iw0DBwphNefyafQMICe6Pnez2GwihrP7r9/E=; b=Pyc+1xnF1eByjpZVlDPdG+ff3YywAUkOrGcCXO5RPA/0XFrFJ9EYK6Xdcgw8pwK4/Z 8TIKsiDq9U85oRxnKEIdJXrGVueeGloE8htyMwyEDOhwQW39J4aob7SbYFG97cBKutU2 3E6aGGsca70KXEJlKDlG6eL79h53sf51SBcQqlaBitf8I27huiBL0WEH+Q8nAXZsKccP M2vzPTJ5nMG8N+zs1YuKpZsuPUZvo4NaqXVs2lX4Y6eWdP7TS8N2fvBKk+QJpkNhAnCR iq6MaEoFmpQqL4xxYvyunkZ4aqqcN79D7PT4xa0GGum47E/xoTERuI3tn3ca7HZNkGV5 PZ0Q== X-Gm-Message-State: AOJu0Yz0Bjbz0PGq9CWK7Upen+NN+PxYFxEn73lYqAawRRYnqTlzHs2Y ttAeRWDCJ9l78mFvCT43gSLBx/jn26El3vCUP9U= X-Google-Smtp-Source: AGHT+IG7iVc0O0Vjmly1Zhvl+WDIJBRtzae59V5k5lbL/WAKGzDB6dvMkUhHnz9dmT9V5S4uCyEQww== X-Received: by 2002:a17:90b:4ac5:b0:28b:98e5:3ae8 with SMTP id mh5-20020a17090b4ac500b0028b98e53ae8mr1678749pjb.95.1702979352546; Tue, 19 Dec 2023 01:49:12 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:11 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 1/8] selftests/net: convert gre_gso.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:49 +0800 Message-ID: <20231219094856.1740079-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Here is the test result after conversion. # ./gre_gso.sh TEST: GREv6/v4 - copy file w/ TSO [ OK ] TEST: GREv6/v4 - copy file w/ GSO [ OK ] TEST: GREv6/v6 - copy file w/ TSO [ OK ] TEST: GREv6/v6 - copy file w/ GSO [ OK ] Tests passed: 4 Tests failed: 0 Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/gre_gso.sh | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/net/gre_gso.sh b/tools/testing/selftests/net/gre_gso.sh index 3224651db97b..5100d90f92d2 100755 --- a/tools/testing/selftests/net/gre_gso.sh +++ b/tools/testing/selftests/net/gre_gso.sh @@ -2,10 +2,8 @@ # SPDX-License-Identifier: GPL-2.0 # This test is for checking GRE GSO. - +source lib.sh ret=0 -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 # all tests in this script. Can be overridden with -t option TESTS="gre_gso" @@ -13,8 +11,6 @@ TESTS="gre_gso" VERBOSE=0 PAUSE_ON_FAIL=no PAUSE=no -IP="ip -netns ns1" -NS_EXEC="ip netns exec ns1" TMPFILE=`mktemp` PID= @@ -50,13 +46,13 @@ log_test() setup() { set -e - ip netns add ns1 - ip netns set ns1 auto - $IP link set dev lo up + setup_ns ns1 + IP="ip -netns $ns1" + NS_EXEC="ip netns exec $ns1" ip link add veth0 type veth peer name veth1 ip link set veth0 up - ip link set veth1 netns ns1 + ip link set veth1 netns $ns1 $IP link set veth1 name veth0 $IP link set veth0 up @@ -70,7 +66,7 @@ cleanup() [ -n "$PID" ] && kill $PID ip link del dev gre1 &> /dev/null ip link del dev veth0 &> /dev/null - ip netns del ns1 + cleanup_ns $ns1 } get_linklocal() @@ -145,7 +141,7 @@ gre6_gso_test() setup a1=$(get_linklocal veth0) - a2=$(get_linklocal veth0 ns1) + a2=$(get_linklocal veth0 $ns1) gre_create_tun $a1 $a2 From patchwork Tue Dec 19 09:48:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498100 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7918014270; Tue, 19 Dec 2023 09:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LU8PEMC9" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-28b0c586c51so1852643a91.2; Tue, 19 Dec 2023 01:49:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979356; x=1703584156; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dHEI46KopoFTbSHMVTDnz8gmhnmWTUCL99W+mBGa7H8=; b=LU8PEMC9kN9s8uvNQ1OXrtHrGSDtHZTurpEMAn/orMatxpjSoIfuf+jD6/IZyYq9Cg Klt27sLDH76RCQ1DbeNCJf8oKR2D5tLUeb3wSz5bAqMMfHMs4jpUqYxtE58KKl/7JpWA 5MVOtTSrRs8xvN96vEo1wqI1hSAjWGn66jnu1208RiDB+UhELHekv8sDgvcjJvxUA5Uv 1YeJwTz8C5un/Gu3iGZLddxVBIuY/QW6bvzf01YvoiCY20Av6C7aFzTIahZaf3LbiYA/ l7h4SEMu9OniBDACwu86e5QO9CA/kwYgHafRZyrdfT6BWC7hhMQg9IVMCTivZXmqh4wy AtZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979356; x=1703584156; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dHEI46KopoFTbSHMVTDnz8gmhnmWTUCL99W+mBGa7H8=; b=lSHzToI7FH+1rD2Y/CgntGxeEVUMwT89vIKgN17mm2RIXkGnLdmEfDZa4/qQPH5tzG 2qgBsDH3DqU+FHt6/+RSY79PoKXdmTxLa1CZe23wu/pKgTawVLJHdXGloSFy4p9LF+XR Ulx3JYtgo5v/kdm/EwZyDRG1ef1JUY4DUUkQ0uYgsAW6F9rNra/GupxVflSlcK7C65DK 3Nuik/HnxLQKct4GN/YndUm6zxsnXE5OtB+I75ZqUFPhzp8ULWDZWBqu2FWQfj+6eFBk 7nEd16qB+bYK0TXZMQ3gnK58gsVjvF4xn5Puzqs61X5R5heeRWDL5fnpMUGcgn3pHA7v gMLg== X-Gm-Message-State: AOJu0Yx1zlHmg4SjecE0N57Ha8XFFa+erVTcNMoSBBSUUkP2J+xamjcn d8zDS7Z+xp1qpMPBBT1E1ImlkU/LYtEsf8QTzk4= X-Google-Smtp-Source: AGHT+IHnvxyHX+vfcv9x6cwV9hXoUi+MoGSaVcqW/7q86wDDkywRN4r1sQE3DDI9qzX6lfuNdGtlZg== X-Received: by 2002:a17:90a:dc0c:b0:28b:bf5c:9b69 with SMTP id i12-20020a17090adc0c00b0028bbf5c9b69mr145305pjv.53.1702979356366; Tue, 19 Dec 2023 01:49:16 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:15 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 2/8] selftests/net: convert netns-name.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:50 +0800 Message-ID: <20231219094856.1740079-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This test will move the device to netns 1. Add a new test_ns to do this. Here is the test result after conversion. # ./netns-name.sh netns-name.sh [ OK ] Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/netns-name.sh | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/netns-name.sh b/tools/testing/selftests/net/netns-name.sh index 7d3d3fc99461..6974474c26f3 100755 --- a/tools/testing/selftests/net/netns-name.sh +++ b/tools/testing/selftests/net/netns-name.sh @@ -1,9 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +source lib.sh set -o pipefail -NS=netns-name-test DEV=dummy-dev0 DEV2=dummy-dev1 ALT_NAME=some-alt-name @@ -11,7 +11,7 @@ ALT_NAME=some-alt-name RET_CODE=0 cleanup() { - ip netns del $NS + cleanup_ns $NS $test_ns } trap cleanup EXIT @@ -21,50 +21,50 @@ fail() { RET_CODE=1 } -ip netns add $NS +setup_ns NS test_ns # # Test basic move without a rename # ip -netns $NS link add name $DEV type dummy || fail -ip -netns $NS link set dev $DEV netns 1 || +ip -netns $NS link set dev $DEV netns $test_ns || fail "Can't perform a netns move" -ip link show dev $DEV >> /dev/null || fail "Device not found after move" -ip link del $DEV || fail +ip -netns $test_ns link show dev $DEV >> /dev/null || fail "Device not found after move" +ip -netns $test_ns link del $DEV || fail # # Test move with a conflict # -ip link add name $DEV type dummy +ip -netns $test_ns link add name $DEV type dummy ip -netns $NS link add name $DEV type dummy || fail -ip -netns $NS link set dev $DEV netns 1 2> /dev/null && +ip -netns $NS link set dev $DEV netns $test_ns 2> /dev/null && fail "Performed a netns move with a name conflict" -ip link show dev $DEV >> /dev/null || fail "Device not found after move" +ip -netns $test_ns link show dev $DEV >> /dev/null || fail "Device not found after move" ip -netns $NS link del $DEV || fail -ip link del $DEV || fail +ip -netns $test_ns link del $DEV || fail # # Test move with a conflict and rename # -ip link add name $DEV type dummy +ip -netns $test_ns link add name $DEV type dummy ip -netns $NS link add name $DEV type dummy || fail -ip -netns $NS link set dev $DEV netns 1 name $DEV2 || +ip -netns $NS link set dev $DEV netns $test_ns name $DEV2 || fail "Can't perform a netns move with rename" -ip link del $DEV2 || fail -ip link del $DEV || fail +ip -netns $test_ns link del $DEV2 || fail +ip -netns $test_ns link del $DEV || fail # # Test dup alt-name with netns move # -ip link add name $DEV type dummy || fail -ip link property add dev $DEV altname $ALT_NAME || fail +ip -netns $test_ns link add name $DEV type dummy || fail +ip -netns $test_ns link property add dev $DEV altname $ALT_NAME || fail ip -netns $NS link add name $DEV2 type dummy || fail ip -netns $NS link property add dev $DEV2 altname $ALT_NAME || fail -ip -netns $NS link set dev $DEV2 netns 1 2> /dev/null && +ip -netns $NS link set dev $DEV2 netns $test_ns 2> /dev/null && fail "Moved with alt-name dup" -ip link del $DEV || fail +ip -netns $test_ns link del $DEV || fail ip -netns $NS link del $DEV2 || fail # @@ -72,11 +72,11 @@ ip -netns $NS link del $DEV2 || fail # ip -netns $NS link add name $DEV type dummy || fail ip -netns $NS link property add dev $DEV altname $ALT_NAME || fail -ip -netns $NS link set dev $DEV netns 1 || fail -ip link show dev $ALT_NAME >> /dev/null || fail "Can't find alt-name after move" -ip -netns $NS link show dev $ALT_NAME 2> /dev/null && +ip -netns $NS link set dev $DEV netns $test_ns || fail +ip -netns $test_ns link show dev $ALT_NAME >> /dev/null || fail "Can't find alt-name after move" +ip -netns $NS link show dev $ALT_NAME 2> /dev/null && fail "Can still find alt-name after move" -ip link del $DEV || fail +ip -netns $test_ns link del $DEV || fail echo -ne "$(basename $0) \t\t\t\t" if [ $RET_CODE -eq 0 ]; then From patchwork Tue Dec 19 09:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498101 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 711F114273; Tue, 19 Dec 2023 09:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RxbsvpZn" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-28b4a73d3c7so2676599a91.2; Tue, 19 Dec 2023 01:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979360; x=1703584160; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BHAcJu9znSRPsLBojULlLh46+h3VyWNF5AMsqybfbR4=; b=RxbsvpZnB88649QbcpIJRQ+OZ7EriB7P+XfU2cQ6X3XrHzJwe6y8WlZ9bTSc7p9hC/ mO2HSh9xMIScrBF9Z4CLJh2O29z6P7gdVY8r4zYFp7Ndu6li9YMhWhLWxs+w7FLLYVzX Mv7z+3pEZi+gFtg4f0GcUsUwTplA4aaas4QKdXqDidlMShHzklKUu/3azubD19Ova7at pivi6cXlaitFQmXebx/y/Q+lhYrKRamDKXm4ebZPUB2sXAvT0PdUVWUfzY3xxcZVUSdB 9IhWSOdXTnuOCjjkdPGqqSXJ8aqUgJJwQnGdCd8iFJ8RoF0f8gLWJerWw2CljYJ7vZzX TK7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979360; x=1703584160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BHAcJu9znSRPsLBojULlLh46+h3VyWNF5AMsqybfbR4=; b=tRAQFgGgPZIyi0o2af1eTFp9msGWNzAw/dRdGG4VWN04s1c+yom3z29kinKdGmLEYJ 7yeCDbOX5l0EoeyG9bYO8/YyYgiR2z+h5gYor1+W77gL9V/G7kvmyOCnserveWEh+PzR rKgqh0DDp7NwH81wNm1nRx6o5corj0nbqozBm+cGRad7W1hzfzIow5H1hxNOStS6WvRS mtXTHp6Zfupq61A6OdOIIc6V/9g5TAjOVmCtSJxGfwfGu9ZGlNyTxU4kUgIq1jmnSqEA 75ti2VvRJmQLi1cmRwCho46tPFo2nUGhXUrpmiVAv96WtFPuWcJHE1Z8IKWO7ecEnMxg T3HA== X-Gm-Message-State: AOJu0YwSbSHIX0sfwe97KQgYbKsDN9Kvy6PMv5WaEj9mTntjCIjYvLmc 9uhzk6M+bAG9Wnv/daNU5dSfXv8bsGjpMy82YeI= X-Google-Smtp-Source: AGHT+IFaigRw3rmD7TNGw13v5VzxHoOUG+TgYXmTBwzT2uJx+rPjFuo9LAvq0HCtRtm7KA+/ZOvmGw== X-Received: by 2002:a17:90a:d518:b0:28b:924d:a7d8 with SMTP id t24-20020a17090ad51800b0028b924da7d8mr1729655pju.51.1702979360213; Tue, 19 Dec 2023 01:49:20 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:19 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 3/8] selftests/net: convert rtnetlink.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:51 +0800 Message-ID: <20231219094856.1740079-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When running the test in namespace, the debugfs may not load automatically. So add a checking to make sure debugfs loaded. Here is the test result after conversion. # ./rtnetlink.sh PASS: policy routing PASS: route get ... PASS: address proto IPv4 PASS: address proto IPv6 Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/rtnetlink.sh | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 38be9706c45f..97278b6427f1 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -35,8 +35,7 @@ VERBOSE=0 PAUSE=no PAUSE_ON_FAIL=no -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +source lib.sh # set global exit status, but never reset nonzero one. check_err() @@ -517,9 +516,8 @@ kci_test_encap_fou() # test various encap methods, use netns to avoid unwanted interference kci_test_encap() { - testns="testns" local ret=0 - run_cmd ip netns add "$testns" + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP encap tests: cannot add net namespace $testns" return $ksft_skip @@ -574,6 +572,10 @@ kci_test_macsec_offload() return $ksft_skip fi + if ! mount | grep -q debugfs; then + mount -t debugfs none /sys/kernel/debug/ &> /dev/null + fi + # setup netdevsim since dummydev doesn't have offload support if [ ! -w /sys/bus/netdevsim/new_device ] ; then run_cmd modprobe -q netdevsim @@ -738,6 +740,10 @@ kci_test_ipsec_offload() sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/ probed=false + if ! mount | grep -q debugfs; then + mount -t debugfs none /sys/kernel/debug/ &> /dev/null + fi + # setup netdevsim since dummydev doesn't have offload support if [ ! -w /sys/bus/netdevsim/new_device ] ; then run_cmd modprobe -q netdevsim @@ -836,11 +842,10 @@ EOF kci_test_gretap() { - testns="testns" DEV_NS=gretap00 local ret=0 - run_cmd ip netns add "$testns" + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP gretap tests: cannot add net namespace $testns" return $ksft_skip @@ -878,11 +883,10 @@ kci_test_gretap() kci_test_ip6gretap() { - testns="testns" DEV_NS=ip6gretap00 local ret=0 - run_cmd ip netns add "$testns" + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP ip6gretap tests: cannot add net namespace $testns" return $ksft_skip @@ -920,7 +924,6 @@ kci_test_ip6gretap() kci_test_erspan() { - testns="testns" DEV_NS=erspan00 local ret=0 run_cmd_grep "^Usage:" ip link help erspan @@ -928,7 +931,7 @@ kci_test_erspan() end_test "SKIP: erspan: iproute2 too old" return $ksft_skip fi - run_cmd ip netns add "$testns" + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP erspan tests: cannot add net namespace $testns" return $ksft_skip @@ -970,7 +973,6 @@ kci_test_erspan() kci_test_ip6erspan() { - testns="testns" DEV_NS=ip6erspan00 local ret=0 run_cmd_grep "^Usage:" ip link help ip6erspan @@ -978,7 +980,7 @@ kci_test_ip6erspan() end_test "SKIP: ip6erspan: iproute2 too old" return $ksft_skip fi - run_cmd ip netns add "$testns" + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP ip6erspan tests: cannot add net namespace $testns" return $ksft_skip @@ -1022,8 +1024,6 @@ kci_test_ip6erspan() kci_test_fdb_get() { - IP="ip -netns testns" - BRIDGE="bridge -netns testns" brdev="test-br0" vxlandev="vxlan10" test_mac=de:ad:be:ef:13:37 @@ -1037,11 +1037,13 @@ kci_test_fdb_get() return $ksft_skip fi - run_cmd ip netns add testns + setup_ns testns if [ $? -ne 0 ]; then end_test "SKIP fdb get tests: cannot add net namespace $testns" return $ksft_skip fi + IP="ip -netns $testns" + BRIDGE="bridge -netns $testns" run_cmd $IP link add "$vxlandev" type vxlan id 10 local $localip \ dstport 4789 run_cmd $IP link add name "$brdev" type bridge @@ -1052,7 +1054,7 @@ kci_test_fdb_get() run_cmd_grep "dev $vxlandev master $brdev" $BRIDGE fdb get $test_mac br "$brdev" run_cmd_grep "dev $vxlandev dst $dstip" $BRIDGE fdb get $test_mac dev "$vxlandev" self - ip netns del testns &>/dev/null + ip netns del $testns &>/dev/null if [ $ret -ne 0 ]; then end_test "FAIL: bridge fdb get" From patchwork Tue Dec 19 09:48:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498102 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE45014A81; Tue, 19 Dec 2023 09:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dOsmmrZC" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-59082c4aadaso2902354eaf.0; Tue, 19 Dec 2023 01:49:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979364; x=1703584164; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O5vxiul68UUq7JIxAGkLhv/RlMa8nWcUJYgyt5si0Ac=; b=dOsmmrZCtWHNOufWcL0BBX2WtswxV/cBV/RZ/JymQjG3gQlG22p/0eF/u5IGr1nC4R RYCWCWrBPcu7AtEvyStO9YcsBV+QJ3WGea0lcZQ5GxPzYTMM/SsYN7jxB2ZVc1BxqivQ fhUX1vGfBA1WcCfpQ9ra0VBusn5Op8G/sZvED6c45BV7mGyNoyH9sFiv3Veln+zqyfGy s7SyZ85UUPsXHceocD/fBNZvL/ToLgCFY0MnDKEfgRzeM9ogjuFrr4bnkaYjjQwCLBI2 t8mpmbWk1C6TKc8vJTc5IHWJji/3UDFihUKmJeyNXJNxI7UD6yQsliHSEB6moX/k8z41 AUiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979364; x=1703584164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O5vxiul68UUq7JIxAGkLhv/RlMa8nWcUJYgyt5si0Ac=; b=wiW5f+57BzKSanC8VoEtlm/BAM9giFKTGPA2cNJ/vKOOcCp/6LGBh3tO0TxS8oLMZi n//SLw82DvKbfblBkki9fciwy6tkW3/T/NCG6KGaLcvtOnAI92mUJCcDpPsyMOuNEEyg SSwDkwu7WaZEFwp/VwHTBn9AJgg0TDuPfAT4p8YwPA4EswuSMjQ6ic7qjGpwXsEvB7Qj ca+yRh6I4ltk6Jkltqfep82z4oXxnJ2qBE7Aw1NCICWZq1fZekDn6cWy6lftVGrxfCuF I5Bf9guXUBcqXYq0zCHwk/gC/CT0XYaw3YcTTj/5zQ2DkaPqqWfAv5T6Q0DbI5idYSWI VWxw== X-Gm-Message-State: AOJu0YxgbivwmCLVUXECLrY4SvwNVqjPAtL9bnoKIf9VKhoLs9t7bYs2 RXY2ZVe0XNoH5rumHeWUkKahv3V1sw2fbMziHkQ= X-Google-Smtp-Source: AGHT+IGDR7QXLAsme5W+PS5J+crSxMckw6cDDgk6OKxxSPG+K9Yo81vh3Fp9pd88l90I7lXGFRiDTw== X-Received: by 2002:a05:6358:6f1c:b0:172:aebe:6995 with SMTP id r28-20020a0563586f1c00b00172aebe6995mr4240677rwn.62.1702979364068; Tue, 19 Dec 2023 01:49:24 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:23 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 4/8] selftests/net: convert stress_reuseport_listen.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:52 +0800 Message-ID: <20231219094856.1740079-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Here is the test result after conversion. # ./stress_reuseport_listen.sh listen 24000 socks took 0.47714 Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/stress_reuseport_listen.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/stress_reuseport_listen.sh b/tools/testing/selftests/net/stress_reuseport_listen.sh index 4de11da4092b..94d5d1a1c90f 100755 --- a/tools/testing/selftests/net/stress_reuseport_listen.sh +++ b/tools/testing/selftests/net/stress_reuseport_listen.sh @@ -2,18 +2,18 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2022 Meta Platforms, Inc. and affiliates. -NS='stress_reuseport_listen_ns' +source lib.sh NR_FILES=24100 SAVED_NR_FILES=$(ulimit -n) setup() { - ip netns add $NS + setup_ns NS ip netns exec $NS sysctl -q -w net.ipv6.ip_nonlocal_bind=1 ulimit -n $NR_FILES } cleanup() { - ip netns del $NS + cleanup_ns $NS ulimit -n $SAVED_NR_FILES } From patchwork Tue Dec 19 09:48:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498103 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2303A1426B; Tue, 19 Dec 2023 09:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E5ahzdRa" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-58d18c224c7so2672918eaf.2; Tue, 19 Dec 2023 01:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979368; x=1703584168; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3gnGTazMYDP2LaFiCvzMYscNqHB3XeHRTsf1tloUUig=; b=E5ahzdRaZTJOULOG1RNfmxJjcFPhwOptcsd5J+vzNsB56SxCvbOOLfb4DcRt988l2c J+fGoIbPP3rAboO0mcAS3ZdaVWRPvFfPc9MX0ob1I08AJvHoBJNyS7AuozyaYSK/XiFz gMY2o20vU2ef+seTcJfCbyo4L+FzNmxojbgmx/QjZMF8rW7xE1oT8C18Rybw4BfOIq/H VTX5X7/bHH5rnzgAquvifYn9yyhQTayPXCR8y9Sdvm83NgxngJ5A1my8gwxDn4zScnMw llDf1MFYMXwtLlZWzu7UkoZ3GD7FIKaBjD0lBKml1lQuk1Lh3WrvRcguViwP8VOMfaiv WaCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979368; x=1703584168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3gnGTazMYDP2LaFiCvzMYscNqHB3XeHRTsf1tloUUig=; b=tDcbaHuaom7mqFUVrvyRK+4Ac8AFxfjrG5xMixq61y4rl1r7nmsmKeNJUzfcF3GuOH clzBDfrcdmYqrGME6tgPcWuFHPtVRKAbmyBrsktIv44HVBUoVqsF90d9Ov+/V4W6RwkA 92Pzytaqlqa98qqrXh0f7+wMriAQsrEXuZxIkdNzVHLnq9j1gLOkIHmFlF235z19hH+I uR9AMz0EFihTEayh/t0YOcwOUlCVvJ53+3LAOUm0r9Zm5Swz8jLtA/t86wzAq9Ga5RP9 WCgt2x5jcMgMNzPCanoz8J1Rg0l/IR0kOfvu+QgXmQSuCftIm9ywfy2ihZAoDRpX2WPb zz9Q== X-Gm-Message-State: AOJu0Yy/cBZQWi/5Ivnuw6QP03wKv1D+9oQmvHzUcV8BJYluC4EiqVlh NeFYJOAZ6TU+/Vf4gnN0Kz/OkCvLFv2onE2YCJ0= X-Google-Smtp-Source: AGHT+IE1ftuQqgtthA3a9u+wcnAkBGZPGf2pLe8tg1VSxCtTIwouz9WC5Bgro4DUlZINUUnIIVkB9Q== X-Received: by 2002:a05:6359:71c1:b0:170:2493:11fa with SMTP id uf1-20020a05635971c100b00170249311famr9295948rwb.50.1702979368185; Tue, 19 Dec 2023 01:49:28 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:27 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 5/8] selftests/net: convert xfrm_policy.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:53 +0800 Message-ID: <20231219094856.1740079-6-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Here is the test result after conversion. # ./xfrm_policy.sh PASS: policy before exception matches PASS: ping to .254 bypassed ipsec tunnel (exceptions) PASS: direct policy matches (exceptions) PASS: policy matches (exceptions) PASS: ping to .254 bypassed ipsec tunnel (exceptions and block policies) PASS: direct policy matches (exceptions and block policies) PASS: policy matches (exceptions and block policies) PASS: ping to .254 bypassed ipsec tunnel (exceptions and block policies after hresh changes) PASS: direct policy matches (exceptions and block policies after hresh changes) PASS: policy matches (exceptions and block policies after hresh changes) PASS: ping to .254 bypassed ipsec tunnel (exceptions and block policies after hthresh change in ns3) PASS: direct policy matches (exceptions and block policies after hthresh change in ns3) PASS: policy matches (exceptions and block policies after hthresh change in ns3) PASS: ping to .254 bypassed ipsec tunnel (exceptions and block policies after htresh change to normal) PASS: direct policy matches (exceptions and block policies after htresh change to normal) PASS: policy matches (exceptions and block policies after htresh change to normal) PASS: policies with repeated htresh change Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/xfrm_policy.sh | 138 ++++++++++----------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh index bdf450eaf60c..457789530645 100755 --- a/tools/testing/selftests/net/xfrm_policy.sh +++ b/tools/testing/selftests/net/xfrm_policy.sh @@ -18,8 +18,7 @@ # ns1: ping 10.0.2.254: does NOT pass via ipsec tunnel (exception) # ns2: ping 10.0.1.254: does NOT pass via ipsec tunnel (exception) -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +source lib.sh ret=0 policy_checks_ok=1 @@ -204,24 +203,24 @@ check_xfrm() { ip=$2 local lret=0 - ip netns exec ns1 ping -q -c 1 10.0.2.$ip > /dev/null + ip netns exec ${ns[1]} ping -q -c 1 10.0.2.$ip > /dev/null - check_ipt_policy_count ns3 + check_ipt_policy_count ${ns[3]} if [ $? -ne $rval ] ; then lret=1 fi - check_ipt_policy_count ns4 + check_ipt_policy_count ${ns[4]} if [ $? -ne $rval ] ; then lret=1 fi - ip netns exec ns2 ping -q -c 1 10.0.1.$ip > /dev/null + ip netns exec ${ns[2]} ping -q -c 1 10.0.1.$ip > /dev/null - check_ipt_policy_count ns3 + check_ipt_policy_count ${ns[3]} if [ $? -ne $rval ] ; then lret=1 fi - check_ipt_policy_count ns4 + check_ipt_policy_count ${ns[4]} if [ $? -ne $rval ] ; then lret=1 fi @@ -270,11 +269,11 @@ check_hthresh_repeat() i=0 for i in $(seq 1 10);do - ip -net ns1 xfrm policy update src e000:0001::0000 dst ff01::0014:0000:0001 dir in tmpl src :: dst :: proto esp mode tunnel priority 100 action allow || break - ip -net ns1 xfrm policy set hthresh6 0 28 || break + ip -net ${ns[1]} xfrm policy update src e000:0001::0000 dst ff01::0014:0000:0001 dir in tmpl src :: dst :: proto esp mode tunnel priority 100 action allow || break + ip -net ${ns[1]} xfrm policy set hthresh6 0 28 || break - ip -net ns1 xfrm policy update src e000:0001::0000 dst ff01::01 dir in tmpl src :: dst :: proto esp mode tunnel priority 100 action allow || break - ip -net ns1 xfrm policy set hthresh6 0 28 || break + ip -net ${ns[1]} xfrm policy update src e000:0001::0000 dst ff01::01 dir in tmpl src :: dst :: proto esp mode tunnel priority 100 action allow || break + ip -net ${ns[1]} xfrm policy set hthresh6 0 28 || break done if [ $i -ne 10 ] ;then @@ -347,79 +346,80 @@ if [ $? -ne 0 ];then exit $ksft_skip fi -for i in 1 2 3 4; do - ip netns add ns$i - ip -net ns$i link set lo up -done +setup_ns ns1 ns2 ns3 ns4 +ns[1]=$ns1 +ns[2]=$ns2 +ns[3]=$ns3 +ns[4]=$ns4 DEV=veth0 -ip link add $DEV netns ns1 type veth peer name eth1 netns ns3 -ip link add $DEV netns ns2 type veth peer name eth1 netns ns4 +ip link add $DEV netns ${ns[1]} type veth peer name eth1 netns ${ns[3]} +ip link add $DEV netns ${ns[2]} type veth peer name eth1 netns ${ns[4]} -ip link add $DEV netns ns3 type veth peer name veth0 netns ns4 +ip link add $DEV netns ${ns[3]} type veth peer name veth0 netns ${ns[4]} DEV=veth0 for i in 1 2; do - ip -net ns$i link set $DEV up - ip -net ns$i addr add 10.0.$i.2/24 dev $DEV - ip -net ns$i addr add dead:$i::2/64 dev $DEV - - ip -net ns$i addr add 10.0.$i.253 dev $DEV - ip -net ns$i addr add 10.0.$i.254 dev $DEV - ip -net ns$i addr add dead:$i::fd dev $DEV - ip -net ns$i addr add dead:$i::fe dev $DEV + ip -net ${ns[$i]} link set $DEV up + ip -net ${ns[$i]} addr add 10.0.$i.2/24 dev $DEV + ip -net ${ns[$i]} addr add dead:$i::2/64 dev $DEV + + ip -net ${ns[$i]} addr add 10.0.$i.253 dev $DEV + ip -net ${ns[$i]} addr add 10.0.$i.254 dev $DEV + ip -net ${ns[$i]} addr add dead:$i::fd dev $DEV + ip -net ${ns[$i]} addr add dead:$i::fe dev $DEV done for i in 3 4; do -ip -net ns$i link set eth1 up -ip -net ns$i link set veth0 up + ip -net ${ns[$i]} link set eth1 up + ip -net ${ns[$i]} link set veth0 up done -ip -net ns1 route add default via 10.0.1.1 -ip -net ns2 route add default via 10.0.2.1 +ip -net ${ns[1]} route add default via 10.0.1.1 +ip -net ${ns[2]} route add default via 10.0.2.1 -ip -net ns3 addr add 10.0.1.1/24 dev eth1 -ip -net ns3 addr add 10.0.3.1/24 dev veth0 -ip -net ns3 addr add 2001:1::1/64 dev eth1 -ip -net ns3 addr add 2001:3::1/64 dev veth0 +ip -net ${ns[3]} addr add 10.0.1.1/24 dev eth1 +ip -net ${ns[3]} addr add 10.0.3.1/24 dev veth0 +ip -net ${ns[3]} addr add 2001:1::1/64 dev eth1 +ip -net ${ns[3]} addr add 2001:3::1/64 dev veth0 -ip -net ns3 route add default via 10.0.3.10 +ip -net ${ns[3]} route add default via 10.0.3.10 -ip -net ns4 addr add 10.0.2.1/24 dev eth1 -ip -net ns4 addr add 10.0.3.10/24 dev veth0 -ip -net ns4 addr add 2001:2::1/64 dev eth1 -ip -net ns4 addr add 2001:3::10/64 dev veth0 -ip -net ns4 route add default via 10.0.3.1 +ip -net ${ns[4]} addr add 10.0.2.1/24 dev eth1 +ip -net ${ns[4]} addr add 10.0.3.10/24 dev veth0 +ip -net ${ns[4]} addr add 2001:2::1/64 dev eth1 +ip -net ${ns[4]} addr add 2001:3::10/64 dev veth0 +ip -net ${ns[4]} route add default via 10.0.3.1 for j in 4 6; do for i in 3 4;do - ip netns exec ns$i sysctl net.ipv$j.conf.eth1.forwarding=1 > /dev/null - ip netns exec ns$i sysctl net.ipv$j.conf.veth0.forwarding=1 > /dev/null + ip netns exec ${ns[$i]} sysctl net.ipv$j.conf.eth1.forwarding=1 > /dev/null + ip netns exec ${ns[$i]} sysctl net.ipv$j.conf.veth0.forwarding=1 > /dev/null done done # abuse iptables rule counter to check if ping matches a policy -ip netns exec ns3 iptables -p icmp -A FORWARD -m policy --dir out --pol ipsec -ip netns exec ns4 iptables -p icmp -A FORWARD -m policy --dir out --pol ipsec +ip netns exec ${ns[3]} iptables -p icmp -A FORWARD -m policy --dir out --pol ipsec +ip netns exec ${ns[4]} iptables -p icmp -A FORWARD -m policy --dir out --pol ipsec if [ $? -ne 0 ];then echo "SKIP: Could not insert iptables rule" - for i in 1 2 3 4;do ip netns del ns$i;done + cleanup_ns $ns1 $ns2 $ns3 $ns4 exit $ksft_skip fi # localip remoteip localnet remotenet -do_esp ns3 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24 $SPI1 $SPI2 -do_esp ns3 dead:3::1 dead:3::10 dead:1::/64 dead:2::/64 $SPI1 $SPI2 -do_esp ns4 10.0.3.10 10.0.3.1 10.0.2.0/24 10.0.1.0/24 $SPI2 $SPI1 -do_esp ns4 dead:3::10 dead:3::1 dead:2::/64 dead:1::/64 $SPI2 $SPI1 +do_esp ${ns[3]} 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24 $SPI1 $SPI2 +do_esp ${ns[3]} dead:3::1 dead:3::10 dead:1::/64 dead:2::/64 $SPI1 $SPI2 +do_esp ${ns[4]} 10.0.3.10 10.0.3.1 10.0.2.0/24 10.0.1.0/24 $SPI2 $SPI1 +do_esp ${ns[4]} dead:3::10 dead:3::1 dead:2::/64 dead:1::/64 $SPI2 $SPI1 -do_dummies4 ns3 -do_dummies6 ns4 +do_dummies4 ${ns[3]} +do_dummies6 ${ns[4]} -do_esp_policy_get_check ns3 10.0.1.0/24 10.0.2.0/24 -do_esp_policy_get_check ns4 10.0.2.0/24 10.0.1.0/24 -do_esp_policy_get_check ns3 dead:1::/64 dead:2::/64 -do_esp_policy_get_check ns4 dead:2::/64 dead:1::/64 +do_esp_policy_get_check ${ns[3]} 10.0.1.0/24 10.0.2.0/24 +do_esp_policy_get_check ${ns[4]} 10.0.2.0/24 10.0.1.0/24 +do_esp_policy_get_check ${ns[3]} dead:1::/64 dead:2::/64 +do_esp_policy_get_check ${ns[4]} dead:2::/64 dead:1::/64 # ping to .254 should use ipsec, exception is not installed. check_xfrm 1 254 @@ -432,11 +432,11 @@ fi # installs exceptions # localip remoteip encryptdst plaindst -do_exception ns3 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28 -do_exception ns4 10.0.3.10 10.0.3.1 10.0.1.253 10.0.1.240/28 +do_exception ${ns[3]} 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28 +do_exception ${ns[4]} 10.0.3.10 10.0.3.1 10.0.1.253 10.0.1.240/28 -do_exception ns3 dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96 -do_exception ns4 dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96 +do_exception ${ns[3]} dead:3::1 dead:3::10 dead:2::fd dead:2:f0::/96 +do_exception ${ns[4]} dead:3::10 dead:3::1 dead:1::fd dead:1:f0::/96 check_exceptions "exceptions" if [ $? -ne 0 ]; then @@ -444,14 +444,14 @@ if [ $? -ne 0 ]; then fi # insert block policies with adjacent/overlapping netmasks -do_overlap ns3 +do_overlap ${ns[3]} check_exceptions "exceptions and block policies" if [ $? -ne 0 ]; then ret=1 fi -for n in ns3 ns4;do +for n in ${ns[3]} ${ns[4]};do ip -net $n xfrm policy set hthresh4 28 24 hthresh6 126 125 sleep $((RANDOM%5)) done @@ -459,19 +459,19 @@ done check_exceptions "exceptions and block policies after hresh changes" # full flush of policy db, check everything gets freed incl. internal meta data -ip -net ns3 xfrm policy flush +ip -net ${ns[3]} xfrm policy flush -do_esp_policy ns3 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24 -do_exception ns3 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28 +do_esp_policy ${ns[3]} 10.0.3.1 10.0.3.10 10.0.1.0/24 10.0.2.0/24 +do_exception ${ns[3]} 10.0.3.1 10.0.3.10 10.0.2.253 10.0.2.240/28 # move inexact policies to hash table -ip -net ns3 xfrm policy set hthresh4 16 16 +ip -net ${ns[3]} xfrm policy set hthresh4 16 16 sleep $((RANDOM%5)) check_exceptions "exceptions and block policies after hthresh change in ns3" # restore original hthresh settings -- move policies back to tables -for n in ns3 ns4;do +for n in ${ns[3]} ${ns[4]};do ip -net $n xfrm policy set hthresh4 32 32 hthresh6 128 128 sleep $((RANDOM%5)) done @@ -479,8 +479,8 @@ check_exceptions "exceptions and block policies after htresh change to normal" check_hthresh_repeat "policies with repeated htresh change" -check_random_order ns3 "policies inserted in random order" +check_random_order ${ns[3]} "policies inserted in random order" -for i in 1 2 3 4;do ip netns del ns$i;done +cleanup_ns $ns1 $ns2 $ns3 $ns4 exit $ret From patchwork Tue Dec 19 09:48:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498104 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749CF1426B; Tue, 19 Dec 2023 09:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lx5V3Tgc" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5cda24a77e0so941226a12.2; Tue, 19 Dec 2023 01:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979372; x=1703584172; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2X8UVuUbchpztlNlu1B9MVgkZAm0pyuW2tgoQGv3vwg=; b=lx5V3TgcSfpcQP25yUX8fM0aG/xxFWuCVZgjEzpd8pw1Ptb/WO30KwdQfvcJlkHAuf FVlmW5jJpnaI5FZGT1AbTAGG2QUFxpSOWbpaGpHYShPCjSwlGqeMuvXfi1DgiwfeJ2om ZEoyUUDwoVAMZc+gLv3lKMC1hyvxWHTWOaUhmzGIPidfCTg/JRJC85136byT6aVIiADW KJ+zDtLw6Pi1S3ZPwpgiFxUIwgx5pxMHWxfN0nKiSHHwOcVANf6BctyKybQma9f5xfsB WvVotbqtKKqxb3CzHivBXjWfd5ZsLz7FM3+1GEVLd3QA9u+528qTgKBKNQcmjyZdObZo i2Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979372; x=1703584172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2X8UVuUbchpztlNlu1B9MVgkZAm0pyuW2tgoQGv3vwg=; b=v0vL9GL8SV5M1kVLqI28x+bDcVdWro4GPeQ41zC4+Vu4URWXnzXqxBjbTEAhkL8pCx IL1py+83fAIH+b/VWpwZSLookGNTRBvoE32rx60WkEj2fkc1Vl3yz6i152Yx6rjCqrbK StfoNXNahLDj4ZeX3R00Ga91iTevzAGXLOz/LA5fIdVFlKCNvgpeJpJ0SJlyCUhXCT2V +WyBho5PZfIpxyslmwB9Bmj3Tpa44ySWM/FeOXVNfosvBs6opioTl6A+JC0XeWVG55rb mStzIcHIqmf9LA2AQPHQuTshpDsvI2m1Xwv0qUm0uLAG2TgwEi7M76Df5qBDVyTkZzut mgNw== X-Gm-Message-State: AOJu0Yx2Fgr336w84nEAJxbFa0a9OZbgyk5tY/FpAGxz0D5BwMLjtBeH ZeRcuuJ1Tzk9eY6WnaYMztf8jE8A163o3x3rh5Q= X-Google-Smtp-Source: AGHT+IHiAFRjisOy85FpbWoav45DgfkGtP/uqSxHeu5/9UcEFALuZkEFqzvbdSi5DiO66svEXSBCoA== X-Received: by 2002:a05:6a21:1a8:b0:194:b79c:9960 with SMTP id le40-20020a056a2101a800b00194b79c9960mr107496pzb.50.1702979372279; Tue, 19 Dec 2023 01:49:32 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:31 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 6/8] selftests/net: use unique netns name for setup_loopback.sh setup_veth.sh Date: Tue, 19 Dec 2023 17:48:54 +0800 Message-ID: <20231219094856.1740079-7-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The setup_loopback and setup_veth use their own way to create namespace. So let's just re-define server_ns/client_ns to unique name. At the same time update the namespace name in gro.sh and toeplitz.sh. As I don't have env to run toeplitz.sh. Here is only the gro test result. # ./gro.sh running test ipv4 data Expected {200 }, Total 1 packets Received {200 }, Total 1 packets. ... Gro::large test passed. All Tests Succeeded! Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/gro.sh | 4 ++-- tools/testing/selftests/net/setup_loopback.sh | 8 +++++--- tools/testing/selftests/net/setup_veth.sh | 9 ++++++--- tools/testing/selftests/net/toeplitz.sh | 14 +++++++------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/net/gro.sh b/tools/testing/selftests/net/gro.sh index 342ad27f631b..19352f106c1d 100755 --- a/tools/testing/selftests/net/gro.sh +++ b/tools/testing/selftests/net/gro.sh @@ -23,11 +23,11 @@ run_test() { # on every try. for tries in {1..3}; do # Actual test starts here - ip netns exec server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \ + ip netns exec $server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \ 1>>log.txt & server_pid=$! sleep 0.5 # to allow for socket init - ip netns exec client_ns ./gro "${ARGS[@]}" "--iface" "client" \ + ip netns exec $client_ns ./gro "${ARGS[@]}" "--iface" "client" \ 1>>log.txt wait "${server_pid}" exit_code=$? diff --git a/tools/testing/selftests/net/setup_loopback.sh b/tools/testing/selftests/net/setup_loopback.sh index e57bbfbc5208..2070b57849de 100755 --- a/tools/testing/selftests/net/setup_loopback.sh +++ b/tools/testing/selftests/net/setup_loopback.sh @@ -5,6 +5,8 @@ readonly FLUSH_PATH="/sys/class/net/${dev}/gro_flush_timeout" readonly IRQ_PATH="/sys/class/net/${dev}/napi_defer_hard_irqs" readonly FLUSH_TIMEOUT="$(< ${FLUSH_PATH})" readonly HARD_IRQS="$(< ${IRQ_PATH})" +readonly server_ns=$(mktemp -u server-XXXXXXXX) +readonly client_ns=$(mktemp -u client-XXXXXXXX) netdev_check_for_carrier() { local -r dev="$1" @@ -97,12 +99,12 @@ setup_interrupt() { setup_ns() { # Set up server_ns namespace and client_ns namespace - setup_macvlan_ns "${dev}" server_ns server "${SERVER_MAC}" - setup_macvlan_ns "${dev}" client_ns client "${CLIENT_MAC}" + setup_macvlan_ns "${dev}" ${server_ns} server "${SERVER_MAC}" + setup_macvlan_ns "${dev}" ${client_ns} client "${CLIENT_MAC}" } cleanup_ns() { - cleanup_macvlan_ns server_ns server client_ns client + cleanup_macvlan_ns ${server_ns} server ${client_ns} client } setup() { diff --git a/tools/testing/selftests/net/setup_veth.sh b/tools/testing/selftests/net/setup_veth.sh index 1003ddf7b3b2..a9a1759e035c 100644 --- a/tools/testing/selftests/net/setup_veth.sh +++ b/tools/testing/selftests/net/setup_veth.sh @@ -1,6 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +readonly server_ns=$(mktemp -u server-XXXXXXXX) +readonly client_ns=$(mktemp -u client-XXXXXXXX) + setup_veth_ns() { local -r link_dev="$1" local -r ns_name="$2" @@ -19,14 +22,14 @@ setup_ns() { # Set up server_ns namespace and client_ns namespace ip link add name server type veth peer name client - setup_veth_ns "${dev}" server_ns server "${SERVER_MAC}" - setup_veth_ns "${dev}" client_ns client "${CLIENT_MAC}" + setup_veth_ns "${dev}" ${server_ns} server "${SERVER_MAC}" + setup_veth_ns "${dev}" ${client_ns} client "${CLIENT_MAC}" } cleanup_ns() { local ns_name - for ns_name in client_ns server_ns; do + for ns_name in ${client_ns} ${server_ns}; do [[ -e /var/run/netns/"${ns_name}" ]] && ip netns del "${ns_name}" done } diff --git a/tools/testing/selftests/net/toeplitz.sh b/tools/testing/selftests/net/toeplitz.sh index da5bfd834eff..8ff172f7bb1b 100755 --- a/tools/testing/selftests/net/toeplitz.sh +++ b/tools/testing/selftests/net/toeplitz.sh @@ -147,14 +147,14 @@ setup() { setup_loopback_environment "${DEV}" # Set up server_ns namespace and client_ns namespace - setup_macvlan_ns "${DEV}" server_ns server \ + setup_macvlan_ns "${DEV}" $server_ns server \ "${SERVER_MAC}" "${SERVER_IP}" - setup_macvlan_ns "${DEV}" client_ns client \ + setup_macvlan_ns "${DEV}" $client_ns client \ "${CLIENT_MAC}" "${CLIENT_IP}" } cleanup() { - cleanup_macvlan_ns server_ns server client_ns client + cleanup_macvlan_ns $server_ns server $client_ns client cleanup_loopback "${DEV}" } @@ -170,22 +170,22 @@ if [[ "${TEST_RSS}" = true ]]; then # RPS/RFS must be disabled because they move packets between cpus, # which breaks the PACKET_FANOUT_CPU identification of RSS decisions. eval "$(get_disable_rfs_cmd) $(get_disable_rps_cmd)" \ - ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ + ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \ -C "$(get_rx_irq_cpus)" -s -v & elif [[ ! -z "${RPS_MAP}" ]]; then eval "$(get_disable_rfs_cmd) $(get_set_rps_bitmaps_cmd ${RPS_MAP})" \ - ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ + ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \ -r "0x${RPS_MAP}" -s -v & else - ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ + ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 -s -v & fi server_pid=$! -ip netns exec client_ns ./toeplitz_client.sh "${PROTO_FLAG}" \ +ip netns exec $client_ns ./toeplitz_client.sh "${PROTO_FLAG}" \ "${IP_FLAG}" "${SERVER_IP%%/*}" "${PORT}" & client_pid=$! From patchwork Tue Dec 19 09:48:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498105 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9778F14A9F; Tue, 19 Dec 2023 09:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hYcgkx28" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6d3954833a5so2775157b3a.3; Tue, 19 Dec 2023 01:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979376; x=1703584176; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L5kGCgDBMgBlf/oLmtC8e2e3YQ6iRyG34FFcH/fAsC4=; b=hYcgkx28E5x/cO1tGIO0GA8bPEr6s9Ix4ONJdKZqS9fPMnf6E9RpQ9ybN7Ytt+lz/w 16g7DI1ff3++Boh1JmHxoQo/x70T4xuPDxItwdLYfEJAK4mK0+LFBuK+5Af3a18UMsNR jm7zGqx0WrkUJiSFKtHaWjPNsGIxSP1MyzUq8pS3a22gSU53m43yVa7aG6vQ1Tpq2bQG 1JWO/Fr3UhhLDwhFMo0EGMq7ADhIehJXgd4a59EhvTgxVdmGMZrHHGsaRZI30Vi3ti7K vUPI2MulbHSlYxZP895ZemIRmNoVrpj+iWLdT0vRse91YekZ5p8RpPh15zHTou43TZ0v oZ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979376; x=1703584176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L5kGCgDBMgBlf/oLmtC8e2e3YQ6iRyG34FFcH/fAsC4=; b=HBM2ZT5dQcvGsZIfkcUVCjXnMJXa5Ys2tvgtYBFDQBFnr+ZPGAgZlTW7RYMxx7y4nA 3gshHOcy/nzcNx0Y0jgQ/cFWyQGWlWxYvHeX7DQFOpU4CabFi+KIz0DAWbIFAIHitLZ/ wk4PzspooM1dwcv+9Wwl7iVdUmDH1sPY38yfgvZTUS0QiK0Jq7rQGTgYEblByKi6D1P+ L/6y8TG9z/YqcXPMNdZib1qNfrvOqEr/Db8brGJs26Dl9B2oxor+i60agUl69sohVSLX 1uMdqFkX2Vbxo8Pf7f2Mcfs7bk8DfKpd3Mw5fZvuCD9Xbs+LFEG6+Awat5iEe95DnQbt 7/aw== X-Gm-Message-State: AOJu0Yx+f4xfn0G5j91ClKP/uwYGtuUaPA0U6/F3JLS9RtgD7+OmS3/m IxZdFlp1VnJxQG2wo4V2lbhfcQlvjbCj0sdl9TQ= X-Google-Smtp-Source: AGHT+IHlPR4OYY9EHJbVcSsCypxECgNmnIxizgkRH7gXm1xISdwQ56xQebroX6+H5ER+HKhzy6Zzzg== X-Received: by 2002:a05:6a21:27a9:b0:191:60f5:2a9 with SMTP id rn41-20020a056a2127a900b0019160f502a9mr14762216pzb.80.1702979376362; Tue, 19 Dec 2023 01:49:36 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:35 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 7/8] selftests/net: convert pmtu.sh to run it in unique namespace Date: Tue, 19 Dec 2023 17:48:55 +0800 Message-ID: <20231219094856.1740079-8-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pmtu test use /bin/sh, so we need to source ./lib.sh instead of lib.sh Here is the test result after conversion. # ./pmtu.sh TEST: ipv4: PMTU exceptions [ OK ] TEST: ipv4: PMTU exceptions - nexthop objects [ OK ] TEST: ipv6: PMTU exceptions [ OK ] TEST: ipv6: PMTU exceptions - nexthop objects [ OK ] ... TEST: ipv4: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv6: list and flush cached exceptions [ OK ] TEST: ipv6: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv4: PMTU exception w/route replace [ OK ] TEST: ipv4: PMTU exception w/route replace - nexthop objects [ OK ] TEST: ipv6: PMTU exception w/route replace [ OK ] TEST: ipv6: PMTU exception w/route replace - nexthop objects [ OK ] Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/pmtu.sh | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index b3b2dc5a630c..175d3d1d773b 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -198,8 +198,7 @@ # - pmtu_ipv6_route_change # Same as above but with IPv6 -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +source ./lib.sh PAUSE_ON_FAIL=no VERBOSE=0 @@ -268,16 +267,6 @@ tests=" pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1 pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1" -NS_A="ns-A" -NS_B="ns-B" -NS_C="ns-C" -NS_R1="ns-R1" -NS_R2="ns-R2" -ns_a="ip netns exec ${NS_A}" -ns_b="ip netns exec ${NS_B}" -ns_c="ip netns exec ${NS_C}" -ns_r1="ip netns exec ${NS_R1}" -ns_r2="ip netns exec ${NS_R2}" # Addressing and routing for tests with routers: four network segments, with # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an # identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2). @@ -543,13 +532,17 @@ setup_ip6ip6() { } setup_namespaces() { + setup_ns NS_A NS_B NS_C NS_R1 NS_R2 for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do - ip netns add ${n} || return 1 - # Disable DAD, so that we don't have to wait to use the # configured IPv6 addresses ip netns exec ${n} sysctl -q net/ipv6/conf/default/accept_dad=0 done + ns_a="ip netns exec ${NS_A}" + ns_b="ip netns exec ${NS_B}" + ns_c="ip netns exec ${NS_C}" + ns_r1="ip netns exec ${NS_R1}" + ns_r2="ip netns exec ${NS_R2}" } setup_veth() { @@ -839,7 +832,7 @@ setup_bridge() { run_cmd ${ns_a} ip link set br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C - run_cmd ${ns_c} ip link set veth_A-C netns ns-A + run_cmd ${ns_c} ip link set veth_A-C netns ${NS_A} run_cmd ${ns_a} ip link set veth_A-C up run_cmd ${ns_c} ip link set veth_C-A up @@ -944,9 +937,7 @@ cleanup() { done socat_pids= - for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do - ip netns del ${n} 2> /dev/null - done + cleanup_all_ns ip link del veth_A-C 2>/dev/null ip link del veth_A-R1 2>/dev/null From patchwork Tue Dec 19 09:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13498106 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 846DF14AA3; Tue, 19 Dec 2023 09:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="deSIWDRb" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-58e256505f7so2889409eaf.3; Tue, 19 Dec 2023 01:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702979380; x=1703584180; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KWclspkFdHwsQxe6p18VtffMIYQVTc/BhcjiGTJxCjs=; b=deSIWDRb4gBXph3RMqQWo39bxLFaiXeEKiE1A1TmcRaCAmi3zSe9nFsqooC5m2Nsjk qsQXhmz+lEYf/MWyGnnXsMHY1dPCcxpP8WnQ2WhyOJsetxgR5WYMlzexrKWiezIzv/9W LQR+/LU1W+CQQ4zZDPaqunzCjIIxs/ahxcTstSUcU9hRkti/Rj109t5oSHzpNkUhRgMT uXvkcLUu8FsTktc8drx1t7sETVgxFIBuqM851ZkZ7QY7S+/qq9HHScso6CMEm+FpKznr sPnLcEa0H/D0/IXNbVJ4BPssXV2xVfCSSo0aMkIwGdOt6+wDt/OiaOhD+OPAlucN17KM s4Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702979380; x=1703584180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KWclspkFdHwsQxe6p18VtffMIYQVTc/BhcjiGTJxCjs=; b=kxCxFojjKEuvlChBuIcrXZa2p14c4HwvZyqKE1uJ7p/2kpWsNMfzqE0XO+ouG6B/+D bRmSZ4vqi1Fs8wRYH9Nqr9nIu5LtXaM5oy6xNqDqfsb5IcBbWtKDQ4i5v65q+F1UrnYw xPmLNS+ce7gUi9AJhPp6IzMJMJuVh9cOQZ6vjT8PVeekxyjJp+gN3NbkrDZ9zy2yee4h NWh+9jJeOZN7vwlWr7+XqrIEcUY2/apBvHH81HJ9JQizPJ+A5maoju/z/gd0kuvXNsQX aPzDhrbwhKn3811uEZw3Mhho6KnqSgMEIxRDMoKGAJGBV787xv1eZKasivxA0HHfHM44 zIZQ== X-Gm-Message-State: AOJu0YwETO84cpZVgXy2iLmZhLVo/MQkT3bx2wOWp4P3l6rQQQMxgnQ9 cWfPS4hE2zxcVpsvwSCJis4/D1dWJz/2jPBomAY= X-Google-Smtp-Source: AGHT+IH1F+4ruknGc0Qe8JnXSRT/68q+3Xl6WhB+9fx+vIag5oILYnt9HBq3qvnPXxNzxh1XYG7wSQ== X-Received: by 2002:a05:6359:2d81:b0:170:7d81:a325 with SMTP id rn1-20020a0563592d8100b001707d81a325mr10215906rwb.43.1702979380674; Tue, 19 Dec 2023 01:49:40 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ds17-20020a17090b08d100b0028b21d24ba6sm1076276pjb.15.2023.12.19.01.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:49:39 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Shuah Khan , David Ahern , linux-kselftest@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Martin KaFai Lau , Stefano Brivio , Kees Cook , Hangbin Liu Subject: [PATCH net-next 8/8] kselftest/runner.sh: add netns support Date: Tue, 19 Dec 2023 17:48:56 +0800 Message-ID: <20231219094856.1740079-9-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219094856.1740079-1-liuhangbin@gmail.com> References: <20231219094856.1740079-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a variable RUN_IN_NETNS if the user wants to run all the selected tests in namespace in parallel. With this, we can save a lot of testing time. Note that some tests may not fit to run in namespace, e.g. net/drop_monitor_tests.sh, as the dwdump needs to be run in init ns. I also added another parameter -p to make all the logs reported separately instead of mixing them in the stdout or output.log. Nit: the NUM in run_one is not used, rename it to test_num. Acked-by: David Ahern Signed-off-by: Hangbin Liu --- tools/testing/selftests/kselftest/runner.sh | 38 +++++++++++++++++++-- tools/testing/selftests/run_kselftest.sh | 10 +++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index cd2fb43eea61..74954f6a8f94 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -6,6 +6,7 @@ export skip_rc=4 export timeout_rc=124 export logfile=/dev/stdout export per_test_logging= +export RUN_IN_NETNS= # Defaults for "settings" file fields: # "timeout" how many seconds to let each test run before running @@ -47,7 +48,7 @@ run_one() { DIR="$1" TEST="$2" - NUM="$3" + local test_num="$3" BASENAME_TEST=$(basename $TEST) @@ -141,6 +142,33 @@ run_one() fi } +in_netns() +{ + local name=$1 + ip netns exec $name bash <<-EOF + BASE_DIR=$BASE_DIR + source $BASE_DIR/kselftest/runner.sh + logfile=$logfile + run_one $DIR $TEST $test_num + EOF +} + +run_in_netns() +{ + local netns=$(mktemp -u ${BASENAME_TEST}-XXXXXX) + local tmplog="/tmp/$(mktemp -u ${BASENAME_TEST}-XXXXXX)" + ip netns add $netns + if [ $? -ne 0 ]; then + echo "# Warning: Create namespace failed for $BASENAME_TEST" + echo "not ok $test_num selftests: $DIR: $BASENAME_TEST # Create NS failed" + fi + ip -n $netns link set lo up + in_netns $netns &> $tmplog + ip netns del $netns &> /dev/null + cat $tmplog + rm -f $tmplog +} + run_many() { echo "TAP version 13" @@ -155,6 +183,12 @@ run_many() logfile="/tmp/$BASENAME_TEST" cat /dev/null > "$logfile" fi - run_one "$DIR" "$TEST" "$test_num" + if [ -n "$RUN_IN_NETNS" ]; then + run_in_netns & + else + run_one "$DIR" "$TEST" "$test_num" + fi done + + wait } diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh index 92743980e553..a28c1416cb89 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -20,11 +20,13 @@ usage() { cat < $logfile shift ;; + -p | --per-test-log) + per_test_logging=1 + shift ;; -t | --test) TESTS="$TESTS $2" shift 2 ;; @@ -53,6 +58,9 @@ while true; do -d | --dry-run) dryrun="echo" shift ;; + -n | --netns) + RUN_IN_NETNS=1 + shift ;; -o | --override-timeout) kselftest_override_timeout="$2" shift 2 ;;