From patchwork Mon Feb 5 13:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13545554 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 6FFD61C683 for ; Mon, 5 Feb 2024 13:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138065; cv=none; b=flVNzc3OyySY+M4NqUm/Ur7X6eZu/N66BzVFEeSrhwoD3rtSoaL/qg+MgjGiElY9uqLXUYmIkstLzngCmAR+8eiff67paMRJoQAjx8CCnKN9chdxs5EbmgfWlOoyu+75czH7Zv6bnJlFzTXYg6VrbJ3sfblySWlVAJGNontB8QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138065; c=relaxed/simple; bh=KDU5Sap9KmERo+IOTSOxwD/wM01vjxr94Mz5wDzVw8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DggmvMl+RKmQmlIt9/av1i1LDhBtphNNjgXiOg8MbzdxDIh+0IKWEY83u7P4wjoyOECTPJ7AoTy8YR1Ee2S1hnPk6qcBD92Aak8kwJKvDTkQgJcfQgbV8aae8yssSk2rYNXuJgW0WNBz0DNkMm2LFhSSS19xMtOl7fzrmsLIq2w= 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=DOpXhKkA; arc=none smtp.client-ip=209.85.214.172 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="DOpXhKkA" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d93ddd76adso31176055ad.2 for ; Mon, 05 Feb 2024 05:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138063; x=1707742863; 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=DOpXhKkAU+4zmVvIZhSlA5LiaPLm9ru5YqgvQ1o4cNlRRgM6RonUWEsQ1koo2hDx4q Kug2qoh8cp0V83QxpalcCzL7cuBdt7Qe3GaZnYmMnyP28KKosiFBhXDqy5I+r1mM6uol 4gC8tWk4+9ZuYBH6/VKo95+UNRsdaD0u6k7sc71dOV+TYlYnqPgt29d6/hiNOg8dxpA+ wJgFo+rqmIT8DkuI7Qcz2o2Is5M2RLodbrtxB4OAbfEBwy40RMcafN85lSdNEE5jHRg+ HwQx+8yX2YP6WkU+l2dEQZ0S+0olYDwbdaXKqP7NlWMZrffSspfCwYgCwG5wL9iVSGxK usdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138063; x=1707742863; 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=n2aXKgo4JkID1ylIBmuts2ZAImthZdyJK5NmaBn0gTqbTTC+xOgi89N2S7smb7N/4G HWQtNheKxW1gr2f+6dMm+JCu3sA3tOcLPs2sPdX2CCc77COQvjajKeQdcDALb0G7VwG1 nH+9sxoPnN3LG/4kVyZA8iN+Wd3PwuHH8H0svApAtuhnntoUnNX8RUrcwBY0TioN4I2A Z1qA2fXytYVDtCO9rg+5OSJo7/3jlIO+0Zw1ObsqUR2OQtcbjQ9lyOvrjOHs8cDwHV+4 e42YqS3iBOK00Fq36Rwyk934VdUkA+h9oFRll+h8rSijoEjpXILZm8Zmo5mw6uP/0fkd 24ow== X-Gm-Message-State: AOJu0YzJNUPz9V1T/ybTKHqNbx75wUWEsXwh5sa8zGf72XhVL3V4vRUy yzcMSTSjwm1SKZgg0okCFdoibSDdvwI2dZKWgBDYhmXcHyQcrNrA8vnhBr0W+Jaf4A== X-Google-Smtp-Source: AGHT+IHemZ/xNPaJGIfO0LBOVGKdhEA4RoMUBYfbaMX5P/fl+2bU+TlQYwtXODZatLs47tnVzKlbVA== X-Received: by 2002:a17:902:6b8a:b0:1d6:fcc3:c98f with SMTP id p10-20020a1709026b8a00b001d6fcc3c98fmr12916232plk.29.1707138062832; Mon, 05 Feb 2024 05:01:02 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWGI8zVljFEqkgfF8qM/Mzu1KIkE8rRyG6jsxEwWhPQq/Q1LnjLwIr5c0D7PKRZzr74CfH42XTIea+n7DzKS+j+hNEt85nxv9kQiquxmo4Mf0pHocl4Igcci82yRAyyPpgO5pYW/Z6jBkc+maCiZ2hmZPI8dNpQOZKmcMVpwI00ih+N3lRlphyk9NjwvGSz7sbWTqM59Uxw358DaC5F81qFAhbJ6l2phvGBayvPBnjrFEBZ1wGlfI6xCoK+DIuoZd091g== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b001d9351f63d4sm6252159plh.68.2024.02.05.05.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:01:02 -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: [PATCHv5 net-next 1/4] selftests/net/forwarding: add slowwait functions Date: Mon, 5 Feb 2024 21:00:45 +0800 Message-ID: <20240205130048.282087-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240205130048.282087-1-liuhangbin@gmail.com> References: <20240205130048.282087-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 Mon Feb 5 13:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13545555 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 21F371C683 for ; Mon, 5 Feb 2024 13:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138068; cv=none; b=hOc8yPr1mzmS5IOciVDABFISjTSeBVG3X3FkFvXCUuo9QK4PX8M5azCBum1DpchyIwZn9YQjFs+JrvLTQaCKnfDpwCyb0IA9iGq3X3kdER/16ylSOuEcYfrZbBI/UP8dsnDUAIuEwS4UeFU2rbkNEgZ+7Uw1aQXmQoEUWAb1eQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138068; c=relaxed/simple; bh=9sCZCUTM9/Bv/osCyDQdlDwrCLiHF/EY3ax+mpZSXpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kpuro9ka+/4XTOUmMegzjfa7O4NLu1ijMI99pwStDYUUVz51hhEELhCB/RtUXzFMlCI99sahpuHjrYfYNUWV/mR1su6Zko23sZEkhE2C78JsE2pv8HYqbN3+oOvU2lHimbJIDSv1+bOz5ca4Ug6GBEbcNHijQQKudYrcFWWbjWs= 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=Xdkc1RCX; arc=none smtp.client-ip=209.85.214.170 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="Xdkc1RCX" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d51ba18e1bso39633515ad.0 for ; Mon, 05 Feb 2024 05:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138066; x=1707742866; 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=Xdkc1RCX3GKdAxGh3OgXLI0FarCIPqftzKNDjeKGaDLrXmmWjGeRR/g0O/6E1e5DXC LQF84uxdxpPIzMDeYGRc8ZHyNhyYxSGj7OdvTgKFZoGSW7chenyQ73OFP2UiZIkOmtCz hGkglNiKA2K7L4Y7jAZf7gr8j4n9Mmvc6Bio6LDinavL3XZ53NKKYLhmewuxyyf+kRHx ZHxZECFL+SIZQYm9PaX+426+gDnFz+wCn46DdsWH+q72D8gJiqSL7FO0ifPxYDuB2a8g aEnVm9oj5DBsuvy6MbEmLoy/eA+RbBIyzIaH3Xp+HFMKhsjtHR+pueDrTPFN5iI5+LHz PnYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138066; x=1707742866; 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=N9WAoeF3BqxlvYBQzJnAFF9iHyAfWeaFW76b+kIhLV0Cpr4Jup04GUv/PXXSXkkvKd h2OQCfMotQNGBi89tG23R8rpdIKNETLXZ9qs7fTEHeir64rxHsn52TIF4Bbfh5tQZzZu aba/fGw5cLuwzgnYV7N5q5pWaszhREnOzXhni6Swv9T9XMP6E1Xvmv4zuVkuA+xldp5x mxH7Du+fBbSaGtaLOM+lKwMCBY7vcKc55IKW6guphKbO3GYbk50rm3nTDNZuJPRyTSVN eQ8oEUYrIRiNOzfOqYDpJEShHw41QjGbNDSIiXdCJDiK+bp29vKiNqS3zb+tKfO2Ekf3 JC4w== X-Gm-Message-State: AOJu0YyawgNLqjwn7qmthHVW8k/zOrkhsrvq4NvhCACtOHsAq8jhggvN RI25x07Lgnm/ZlTEWhRN1OaKPxLP5oDYGsdIRbct4pnBIgimC+MqTbZUF5HBbOD88Q== X-Google-Smtp-Source: AGHT+IHfss23bNnQLsGjdQKo+zNLgfCMyUPheqf4XSG+s6U3LEX5XsYYwdI61PrpcNm71kkHJsayNw== X-Received: by 2002:a17:903:124b:b0:1d9:14fb:d142 with SMTP id u11-20020a170903124b00b001d914fbd142mr13795602plh.32.1707138065674; Mon, 05 Feb 2024 05:01:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV6AIpq/8Ug/iHKPpKN5AxOVKr3FelNHKdOGu63FeG618VJgACzczkmLUa++YQa+2Na1sroWVY+lQf2olG2zfvR12yrauC9r7JWw1F9ytSo8TFHEGPkxl9AIH7ANTeL6+MnRSfjTmH6NsbkYMr8QhTHT1W7CTTfG/oxUbw/NsO9opFAdxanjwXZBM3mUfNwGWjinAUxyWVT/3Z9owQms1snembUGXVBnQSS9K7OI6iNy638o5cp/k1K6eZk6bsAYyR4kw== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b001d9351f63d4sm6252159plh.68.2024.02.05.05.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:01:05 -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: [PATCHv5 net-next 2/4] selftests: bonding: use tc filter to check if LACP was sent Date: Mon, 5 Feb 2024 21:00:46 +0800 Message-ID: <20240205130048.282087-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240205130048.282087-1-liuhangbin@gmail.com> References: <20240205130048.282087-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 Mon Feb 5 13:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13545556 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 024B11CD15 for ; Mon, 5 Feb 2024 13:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138071; cv=none; b=XycIybHMkY10DymcH1gNNQTIVEq9vkb2YBOVTFS548QijOCyp5yVCQ1+UgNEGtQgb/ZiSYmFEkJPYZak4n9R+4MqUjGBVuUfq5J9jUZi5tYT89BSOg00kTbsOd6f6oukXpqn9F0RT2yWhscPktoMlUoEkPFuAXp7tjwh6ScwaeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138071; c=relaxed/simple; bh=G/Ux3LgDRNAQg7rjHZrbyybShnGgVnE/dh5wJIEOlQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IXpWc2IKX18reiRtJccmbLtJJn5trnBZ0ybKavCM1v7ZDdm7DTS0RM7kMM2udD6Df8x7bcUouYmh9LiAfYRG2peZiG5zjPYAV8Sj/Y0Y/q+H2NNU0h2mXEa64r9BW6tH/wJ3qCHqV1rMCf4MCcmZQ4FLHEfyBE5ubY6ARhrwYsg= 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=fqGdViYn; arc=none smtp.client-ip=209.85.214.169 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="fqGdViYn" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d51ba18e1bso39633945ad.0 for ; Mon, 05 Feb 2024 05:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138069; x=1707742869; 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=fqGdViYn4gu6mJFLfc+mvujwloV9bYQK58hLMbMgTVK0wH6SDOaORPAJ7kwMPUtqpI Cye1YgOlgw2Zlzdg4zEEmmcyDcoHj4hUPGZuHk2/PqpWcYnxvjTTKPMiIzQO6G5piUce d2dBnRLTtSPtn/WIB7eyVRbzWnmsI5tR6LvcQ6LoKNt4KYJth4wrIPsOf2ikFb5N0JTa YcoeC/OIrgxlSgy5XjWLz5r3FQIg0T6wSvWRdS15yTFoPMQQCv0DujNF3+60ZrqwPq33 X8tAprmTZDQ48QLZoOBCtq3kfC7b+h5WA9SfkF82+EMy9LT4orlRDnFMbT9MEnZ+e4sv lESw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138069; x=1707742869; 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=R3JnyvJH3VYK6lRh5fp7wDgQvQCihYBZ7xfepH40wGruSfIGYA8g2I9rr2blITPA3X n+q497xMW64RChd7Japic6JNTC7/tqjpsjok4HXUvJQPgowmlz3y9J3MlbwvvFGYlIrx 9I3iTnSQWzHVirTJq3hKbUhVUkN1rdA8LSJOwTecuezxmv6xEOzpGQvzBQ75bB3OQkgv SXJI77Cxxt7xvGeLAcFPVGr2zPBM2nuchf1cOJ3SpDeQRt+9HorQwQ/7jrIPgGORPUO6 D/RX5eHYRC3L1FPpsePQe6N8vrOmfYEJlxPPbLXkrJEgBqWXfSIXNKFRF+DHGQKgvsV+ VOHg== X-Gm-Message-State: AOJu0YzlCfR1aanr12FKhbRkHsh/Bf2McLwIU6eK6uuZmkkwhQ4OjiUt HsNEbcklGR0Nlnf+6g5DveJzJOWMGbyPz2FYTl7VBj+D0MT3c/6gUKm6HLiK49LDXg== X-Google-Smtp-Source: AGHT+IE+VyLmNIQmO75C0Vf0ErzK27+tJ51eOYgQDihw7LgT3nucdEv11kv0je2hrSEBIgEUfTrtkA== X-Received: by 2002:a17:903:2281:b0:1d9:b9da:ea8f with SMTP id b1-20020a170903228100b001d9b9daea8fmr3050899plh.2.1707138068528; Mon, 05 Feb 2024 05:01:08 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXlAr6uDNkxCyR7d0qr3wyNhNJ05FPxGfHT671eQJOiKztF6LMzKu4QfKpaHDjkYBeBW1wKktgkBrDFn/Yn4tzwAY5NmbGs+ptDKATSIIT0lMV/Zk9FqPhNhwU55Azk87FI3sdDE0dP/XPa4K+UEzl54aQ03WzrB17Pr27yQ9JPW2u3I5EXVObX0GcThXpzZ1tBozJNaL/EmVPa05nwDKPRf7Kfw8LKBMEdWD4Ufdy//08jxHa2KsxkDUBYOuDjVU9BIA== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b001d9351f63d4sm6252159plh.68.2024.02.05.05.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:01: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: [PATCHv5 net-next 3/4] selftests: bonding: reduce garp_test/arp_validate test time Date: Mon, 5 Feb 2024 21:00:47 +0800 Message-ID: <20240205130048.282087-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240205130048.282087-1-liuhangbin@gmail.com> References: <20240205130048.282087-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 Mon Feb 5 13:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13545557 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 C195020DC9 for ; Mon, 5 Feb 2024 13:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138074; cv=none; b=uxMPO/mNiy1ohP3Q9xDd1He/NJXfyKDEiVtknLehBMCONCkK8hrDwc+gamky/f9lyV8bMZH3g3wcAe3Lmw0GaYWDd4A5sffXEUCKn7Dz3VdR8mh5GYszn6/Rr1mq/aBTjRBs5EOXvlyHLN7uWTQLkw96SySH7rsGGSamFDUqWXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707138074; c=relaxed/simple; bh=o5YNneojXPnW87CVFXi1KGJB75d0sDWlMEQyGyaKEmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AY0MV/Yluwe5SlYwcJYbkBnIewtuJfcN5hJdDgvIMeqjIZO2KgbsRgOrY3qzC8EluXG0vZ2a/g5ZZRJpOmh+OWjdmAbl++a5CrMEYM5AMrwDeXuY6nZDtSnCO6fGimBJ6CjfYEEmUx4iqruX5xP+d5XzyzTDjqUrkJPsEI/XjtY= 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=HSC9vVIs; arc=none smtp.client-ip=209.85.214.169 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="HSC9vVIs" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d73066880eso37842365ad.3 for ; Mon, 05 Feb 2024 05:01:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707138071; x=1707742871; 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=4BsYS0JII2wqPsBRvjpRVtvAleGVUHvck6gX20GtRuQ=; b=HSC9vVIsJQVIqWlZy3qdWIKfVsB0dTK+D9cNDAAfiWflVMwRpa2AvtjSMJv/RHsl2y jPZFEljaIvAysbJl4lTahbluOPONMbuTPFSlYT+nn0BXPDpHkdpdKwPGhAe9kSXVdHh8 IFkxRGckYbWejD+5OdVpiT7kDLksKbJy0Pz8vziQdhWsJ1ULbfTjhb/iclPqlmaoLz+v Nev34ZQ0NHoIeHQHn63SoM2aMEnIux1kW0wkEkvMck66QjSRaeoygtFRpbJK5SVNZvbv BLtEVpplZVzcmUsQagRDIs/j6qRTfCyypb/5vUZvIp9mJ9aoPYAYLBGTUJJN9+7a9NrJ GHow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707138071; x=1707742871; 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=4BsYS0JII2wqPsBRvjpRVtvAleGVUHvck6gX20GtRuQ=; b=MA3lcr2n1mRnizQkzaD9TV42OQXYCxRucdHWTxa5UFCw/WOvtgYbyXUXZ4jeInXD0k bV6eSSukRqYtjYm9ht8L5snocRUj/PTcJjjm1Upd/s36FWxgLpw7Y6fqvrbzXP1T0qbB e0gI61dO1ET6uQ2O8JXAm4y8morKv8mTXFrrWdMnOo0vrY0w/IxJwcMavnBnLf+nYbsa u+3vUUu9rKMhshq4PdClKw2AB6pKIFadj6P+63uuAy6y4NJt7tVbMUa9aW/JC1MlsL37 T/NEufgFTuY5PuT2vzMxPSetW41pG/VvC+5kO8MDh7xqpCp67lX1GSCFKi7PPSsWlXdx 73Cg== X-Gm-Message-State: AOJu0Yw+Pm++xWH4Gt4iL/jISySZdjHWWgZaTtc575Sikc8jnKXuQnpV sjetQLCUZfYoPl2MZfduPzGMX/Am+5C6AA9OLTGWQZlkVtZeIBLfg4lo5E3P2gOUVA== X-Google-Smtp-Source: AGHT+IFqLHnNScxDLHFOG00Rz09mcSw4RqK1ZKZJgeigRncz+EK/UjH+x4M/aAfhw3YApDjZvmS6tA== X-Received: by 2002:a17:903:2446:b0:1d9:8ac8:d784 with SMTP id l6-20020a170903244600b001d98ac8d784mr10201851pls.7.1707138071477; Mon, 05 Feb 2024 05:01:11 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWN6tgblzBqOKy7cH3wWhd57Wc/kdjRaOJOJZ+jzLAkwNO0ubgvx6rDaoIfvWxK9vwLxO3YbS2bzdTCNg5zn3SRjQcDxZAecm+Th1PAETz5u+B2TmoTc2Vf+aoE3aQulMX0Pv4iBHXTZJLXn9YuCrJrxLVwXLczcuzpi7PUFUcOy907VYR2b7NOYzwJZCvNHGjNj96HsaYnXfns+fGzUtxoNeQQVmVkdLFD0Q2m6LX4JLTvLuALFMDWmvbCqHuJqAQzaw== Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b001d9351f63d4sm6252159plh.68.2024.02.05.05.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 05:01:10 -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: [PATCHv5 net-next 4/4] selftests: bonding: use slowwait instead of hard code sleep Date: Mon, 5 Feb 2024 21:00:48 +0800 Message-ID: <20240205130048.282087-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240205130048.282087-1-liuhangbin@gmail.com> References: <20240205130048.282087-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_topo_2d1c.sh | 6 +++--- .../selftests/drivers/net/bonding/lag_lib.sh | 7 +++---- 3 files changed, 24 insertions(+), 10 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_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"