sysctl.c 7.4 KB

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