From patchwork Fri Feb 2 02:37: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: 13542000 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 49452BE5A for ; Fri, 2 Feb 2024 02:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841489; cv=none; b=MzHA71aEj/rG7YwSx46vWVDBq9wESm0K9K63n+y1Dd7xHcpahcnOXQEOBenM94mA/dXCd4cXDdttuAxSinkoVWmLpv7DoYOg+47sMxD+86yVqz188CG0OpNRzI9V4z9uzPt3VXV7ZIxOiP9E+Tgt9HkZqbdLARcXnlBj6FlI9CA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841489; c=relaxed/simple; bh=KDU5Sap9KmERo+IOTSOxwD/wM01vjxr94Mz5wDzVw8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=acSzBx1USYaHNGLyGwErsEJYpgzJazwHZD+o+mLu9VKizqbVkl1DBM6YiSyGbwVBpIbKdMBIPJtqrQqc34/jQTiIp7Eecj4p1etxtc6KyQYmPDQp9+ncxtoREa+ZN6u8s8W1iBykBNZ18ny/t7cZbpyDICK3XosHSpBnOQSu+MQ= 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=F4jGuH/n; arc=none smtp.client-ip=209.85.214.174 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="F4jGuH/n" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d932f6ccfaso13112155ad.1 for ; Thu, 01 Feb 2024 18:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706841487; x=1707446287; 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=7f+YPdLV02rXa/1f3nKaHnsp07nRY0/vdqPS1EubdSo=; b=F4jGuH/nAiCYeuEN3cwd6JF3YIN9ZSyUGJsz26oBluP9GF5um5NSboxJqwbKbwWCCZ WIt6QwHuHS4+qRlJCH7k1I8FAF9zdQ8d1EhU8KxDqCgw7vXCqPMkT8TMt80XayvsJGf8 ayq0SEI5h4yN173dGzkCKg8WD2LI7ps4ukCYRYWKzyoiwqoiXzwk1y8Lkmpwg4qw3A1k IRDI8psXQlj60Zl23uskLi5bXgJpP9tw2h8c5z7TddmJrOk/O+fDhU9fyucmns2R/vWh vILgMQE2A/u7ILUeCP/IejN5NYJKs3G75kFf1lRutuTI84oacLJHr13WgW2GCe4HhzSt gsfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706841487; x=1707446287; 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=7f+YPdLV02rXa/1f3nKaHnsp07nRY0/vdqPS1EubdSo=; b=s217sCEZ8CVGuwIdcBqay0o6/4Dn4uIJE+ySM1EoD3SUSclO33Rn8MsydrPUnCiaYm ZUCmjg09ZpUkhSqF7iBgILukiIsTLnIOKhl4cxqDD9lii9R7qvMCHWvs1FIB2Cfdc7bn CewFAJG9GodRJ6Yxczz90gg4GcZjnJCOyAGmuXNVXqjVhWhHKKWUsK8rgMwwaocmDQ+V HUL8IScLhLX4Rq8edWfwSnN0CS4qA8NpPDypgh2w21gnqOc5zJZj3oUIa9zZvm3N63IJ Uu06QGzb2jBd3HyZ4hBuyfG+A9Je3yF23zqyy1Q10zqGAwidhADaztHbb/V+8QA3CpFK TkbQ== X-Gm-Message-State: AOJu0Yz31rLva1cxHttArkxnOBT0KTkHcYdear3AJRiGnud7ZCuN8o8q waX8WjEQP+JbYnz/5EqVe+nLu9CHzgf3a1y7w30VfU83WCFjzrejJFa92AMv88l7D0hs X-Google-Smtp-Source: AGHT+IE60aE7iVtNs16/OTB6Oi5cYYl4Ls/oROOmgN/3m+JftJYc1+BE+6HL5g30nAvNOK7OSebgvQ== X-Received: by 2002:a17:903:2b08:b0:1d9:63db:2bd7 with SMTP id mc8-20020a1709032b0800b001d963db2bd7mr2464077plb.61.1706841487115; Thu, 01 Feb 2024 18:38:07 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVQCXpwluYZWLhgSAVOEAI7WrRmfnyVaHlzzvx6zICR6OndgZS8OgCvPLIqVS4hhSaaKHqPahXiOqOLRcMu6XFTlJ4gT+8rqnbGcsJWel8NVP1uXJtIf/KtSwNi8bXjjy5aQrWUrXy+bYpdLPk7Tz0qeSpR5bYeZRWkxABYCXhW7bn3IXPzXcnrt3uBpuEK7Lmpnc5J/fmLssB7uTZ1mOkX/2KOI8Xa39rXwuTnU8/GedmJjPVUJlTfr7txzkajr8sJSg== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ji19-20020a170903325300b001d944b3c5f1sm493256plb.178.2024.02.01.18.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 18:38:06 -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: [PATCHv3 net-next 1/4] selftests/net/forwarding: add slowwait functions Date: Fri, 2 Feb 2024 10:37:51 +0800 Message-ID: <20240202023754.932930-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202023754.932930-1-liuhangbin@gmail.com> References: <20240202023754.932930-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 | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index a7ecfc8cae98..db3688f52888 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -37,6 +37,32 @@ fi source "$net_forwarding_dir/../lib.sh" +# 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 @@ -478,6 +504,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 Fri Feb 2 02:37: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: 13542001 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 5819FC2CF for ; Fri, 2 Feb 2024 02:38:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841492; cv=none; b=oFs8EpGKWyoVlVrlAzao2GXNORqZRo7+czuoj211s5aZEJpgoy9z1lq3RdpvD4nwXl7mfptdN6ArWpP+XLZTxs67o9Oh9sdc83zrkbpPH+h6Gh9CNzLq8gCihfwskB4tD+HZtz/DUNCseDFpe2IU5jFcERJ/6EFAfrwtKPZzpcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841492; c=relaxed/simple; bh=9sCZCUTM9/Bv/osCyDQdlDwrCLiHF/EY3ax+mpZSXpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zqh7aSHwWs9p5L6aPlTQuQzmhKiXURsR9ldiAYGYgfIrHsYeEtuLql7+tIxM7imU78qG9ClTohtPsLtS46ZMh0zHrGAwMQzI/IlF6eUTB5P15/UJM1q+V2bOrCME7hh4E9WCDs4OKeSSSuWPn0uW0XoSqEfr193vwHbaJAvzwGo= 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=SoJsY9u+; arc=none smtp.client-ip=209.85.214.176 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="SoJsY9u+" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d94323d547so13731665ad.3 for ; Thu, 01 Feb 2024 18:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706841490; x=1707446290; 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=0292U331PRMk/JKM5bmBjV7z2aP5Wa2jlTcLtcJEHno=; b=SoJsY9u+sW9AxEKwmgLEyhNdYPAQV9xPCDqTvUtE7NuYBO767tU2IewMNxPV+BIbq9 /2qR4Bufi0k0bwQAlcvDH22+4LYVEDU7ffOTtt9MPNocLD6fTvfY7ltUwBA1jZiuU4pA j91oCQqPolKXH697stgBM9HNmAlBXZe9eJCtShZayT00+mQ8JFR0EmLIiDucR1P7tlfr 4ZNDJry0KmVgmOazY6JSqn8GEO44Obys3UDP7VlYB8/iwHFRYZsgLLyc1UqzgZGrlNty Qhx/0sCnTuplPeEE6O6XGE6yi8ewf/mTF8FBF0lahVeiVavCqcDiSqLixAwfLRxzkROz 77aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706841490; x=1707446290; 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=0292U331PRMk/JKM5bmBjV7z2aP5Wa2jlTcLtcJEHno=; b=WKvhWB/nJfnNG8jfOQTYDVo2X1/Nnh9y/eQwWv5cF/+jBoHQtsoF4Xv47h/KHFlb3w 7j48m11Xi7MlsPseNuXqzPcQzWPbCMsLm2WTnEvvRxl9pu5zOsJrYBw8MM/8j5s+CKpu lVPEKgV1LTf3A5pQu8FkYc9AqlWJMFs5KFtaZNNSqZb0fO/GZ0dMx3VCoqRGk23PvY2W tT7mrd0tgQT7s5Lw3qgvS2NUxdWCI8eiVUt09l3OjfWjzO/JXwGkWwLHkvyB8gmQe8BF D9/r3jAgg3/fCJ3Hr3CZGHGhzwi2M4O7WVIXc2m38tyYVJUHYqvl5YMtWvTwMCisuyt6 XdPg== X-Gm-Message-State: AOJu0YyGrOIlAQyZIGxv2OygtWGFEq5eZuJXd6ovVyf5QafdvRs4uLHM X4ga5gtq1bWMzczdawcD1oJ4sa1bPRE8d8JDiGs7SrXjHHHdtoJGS53Cz/New1AQeIho X-Google-Smtp-Source: AGHT+IFJaPPv+zV8irfAAXJzsiqz/qn3WEddHTNgCe97pZzkHtiGUGQthDgX1QPYO3o/s5dTtyg/ag== X-Received: by 2002:a17:902:f545:b0:1d9:232d:4c1c with SMTP id h5-20020a170902f54500b001d9232d4c1cmr1081597plf.52.1706841490217; Thu, 01 Feb 2024 18:38:10 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXoO0RpiBdZ35WtlW4lxLcC9+yhNGkuDYf4z2BMDt4KQ8Ls5Qd5QKSTQ3S8ZLpu9hAD0TJe+8+IRSg2an/KqMQ6Cymu24NKQDyLQAtRB8uT6B6T6VFClyD34+L0WIMbXgODCEMRd3MlsdxSEJO+SHUPl0ltCFXwdCYPcba54t+EnIJDmeeJLos3bl6nkn4BH5nqjbDJeSnrVk/cjTw4EZ7p9Xz2cjCKc9n7kmPfTKJ/w+x0xnbupOTKUaT7PcdxrbHYxg== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ji19-20020a170903325300b001d944b3c5f1sm493256plb.178.2024.02.01.18.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 18:38:09 -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: [PATCHv3 net-next 2/4] selftests: bonding: use tc filter to check if LACP was sent Date: Fri, 2 Feb 2024 10:37:52 +0800 Message-ID: <20240202023754.932930-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202023754.932930-1-liuhangbin@gmail.com> References: <20240202023754.932930-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..1ec7f59db7f4 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 Fri Feb 2 02:37: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: 13542002 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 1C0A0C8DB for ; Fri, 2 Feb 2024 02:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841496; cv=none; b=bknJIub9F8bYtjoUWV0FHLYaZ6QNrU60Bgp8FNPf2qOmXi2SISS3XVSv+3ihldVk15YSsXhAv0wCCDfPi7y70lGTZhrdz1doXPWnKkPYZXLDtX1qtHw6r1vFGYzsfxfnMsYAcr+izXGsfTOxvaWBQIHUUljjLAfqRy8t8/yrTW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841496; c=relaxed/simple; bh=G/Ux3LgDRNAQg7rjHZrbyybShnGgVnE/dh5wJIEOlQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NlRkw8KkvUGAP+ZPoTHh8QGp/97fnK0cGnHV+LTLKiyuuWIBdnIHlXFRNkidxDBOmADm667LfSexfCDB74NvT7HR9eZrWt6UJW8UtbrAIuyKJ/djhalBQsjQVGYD7Le/Xr2jaMD7yJ9Jy/kwbDJq0rY8I+ciHHlQ1Yb9wb5ZlMU= 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=JUMuC/2P; arc=none smtp.client-ip=209.85.214.176 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="JUMuC/2P" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d70b0e521eso11825135ad.1 for ; Thu, 01 Feb 2024 18:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706841494; x=1707446294; 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=JUMuC/2PZ5yf0w21dfTtvPJuThbkjARmcF4XCJbDFqG5GUfXxrM17tNJe6HiH1amkY eqXxfzqWzXcmKy4VR3DjZAgzSqdb+kn8XIIcW+u6sM6zcJEtSlfufEDIZTh8Fkp8py97 9IugEJ7Zh3chR2qeZl6IZi1XzQW2GCr1MRpmjewlsT5mc1kU94DEXe3afuyRfBMS0si4 7O5KIoDGpnEoTHD9+2UPPgcjU844sy2lP8ie5RhPxgCqAI+ukP/AXcq3KCmXPGGZ0QcN qPMCYNjDjiRZI5VO5YOCOIAXCRwe4z30a0qaPfujSp8N6eu3oG9UwS7rn/O6q/mW83ar Lnrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706841494; x=1707446294; 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=uewYcFSe0xpKEE+Ovg/M0bF8HLHzgXD5FY6GpjtWGUXYe+bIESaxkNsD7FF7Ee0CPb dEYNtbdgrT7JOxVD2HG9ctwbrglED4M0FoSZc67AluvrKkIIo6nB+dpkfdUqxyx0w9RE 7HM/Vp5GBYE7N1KstQZcadvVWMO5/bLKDCOTUETg3tnVomjdexvceWtHWOYHs2kbddsg 9pbWJb0/Pq+kO/wx220r+xEAi5ofwGf54MZLYjBj01ThYg0k9vxeM8y7FWWOyOdyWe1i 6OvTzPjSpvTsWu4df1JehqQQUG4jHcT+tVFuDWI/pGM3oVjV+YI8YKnHA8WAyKWQePKr DpeQ== X-Gm-Message-State: AOJu0Yy+yokXzrWTMtiouu2jlB2K7PzK1AqHuX9vzl/6zDa7MHhhCrMe 4McbAuWzBn2gcd08Pds1CN3C7Ul5UStQc3ct8TCn+l1s7DC3nZ2oskEmtUI3L8nmGHiK X-Google-Smtp-Source: AGHT+IHYxYeHkGbsaMmubGxfoBe7dFJ8wpd6/3BK8jrWNYu1pUquYS0ENT1Cz2FhgFlJTMmFv6qXhg== X-Received: by 2002:a17:902:c64a:b0:1d7:719a:41a0 with SMTP id s10-20020a170902c64a00b001d7719a41a0mr851872pls.56.1706841493953; Thu, 01 Feb 2024 18:38:13 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXYJj1iI533R35PO7eC2QImFQfDviFDOy4e6BCTrj8Io3S+s2Ow8EJHAWxp7i2n29ELbxQoDij6OIR5V76xX91CrMdSLqv6d8oPFt9XPOC6yWE9S/fXrGJo1/aP+EQ3G1geru48A7c1GsJx6wWTM3npxWNEOATmJD7DirTWP8xKmwMmjtTtaMTUw5C9lDm4eSuL+3C9WTE8A4xN2uoeQA8uZ5n+GFQmSQk9anIfxPRZO24w1byQb6OiYRrGm7ocG8zYUw== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ji19-20020a170903325300b001d944b3c5f1sm493256plb.178.2024.02.01.18.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 18:38:13 -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: [PATCHv3 net-next 3/4] selftests: bonding: reduce garp_test/arp_validate test time Date: Fri, 2 Feb 2024 10:37:53 +0800 Message-ID: <20240202023754.932930-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202023754.932930-1-liuhangbin@gmail.com> References: <20240202023754.932930-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 Fri Feb 2 02:37: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: 13542003 X-Patchwork-Delegate: kuba@kernel.org 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 1AF15C8EA for ; Fri, 2 Feb 2024 02:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841500; cv=none; b=KKpiWtLLlv7ZT33tO6QDOcun/V1s3L8Rb2/tW6k2GsP/JcuVplY8rtY2Wr8JqiR/1uLJkoJxJcxmemUk+hAWhCC3o5LWprU09xXjdS/K3aUoUSkzQTk5q+5vAnfdna8N5hKDM+7IesYODXy1yUn8OSqpdH23MENvHlNTqXquNDA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706841500; c=relaxed/simple; bh=zJdidQYa9AADNngsqGQ0JLKnlpMwCBGS7dyutvjzjvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C3GyrIS4HrUa9psnau4xCVTyuEr7TsefQI5DF7DQ2+GH56pIlfNxgf1buCpk5EZhjjHW0XnbdNEfiEIiEhhE86kwDBmUMyY3cHJTETWSqqpd7lQV0m1bcsl0+NaESa2Nj5+YMvgi3MKs9G9OVohsaZJpn5eXc4MFfdU9qhpzayE= 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=S6pxuRMZ; arc=none smtp.client-ip=209.85.215.181 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="S6pxuRMZ" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5ca29c131ebso1443854a12.0 for ; Thu, 01 Feb 2024 18:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706841497; x=1707446297; 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=ROyTVP+CZ1AMHXlRGWi4pRwAXiD8TK9McQ610tQyilc=; b=S6pxuRMZ5IDX4rAo0Ilffdql228PwCI9Ns/q80M/TiiI9n8yRoUN7VcWw/TJ+xzOz9 2nkuOBnUpzn+bgchoFNVhatBgvTWwQ+aL6tX6+8ogYiYf4OMXd8oYx0kzFzCNHZESeuy EKhp7sHJlHnqEfaVxZNl7TtXNaomMAr1CAK9FkyY4PLYBVwFwSXvAY9ifriZ2PLKnv+f nunPS6a3nugEgTqAakq1dzkLpBKhbfi60ODlt8/enqQU81cleNh3Jtrlk0P2efA5OxsJ khO1UXcSMif+HV0x/rnhAqlVsIBLQ/vqlf/HbfwIpy5ilC8KGFe5c9wEQMol5hQTuTzt 6hUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706841497; x=1707446297; 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=ROyTVP+CZ1AMHXlRGWi4pRwAXiD8TK9McQ610tQyilc=; b=wu0KYFi8wjsCcxLfZRqnodA5gfQ66fXsXrJzIXT1Nxbl0nvRXuA2ifTNwtRTMDAtt5 QbLovLdNv0sTXxLpx6/d89n6TciH5w5bnkyJAS8uIgLSMdNPf9f+3ANNozc8eSFLoDEW +/rjbRVG5Pm1NULHK9tQSG72P4NdsrDlGt3+6iz9wh3OF4EdOULI7GyNUZe0YfQ7JjCl d0MG5QetcaHglCVPWQb5hHa1sDY+w850LDS2/4AmHtGCadu0kGhVC9J+zksuISopla0j GPLIDu97f6kIMsArFXNYqshFEGXpfnAEdoGLvD6V4qvc+Anu6FPuea++PoD1vODKhu5F mhRg== X-Gm-Message-State: AOJu0Yw6Uv+Uc0eNOtzC7WQJdfVbLsKO2/Q0AOrNcdjXmBGi6UzpUoga P8eLJTDcFKr+6ZiF9/VFr8nk893RRK+/zPJt2uTwY7QxZI+sO8A878ky6tBVy7hgU0Qs X-Google-Smtp-Source: AGHT+IHkQftHAKYoArCyRZg2tukcE6eb0938Dqw9g8iKnvd0U8lpvp9PIzrCGcMebzk5AuEDUS5T4g== X-Received: by 2002:a05:6a21:629:b0:19c:1881:b4fa with SMTP id ll41-20020a056a21062900b0019c1881b4famr641835pzb.33.1706841497492; Thu, 01 Feb 2024 18:38:17 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVLD8LCviu/8y9F6jMb2hhVA2ZquDwZTo8ZPx9oM7vyccxnqzmTrZwgwgmY8omnebUKqyrh9WXnc6JJFEdfv+VPaBVjKR1uRmPrgOjbO7snLZ6p50x9cOKciUOWLaRkNmdXRHKtOZXaCMHhij8+pR13oWpVKzWSscQi0ddCc1lcvXjpiK/dOxPfT1rxSGuM+A165eWL5kLn+WzuYD0kUt4r9Sq+dCHG2w+5R880iGcdxaW9Z1ZKb3UuZWi0AbeXO382xg== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ji19-20020a170903325300b001d944b3c5f1sm493256plb.178.2024.02.01.18.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 18:38:16 -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: [PATCHv3 net-next 4/4] selftests: bonding: use slowwait instead of hard code sleep Date: Fri, 2 Feb 2024 10:37:54 +0800 Message-ID: <20240202023754.932930-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202023754.932930-1-liuhangbin@gmail.com> References: <20240202023754.932930-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..78d3e0fe6604 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 0eb7edfb584c..195ef83cfbf1 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 dbdd736a41d3..bf9bcd1b5ec0 100644 --- a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh +++ b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh @@ -107,13 +107,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" @@ -159,7 +158,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 @@ -169,7 +168,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"