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  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 2 Oct 2012 17:26:33 -0700
From:	Stephen Hemminger <shemminger@...tta.com>
To:	Julian Anastasov <ja@....bg>
Cc:	Eric Dumazet <eric.dumazet@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH v2] iproute2: add support for tcp_metrics

On Wed, 3 Oct 2012 03:21:08 +0300 (EEST)
Julian Anastasov <ja@....bg> wrote:

> 	Something like this in process_msg?:
> 
> case TCP_METRIC_RTT:
> 	fprintf(fp, "%lluus",
> 		((__u64) val * 1000) >> 3);
> 	break;
> case TCP_METRIC_RTTVAR:
> 	fprintf(fp, "%lluus",
> 		((__u64) val * 1000) >> 2);
> 	break;
> 
> 	And may be variant without __u64 should be fine?

Remember u64 is not always same as unsigned long long.
One safe way of handling this is:

#include <inttypes.h>
...
 
 case TCP_METRIC_RTT:
	fprintf(fp, "%"PRIu64"us",
 		((__u64) val * 1000) >> 3);
 	break;
 case TCP_METRIC_RTTVAR:
 	fprintf(fp, "%"PRIu64"us",
 		((__u64) val * 1000) >> 2);
 	break;

Also make sure metrics work independent of kernel HZ.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists