diff options
| author | Steve French <sfrench@us.ibm.com> | 2008-04-17 19:38:45 -0400 |
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2008-04-17 19:38:45 -0400 |
| commit | 20e673810c69d18bee2ed74d19af3806ec2504f5 (patch) | |
| tree | 7c22dc5246295a82f2688a23ae1c7f3a4f424302 /net/ipv4/tcp_input.c | |
| parent | 8d142137b4fe87188f211042b16a5993964226f9 (diff) | |
| parent | 4b119e21d0c66c22e8ca03df05d9de623d0eb50f (diff) | |
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'net/ipv4/tcp_input.c')
| -rw-r--r-- | net/ipv4/tcp_input.c | 78 |
1 files changed, 52 insertions, 26 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5119856017ab..bbb7d88a16b4 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -3841,8 +3841,28 @@ static void tcp_ofo_queue(struct sock *sk) | |||
| 3841 | } | 3841 | } |
| 3842 | } | 3842 | } |
| 3843 | 3843 | ||
| 3844 | static int tcp_prune_ofo_queue(struct sock *sk); | ||
| 3844 | static int tcp_prune_queue(struct sock *sk); | 3845 | static int tcp_prune_queue(struct sock *sk); |
| 3845 | 3846 | ||
| 3847 | static inline int tcp_try_rmem_schedule(struct sock *sk, unsigned int size) | ||
| 3848 | { | ||
| 3849 | if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || | ||
| 3850 | !sk_rmem_schedule(sk, size)) { | ||
| 3851 | |||
| 3852 | if (tcp_prune_queue(sk) < 0) | ||
| 3853 | return -1; | ||
| 3854 | |||
| 3855 | if (!sk_rmem_schedule(sk, size)) { | ||
| 3856 | if (!tcp_prune_ofo_queue(sk)) | ||
| 3857 | return -1; | ||
| 3858 | |||
| 3859 | if (!sk_rmem_schedule(sk, size)) | ||
| 3860 | return -1; | ||
| 3861 | } | ||
| 3862 | } | ||
| 3863 | return 0; | ||
| 3864 | } | ||
| 3865 | |||
| 3846 | static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) | 3866 | static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) |
| 3847 | { | 3867 | { |
| 3848 | struct tcphdr *th = tcp_hdr(skb); | 3868 | struct tcphdr *th = tcp_hdr(skb); |
| @@ -3892,12 +3912,9 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) | |||
| 3892 | if (eaten <= 0) { | 3912 | if (eaten <= 0) { |
| 3893 | queue_and_out: | 3913 | queue_and_out: |
| 3894 | if (eaten < 0 && | 3914 | if (eaten < 0 && |
| 3895 | (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || | 3915 | tcp_try_rmem_schedule(sk, skb->truesize)) |
| 3896 | !sk_rmem_schedule(sk, skb->truesize))) { | 3916 | goto drop; |
| 3897 | if (tcp_prune_queue(sk) < 0 || | 3917 | |
| 3898 | !sk_rmem_schedule(sk, skb->truesize)) | ||
| 3899 | goto drop; | ||
| 3900 | } | ||
| 3901 | skb_set_owner_r(skb, sk); | 3918 | skb_set_owner_r(skb, sk); |
| 3902 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 3919 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
| 3903 | } | 3920 | } |
| @@ -3966,12 +3983,8 @@ drop: | |||
| 3966 | 3983 | ||
| 3967 | TCP_ECN_check_ce(tp, skb); | 3984 | TCP_ECN_check_ce(tp, skb); |
| 3968 | 3985 | ||
| 3969 | if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || | 3986 | if (tcp_try_rmem_schedule(sk, skb->truesize)) |
| 3970 | !sk_rmem_schedule(sk, skb->truesize)) { | 3987 | goto drop; |
| 3971 | if (tcp_prune_queue(sk) < 0 || | ||
| 3972 | !sk_rmem_schedule(sk, skb->truesize)) | ||
| 3973 | goto drop; | ||
| 3974 | } | ||
| 3975 | 3988 | ||
| 3976 | /* Disable header prediction. */ | 3989 | /* Disable header prediction. */ |
| 3977 | tp->pred_flags = 0; | 3990 | tp->pred_flags = 0; |
| @@ -4198,6 +4211,32 @@ static void tcp_collapse_ofo_queue(struct sock *sk) | |||
| 4198 | } | 4211 | } |
| 4199 | } | 4212 | } |
| 4200 | 4213 | ||
| 4214 | /* | ||
| 4215 | * Purge the out-of-order queue. | ||
| 4216 | * Return true if queue was pruned. | ||
| 4217 | */ | ||
| 4218 | static int tcp_prune_ofo_queue(struct sock *sk) | ||
| 4219 | { | ||
| 4220 | struct tcp_sock *tp = tcp_sk(sk); | ||
| 4221 | int res = 0; | ||
| 4222 | |||
| 4223 | if (!skb_queue_empty(&tp->out_of_order_queue)) { | ||
| 4224 | NET_INC_STATS_BH(LINUX_MIB_OFOPRUNED); | ||
| 4225 | __skb_queue_purge(&tp->out_of_order_queue); | ||
| 4226 | |||
| 4227 | /* Reset SACK state. A conforming SACK implementation will | ||
| 4228 | * do the same at a timeout based retransmit. When a connection | ||
| 4229 | * is in a sad state like this, we care only about integrity | ||
| 4230 | * of the connection not performance. | ||
| 4231 | */ | ||
| 4232 | if (tp->rx_opt.sack_ok) | ||
| 4233 | tcp_sack_reset(&tp->rx_opt); | ||
| 4234 | sk_mem_reclaim(sk); | ||
| 4235 | res = 1; | ||
| 4236 | } | ||
| 4237 | return res; | ||
| 4238 | } | ||
| 4239 | |||
| 4201 | /* Reduce allocated memory if we can, trying to get | 4240 | /* Reduce allocated memory if we can, trying to get |
| 4202 | * the socket within its memory limits again. | 4241 | * the socket within its memory limits again. |
| 4203 | * | 4242 | * |
| @@ -4231,20 +4270,7 @@ static int tcp_prune_queue(struct sock *sk) | |||
| 4231 | /* Collapsing did not help, destructive actions follow. | 4270 | /* Collapsing did not help, destructive actions follow. |
| 4232 | * This must not ever occur. */ | 4271 | * This must not ever occur. */ |
| 4233 | 4272 | ||
| 4234 | /* First, purge the out_of_order queue. */ | 4273 | tcp_prune_ofo_queue(sk); |
| 4235 | if (!skb_queue_empty(&tp->out_of_order_queue)) { | ||
| 4236 | NET_INC_STATS_BH(LINUX_MIB_OFOPRUNED); | ||
| 4237 | __skb_queue_purge(&tp->out_of_order_queue); | ||
| 4238 | |||
| 4239 | /* Reset SACK state. A conforming SACK implementation will | ||
| 4240 | * do the same at a timeout based retransmit. When a connection | ||
| 4241 | * is in a sad state like this, we care only about integrity | ||
| 4242 | * of the connection not performance. | ||
| 4243 | */ | ||
| 4244 | if (tcp_is_sack(tp)) | ||
| 4245 | tcp_sack_reset(&tp->rx_opt); | ||
| 4246 | sk_mem_reclaim(sk); | ||
| 4247 | } | ||
| 4248 | 4274 | ||
| 4249 | if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) | 4275 | if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) |
| 4250 | return 0; | 4276 | return 0; |
