[radvd-devel-l] [PATCH] retrans_time takes USER_HZ, not seconds.

Jim Paris jim at jtan.com
Wed Jan 23 21:38:37 EST 2008


Looking at the Linux source, it seems /proc/sys/net/ipv6/neigh/*/retrans_time
takes units of USER_HZ, not seconds.  However, knowing the actual
USER_HZ from userspace doesn't seem to be easy (sysconf(_SC_CLK_TCK)
is hardcoded in glibc).  This patch (on top of my privsep one)
changes it to assume USER_HZ=100.  Any suggestions on a better way to 
handle it?  Being wrong isn't too bad because this only gets used when
retrans_time_ms doesn't exist, which is <2.6.12 or so.

-jim


 device-linux.c  |    4 ++--
 privsep-linux.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/device-linux.c b/device-linux.c
index b007187..4af1baf 100644
--- a/device-linux.c
+++ b/device-linux.c
@@ -286,7 +286,7 @@ set_interface_reachtime(const char *iface, uint32_t rtime)
 		ret = set_interface_var(iface,
 					PROC_SYS_IP6_BASEREACHTIME,
 					"BaseReachableTimer",
-					rtime / 1000);
+					rtime / 1000); /* sec */
 	return ret;
 }
 
@@ -306,7 +306,7 @@ set_interface_retranstimer(const char *iface, uint32_t rettimer)
 		ret = set_interface_var(iface,
 					PROC_SYS_IP6_RETRANSTIMER,
 					"RetransTimer",
-					rettimer / 1000);
+					rettimer / 10); /* XXX user_hz */
 	return ret;
 }
 
diff --git a/privsep-linux.c b/privsep-linux.c
index 3007993..28238e2 100644
--- a/privsep-linux.c
+++ b/privsep-linux.c
@@ -82,7 +82,7 @@ privsep_read_loop(void)
 			ret = privsep_set(cmd.iface, PROC_SYS_IP6_BASEREACHTIME_MS, cmd.val);
 			if (ret == 0)
 				break;
-			privsep_set(cmd.iface, PROC_SYS_IP6_BASEREACHTIME, cmd.val / 1000);
+			privsep_set(cmd.iface, PROC_SYS_IP6_BASEREACHTIME, cmd.val / 1000); /* sec */
 			break;
 
 		case SET_INTERFACE_RETRANSTIMER:
@@ -91,7 +91,7 @@ privsep_read_loop(void)
 			ret = privsep_set(cmd.iface, PROC_SYS_IP6_RETRANSTIMER_MS, cmd.val);
 			if (ret == 0)
 				break;
-			privsep_set(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, cmd.val / 1000);
+			privsep_set(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, cmd.val / 10); /* XXX user_hz */
 			break;
 
 		default:
-- 
1.5.3.4



More information about the radvd-devel-l mailing list