Skip to content

Commit b58537a

Browse files
Daniel Borkmanndavem330
authored andcommitted
net: sctp: fix permissions for rto_alpha and rto_beta knobs
Commit 3fd091e ("[SCTP]: Remove multiple levels of msecs to jiffies conversions.") has silently changed permissions for rto_alpha and rto_beta knobs from 0644 to 0444. The purpose of this was to discourage users from tweaking rto_alpha and rto_beta knobs in production environments since they are key to correctly compute rtt/srtt. RFC4960 under section 6.3.1. RTO Calculation says regarding rto_alpha and rto_beta under rule C3 and C4: [...] C3) When a new RTT measurement R' is made, set RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| and SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' Note: The value of SRTT used in the update to RTTVAR is its value before updating SRTT itself using the second assignment. After the computation, update RTO <- SRTT + 4 * RTTVAR. C4) When data is in flight and when allowed by rule C5 below, a new RTT measurement MUST be made each round trip. Furthermore, new RTT measurements SHOULD be made no more than once per round trip for a given destination transport address. There are two reasons for this recommendation: First, it appears that measuring more frequently often does not in practice yield any significant benefit [ALLMAN99]; second, if measurements are made more often, then the values of RTO.Alpha and RTO.Beta in rule C3 above should be adjusted so that SRTT and RTTVAR still adjust to changes at roughly the same rate (in terms of how many round trips it takes them to reflect new values) as they would if making only one measurement per round-trip and using RTO.Alpha and RTO.Beta as given in rule C3. However, the exact nature of these adjustments remains a research issue. [...] While it is discouraged to adjust rto_alpha and rto_beta and not further specified how to adjust them, the RFC also doesn't explicitly forbid it, but rather gives a RECOMMENDED default value (rto_alpha=3, rto_beta=2). We have a couple of users relying on the old permissions before they got changed. That said, if someone really has the urge to adjust them, we could allow it with a warning in the log. Fixes: 3fd091e ("[SCTP]: Remove multiple levels of msecs to jiffies conversions.") Signed-off-by: Daniel Borkmann <[email protected]> Cc: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e4f7ae9 commit b58537a

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

net/sctp/sysctl.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
* Sridhar Samudrala <[email protected]>
3535
*/
3636

37+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38+
3739
#include <net/sctp/structs.h>
3840
#include <net/sctp/sctp.h>
3941
#include <linux/sysctl.h>
@@ -46,6 +48,11 @@ static int sack_timer_min = 1;
4648
static int sack_timer_max = 500;
4749
static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
4850
static int rwnd_scale_max = 16;
51+
static int rto_alpha_min = 0;
52+
static int rto_beta_min = 0;
53+
static int rto_alpha_max = 1000;
54+
static int rto_beta_max = 1000;
55+
4956
static unsigned long max_autoclose_min = 0;
5057
static unsigned long max_autoclose_max =
5158
(MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
@@ -64,6 +71,9 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
6471
static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
6572
void __user *buffer, size_t *lenp,
6673
loff_t *ppos);
74+
static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
75+
void __user *buffer, size_t *lenp,
76+
loff_t *ppos);
6777
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
6878
void __user *buffer, size_t *lenp,
6979
loff_t *ppos);
@@ -126,15 +136,19 @@ static struct ctl_table sctp_net_table[] = {
126136
.procname = "rto_alpha_exp_divisor",
127137
.data = &init_net.sctp.rto_alpha,
128138
.maxlen = sizeof(int),
129-
.mode = 0444,
130-
.proc_handler = proc_dointvec,
139+
.mode = 0644,
140+
.proc_handler = proc_sctp_do_alpha_beta,
141+
.extra1 = &rto_alpha_min,
142+
.extra2 = &rto_alpha_max,
131143
},
132144
{
133145
.procname = "rto_beta_exp_divisor",
134146
.data = &init_net.sctp.rto_beta,
135147
.maxlen = sizeof(int),
136-
.mode = 0444,
137-
.proc_handler = proc_dointvec,
148+
.mode = 0644,
149+
.proc_handler = proc_sctp_do_alpha_beta,
150+
.extra1 = &rto_beta_min,
151+
.extra2 = &rto_beta_max,
138152
},
139153
{
140154
.procname = "max_burst",
@@ -403,6 +417,16 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
403417
return ret;
404418
}
405419

420+
static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
421+
void __user *buffer, size_t *lenp,
422+
loff_t *ppos)
423+
{
424+
pr_warn_once("Changing rto_alpha or rto_beta may lead to "
425+
"suboptimal rtt/srtt estimations!\n");
426+
427+
return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
428+
}
429+
406430
static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
407431
void __user *buffer, size_t *lenp,
408432
loff_t *ppos)

0 commit comments

Comments
 (0)