ip -6 route shows incorrect route expiry times
Subsystems (3)
This looks like a unit conversion error, spotted in Red Hat FC2. On it's own, it doesn't look like there's anything wrong, until you look at two copies of the output 10 seconds apart:
rmk@dyn-67:[bk]:<1030> /sbin/ip -6 route; sleep 10; /sbin/ip -6 route default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 169sec mtu 1500 advmss 1440
default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 168sec mtu 1500 advmss 1440
It appears that the expiry seconds here are actually in units of 10 seconds. Maybe someone's double-converting kernel Hz to user Hz?
Signature · 1 line
Russell King
In article <[email protected]> (at Sun, 30 Jan 2005 16:08:40 +0000), Russell King <[email protected]> says:
Quoted 8 lines
rmk@dyn-67:[bk]:<1030>
/sbin/ip-6 route; sleep 10;/sbin/ip-6 route default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 169sec mtu 1500 advmss 1440
default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 168sec mtu 1500 advmss 1440It appears that the expiry seconds here are actually in units of 10 seconds. Maybe someone's double-converting kernel Hz to user Hz?
Kernel exports in USER_HZ.
iproute2 seem to convert it again; workaround is to do "export HZ=100".
--yoshfuji
In article <[email protected]> (at Mon, 31 Jan 2005 01:29:10 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:
Quoted 5 lines
Quoted 2 lines
It appears that the expiry seconds here are actually in units of 10 seconds. Maybe someone's double-converting kernel Hz to user Hz?
Kernel exports in
USER_HZ.
iproute2 seem to convert it again; workaround is to do "export HZ=100".
~~~~~~~~~~~~~
This is example. Of course, this depends on your arch.
--yoshfuji
Quoted 9 lines · On Mon, 31 Jan 2005, YOSHIFUJI Hideaki / [iso-2022-jp] �������� wrote:
In article <[email protected]> (at Mon, 31 Jan 2005 01:29:10 +0900 (JST)), YOSHIFUJI Hideaki / �������� <[email protected]> says:
Quoted 5 lines
Quoted 2 lines
It appears that the expiry seconds here are actually in units of 10 seconds. Maybe someone's double-converting kernel Hz to user Hz?
Kernel exports in
USER_HZ.
iproute2 seem to convert it again; workaround is to do "export HZ=100".~~~~~~~~~~~~~This is example. Of course, this depends on your arch.
Please, couldn't the lifetimes be passed to userspace in a architecture indepentent unit like whole seconds?
I don't think any routing protocols need a sub-second resolution for the lifetimes but if they do, why not use milliseconds? Better still, why not add a new attribute with a struct timespec or timeval to store the sub-second lifetimes for those who need them?
Btw. we have the same HZ problem in many /proc files.
Here too I would like to see a millisecond based interface in addition to the existing USER_HZ/jiffies/second based one. This especially applies to values like base_reachable_time and retrans_time, which are originally defined as millisecond values in the specification (RFC 2461).
Regards,
Ville
--
Ville Nuorvala
Research Assistant, Institute of Digital Communications, Helsinki University of Technology
email: [email protected], phone: +358 (0)9 451 5257
Quoted 9 lines · YOSHIFUJI Hideaki / $B5HF#1QL@ wrote:
In article <[email protected]> (at Sun, 30 Jan 2005 16:08:40 +0000), Russell King <[email protected]> says:
Quoted 6 lines
rmk@dyn-67:[bk]:<1030>
/sbin/ip-6 route; sleep 10;/sbin/ip-6 route default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 169sec mtu 1500 advmss 1440
default via fe80::a00:2bff:fe95:1d7b dev eth0 proto kernel metric 1024
expires 168sec mtu 1500 advmss 1440
Quoted 7 lines
Quoted 3 lines
It appears that the expiry seconds here are actually in units of 10 seconds. Maybe someone's double-converting kernel Hz to user Hz?
Kernel exports in
USER_HZ.
iproute2 seem to convert it again; workaround is to do "export HZ=100".
I've sent this fix to Stephen yesterday.
Regards
Patrick
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/01/29 10:59:53+01:00 [email protected]
# Use USER_HZ where necessary
#
# BitKeeper/etc/logging_ok
# 2005/01/29 10:59:51+01:00 [email protected] +1 -0
# Logging to [email protected] accepted
#
# tc/tc_util.c # 2005/01/29 10:59:48+01:00 [email protected] +1 -1 # Use USER_HZ where necessary # # lib/utils.c # 2005/01/29 10:59:48+01:00 [email protected] +7 -0 # Use USER_HZ where necessary # # ip/iproute.c # 2005/01/29 10:59:48+01:00 [email protected] +3 -3 # Use USER_HZ where necessary # # include/utils.h # 2005/01/29 10:59:48+01:00 [email protected] +10 -0 # Use USER_HZ where necessary # diff -Nru a/include/utils.h b/include/utils.h --- a/include/utils.h 2005-01-30 18:08:57 +01:00 +++ b/include/utils.h 2005-01-30 18:08:57 +01:00 @@ -113,4 +113,14 @@ return __iproute2_hz_internal; }
+extern int __iproute2_user_hz_internal;
+extern int __get_user_hz(void);
+
+static __inline__ int get_user_hz(void)
+{
+ if (__iproute2_user_hz_internal == 0)
+ __iproute2_user_hz_internal = __get_user_hz();
+ return __iproute2_user_hz_internal;
+}
+
#endif /* __UTILS_H__ */
ip/iproute.c +3 -3
@@ -412,7 +412,7 @@struct rta_cacheinfo *ci =RTA_DATA (tb[RTA_CACHEINFO ]);static int hz;if (!hz) - hz =get_hz (); + hz =get_user_hz ();if (ci->rta_expires !=0 )fprintf (fp," expires %dsec" , ci->rta_expires/hz);if (ci->rta_error !=0 )
@@ -439,7 +439,7 @@if ((r->rtm_flags &RTM_F_CLONED ) || (ci && ci->rta_expires)) {static int hz;if (!hz) - hz =get_hz (); + hz =get_user_hz ();if (r->rtm_flags &RTM_F_CLONED )fprintf (fp,"%s cache " , _SL_);if (ci->rta_expires)
@@ -491,7 +491,7 @@if (i-2 <sizeof (mx_names)/sizeof (char *))fprintf (fp," %s" , mx_names[i-2 ]);else -fprintf (fp," metric%d" , i); +fprintf (fp," metric %d" , i);if (mxlock & (1 <<i))fprintf (fp," lock" );
lib/utils.c +7 -0
@@ -383,6 +383,13 @@return HZ ; } +int __iproute2_user_hz_internal; + +int __get_user_hz (void ) +{ +return sysconf (_SC_CLK_TCK); +} +const char *rt_addr_n2a (int af,int len,const void *addr,char *buf,int buflen) {switch (af) {
tc/tc_util.c +1 -1
@@ -417,7 +417,7 @@void print_tm (FILE * f,const struct tcf_t *tm) { -int hz =get_hz (); +int hz =get_user_hz ();if (tm->install !=0 )fprintf (f," installed %d sec" , tm->install/hz);if (tm->lastuse !=0 )
David S. Miller
maintainerQuoted 4 lines · On Sun, 30 Jan 2005 18:09:56 +0100 Patrick McHardy <[email protected]> wrote:
Quoted 3 lines
Kernel exports in
USER_HZ.
iproute2 seem to convert it again; workaround is to do "export HZ=100".I've sent this fix to Stephen yesterday.
"HZ" should be defined in userspace as 100.
Only the kernel should ever be able to see other settings. That is true even if userspace includes kernel headers. For example, on sparc64 asm/param.h does this:
#ifdef __KERNEL__
# define HZ 1000 /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) #endif
#ifndef HZ
#define HZ 100
#endif