selftests: forwarding: lib: Add ethtool_stats_get()
authorPetr Machata <petrm@mellanox.com>
Thu, 20 Sep 2018 06:21:34 +0000 (09:21 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Sep 2018 14:46:01 +0000 (07:46 -0700)
Add a new service function to obtain ethtool counters.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh

index ca53b539aa2d18affad9fd63399837c7f5a7fe14..4c2351996a7f33b2fac82bb2bc6c84770ef31306 100644 (file)
@@ -494,6 +494,14 @@ tc_rule_stats_get()
            | jq '.[1].options.actions[].stats.packets'
 }
 
+ethtool_stats_get()
+{
+       local dev=$1; shift
+       local stat=$1; shift
+
+       ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
+}
+
 mac_get()
 {
        local if_name=$1