From b52bd43afeb25cedf536fa5cfc33d3b2639b7549 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 5 Jul 2005 15:21:10 -0700 Subject: [PATCH] --- yaml --- r: 4143 b: refs/heads/master c: 0d9901df62fe4820aee86b49f1a074cdb5c6928e h: refs/heads/master i: 4141: 1de21434024a7fd061012015283ab47abf55f4f6 4139: 3c20fd036730b4266ff14c621dbc70a9105391c3 4135: 6d211f87d380eccd721e154c105a3c44eb2583be 4127: 2e78df5d84335793ecb34af6f83f817862a84cc7 v: v3 --- [refs] | 2 +- trunk/net/ipv4/tcp_input.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index e370683d55ec..fef207c9a96d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cb83199a29dc0408423d6df432f28cc67fcadaf4 +refs/heads/master: 0d9901df62fe4820aee86b49f1a074cdb5c6928e diff --git a/trunk/net/ipv4/tcp_input.c b/trunk/net/ipv4/tcp_input.c index b948e4eb39b7..2ef2f355b8b8 100644 --- a/trunk/net/ipv4/tcp_input.c +++ b/trunk/net/ipv4/tcp_input.c @@ -3300,6 +3300,28 @@ void tcp_cwnd_application_limited(struct sock *sk) tp->snd_cwnd_stamp = tcp_time_stamp; } +static inline int tcp_should_expand_sndbuf(struct sock *sk, struct tcp_sock *tp) +{ + /* If the user specified a specific send buffer setting, do + * not modify it. + */ + if (sk->sk_userlocks & SOCK_SNDBUF_LOCK) + return 0; + + /* If we are under global TCP memory pressure, do not expand. */ + if (tcp_memory_pressure) + return 0; + + /* If we are under soft global TCP memory pressure, do not expand. */ + if (atomic_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0]) + return 0; + + /* If we filled the congestion window, do not expand. */ + if (tp->packets_out >= tp->snd_cwnd) + return 0; + + return 1; +} /* When incoming ACK allowed to free some skb from write_queue, * we remember this event in flag SOCK_QUEUE_SHRUNK and wake up socket @@ -3311,10 +3333,7 @@ static void tcp_new_space(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); - if (tp->packets_out < tp->snd_cwnd && - !(sk->sk_userlocks & SOCK_SNDBUF_LOCK) && - !tcp_memory_pressure && - atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) { + if (tcp_should_expand_sndbuf(sk, tp)) { int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache_std) + MAX_TCP_HEADER + 16 + sizeof(struct sk_buff), demanded = max_t(unsigned int, tp->snd_cwnd,