Commit cc1ff32a authored by Jon Grimm's avatar Jon Grimm

[SCTP] Change sysctl settable timers to ms granularity (rmlayer@us.ibm.com)

parent 247d0d19
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
* Daisy Chang <daisyc@us.ibm.com> * Daisy Chang <daisyc@us.ibm.com>
* Sridhar Samudrala <sri@us.ibm.com> * Sridhar Samudrala <sri@us.ibm.com>
* Ardelle Fan <ardelle.fan@intel.com> * Ardelle Fan <ardelle.fan@intel.com>
* Ryan Layer <rmlayer@us.ibm.com>
* *
* Any bugs reported given to us we will try to fix... any fixes shared will * Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release. * be incorporated into the next SCTP release.
...@@ -311,6 +312,11 @@ void sctp_sysctl_unregister(void); ...@@ -311,6 +312,11 @@ void sctp_sysctl_unregister(void);
#else #else
static inline void sctp_sysctl_register(void) { return; } static inline void sctp_sysctl_register(void) { return; }
static inline void sctp_sysctl_unregister(void) { return; } static inline void sctp_sysctl_unregister(void) { return; }
static inline int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen, void **context) {
return -ENOSYS;
}
#endif #endif
/* Size of Supported Address Parameter for 'x' address types. */ /* Size of Supported Address Parameter for 'x' address types. */
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
* Mingqin Liu <liuming@us.ibm.com> * Mingqin Liu <liuming@us.ibm.com>
* Jon Grimm <jgrimm@us.ibm.com> * Jon Grimm <jgrimm@us.ibm.com>
* Ardelle Fan <ardelle.fan@intel.com> * Ardelle Fan <ardelle.fan@intel.com>
* Ryan Layer <rmlayer@us.ibm.com>
* *
* Any bugs reported given to us we will try to fix... any fixes shared will * Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release. * be incorporated into the next SCTP release.
...@@ -42,42 +43,54 @@ ...@@ -42,42 +43,54 @@
#include <net/sctp/structs.h> #include <net/sctp/structs.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
static ctl_handler sctp_sysctl_jiffies_ms;
static long rto_timer_min = 0;
static long rto_timer_max = 86400000; /* One day */
static ctl_table sctp_table[] = { static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_INITIAL, .ctl_name = NET_SCTP_RTO_INITIAL,
.procname = "rto_initial", .procname = "rto_initial",
.data = &sctp_rto_initial, .data = &sctp_rto_initial,
.maxlen = sizeof(int), .maxlen = sizeof(long),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
.strategy = &sysctl_jiffies .strategy = &sctp_sysctl_jiffies_ms,
.extra1 = &rto_timer_min,
.extra2 = &rto_timer_max
}, },
{ {
.ctl_name = NET_SCTP_RTO_MIN, .ctl_name = NET_SCTP_RTO_MIN,
.procname = "rto_min", .procname = "rto_min",
.data = &sctp_rto_min, .data = &sctp_rto_min,
.maxlen = sizeof(int), .maxlen = sizeof(long),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
.strategy = &sysctl_jiffies .strategy = &sctp_sysctl_jiffies_ms,
.extra1 = &rto_timer_min,
.extra2 = &rto_timer_max
}, },
{ {
.ctl_name = NET_SCTP_RTO_MAX, .ctl_name = NET_SCTP_RTO_MAX,
.procname = "rto_max", .procname = "rto_max",
.data = &sctp_rto_max, .data = &sctp_rto_max,
.maxlen = sizeof(int), .maxlen = sizeof(long),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
.strategy = &sysctl_jiffies .strategy = &sctp_sysctl_jiffies_ms,
.extra1 = &rto_timer_min,
.extra2 = &rto_timer_max
}, },
{ {
.ctl_name = NET_SCTP_VALID_COOKIE_LIFE, .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
.procname = "valid_cookie_life", .procname = "valid_cookie_life",
.data = &sctp_valid_cookie_life, .data = &sctp_valid_cookie_life,
.maxlen = sizeof(int), .maxlen = sizeof(long),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
.strategy = &sysctl_jiffies .strategy = &sctp_sysctl_jiffies_ms,
.extra1 = &rto_timer_min,
.extra2 = &rto_timer_max
}, },
{ {
.ctl_name = NET_SCTP_MAX_BURST, .ctl_name = NET_SCTP_MAX_BURST,
...@@ -183,3 +196,37 @@ void sctp_sysctl_unregister(void) ...@@ -183,3 +196,37 @@ void sctp_sysctl_unregister(void)
{ {
unregister_sysctl_table(sctp_sysctl_header); unregister_sysctl_table(sctp_sysctl_header);
} }
/* Strategy function to convert jiffies to milliseconds. */
static int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen, void **context) {
if (oldval) {
size_t olen;
if (oldlenp) {
if (get_user(olen, oldlenp))
return -EFAULT;
if (olen != sizeof (int))
return -EINVAL;
}
if (put_user((*(int *)(table->data) / HZ) * 1000,
(int *)oldval) ||
(oldlenp && put_user(sizeof (int), oldlenp)))
return -EFAULT;
}
if (newval && newlen) {
int new;
if (newlen != sizeof (int))
return -EINVAL;
if (get_user(new, (int *)newval))
return -EFAULT;
*(int *)(table->data) = (new * HZ) * 1000;
}
return 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment