All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch iproute2] tc: add performance counters for basic filter
@ 2019-01-23  6:41 Cong Wang
  2019-01-23 20:43 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2019-01-23  6:41 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Jamal Hadi Salim, Jiri Pirko, David Ahern

Sample output:

filter protocol arp pref 49152 basic chain 0
filter protocol arp pref 49152 basic chain 0 handle 0x1  (rule hit 3 success 3)
    action order 1: gact action pass
     random type none pass val 0
     index 1 ref 1 bind 1 installed 81 sec used 4 sec
    Action statistics:
    Sent 126 bytes 3 pkt (dropped 0, overlimits 0 requeues 0)
    backlog 0b 0p requeues 0

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 tc/f_basic.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tc/f_basic.c b/tc/f_basic.c
index af98c088..97d43d49 100644
--- a/tc/f_basic.c
+++ b/tc/f_basic.c
@@ -110,6 +110,7 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
 			   struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_BASIC_MAX+1];
+	struct tc_basic_pcnt *pf = NULL;
 
 	if (opt == NULL)
 		return 0;
@@ -125,6 +126,19 @@ static int basic_print_opt(struct filter_util *qu, FILE *f,
 			sprint_tc_classid(rta_getattr_u32(tb[TCA_BASIC_CLASSID]), b1));
 	}
 
+	if (tb[TCA_BASIC_PCNT]) {
+		if (RTA_PAYLOAD(tb[TCA_BASIC_PCNT])  < sizeof(*pf)) {
+			fprintf(f, "Broken perf counters\n");
+			return -1;
+		}
+		pf = RTA_DATA(tb[TCA_BASIC_PCNT]);
+	}
+
+	if (show_stats && NULL != pf)
+		fprintf(f, " (rule hit %llu success %llu)",
+			(unsigned long long) pf->rcnt,
+			(unsigned long long) pf->rhit);
+
 	if (tb[TCA_BASIC_EMATCHES])
 		print_ematch(f, tb[TCA_BASIC_EMATCHES]);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch iproute2] tc: add performance counters for basic filter
  2019-01-23  6:41 [Patch iproute2] tc: add performance counters for basic filter Cong Wang
@ 2019-01-23 20:43 ` Stephen Hemminger
  2019-01-24  1:14   ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2019-01-23 20:43 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, Jamal Hadi Salim, Jiri Pirko, David Ahern

On Tue, 22 Jan 2019 22:41:45 -0800
Cong Wang <xiyou.wangcong@gmail.com> wrote:

> +	if (tb[TCA_BASIC_PCNT]) {
> +		if (RTA_PAYLOAD(tb[TCA_BASIC_PCNT])  < sizeof(*pf)) {
> +			fprintf(f, "Broken perf counters\n");
> +			return -1;

Errors should go to stderr not f (which is stdout).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch iproute2] tc: add performance counters for basic filter
  2019-01-23 20:43 ` Stephen Hemminger
@ 2019-01-24  1:14   ` Cong Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Cong Wang @ 2019-01-24  1:14 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Linux Kernel Network Developers, Jamal Hadi Salim, Jiri Pirko,
	David Ahern

On Wed, Jan 23, 2019 at 12:43 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Tue, 22 Jan 2019 22:41:45 -0800
> Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> > +     if (tb[TCA_BASIC_PCNT]) {
> > +             if (RTA_PAYLOAD(tb[TCA_BASIC_PCNT])  < sizeof(*pf)) {
> > +                     fprintf(f, "Broken perf counters\n");
> > +                     return -1;
>
> Errors should go to stderr not f (which is stdout).

Ok, I copy the code from u32 filter, so it has the same issue.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-24  1:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23  6:41 [Patch iproute2] tc: add performance counters for basic filter Cong Wang
2019-01-23 20:43 ` Stephen Hemminger
2019-01-24  1:14   ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.