diff options
author | Vladislav Yasevich <vladislav.yasevich@hp.com> | 2006-08-22 16:29:17 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 17:55:39 -0400 |
commit | 3fd091e73b81f131e1567c4d4a1ec042940bf2f7 (patch) | |
tree | c08ebbeee329bbc31cb578db1dddde7394431f5f /net/sctp | |
parent | ce556b3a591fff3bebf8c5590a86aa98e1b2f153 (diff) |
[SCTP]: Remove multiple levels of msecs to jiffies conversions.
The SCTP sysctl entries are displayed in milliseconds, but stored
internally in jiffies. This results in multiple levels of msecs to
jiffies conversion and as a result produces a truncation error. This
patch makes things consistent in that we store and display defaults
in milliseconds and only convert once for use by association.
This patch also adds some sane min/max values so that we don't go off
the deep end.
Signed-off-by: Vladislav Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/protocol.c | 2 | ||||
-rw-r--r-- | net/sctp/socket.c | 15 | ||||
-rw-r--r-- | net/sctp/sysctl.c | 140 | ||||
-rw-r--r-- | net/sctp/transport.c | 2 |
4 files changed, 72 insertions, 87 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1ab03a27a76e..5692ef5485d3 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1049,7 +1049,7 @@ SCTP_STATIC __init int sctp_init(void) | |||
1049 | sctp_rto_beta = SCTP_RTO_BETA; | 1049 | sctp_rto_beta = SCTP_RTO_BETA; |
1050 | 1050 | ||
1051 | /* Valid.Cookie.Life - 60 seconds */ | 1051 | /* Valid.Cookie.Life - 60 seconds */ |
1052 | sctp_valid_cookie_life = 60 * HZ; | 1052 | sctp_valid_cookie_life = SCTP_DEFAULT_COOKIE_LIFE; |
1053 | 1053 | ||
1054 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | 1054 | /* Whether Cookie Preservative is enabled(1) or not(0) */ |
1055 | sctp_cookie_preserve_enable = 1; | 1055 | sctp_cookie_preserve_enable = 1; |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 3b6e82cb372f..7c1dbb1d10df 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3045,14 +3045,14 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3045 | sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; | 3045 | sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; |
3046 | sp->initmsg.sinit_max_instreams = sctp_max_instreams; | 3046 | sp->initmsg.sinit_max_instreams = sctp_max_instreams; |
3047 | sp->initmsg.sinit_max_attempts = sctp_max_retrans_init; | 3047 | sp->initmsg.sinit_max_attempts = sctp_max_retrans_init; |
3048 | sp->initmsg.sinit_max_init_timeo = jiffies_to_msecs(sctp_rto_max); | 3048 | sp->initmsg.sinit_max_init_timeo = sctp_rto_max; |
3049 | 3049 | ||
3050 | /* Initialize default RTO related parameters. These parameters can | 3050 | /* Initialize default RTO related parameters. These parameters can |
3051 | * be modified for with the SCTP_RTOINFO socket option. | 3051 | * be modified for with the SCTP_RTOINFO socket option. |
3052 | */ | 3052 | */ |
3053 | sp->rtoinfo.srto_initial = jiffies_to_msecs(sctp_rto_initial); | 3053 | sp->rtoinfo.srto_initial = sctp_rto_initial; |
3054 | sp->rtoinfo.srto_max = jiffies_to_msecs(sctp_rto_max); | 3054 | sp->rtoinfo.srto_max = sctp_rto_max; |
3055 | sp->rtoinfo.srto_min = jiffies_to_msecs(sctp_rto_min); | 3055 | sp->rtoinfo.srto_min = sctp_rto_min; |
3056 | 3056 | ||
3057 | /* Initialize default association related parameters. These parameters | 3057 | /* Initialize default association related parameters. These parameters |
3058 | * can be modified with the SCTP_ASSOCINFO socket option. | 3058 | * can be modified with the SCTP_ASSOCINFO socket option. |
@@ -3061,8 +3061,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3061 | sp->assocparams.sasoc_number_peer_destinations = 0; | 3061 | sp->assocparams.sasoc_number_peer_destinations = 0; |
3062 | sp->assocparams.sasoc_peer_rwnd = 0; | 3062 | sp->assocparams.sasoc_peer_rwnd = 0; |
3063 | sp->assocparams.sasoc_local_rwnd = 0; | 3063 | sp->assocparams.sasoc_local_rwnd = 0; |
3064 | sp->assocparams.sasoc_cookie_life = | 3064 | sp->assocparams.sasoc_cookie_life = sctp_valid_cookie_life; |
3065 | jiffies_to_msecs(sctp_valid_cookie_life); | ||
3066 | 3065 | ||
3067 | /* Initialize default event subscriptions. By default, all the | 3066 | /* Initialize default event subscriptions. By default, all the |
3068 | * options are off. | 3067 | * options are off. |
@@ -3072,10 +3071,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3072 | /* Default Peer Address Parameters. These defaults can | 3071 | /* Default Peer Address Parameters. These defaults can |
3073 | * be modified via SCTP_PEER_ADDR_PARAMS | 3072 | * be modified via SCTP_PEER_ADDR_PARAMS |
3074 | */ | 3073 | */ |
3075 | sp->hbinterval = jiffies_to_msecs(sctp_hb_interval); | 3074 | sp->hbinterval = sctp_hb_interval; |
3076 | sp->pathmaxrxt = sctp_max_retrans_path; | 3075 | sp->pathmaxrxt = sctp_max_retrans_path; |
3077 | sp->pathmtu = 0; // allow default discovery | 3076 | sp->pathmtu = 0; // allow default discovery |
3078 | sp->sackdelay = jiffies_to_msecs(sctp_sack_timeout); | 3077 | sp->sackdelay = sctp_sack_timeout; |
3079 | sp->param_flags = SPP_HB_ENABLE | | 3078 | sp->param_flags = SPP_HB_ENABLE | |
3080 | SPP_PMTUD_ENABLE | | 3079 | SPP_PMTUD_ENABLE | |
3081 | SPP_SACKDELAY_ENABLE; | 3080 | SPP_SACKDELAY_ENABLE; |
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index dc6f3ff32358..633cd178654b 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c | |||
@@ -45,9 +45,10 @@ | |||
45 | #include <net/sctp/sctp.h> | 45 | #include <net/sctp/sctp.h> |
46 | #include <linux/sysctl.h> | 46 | #include <linux/sysctl.h> |
47 | 47 | ||
48 | static ctl_handler sctp_sysctl_jiffies_ms; | 48 | static int zero = 0; |
49 | static long rto_timer_min = 1; | 49 | static int one = 1; |
50 | static long rto_timer_max = 86400000; /* One day */ | 50 | static int timer_max = 86400000; /* ms in one day */ |
51 | static int int_max = INT_MAX; | ||
51 | static long sack_timer_min = 1; | 52 | static long sack_timer_min = 1; |
52 | static long sack_timer_max = 500; | 53 | static long sack_timer_max = 500; |
53 | 54 | ||
@@ -56,45 +57,45 @@ static ctl_table sctp_table[] = { | |||
56 | .ctl_name = NET_SCTP_RTO_INITIAL, | 57 | .ctl_name = NET_SCTP_RTO_INITIAL, |
57 | .procname = "rto_initial", | 58 | .procname = "rto_initial", |
58 | .data = &sctp_rto_initial, | 59 | .data = &sctp_rto_initial, |
59 | .maxlen = sizeof(long), | 60 | .maxlen = sizeof(unsigned int), |
60 | .mode = 0644, | 61 | .mode = 0644, |
61 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 62 | .proc_handler = &proc_dointvec_minmax, |
62 | .strategy = &sctp_sysctl_jiffies_ms, | 63 | .strategy = &sysctl_intvec, |
63 | .extra1 = &rto_timer_min, | 64 | .extra1 = &one, |
64 | .extra2 = &rto_timer_max | 65 | .extra2 = &timer_max |
65 | }, | 66 | }, |
66 | { | 67 | { |
67 | .ctl_name = NET_SCTP_RTO_MIN, | 68 | .ctl_name = NET_SCTP_RTO_MIN, |
68 | .procname = "rto_min", | 69 | .procname = "rto_min", |
69 | .data = &sctp_rto_min, | 70 | .data = &sctp_rto_min, |
70 | .maxlen = sizeof(long), | 71 | .maxlen = sizeof(unsigned int), |
71 | .mode = 0644, | 72 | .mode = 0644, |
72 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 73 | .proc_handler = &proc_dointvec_minmax, |
73 | .strategy = &sctp_sysctl_jiffies_ms, | 74 | .strategy = &sysctl_intvec, |
74 | .extra1 = &rto_timer_min, | 75 | .extra1 = &one, |
75 | .extra2 = &rto_timer_max | 76 | .extra2 = &timer_max |
76 | }, | 77 | }, |
77 | { | 78 | { |
78 | .ctl_name = NET_SCTP_RTO_MAX, | 79 | .ctl_name = NET_SCTP_RTO_MAX, |
79 | .procname = "rto_max", | 80 | .procname = "rto_max", |
80 | .data = &sctp_rto_max, | 81 | .data = &sctp_rto_max, |
81 | .maxlen = sizeof(long), | 82 | .maxlen = sizeof(unsigned int), |
82 | .mode = 0644, | 83 | .mode = 0644, |
83 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 84 | .proc_handler = &proc_dointvec_minmax, |
84 | .strategy = &sctp_sysctl_jiffies_ms, | 85 | .strategy = &sysctl_intvec, |
85 | .extra1 = &rto_timer_min, | 86 | .extra1 = &one, |
86 | .extra2 = &rto_timer_max | 87 | .extra2 = &timer_max |
87 | }, | 88 | }, |
88 | { | 89 | { |
89 | .ctl_name = NET_SCTP_VALID_COOKIE_LIFE, | 90 | .ctl_name = NET_SCTP_VALID_COOKIE_LIFE, |
90 | .procname = "valid_cookie_life", | 91 | .procname = "valid_cookie_life", |
91 | .data = &sctp_valid_cookie_life, | 92 | .data = &sctp_valid_cookie_life, |
92 | .maxlen = sizeof(long), | 93 | .maxlen = sizeof(unsigned int), |
93 | .mode = 0644, | 94 | .mode = 0644, |
94 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 95 | .proc_handler = &proc_dointvec_minmax, |
95 | .strategy = &sctp_sysctl_jiffies_ms, | 96 | .strategy = &sysctl_intvec, |
96 | .extra1 = &rto_timer_min, | 97 | .extra1 = &one, |
97 | .extra2 = &rto_timer_max | 98 | .extra2 = &timer_max |
98 | }, | 99 | }, |
99 | { | 100 | { |
100 | .ctl_name = NET_SCTP_MAX_BURST, | 101 | .ctl_name = NET_SCTP_MAX_BURST, |
@@ -102,7 +103,10 @@ static ctl_table sctp_table[] = { | |||
102 | .data = &sctp_max_burst, | 103 | .data = &sctp_max_burst, |
103 | .maxlen = sizeof(int), | 104 | .maxlen = sizeof(int), |
104 | .mode = 0644, | 105 | .mode = 0644, |
105 | .proc_handler = &proc_dointvec | 106 | .proc_handler = &proc_dointvec_minmax, |
107 | .strategy = &sysctl_intvec, | ||
108 | .extra1 = &zero, | ||
109 | .extra2 = &int_max | ||
106 | }, | 110 | }, |
107 | { | 111 | { |
108 | .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS, | 112 | .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS, |
@@ -110,7 +114,10 @@ static ctl_table sctp_table[] = { | |||
110 | .data = &sctp_max_retrans_association, | 114 | .data = &sctp_max_retrans_association, |
111 | .maxlen = sizeof(int), | 115 | .maxlen = sizeof(int), |
112 | .mode = 0644, | 116 | .mode = 0644, |
113 | .proc_handler = &proc_dointvec | 117 | .proc_handler = &proc_dointvec_minmax, |
118 | .strategy = &sysctl_intvec, | ||
119 | .extra1 = &one, | ||
120 | .extra2 = &int_max | ||
114 | }, | 121 | }, |
115 | { | 122 | { |
116 | .ctl_name = NET_SCTP_SNDBUF_POLICY, | 123 | .ctl_name = NET_SCTP_SNDBUF_POLICY, |
@@ -118,7 +125,8 @@ static ctl_table sctp_table[] = { | |||
118 | .data = &sctp_sndbuf_policy, | 125 | .data = &sctp_sndbuf_policy, |
119 | .maxlen = sizeof(int), | 126 | .maxlen = sizeof(int), |
120 | .mode = 0644, | 127 | .mode = 0644, |
121 | .proc_handler = &proc_dointvec | 128 | .proc_handler = &proc_dointvec, |
129 | .strategy = &sysctl_intvec | ||
122 | }, | 130 | }, |
123 | { | 131 | { |
124 | .ctl_name = NET_SCTP_RCVBUF_POLICY, | 132 | .ctl_name = NET_SCTP_RCVBUF_POLICY, |
@@ -126,7 +134,8 @@ static ctl_table sctp_table[] = { | |||
126 | .data = &sctp_rcvbuf_policy, | 134 | .data = &sctp_rcvbuf_policy, |
127 | .maxlen = sizeof(int), | 135 | .maxlen = sizeof(int), |
128 | .mode = 0644, | 136 | .mode = 0644, |
129 | .proc_handler = &proc_dointvec | 137 | .proc_handler = &proc_dointvec, |
138 | .strategy = &sysctl_intvec | ||
130 | }, | 139 | }, |
131 | { | 140 | { |
132 | .ctl_name = NET_SCTP_PATH_MAX_RETRANS, | 141 | .ctl_name = NET_SCTP_PATH_MAX_RETRANS, |
@@ -134,7 +143,10 @@ static ctl_table sctp_table[] = { | |||
134 | .data = &sctp_max_retrans_path, | 143 | .data = &sctp_max_retrans_path, |
135 | .maxlen = sizeof(int), | 144 | .maxlen = sizeof(int), |
136 | .mode = 0644, | 145 | .mode = 0644, |
137 | .proc_handler = &proc_dointvec | 146 | .proc_handler = &proc_dointvec_minmax, |
147 | .strategy = &sysctl_intvec, | ||
148 | .extra1 = &one, | ||
149 | .extra2 = &int_max | ||
138 | }, | 150 | }, |
139 | { | 151 | { |
140 | .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS, | 152 | .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS, |
@@ -142,18 +154,21 @@ static ctl_table sctp_table[] = { | |||
142 | .data = &sctp_max_retrans_init, | 154 | .data = &sctp_max_retrans_init, |
143 | .maxlen = sizeof(int), | 155 | .maxlen = sizeof(int), |
144 | .mode = 0644, | 156 | .mode = 0644, |
145 | .proc_handler = &proc_dointvec | 157 | .proc_handler = &proc_dointvec_minmax, |
158 | .strategy = &sysctl_intvec, | ||
159 | .extra1 = &one, | ||
160 | .extra2 = &int_max | ||
146 | }, | 161 | }, |
147 | { | 162 | { |
148 | .ctl_name = NET_SCTP_HB_INTERVAL, | 163 | .ctl_name = NET_SCTP_HB_INTERVAL, |
149 | .procname = "hb_interval", | 164 | .procname = "hb_interval", |
150 | .data = &sctp_hb_interval, | 165 | .data = &sctp_hb_interval, |
151 | .maxlen = sizeof(long), | 166 | .maxlen = sizeof(unsigned int), |
152 | .mode = 0644, | 167 | .mode = 0644, |
153 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 168 | .proc_handler = &proc_dointvec_minmax, |
154 | .strategy = &sctp_sysctl_jiffies_ms, | 169 | .strategy = &sysctl_intvec, |
155 | .extra1 = &rto_timer_min, | 170 | .extra1 = &one, |
156 | .extra2 = &rto_timer_max | 171 | .extra2 = &timer_max |
157 | }, | 172 | }, |
158 | { | 173 | { |
159 | .ctl_name = NET_SCTP_PRESERVE_ENABLE, | 174 | .ctl_name = NET_SCTP_PRESERVE_ENABLE, |
@@ -161,23 +176,26 @@ static ctl_table sctp_table[] = { | |||
161 | .data = &sctp_cookie_preserve_enable, | 176 | .data = &sctp_cookie_preserve_enable, |
162 | .maxlen = sizeof(int), | 177 | .maxlen = sizeof(int), |
163 | .mode = 0644, | 178 | .mode = 0644, |
164 | .proc_handler = &proc_dointvec | 179 | .proc_handler = &proc_dointvec, |
180 | .strategy = &sysctl_intvec | ||
165 | }, | 181 | }, |
166 | { | 182 | { |
167 | .ctl_name = NET_SCTP_RTO_ALPHA, | 183 | .ctl_name = NET_SCTP_RTO_ALPHA, |
168 | .procname = "rto_alpha_exp_divisor", | 184 | .procname = "rto_alpha_exp_divisor", |
169 | .data = &sctp_rto_alpha, | 185 | .data = &sctp_rto_alpha, |
170 | .maxlen = sizeof(int), | 186 | .maxlen = sizeof(int), |
171 | .mode = 0644, | 187 | .mode = 0444, |
172 | .proc_handler = &proc_dointvec | 188 | .proc_handler = &proc_dointvec, |
189 | .strategy = &sysctl_intvec | ||
173 | }, | 190 | }, |
174 | { | 191 | { |
175 | .ctl_name = NET_SCTP_RTO_BETA, | 192 | .ctl_name = NET_SCTP_RTO_BETA, |
176 | .procname = "rto_beta_exp_divisor", | 193 | .procname = "rto_beta_exp_divisor", |
177 | .data = &sctp_rto_beta, | 194 | .data = &sctp_rto_beta, |
178 | .maxlen = sizeof(int), | 195 | .maxlen = sizeof(int), |
179 | .mode = 0644, | 196 | .mode = 0444, |
180 | .proc_handler = &proc_dointvec | 197 | .proc_handler = &proc_dointvec, |
198 | .strategy = &sysctl_intvec | ||
181 | }, | 199 | }, |
182 | { | 200 | { |
183 | .ctl_name = NET_SCTP_ADDIP_ENABLE, | 201 | .ctl_name = NET_SCTP_ADDIP_ENABLE, |
@@ -185,7 +203,8 @@ static ctl_table sctp_table[] = { | |||
185 | .data = &sctp_addip_enable, | 203 | .data = &sctp_addip_enable, |
186 | .maxlen = sizeof(int), | 204 | .maxlen = sizeof(int), |
187 | .mode = 0644, | 205 | .mode = 0644, |
188 | .proc_handler = &proc_dointvec | 206 | .proc_handler = &proc_dointvec, |
207 | .strategy = &sysctl_intvec | ||
189 | }, | 208 | }, |
190 | { | 209 | { |
191 | .ctl_name = NET_SCTP_PRSCTP_ENABLE, | 210 | .ctl_name = NET_SCTP_PRSCTP_ENABLE, |
@@ -193,7 +212,8 @@ static ctl_table sctp_table[] = { | |||
193 | .data = &sctp_prsctp_enable, | 212 | .data = &sctp_prsctp_enable, |
194 | .maxlen = sizeof(int), | 213 | .maxlen = sizeof(int), |
195 | .mode = 0644, | 214 | .mode = 0644, |
196 | .proc_handler = &proc_dointvec | 215 | .proc_handler = &proc_dointvec, |
216 | .strategy = &sysctl_intvec | ||
197 | }, | 217 | }, |
198 | { | 218 | { |
199 | .ctl_name = NET_SCTP_SACK_TIMEOUT, | 219 | .ctl_name = NET_SCTP_SACK_TIMEOUT, |
@@ -201,8 +221,8 @@ static ctl_table sctp_table[] = { | |||
201 | .data = &sctp_sack_timeout, | 221 | .data = &sctp_sack_timeout, |
202 | .maxlen = sizeof(long), | 222 | .maxlen = sizeof(long), |
203 | .mode = 0644, | 223 | .mode = 0644, |
204 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, | 224 | .proc_handler = &proc_dointvec_minmax, |
205 | .strategy = &sctp_sysctl_jiffies_ms, | 225 | .strategy = &sysctl_intvec, |
206 | .extra1 = &sack_timer_min, | 226 | .extra1 = &sack_timer_min, |
207 | .extra2 = &sack_timer_max, | 227 | .extra2 = &sack_timer_max, |
208 | }, | 228 | }, |
@@ -242,37 +262,3 @@ void sctp_sysctl_unregister(void) | |||
242 | { | 262 | { |
243 | unregister_sysctl_table(sctp_sysctl_header); | 263 | unregister_sysctl_table(sctp_sysctl_header); |
244 | } | 264 | } |
245 | |||
246 | /* Strategy function to convert jiffies to milliseconds. */ | ||
247 | static int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen, | ||
248 | void __user *oldval, size_t __user *oldlenp, | ||
249 | void __user *newval, size_t newlen, void **context) { | ||
250 | |||
251 | if (oldval) { | ||
252 | size_t olen; | ||
253 | |||
254 | if (oldlenp) { | ||
255 | if (get_user(olen, oldlenp)) | ||
256 | return -EFAULT; | ||
257 | |||
258 | if (olen != sizeof (int)) | ||
259 | return -EINVAL; | ||
260 | } | ||
261 | if (put_user((*(int *)(table->data) * 1000) / HZ, | ||
262 | (int __user *)oldval) || | ||
263 | (oldlenp && put_user(sizeof (int), oldlenp))) | ||
264 | return -EFAULT; | ||
265 | } | ||
266 | if (newval && newlen) { | ||
267 | int new; | ||
268 | |||
269 | if (newlen != sizeof (int)) | ||
270 | return -EINVAL; | ||
271 | |||
272 | if (get_user(new, (int __user *)newval)) | ||
273 | return -EFAULT; | ||
274 | |||
275 | *(int *)(table->data) = (new * HZ) / 1000; | ||
276 | } | ||
277 | return 1; | ||
278 | } | ||
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 2763aa93de1a..3e5936a5f671 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -75,7 +75,7 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
75 | * parameter 'RTO.Initial'. | 75 | * parameter 'RTO.Initial'. |
76 | */ | 76 | */ |
77 | peer->rtt = 0; | 77 | peer->rtt = 0; |
78 | peer->rto = sctp_rto_initial; | 78 | peer->rto = msecs_to_jiffies(sctp_rto_initial); |
79 | peer->rttvar = 0; | 79 | peer->rttvar = 0; |
80 | peer->srtt = 0; | 80 | peer->srtt = 0; |
81 | peer->rto_pending = 0; | 81 | peer->rto_pending = 0; |