netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Takanori Hirano <me@hrntknr.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2 v2] tc: Add support json option in filter.
Date: Sat, 10 Feb 2024 09:21:07 -0800	[thread overview]
Message-ID: <20240210092107.53598a13@hermes.local> (raw)
In-Reply-To: <0106018d927d04ff-efbd5d4b-b32f-4b39-a184-a28939608096-000000@ap-northeast-1.amazonses.com>

On Sat, 10 Feb 2024 10:08:03 +0000
Takanori Hirano <me@hrntknr.net> wrote:

>  	if (tb[TCA_FLOW_MODE]) {
>  		__u32 mode = rta_getattr_u32(tb[TCA_FLOW_MODE]);
>  
>  		switch (mode) {
>  		case FLOW_MODE_MAP:
> -			fprintf(f, "map ");
> +			open_json_object("map");
> +			print_string(PRINT_FP, NULL, "map ", NULL);
>  			break;
>  		case FLOW_MODE_HASH:
> -			fprintf(f, "hash ");
> +			open_json_object("hash");
> +			print_string(PRINT_FP, NULL, "hash ", NULL);
>  			break;
>  		}
>  	}

Since this is two values for mode, in my version it looks like
 
+static const char *flow_mode2str(__u32 mode)
+{
+	static char buf[128];
+
+	switch (mode) {
+	case FLOW_MODE_MAP:
+		return "map";
+	case FLOW_MODE_HASH:
+		return "hash";
+	default:
+		snprintf(buf, sizeof(buf), "%#x", mode);
+		return buf;
+	}
+}
+

 
 	if (tb[TCA_FLOW_MODE]) {
 		__u32 mode = rta_getattr_u32(tb[TCA_FLOW_MODE]);
 
-		switch (mode) {
-		case FLOW_MODE_MAP:
-			fprintf(f, "map ");
-			break;
-		case FLOW_MODE_HASH:
-			fprintf(f, "hash ");
-			break;
-		}
+		print_string(PRINT_ANY, "mode", "%s ", flow_mode2str(mode));
 	}
 

  parent reply	other threads:[~2024-02-10 17:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 14:22 [PATCH iproute2] tc: Support json option in tc-fw Takanori Hirano
2024-02-09 16:37 ` Stephen Hemminger
2024-02-10 10:02   ` Takanori Hirano
2024-02-10 10:08   ` [PATCH iproute2 v2] tc: Add support json option in filter Takanori Hirano
2024-02-10 17:18     ` Stephen Hemminger
2024-02-10 17:21     ` Stephen Hemminger [this message]
2024-02-11  0:56       ` Takanori Hirano
2024-02-11  0:59       ` [PATCH] tc: Support json option in tc-cgroup, tc-flow and tc-route Takanori Hirano
2024-02-13  4:16         ` Stephen Hemminger
2024-02-13 10:01           ` [PATCH v2] " Takanori Hirano
2024-02-19 18:20             ` patchwork-bot+netdevbpf
2024-02-11  1:27       ` [PATCH] tc: Change of json key: options.handle -> options.fw in tc-fw Takanori Hirano
2024-02-11  1:38       ` [PATCH v2] tc: Change of json format " Takanori Hirano
2024-02-19 18:20         ` patchwork-bot+netdevbpf
2024-02-11  1:00     ` [PATCH iproute2 v2] tc: Add support json option in filter Stephen Hemminger
2024-02-11  1:08       ` Takanori Hirano
2024-02-10 17:50 ` [PATCH iproute2] tc: Support json option in tc-fw patchwork-bot+netdevbpf

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=20240210092107.53598a13@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=me@hrntknr.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).