Subject: Re: [PATCHv3 iproute2-next 3/7] iproute_lwtunnel: add options support for erspan metadata

From: Stephen Hemminger <[email-masked]>
Date: Thu, 23 Apr 2020 08:23:51 -0700

On Sat, 15 Feb 2020 01:40:27 +0800
Xin Long <[email-masked]> wrote:

> On Sat, Feb 15, 2020 at 12:13 AM Stephen Hemminger
> <[email-masked]> wrote:
> >
> > On Fri, 14 Feb 2020 18:30:47 +0800
> > Xin Long <[email-masked]> wrote:
> >  
> > > +
> > > +     open_json_array(PRINT_JSON, name);
> > > +     open_json_object(NULL);
> > > +     print_uint(PRINT_JSON, "ver", NULL, ver);
> > > +     print_uint(PRINT_JSON, "index", NULL, idx);
> > > +     print_uint(PRINT_JSON, "dir", NULL, dir);
> > > +     print_uint(PRINT_JSON, "hwid", NULL, hwid);
> > > +     close_json_object();
> > > +     close_json_array(PRINT_JSON, name);
> > > +
> > > +     print_nl();
> > > +     print_string(PRINT_FP, name, "\t%s ", name);
> > > +     sprintf(strbuf, "%02x:%08x:%02x:%02x", ver, idx, dir, hwid);
> > > +     print_string(PRINT_FP, NULL, "%s ", strbuf);
> > > +}  
> >
> > Instead of having two sets of prints, is it possible to do this
> >         print_nl();
> >         print_string(PRINT_FP, NULL, "\t", NULL);
> >
> >         open_json_array(PRINT_ANY, name);
> >         open_json_object(NULL);
> >         print_0xhex(PRINT_ANY, "ver", " %02x", ver);
> >         print_0xhex(PRINT_ANY, "idx", ":%08x", idx);
> >         print_0xhex(PRINT_ANY, "dir", ":%02x", dir);
> >         print_0xhex(PRINT_ANY, "hwid", ":%02x", hwid)
> >         close_json_object();
> >         close_json_array(PRINT_ANY, " ");  
> Hi Stephen,
> 
> This's not gonna work. as the output will be:
> {"ver":"0x2","idx":"0","dir":"0x1","hwid":"0x2"}  (string)
> instead of
> {"ver":2,"index":0,"dir":1,"hwid":2} (number)
> 
> >
> > Also, you seem to not hear the request to not use opaque hex values
> > in the iproute2 interface. The version, index, etc should be distinct
> > parameter values not a hex string.  
> The opts STRING, especially these like "XX:YY:ZZ" are represented
> as hex string on both adding and dumping. It is to keep consistent with
> geneve_opts in m_tunnel_key and f_flower,  see

There are several different requests.

 1. The format of the output must match the input.
 2. Printing values in hex would be nice if they are bit fields
 3. If non json uses hex, then json should use hex
    json is type less so { "ver":2 } and { "ver":"0x2" } are the same