Date: Tue, 21 Jul 2009 21:58:55 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r195814 - in head/sys: kern net netinet netinet6 Message-ID: <200907212158.n6LLwtKG023171@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bz Date: Tue Jul 21 21:58:55 2009 New Revision: 195814 URL: http://svn.freebsd.org/changeset/base/195814 Log: sysctl_msec_to_ticks is used with both virtualized and non-vrtiualized sysctls so we cannot used one common function. Add a macro to convert the arg1 in the virtualized case to vnet.h to not expose the maths to all over the code. Add a wrapper for the single virtualized call, properly handling arg1 and call the default implementation from there. Convert the two over places to use the new macro. Reviewed by: rwatson Approved by: re (kib) Modified: head/sys/kern/kern_sysctl.c head/sys/net/vnet.h head/sys/netinet/tcp_subr.c head/sys/netinet6/in6_proto.c Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Tue Jul 21 19:38:22 2009 (r195813) +++ head/sys/kern/kern_sysctl.c Tue Jul 21 21:58:55 2009 (r195814) @@ -948,11 +948,6 @@ sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS { int error, s, tt; -#ifdef VIMAGE - if (arg1 != NULL) - arg1 = (void *)(TD_TO_VNET(req->td)->vnet_data_base + - (uintptr_t)arg1); -#endif tt = *(int *)arg1; s = (int)((int64_t)tt * 1000 / hz); Modified: head/sys/net/vnet.h ============================================================================== --- head/sys/net/vnet.h Tue Jul 21 19:38:22 2009 (r195813) +++ head/sys/net/vnet.h Tue Jul 21 21:58:55 2009 (r195814) @@ -101,6 +101,11 @@ int vnet_sysctl_handle_uint(SYSCTL_HANDL #define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, vnet_sysctl_handle_uint, "IU", descr) +#define VNET_SYSCTL_ARG(req, arg1) do { \ + if (arg1 != NULL) \ + arg1 = (void *)(TD_TO_VNET((req)->td)->vnet_data_base + \ + (uintptr_t)(arg1)); \ +} while (0) #endif /* SYSCTL_OID */ /* @@ -141,6 +146,7 @@ void vnet_data_destroy(struct vnet *vne SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) #define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) +#define VNET_SYSCTL_ARG(req, arg1) #endif /* SYSCTL_OID */ /* Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Tue Jul 21 19:38:22 2009 (r195813) +++ head/sys/netinet/tcp_subr.c Tue Jul 21 21:58:55 2009 (r195814) @@ -178,6 +178,14 @@ SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_V "Default TCP Maximum Segment Size for IPv6"); #endif +static int +vnet_sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) +{ + + VNET_SYSCTL_ARG(req, arg1); + return (sysctl_msec_to_ticks(oidp, arg1, arg2, req)); +} + /* * Minimum MSS we accept and use. This prevents DoS attacks where * we are forced to a ridiculous low MSS like 20 and send hundreds @@ -236,7 +244,7 @@ SYSCTL_INT(_net_inet_tcp_inflight, OID_A SYSCTL_VNET_PROC(_net_inet_tcp_inflight, OID_AUTO, rttthresh, CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(tcp_inflight_rttthresh), 0, - sysctl_msec_to_ticks, "I", + vnet_sysctl_msec_to_ticks, "I", "RTT threshold below which inflight will deactivate itself"); SYSCTL_VNET_INT(_net_inet_tcp_inflight, OID_AUTO, min, CTLFLAG_RW, Modified: head/sys/netinet6/in6_proto.c ============================================================================== --- head/sys/netinet6/in6_proto.c Tue Jul 21 19:38:22 2009 (r195813) +++ head/sys/netinet6/in6_proto.c Tue Jul 21 21:58:55 2009 (r195814) @@ -452,11 +452,7 @@ sysctl_ip6_temppltime(SYSCTL_HANDLER_ARG int error = 0; int old; -#ifdef VIMAGE - if (arg1 != NULL) - arg1 = (void *)(TD_TO_VNET(req->td)->vnet_data_base + - (uintptr_t)arg1); -#endif + VNET_SYSCTL_ARG(req, arg1); error = SYSCTL_OUT(req, arg1, sizeof(int)); if (error || !req->newptr) @@ -477,11 +473,7 @@ sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARG int error = 0; int old; -#ifdef VIMAGE - if (arg1 != NULL) - arg1 = (void *)(TD_TO_VNET(req->td)->vnet_data_base + - (uintptr_t)arg1); -#endif + VNET_SYSCTL_ARG(req, arg1); error = SYSCTL_OUT(req, arg1, sizeof(int)); if (error || !req->newptr)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907212158.n6LLwtKG023171>