sysctl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* SCTP kernel implementation
  3. * (C) Copyright IBM Corp. 2002, 2004
  4. * Copyright (c) 2002 Intel Corp.
  5. *
  6. * This file is part of the SCTP kernel implementation
  7. *
  8. * Sysctl related interfaces for SCTP.
  9. *
  10. * Please send any bug reports or fixes you make to the
  11. * email address(es):
  12. * lksctp developers <linux-sctp@vger.kernel.org>
  13. *
  14. * Written or modified by:
  15. * Mingqin Liu <liuming@us.ibm.com>
  16. * Jon Grimm <jgrimm@us.ibm.com>
  17. * Ardelle Fan <ardelle.fan@intel.com>
  18. * Ryan Layer <rmlayer@us.ibm.com>
  19. * Sridhar Samudrala <sri@us.ibm.com>
  20. */
  21. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  22. #include <net/sctp/structs.h>
  23. #include <net/sctp/sctp.h>
  24. #include <linux/sysctl.h>
  25. static int timer_max = 86400000; /* ms in one day */
  26. static int sack_timer_min = 1;
  27. static int sack_timer_max = 500;
  28. static int addr_scope_max = SCTP_SCOPE_POLICY_MAX;
  29. static int rwnd_scale_max = 16;
  30. static int rto_alpha_min = 0;
  31. static int rto_beta_min = 0;
  32. static int rto_alpha_max = 1000;
  33. static int rto_beta_max = 1000;
  34. static int pf_expose_max = SCTP_PF_EXPOSE_MAX;
  35. static int ps_retrans_max = SCTP_PS_RETRANS_MAX;
  36. static int udp_port_max = 65535;
  37. static unsigned long max_autoclose_min = 0;
  38. static unsigned long max_autoclose_max =
  39. (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
  40. ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
  41. static int proc_sctp_do_hmac_alg(const struct ctl_table *ctl, int write,
  42. void *buffer, size_t *lenp, loff_t *ppos);
  43. static int proc_sctp_do_rto_min(const struct ctl_table *ctl, int write,
  44. void *buffer, size_t *lenp, loff_t *ppos);
  45. static int proc_sctp_do_rto_max(const struct ctl_table *ctl, int write, void *buffer,
  46. size_t *lenp, loff_t *ppos);
  47. static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write, void *buffer,
  48. size_t *lenp, loff_t *ppos);
  49. static int proc_sctp_do_alpha_beta(const struct ctl_table *ctl, int write,
  50. void *buffer, size_t *lenp, loff_t *ppos);
  51. static int proc_sctp_do_auth(const struct ctl_table *ctl, int write,
  52. void *buffer, size_t *lenp, loff_t *ppos);
  53. static int proc_sctp_do_probe_interval(const struct ctl_table *ctl, int write,
  54. void *buffer, size_t *lenp, loff_t *ppos);
  55. static struct ctl_table sctp_table[] = {
  56. {
  57. .procname = "sctp_mem",
  58. .data = &sysctl_sctp_mem,
  59. .maxlen = sizeof(sysctl_sctp_mem),
  60. .mode = 0644,
  61. .proc_handler = proc_doulongvec_minmax
  62. },
  63. {
  64. .procname = "sctp_rmem",
  65. .data = &sysctl_sctp_rmem,
  66. .maxlen = sizeof(sysctl_sctp_rmem),
  67. .mode = 0644,
  68. .proc_handler = proc_dointvec,
  69. },
  70. {
  71. .procname = "sctp_wmem",
  72. .data = &sysctl_sctp_wmem,
  73. .maxlen = sizeof(sysctl_sctp_wmem),
  74. .mode = 0644,
  75. .proc_handler = proc_dointvec,
  76. },
  77. };
  78. /* The following index defines are used in sctp_sysctl_net_register().
  79. * If you add new items to the sctp_net_table, please ensure that
  80. * the index values of these defines hold the same meaning indicated by
  81. * their macro names when they appear in sctp_net_table.
  82. */
  83. #define SCTP_RTO_MIN_IDX 0
  84. #define SCTP_RTO_MAX_IDX 1
  85. #define SCTP_PF_RETRANS_IDX 2
  86. #define SCTP_PS_RETRANS_IDX 3
  87. static struct ctl_table sctp_net_table[] = {
  88. [SCTP_RTO_MIN_IDX] = {
  89. .procname = "rto_min",
  90. .data = &init_net.sctp.rto_min,
  91. .maxlen = sizeof(unsigned int),
  92. .mode = 0644,
  93. .proc_handler = proc_sctp_do_rto_min,
  94. .extra1 = SYSCTL_ONE,
  95. .extra2 = &init_net.sctp.rto_max
  96. },
  97. [SCTP_RTO_MAX_IDX] = {
  98. .procname = "rto_max",
  99. .data = &init_net.sctp.rto_max,
  100. .maxlen = sizeof(unsigned int),
  101. .mode = 0644,
  102. .proc_handler = proc_sctp_do_rto_max,
  103. .extra1 = &init_net.sctp.rto_min,
  104. .extra2 = &timer_max
  105. },
  106. [SCTP_PF_RETRANS_IDX] = {
  107. .procname = "pf_retrans",
  108. .data = &init_net.sctp.pf_retrans,
  109. .maxlen = sizeof(int),
  110. .mode = 0644,
  111. .proc_handler = proc_dointvec_minmax,
  112. .extra1 = SYSCTL_ZERO,
  113. .extra2 = &init_net.sctp.ps_retrans,
  114. },
  115. [SCTP_PS_RETRANS_IDX] = {
  116. .procname = "ps_retrans",
  117. .data = &init_net.sctp.ps_retrans,
  118. .maxlen = sizeof(int),
  119. .mode = 0644,
  120. .proc_handler = proc_dointvec_minmax,
  121. .extra1 = &init_net.sctp.pf_retrans,
  122. .extra2 = &ps_retrans_max,
  123. },
  124. {
  125. .procname = "rto_initial",
  126. .data = &init_net.sctp.rto_initial,
  127. .maxlen = sizeof(unsigned int),
  128. .mode = 0644,
  129. .proc_handler = proc_dointvec_minmax,
  130. .extra1 = SYSCTL_ONE,
  131. .extra2 = &timer_max
  132. },
  133. {
  134. .procname = "rto_alpha_exp_divisor",
  135. .data = &init_net.sctp.rto_alpha,
  136. .maxlen = sizeof(int),
  137. .mode = 0644,
  138. .proc_handler = proc_sctp_do_alpha_beta,
  139. .extra1 = &rto_alpha_min,
  140. .extra2 = &rto_alpha_max,
  141. },
  142. {
  143. .procname = "rto_beta_exp_divisor",
  144. .data = &init_net.sctp.rto_beta,
  145. .maxlen = sizeof(int),
  146. .mode = 0644,
  147. .proc_handler = proc_sctp_do_alpha_beta,
  148. .extra1 = &rto_beta_min,
  149. .extra2 = &rto_beta_max,
  150. },
  151. {
  152. .procname = "max_burst",
  153. .data = &init_net.sctp.max_burst,
  154. .maxlen = sizeof(int),
  155. .mode = 0644,
  156. .proc_handler = proc_dointvec_minmax,
  157. .extra1 = SYSCTL_ZERO,
  158. .extra2 = SYSCTL_INT_MAX,
  159. },
  160. {
  161. .procname = "cookie_preserve_enable",
  162. .data = &init_net.sctp.cookie_preserve_enable,
  163. .maxlen = sizeof(int),
  164. .mode = 0644,
  165. .proc_handler = proc_dointvec,
  166. },
  167. {
  168. .procname = "cookie_hmac_alg",
  169. .data = &init_net.sctp.sctp_hmac_alg,
  170. .maxlen = 8,
  171. .mode = 0644,
  172. .proc_handler = proc_sctp_do_hmac_alg,
  173. },
  174. {
  175. .procname = "valid_cookie_life",
  176. .data = &init_net.sctp.valid_cookie_life,
  177. .maxlen = sizeof(unsigned int),
  178. .mode = 0644,
  179. .proc_handler = proc_dointvec_minmax,
  180. .extra1 = SYSCTL_ONE,
  181. .extra2 = &timer_max
  182. },
  183. {
  184. .procname = "sack_timeout",
  185. .data = &init_net.sctp.sack_timeout,
  186. .maxlen = sizeof(int),
  187. .mode = 0644,
  188. .proc_handler = proc_dointvec_minmax,
  189. .extra1 = &sack_timer_min,
  190. .extra2 = &sack_timer_max,
  191. },
  192. {
  193. .procname = "hb_interval",
  194. .data = &init_net.sctp.hb_interval,
  195. .maxlen = sizeof(unsigned int),
  196. .mode = 0644,
  197. .proc_handler = proc_dointvec_minmax,
  198. .extra1 = SYSCTL_ONE,
  199. .extra2 = &timer_max
  200. },
  201. {
  202. .procname = "association_max_retrans",
  203. .data = &init_net.sctp.max_retrans_association,
  204. .maxlen = sizeof(int),
  205. .mode = 0644,
  206. .proc_handler = proc_dointvec_minmax,
  207. .extra1 = SYSCTL_ONE,
  208. .extra2 = SYSCTL_INT_MAX,
  209. },
  210. {
  211. .procname = "path_max_retrans",
  212. .data = &init_net.sctp.max_retrans_path,
  213. .maxlen = sizeof(int),
  214. .mode = 0644,
  215. .proc_handler = proc_dointvec_minmax,
  216. .extra1 = SYSCTL_ONE,
  217. .extra2 = SYSCTL_INT_MAX,
  218. },
  219. {
  220. .procname = "max_init_retransmits",
  221. .data = &init_net.sctp.max_retrans_init,
  222. .maxlen = sizeof(int),
  223. .mode = 0644,
  224. .proc_handler = proc_dointvec_minmax,
  225. .extra1 = SYSCTL_ONE,
  226. .extra2 = SYSCTL_INT_MAX,
  227. },
  228. {
  229. .procname = "sndbuf_policy",
  230. .data = &init_net.sctp.sndbuf_policy,
  231. .maxlen = sizeof(int),
  232. .mode = 0644,
  233. .proc_handler = proc_dointvec,
  234. },
  235. {
  236. .procname = "rcvbuf_policy",
  237. .data = &init_net.sctp.rcvbuf_policy,
  238. .maxlen = sizeof(int),
  239. .mode = 0644,
  240. .proc_handler = proc_dointvec,
  241. },
  242. {
  243. .procname = "default_auto_asconf",
  244. .data = &init_net.sctp.default_auto_asconf,
  245. .maxlen = sizeof(int),
  246. .mode = 0644,
  247. .proc_handler = proc_dointvec,
  248. },
  249. {
  250. .procname = "addip_enable",
  251. .data = &init_net.sctp.addip_enable,
  252. .maxlen = sizeof(int),
  253. .mode = 0644,
  254. .proc_handler = proc_dointvec,
  255. },
  256. {
  257. .procname = "addip_noauth_enable",
  258. .data = &init_net.sctp.addip_noauth,
  259. .maxlen = sizeof(int),
  260. .mode = 0644,
  261. .proc_handler = proc_dointvec,
  262. },
  263. {
  264. .procname = "prsctp_enable",
  265. .data = &init_net.sctp.prsctp_enable,
  266. .maxlen = sizeof(int),
  267. .mode = 0644,
  268. .proc_handler = proc_dointvec,
  269. },
  270. {
  271. .procname = "reconf_enable",
  272. .data = &init_net.sctp.reconf_enable,
  273. .maxlen = sizeof(int),
  274. .mode = 0644,
  275. .proc_handler = proc_dointvec,
  276. },
  277. {
  278. .procname = "auth_enable",
  279. .data = &init_net.sctp.auth_enable,
  280. .maxlen = sizeof(int),
  281. .mode = 0644,
  282. .proc_handler = proc_sctp_do_auth,
  283. },
  284. {
  285. .procname = "intl_enable",
  286. .data = &init_net.sctp.intl_enable,
  287. .maxlen = sizeof(int),
  288. .mode = 0644,
  289. .proc_handler = proc_dointvec,
  290. },
  291. {
  292. .procname = "ecn_enable",
  293. .data = &init_net.sctp.ecn_enable,
  294. .maxlen = sizeof(int),
  295. .mode = 0644,
  296. .proc_handler = proc_dointvec,
  297. },
  298. {
  299. .procname = "plpmtud_probe_interval",
  300. .data = &init_net.sctp.probe_interval,
  301. .maxlen = sizeof(int),
  302. .mode = 0644,
  303. .proc_handler = proc_sctp_do_probe_interval,
  304. },
  305. {
  306. .procname = "udp_port",
  307. .data = &init_net.sctp.udp_port,
  308. .maxlen = sizeof(int),
  309. .mode = 0644,
  310. .proc_handler = proc_sctp_do_udp_port,
  311. .extra1 = SYSCTL_ZERO,
  312. .extra2 = &udp_port_max,
  313. },
  314. {
  315. .procname = "encap_port",
  316. .data = &init_net.sctp.encap_port,
  317. .maxlen = sizeof(int),
  318. .mode = 0644,
  319. .proc_handler = proc_dointvec_minmax,
  320. .extra1 = SYSCTL_ZERO,
  321. .extra2 = &udp_port_max,
  322. },
  323. {
  324. .procname = "addr_scope_policy",
  325. .data = &init_net.sctp.scope_policy,
  326. .maxlen = sizeof(int),
  327. .mode = 0644,
  328. .proc_handler = proc_dointvec_minmax,
  329. .extra1 = SYSCTL_ZERO,
  330. .extra2 = &addr_scope_max,
  331. },
  332. {
  333. .procname = "rwnd_update_shift",
  334. .data = &init_net.sctp.rwnd_upd_shift,
  335. .maxlen = sizeof(int),
  336. .mode = 0644,
  337. .proc_handler = &proc_dointvec_minmax,
  338. .extra1 = SYSCTL_ONE,
  339. .extra2 = &rwnd_scale_max,
  340. },
  341. {
  342. .procname = "max_autoclose",
  343. .data = &init_net.sctp.max_autoclose,
  344. .maxlen = sizeof(unsigned long),
  345. .mode = 0644,
  346. .proc_handler = &proc_doulongvec_minmax,
  347. .extra1 = &max_autoclose_min,
  348. .extra2 = &max_autoclose_max,
  349. },
  350. #ifdef CONFIG_NET_L3_MASTER_DEV
  351. {
  352. .procname = "l3mdev_accept",
  353. .data = &init_net.sctp.l3mdev_accept,
  354. .maxlen = sizeof(int),
  355. .mode = 0644,
  356. .proc_handler = proc_dointvec_minmax,
  357. .extra1 = SYSCTL_ZERO,
  358. .extra2 = SYSCTL_ONE,
  359. },
  360. #endif
  361. {
  362. .procname = "pf_enable",
  363. .data = &init_net.sctp.pf_enable,
  364. .maxlen = sizeof(int),
  365. .mode = 0644,
  366. .proc_handler = proc_dointvec,
  367. },
  368. {
  369. .procname = "pf_expose",
  370. .data = &init_net.sctp.pf_expose,
  371. .maxlen = sizeof(int),
  372. .mode = 0644,
  373. .proc_handler = proc_dointvec_minmax,
  374. .extra1 = SYSCTL_ZERO,
  375. .extra2 = &pf_expose_max,
  376. },
  377. };
  378. static int proc_sctp_do_hmac_alg(const struct ctl_table *ctl, int write,
  379. void *buffer, size_t *lenp, loff_t *ppos)
  380. {
  381. struct net *net = container_of(ctl->data, struct net,
  382. sctp.sctp_hmac_alg);
  383. struct ctl_table tbl;
  384. bool changed = false;
  385. char *none = "none";
  386. char tmp[8] = {0};
  387. int ret;
  388. memset(&tbl, 0, sizeof(struct ctl_table));
  389. if (write) {
  390. tbl.data = tmp;
  391. tbl.maxlen = sizeof(tmp);
  392. } else {
  393. tbl.data = net->sctp.sctp_hmac_alg ? : none;
  394. tbl.maxlen = strlen(tbl.data);
  395. }
  396. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  397. if (write && ret == 0) {
  398. #ifdef CONFIG_CRYPTO_MD5
  399. if (!strncmp(tmp, "md5", 3)) {
  400. net->sctp.sctp_hmac_alg = "md5";
  401. changed = true;
  402. }
  403. #endif
  404. #ifdef CONFIG_CRYPTO_SHA1
  405. if (!strncmp(tmp, "sha1", 4)) {
  406. net->sctp.sctp_hmac_alg = "sha1";
  407. changed = true;
  408. }
  409. #endif
  410. if (!strncmp(tmp, "none", 4)) {
  411. net->sctp.sctp_hmac_alg = NULL;
  412. changed = true;
  413. }
  414. if (!changed)
  415. ret = -EINVAL;
  416. }
  417. return ret;
  418. }
  419. static int proc_sctp_do_rto_min(const struct ctl_table *ctl, int write,
  420. void *buffer, size_t *lenp, loff_t *ppos)
  421. {
  422. struct net *net = container_of(ctl->data, struct net, sctp.rto_min);
  423. unsigned int min = *(unsigned int *) ctl->extra1;
  424. unsigned int max = *(unsigned int *) ctl->extra2;
  425. struct ctl_table tbl;
  426. int ret, new_value;
  427. memset(&tbl, 0, sizeof(struct ctl_table));
  428. tbl.maxlen = sizeof(unsigned int);
  429. if (write)
  430. tbl.data = &new_value;
  431. else
  432. tbl.data = &net->sctp.rto_min;
  433. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  434. if (write && ret == 0) {
  435. if (new_value > max || new_value < min)
  436. return -EINVAL;
  437. net->sctp.rto_min = new_value;
  438. }
  439. return ret;
  440. }
  441. static int proc_sctp_do_rto_max(const struct ctl_table *ctl, int write,
  442. void *buffer, size_t *lenp, loff_t *ppos)
  443. {
  444. struct net *net = container_of(ctl->data, struct net, sctp.rto_max);
  445. unsigned int min = *(unsigned int *) ctl->extra1;
  446. unsigned int max = *(unsigned int *) ctl->extra2;
  447. struct ctl_table tbl;
  448. int ret, new_value;
  449. memset(&tbl, 0, sizeof(struct ctl_table));
  450. tbl.maxlen = sizeof(unsigned int);
  451. if (write)
  452. tbl.data = &new_value;
  453. else
  454. tbl.data = &net->sctp.rto_max;
  455. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  456. if (write && ret == 0) {
  457. if (new_value > max || new_value < min)
  458. return -EINVAL;
  459. net->sctp.rto_max = new_value;
  460. }
  461. return ret;
  462. }
  463. static int proc_sctp_do_alpha_beta(const struct ctl_table *ctl, int write,
  464. void *buffer, size_t *lenp, loff_t *ppos)
  465. {
  466. if (write)
  467. pr_warn_once("Changing rto_alpha or rto_beta may lead to "
  468. "suboptimal rtt/srtt estimations!\n");
  469. return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  470. }
  471. static int proc_sctp_do_auth(const struct ctl_table *ctl, int write,
  472. void *buffer, size_t *lenp, loff_t *ppos)
  473. {
  474. struct net *net = container_of(ctl->data, struct net, sctp.auth_enable);
  475. struct ctl_table tbl;
  476. int new_value, ret;
  477. memset(&tbl, 0, sizeof(struct ctl_table));
  478. tbl.maxlen = sizeof(unsigned int);
  479. if (write)
  480. tbl.data = &new_value;
  481. else
  482. tbl.data = &net->sctp.auth_enable;
  483. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  484. if (write && ret == 0) {
  485. struct sock *sk = net->sctp.ctl_sock;
  486. net->sctp.auth_enable = new_value;
  487. /* Update the value in the control socket */
  488. lock_sock(sk);
  489. sctp_sk(sk)->ep->auth_enable = new_value;
  490. release_sock(sk);
  491. }
  492. return ret;
  493. }
  494. static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write,
  495. void *buffer, size_t *lenp, loff_t *ppos)
  496. {
  497. struct net *net = container_of(ctl->data, struct net, sctp.udp_port);
  498. unsigned int min = *(unsigned int *)ctl->extra1;
  499. unsigned int max = *(unsigned int *)ctl->extra2;
  500. struct ctl_table tbl;
  501. int ret, new_value;
  502. memset(&tbl, 0, sizeof(struct ctl_table));
  503. tbl.maxlen = sizeof(unsigned int);
  504. if (write)
  505. tbl.data = &new_value;
  506. else
  507. tbl.data = &net->sctp.udp_port;
  508. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  509. if (write && ret == 0) {
  510. struct sock *sk = net->sctp.ctl_sock;
  511. if (new_value > max || new_value < min)
  512. return -EINVAL;
  513. net->sctp.udp_port = new_value;
  514. sctp_udp_sock_stop(net);
  515. if (new_value) {
  516. ret = sctp_udp_sock_start(net);
  517. if (ret)
  518. net->sctp.udp_port = 0;
  519. }
  520. /* Update the value in the control socket */
  521. lock_sock(sk);
  522. sctp_sk(sk)->udp_port = htons(net->sctp.udp_port);
  523. release_sock(sk);
  524. }
  525. return ret;
  526. }
  527. static int proc_sctp_do_probe_interval(const struct ctl_table *ctl, int write,
  528. void *buffer, size_t *lenp, loff_t *ppos)
  529. {
  530. struct net *net = container_of(ctl->data, struct net,
  531. sctp.probe_interval);
  532. struct ctl_table tbl;
  533. int ret, new_value;
  534. memset(&tbl, 0, sizeof(struct ctl_table));
  535. tbl.maxlen = sizeof(unsigned int);
  536. if (write)
  537. tbl.data = &new_value;
  538. else
  539. tbl.data = &net->sctp.probe_interval;
  540. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  541. if (write && ret == 0) {
  542. if (new_value && new_value < SCTP_PROBE_TIMER_MIN)
  543. return -EINVAL;
  544. net->sctp.probe_interval = new_value;
  545. }
  546. return ret;
  547. }
  548. int sctp_sysctl_net_register(struct net *net)
  549. {
  550. size_t table_size = ARRAY_SIZE(sctp_net_table);
  551. struct ctl_table *table;
  552. int i;
  553. table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
  554. if (!table)
  555. return -ENOMEM;
  556. for (i = 0; i < table_size; i++)
  557. table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
  558. table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max;
  559. table[SCTP_RTO_MAX_IDX].extra1 = &net->sctp.rto_min;
  560. table[SCTP_PF_RETRANS_IDX].extra2 = &net->sctp.ps_retrans;
  561. table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans;
  562. net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp",
  563. table, table_size);
  564. if (net->sctp.sysctl_header == NULL) {
  565. kfree(table);
  566. return -ENOMEM;
  567. }
  568. return 0;
  569. }
  570. void sctp_sysctl_net_unregister(struct net *net)
  571. {
  572. const struct ctl_table *table;
  573. table = net->sctp.sysctl_header->ctl_table_arg;
  574. unregister_net_sysctl_table(net->sctp.sysctl_header);
  575. kfree(table);
  576. }
  577. static struct ctl_table_header *sctp_sysctl_header;
  578. /* Sysctl registration. */
  579. void sctp_sysctl_register(void)
  580. {
  581. sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
  582. }
  583. /* Sysctl deregistration. */
  584. void sctp_sysctl_unregister(void)
  585. {
  586. unregister_net_sysctl_table(sctp_sysctl_header);
  587. }