[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0106018d95aa6929-b0f30ab9-f719-4208-9f1e-f5738423d095-000000@ap-northeast-1.amazonses.com>
Date: Sun, 11 Feb 2024 00:56:29 +0000
From: Takanori Hirano <me@...tknr.net>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH iproute2 v2] tc: Add support json option in filter.
On Sat, Feb 10, 2024 at 09:21:07AM -0800, Stephen Hemminger wrote:
> On Sat, 10 Feb 2024 10:08:03 +0000
> Takanori Hirano <me@...tknr.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));
> }
>
Thank you for the v1 merge.
We will send the remaining diff as a separate patch to reflect your review.
Powered by blists - more mailing lists