From patchwork Sun Feb 26 20:06:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 143114 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CBCA0B6EE8 for ; Mon, 27 Feb 2012 07:13:14 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836Ab2BZUMo (ORCPT ); Sun, 26 Feb 2012 15:12:44 -0500 Received: from mail-gx0-f202.google.com ([209.85.161.202]:41966 "EHLO mail-gx0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701Ab2BZUMn (ORCPT ); Sun, 26 Feb 2012 15:12:43 -0500 Received: by ggnp1 with SMTP id p1so464079ggn.1 for ; Sun, 26 Feb 2012 12:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of ncardwell@google.com designates 10.236.139.199 as permitted sender) client-ip=10.236.139.199; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ncardwell@google.com designates 10.236.139.199 as permitted sender) smtp.mail=ncardwell@google.com; dkim=pass header.i=ncardwell@google.com Received: from mr.google.com ([10.236.139.199]) by 10.236.139.199 with SMTP id c47mr21793799yhj.5.1330287163142 (num_hops = 1); Sun, 26 Feb 2012 12:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=gamma; h=mime-version:from:to:cc:subject:date:message-id:x-mailer; bh=kWCn8WbYN6RAN9jf6GMpCjnR24bCGaWmhEQJ7sC697U=; b=TKbTkmlgBLXqJhhXtuSarvF46pjNR/Fgls7zwb3hRdKYiMDb92jqChilc+ndJIxCMR HdWFn1P91Qf9WTfaDZXUaOpUV7HL14a6wwa6FtefQTDULoCqgosufsxiso2NVGEnjUvc qiPX/Rna3GE6p6p5lkf12ve7mWRWV1f2uWakU= Received: by 10.236.139.199 with SMTP id c47mr14040508yhj.5.1330286781114; Sun, 26 Feb 2012 12:06:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.139.199 with SMTP id c47mr14040481yhj.5.1330286781016; Sun, 26 Feb 2012 12:06:21 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id g10si7019425yhn.7.2012.02.26.12.06.21 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sun, 26 Feb 2012 12:06:21 -0800 (PST) Received: from coy.nyc.corp.google.com (coy.nyc.corp.google.com [172.26.62.101]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id EBFAB1E004D; Sun, 26 Feb 2012 12:06:20 -0800 (PST) Received: by coy.nyc.corp.google.com (Postfix, from userid 4318) id 9300F1C0C6B; Sun, 26 Feb 2012 15:06:20 -0500 (EST) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, ilpo.jarvinen@helsinki.fi, Nandita Dukkipati , Yuchung Cheng , Tom Herbert , Vijay Subramanian , Neal Cardwell Subject: [PATCH] tcp: fix false reordering signal in tcp_shifted_skb Date: Sun, 26 Feb 2012 15:06:19 -0500 Message-Id: <1330286779-10462-1-git-send-email-ncardwell@google.com> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQnhZQkDt/GjnbPiexDWPCMx7IpL5OLAMTD3Zc32ejjktOnRiqOCeiWz9za0bKF3Vk1WxgxMWRk870vQdG+3xHQ0rVAFjr6utqm/8p1BhuUQgVZJhyJKNCLQUn+XSO1al7DUkoFpI3iPo1WhrstreTvtnIuCZp/OTQNQyiVF6JRaDqeK5eo= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When tcp_shifted_skb() shifts bytes from the skb that is currently pointed to by 'highest_sack' then the increment of TCP_SKB_CB(skb)->seq implicitly advances tcp_highest_sack_seq(). This implicit advancement, combined with the recent fix to pass the correct SACKed range into tcp_sacktag_one(), caused tcp_sacktag_one() to think that the newly SACKed range was before the tcp_highest_sack_seq(), leading to a call to tcp_update_reordering() with a degree of reordering matching the size of the newly SACKed range (typically just 1 packet, which is a NOP, but potentially larger). This commit fixes this by simply calling tcp_sacktag_one() before the TCP_SKB_CB(skb)->seq advancement that can advance our notion of the highest SACKed sequence. Correspondingly, we can simplify the code a little now that tcp_shifted_skb() should update the lost_cnt_hint in all cases where skb == tp->lost_skb_hint. Signed-off-by: Neal Cardwell Acked-by: Yuchung Cheng --- net/ipv4/tcp_input.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 53c8ce4..ee42d42 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1403,8 +1403,16 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, BUG_ON(!pcount); - /* Adjust hint for FACK. Non-FACK is handled in tcp_sacktag_one(). */ - if (tcp_is_fack(tp) && (skb == tp->lost_skb_hint)) + /* Adjust counters and hints for the newly sacked sequence + * range but discard the return value since prev is already + * marked. We must tag the range first because the seq + * advancement below implicitly advances + * tcp_highest_sack_seq() when skb is highest_sack. + */ + tcp_sacktag_one(sk, state, TCP_SKB_CB(skb)->sacked, + start_seq, end_seq, dup_sack, pcount); + + if (skb == tp->lost_skb_hint) tp->lost_cnt_hint += pcount; TCP_SKB_CB(prev)->end_seq += shifted; @@ -1430,12 +1438,6 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, skb_shinfo(skb)->gso_type = 0; } - /* Adjust counters and hints for the newly sacked sequence range but - * discard the return value since prev is already marked. - */ - tcp_sacktag_one(sk, state, TCP_SKB_CB(skb)->sacked, - start_seq, end_seq, dup_sack, pcount); - /* Difference in this won't matter, both ACKed by the same cumul. ACK */ TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS);