From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Privoznik Subject: [PATCH] tc: police: fix control action parsing Date: Mon, 27 Nov 2017 18:51:56 +0100 Message-ID: <01774dea3239d1127d2e174a48419db4089c4de3.1511805077.git.mprivozn@redhat.com> Cc: jiri@mellanox.com To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57412 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932398AbdK0RwG (ORCPT ); Mon, 27 Nov 2017 12:52:06 -0500 Sender: netdev-owner@vger.kernel.org List-ID: parse_action_control helper does advancing of the arg inside. So don't do it outside. Fixes: e67aba559581 ("tc: actions: add helpers to parse and print control actions") Signed-off-by: Michal Privoznik --- tc/m_police.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tc/m_police.c b/tc/m_police.c index ff1dcb7d..62cc6f86 100644 --- a/tc/m_police.c +++ b/tc/m_police.c @@ -75,6 +75,7 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p, return -1; while (argc > 0) { + bool advance = true; if (matches(*argv, "index") == 0) { NEXT_ARG(); @@ -154,11 +155,13 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p, matches(*argv, "goto") == 0) { if (parse_action_control(&argc, &argv, &p.action, false)) return -1; + advance = false; } else if (strcmp(*argv, "conform-exceed") == 0) { NEXT_ARG(); if (parse_action_control_slash(&argc, &argv, &p.action, &presult, true)) return -1; + advance = false; } else if (matches(*argv, "overhead") == 0) { NEXT_ARG(); if (get_u16(&overhead, *argv, 10)) { @@ -175,7 +178,9 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p, break; } ok++; - argc--; argv++; + if (advance) { + argc--; argv++; + } } if (!ok) -- 2.13.6