sysctl.c 8.2 KB

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