netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, amcohen@nvidia.com,
	petrm@nvidia.com, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
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	[thread overview]
Message-ID: <20211008131241.85038-3-idosch@idosch.org> (raw)
In-Reply-To: <20211008131241.85038-1-idosch@idosch.org>

From: Amit Cohen <amcohen@nvidia.com>

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 <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 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
-- 
2.31.1


  parent reply	other threads:[~2021-10-08 13:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 13:12 [PATCH net-next 0/8] selftests: forwarding: Add ip6gre tests Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 1/8] testing: selftests: forwarding.config.sample: Add tc flag Ido Schimmel
2021-10-08 13:12 ` Ido Schimmel [this message]
2021-10-08 13:12 ` [PATCH net-next 3/8] selftests: forwarding: Add IPv6 GRE flat tests Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 4/8] selftests: forwarding: Add IPv6 GRE hierarchical tests Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 5/8] selftests: mlxsw: devlink_trap_tunnel_ipip6: Add test case for IPv6 decap_error Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 6/8] selftests: mlxsw: devlink_trap_tunnel_ipip: Align topology drawing correctly Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 7/8] selftests: mlxsw: devlink_trap_tunnel_ipip: Remove code duplication Ido Schimmel
2021-10-08 13:12 ` [PATCH net-next 8/8] selftests: mlxsw: devlink_trap_tunnel_ipip: Send a full-length key Ido Schimmel
2021-10-08 15:50 ` [PATCH net-next 0/8] selftests: forwarding: Add ip6gre tests patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211008131241.85038-3-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=amcohen@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).