diff mbox

[1/1] actions: correctly report the number of actions flushed

Message ID 1400937215-15542-1-git-send-email-jhs@emojatatu.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Jamal Hadi Salim May 24, 2014, 1:13 p.m. UTC
From: Jamal Hadi Salim <jhs@mojatatu.com>

This also fixes a long standing bug of not sanely reporting the
action chain ordering

Sample scenario test

on window 1(event window):
run "tc monitor" and observe events

on window 2:
sudo tc actions add action drop index 10
sudo tc actions add action ok index 12
sudo tc actions ls action gact
sudo tc actions flush action gact

See the event window reporting two entries
(doing another listing should show empty generic actions)

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 tc/m_action.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Stephen Hemminger May 28, 2014, 11:56 p.m. UTC | #1
On Sat, 24 May 2014 09:13:35 -0400
Jamal Hadi Salim <jhs@mojatatu.com> wrote:

> From: Jamal Hadi Salim <jhs@mojatatu.com>
> 
> This also fixes a long standing bug of not sanely reporting the
> action chain ordering
> 
> Sample scenario test
> 
> on window 1(event window):
> run "tc monitor" and observe events
> 
> on window 2:
> sudo tc actions add action drop index 10
> sudo tc actions add action ok index 12
> sudo tc actions ls action gact
> sudo tc actions flush action gact
> 
> See the event window reporting two entries
> (doing another listing should show empty generic actions)
> 
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

Applied all 3 action patches, thanks

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tc/m_action.c b/tc/m_action.c
index 5cd5e67..7dbcf5b 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -249,37 +249,38 @@  static int
 tc_print_one_action(FILE * f, struct rtattr *arg)
 {
 
-	struct rtattr *tb[TCA_ACT_MAX + 1];
+	struct rtattr *tb[TCA_MAX + 1];
 	int err = 0;
 	struct action_util *a = NULL;
 
 	if (arg == NULL)
 		return -1;
 
-	parse_rtattr_nested(tb, TCA_ACT_MAX, arg);
-	if (tb[TCA_ACT_KIND] == NULL) {
+	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_ACT_KIND]));
+	a = get_action_kind(RTA_DATA(tb[TCA_KIND]));
 	if (NULL == a)
 		return err;
 
 	if (tab_flush) {
-		fprintf(f," %s \n", a->id);
+		__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_ACT_OPTIONS]);
+	err = a->print_aopt(a,f,tb[TCA_OPTIONS]);
 
 
 	if (0 > err)
 		return err;
 
-	if (show_stats && tb[TCA_ACT_STATS]) {
+	if (show_stats && tb[TCA_STATS]) {
 		fprintf(f, "\tAction statistics:\n");
 		print_tcstats2_attr(f, tb[TCA_ACT_STATS], "\t", NULL);
 		fprintf(f, "\n");