sysctl.c 7.6 KB

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