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] [day] [month] [year] [list]
Date:   Sun, 18 Apr 2021 01:36:22 +0200
From:   Paolo Lungaroni <paolo.lungaroni@...roma2.it>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
        Jakub Kicinski <kuba@...nel.org>,
        Stefano Salsano <stefano.salsano@...roma2.it>,
        Ahmed Abdelsalam <ahabdels.dev@...il.com>,
        Andrea Mayer <andrea.mayer@...roma2.it>,
        Paolo Lungaroni <paolo.lungaroni@...roma2.it>
Subject: Re: [RFC iproute2-next v2] seg6: add counters support for SRv6
 Behaviors

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

> On Thu, 15 Apr 2021 20:06:43 +0200
> Paolo Lungaroni <paolo.lungaroni@...roma2.it> wrote:
>
>> +	if (is_json_context())
>> +		open_json_object("stats64");
>> +
>> +	if (tb[SEG6_LOCAL_CNT_PACKETS]) {
>> +		packets = rta_getattr_u64(tb[SEG6_LOCAL_CNT_PACKETS]);
>> +		if (is_json_context()) {
>> +			print_u64(PRINT_JSON, "packets", NULL, packets);
>> +		} else {
>> +			print_string(PRINT_FP, NULL, "%s ", "packets");
>> +			print_num(fp, 1, packets);
>> +		}
>> +	}
>> +
>> +	if (tb[SEG6_LOCAL_CNT_BYTES]) {
>> +		bytes = rta_getattr_u64(tb[SEG6_LOCAL_CNT_BYTES]);
>> +		if (is_json_context()) {
>> +			print_u64(PRINT_JSON, "bytes", NULL, bytes);
>> +		} else {
>> +			print_string(PRINT_FP, NULL, "%s ", "bytes");
>> +			print_num(fp, 1, bytes);
>> +		}
>> +	}
>> +
>> +	if (tb[SEG6_LOCAL_CNT_ERRORS]) {
>> +		errors = rta_getattr_u64(tb[SEG6_LOCAL_CNT_ERRORS]);
>> +		if (is_json_context()) {
>> +			print_u64(PRINT_JSON, "errors", NULL, errors);
>> +		} else {
>> +			print_string(PRINT_FP, NULL, "%s ", "errors");
>> +			print_num(fp, 1, errors);
>> +		}
>> +	}
>> +
>> +	if (is_json_context())
>> +		close_json_object();
>
>
> The code would be cleaner with doing if (is_json_context()) once at  
> outer loop.
> See print_vf_stats64.

Hi Stephen,

thank you for your suggestion. We will change the code as you suggest.

Paolo.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ