lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Oct 2020 01:48:58 +0200
From:   Petr Machata <me@...chata.org>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        dsahern@...il.com, john.fastabend@...il.com, jiri@...dia.com,
        idosch@...dia.com
Subject: Re: [PATCH iproute2-next 15/15] dcb: Add a subtool for the DCB ETS object


Stephen Hemminger <stephen@...workplumber.org> writes:

> On Tue, 20 Oct 2020 22:43:37 +0200
> Petr Machata <me@...chata.org> wrote:
>
>> Jakub Kicinski <kuba@...nel.org> writes:
>>
>> > On Tue, 20 Oct 2020 02:58:23 +0200 Petr Machata wrote:
>> >> +static void dcb_ets_print_cbs(FILE *fp, const struct ieee_ets *ets)
>> >> +{
>> >> +	print_string(PRINT_ANY, "cbs", "cbs %s ", ets->cbs ? "on" : "off");
>> >> +}
>> >
>> > I'd personally lean in the direction ethtool is taking and try to limit
>> > string values in json output as much as possible. This would be a good
>> > fit for bool.
>>
>> Yep, makes sense. The value is not user-toggleable, so the on / off
>> there is just arbitrary.
>>
>> I'll consider it for "willing" as well. That one is user-toggleable, and
>> the "on" / "off" makes sense for consistency with the command line. But
>> that doesn't mean it can't be a boolean in JSON.
>
> There are three ways of representing a boolean. You chose the worst.
> Option 1: is to use a json null value to indicate presence.
>       this works well for a flag.
> Option 2: is to use json bool.
> 	this looks awkward in non-json output
> Option 3: is to use a string
>      	but this makes the string output something harder to consume
> 	in json.

What seems to be used commonly for these on/off toggles is the following
pattern:

	print_string(PRINT_FP, NULL, "willing %s ", ets->willing ? "on" : "off");
	print_bool(PRINT_JSON, "willing", NULL, true);

That way the JSON output is easy to query and the FP output is obvious
and compatible with the command line. Does that work for you?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ