All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roi Dayan <roid@nvidia.com>
To: David Ahern <dsahern@gmail.com>, <netdev@vger.kernel.org>,
	"Stephen Hemminger" <stephen@networkplumber.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Paul Blakey <paulb@nvidia.com>
Subject: Re: [PATCH iproute2-next] police: Add support for json output
Date: Thu, 3 Jun 2021 10:27:55 +0300	[thread overview]
Message-ID: <a745235f-ff64-3f7f-1264-198649795856@nvidia.com> (raw)
In-Reply-To: <e107ce61-58bf-d106-3891-46c83e3bfe8f@gmail.com>



On 2021-06-02 5:29 PM, David Ahern wrote:
> On 5/27/21 7:07 AM, Roi Dayan wrote:
>> @@ -300,13 +300,13 @@ static int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
>>   	    RTA_PAYLOAD(tb[TCA_POLICE_RATE64]) >= sizeof(rate64))
>>   		rate64 = rta_getattr_u64(tb[TCA_POLICE_RATE64]);
>>   
>> -	fprintf(f, " police 0x%x ", p->index);
>> +	print_int(PRINT_ANY, "police", "police %d ", p->index);
> 
> this changes the output format from hex to decimal.
> 

hmm thanks for the review. actually I see another issue with this.
I missed this but this should actually be split into "kind" and "index".
And index should be unsigned as the other actions.
so we should have kind printed at the top of the function even if arg
is null and index here.

         print_string(PRINT_ANY, "kind", "%s", "police"); 

         if (arg == NULL) 

                 return 0;
...
         print_uint(PRINT_ANY, "index", "\t index %u ", p->index); 



then the json output should be this

            "actions": [ {
                     "order": 1,
                     "kind": "police",
                     "index": 1,


i'll send v2.


> 
>>   	tc_print_rate(PRINT_FP, NULL, "rate %s ", rate64);
>>   	buffer = tc_calc_xmitsize(rate64, p->burst);
>>   	print_size(PRINT_FP, NULL, "burst %s ", buffer);
>>   	print_size(PRINT_FP, NULL, "mtu %s ", p->mtu);
>>   	if (show_raw)
>> -		fprintf(f, "[%08x] ", p->burst);
>> +		print_hex(PRINT_FP, NULL, "[%08x] ", p->burst);
>>   
>>   	prate64 = p->peakrate.rate;
>>   	if (tb[TCA_POLICE_PEAKRATE64] &&
> 
> 

  reply	other threads:[~2021-06-03  7:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 13:07 [PATCH iproute2-next] police: Add support for json output Roi Dayan
2021-06-02 14:29 ` David Ahern
2021-06-03  7:27   ` Roi Dayan [this message]
2021-06-03 15:40     ` Stephen Hemminger
2021-06-03 16:04       ` Roi Dayan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a745235f-ff64-3f7f-1264-198649795856@nvidia.com \
    --to=roid@nvidia.com \
    --cc=dsahern@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulb@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.