Skip to contentSkip to conversation

tc_util: Fix parsing action control with space and slash

PATCH Applied Roi Dayan 2 participants 2 messages Feb 3, 2022 – Feb 11, 2022

Subsystems (2)
lore
Share & tools
lore

Roi Dayan

author
#0 lore raw

PATCH 1/1 tc_util: Fix parsing action control with space and slash

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 ...

---
 tc/tc_util.c | 1 -
 1 file changed, 1 deletion(-)
tc/tc_util.c +0 -1
index 48065897cee7..b82dbd5dc75d 100644
@@ -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)
Signature · 1 line
2.8.0
#1 lore raw
Quoted 36 lines · On Thu, 3 Feb 2022 14:20:46 +0200 Roi Dayan <[email protected]> wrote:

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 ...

---
 tc/tc_util.c | 1 -
 1 file changed, 1 deletion(-)
tc/tc_util.c +0 -0
index 48065897cee7..b82dbd5dc75d 100644

tc/tc_util.c static int parse_action_control_slash_spaces(int *argc_p, char ***argv_p, · line 481

Quoted 7 lines
tc/tc_util.c +0 -1
@@ -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)

Applied, and removed the now unnecessary second fall-through comment.