All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
	"Christian Pössinger" <christian@poessinger.com>
Subject: [PATCH iproute2] u32: fix json formatting of flowid
Date: Thu, 13 Oct 2022 08:32:40 -0700	[thread overview]
Message-ID: <20221013153240.108340-1-stephen@networkplumber.org> (raw)
In-Reply-To: <f4806731521546b0bb7011b8c570b52b@poessinger.com>

The code to print json was not done for the flow id.
This would lead to incorrect JSON format output.

Reported-by: Christian Pössinger <christian@poessinger.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/f_u32.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tc/f_u32.c b/tc/f_u32.c
index d787eb915603..e4e0ab121c57 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -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]) {
-- 
2.35.1


  parent reply	other threads:[~2022-10-13 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 11:17 iproute2/tc invalid JSON in 6.0.0 for flowid Christian Pössinger
2022-10-13 15:18 ` Francois Romieu
2022-10-13 15:43   ` Stephen Hemminger
2022-10-13 15:32 ` Stephen Hemminger [this message]
2022-10-13 17:22   ` [PATCH iproute2] u32: fix json formatting of flowid Christian Pössinger

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=20221013153240.108340-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=christian@poessinger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.