sysctl.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. static unsigned long max_autoclose_min = 0;
  55. static unsigned long max_autoclose_max =
  56. (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
  57. ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
  58. extern long sysctl_sctp_mem[3];
  59. extern int sysctl_sctp_rmem[3];
  60. extern int sysctl_sctp_wmem[3];
  61. static ctl_table sctp_table[] = {
  62. {
  63. .procname = "sctp_mem",
  64. .data = &sysctl_sctp_mem,
  65. .maxlen = sizeof(sysctl_sctp_mem),
  66. .mode = 0644,
  67. .proc_handler = proc_doulongvec_minmax
  68. },
  69. {
  70. .procname = "sctp_rmem",
  71. .data = &sysctl_sctp_rmem,
  72. .maxlen = sizeof(sysctl_sctp_rmem),
  73. .mode = 0644,
  74. .proc_handler = proc_dointvec,
  75. },
  76. {
  77. .procname = "sctp_wmem",
  78. .data = &sysctl_sctp_wmem,
  79. .maxlen = sizeof(sysctl_sctp_wmem),
  80. .mode = 0644,
  81. .proc_handler = proc_dointvec,
  82. },
  83. { /* sentinel */ }
  84. };
  85. static ctl_table sctp_net_table[] = {
  86. {
  87. .procname = "rto_initial",
  88. .data = &init_net.sctp.rto_initial,
  89. .maxlen = sizeof(unsigned int),
  90. .mode = 0644,
  91. .proc_handler = proc_dointvec_minmax,
  92. .extra1 = &one,
  93. .extra2 = &timer_max
  94. },
  95. {
  96. .procname = "rto_min",
  97. .data = &init_net.sctp.rto_min,
  98. .maxlen = sizeof(unsigned int),
  99. .mode = 0644,
  100. .proc_handler = proc_dointvec_minmax,
  101. .extra1 = &one,
  102. .extra2 = &timer_max
  103. },
  104. {
  105. .procname = "rto_max",
  106. .data = &init_net.sctp.rto_max,
  107. .maxlen = sizeof(unsigned int),
  108. .mode = 0644,
  109. .proc_handler = proc_dointvec_minmax,
  110. .extra1 = &one,
  111. .extra2 = &timer_max
  112. },
  113. {
  114. .procname = "rto_alpha_exp_divisor",
  115. .data = &init_net.sctp.rto_alpha,
  116. .maxlen = sizeof(int),
  117. .mode = 0444,
  118. .proc_handler = proc_dointvec,
  119. },
  120. {
  121. .procname = "rto_beta_exp_divisor",
  122. .data = &init_net.sctp.rto_beta,
  123. .maxlen = sizeof(int),
  124. .mode = 0444,
  125. .proc_handler = proc_dointvec,
  126. },
  127. {
  128. .procname = "max_burst",
  129. .data = &init_net.sctp.max_burst,
  130. .maxlen = sizeof(int),
  131. .mode = 0644,
  132. .proc_handler = proc_dointvec_minmax,
  133. .extra1 = &zero,
  134. .extra2 = &int_max
  135. },
  136. {
  137. .procname = "cookie_preserve_enable",
  138. .data = &init_net.sctp.cookie_preserve_enable,
  139. .maxlen = sizeof(int),
  140. .mode = 0644,
  141. .proc_handler = proc_dointvec,
  142. },
  143. {
  144. .procname = "valid_cookie_life",
  145. .data = &init_net.sctp.valid_cookie_life,
  146. .maxlen = sizeof(unsigned int),
  147. .mode = 0644,
  148. .proc_handler = proc_dointvec_minmax,
  149. .extra1 = &one,
  150. .extra2 = &timer_max
  151. },
  152. {
  153. .procname = "sack_timeout",
  154. .data = &init_net.sctp.sack_timeout,
  155. .maxlen = sizeof(int),
  156. .mode = 0644,
  157. .proc_handler = proc_dointvec_minmax,
  158. .extra1 = &sack_timer_min,
  159. .extra2 = &sack_timer_max,
  160. },
  161. {
  162. .procname = "hb_interval",
  163. .data = &init_net.sctp.hb_interval,
  164. .maxlen = sizeof(unsigned int),
  165. .mode = 0644,
  166. .proc_handler = proc_dointvec_minmax,
  167. .extra1 = &one,
  168. .extra2 = &timer_max
  169. },
  170. {
  171. .procname = "association_max_retrans",
  172. .data = &init_net.sctp.max_retrans_association,
  173. .maxlen = sizeof(int),
  174. .mode = 0644,
  175. .proc_handler = proc_dointvec_minmax,
  176. .extra1 = &one,
  177. .extra2 = &int_max
  178. },
  179. {
  180. .procname = "path_max_retrans",
  181. .data = &init_net.sctp.max_retrans_path,
  182. .maxlen = sizeof(int),
  183. .mode = 0644,
  184. .proc_handler = proc_dointvec_minmax,
  185. .extra1 = &one,
  186. .extra2 = &int_max
  187. },
  188. {
  189. .procname = "max_init_retransmits",
  190. .data = &init_net.sctp.max_retrans_init,
  191. .maxlen = sizeof(int),
  192. .mode = 0644,
  193. .proc_handler = proc_dointvec_minmax,
  194. .extra1 = &one,
  195. .extra2 = &int_max
  196. },
  197. {
  198. .procname = "pf_retrans",
  199. .data = &init_net.sctp.pf_retrans,
  200. .maxlen = sizeof(int),
  201. .mode = 0644,
  202. .proc_handler = proc_dointvec_minmax,
  203. .extra1 = &zero,
  204. .extra2 = &int_max
  205. },
  206. {
  207. .procname = "sndbuf_policy",
  208. .data = &init_net.sctp.sndbuf_policy,
  209. .maxlen = sizeof(int),
  210. .mode = 0644,
  211. .proc_handler = proc_dointvec,
  212. },
  213. {
  214. .procname = "rcvbuf_policy",
  215. .data = &init_net.sctp.rcvbuf_policy,
  216. .maxlen = sizeof(int),
  217. .mode = 0644,
  218. .proc_handler = proc_dointvec,
  219. },
  220. {
  221. .procname = "default_auto_asconf",
  222. .data = &init_net.sctp.default_auto_asconf,
  223. .maxlen = sizeof(int),
  224. .mode = 0644,
  225. .proc_handler = proc_dointvec,
  226. },
  227. {
  228. .procname = "addip_enable",
  229. .data = &init_net.sctp.addip_enable,
  230. .maxlen = sizeof(int),
  231. .mode = 0644,
  232. .proc_handler = proc_dointvec,
  233. },
  234. {
  235. .procname = "addip_noauth_enable",
  236. .data = &init_net.sctp.addip_noauth,
  237. .maxlen = sizeof(int),
  238. .mode = 0644,
  239. .proc_handler = proc_dointvec,
  240. },
  241. {
  242. .procname = "prsctp_enable",
  243. .data = &init_net.sctp.prsctp_enable,
  244. .maxlen = sizeof(int),
  245. .mode = 0644,
  246. .proc_handler = proc_dointvec,
  247. },
  248. {
  249. .procname = "auth_enable",
  250. .data = &init_net.sctp.auth_enable,
  251. .maxlen = sizeof(int),
  252. .mode = 0644,
  253. .proc_handler = proc_dointvec,
  254. },
  255. {
  256. .procname = "addr_scope_policy",
  257. .data = &init_net.sctp.scope_policy,
  258. .maxlen = sizeof(int),
  259. .mode = 0644,
  260. .proc_handler = proc_dointvec_minmax,
  261. .extra1 = &zero,
  262. .extra2 = &addr_scope_max,
  263. },
  264. {
  265. .procname = "rwnd_update_shift",
  266. .data = &init_net.sctp.rwnd_upd_shift,
  267. .maxlen = sizeof(int),
  268. .mode = 0644,
  269. .proc_handler = &proc_dointvec_minmax,
  270. .extra1 = &one,
  271. .extra2 = &rwnd_scale_max,
  272. },
  273. {
  274. .procname = "max_autoclose",
  275. .data = &init_net.sctp.max_autoclose,
  276. .maxlen = sizeof(unsigned long),
  277. .mode = 0644,
  278. .proc_handler = &proc_doulongvec_minmax,
  279. .extra1 = &max_autoclose_min,
  280. .extra2 = &max_autoclose_max,
  281. },
  282. { /* sentinel */ }
  283. };
  284. int sctp_sysctl_net_register(struct net *net)
  285. {
  286. struct ctl_table *table;
  287. int i;
  288. table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
  289. if (!table)
  290. return -ENOMEM;
  291. for (i = 0; table[i].data; i++)
  292. table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
  293. net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
  294. return 0;
  295. }
  296. void sctp_sysctl_net_unregister(struct net *net)
  297. {
  298. unregister_net_sysctl_table(net->sctp.sysctl_header);
  299. }
  300. static struct ctl_table_header * sctp_sysctl_header;
  301. /* Sysctl registration. */
  302. void sctp_sysctl_register(void)
  303. {
  304. sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
  305. }
  306. /* Sysctl deregistration. */
  307. void sctp_sysctl_unregister(void)
  308. {
  309. unregister_net_sysctl_table(sctp_sysctl_header);
  310. }