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, 9 Aug 2018 09:07:23 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Eelco Chaudron <echaudro@...hat.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net
Subject: Re: [PATCH iproute2/net-next] tc_util: Add support for showing
 TCA_STATS_BASIC_HW statistics

On Thu,  9 Aug 2018 11:16:02 -0400
Eelco Chaudron <echaudro@...hat.com> wrote:

>  
> +static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)
> +{
> +	struct gnet_stats_basic bs = {0};

If not present don't print it rather than printing zero.

> +	struct gnet_stats_basic bs_hw = {0};

This initialization is unnecessary since you always overwrite it.

> +
> +	if (!tbs[TCA_STATS_BASIC_HW])
> +		return;
> +
> +	memcpy(&bs_hw, RTA_DATA(tbs[TCA_STATS_BASIC_HW]),
> +	       MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC_HW]), sizeof(bs_hw)));
> +
> +	if (bs_hw.bytes == 0 && bs_hw.packets == 0)
> +		return;
> +
> +	if (tbs[TCA_STATS_BASIC]) {
> +		memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]),
> +		       MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]),
> +			   sizeof(bs)));
> +	}
> +
> +	if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
> +		print_string(PRINT_FP, NULL, "\n%s", prefix);

Please use the magic string _SL_ to allow supporting single line output mode.

> +		print_lluint(PRINT_ANY, "sw_bytes",
> +			     "Sent software %llu bytes",
> +			     bs.bytes - bs_hw.bytes);
> +		print_uint(PRINT_ANY, "sw_packets", " %u pkt",
> +			   bs.packets - bs_hw.packets);
> +	}
> +
> +	print_string(PRINT_FP, NULL, "\n%s", prefix);
> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
> +		     bs_hw.bytes);
> +	print_uint(PRINT_ANY, "hw_packets", " %u pkt", bs_hw.packets);
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ