Skip to content

Commit

Permalink
tcp: make TCP_RTO_MIN/MAX be tunable
Browse files Browse the repository at this point in the history
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: Xiaoming Gao <newtongao@tencent.com>
  • Loading branch information
gxm-newton committed Jan 2, 2020
1 parent 88885ab commit c715d50
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ 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_MIN ((unsigned)((sysctl_tcp_rto_min*HZ)/1000))
#define TCP_RTO_MAX ((unsigned)(sysctl_tcp_rto_max*HZ))
#define TCP_TIMEOUT_MIN (2U) /* Min timeout for TCP timers in jiffies */
#define TCP_TIMEOUT_INIT ((unsigned)(1*HZ)) /* RFC6298 2.1 initial RTO value */
#define TCP_TIMEOUT_FALLBACK ((unsigned)(3*HZ)) /* RFC 1122 initial RTO value, now
Expand Down Expand Up @@ -276,6 +276,8 @@ extern int sysctl_tcp_pacing_ca_ratio;
extern int sysctl_tcp_tw_ignore_syn_tsval_zero;
extern int sysctl_tcp_loss_init_cwnd;
extern int sysctl_tcp_init_cwnd;
extern int sysctl_tcp_rto_min;
extern int sysctl_tcp_rto_max;

extern atomic_long_t tcp_memory_allocated;
extern struct percpu_counter tcp_sockets_allocated;
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/linux/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,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 {
Expand Down
15 changes: 15 additions & 0 deletions net/ipv4/sysctl_net_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,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 = &four
},
{
.procname = "tcp_rto_max",
.data = &sysctl_tcp_rto_max,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};

Expand Down
8 changes: 8 additions & 0 deletions net/ipv4/tcp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@

int sysctl_tcp_thin_linear_timeouts __read_mostly;

/* 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);

/**
* tcp_write_err() - close socket and save error info
* @sk: The socket the error has appeared on.
Expand Down

0 comments on commit c715d50

Please sign in to comment.