]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc/taprio: fix parsing of "fp" option when it doesn't appear last
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 5 Jul 2023 10:51:55 +0000 (13:51 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 5 Jul 2023 17:57:40 +0000 (10:57 -0700)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/q_taprio.c

index 65d0a30bd67ffdead674c6d8c7312f5a63325c2f..913197f68caa46281d48d49c27f1db65d6790adf 100644 (file)
@@ -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++;