From patchwork Fri Oct 8 13:12:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12545341 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0201C433EF for ; Fri, 8 Oct 2021 13:13:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B92D361042 for ; Fri, 8 Oct 2021 13:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242509AbhJHNPG (ORCPT ); Fri, 8 Oct 2021 09:15:06 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:41723 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242499AbhJHNPF (ORCPT ); Fri, 8 Oct 2021 09:15:05 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 722F35C00E0; Fri, 8 Oct 2021 09:13:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 08 Oct 2021 09:13:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Zy3T1abwhqeS/8cXqMqvRbE2ZHy4i5ttc0U1mCLzJkM=; b=nLoUwx3r ahIqqvsv8DRrfsqtGypblzu2x+5uAGusqjn+kfvbsw/n8z/Qep3+rVu8nPlWhh39 gpdYupGYacveB08P3RbpB6fcrHHfHL0onUgOnM3bGU6pevTR+3kh6F9+1pi0wZYl RfRNXAYf/3qweXF+3x4XB6kKJToviLmmibb8eTMpmVutoxOgEMS/9oXwUTId0VJ5 F9EYu1JXObdUG7aXEwa1BXGvjnaQCxrwesTy84WWlmBJgSMqgr7osTogrzTL/TeG j2q9aL9dF7uBJpwiH1d5PNVmkm70b6Ch5rU6I2Erq/aORalpDr4tG5mXUxqxOOlv zwP3Ckpb/P9vwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddttddgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnhepudetieevffffveelkeeljeffkefhke ehgfdtffethfelvdejgffghefgveejkefhnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Oct 2021 09:13:08 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com, petrm@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 2/8] testing: selftests: tc_common: Add tc_check_at_least_x_packets() Date: Fri, 8 Oct 2021 16:12:35 +0300 Message-Id: <20211008131241.85038-3-idosch@idosch.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008131241.85038-1-idosch@idosch.org> References: <20211008131241.85038-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Add function that checks that at least X packets hit the tc rule. There are cases that it is not possible to catch only the interesting packets, so then, it is possible to send many packets and verify that at least this amount of packets hit the rule. This function will be used in the next patch for general tc rule that can be used to test both software and hardware. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/tc_common.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh index 0e18e8be6e2a..bce8bb8d2b6f 100644 --- a/tools/testing/selftests/net/forwarding/tc_common.sh +++ b/tools/testing/selftests/net/forwarding/tc_common.sh @@ -16,6 +16,16 @@ tc_check_packets() tc_rule_handle_stats_get "$id" "$handle" > /dev/null } +tc_check_at_least_x_packets() +{ + local id=$1 + local handle=$2 + local count=$3 + + busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $count" \ + tc_rule_handle_stats_get "$id" "$handle" > /dev/null +} + tc_check_packets_hitting() { local id=$1