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