[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200713075445.33aca679@hermes.lan>
Date: Mon, 13 Jul 2020 07:54:45 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Julien Fortin <julien@...ulusnetworks.com>
Cc: netdev@...r.kernel.org, roopa@...ulusnetworks.com,
dsahern@...il.com
Subject: Re: [PATCH iproute2-next master] bridge: fdb show: fix fdb entry
state output for json context
On Fri, 10 Jul 2020 02:50:55 +0200
Julien Fortin <julien@...ulusnetworks.com> wrote:
> From: Julien Fortin <julien@...ulusnetworks.com>
>
> bridge json fdb show is printing an incorrect / non-machine readable
> value, when using -j (json output) we are expecting machine readable
> data that shouldn't require special handling/parsing.
>
> $ bridge -j fdb show | \
> python -c \
> 'import sys,json;print(json.dumps(json.loads(sys.stdin.read()),indent=4))'
> [
> {
> "master": "br0",
> "mac": "56:23:28:4f:4f:e5",
> "flags": [],
> "ifname": "vx0",
> "state": "state=0x80" <<<<<<<<< with the patch: "state": "0x80"
> }
> ]
>
> Fixes: c7c1a1ef51aea7c ("bridge: colorize output and use JSON print library")
> Signed-off-by: Julien Fortin <julien@...ulusnetworks.com>
> ---
> bridge/fdb.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/bridge/fdb.c b/bridge/fdb.c
> index d2247e80..198c51d1 100644
> --- a/bridge/fdb.c
> +++ b/bridge/fdb.c
> @@ -62,7 +62,10 @@ static const char *state_n2a(unsigned int s)
> if (s & NUD_REACHABLE)
> return "";
>
> - sprintf(buf, "state=%#x", s);
> + if (is_json_context())
> + sprintf(buf, "%#x", s);
> + else
> + sprintf(buf, "state=%#x", s);
> return buf;
> }
>
Printing in non JSON case was also wrong.
i.e.
... state state=0x80
should be:
... state 0x80
Let's do that.
The state=xxx value only shows up if the FDB entry has a value bridge command
doesn't understand. The bridge command needs to be able to display the new flag values.
Please fixup the two patches and resubmit to iproute2
Powered by blists - more mailing lists