From patchwork Thu Feb 1 06:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13540686 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 81FA46DD0B for ; Thu, 1 Feb 2024 06:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769008; cv=none; b=EEy/biVEh3BsZ0DY14N7wJRWZP769cHqx+aJ/HXduEp7nayXTVUTpMzBFrpHsU+jqyOZGspAtFa0IPBqUH172twjc8IneQNS27zqZ0ZBdS7zpiPc2uMTDTUaSJ3EoW9ENWP5YoVK2Y0+foBp1AAXqMvaz1Fr2lPxkQR3o8o9wGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769008; c=relaxed/simple; bh=DEJdWYns591whJd1rLSMrbdSOtHH9z6hQUwg4x8+DIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BRCIop2c7WEJonX/WuEjfyy0bP4ugBentQQ++slwRkPBLUQ2/zPzJLfqaFBNM2D6djzJgW2uuWuaPTyB7b7lcPNY5xRYxlYYE1cxL5OAy4WW5yDi+85VJ1VkZPggJRUhPk8R3WcE9V++V/eLKphpBwMcrAWlWS+evXeGaScHQyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=abpGXSTh; arc=none smtp.client-ip=209.85.216.43 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="abpGXSTh" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-290b37bb7deso414083a91.0 for ; Wed, 31 Jan 2024 22:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706769005; x=1707373805; 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=E1wOc1dBlqKAqzY5ma1gRIVsIZ65JWNBqw441NLcBTs=; b=abpGXSThgYI4rrvOiKyp61lIZe1XwmkaCPutLyruogygkdHYW55ymFIPnIS18QfHDf Jko2VyusiNY8CSe4dnPbsQMZ73dT8OR4DnHf2rOp9FUIYHDVfad+eKvR3kx5unIpUWMB sLnXiVhRIJW3Hn4KnAVtWHwFVx7ufH9EL2/a6F8MmAzhSVKnFB1BAzQa0udp2o2+Vh3f rwvcRFrL2qn2l1sehQENfd894fHyfDmji2FCCf21W4HbQHn1N3C9Oa7wPuX/nDhswpXk OrtKDjfDR4GTvB4M7WqvRMA8QM8yGKLDAsChsut8FvyPbeWPk5dlmAEC3KjrtT1h6WBL jkQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706769005; x=1707373805; 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=E1wOc1dBlqKAqzY5ma1gRIVsIZ65JWNBqw441NLcBTs=; b=iH6aj1RUN0qRuqcMYhSHM8L3sxDb3iD2gywneSPCLNwR5bBgIQb3z5Q7RBD4RNj/7Q izIwIc4b16drFkMorSRngrEP0OO6PXvN2tZiSonXjju/jYyXH6nWj8tJ3+KAfyWWx1Z1 xnppjIrVs7coGfm9a7TvDbbVGP2q9yUnpkO0T9DKyMcOKco6dw81FL02huAILfIw0NGc LegHdV437dnvUyNeaKvovCNobRsXcj3k/qkjfOimQK5iTuu6odK246mGpYJwajF9C4X5 J5e6KO+7SQOPqdaUYdnls7Ahme21C18qF6Ccf00ZSyS6iwBNipT9GVLAls7iWit4h+bf UYsQ== X-Gm-Message-State: AOJu0YxlUhH0Gvk7pwzSj0PnwGYxR4LbLzEpikW06au9MRaUQVDCbyLb 8yvbBIXfK70G4QCQ3r2KhomCR8IsDzsTQXoWl+6xHXjZJQs1wvBsmVDTDINzmD/j+7cl X-Google-Smtp-Source: AGHT+IFj+gHRIZ1pjspfuTZ1ywwyZKF5bOg7hzvZ+fgSJi8ovA+ICJ9jZwmK8sEW4r88K5YDJsp2nw== X-Received: by 2002:a17:90a:1506:b0:296:15e7:8f33 with SMTP id l6-20020a17090a150600b0029615e78f33mr702228pja.3.1706769005152; Wed, 31 Jan 2024 22:30:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXbzAgiYRBb6cmEFpS99nOabq5ywTnxCx3lloSvDAXEfbakUwZCdEJJoBns6eFBp973eCeVj4QE9yN4fYadPEo22haBxnaA5ATQI9Doqm6eCqs/VWt3ig0eIddAFL/jWEBeCd+SPGyHGe3GtmcQUVDCouOHleD+/9tU9JNVfxLzE2rxM4FbnU7fLHqchINri4PdNN+v4OeU/MFToBDAKGXnfUf4uIbwLjqvVkCLVAmFXWvH3Si2/8wZOjtD9BnU6WdYfw== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id pm12-20020a17090b3c4c00b0029618dbe87dsm515895pjb.3.2024.01.31.22.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 22:30:04 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Przemek Kitszel , Hangbin Liu Subject: [PATCHv2 net-next 1/4] selftests/net/forwarding: add slowwait functions Date: Thu, 1 Feb 2024 14:29:51 +0800 Message-ID: <20240201062954.421145-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201062954.421145-1-liuhangbin@gmail.com> References: <20240201062954.421145-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add slowwait functions to wait for some operations that may need a long time to finish. The busywait executes the cmd too fast, which is kind of wasting cpu in this scenario. At the same time, if shell debugging is enabled with `set -x`. the busywait will output too much logs. Reviewed-by: Przemek Kitszel Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/forwarding/lib.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 8a61464ab6eb..f9b0195bf7ba 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -41,6 +41,7 @@ fi # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +# timeout in milliseconds busywait() { local timeout=$1; shift @@ -64,6 +65,32 @@ busywait() done } +# timeout in seconds +slowwait() +{ + local timeout=$1; shift + + local start_time="$(date -u +%s)" + while true + do + local out + out=$("$@") + local ret=$? + if ((!ret)); then + echo -n "$out" + return 0 + fi + + local current_time="$(date -u +%s)" + if ((current_time - start_time > timeout)); then + echo -n "$out" + return 1 + fi + + sleep 0.1 + done +} + ############################################################################## # Sanity checks @@ -505,6 +532,15 @@ busywait_for_counter() busywait "$timeout" until_counter_is ">= $((base + delta))" "$@" } +slowwait_for_counter() +{ + local timeout=$1; shift + local delta=$1; shift + + local base=$("$@") + slowwait "$timeout" until_counter_is ">= $((base + delta))" "$@" +} + setup_wait_dev() { local dev=$1; shift From patchwork Thu Feb 1 06:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13540687 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 D443D7D408 for ; Thu, 1 Feb 2024 06:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769011; cv=none; b=QPutUEDfSCuUMiVPX3ih2qC0O7SqDE5wktzB59Z9uwBIoRypSRM6eNG4hAFVniQbor3qP918GPvbodJT2DFo4d0mslx1L2VcVydKmXsH/5/yvs3WfZM08RU3Cf0r1cSqHwg+7fodlmxEnUc/a+nO7ECkynQ4VfxJL70gwUkD/eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769011; c=relaxed/simple; bh=gJQE8wRVd0GajJkI88jFA5ZoJgVe1m9Id162/M4AmuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ku4lMHbvEeIJ6xpEML8TIv28rD+86/KGKiKY6PCk7mZMpmjEWkXAhSW+7GVgfrsdhZgr47leUoJbreZf/pFzGa3c3GCgGb90ZYRL1a/lAENq2FpP52UFC5OxC+1QhgilYJFRNPBg6b535POirkI6lwpdoJ134+tOkmfpXxhwoSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y3zDs329; arc=none smtp.client-ip=209.85.216.50 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="Y3zDs329" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-295ff33ae32so417657a91.2 for ; Wed, 31 Jan 2024 22:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706769008; x=1707373808; 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=FK5lXYghVCWitYGnZ7kIQtJ1HeoGTh9XeToUTcvTOG4=; b=Y3zDs329sWItLRQyDePWLcYcNmQNN7KcbaIgt2DSUMddcG44MwnU+HWBok+0C4QuP6 ajPESldYXvwZf5tQM3lpyLQF9F1P6AHBi4D4OV6P5lHErLZ7HXKhwa/oUvhVYDe7Ug9q 05mxusLawdLPKxfiksn5E7+PiWUsQMOPupesfvz3SRtEHcaq3jxM6+qsSVQoZDAGvXro F+rAPElvidcJQFLbnX7BB6bODPl6CCw86rt3rOEGT90ZtABqcJo/bivP9I6PgxlUlS9C TxNrgDtJIP6MYdue1DFLXnnCnpqsHp2wCBbq6hH5464xufNLgJQHjGUEoXT2oeLe1xda 35rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706769008; x=1707373808; 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=FK5lXYghVCWitYGnZ7kIQtJ1HeoGTh9XeToUTcvTOG4=; b=CMQBjDfxg4+6TDtu7C9k1QNI/GsPhRmeERI7KYjZJuve2Cg4pV6dlAy4jS2DqL0K05 SHkjXYVugovLPfzyiRhxiAMiOKXuM2bBsAjWBLjL/vcgC+22D30sg6LNgaD64zEdKPZS 2503Jm/hlp9WZ+UYqEeGfTn5uQBTQbSAuMBdbg2WmFawVHMzeiZaVRV4p6jIEQdDB/tz ogrAbcUaNpm0JlGoUS6RCSqIhzXP1wNhwV1p4Yi+momaauUbr9OKMhR9SK1fDdOI73HF uR4Brp9IfzKeTKcc9wMzwtRsCyU6s5IwV2NDCccvqhqVoib5tmmjce8B84Swhxx7O+JZ puvg== X-Gm-Message-State: AOJu0Yxx7LO3p5QrCiPtViKgsHl2DbSUv+Zz60v5hDPpMSoAph3rmy5a gdko9Kgw+m9VJGQHpQMe1x8kjMpePHlvL0VzWL7ZJT+/V/8/CrX46XwHgb/T1nps0Snx X-Google-Smtp-Source: AGHT+IHjl1NObgoMWBTapQuAmzjvWyOGFZOis9i2PjdAgQbLdTLRh7KlI3xfTx3Dl02O7P5ptm376g== X-Received: by 2002:a17:90a:fb8f:b0:295:b0cd:9be6 with SMTP id cp15-20020a17090afb8f00b00295b0cd9be6mr1148845pjb.30.1706769008546; Wed, 31 Jan 2024 22:30:08 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVMvdFe7EohbMAn54EXJdscrdDZ9m4GCU4sqMYZletBSefFuQiQstnObxpd8tg9iiJUgh5afLGUOLxYS4ADTtVRtSgOgSJN5q5UAbeIpZqFQB/WeRl+Uf8r/8TA/9HelbgyPuimqauNFj2XNw9SZMlP4Uo+L7pdbOBvE6zCO+nxRl8RlauLutPwXd8UVbIaplHxNBvYv4Y1QNP6ZwWrZM0MOv0KgEJK3W/S+hlCYs/IFlotNNM0AV5CEfKC4N7G9hb5aA== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id pm12-20020a17090b3c4c00b0029618dbe87dsm515895pjb.3.2024.01.31.22.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 22:30:08 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Przemek Kitszel , Hangbin Liu Subject: [PATCHv2 net-next 2/4] selftests: bonding: use tc filter to check if LACP was sent Date: Thu, 1 Feb 2024 14:29:52 +0800 Message-ID: <20240201062954.421145-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201062954.421145-1-liuhangbin@gmail.com> References: <20240201062954.421145-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use tc filter to check if LACP was sent, which is accurate and save more time. No need to remove bonding module as some test env may buildin bonding. And the bond link has been deleted. Reviewed-by: Przemek Kitszel Signed-off-by: Hangbin Liu --- .../net/bonding/bond-break-lacpdu-tx.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh b/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh index 6358df5752f9..01dcf501da41 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh @@ -20,21 +20,21 @@ # +------+ +------+ # # We use veths instead of physical interfaces +REQUIRE_MZ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/net_forwarding_lib.sh set -e -tmp=$(mktemp -q dump.XXXXXX) cleanup() { ip link del fab-br0 >/dev/null 2>&1 || : ip link del fbond >/dev/null 2>&1 || : ip link del veth1-bond >/dev/null 2>&1 || : ip link del veth2-bond >/dev/null 2>&1 || : - modprobe -r bonding >/dev/null 2>&1 || : - rm -f -- ${tmp} } trap cleanup 0 1 2 cleanup -sleep 1 # create the bridge ip link add fab-br0 address 52:54:00:3B:7C:A6 mtu 1500 type bridge \ @@ -67,13 +67,12 @@ ip link set fab-br0 up ip link set fbond up ip addr add dev fab-br0 10.0.0.3 -tcpdump -n -i veth1-end -e ether proto 0x8809 >${tmp} 2>&1 & -sleep 15 -pkill tcpdump >/dev/null 2>&1 rc=0 -num=$(grep "packets captured" ${tmp} | awk '{print $1}') -if test "$num" -gt 0; then - echo "PASS, captured ${num}" +tc qdisc add dev veth1-end clsact +tc filter add dev veth1-end ingress protocol 0x8809 pref 1 handle 101 flower skip_hw action pass +if slowwait_for_counter 15 2 \ + tc_rule_handle_stats_get "dev veth1-end ingress" 101 ".packets" "" &> /dev/null; then + echo "PASS, captured 2" else echo "FAIL" rc=1 From patchwork Thu Feb 1 06:29:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13540688 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 212766DD0B for ; Thu, 1 Feb 2024 06:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769014; cv=none; b=lTlu2wdHNrBBPots64Q5l1Pa4OMpe85HoG3oMTZNjpRA8Cb+nKzwyuCe1T6v9ezBUfGoMIMM4vN0AO7ODNSpLVo5PqdZwQZIR3NIrbVd3/F9IyFvwxzE0PQ80eLlJcBzhqcqRLdI9fgMrKZQq2iGWcLTbyJPDeZkAcuK9slrOZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769014; c=relaxed/simple; bh=G/Ux3LgDRNAQg7rjHZrbyybShnGgVnE/dh5wJIEOlQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TT7e3+44a4J23gLv4PiJNVrrBlzKFHLQFcHTJay60R9QpGZvK++dPYncpCZrxsIP9TIa627N7IgfU2Y7Lb3YxGt7E0SgHznYM4tjr+xZNMdhvVYVt/LqBRgysQOBifPNy/03gC4zZvDl7TfJ+Pm5jounvAbrUfvHp3KxuslaCUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WKzv3dB7; arc=none smtp.client-ip=209.85.216.41 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="WKzv3dB7" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-295c67ab2ccso420684a91.1 for ; Wed, 31 Jan 2024 22:30:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706769012; x=1707373812; 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=1N5DayUxd7++DZoXwdreOmT1QtfwA5myExd/7/w8Yzc=; b=WKzv3dB7qiEH7oJdY/De2HO/eu5G4okv7HF0QvuYjLfT82Rkqu/FOnjavyaZIei1ah EbMufCe+P+y2aT4TmzKRNsIZmFFEEjzp+kL8fbeZ/N9CrhRWmg+NH0TF4nq5zJ3RZieJ o8vYP6C2IoQm8uzmACwGTlOqAcRbcSYkZg768YkZw9kHds9/i2/Y6jhl7hCwpQIgokl5 FkbM/B5mO9i2Qle4MGok5zlqZH0LTVrROzw+AP2gpt7l1BTJ14zvpvnfOQ6E4SdMw77G cQFbYlYE0W9q/lXtxVWiX3rggUcwCQXKhRxN+AJdcctLCimo9sUTHx0OuJVMbDBQrRTx eCjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706769012; x=1707373812; 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=1N5DayUxd7++DZoXwdreOmT1QtfwA5myExd/7/w8Yzc=; b=Irp6wKGs0zzMpCg0f2IM0pQKv8X+f9y2ITvG63xVNtaMkSFmQ7NMobA4Y4/363H2AF 4f9WRZqjbK6i4YynNR2Uw0kdDfwEx2I88wJO/CKFTmGdK8ZeYDBz1CY6TmuHMqcGvwzE v4p7YyxErLHKIqXPMTzmyAkohtM8W/MBKimw7pFcd8oma0rbQsvTY+pQxyt54HapsVvS kErkN0f0DxkWS6EUo2Vz+7VG1JMB/E0EHfQMCaTT59aSG/Teamxog4xjOlqllJYPbXoQ ujLQJ6zZ1BdIZhP3UiV1ahHn8p3xQSCIjes8hfGdzEzhtNSEGB1NmPNrfwoz/1xBbWX+ LUwg== X-Gm-Message-State: AOJu0YxT6nCmrrZkp+KjWZb0DYXpnojdbiU9+hdAjOW1e4ngh5FReMML 19PdFxMF+eKqFytlSrLL30KGLUOe0zc0NkiutTmxHSzFtl+mNR/8be/jcF27E8GhFfaF X-Google-Smtp-Source: AGHT+IGjbjoYBiUCUN4oMlEc1AcbX/l7Rysj7XXL2LxhB2L/N3FCqZall+WbA1adkhpnfa/difClPA== X-Received: by 2002:a17:90a:bc82:b0:295:f059:5713 with SMTP id x2-20020a17090abc8200b00295f0595713mr3304993pjr.38.1706769011920; Wed, 31 Jan 2024 22:30:11 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVZETwiN+z2dGRmFb/f/IG67qAnO/poTwa3Dgl5ZnTfGCwGXval12+6F55mrbYFMSYOX0EwxAvEVxARW8DhoHImxr2g34fitM3t7cO7VwdG2vSO1hR3oGGxM37qqbPGWWWCPh8B9ZdCbEom+GUbIr9fiGd2ckbaRJX1qtK8cGUa5vZAdnR+nKrcKbHvQokB/t4If1/cuJXc5YILZYAoqTmnM65JtFJycnUpz8lPvBsgKHLQ0TaDPU20f1biXlbMmF1ZTA== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id pm12-20020a17090b3c4c00b0029618dbe87dsm515895pjb.3.2024.01.31.22.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 22:30:11 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Przemek Kitszel , Hangbin Liu Subject: [PATCHv2 net-next 3/4] selftests: bonding: reduce garp_test/arp_validate test time Date: Thu, 1 Feb 2024 14:29:53 +0800 Message-ID: <20240201062954.421145-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201062954.421145-1-liuhangbin@gmail.com> References: <20240201062954.421145-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The purpose of grat_arp is testing commit 9949e2efb54e ("bonding: fix send_peer_notif overflow"). As the send_peer_notif was defined to u8, to overflow it, we need to send_peer_notif = num_peer_notif * peer_notif_delay = num_grat_arp * peer_notify_delay / miimon > 255 (kernel) (kernel parameter) (user parameter) e.g. 30 (num_grat_arp) * 1000 (peer_notify_delay) / 100 (miimon) > 255. Which need 30s to complete sending garp messages. To save the testing time, the only way is reduce the miimon number. Something like 30 (num_grat_arp) * 100 (peer_notify_delay) / 10 (miimon) > 255. To save more time, the 50 num_grat_arp testing could be removed. The arp_validate_test also need to check the mii_status, which sleep too long. Use slowwait to save some time. For other connection checkings, make sure active slave changed first. Reviewed-by: Przemek Kitszel Signed-off-by: Hangbin Liu --- .../drivers/net/bonding/bond_options.sh | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/drivers/net/bonding/bond_options.sh b/tools/testing/selftests/drivers/net/bonding/bond_options.sh index d508486cc0bd..6fd0cff3e1e9 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond_options.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_options.sh @@ -45,15 +45,23 @@ skip_ns() } active_slave="" +active_slave_changed() +{ + local old_active_slave=$1 + local new_active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" \ + ".[].linkinfo.info_data.active_slave") + test "$old_active_slave" != "$new_active_slave" +} + check_active_slave() { local target_active_slave=$1 + slowwait 2 active_slave_changed $active_slave active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") test "$active_slave" = "$target_active_slave" check_err $? "Current active slave is $active_slave but not $target_active_slave" } - # Test bonding prio option prio_test() { @@ -84,13 +92,13 @@ prio_test() # active slave should be the higher prio slave ip -n ${s_ns} link set $active_slave down - bond_check_connection "fail over" check_active_slave eth2 + bond_check_connection "fail over" # when only 1 slave is up ip -n ${s_ns} link set $active_slave down - bond_check_connection "only 1 slave up" check_active_slave eth0 + bond_check_connection "only 1 slave up" # when a higher prio slave change to up ip -n ${s_ns} link set eth2 up @@ -140,8 +148,8 @@ prio_test() check_active_slave "eth1" ip -n ${s_ns} link set $active_slave down - bond_check_connection "change slave prio" check_active_slave "eth0" + bond_check_connection "change slave prio" fi } @@ -199,6 +207,15 @@ prio() prio_ns "active-backup" } +wait_mii_up() +{ + for i in $(seq 0 2); do + mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status") + [ ${mii_status} != "UP" ] && return 1 + done + return 0 +} + arp_validate_test() { local param="$1" @@ -211,7 +228,7 @@ arp_validate_test() [ $RET -ne 0 ] && log_test "arp_validate" "$retmsg" # wait for a while to make sure the mii status stable - sleep 5 + slowwait 5 wait_mii_up for i in $(seq 0 2); do mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status") if [ ${mii_status} != "UP" ]; then @@ -276,10 +293,13 @@ garp_test() active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") ip -n ${s_ns} link set ${active_slave} down - exp_num=$(echo "${param}" | cut -f6 -d ' ') - sleep $((exp_num + 2)) + # wait for active link change + slowwait 2 active_slave_changed $active_slave + exp_num=$(echo "${param}" | cut -f6 -d ' ') active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") + slowwait_for_counter $((exp_num + 5)) $exp_num \ + tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}" # check result real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}") @@ -296,8 +316,8 @@ garp_test() num_grat_arp() { local val - for val in 10 20 30 50; do - garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000" + for val in 10 20 30; do + garp_test "mode active-backup miimon 10 num_grat_arp $val peer_notify_delay 100" log_test "num_grat_arp" "active-backup miimon num_grat_arp $val" done } From patchwork Thu Feb 1 06:29:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13540689 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 3BCEF83CD5 for ; Thu, 1 Feb 2024 06:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769018; cv=none; b=QMMgHKPLEH6xYefE7dkU4yd0Bvjld0kZUPbNtTX6Da79bt/6cVjxykZ4PlDCxckidK3bZWRgUwesJaE53xqFxrymZPsDVDUu0An2mDyo3zy/PHUIUocqdkMPEBipNig5YpxGLk0/7h96c+zKAc5p98BFsEYu+tFjzampVt7miDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706769018; c=relaxed/simple; bh=M74eNgV16JtgWx9aB7DcyItDIPTDR+gWkpKSQxRd9Ek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y22mvqG3Dd/1mIgaxih/KBynyu0LoBydAlddOJTDuXA+hjEoNy2ftjd1UhuKu+PobWvmzWc8BpW8ClgOuaO6Q2qNZ0isGjSUgjQEMTWcFOZF3jqAikAxwBVamTUm9v7GSt5Tg+nn9zx6vgqYPbmezV3rY+lCxVLZqD6A8uHS/pk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kY9uEuiw; arc=none smtp.client-ip=209.85.216.43 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="kY9uEuiw" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2907a17fa34so423108a91.1 for ; Wed, 31 Jan 2024 22:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706769015; x=1707373815; 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=ej4ohfH3ilat5qexDhlEeW0/MFPNuEhuHNlBwUEMkl4=; b=kY9uEuiwupRKvN/kdZ2jjtZq376DpkFDGKEF1LPJIP01DQl4Cy9uSaDS0SlpNN5E7H U6Y1cxsHGhF4KvqaKeBLAy4HLdACARprUjGcLhpWCU9h5+/iJKIzRbVOb+0J0hm7FiaF No7QcTVzsbm5ensgMkvhfcCAA3kCqW3f0y5rr03ffn6EJkYG8pE8wZEdBW3QZNNFo10o X3xdG9fZAKYO5COXSvvx/DC0Y7DOXZzHSsSVarawxyAwI3EZX7MVRfcwrMANxQ1YfdS1 Z9whgFqQGSsMJ70VrBYW9ckWjatX/Z/sJnW/3e6nqU8F5tMzzjyDzVh0nhlHB2jsfwBP Skow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706769015; x=1707373815; 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=ej4ohfH3ilat5qexDhlEeW0/MFPNuEhuHNlBwUEMkl4=; b=QFMR4N7M4PjiodG0e0zUR0cXMoht+oVxMZ9sevMzhlwYqMAJ0Gfi1B+nio6vFZQWzI wcFj0CpxC/0m5JjlqKXtI715pJDGV3bOOKNrdzfuqWzRw+jrW+6yEaBWFwKlbvrPVUuw cnym8LeXfQMC0HREq1r1mA1ZBWQoGwNjST3oBgnHVrVwHh9V8SW23i/rBDH2DGPW4xWQ 17LyhFXtrDl1UDEwqKSlTifHu/19GcvMlfZ8IKOiLb8Jn55zKmczIA6WV9I5CvxMYXTY pV1P2qcoowoNxrN5qm/tM3THUZK8db7MHm+Kja3y4jv3BRG67muIDUGqldyV6ONeM9j4 tD5g== X-Gm-Message-State: AOJu0Yx9ier0l6OU6vrWVs6NyiCcKaQMEN4ZI+6UFU4/fQyWzWMg/ZSK J+KJKyCEBkxJaJPG4LJt0qx4C4ScdBJhmFcbCUSpC1pyODjRwd4yFpuGkA8DoerXyHtN X-Google-Smtp-Source: AGHT+IEvQUjc30ptGFEoJ7RWP2nU5qS3B/ZsF74gvz6UhTdikCIpYXKBDgxQ6syIoyarSHkAD7az2Q== X-Received: by 2002:a17:90b:f88:b0:295:c87f:6f51 with SMTP id ft8-20020a17090b0f8800b00295c87f6f51mr1247973pjb.26.1706769014942; Wed, 31 Jan 2024 22:30:14 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUr1GUPop459yagO+MWzNnM+ZQfsjsLw6YA1TqhmQRAclJ7xE11uW9y5qC6iBkVUB8TdDhEuTUYcMvSDLoEad5rUeSoxEK1hwiskGxNB2lMnojaYcxoGQ0KUpBVqnTkgG2pFslO5VGdmtr8GQ+UZa0hQ67sqU11oK9iyiJBFBjn/PB0YQ0XyPeSTge4RMDKmyn3NqhfSi3P/z5bSvO1TnXz+9T4i3GNkH7bszY3VJHR0DNo76twrU5vE9VXZTbsv30OqQ== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id pm12-20020a17090b3c4c00b0029618dbe87dsm515895pjb.3.2024.01.31.22.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 22:30:14 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Przemek Kitszel , Hangbin Liu Subject: [PATCHv2 net-next 4/4] selftests: bonding: use slowwait instead of hard code sleep Date: Thu, 1 Feb 2024 14:29:54 +0800 Message-ID: <20240201062954.421145-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201062954.421145-1-liuhangbin@gmail.com> References: <20240201062954.421145-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use slowwait instead of hard code sleep for bonding tests. In function setup_prepare(), the client_create() will be called after server_create(). So I think there is no need to sleep in server_create() and remove it. For lab_lib.sh, remove bonding module may affect other running bonding tests. And some test env may buildin bond which can't be removed. The bonding link should be removed by lag_reset_network() or netns delete. Signed-off-by: Hangbin Liu --- .../drivers/net/bonding/bond-lladdr-target.sh | 21 ++++++++++++++++--- .../drivers/net/bonding/bond_macvlan.sh | 5 ++--- .../drivers/net/bonding/bond_topo_2d1c.sh | 6 +++--- .../selftests/drivers/net/bonding/lag_lib.sh | 7 +++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/drivers/net/bonding/bond-lladdr-target.sh b/tools/testing/selftests/drivers/net/bonding/bond-lladdr-target.sh index 89af402fabbe..b7b60e767daa 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond-lladdr-target.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond-lladdr-target.sh @@ -17,6 +17,11 @@ # +----------------+ # # We use veths instead of physical interfaces +REQUIRE_MZ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/net_forwarding_lib.sh + sw="sw-$(mktemp -u XXXXXX)" host="ns-$(mktemp -u XXXXXX)" @@ -26,6 +31,16 @@ cleanup() ip netns del $host } +wait_lladdr_dad() +{ + $@ | grep fe80 | grep -qv tentative +} + +wait_bond_up() +{ + $@ | grep -q 'state UP' +} + trap cleanup 0 1 2 ip netns add $sw @@ -37,8 +52,8 @@ ip -n $host link add veth1 type veth peer name veth1 netns $sw ip -n $sw link add br0 type bridge ip -n $sw link set br0 up sw_lladdr=$(ip -n $sw addr show br0 | awk '/fe80/{print $2}' | cut -d'/' -f1) -# sleep some time to make sure bridge lladdr pass DAD -sleep 2 +# wait some time to make sure bridge lladdr pass DAD +slowwait 2 wait_lladdr_dad ip -n $sw addr show br0 ip -n $host link add bond0 type bond mode 1 ns_ip6_target ${sw_lladdr} \ arp_validate 3 arp_interval 1000 @@ -53,7 +68,7 @@ ip -n $sw link set veth1 master br0 ip -n $sw link set veth0 up ip -n $sw link set veth1 up -sleep 5 +slowwait 5 wait_bond_up ip -n $host link show bond0 rc=0 if ip -n $host link show bond0 | grep -q LOWER_UP; then diff --git a/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh b/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh index b609fb6231f4..acd3ebed3e20 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh @@ -58,7 +58,7 @@ macvlan_over_bond() ip -n ${m2_ns} addr add ${m2_ip4}/24 dev macv0 ip -n ${m2_ns} addr add ${m2_ip6}/24 dev macv0 - sleep 2 + slowwait 2 ip netns exec ${c_ns} ping ${s_ip4} -c 1 -W 0.1 &> /dev/null check_connection "${c_ns}" "${s_ip4}" "IPv4: client->server" check_connection "${c_ns}" "${s_ip6}" "IPv6: client->server" @@ -69,8 +69,7 @@ macvlan_over_bond() check_connection "${m1_ns}" "${m2_ip4}" "IPv4: macvlan_1->macvlan_2" check_connection "${m1_ns}" "${m2_ip6}" "IPv6: macvlan_1->macvlan_2" - - sleep 5 + slowwait 5 ip netns exec ${s_ns} ping ${c_ip4} -c 1 -W 0.1 &> /dev/null check_connection "${s_ns}" "${c_ip4}" "IPv4: server->client" check_connection "${s_ns}" "${c_ip6}" "IPv6: server->client" diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh index a509ef949dcf..ed2317eea5d3 100644 --- a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh @@ -73,7 +73,6 @@ server_create() ip -n ${s_ns} link set bond0 up ip -n ${s_ns} addr add ${s_ip4}/24 dev bond0 ip -n ${s_ns} addr add ${s_ip6}/24 dev bond0 - sleep 2 } # Reset bond with new mode and options @@ -96,7 +95,8 @@ bond_reset() ip -n ${s_ns} link set bond0 up ip -n ${s_ns} addr add ${s_ip4}/24 dev bond0 ip -n ${s_ns} addr add ${s_ip6}/24 dev bond0 - sleep 2 + # Wait for IPv6 address ready as it needs DAD + slowwait 2 ip netns exec ${s_ns} ping6 ${c_ip6} -c 1 -W 0.1 &> /dev/null } server_destroy() @@ -150,7 +150,7 @@ bond_check_connection() { local msg=${1:-"check connection"} - sleep 2 + slowwait 2 ip netns exec ${s_ns} ping ${c_ip4} -c 1 -W 0.1 &> /dev/null ip netns exec ${s_ns} ping ${c_ip4} -c5 -i 0.1 &>/dev/null check_err $? "${msg}: ping failed" ip netns exec ${s_ns} ping6 ${c_ip6} -c5 -i 0.1 &>/dev/null diff --git a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh index 2a268b17b61f..43447be54b10 100644 --- a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh +++ b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh @@ -96,13 +96,12 @@ lag_setup2x2() NAMESPACES="${namespaces}" } -# cleanup all lag related namespaces and remove the bonding module +# cleanup all lag related namespaces lag_cleanup() { for n in ${NAMESPACES}; do ip netns delete ${n} >/dev/null 2>&1 || true done - modprobe -r bonding } SWITCH="lag_node1" @@ -148,7 +147,7 @@ test_bond_recovery() create_bond $@ # verify connectivity - ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1 + slowwait 2 ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 -W 0.1 &> /dev/null check_err $? "No connectivity" # force the links of the bond down @@ -158,7 +157,7 @@ test_bond_recovery() ip netns exec ${SWITCH} ip link set eth1 down # re-verify connectivity - ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1 + slowwait 2 ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 -W 0.1 &> /dev/null local rc=$? check_err $rc "Bond failed to recover"