lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200331085031.10454-1-jiri@resnulli.us>
Date:   Tue, 31 Mar 2020 10:50:31 +0200
From:   Jiri Pirko <jiri@...nulli.us>
To:     netdev@...r.kernel.org
Cc:     dsahern@...il.com, stephen@...workplumber.org, davem@...emloft.net,
        kuba@...nel.org, idosch@...lanox.com, saeedm@...lanox.com,
        leon@...nel.org, michael.chan@...adcom.com, vishal@...lsio.com,
        pablo@...filter.org, jhs@...atatu.com, xiyou.wangcong@...il.com,
        paulb@...lanox.com, alexandre.belloni@...tlin.com,
        ozsh@...lanox.com, roid@...lanox.com, john.hurley@...ronome.com,
        simon.horman@...ronome.com, pieter.jansenvanvuuren@...ronome.com
Subject: [patch iproute2/net-next v2] tc: show used HW stats types

From: Jiri Pirko <jiri@...lanox.com>

If kernel provides the attribute, show the used HW stats types.

Example:

$ tc filter add dev enp3s0np1 ingress proto ip handle 1 pref 1 flower dst_ip 192.168.1.1 action drop
$ tc -s filter show dev enp3s0np1 ingress
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 192.168.1.1
  in_hw in_hw_count 2
        action order 1: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 1 installed 10 sec used 10 sec
        Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0
        used_hw_stats immediate     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Signed-off-by: Jiri Pirko <jiri@...lanox.com>
---
v1->v2:
- fix output then hw_stats is not "any" - add \n
---
 include/uapi/linux/pkt_cls.h |  1 +
 tc/m_action.c                | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 6fcf7307e534..9f06d29cab70 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -18,6 +18,7 @@ enum {
 	TCA_ACT_COOKIE,
 	TCA_ACT_FLAGS,
 	TCA_ACT_HW_STATS,
+	TCA_ACT_USED_HW_STATS,
 	__TCA_ACT_MAX
 };
 
diff --git a/tc/m_action.c b/tc/m_action.c
index 2c4b5df6e05c..108329db29d0 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -159,7 +159,7 @@ static const struct hw_stats_item {
 	{ "disabled", 0 }, /* no bit set */
 };
 
-static void print_hw_stats(const struct rtattr *arg)
+static void print_hw_stats(const struct rtattr *arg, bool print_used)
 {
 	struct nla_bitfield32 *hw_stats_bf = RTA_DATA(arg);
 	__u8 hw_stats;
@@ -167,7 +167,7 @@ static void print_hw_stats(const struct rtattr *arg)
 
 	hw_stats = hw_stats_bf->value & hw_stats_bf->selector;
 	print_string(PRINT_FP, NULL, "\t", NULL);
-	open_json_array(PRINT_ANY, "hw_stats");
+	open_json_array(PRINT_ANY, print_used ? "used_hw_stats" : "hw_stats");
 
 	for (i = 0; i < ARRAY_SIZE(hw_stats_items); i++) {
 		const struct hw_stats_item *item;
@@ -177,6 +177,7 @@ static void print_hw_stats(const struct rtattr *arg)
 			print_string(PRINT_ANY, NULL, " %s", item->str);
 	}
 	close_json_array(PRINT_JSON, NULL);
+	print_string(PRINT_FP, NULL, "%s", _SL_);
 }
 
 static int parse_hw_stats(const char *str, struct nlmsghdr *n)
@@ -399,7 +400,10 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
 		print_string(PRINT_FP, NULL, "%s", _SL_);
 	}
 	if (tb[TCA_ACT_HW_STATS])
-		print_hw_stats(tb[TCA_ACT_HW_STATS]);
+		print_hw_stats(tb[TCA_ACT_HW_STATS], false);
+
+	if (tb[TCA_ACT_USED_HW_STATS])
+		print_hw_stats(tb[TCA_ACT_USED_HW_STATS], true);
 
 	return 0;
 }
-- 
2.21.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ