From a4684d742dbebeb758bf8f2bdada11e417153cd8 Mon Sep 17 00:00:00 2001 From: Andre Oppermann Date: Thu, 16 Feb 2006 15:40:36 +0000 Subject: [PATCH] Make sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) generally available instead of being private to tcp_timer.c. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 3 days --- sys/kern/kern_sysctl.c | 26 ++++++++++++++++++++++++++ sys/netinet/tcp_timer.c | 20 -------------------- sys/sys/sysctl.h | 1 + 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 38fb5dc86ed..aaa3dc3c52c 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -822,6 +822,32 @@ sysctl_handle_int(SYSCTL_HANDLER_ARGS) return (error); } + +/* + * Based on on sysctl_handle_int() convert milliseconds into ticks. + */ + +int +sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) +{ + int error, s, tt; + + tt = *(int *)oidp->oid_arg1; + s = (int)((int64_t)tt * 1000 / hz); + + error = sysctl_handle_int(oidp, &s, 0, req); + if (error || !req->newptr) + return (error); + + tt = (int)((int64_t)s * hz / 1000); + if (tt < 1) + return (EINVAL); + + *(int *)oidp->oid_arg1 = tt; + return (0); +} + + /* * Handle a long, signed or unsigned. arg1 points to it. */ diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 9726f677239..b9d24a8a4ec 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -63,26 +63,6 @@ #include #endif -static int -sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) -{ - int error, s, tt; - - tt = *(int *)oidp->oid_arg1; - s = (int)((int64_t)tt * 1000 / hz); - - error = sysctl_handle_int(oidp, &s, 0, req); - if (error || !req->newptr) - return (error); - - tt = (int)((int64_t)s * hz / 1000); - if (tt < 1) - return (EINVAL); - - *(int *)oidp->oid_arg1 = tt; - return (0); -} - int tcp_keepinit; SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPINIT, keepinit, CTLTYPE_INT|CTLFLAG_RW, &tcp_keepinit, 0, sysctl_msec_to_ticks, "I", ""); diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index c9532aca6d5..8aeca9fdbee 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -168,6 +168,7 @@ struct sysctl_oid { #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) int sysctl_handle_int(SYSCTL_HANDLER_ARGS); +int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); int sysctl_handle_long(SYSCTL_HANDLER_ARGS); int sysctl_handle_intptr(SYSCTL_HANDLER_ARGS); int sysctl_handle_string(SYSCTL_HANDLER_ARGS);