sysctl.c 7.9 KB

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