sysctl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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.cookie_auth_enable,
  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.cookie_auth_enable);
  383. struct ctl_table tbl;
  384. char tmp[8] = {0};
  385. int ret;
  386. memset(&tbl, 0, sizeof(struct ctl_table));
  387. if (write) {
  388. tbl.data = tmp;
  389. tbl.maxlen = sizeof(tmp) - 1;
  390. ret = proc_dostring(&tbl, 1, buffer, lenp, ppos);
  391. if (ret)
  392. return ret;
  393. if (!strcmp(tmp, "sha256")) {
  394. net->sctp.cookie_auth_enable = 1;
  395. return 0;
  396. }
  397. if (!strcmp(tmp, "none")) {
  398. net->sctp.cookie_auth_enable = 0;
  399. return 0;
  400. }
  401. return -EINVAL;
  402. }
  403. if (net->sctp.cookie_auth_enable)
  404. tbl.data = (char *)"sha256";
  405. else
  406. tbl.data = (char *)"none";
  407. tbl.maxlen = strlen(tbl.data);
  408. return proc_dostring(&tbl, 0, buffer, lenp, ppos);
  409. }
  410. static int proc_sctp_do_rto_min(const struct ctl_table *ctl, int write,
  411. void *buffer, size_t *lenp, loff_t *ppos)
  412. {
  413. struct net *net = container_of(ctl->data, struct net, sctp.rto_min);
  414. unsigned int min = *(unsigned int *) ctl->extra1;
  415. unsigned int max = *(unsigned int *) ctl->extra2;
  416. struct ctl_table tbl;
  417. int ret, new_value;
  418. memset(&tbl, 0, sizeof(struct ctl_table));
  419. tbl.maxlen = sizeof(unsigned int);
  420. if (write)
  421. tbl.data = &new_value;
  422. else
  423. tbl.data = &net->sctp.rto_min;
  424. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  425. if (write && ret == 0) {
  426. if (new_value > max || new_value < min)
  427. return -EINVAL;
  428. net->sctp.rto_min = new_value;
  429. }
  430. return ret;
  431. }
  432. static int proc_sctp_do_rto_max(const struct ctl_table *ctl, int write,
  433. void *buffer, size_t *lenp, loff_t *ppos)
  434. {
  435. struct net *net = container_of(ctl->data, struct net, sctp.rto_max);
  436. unsigned int min = *(unsigned int *) ctl->extra1;
  437. unsigned int max = *(unsigned int *) ctl->extra2;
  438. struct ctl_table tbl;
  439. int ret, new_value;
  440. memset(&tbl, 0, sizeof(struct ctl_table));
  441. tbl.maxlen = sizeof(unsigned int);
  442. if (write)
  443. tbl.data = &new_value;
  444. else
  445. tbl.data = &net->sctp.rto_max;
  446. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  447. if (write && ret == 0) {
  448. if (new_value > max || new_value < min)
  449. return -EINVAL;
  450. net->sctp.rto_max = new_value;
  451. }
  452. return ret;
  453. }
  454. static int proc_sctp_do_alpha_beta(const struct ctl_table *ctl, int write,
  455. void *buffer, size_t *lenp, loff_t *ppos)
  456. {
  457. if (write)
  458. pr_warn_once("Changing rto_alpha or rto_beta may lead to "
  459. "suboptimal rtt/srtt estimations!\n");
  460. return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  461. }
  462. static int proc_sctp_do_auth(const struct ctl_table *ctl, int write,
  463. void *buffer, size_t *lenp, loff_t *ppos)
  464. {
  465. struct net *net = container_of(ctl->data, struct net, sctp.auth_enable);
  466. struct ctl_table tbl;
  467. int new_value, ret;
  468. memset(&tbl, 0, sizeof(struct ctl_table));
  469. tbl.maxlen = sizeof(unsigned int);
  470. if (write)
  471. tbl.data = &new_value;
  472. else
  473. tbl.data = &net->sctp.auth_enable;
  474. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  475. if (write && ret == 0) {
  476. struct sock *sk = net->sctp.ctl_sock;
  477. net->sctp.auth_enable = new_value;
  478. /* Update the value in the control socket */
  479. lock_sock(sk);
  480. sctp_sk(sk)->ep->auth_enable = new_value;
  481. release_sock(sk);
  482. }
  483. return ret;
  484. }
  485. static DEFINE_MUTEX(sctp_sysctl_mutex);
  486. static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write,
  487. void *buffer, size_t *lenp, loff_t *ppos)
  488. {
  489. struct net *net = container_of(ctl->data, struct net, sctp.udp_port);
  490. unsigned int min = *(unsigned int *)ctl->extra1;
  491. unsigned int max = *(unsigned int *)ctl->extra2;
  492. struct ctl_table tbl;
  493. int ret, new_value;
  494. memset(&tbl, 0, sizeof(struct ctl_table));
  495. tbl.maxlen = sizeof(unsigned int);
  496. if (write)
  497. tbl.data = &new_value;
  498. else
  499. tbl.data = &net->sctp.udp_port;
  500. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  501. if (write && ret == 0) {
  502. struct sock *sk = net->sctp.ctl_sock;
  503. if (new_value > max || new_value < min)
  504. return -EINVAL;
  505. mutex_lock(&sctp_sysctl_mutex);
  506. net->sctp.udp_port = new_value;
  507. sctp_udp_sock_stop(net);
  508. if (new_value) {
  509. ret = sctp_udp_sock_start(net);
  510. if (ret)
  511. net->sctp.udp_port = 0;
  512. }
  513. /* Update the value in the control socket */
  514. lock_sock(sk);
  515. sctp_sk(sk)->udp_port = htons(net->sctp.udp_port);
  516. release_sock(sk);
  517. mutex_unlock(&sctp_sysctl_mutex);
  518. }
  519. return ret;
  520. }
  521. static int proc_sctp_do_probe_interval(const struct ctl_table *ctl, int write,
  522. void *buffer, size_t *lenp, loff_t *ppos)
  523. {
  524. struct net *net = container_of(ctl->data, struct net,
  525. sctp.probe_interval);
  526. struct ctl_table tbl;
  527. int ret, new_value;
  528. memset(&tbl, 0, sizeof(struct ctl_table));
  529. tbl.maxlen = sizeof(unsigned int);
  530. if (write)
  531. tbl.data = &new_value;
  532. else
  533. tbl.data = &net->sctp.probe_interval;
  534. ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
  535. if (write && ret == 0) {
  536. if (new_value && new_value < SCTP_PROBE_TIMER_MIN)
  537. return -EINVAL;
  538. net->sctp.probe_interval = new_value;
  539. }
  540. return ret;
  541. }
  542. int sctp_sysctl_net_register(struct net *net)
  543. {
  544. size_t table_size = ARRAY_SIZE(sctp_net_table);
  545. struct ctl_table *table;
  546. int i;
  547. table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
  548. if (!table)
  549. return -ENOMEM;
  550. for (i = 0; i < table_size; i++)
  551. table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
  552. table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max;
  553. table[SCTP_RTO_MAX_IDX].extra1 = &net->sctp.rto_min;
  554. table[SCTP_PF_RETRANS_IDX].extra2 = &net->sctp.ps_retrans;
  555. table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans;
  556. net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp",
  557. table, table_size);
  558. if (net->sctp.sysctl_header == NULL) {
  559. kfree(table);
  560. return -ENOMEM;
  561. }
  562. return 0;
  563. }
  564. void sctp_sysctl_net_unregister(struct net *net)
  565. {
  566. const struct ctl_table *table;
  567. table = net->sctp.sysctl_header->ctl_table_arg;
  568. unregister_net_sysctl_table(net->sctp.sysctl_header);
  569. kfree(table);
  570. }
  571. static struct ctl_table_header *sctp_sysctl_header;
  572. /* Sysctl registration. */
  573. void sctp_sysctl_register(void)
  574. {
  575. sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
  576. }
  577. /* Sysctl deregistration. */
  578. void sctp_sysctl_unregister(void)
  579. {
  580. unregister_net_sysctl_table(sctp_sysctl_header);
  581. }