diff mbox series

[iproute2] tc/taprio: fix parsing of "fp" option when it doesn't appear last

Message ID 20230705105155.51490-1-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit e848ef0ad5d07034ed08745eefec37586887a454
Delegated to: Stephen Hemminger
Headers show
Series [iproute2] tc/taprio: fix parsing of "fp" option when it doesn't appear last | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Vladimir Oltean July 5, 2023, 10:51 a.m. UTC
When installing a Qdisc this way:

tc qdisc replace dev $ifname handle 8001: parent root stab overhead 24 taprio \
	num_tc 8 \
	map 0 1 2 3 4 5 6 7 \
	queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
	base-time 0 \
	sched-entry S 01 1216 \
	sched-entry S fe 12368 \
	fp P E E E E E E E \
	flags 0x2

the parser will error out when it tries to parse the "fp" array and it
finds "flags" as one of the elements, expecting it to be one of "P" or
"E".

The way this is handled in the parsing of other array arguments of
variable size (max-sdu, map, queues etc) is to not fail, call PREV_ARG()
and attempt re-parsing the argument as something else. Do that for "fp"
as well.

Apparently mqprio handles this case correctly, so I must have forgotten
to apply the same treatment for taprio as well, during development.

Fixes: 5fbca3b469ec ("tc/taprio: add support for preemptible traffic classes")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 tc/q_taprio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org July 5, 2023, 6 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Wed,  5 Jul 2023 13:51:55 +0300 you wrote:
> When installing a Qdisc this way:
> 
> tc qdisc replace dev $ifname handle 8001: parent root stab overhead 24 taprio \
> 	num_tc 8 \
> 	map 0 1 2 3 4 5 6 7 \
> 	queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
> 	base-time 0 \
> 	sched-entry S 01 1216 \
> 	sched-entry S fe 12368 \
> 	fp P E E E E E E E \
> 	flags 0x2
> 
> [...]

Here is the summary with links:
  - [iproute2] tc/taprio: fix parsing of "fp" option when it doesn't appear last
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=e848ef0ad5d0

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tc/q_taprio.c b/tc/q_taprio.c
index 65d0a30bd67f..913197f68caa 100644
--- a/tc/q_taprio.c
+++ b/tc/q_taprio.c
@@ -250,10 +250,8 @@  static int taprio_parse_opt(struct qdisc_util *qu, int argc,
 				} else if (strcmp(*argv, "P") == 0) {
 					fp[idx] = TC_FP_PREEMPTIBLE;
 				} else {
-					fprintf(stderr,
-						"Illegal \"fp\" value \"%s\", expected \"E\" or \"P\"\n",
-						*argv);
-					return -1;
+					PREV_ARG();
+					break;
 				}
 				num_fp_entries++;
 				idx++;