netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roi Dayan <roid@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: Roi Dayan <roid@nvidia.com>, Maor Dickman <maord@nvidia.com>
Subject: [PATCH iproute2] tc_util: Fix parsing action control with space and slash
Date: Thu, 3 Feb 2022 14:20:46 +0200	[thread overview]
Message-ID: <20220203122046.307076-1-roid@nvidia.com> (raw)

For action police there is an conform-exceed action control
which can be for example "jump 2 / pipe".
The current parsing loop is doing one more iteration than necessary
and results in ok var being 3.

Example filter:

tc filter add dev enp8s0f0_0 ingress protocol ip prio 2 flower \
    verbose action police rate 100mbit burst 12m \
    conform-exceed jump 1 / pipe mirred egress redirect dev enp8s0f0_1 action drop

Before this change the command will fail.
Trying to add another "pipe" before mirred as a workaround for the stopping the loop
in ok var 3 resulting in result2 not being saved and wrong filter.

... conform-exceed jump 1 / pipe pipe mirred ...

Example dump of the action part:
... action order 1:  police 0x1 rate 100Mbit burst 12Mb mtu 2Kb action jump 1 overhead 0b  ...

Fix the behavior by removing redundant case 2 handling, either argc is over or breaking.

Example dump of the action part with the fix:
... action order 1:  police 0x1 rate 100Mbit burst 12Mb mtu 2Kb action jump 1/pipe overhead 0b ...

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
---
 tc/tc_util.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index 48065897cee7..b82dbd5dc75d 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -476,7 +476,6 @@ static int parse_action_control_slash_spaces(int *argc_p, char ***argv_p,
 			NEXT_ARG();
 			/* fall-through */
 		case 0: /* fall-through */
-		case 2:
 			ret = parse_action_control(&argc, &argv,
 						   result_p, allow_num);
 			if (ret)
-- 
2.8.0


             reply	other threads:[~2022-02-03 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 12:20 Roi Dayan [this message]
2022-02-11  1:21 ` [PATCH iproute2] tc_util: Fix parsing action control with space and slash Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220203122046.307076-1-roid@nvidia.com \
    --to=roid@nvidia.com \
    --cc=maord@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).