sysctl.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* SCTP kernel implementation
  2. * (C) Copyright IBM Corp. 2002, 2004
  3. * Copyright (c) 2002 Intel Corp.
  4. *
  5. * This file is part of the SCTP kernel implementation
  6. *
  7. * Sysctl related interfaces for SCTP.
  8. *
  9. * This SCTP 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. * This SCTP 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 <net/sctp/sctp.h>
  45. #include <linux/sysctl.h>
  46. static int zero = 0;
  47. static int one = 1;
  48. static int timer_max = 86400000; /* ms in one day */
  49. static int int_max = INT_MAX;
  50. static int sack_timer_min = 1;
  51. static int sack_timer_max = 500;
  52. static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
  53. extern int sysctl_sctp_mem[3];
  54. extern int sysctl_sctp_rmem[3];
  55. extern int sysctl_sctp_wmem[3];
  56. static ctl_table sctp_table[] = {
  57. {
  58. .procname = "rto_initial",
  59. .data = &sctp_rto_initial,
  60. .maxlen = sizeof(unsigned int),
  61. .mode = 0644,
  62. .proc_handler = proc_dointvec_minmax,
  63. .extra1 = &one,
  64. .extra2 = &timer_max
  65. },
  66. {
  67. .procname = "rto_min",
  68. .data = &sctp_rto_min,
  69. .maxlen = sizeof(unsigned int),
  70. .mode = 0644,
  71. .proc_handler = proc_dointvec_minmax,
  72. .extra1 = &one,
  73. .extra2 = &timer_max
  74. },
  75. {
  76. .procname = "rto_max",
  77. .data = &sctp_rto_max,
  78. .maxlen = sizeof(unsigned int),
  79. .mode = 0644,
  80. .proc_handler = proc_dointvec_minmax,
  81. .extra1 = &one,
  82. .extra2 = &timer_max
  83. },
  84. {
  85. .procname = "valid_cookie_life",
  86. .data = &sctp_valid_cookie_life,
  87. .maxlen = sizeof(unsigned int),
  88. .mode = 0644,
  89. .proc_handler = proc_dointvec_minmax,
  90. .extra1 = &one,
  91. .extra2 = &timer_max
  92. },
  93. {
  94. .procname = "max_burst",
  95. .data = &sctp_max_burst,
  96. .maxlen = sizeof(int),
  97. .mode = 0644,
  98. .proc_handler = proc_dointvec_minmax,
  99. .extra1 = &zero,
  100. .extra2 = &int_max
  101. },
  102. {
  103. .procname = "association_max_retrans",
  104. .data = &sctp_max_retrans_association,
  105. .maxlen = sizeof(int),
  106. .mode = 0644,
  107. .proc_handler = proc_dointvec_minmax,
  108. .extra1 = &one,
  109. .extra2 = &int_max
  110. },
  111. {
  112. .procname = "sndbuf_policy",
  113. .data = &sctp_sndbuf_policy,
  114. .maxlen = sizeof(int),
  115. .mode = 0644,
  116. .proc_handler = proc_dointvec,
  117. },
  118. {
  119. .procname = "rcvbuf_policy",
  120. .data = &sctp_rcvbuf_policy,
  121. .maxlen = sizeof(int),
  122. .mode = 0644,
  123. .proc_handler = proc_dointvec,
  124. },
  125. {
  126. .procname = "path_max_retrans",
  127. .data = &sctp_max_retrans_path,
  128. .maxlen = sizeof(int),
  129. .mode = 0644,
  130. .proc_handler = proc_dointvec_minmax,
  131. .extra1 = &one,
  132. .extra2 = &int_max
  133. },
  134. {
  135. .procname = "max_init_retransmits",
  136. .data = &sctp_max_retrans_init,
  137. .maxlen = sizeof(int),
  138. .mode = 0644,
  139. .proc_handler = proc_dointvec_minmax,
  140. .extra1 = &one,
  141. .extra2 = &int_max
  142. },
  143. {
  144. .procname = "hb_interval",
  145. .data = &sctp_hb_interval,
  146. .maxlen = sizeof(unsigned int),
  147. .mode = 0644,
  148. .proc_handler = proc_dointvec_minmax,
  149. .extra1 = &one,
  150. .extra2 = &timer_max
  151. },
  152. {
  153. .procname = "cookie_preserve_enable",
  154. .data = &sctp_cookie_preserve_enable,
  155. .maxlen = sizeof(int),
  156. .mode = 0644,
  157. .proc_handler = proc_dointvec,
  158. },
  159. {
  160. .procname = "rto_alpha_exp_divisor",
  161. .data = &sctp_rto_alpha,
  162. .maxlen = sizeof(int),
  163. .mode = 0444,
  164. .proc_handler = proc_dointvec,
  165. },
  166. {
  167. .procname = "rto_beta_exp_divisor",
  168. .data = &sctp_rto_beta,
  169. .maxlen = sizeof(int),
  170. .mode = 0444,
  171. .proc_handler = proc_dointvec,
  172. },
  173. {
  174. .procname = "addip_enable",
  175. .data = &sctp_addip_enable,
  176. .maxlen = sizeof(int),
  177. .mode = 0644,
  178. .proc_handler = proc_dointvec,
  179. },
  180. {
  181. .procname = "prsctp_enable",
  182. .data = &sctp_prsctp_enable,
  183. .maxlen = sizeof(int),
  184. .mode = 0644,
  185. .proc_handler = proc_dointvec,
  186. },
  187. {
  188. .procname = "sack_timeout",
  189. .data = &sctp_sack_timeout,
  190. .maxlen = sizeof(int),
  191. .mode = 0644,
  192. .proc_handler = proc_dointvec_minmax,
  193. .extra1 = &sack_timer_min,
  194. .extra2 = &sack_timer_max,
  195. },
  196. {
  197. .procname = "sctp_mem",
  198. .data = &sysctl_sctp_mem,
  199. .maxlen = sizeof(sysctl_sctp_mem),
  200. .mode = 0644,
  201. .proc_handler = proc_dointvec,
  202. },
  203. {
  204. .procname = "sctp_rmem",
  205. .data = &sysctl_sctp_rmem,
  206. .maxlen = sizeof(sysctl_sctp_rmem),
  207. .mode = 0644,
  208. .proc_handler = proc_dointvec,
  209. },
  210. {
  211. .procname = "sctp_wmem",
  212. .data = &sysctl_sctp_wmem,
  213. .maxlen = sizeof(sysctl_sctp_wmem),
  214. .mode = 0644,
  215. .proc_handler = proc_dointvec,
  216. },
  217. {
  218. .procname = "auth_enable",
  219. .data = &sctp_auth_enable,
  220. .maxlen = sizeof(int),
  221. .mode = 0644,
  222. .proc_handler = proc_dointvec,
  223. },
  224. {
  225. .procname = "addip_noauth_enable",
  226. .data = &sctp_addip_noauth,
  227. .maxlen = sizeof(int),
  228. .mode = 0644,
  229. .proc_handler = proc_dointvec,
  230. },
  231. {
  232. .procname = "addr_scope_policy",
  233. .data = &sctp_scope_policy,
  234. .maxlen = sizeof(int),
  235. .mode = 0644,
  236. .proc_handler = &proc_dointvec_minmax,
  237. .extra1 = &zero,
  238. .extra2 = &addr_scope_max,
  239. },
  240. { }
  241. };
  242. static struct ctl_path sctp_path[] = {
  243. { .procname = "net", },
  244. { .procname = "sctp", },
  245. { }
  246. };
  247. static struct ctl_table_header * sctp_sysctl_header;
  248. /* Sysctl registration. */
  249. void sctp_sysctl_register(void)
  250. {
  251. sctp_sysctl_header = register_sysctl_paths(sctp_path, sctp_table);
  252. }
  253. /* Sysctl deregistration. */
  254. void sctp_sysctl_unregister(void)
  255. {
  256. unregister_sysctl_table(sctp_sysctl_header);
  257. }