tcp: make TCP_RTO_MIN/MAX be tunable

Upstream: no

tcp_rto_min,tcp_rto_max control the parameters of them.
remember that the min value of tcp_rto_min is 4ms which
be used to be div by RTO_MAX.

Signed-off-by: Shan Wei <davidshan@tencent.com>
Signed-off-by: Fuhai Wang <fuhaiwang@tencent.com>
Signed-off-by: katrinzhou <katrinzhou@tencent.com>
Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
Fuhai Wang 2022-04-24 19:49:54 +08:00 committed by Kairui Song
parent 8fd6fdaf2d
commit 801f14febd
4 changed files with 30 additions and 2 deletions

View File

@ -138,8 +138,9 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
#define TCP_DELACK_MIN 4U
#define TCP_ATO_MIN 4U
#endif
#define TCP_RTO_MAX ((unsigned)(120*HZ))
#define TCP_RTO_MIN ((unsigned)(HZ/5))
#define TCP_RTO_MAX ((unsigned)(sysctl_tcp_rto_max*HZ))
#define TCP_RTO_MIN ((unsigned)((sysctl_tcp_rto_min*HZ)/1000))
#define TCP_TIMEOUT_MIN (2U) /* Min timeout for TCP timers in jiffies */
#define TCP_TIMEOUT_MIN_US (2*USEC_PER_MSEC) /* Min TCP timeout in microsecs */
@ -259,6 +260,8 @@ extern int sysctl_tcp_init_cwnd;
extern int sysctl_tcp_inherit_buffsize;
extern int sysctl_tcp_init_rto;
extern int sysctl_tcp_synack_rto_interval;
extern int sysctl_tcp_rto_min;
extern int sysctl_tcp_rto_max;
#define TCP_RACK_LOSS_DETECTION 0x1 /* Use RACK to detect losses */
#define TCP_RACK_STATIC_REO_WND 0x2 /* Use static RACK reo wnd */

View File

@ -427,6 +427,8 @@ enum
NET_TCP_MAX_SSTHRESH=124,
NET_TCP_FRTO_RESPONSE=125,
NET_TCP_TW_IGNORE_SYN_TSVAL_ZERO = 126,
NET_IPV4_TCP_RTO_MIN = 127,
NET_IPV4_TCP_RTO_MAX = 128,
};
enum {

View File

@ -594,6 +594,21 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec
},
{
.procname = "tcp_rto_min",
.data = &sysctl_tcp_rto_min,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_FOUR
},
{
.procname = "tcp_rto_max",
.data = &sysctl_tcp_rto_max,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};

View File

@ -31,6 +31,14 @@ EXPORT_SYMBOL(sysctl_tcp_init_rto);
int sysctl_tcp_synack_rto_interval __read_mostly = 200;
EXPORT_SYMBOL(sysctl_tcp_synack_rto_interval);
/* default value is 200ms */
int sysctl_tcp_rto_min __read_mostly = 200;
EXPORT_SYMBOL(sysctl_tcp_rto_min);
/* default value is 120s */
int sysctl_tcp_rto_max __read_mostly = 120;
EXPORT_SYMBOL(sysctl_tcp_rto_max);
static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);