]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: add hit counter for matchall
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 17 Jan 2019 21:18:55 +0000 (13:18 -0800)
committerDavid Ahern <dsahern@gmail.com>
Mon, 21 Jan 2019 16:30:07 +0000 (08:30 -0800)
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>
Signed-off-by: David Ahern <dsahern@gmail.com>
tc/f_matchall.c

index 5ebd04155dcfecac1b4436735c19bd974361d77d..03dd51de1aced9ffb7d43ed6f69c1ddf30dfe1c3 100644 (file)
@@ -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);