From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: [PATCH net-next 06/18] selftests: forwarding: lib: Add link_stats_rx_errors_get() Date: Mon, 19 Nov 2018 16:11:13 +0000 Message-ID: <20181119161006.5405-7-idosch@mellanox.com> References: <20181119161006.5405-1-idosch@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "davem@davemloft.net" , "shuah@kernel.org" , Jiri Pirko , Petr Machata , "roopa@cumulusnetworks.com" , mlxsw , Ido Schimmel To: "netdev@vger.kernel.org" , "linux-kselftest@vger.kernel.org" Return-path: Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49]:48096 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729935AbeKTCf2 (ORCPT ); Mon, 19 Nov 2018 21:35:28 -0500 In-Reply-To: <20181119161006.5405-1-idosch@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: From: Petr Machata Such a function will be useful for counting malformed packets in the ECN decap test. To that end, introduce a common handler for handling stat-fetching, and reuse it in link_stats_tx_packets_get() and link_stats_rx_errors_get(). Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/= selftests/net/forwarding/lib.sh index e916663a1019..7af5a03bcb32 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -477,11 +477,24 @@ master_name_get() ip -j link show dev $if_name | jq -r '.[]["master"]' } =20 +link_stats_get() +{ + local if_name=3D$1; shift + local dir=3D$1; shift + local stat=3D$1; shift + + ip -j -s link show dev $if_name \ + | jq '.[]["stats64"]["'$dir'"]["'$stat'"]' +} + link_stats_tx_packets_get() { - local if_name=3D$1 + link_stats_get $1 tx packets +} =20 - ip -j -s link show dev $if_name | jq '.[]["stats64"]["tx"]["packets= "]' +link_stats_rx_errors_get() +{ + link_stats_get $1 rx errors } =20 tc_rule_stats_get() --=20 2.19.1