tcp: add proc parameter to change init cwnd

Upstream: no

10 is not ok for all scenes. This may be useful for some business
e.g. bad network quality of little ISP.

CDN need big cwnd value to send more packets at first.
ChinaCache set it with 30 for default.

Signed-off-by: Shan Wei <davidshan@tencent.com>
Signed-off-by: Samuel Liao <samuelliao@tencent.com>
Signed-off-by: katrinzhou <katrinzhou@tencent.com>
Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
Kairui Song 2022-12-19 16:13:23 +08:00
parent 869d03bdf4
commit 42f5e22854
4 changed files with 12 additions and 2 deletions

View File

@ -251,6 +251,7 @@ extern long sysctl_tcp_mem[3];
extern int sysctl_tcp_tw_ignore_syn_tsval_zero;
extern int sysctl_tcp_loss_init_cwnd;
extern int sysctl_tcp_no_delay_ack;
extern int sysctl_tcp_init_cwnd;
#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

@ -563,6 +563,14 @@ static struct ctl_table ipv4_table[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
},
{
.procname = "tcp_init_cwnd",
.data = &sysctl_tcp_init_cwnd,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
.extra1 = SYSCTL_ONE,
},
{
.procname = "udp_mem",
.data = &sysctl_udp_mem,

View File

@ -431,7 +431,7 @@ void tcp_init_sock(struct sock *sk)
* algorithms that we must have the following bandaid to talk
* efficiently to them. -DaveM
*/
tcp_snd_cwnd_set(tp, TCP_INIT_CWND);
tcp_snd_cwnd_set(tp, sysctl_tcp_init_cwnd);
/* There's a bubble in the pipe until at least the first ACK. */
tp->app_limited = ~0U;

View File

@ -85,6 +85,7 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
int sysctl_tcp_tw_ignore_syn_tsval_zero __read_mostly = 1;
int sysctl_tcp_loss_init_cwnd = 1;
int sysctl_tcp_no_delay_ack;
int sysctl_tcp_init_cwnd = TCP_INIT_CWND;
#define FLAG_DATA 0x01 /* Incoming frame contained data. */
#define FLAG_WIN_UPDATE 0x02 /* Incoming ACK was a window update. */
@ -982,7 +983,7 @@ __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst)
__u32 cwnd = (dst ? dst_metric(dst, RTAX_INITCWND) : 0);
if (!cwnd)
cwnd = TCP_INIT_CWND;
cwnd = sysctl_tcp_init_cwnd;
return min_t(__u32, cwnd, tp->snd_cwnd_clamp);
}