Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* SCTP kernel reference Implementation |
| 2 | * (C) Copyright IBM Corp. 2002, 2004 |
| 3 | * Copyright (c) 2002 Intel Corp. |
| 4 | * |
| 5 | * This file is part of the SCTP kernel reference Implementation |
| 6 | * |
| 7 | * Sysctl related interfaces for SCTP. |
| 8 | * |
| 9 | * The SCTP reference implementation is free software; |
| 10 | * you can redistribute it and/or modify it under the terms of |
| 11 | * the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2, or (at your option) |
| 13 | * any later version. |
| 14 | * |
| 15 | * The SCTP reference implementation is distributed in the hope that it |
| 16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 17 | * ************************ |
| 18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 19 | * See the GNU General Public License for more details. |
| 20 | * |
| 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 |
| 23 | * the Free Software Foundation, 59 Temple Place - Suite 330, |
| 24 | * Boston, MA 02111-1307, USA. |
| 25 | * |
| 26 | * Please send any bug reports or fixes you make to the |
| 27 | * email address(es): |
| 28 | * lksctp developers <lksctp-developers@lists.sourceforge.net> |
| 29 | * |
| 30 | * Or submit a bug report through the following website: |
| 31 | * http://www.sf.net/projects/lksctp |
| 32 | * |
| 33 | * Written or modified by: |
| 34 | * Mingqin Liu <liuming@us.ibm.com> |
| 35 | * Jon Grimm <jgrimm@us.ibm.com> |
| 36 | * Ardelle Fan <ardelle.fan@intel.com> |
| 37 | * Ryan Layer <rmlayer@us.ibm.com> |
| 38 | * Sridhar Samudrala <sri@us.ibm.com> |
| 39 | * |
| 40 | * Any bugs reported given to us we will try to fix... any fixes shared will |
| 41 | * be incorporated into the next SCTP release. |
| 42 | */ |
| 43 | |
| 44 | #include <net/sctp/structs.h> |
Adrian Bunk | 8c5955d | 2005-09-05 18:07:42 -0700 | [diff] [blame] | 45 | #include <net/sctp/sctp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <linux/sysctl.h> |
| 47 | |
| 48 | static ctl_handler sctp_sysctl_jiffies_ms; |
| 49 | static long rto_timer_min = 1; |
| 50 | static long rto_timer_max = 86400000; /* One day */ |
Vlad Yasevich | 2f85a42 | 2005-06-28 13:24:23 -0700 | [diff] [blame] | 51 | static long sack_timer_min = 1; |
| 52 | static long sack_timer_max = 500; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | static ctl_table sctp_table[] = { |
| 55 | { |
| 56 | .ctl_name = NET_SCTP_RTO_INITIAL, |
| 57 | .procname = "rto_initial", |
| 58 | .data = &sctp_rto_initial, |
| 59 | .maxlen = sizeof(long), |
| 60 | .mode = 0644, |
| 61 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 62 | .strategy = &sctp_sysctl_jiffies_ms, |
| 63 | .extra1 = &rto_timer_min, |
| 64 | .extra2 = &rto_timer_max |
| 65 | }, |
| 66 | { |
| 67 | .ctl_name = NET_SCTP_RTO_MIN, |
| 68 | .procname = "rto_min", |
| 69 | .data = &sctp_rto_min, |
| 70 | .maxlen = sizeof(long), |
| 71 | .mode = 0644, |
| 72 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 73 | .strategy = &sctp_sysctl_jiffies_ms, |
| 74 | .extra1 = &rto_timer_min, |
| 75 | .extra2 = &rto_timer_max |
| 76 | }, |
| 77 | { |
| 78 | .ctl_name = NET_SCTP_RTO_MAX, |
| 79 | .procname = "rto_max", |
| 80 | .data = &sctp_rto_max, |
| 81 | .maxlen = sizeof(long), |
| 82 | .mode = 0644, |
| 83 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 84 | .strategy = &sctp_sysctl_jiffies_ms, |
| 85 | .extra1 = &rto_timer_min, |
| 86 | .extra2 = &rto_timer_max |
| 87 | }, |
| 88 | { |
| 89 | .ctl_name = NET_SCTP_VALID_COOKIE_LIFE, |
| 90 | .procname = "valid_cookie_life", |
| 91 | .data = &sctp_valid_cookie_life, |
| 92 | .maxlen = sizeof(long), |
| 93 | .mode = 0644, |
| 94 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 95 | .strategy = &sctp_sysctl_jiffies_ms, |
| 96 | .extra1 = &rto_timer_min, |
| 97 | .extra2 = &rto_timer_max |
| 98 | }, |
| 99 | { |
| 100 | .ctl_name = NET_SCTP_MAX_BURST, |
| 101 | .procname = "max_burst", |
| 102 | .data = &sctp_max_burst, |
| 103 | .maxlen = sizeof(int), |
| 104 | .mode = 0644, |
| 105 | .proc_handler = &proc_dointvec |
| 106 | }, |
| 107 | { |
| 108 | .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS, |
| 109 | .procname = "association_max_retrans", |
| 110 | .data = &sctp_max_retrans_association, |
| 111 | .maxlen = sizeof(int), |
| 112 | .mode = 0644, |
| 113 | .proc_handler = &proc_dointvec |
| 114 | }, |
| 115 | { |
Neil Horman | 4eb701d | 2005-04-28 12:02:04 -0700 | [diff] [blame] | 116 | .ctl_name = NET_SCTP_SNDBUF_POLICY, |
| 117 | .procname = "sndbuf_policy", |
| 118 | .data = &sctp_sndbuf_policy, |
| 119 | .maxlen = sizeof(int), |
| 120 | .mode = 0644, |
| 121 | .proc_handler = &proc_dointvec |
| 122 | }, |
| 123 | { |
Neil Horman | 049b3ff | 2005-11-11 16:08:24 -0800 | [diff] [blame] | 124 | .ctl_name = NET_SCTP_RCVBUF_POLICY, |
| 125 | .procname = "rcvbuf_policy", |
| 126 | .data = &sctp_rcvbuf_policy, |
| 127 | .maxlen = sizeof(int), |
| 128 | .mode = 0644, |
| 129 | .proc_handler = &proc_dointvec |
| 130 | }, |
| 131 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | .ctl_name = NET_SCTP_PATH_MAX_RETRANS, |
| 133 | .procname = "path_max_retrans", |
| 134 | .data = &sctp_max_retrans_path, |
| 135 | .maxlen = sizeof(int), |
| 136 | .mode = 0644, |
| 137 | .proc_handler = &proc_dointvec |
| 138 | }, |
| 139 | { |
| 140 | .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS, |
| 141 | .procname = "max_init_retransmits", |
| 142 | .data = &sctp_max_retrans_init, |
| 143 | .maxlen = sizeof(int), |
| 144 | .mode = 0644, |
| 145 | .proc_handler = &proc_dointvec |
| 146 | }, |
| 147 | { |
| 148 | .ctl_name = NET_SCTP_HB_INTERVAL, |
| 149 | .procname = "hb_interval", |
| 150 | .data = &sctp_hb_interval, |
| 151 | .maxlen = sizeof(long), |
| 152 | .mode = 0644, |
| 153 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 154 | .strategy = &sctp_sysctl_jiffies_ms, |
| 155 | .extra1 = &rto_timer_min, |
| 156 | .extra2 = &rto_timer_max |
| 157 | }, |
| 158 | { |
| 159 | .ctl_name = NET_SCTP_PRESERVE_ENABLE, |
| 160 | .procname = "cookie_preserve_enable", |
| 161 | .data = &sctp_cookie_preserve_enable, |
Vlad Yasevich | 8116ffa | 2006-01-17 11:55:17 -0800 | [diff] [blame] | 162 | .maxlen = sizeof(int), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | .mode = 0644, |
Vlad Yasevich | 8116ffa | 2006-01-17 11:55:17 -0800 | [diff] [blame] | 164 | .proc_handler = &proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | }, |
| 166 | { |
| 167 | .ctl_name = NET_SCTP_RTO_ALPHA, |
| 168 | .procname = "rto_alpha_exp_divisor", |
| 169 | .data = &sctp_rto_alpha, |
| 170 | .maxlen = sizeof(int), |
| 171 | .mode = 0644, |
| 172 | .proc_handler = &proc_dointvec |
| 173 | }, |
| 174 | { |
| 175 | .ctl_name = NET_SCTP_RTO_BETA, |
| 176 | .procname = "rto_beta_exp_divisor", |
| 177 | .data = &sctp_rto_beta, |
| 178 | .maxlen = sizeof(int), |
| 179 | .mode = 0644, |
| 180 | .proc_handler = &proc_dointvec |
| 181 | }, |
| 182 | { |
| 183 | .ctl_name = NET_SCTP_ADDIP_ENABLE, |
| 184 | .procname = "addip_enable", |
| 185 | .data = &sctp_addip_enable, |
| 186 | .maxlen = sizeof(int), |
| 187 | .mode = 0644, |
| 188 | .proc_handler = &proc_dointvec |
| 189 | }, |
| 190 | { |
| 191 | .ctl_name = NET_SCTP_PRSCTP_ENABLE, |
| 192 | .procname = "prsctp_enable", |
| 193 | .data = &sctp_prsctp_enable, |
| 194 | .maxlen = sizeof(int), |
| 195 | .mode = 0644, |
| 196 | .proc_handler = &proc_dointvec |
| 197 | }, |
Vlad Yasevich | 2f85a42 | 2005-06-28 13:24:23 -0700 | [diff] [blame] | 198 | { |
| 199 | .ctl_name = NET_SCTP_SACK_TIMEOUT, |
| 200 | .procname = "sack_timeout", |
| 201 | .data = &sctp_sack_timeout, |
| 202 | .maxlen = sizeof(long), |
| 203 | .mode = 0644, |
| 204 | .proc_handler = &proc_doulongvec_ms_jiffies_minmax, |
| 205 | .strategy = &sctp_sysctl_jiffies_ms, |
| 206 | .extra1 = &sack_timer_min, |
| 207 | .extra2 = &sack_timer_max, |
| 208 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | { .ctl_name = 0 } |
| 210 | }; |
| 211 | |
| 212 | static ctl_table sctp_net_table[] = { |
| 213 | { |
| 214 | .ctl_name = NET_SCTP, |
| 215 | .procname = "sctp", |
| 216 | .mode = 0555, |
| 217 | .child = sctp_table |
| 218 | }, |
| 219 | { .ctl_name = 0 } |
| 220 | }; |
| 221 | |
| 222 | static ctl_table sctp_root_table[] = { |
| 223 | { |
| 224 | .ctl_name = CTL_NET, |
| 225 | .procname = "net", |
| 226 | .mode = 0555, |
| 227 | .child = sctp_net_table |
| 228 | }, |
| 229 | { .ctl_name = 0 } |
| 230 | }; |
| 231 | |
| 232 | static struct ctl_table_header * sctp_sysctl_header; |
| 233 | |
| 234 | /* Sysctl registration. */ |
| 235 | void sctp_sysctl_register(void) |
| 236 | { |
| 237 | sctp_sysctl_header = register_sysctl_table(sctp_root_table, 0); |
| 238 | } |
| 239 | |
| 240 | /* Sysctl deregistration. */ |
| 241 | void sctp_sysctl_unregister(void) |
| 242 | { |
| 243 | unregister_sysctl_table(sctp_sysctl_header); |
| 244 | } |
| 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 | } |