summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDouglas Caetano dos Santos <douglascs@taghos.com.br>2016-09-22 15:52:04 -0300
committerDavid S. Miller <davem@davemloft.net>2016-09-23 07:55:02 -0400
commit2fe664f1fcf7c4da6891f95708a7a56d3c024354 (patch)
tree44bf1c6e889204e43ae18c85be64e0713d451782 /net
parentf44ace4d06aab8210d29c731f70b657a7524198b (diff)
downloadlinux-stable-2fe664f1fcf7c4da6891f95708a7a56d3c024354.tar.gz
linux-stable-2fe664f1fcf7c4da6891f95708a7a56d3c024354.tar.bz2
linux-stable-2fe664f1fcf7c4da6891f95708a7a56d3c024354.zip
tcp: fix wrong checksum calculation on MTU probing
With TCP MTU probing enabled and offload TX checksumming disabled, tcp_mtu_probe() calculated the wrong checksum when a fragment being copied into the probe's SKB had an odd length. This was caused by the direct use of skb_copy_and_csum_bits() to calculate the checksum, as it pads the fragment being copied, if needed. When this fragment was not the last, a subsequent call used the previous checksum without considering this padding. The effect was a stale connection in one way, as even retransmissions wouldn't solve the problem, because the checksum was never recalculated for the full SKB length. Signed-off-by: Douglas Caetano dos Santos <douglascs@taghos.com.br> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_output.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 5288cec4a2b2..d48d5571e62a 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1966,12 +1966,14 @@ static int tcp_mtu_probe(struct sock *sk)
len = 0;
tcp_for_write_queue_from_safe(skb, next, sk) {
copy = min_t(int, skb->len, probe_size - len);
- if (nskb->ip_summed)
+ if (nskb->ip_summed) {
skb_copy_bits(skb, 0, skb_put(nskb, copy), copy);
- else
- nskb->csum = skb_copy_and_csum_bits(skb, 0,
- skb_put(nskb, copy),
- copy, nskb->csum);
+ } else {
+ __wsum csum = skb_copy_and_csum_bits(skb, 0,
+ skb_put(nskb, copy),
+ copy, 0);
+ nskb->csum = csum_block_add(nskb->csum, csum, len);
+ }
if (skb->len <= copy) {
/* We've eaten all the data from this skb.