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)
This commit is contained in:
parent
e50821abe7
commit
a08362ce46
@ -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);
|
||||
|
||||
|
@ -101,6 +101,11 @@ int vnet_sysctl_handle_uint(SYSCTL_HANDLER_ARGS);
|
||||
#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 *vnet);
|
||||
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 */
|
||||
|
||||
/*
|
||||
|
@ -178,6 +178,14 @@ SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt,
|
||||
"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_AUTO, debug, CTLFLAG_RW,
|
||||
|
||||
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,
|
||||
|
@ -452,11 +452,7 @@ sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS)
|
||||
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_ARGS)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user