diff options
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 4af1f5dae9d3..8a645f304e6c 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -1288,6 +1288,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, | |||
1288 | struct tcp_sock *tp = tcp_sk(sk); | 1288 | struct tcp_sock *tp = tcp_sk(sk); |
1289 | struct sk_buff *buff; | 1289 | struct sk_buff *buff; |
1290 | int nsize, old_factor; | 1290 | int nsize, old_factor; |
1291 | long limit; | ||
1291 | int nlen; | 1292 | int nlen; |
1292 | u8 flags; | 1293 | u8 flags; |
1293 | 1294 | ||
@@ -1298,8 +1299,16 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, | |||
1298 | if (nsize < 0) | 1299 | if (nsize < 0) |
1299 | nsize = 0; | 1300 | nsize = 0; |
1300 | 1301 | ||
1301 | if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf && | 1302 | /* tcp_sendmsg() can overshoot sk_wmem_queued by one full size skb. |
1302 | tcp_queue != TCP_FRAG_IN_WRITE_QUEUE)) { | 1303 | * We need some allowance to not penalize applications setting small |
1304 | * SO_SNDBUF values. | ||
1305 | * Also allow first and last skb in retransmit queue to be split. | ||
1306 | */ | ||
1307 | limit = sk->sk_sndbuf + 2 * SKB_TRUESIZE(GSO_MAX_SIZE); | ||
1308 | if (unlikely((sk->sk_wmem_queued >> 1) > limit && | ||
1309 | tcp_queue != TCP_FRAG_IN_WRITE_QUEUE && | ||
1310 | skb != tcp_rtx_queue_head(sk) && | ||
1311 | skb != tcp_rtx_queue_tail(sk))) { | ||
1303 | NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG); | 1312 | NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG); |
1304 | return -ENOMEM; | 1313 | return -ENOMEM; |
1305 | } | 1314 | } |
@@ -1311,6 +1320,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, | |||
1311 | buff = sk_stream_alloc_skb(sk, nsize, gfp, true); | 1320 | buff = sk_stream_alloc_skb(sk, nsize, gfp, true); |
1312 | if (!buff) | 1321 | if (!buff) |
1313 | return -ENOMEM; /* We'll just try again later. */ | 1322 | return -ENOMEM; /* We'll just try again later. */ |
1323 | skb_copy_decrypted(buff, skb); | ||
1314 | 1324 | ||
1315 | sk->sk_wmem_queued += buff->truesize; | 1325 | sk->sk_wmem_queued += buff->truesize; |
1316 | sk_mem_charge(sk, buff->truesize); | 1326 | sk_mem_charge(sk, buff->truesize); |
@@ -1865,6 +1875,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, | |||
1865 | buff = sk_stream_alloc_skb(sk, 0, gfp, true); | 1875 | buff = sk_stream_alloc_skb(sk, 0, gfp, true); |
1866 | if (unlikely(!buff)) | 1876 | if (unlikely(!buff)) |
1867 | return -ENOMEM; | 1877 | return -ENOMEM; |
1878 | skb_copy_decrypted(buff, skb); | ||
1868 | 1879 | ||
1869 | sk->sk_wmem_queued += buff->truesize; | 1880 | sk->sk_wmem_queued += buff->truesize; |
1870 | sk_mem_charge(sk, buff->truesize); | 1881 | sk_mem_charge(sk, buff->truesize); |
@@ -2042,7 +2053,7 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len) | |||
2042 | if (len <= skb->len) | 2053 | if (len <= skb->len) |
2043 | break; | 2054 | break; |
2044 | 2055 | ||
2045 | if (unlikely(TCP_SKB_CB(skb)->eor)) | 2056 | if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb)) |
2046 | return false; | 2057 | return false; |
2047 | 2058 | ||
2048 | len -= skb->len; | 2059 | len -= skb->len; |
@@ -2134,6 +2145,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
2134 | sk_mem_charge(sk, nskb->truesize); | 2145 | sk_mem_charge(sk, nskb->truesize); |
2135 | 2146 | ||
2136 | skb = tcp_send_head(sk); | 2147 | skb = tcp_send_head(sk); |
2148 | skb_copy_decrypted(nskb, skb); | ||
2137 | 2149 | ||
2138 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; | 2150 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; |
2139 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; | 2151 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; |
@@ -2158,6 +2170,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
2158 | * we need to propagate it to the new skb. | 2170 | * we need to propagate it to the new skb. |
2159 | */ | 2171 | */ |
2160 | TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor; | 2172 | TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor; |
2173 | tcp_skb_collapse_tstamp(nskb, skb); | ||
2161 | tcp_unlink_write_queue(skb, sk); | 2174 | tcp_unlink_write_queue(skb, sk); |
2162 | sk_wmem_free_skb(sk, skb); | 2175 | sk_wmem_free_skb(sk, skb); |
2163 | } else { | 2176 | } else { |