]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
u32: fix json formatting of flowid
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 13 Oct 2022 15:30:34 +0000 (08:30 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 13 Oct 2022 15:30:34 +0000 (08:30 -0700)
The code to print json was not done for the flow id.
This would lead to incorrect JSON format output.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/f_u32.c

index d787eb91560344458b8e0a17accf6ac358a488f7..e4e0ab121c57bb57f632be59e4dba451a5003211 100644 (file)
@@ -1275,12 +1275,14 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
                fprintf(stderr, "divisor and hash missing ");
        }
        if (tb[TCA_U32_CLASSID]) {
+               __u32 classid = rta_getattr_u32(tb[TCA_U32_CLASSID]);
                SPRINT_BUF(b1);
-               fprintf(f, "%sflowid %s ",
-                       !sel || !(sel->flags & TC_U32_TERMINAL) ? "*" : "",
-                       sprint_tc_classid(rta_getattr_u32(tb[TCA_U32_CLASSID]),
-                                         b1));
-       } else if (sel && sel->flags & TC_U32_TERMINAL) {
+               if (sel && (sel->flags & TC_U32_TERMINAL))
+                       print_string(PRINT_FP, NULL, "*", NULL);
+
+               print_string(PRINT_ANY, "flowid", "flowid %s ",
+                            sprint_tc_classid(classid, b1));
+       } else if (sel && (sel->flags & TC_U32_TERMINAL)) {
                print_string(PRINT_FP, NULL, "terminal flowid ", NULL);
        }
        if (tb[TCA_U32_LINK]) {