diff options
author | David S. Miller <davem@davemloft.net> | 2005-07-05 18:21:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-07-05 18:21:10 -0400 |
commit | 0d9901df62fe4820aee86b49f1a074cdb5c6928e (patch) | |
tree | 747e4af9c87477d58cdbb07196a35e2954da2a9f /net | |
parent | cb83199a29dc0408423d6df432f28cc67fcadaf4 (diff) |
[TCP]: Break out send buffer expansion test.
This makes it easier to understand, and allows easier
tweaking of the heuristic later on.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp_input.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b948e4eb39b7..2ef2f355b8b8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -3300,6 +3300,28 @@ void tcp_cwnd_application_limited(struct sock *sk) | |||
3300 | tp->snd_cwnd_stamp = tcp_time_stamp; | 3300 | tp->snd_cwnd_stamp = tcp_time_stamp; |
3301 | } | 3301 | } |
3302 | 3302 | ||
3303 | static inline int tcp_should_expand_sndbuf(struct sock *sk, struct tcp_sock *tp) | ||
3304 | { | ||
3305 | /* If the user specified a specific send buffer setting, do | ||
3306 | * not modify it. | ||
3307 | */ | ||
3308 | if (sk->sk_userlocks & SOCK_SNDBUF_LOCK) | ||
3309 | return 0; | ||
3310 | |||
3311 | /* If we are under global TCP memory pressure, do not expand. */ | ||
3312 | if (tcp_memory_pressure) | ||
3313 | return 0; | ||
3314 | |||
3315 | /* If we are under soft global TCP memory pressure, do not expand. */ | ||
3316 | if (atomic_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0]) | ||
3317 | return 0; | ||
3318 | |||
3319 | /* If we filled the congestion window, do not expand. */ | ||
3320 | if (tp->packets_out >= tp->snd_cwnd) | ||
3321 | return 0; | ||
3322 | |||
3323 | return 1; | ||
3324 | } | ||
3303 | 3325 | ||
3304 | /* When incoming ACK allowed to free some skb from write_queue, | 3326 | /* When incoming ACK allowed to free some skb from write_queue, |
3305 | * we remember this event in flag SOCK_QUEUE_SHRUNK and wake up socket | 3327 | * 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) | |||
3311 | { | 3333 | { |
3312 | struct tcp_sock *tp = tcp_sk(sk); | 3334 | struct tcp_sock *tp = tcp_sk(sk); |
3313 | 3335 | ||
3314 | if (tp->packets_out < tp->snd_cwnd && | 3336 | if (tcp_should_expand_sndbuf(sk, tp)) { |
3315 | !(sk->sk_userlocks & SOCK_SNDBUF_LOCK) && | ||
3316 | !tcp_memory_pressure && | ||
3317 | atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) { | ||
3318 | int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache_std) + | 3337 | int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache_std) + |
3319 | MAX_TCP_HEADER + 16 + sizeof(struct sk_buff), | 3338 | MAX_TCP_HEADER + 16 + sizeof(struct sk_buff), |
3320 | demanded = max_t(unsigned int, tp->snd_cwnd, | 3339 | demanded = max_t(unsigned int, tp->snd_cwnd, |