sysctl.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. static int rwnd_scale_max = 16;
  54. extern long sysctl_sctp_mem[3];
  55. extern int sysctl_sctp_rmem[3];
  56. extern int sysctl_sctp_wmem[3];
  57. static ctl_table sctp_table[] = {
  58. {
  59. .procname = "rto_initial",
  60. .data = &sctp_rto_initial,
  61. .maxlen = sizeof(unsigned int),
  62. .mode = 0644,
  63. .proc_handler = proc_dointvec_minmax,
  64. .extra1 = &one,
  65. .extra2 = &timer_max
  66. },
  67. {
  68. .procname = "rto_min",
  69. .data = &sctp_rto_min,
  70. .maxlen = sizeof(unsigned int),
  71. .mode = 0644,
  72. .proc_handler = proc_dointvec_minmax,
  73. .extra1 = &one,
  74. .extra2 = &timer_max
  75. },
  76. {
  77. .procname = "rto_max",
  78. .data = &sctp_rto_max,
  79. .maxlen = sizeof(unsigned int),
  80. .mode = 0644,
  81. .proc_handler = proc_dointvec_minmax,
  82. .extra1 = &one,
  83. .extra2 = &timer_max
  84. },
  85. {
  86. .procname = "valid_cookie_life",
  87. .data = &sctp_valid_cookie_life,
  88. .maxlen = sizeof(unsigned int),
  89. .mode = 0644,
  90. .proc_handler = proc_dointvec_minmax,
  91. .extra1 = &one,
  92. .extra2 = &timer_max
  93. },
  94. {
  95. .procname = "max_burst",
  96. .data = &sctp_max_burst,
  97. .maxlen = sizeof(int),
  98. .mode = 0644,
  99. .proc_handler = proc_dointvec_minmax,
  100. .extra1 = &zero,
  101. .extra2 = &int_max
  102. },
  103. {
  104. .procname = "association_max_retrans",
  105. .data = &sctp_max_retrans_association,
  106. .maxlen = sizeof(int),
  107. .mode = 0644,
  108. .proc_handler = proc_dointvec_minmax,
  109. .extra1 = &one,
  110. .extra2 = &int_max
  111. },
  112. {
  113. .procname = "sndbuf_policy",
  114. .data = &sctp_sndbuf_policy,
  115. .maxlen = sizeof(int),
  116. .mode = 0644,
  117. .proc_handler = proc_dointvec,
  118. },
  119. {
  120. .procname = "rcvbuf_policy",
  121. .data = &sctp_rcvbuf_policy,
  122. .maxlen = sizeof(int),
  123. .mode = 0644,
  124. .proc_handler = proc_dointvec,
  125. },
  126. {
  127. .procname = "path_max_retrans",
  128. .data = &sctp_max_retrans_path,
  129. .maxlen = sizeof(int),
  130. .mode = 0644,
  131. .proc_handler = proc_dointvec_minmax,
  132. .extra1 = &one,
  133. .extra2 = &int_max
  134. },
  135. {
  136. .procname = "max_init_retransmits",
  137. .data = &sctp_max_retrans_init,
  138. .maxlen = sizeof(int),
  139. .mode = 0644,
  140. .proc_handler = proc_dointvec_minmax,
  141. .extra1 = &one,
  142. .extra2 = &int_max
  143. },
  144. {
  145. .procname = "hb_interval",
  146. .data = &sctp_hb_interval,
  147. .maxlen = sizeof(unsigned int),
  148. .mode = 0644,
  149. .proc_handler = proc_dointvec_minmax,
  150. .extra1 = &one,
  151. .extra2 = &timer_max
  152. },
  153. {
  154. .procname = "cookie_preserve_enable",
  155. .data = &sctp_cookie_preserve_enable,
  156. .maxlen = sizeof(int),
  157. .mode = 0644,
  158. .proc_handler = proc_dointvec,
  159. },
  160. {
  161. .procname = "rto_alpha_exp_divisor",
  162. .data = &sctp_rto_alpha,
  163. .maxlen = sizeof(int),
  164. .mode = 0444,
  165. .proc_handler = proc_dointvec,
  166. },
  167. {
  168. .procname = "rto_beta_exp_divisor",
  169. .data = &sctp_rto_beta,
  170. .maxlen = sizeof(int),
  171. .mode = 0444,
  172. .proc_handler = proc_dointvec,
  173. },
  174. {
  175. .procname = "addip_enable",
  176. .data = &sctp_addip_enable,
  177. .maxlen = sizeof(int),
  178. .mode = 0644,
  179. .proc_handler = proc_dointvec,
  180. },
  181. {
  182. .procname = "default_auto_asconf",
  183. .data = &sctp_default_auto_asconf,
  184. .maxlen = sizeof(int),
  185. .mode = 0644,
  186. .proc_handler = proc_dointvec,
  187. },
  188. {
  189. .procname = "prsctp_enable",
  190. .data = &sctp_prsctp_enable,
  191. .maxlen = sizeof(int),
  192. .mode = 0644,
  193. .proc_handler = proc_dointvec,
  194. },
  195. {
  196. .procname = "sack_timeout",
  197. .data = &sctp_sack_timeout,
  198. .maxlen = sizeof(int),
  199. .mode = 0644,
  200. .proc_handler = proc_dointvec_minmax,
  201. .extra1 = &sack_timer_min,
  202. .extra2 = &sack_timer_max,
  203. },
  204. {
  205. .procname = "sctp_mem",
  206. .data = &sysctl_sctp_mem,
  207. .maxlen = sizeof(sysctl_sctp_mem),
  208. .mode = 0644,
  209. .proc_handler = proc_doulongvec_minmax
  210. },
  211. {
  212. .procname = "sctp_rmem",
  213. .data = &sysctl_sctp_rmem,
  214. .maxlen = sizeof(sysctl_sctp_rmem),
  215. .mode = 0644,
  216. .proc_handler = proc_dointvec,
  217. },
  218. {
  219. .procname = "sctp_wmem",
  220. .data = &sysctl_sctp_wmem,
  221. .maxlen = sizeof(sysctl_sctp_wmem),
  222. .mode = 0644,
  223. .proc_handler = proc_dointvec,
  224. },
  225. {
  226. .procname = "auth_enable",
  227. .data = &sctp_auth_enable,
  228. .maxlen = sizeof(int),
  229. .mode = 0644,
  230. .proc_handler = proc_dointvec,
  231. },
  232. {
  233. .procname = "addip_noauth_enable",
  234. .data = &sctp_addip_noauth,
  235. .maxlen = sizeof(int),
  236. .mode = 0644,
  237. .proc_handler = proc_dointvec,
  238. },
  239. {
  240. .procname = "addr_scope_policy",
  241. .data = &sctp_scope_policy,
  242. .maxlen = sizeof(int),
  243. .mode = 0644,
  244. .proc_handler = proc_dointvec_minmax,
  245. .extra1 = &zero,
  246. .extra2 = &addr_scope_max,
  247. },
  248. {
  249. .procname = "rwnd_update_shift",
  250. .data = &sctp_rwnd_upd_shift,
  251. .maxlen = sizeof(int),
  252. .mode = 0644,
  253. .proc_handler = &proc_dointvec_minmax,
  254. .extra1 = &one,
  255. .extra2 = &rwnd_scale_max,
  256. },
  257. { /* sentinel */ }
  258. };
  259. static struct ctl_path sctp_path[] = {
  260. { .procname = "net", },
  261. { .procname = "sctp", },
  262. { }
  263. };
  264. static struct ctl_table_header * sctp_sysctl_header;
  265. /* Sysctl registration. */
  266. void sctp_sysctl_register(void)
  267. {
  268. sctp_sysctl_header = register_sysctl_paths(sctp_path, sctp_table);
  269. }
  270. /* Sysctl deregistration. */
  271. void sctp_sysctl_unregister(void)
  272. {
  273. unregister_sysctl_table(sctp_sysctl_header);
  274. }