sysctl.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. #include <net/sctp/structs.h>
  44. #include <linux/sysctl.h>
  45. static ctl_handler sctp_sysctl_jiffies_ms;
  46. static long rto_timer_min = 1;
  47. static long rto_timer_max = 86400000; /* One day */
  48. static long sack_timer_min = 1;
  49. static long sack_timer_max = 500;
  50. static ctl_table sctp_table[] = {
  51. {
  52. .ctl_name = NET_SCTP_RTO_INITIAL,
  53. .procname = "rto_initial",
  54. .data = &sctp_rto_initial,
  55. .maxlen = sizeof(long),
  56. .mode = 0644,
  57. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  58. .strategy = &sctp_sysctl_jiffies_ms,
  59. .extra1 = &rto_timer_min,
  60. .extra2 = &rto_timer_max
  61. },
  62. {
  63. .ctl_name = NET_SCTP_RTO_MIN,
  64. .procname = "rto_min",
  65. .data = &sctp_rto_min,
  66. .maxlen = sizeof(long),
  67. .mode = 0644,
  68. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  69. .strategy = &sctp_sysctl_jiffies_ms,
  70. .extra1 = &rto_timer_min,
  71. .extra2 = &rto_timer_max
  72. },
  73. {
  74. .ctl_name = NET_SCTP_RTO_MAX,
  75. .procname = "rto_max",
  76. .data = &sctp_rto_max,
  77. .maxlen = sizeof(long),
  78. .mode = 0644,
  79. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  80. .strategy = &sctp_sysctl_jiffies_ms,
  81. .extra1 = &rto_timer_min,
  82. .extra2 = &rto_timer_max
  83. },
  84. {
  85. .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
  86. .procname = "valid_cookie_life",
  87. .data = &sctp_valid_cookie_life,
  88. .maxlen = sizeof(long),
  89. .mode = 0644,
  90. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  91. .strategy = &sctp_sysctl_jiffies_ms,
  92. .extra1 = &rto_timer_min,
  93. .extra2 = &rto_timer_max
  94. },
  95. {
  96. .ctl_name = NET_SCTP_MAX_BURST,
  97. .procname = "max_burst",
  98. .data = &sctp_max_burst,
  99. .maxlen = sizeof(int),
  100. .mode = 0644,
  101. .proc_handler = &proc_dointvec
  102. },
  103. {
  104. .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS,
  105. .procname = "association_max_retrans",
  106. .data = &sctp_max_retrans_association,
  107. .maxlen = sizeof(int),
  108. .mode = 0644,
  109. .proc_handler = &proc_dointvec
  110. },
  111. {
  112. .ctl_name = NET_SCTP_SNDBUF_POLICY,
  113. .procname = "sndbuf_policy",
  114. .data = &sctp_sndbuf_policy,
  115. .maxlen = sizeof(int),
  116. .mode = 0644,
  117. .proc_handler = &proc_dointvec
  118. },
  119. {
  120. .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
  121. .procname = "path_max_retrans",
  122. .data = &sctp_max_retrans_path,
  123. .maxlen = sizeof(int),
  124. .mode = 0644,
  125. .proc_handler = &proc_dointvec
  126. },
  127. {
  128. .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS,
  129. .procname = "max_init_retransmits",
  130. .data = &sctp_max_retrans_init,
  131. .maxlen = sizeof(int),
  132. .mode = 0644,
  133. .proc_handler = &proc_dointvec
  134. },
  135. {
  136. .ctl_name = NET_SCTP_HB_INTERVAL,
  137. .procname = "hb_interval",
  138. .data = &sctp_hb_interval,
  139. .maxlen = sizeof(long),
  140. .mode = 0644,
  141. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  142. .strategy = &sctp_sysctl_jiffies_ms,
  143. .extra1 = &rto_timer_min,
  144. .extra2 = &rto_timer_max
  145. },
  146. {
  147. .ctl_name = NET_SCTP_PRESERVE_ENABLE,
  148. .procname = "cookie_preserve_enable",
  149. .data = &sctp_cookie_preserve_enable,
  150. .maxlen = sizeof(long),
  151. .mode = 0644,
  152. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  153. .strategy = &sctp_sysctl_jiffies_ms,
  154. .extra1 = &rto_timer_min,
  155. .extra2 = &rto_timer_max
  156. },
  157. {
  158. .ctl_name = NET_SCTP_RTO_ALPHA,
  159. .procname = "rto_alpha_exp_divisor",
  160. .data = &sctp_rto_alpha,
  161. .maxlen = sizeof(int),
  162. .mode = 0644,
  163. .proc_handler = &proc_dointvec
  164. },
  165. {
  166. .ctl_name = NET_SCTP_RTO_BETA,
  167. .procname = "rto_beta_exp_divisor",
  168. .data = &sctp_rto_beta,
  169. .maxlen = sizeof(int),
  170. .mode = 0644,
  171. .proc_handler = &proc_dointvec
  172. },
  173. {
  174. .ctl_name = NET_SCTP_ADDIP_ENABLE,
  175. .procname = "addip_enable",
  176. .data = &sctp_addip_enable,
  177. .maxlen = sizeof(int),
  178. .mode = 0644,
  179. .proc_handler = &proc_dointvec
  180. },
  181. {
  182. .ctl_name = NET_SCTP_PRSCTP_ENABLE,
  183. .procname = "prsctp_enable",
  184. .data = &sctp_prsctp_enable,
  185. .maxlen = sizeof(int),
  186. .mode = 0644,
  187. .proc_handler = &proc_dointvec
  188. },
  189. {
  190. .ctl_name = NET_SCTP_SACK_TIMEOUT,
  191. .procname = "sack_timeout",
  192. .data = &sctp_sack_timeout,
  193. .maxlen = sizeof(long),
  194. .mode = 0644,
  195. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  196. .strategy = &sctp_sysctl_jiffies_ms,
  197. .extra1 = &sack_timer_min,
  198. .extra2 = &sack_timer_max,
  199. },
  200. { .ctl_name = 0 }
  201. };
  202. static ctl_table sctp_net_table[] = {
  203. {
  204. .ctl_name = NET_SCTP,
  205. .procname = "sctp",
  206. .mode = 0555,
  207. .child = sctp_table
  208. },
  209. { .ctl_name = 0 }
  210. };
  211. static ctl_table sctp_root_table[] = {
  212. {
  213. .ctl_name = CTL_NET,
  214. .procname = "net",
  215. .mode = 0555,
  216. .child = sctp_net_table
  217. },
  218. { .ctl_name = 0 }
  219. };
  220. static struct ctl_table_header * sctp_sysctl_header;
  221. /* Sysctl registration. */
  222. void sctp_sysctl_register(void)
  223. {
  224. sctp_sysctl_header = register_sysctl_table(sctp_root_table, 0);
  225. }
  226. /* Sysctl deregistration. */
  227. void sctp_sysctl_unregister(void)
  228. {
  229. unregister_sysctl_table(sctp_sysctl_header);
  230. }
  231. /* Strategy function to convert jiffies to milliseconds. */
  232. static int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
  233. void __user *oldval, size_t __user *oldlenp,
  234. void __user *newval, size_t newlen, void **context) {
  235. if (oldval) {
  236. size_t olen;
  237. if (oldlenp) {
  238. if (get_user(olen, oldlenp))
  239. return -EFAULT;
  240. if (olen != sizeof (int))
  241. return -EINVAL;
  242. }
  243. if (put_user((*(int *)(table->data) * 1000) / HZ,
  244. (int __user *)oldval) ||
  245. (oldlenp && put_user(sizeof (int), oldlenp)))
  246. return -EFAULT;
  247. }
  248. if (newval && newlen) {
  249. int new;
  250. if (newlen != sizeof (int))
  251. return -EINVAL;
  252. if (get_user(new, (int __user *)newval))
  253. return -EFAULT;
  254. *(int *)(table->data) = (new * HZ) / 1000;
  255. }
  256. return 1;
  257. }