Commit 954de6c7 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by Stephen Hemminger

actions: BugFix action stats to display with -s

Was broken by commit 288abf51
Lets not be too clever and have a separate call to print flushed
actions info.

Broken looks like:
root@moja-1:~# tc actions add  action drop index 4
root@moja-1:~# tc -s actions ls action gact

    action order 0: gact action drop
     random type none pass val 0
     index 4 ref 1 bind 0 installed 9 sec used 4 sec

The fixed version looks like:
    action order 0: gact action drop
     random type none pass val 0
     index 4 ref 1 bind 0 installed 9 sec used 4 sec
         Sent 108948 bytes 1297 pkts (dropped 1297, overlimits 0)
Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
parent 2f7fbec2
...@@ -249,38 +249,31 @@ static int ...@@ -249,38 +249,31 @@ static int
tc_print_one_action(FILE * f, struct rtattr *arg) tc_print_one_action(FILE * f, struct rtattr *arg)
{ {
struct rtattr *tb[TCA_MAX + 1]; struct rtattr *tb[TCA_ACT_MAX + 1];
int err = 0; int err = 0;
struct action_util *a = NULL; struct action_util *a = NULL;
if (arg == NULL) if (arg == NULL)
return -1; return -1;
parse_rtattr_nested(tb, TCA_MAX, arg); parse_rtattr_nested(tb, TCA_ACT_MAX, arg);
if (tb[TCA_KIND] == NULL) {
if (tb[TCA_ACT_KIND] == NULL) {
fprintf(stderr, "NULL Action!\n"); fprintf(stderr, "NULL Action!\n");
return -1; return -1;
} }
a = get_action_kind(RTA_DATA(tb[TCA_KIND])); a = get_action_kind(RTA_DATA(tb[TCA_ACT_KIND]));
if (NULL == a) if (NULL == a)
return err; return err;
if (tab_flush) { err = a->print_aopt(a, f, tb[TCA_ACT_OPTIONS]);
__u32 *delete_count = RTA_DATA(tb[TCA_FCNT]);
fprintf(f," %s (%d entries)\n", a->id, *delete_count);
tab_flush = 0;
return 0;
}
err = a->print_aopt(a,f,tb[TCA_OPTIONS]);
if (0 > err) if (0 > err)
return err; return err;
if (show_stats && tb[TCA_STATS]) { if (show_stats && tb[TCA_ACT_STATS]) {
fprintf(f, "\tAction statistics:\n"); fprintf(f, "\tAction statistics:\n");
print_tcstats2_attr(f, tb[TCA_ACT_STATS], "\t", NULL); print_tcstats2_attr(f, tb[TCA_ACT_STATS], "\t", NULL);
fprintf(f, "\n"); fprintf(f, "\n");
...@@ -289,8 +282,34 @@ tc_print_one_action(FILE * f, struct rtattr *arg) ...@@ -289,8 +282,34 @@ tc_print_one_action(FILE * f, struct rtattr *arg)
return 0; return 0;
} }
static int
tc_print_action_flush(FILE *f, const struct rtattr *arg)
{
struct rtattr *tb[TCA_MAX + 1];
int err = 0;
struct action_util *a = NULL;
__u32 *delete_count = 0;
parse_rtattr_nested(tb, TCA_MAX, arg);
if (tb[TCA_KIND] == NULL) {
fprintf(stderr, "NULL Action!\n");
return -1;
}
a = get_action_kind(RTA_DATA(tb[TCA_KIND]));
if (NULL == a)
return err;
delete_count = RTA_DATA(tb[TCA_FCNT]);
fprintf(f," %s (%d entries)\n", a->id, *delete_count);
tab_flush = 0;
return 0;
}
int int
tc_print_action(FILE * f, const struct rtattr *arg) tc_print_action(FILE *f, const struct rtattr *arg)
{ {
int i; int i;
...@@ -301,10 +320,8 @@ tc_print_action(FILE * f, const struct rtattr *arg) ...@@ -301,10 +320,8 @@ tc_print_action(FILE * f, const struct rtattr *arg)
parse_rtattr_nested(tb, TCA_ACT_MAX_PRIO, arg); parse_rtattr_nested(tb, TCA_ACT_MAX_PRIO, arg);
if (tab_flush && NULL != tb[0] && NULL == tb[1]) { if (tab_flush && NULL != tb[0] && NULL == tb[1])
int ret = tc_print_one_action(f, tb[0]); return tc_print_action_flush(f, tb[0]);
return ret;
}
for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
if (tb[i]) { if (tb[i]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment