aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/sysctl.c')
-rw-r--r--net/sctp/sysctl.c83
1 files changed, 70 insertions, 13 deletions
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 6b36561a1b3b..7135e617ab0f 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -19,9 +19,8 @@
19 * See the GNU General Public License for more details. 19 * See the GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with GNU CC; see the file COPYING. If not, write to 22 * along with GNU CC; see the file COPYING. If not, see
23 * the Free Software Foundation, 59 Temple Place - Suite 330, 23 * <http://www.gnu.org/licenses/>.
24 * Boston, MA 02111-1307, USA.
25 * 24 *
26 * Please send any bug reports or fixes you make to the 25 * Please send any bug reports or fixes you make to the
27 * email address(es): 26 * email address(es):
@@ -56,11 +55,16 @@ extern long sysctl_sctp_mem[3];
56extern int sysctl_sctp_rmem[3]; 55extern int sysctl_sctp_rmem[3];
57extern int sysctl_sctp_wmem[3]; 56extern int sysctl_sctp_wmem[3];
58 57
59static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, 58static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
60 int write, 59 void __user *buffer, size_t *lenp,
60 loff_t *ppos);
61static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
62 void __user *buffer, size_t *lenp,
63 loff_t *ppos);
64static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
61 void __user *buffer, size_t *lenp, 65 void __user *buffer, size_t *lenp,
62
63 loff_t *ppos); 66 loff_t *ppos);
67
64static struct ctl_table sctp_table[] = { 68static struct ctl_table sctp_table[] = {
65 { 69 {
66 .procname = "sctp_mem", 70 .procname = "sctp_mem",
@@ -102,17 +106,17 @@ static struct ctl_table sctp_net_table[] = {
102 .data = &init_net.sctp.rto_min, 106 .data = &init_net.sctp.rto_min,
103 .maxlen = sizeof(unsigned int), 107 .maxlen = sizeof(unsigned int),
104 .mode = 0644, 108 .mode = 0644,
105 .proc_handler = proc_dointvec_minmax, 109 .proc_handler = proc_sctp_do_rto_min,
106 .extra1 = &one, 110 .extra1 = &one,
107 .extra2 = &timer_max 111 .extra2 = &init_net.sctp.rto_max
108 }, 112 },
109 { 113 {
110 .procname = "rto_max", 114 .procname = "rto_max",
111 .data = &init_net.sctp.rto_max, 115 .data = &init_net.sctp.rto_max,
112 .maxlen = sizeof(unsigned int), 116 .maxlen = sizeof(unsigned int),
113 .mode = 0644, 117 .mode = 0644,
114 .proc_handler = proc_dointvec_minmax, 118 .proc_handler = proc_sctp_do_rto_max,
115 .extra1 = &one, 119 .extra1 = &init_net.sctp.rto_min,
116 .extra2 = &timer_max 120 .extra2 = &timer_max
117 }, 121 },
118 { 122 {
@@ -294,8 +298,7 @@ static struct ctl_table sctp_net_table[] = {
294 { /* sentinel */ } 298 { /* sentinel */ }
295}; 299};
296 300
297static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, 301static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
298 int write,
299 void __user *buffer, size_t *lenp, 302 void __user *buffer, size_t *lenp,
300 loff_t *ppos) 303 loff_t *ppos)
301{ 304{
@@ -342,6 +345,60 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
342 return ret; 345 return ret;
343} 346}
344 347
348static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
349 void __user *buffer, size_t *lenp,
350 loff_t *ppos)
351{
352 struct net *net = current->nsproxy->net_ns;
353 int new_value;
354 struct ctl_table tbl;
355 unsigned int min = *(unsigned int *) ctl->extra1;
356 unsigned int max = *(unsigned int *) ctl->extra2;
357 int ret;
358
359 memset(&tbl, 0, sizeof(struct ctl_table));
360 tbl.maxlen = sizeof(unsigned int);
361
362 if (write)
363 tbl.data = &new_value;
364 else
365 tbl.data = &net->sctp.rto_min;
366 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
367 if (write) {
368 if (ret || new_value > max || new_value < min)
369 return -EINVAL;
370 net->sctp.rto_min = new_value;
371 }
372 return ret;
373}
374
375static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
376 void __user *buffer, size_t *lenp,
377 loff_t *ppos)
378{
379 struct net *net = current->nsproxy->net_ns;
380 int new_value;
381 struct ctl_table tbl;
382 unsigned int min = *(unsigned int *) ctl->extra1;
383 unsigned int max = *(unsigned int *) ctl->extra2;
384 int ret;
385
386 memset(&tbl, 0, sizeof(struct ctl_table));
387 tbl.maxlen = sizeof(unsigned int);
388
389 if (write)
390 tbl.data = &new_value;
391 else
392 tbl.data = &net->sctp.rto_max;
393 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
394 if (write) {
395 if (ret || new_value > max || new_value < min)
396 return -EINVAL;
397 net->sctp.rto_max = new_value;
398 }
399 return ret;
400}
401
345int sctp_sysctl_net_register(struct net *net) 402int sctp_sysctl_net_register(struct net *net)
346{ 403{
347 struct ctl_table *table; 404 struct ctl_table *table;
@@ -367,7 +424,7 @@ void sctp_sysctl_net_unregister(struct net *net)
367 kfree(table); 424 kfree(table);
368} 425}
369 426
370static struct ctl_table_header * sctp_sysctl_header; 427static struct ctl_table_header *sctp_sysctl_header;
371 428
372/* Sysctl registration. */ 429/* Sysctl registration. */
373void sctp_sysctl_register(void) 430void sctp_sysctl_register(void)