From patchwork Sun Feb 4 08:51:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13544572 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 F30B114A84 for ; Sun, 4 Feb 2024 08:51:44 +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=1707036706; cv=none; b=Vs7KJqXsCI2M4CKrmUQZVi+nnhfHwd/yFCPo9ZvKwPMbfdx8XEIcnNR3uygjuI7XlTWsL/EszzLLw9t1CxxFv8evlMFq5VH4fp2jOe2v12G1TD3ak1huprYh1e6lKDK98kW25MdUnqq223hyZYLn38EGPa5WoObFrdRdPU5/wRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036706; c=relaxed/simple; bh=KDU5Sap9KmERo+IOTSOxwD/wM01vjxr94Mz5wDzVw8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e6q+eGx2jH2ixg8OA/mCT73MSnUY4Viz4pgZimzq0kafGytFgz+vxVCpWUGPckSz6cpFWqs2E4jGwYVomTLmi22f/oYrBFJgrdkaQNOdIZnPCoAqRbUtN3XjIL3CZq1sIq348TjEKGfbIg+ViTXYhuLh9g9MaSwGPqNxbWwrNIo= 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=J0MoUBAp; 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="J0MoUBAp" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5ce942efda5so2989745a12.2 for ; Sun, 04 Feb 2024 00:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707036703; x=1707641503; 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=J0MoUBApKW2mNnC1Z3AIL2iEQFgSjOowIpRhs4kxqxRAOk9ITzf9EBUqt0tGIL07Y9 X7XGn+mhivnnzk29Q+Zy93Ll7vjCKo4rBjPG7QoXmzTAsmjvsglhkwoJ3RcYizYuac8t qZd8NR56g2GvRUBYInRlfXnsqcL9syZdHtAMi8N7UdIEIr9lhIRvpvUu/4c5hykm6ppw W6SqVB/chpdEIVZIIg3QU2Sl4lL0kUQHmkthyRJGCzQCZh0sQuB4xV4aLbO6hIABhBBz 3JHBnU9aZRWUzQ5a+AHmGJwMn/HeAnUoAqKkNVndUzyeIZ9sM6xitlxGSB9lsJrra1fp qMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707036703; x=1707641503; 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=PyGTSJE75qqFPFmYZL0Nq9vefX2Tgq9u7Xl4CN1iP+3iodEkQ4mndBH0tRNIMS1w2q UTS2q04wZszQ8qGGb7XxWZBRQ6uaxrCF10G7skPSIYPo2y5MsmDXSR8lPJr1D/RJF/rG m/o9DEbA3RA/1Vldi3Fy8VHvb7xpuS3+bPxgDbBmac8X+8txK1zgi+1gMqyrrMyuibsk aBBznX80IanE9mzoMbvg3mu4FgS4DT25HUUo/o5qrHA/RnDPo9zqbVuJ9Na7VdcB1yb5 6xH59yLxOVp80Yo3Iq0mlFXKBnD4MVbFW2Ga2mXTqQ7XJvfDtQR9BUK8oqo70jub2nYZ ChIw== X-Gm-Message-State: AOJu0Yztdr9aQanrtVLxYvhTRU+Tw8k45Dij7pEP8Qfq0tRj721hiXM/ YsQW7XBUtJMS09E0G30HcB0kZ8E229m6L2CnvtbOiMs6teBwRnbiS0uzukn4QBYAMA== X-Google-Smtp-Source: AGHT+IG6i24AD1txlGWx6h1I5GekDlSUfWp5Vqr5uBRu+/O8nyZwOM7Vfk3pB6ZytpKDg3aUp8JtKA== X-Received: by 2002:a05:6a20:9592:b0:19e:4790:25dc with SMTP id iu18-20020a056a20959200b0019e479025dcmr11588978pzb.60.1707036703563; Sun, 04 Feb 2024 00:51:43 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVSVB6hbczM3xkr1lx8CMvgDeBsaxgJBf3YOBMwj2MU3gntq19PWR7sb7mWHtXopJhBqhMqWvnWO1PObtsz3jltSiqANm+VnRHOQOsr7C3llstTD7C5uiAjuxtDu2h3GSe99QMAuBmF6Qupcumi2OTCGKigb66YfLtt1vEuLrUE/pkgVLPVlD46vgUTWVB9bCdf5dfcjW5h8ZGMS7MDAtK0oBr6WSDLuM8KmwgBb0IY0AA3LRn89OEpJbTkw2nKROkaHA== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ka39-20020a056a0093a700b006d9b2694b0csm4398228pfb.200.2024.02.04.00.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 00:51:43 -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: [PATCHv4 net-next 1/4] selftests/net/forwarding: add slowwait functions Date: Sun, 4 Feb 2024 16:51:25 +0800 Message-ID: <20240204085128.1512341-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204085128.1512341-1-liuhangbin@gmail.com> References: <20240204085128.1512341-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 Sun Feb 4 08:51:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13544573 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.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 B751216423 for ; Sun, 4 Feb 2024 08:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036710; cv=none; b=uU+AlMyl6xTDERl3cvjI9MhPrGaHUeORrvpI9avYbgRvKt42bfnkYyTpjI4lMgvGcqoIgUXLpKNlH7XQRzwlT+ksWAhIuDNdVD4QjjilpBVjGBBJQTa5jzs3lmR8ypv2rQ6fb5z2ob1ctNceygfFAhFGMN4+uheHMUjneIzO2gE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036710; c=relaxed/simple; bh=9sCZCUTM9/Bv/osCyDQdlDwrCLiHF/EY3ax+mpZSXpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ukbq2WlLupBLlTBbcSIZ8HZkE2fnCiuE/ny4hrvfUCCxO8mRzw43EG8ekGlq8Ulnd+MS69nrZaABXz6DYWe+3ciLT7Sf06oDHcOUyhDqRdlzETzz0P4QJ/v3WksPWpY4PdzN+ur6T5o8dAnTLtB36uVhrvx34TxYBf5KNW3s0T8= 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=C8IVJIdT; arc=none smtp.client-ip=209.85.215.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="C8IVJIdT" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so3430102a12.1 for ; Sun, 04 Feb 2024 00:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707036707; x=1707641507; 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=C8IVJIdTvuX32cbUguIj28jiK15Wqc+rPAqv7r8AvxpMhaPgN5db504yMe+/Wt9DUB lbLi+68/2lx0k1mex0RKr9NRVj7gfjjQVlxLHzyv2fXMTSsCCTyHRuV9BRakHVwIpqcv zJs/3zK3dyYIV4J5GY9acGtrLGJXmhUWUS6vNyZ/Vh6JDos/P2+Hll9+CXQNhaakFUcN Rzj1ve69J2ngmgAfzcrUexPO1sFPgEaipqJI6UEI948ae2FKf0l6y0HBH2BdRx0D3BWY /8Ds2WQFPWc6DjevG/OKkiMd9aWhVnBht9Gg+AZGv/0kFof6b+ZfEwSVV9I7m28eIhDL Dd+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707036707; x=1707641507; 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=hSfIyKDWW9Jxm5B8THzem1eaUD1MwpDD1BdOu+xqh6RStL6AWu4imjdJKag3LxUK1y bNYIsDmqYAIe7hAYtSzqivRCGYFV2vpEjP+mOR2mzjuxu2npkvcjrubY0fiv1m7OElTo GUWBSKQzeS8NhLTFoyJaetDJwI6Mo2u0T52aChTp5kxjDniiS3wRTYS1zIDNO2nlleVU lrmVB83uoxyrG4QBzguZiPpm6xuXx/1DlBWbDxDE5sLCT+ksf0yizoCphVzrY7hRrlJD AHY1OyiOuT7GufAFB8J5yNSQE+6sbKsZkAKkwaub8DSh3BXBtus/aoO00E8rBoBj+aTO kUjg== X-Gm-Message-State: AOJu0YyO21uAHs8jP6KdijyNANiwMn0vtoA05zABKkNM3UHgnugwy3p7 JiXwQz6uMMFlKDqwWVnbrdszt8enbpYONNlpM+xg8w4l258C6+NkE8g9dRDafzLa7g== X-Google-Smtp-Source: AGHT+IEbd9UCtz8uG6GISMpSjgofEG1rEr87ZMY7E0d5j2hbWN5TGyIRWK2/vVcJmNUlLSQvN/OKnQ== X-Received: by 2002:a05:6a20:ba7:b0:19c:9abb:8a64 with SMTP id i39-20020a056a200ba700b0019c9abb8a64mr6276566pzh.24.1707036707307; Sun, 04 Feb 2024 00:51:47 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW6T9Ag2cwoFWdQfoC6G9f1alkmlyy4exsLzkly2uQrvr17xF1XIlMtcMnU7RNAJnx4vTWmkOvGfrwMVm8p9DDF1VDQTfbVye88FtLN2QV4LbQJ0KNuwgz2wWL1Nvo3HTubJ3DX66dESKcf1Mj8zE4NKf8C/+eneA8iX5uMwzIrW/wyfPm6hN6y4PH3ZjSFkXx1s/Hya7IGRPi8BOZfFxvXoV8JSGceFtL/Mp2Dew0dZL7Sz/6BW/nYPtGad0d+h5FGSQ== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ka39-20020a056a0093a700b006d9b2694b0csm4398228pfb.200.2024.02.04.00.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 00:51:46 -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: [PATCHv4 net-next 2/4] selftests: bonding: use tc filter to check if LACP was sent Date: Sun, 4 Feb 2024 16:51:26 +0800 Message-ID: <20240204085128.1512341-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204085128.1512341-1-liuhangbin@gmail.com> References: <20240204085128.1512341-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 Sun Feb 4 08:51:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13544574 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 B051716423 for ; Sun, 4 Feb 2024 08:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036713; cv=none; b=aU75mKLp/soYIcoN2NVIAexT4fIJbTOchJbtGPibAOavs8H7dP2taTP6JOwJaUuFSO/71606/TAKOIPu998ZpwoYJ1RFCLPFTGLovzNjhmYvHylSrNKQNW9SyL7KMKRs36cPFD/LbuQmdWu6DCjTsjz0Gb1t284GNlWkxAjfEWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036713; c=relaxed/simple; bh=G/Ux3LgDRNAQg7rjHZrbyybShnGgVnE/dh5wJIEOlQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N1mnlTFLRbCM3TqtKaAXVVn1/mVUIiwdw0C21Cl+amkhSBtIvPeyE3uc+lqZO2BD5J+E1oAIFU+l5v4ttL+5Ash7iWUuUiDKNWO8O74lzs812g82t9/TaszjWqpVcWaNX+/8plzK0phdSoAvMF76DXkc5ohPyzawpKuO56s98BE= 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=Nn10GycV; arc=none smtp.client-ip=209.85.215.175 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="Nn10GycV" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5d8b276979aso2660929a12.2 for ; Sun, 04 Feb 2024 00:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707036710; x=1707641510; 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=Nn10GycVfvEFfWXONyRdvh2J2BGsle2ZnM2NbUagR4qTgFYiLxyDRFlgJp3X/yYgPi gBZpPZKQEO6WQdm7lnZXAJ/NfEs/oV8+RfarLYIzT2ymV73s1olKh/0AhLiMK4rc3r59 9/5L6fcyLtSaHPohG3jqb3d+y1aTp4cc8h670NHVB/fk7gQgnAs79hUige1rdmzQrsYk wUnjDqiUx3LyCLVHfd3aYog84Y+pIb0KrZMd2PJKsXlqQe21i8D3SnoP4tnfrLgIPc9D 4T4GrRKdZQrCZaI6zVjyrf2AGI4YkDOfXAGrQ5WFsHozNTzVCqVqR2I0RD1GGEXiKHFz +5hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707036710; x=1707641510; 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=V9vserSbbzs/aFPz1YSKZh+oBtn31S8FWV8TuqNbL0qZpFGg21HrqKbwkB1GAtNO1I lyYotLtWcbA/hnPAW8Mn5j/YNeyBD8ZyTpfr9/xt3AZ38We3jVGga0S3pcYul0LB5rhN uy01qvuF/zC1Jf2Pq4u316Ch7g3UTcJG1xfR1MCvVPZQRBZzo+1zV43HN9S8IAJL5eXX aq/4CFx9GchI20xiPqF/h3uWK63b1lMdIYEoZC9rnqCjN/vMDWz6nEJOgH7AojGiHeaA RYgi4mLghS8Ic6CVY8mS82MaQEGPnS8Kfs/kuX8ke7pvseNZegqbqjfwrD6hjsLmC0it fqRA== X-Gm-Message-State: AOJu0Yw/2C1FDCl9fCYY2pvyfrm6ketHoBzhfSdUKhkipl0JJ1ELxwZH cZOURnYiI32AbSRytXwH+kbflxAMCA3wM0b83numnYWwW503KS997b8Au+yzjTVxrA== X-Google-Smtp-Source: AGHT+IGRc3ckvtDkjv5AHx76IcEaX1ITPJ6j9xvZ/q5KTGY+O8VWlp8hKFk45bzWoe1QhArOpOxVrw== X-Received: by 2002:aa7:8592:0:b0:6e0:329b:9d4d with SMTP id w18-20020aa78592000000b006e0329b9d4dmr1487521pfn.26.1707036710333; Sun, 04 Feb 2024 00:51:50 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU2Hr/I1h+wwhDj/ZemqQtBzVBq1NeyPcM1+XR4t21mugMcjOVhicoKYCfi238jHlVeX8Gtvsd9ht34eOjbmRjjGH52+959DDPimkIRswOUYm/a2tlboYuIDiLA4CJhcE/L2hlEYS/EYHh7aymyK1NE8egBT519GgpwzA+nx4vRYR6cmbJuvC86iL4lcPZMpePN5tiJNrhqFf9TOsNwbZP3i4/8gVcRpw+WZ+AEEgGLE6X5mR2d8WXiCusbK8kxM0CLCg== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ka39-20020a056a0093a700b006d9b2694b0csm4398228pfb.200.2024.02.04.00.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 00:51:49 -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: [PATCHv4 net-next 3/4] selftests: bonding: reduce garp_test/arp_validate test time Date: Sun, 4 Feb 2024 16:51:27 +0800 Message-ID: <20240204085128.1512341-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204085128.1512341-1-liuhangbin@gmail.com> References: <20240204085128.1512341-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 Sun Feb 4 08:51:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13544575 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 31EF916423 for ; Sun, 4 Feb 2024 08:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036717; cv=none; b=DItzAXUrqpicZLX/ZthTiyZAPizb3arnS5mt6wq8Liq8k7Qbr+chd4N5lX5PiQ5oPDW+MmRx87rttLSpyc+kQsqAgksglRjW04xw9DPIo2pcwWgNskVPIBy+WJsQtCoGnbkIur+J2PBxBdZQDE7lgS66W2lNvoJeOsuc5aiCXtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707036717; c=relaxed/simple; bh=desnL+jA/Zr0KABIxn8iFjcjyqDkqg+s1fSbN3LQKxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BFp7WvjwSTYlrR0m5sRR5A2zz3/WWNsdCgP0+baKYsDxt843KV0ABtgxJiyDDvlt75bHPE0C1JTiIb2DyotJ1kEFbSkAgMaoD2DJegETSYaW7UwpS/3IRCWAUdCLJZcacVYQwDUkhKVeEkmMvjcW/4hgkUu5F8CbGrS+bPI1mi4= 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=c48yWX+w; arc=none smtp.client-ip=209.85.210.182 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="c48yWX+w" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ddb1115e82so2045965b3a.0 for ; Sun, 04 Feb 2024 00:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707036714; x=1707641514; 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=aPKB/+68qoHi0zib82miR5yf7x2+T7pG1dARh5KvH2A=; b=c48yWX+wxsRDL6Vx25EKbGmB9UyMS3SwnWFAuEiscNXoXBniVxODVOAc4k1p1r/c6c xVIyqrMIbcoi0as2XYrVvKYbHboJNvKhsbPfl6oe0bYm/ztVL5ArSCg2lPdxjksdwYx1 8qB4ukDtO9xaOycyizI1rn+ZdybsGBxxn2/u9kvUV4eCgjnKO/DHAgYIiyzl3/hR4F6v cxi8p0wfDmUBSIPd61rAAi0DLoLQU7Q3HrOIZh5GdcP0TMtQvZ6S0fEto+M0cyKduYzC Ku5Np1lIMm3hlYlfU7tc4P2cdTvkg+nJ9UjXPgwuLD7j5w8lMerYFEqsYELm6QrhIMhv slYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707036714; x=1707641514; 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=aPKB/+68qoHi0zib82miR5yf7x2+T7pG1dARh5KvH2A=; b=TV1UTdmcSbGEHL/oJCrnSpm7hwFNdoS4frTYVv/XI2JXwQlSYU2QwNwvhWEd3kmtMx baZT9jW1GPxJNu4KTDZGSNjX1PyRV8nZNrNEyqwUsPUs4h2hVbgftK/LAz8p90a7GRrc k3sJX5M+uhC/sdBmSOOHz42nBmVaO3u2Q0S08AkzdtbAyX5izURbqHS7x35JrWhfhuw6 k9NYuZnW+E/SnnYr9iLePb3xA/Vanp+06efamWcWVJWcWDitz0iQvDVKQoUi6LlUzlT2 iP8t0fm5+NQjiLvE9l/c2yly6wktSjaoVe6PgarPjSdYVjd8jOibCvsc0GlpYLBuWX+x Z17A== X-Gm-Message-State: AOJu0Yzty/UnU5CSY3zXQ8qlCRH91jeo6vCsyqeYsHKpLr+D12rRKv0y 16eOssBoJUR0JLPTmmS2gHega25I1y71L4DGM6z6W0mSYoYuVuT3SeXdtKCbPvGErw== X-Google-Smtp-Source: AGHT+IEpi+b7oMuN1SDtHtcPS1Hg8T8Y2suW6ZAIpSEdxdAqRiWNxuRYm/CSAV49F2ocwgjwPZzeaQ== X-Received: by 2002:a05:6a00:9391:b0:6df:e463:5ff6 with SMTP id ka17-20020a056a00939100b006dfe4635ff6mr11865262pfb.30.1707036713818; Sun, 04 Feb 2024 00:51:53 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX2+5KT/VWxIo4OUwVSg6/sfn3wkBEC0GjbYJ21LJQhUCgVSUAjx9qyoRNeMWAy4/dX+UeFPi2hs9KHhZPLWuRnqZIR06/V5ZP8iWurZfqmjMQUWgXpc68BTqsaFnMWUe7aXHmCJ/lrUed2eBviqcPQV+fMUWVKwOtXaBSmfKVPMuwfUKUlh8m2gWT5r8X1odinocuw88OPCdSA9VhGtIikP0wmU+Yr9L2xvZ0Q4TKGBMt04pqQG0uVlsU/0epO8Bd9fw== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id ka39-20020a056a0093a700b006d9b2694b0csm4398228pfb.200.2024.02.04.00.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 00:51:53 -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: [PATCHv4 net-next 4/4] selftests: bonding: use slowwait instead of hard code sleep Date: Sun, 4 Feb 2024 16:51:28 +0800 Message-ID: <20240204085128.1512341-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204085128.1512341-1-liuhangbin@gmail.com> References: <20240204085128.1512341-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..77969824a3bf 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 5 ip netns exec ${c_ns} ping6 ${m2_ip6} -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 ${m2_ns} ping6 ${c_ip6} -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"