All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch iproute2] tc: add hit counter for matchall
@ 2019-01-17 21:18 Cong Wang
  2019-01-21 16:35 ` David Ahern
  2019-01-23 20:47 ` Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Cong Wang @ 2019-01-17 21:18 UTC (permalink / raw)
  To: netdev
  Cc: Cong Wang, Martin Olsson, Jamal Hadi Salim, Jiri Pirko, David Ahern

Cc: Martin Olsson <martin.olsson+netdev@sentorsecurity.com>
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_matchall.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 5ebd0415..03dd51de 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -114,6 +114,7 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f,
 			   struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_MATCHALL_MAX+1];
+	struct tc_matchall_pcnt *pf = NULL;
 
 	if (opt == NULL)
 		return 0;
@@ -143,6 +144,19 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f,
 			print_bool(PRINT_ANY, "not_in_hw", "\n  not_in_hw", true);
 	}
 
+	if (tb[TCA_MATCHALL_PCNT]) {
+		if (RTA_PAYLOAD(tb[TCA_MATCHALL_PCNT])  < sizeof(*pf)) {
+			print_string(PRINT_FP, NULL, "Broken perf counters\n", NULL);
+			return -1;
+		}
+		pf = RTA_DATA(tb[TCA_MATCHALL_PCNT]);
+	}
+
+	if (show_stats && NULL != pf)
+		print_u64(PRINT_ANY, "rule_hit", " (rule hit %llu)",
+			(unsigned long long) pf->rhit);
+
+
 	if (tb[TCA_MATCHALL_ACT])
 		tc_print_action(f, tb[TCA_MATCHALL_ACT], 0);
 
-- 
2.20.1


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

* Re: [Patch iproute2] tc: add hit counter for matchall
  2019-01-17 21:18 [Patch iproute2] tc: add hit counter for matchall Cong Wang
@ 2019-01-21 16:35 ` David Ahern
  2019-01-23  5:08   ` Cong Wang
  2019-01-23 20:47 ` Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: David Ahern @ 2019-01-21 16:35 UTC (permalink / raw)
  To: Cong Wang, netdev; +Cc: Martin Olsson, Jamal Hadi Salim, Jiri Pirko

On 1/17/19 2:18 PM, Cong Wang wrote:
> Cc: Martin Olsson <martin.olsson+netdev@sentorsecurity.com>
> 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_matchall.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 

applied to iproute2-next.

In the future, add some kind of description to the log - preferably
including example output from the command.


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

* Re: [Patch iproute2] tc: add hit counter for matchall
  2019-01-21 16:35 ` David Ahern
@ 2019-01-23  5:08   ` Cong Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Cong Wang @ 2019-01-23  5:08 UTC (permalink / raw)
  To: David Ahern
  Cc: Linux Kernel Network Developers, Martin Olsson, Jamal Hadi Salim,
	Jiri Pirko

On Mon, Jan 21, 2019 at 8:35 AM David Ahern <dsahern@gmail.com> wrote:
>
> On 1/17/19 2:18 PM, Cong Wang wrote:
> > Cc: Martin Olsson <martin.olsson+netdev@sentorsecurity.com>
> > 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_matchall.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
>
> applied to iproute2-next.
>
> In the future, add some kind of description to the log - preferably
> including example output from the command.

Will do.
I did in the kernel commit, but somehow forgot for iproute2.

Thanks.

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

* Re: [Patch iproute2] tc: add hit counter for matchall
  2019-01-17 21:18 [Patch iproute2] tc: add hit counter for matchall Cong Wang
  2019-01-21 16:35 ` David Ahern
@ 2019-01-23 20:47 ` Stephen Hemminger
  2019-01-24  1:16   ` Cong Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2019-01-23 20:47 UTC (permalink / raw)
  To: Cong Wang
  Cc: netdev, Martin Olsson, Jamal Hadi Salim, Jiri Pirko, David Ahern

On Thu, 17 Jan 2019 13:18:55 -0800
Cong Wang <xiyou.wangcong@gmail.com> wrote:

>  
> +	if (tb[TCA_MATCHALL_PCNT]) {
> +		if (RTA_PAYLOAD(tb[TCA_MATCHALL_PCNT])  < sizeof(*pf)) {
> +			print_string(PRINT_FP, NULL, "Broken perf counters\n", NULL);

This the wrong way to print an error message with iproute2 suite.
The correct answer is simple.
			fprintf(stderr, "Broken perf counters\n");
and better yet give a more informative message that says what is incorrect.

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

* Re: [Patch iproute2] tc: add hit counter for matchall
  2019-01-23 20:47 ` Stephen Hemminger
@ 2019-01-24  1:16   ` Cong Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Cong Wang @ 2019-01-24  1:16 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Linux Kernel Network Developers, Martin Olsson, Jamal Hadi Salim,
	Jiri Pirko, David Ahern

On Wed, Jan 23, 2019 at 12:47 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Thu, 17 Jan 2019 13:18:55 -0800
> Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> >
> > +     if (tb[TCA_MATCHALL_PCNT]) {
> > +             if (RTA_PAYLOAD(tb[TCA_MATCHALL_PCNT])  < sizeof(*pf)) {
> > +                     print_string(PRINT_FP, NULL, "Broken perf counters\n", NULL);
>
> This the wrong way to print an error message with iproute2 suite.
> The correct answer is simple.
>                         fprintf(stderr, "Broken perf counters\n");
> and better yet give a more informative message that says what is incorrect.

What's your suggestion?

In fact, I am not sure if we really have to check the size here, it should
be safe to assume kernel will always dump a non-broken struct here,
and this struct will never shrink.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 21:18 [Patch iproute2] tc: add hit counter for matchall Cong Wang
2019-01-21 16:35 ` David Ahern
2019-01-23  5:08   ` Cong Wang
2019-01-23 20:47 ` Stephen Hemminger
2019-01-24  1:16   ` 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.