Message ID | 20200727162009.7618-1-julien@cumulusnetworks.com |
---|---|
State | Changes Requested |
Delegated to: | David Ahern |
Headers | show |
Series | [iproute2-next,master,v2] bridge: fdb show: fix fdb entry state output (+ add json support) | expand |
On Mon, 27 Jul 2020 18:20:09 +0200 Julien Fortin <julien@cumulusnetworks.com> wrote: > diff --git a/bridge/fdb.c b/bridge/fdb.c > index d1f8afbe..765f4e51 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) Please keep the "state=%#x" for the non JSON case. No need to change output format.
On Mon, Jul 27, 2020 at 6:30 PM Stephen Hemminger <stephen@networkplumber.org> wrote: > > On Mon, 27 Jul 2020 18:20:09 +0200 > Julien Fortin <julien@cumulusnetworks.com> wrote: > > > diff --git a/bridge/fdb.c b/bridge/fdb.c > > index d1f8afbe..765f4e51 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) > > Please keep the "state=%#x" for the non JSON case. > No need to change output format. My v1 patch (see below) kept the "state=" but you asked me to remove it and re-submit. 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; }
On 7/27/20 5:25 PM, Julien Fortin wrote: > On Mon, Jul 27, 2020 at 6:30 PM Stephen Hemminger > <stephen@networkplumber.org> wrote: >> >> On Mon, 27 Jul 2020 18:20:09 +0200 >> Julien Fortin <julien@cumulusnetworks.com> wrote: >> >>> diff --git a/bridge/fdb.c b/bridge/fdb.c >>> index d1f8afbe..765f4e51 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) >> >> Please keep the "state=%#x" for the non JSON case. >> No need to change output format. > > My v1 patch (see below) kept the "state=" but you asked me to remove > it and re-submit. > > 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; > } > the v1 patch looks correct to me. Resubmit, but this should go to main branch since it is a bug fix.
diff --git a/bridge/fdb.c b/bridge/fdb.c index d1f8afbe..765f4e51 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; }