From patchwork Tue Sep 14 01:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhengguoyong X-Patchwork-Id: 12491231 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEE12C433EF for ; Tue, 14 Sep 2021 01:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDC0A606A5 for ; Tue, 14 Sep 2021 01:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231976AbhINBw4 (ORCPT ); Mon, 13 Sep 2021 21:52:56 -0400 Received: from prt-mail.chinatelecom.cn ([42.123.76.223]:38840 "EHLO chinatelecom.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229732AbhINBwz (ORCPT ); Mon, 13 Sep 2021 21:52:55 -0400 HMM_SOURCE_IP: 172.18.0.218:36198.1001769352 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-110.87.95.153 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id B008B280142; Tue, 14 Sep 2021 09:51:16 +0800 (CST) X-189-SAVE-TO-SEND: +zhenggy@chinatelecom.cn Received: from ([172.18.0.218]) by app0025 with ESMTP id 02d5a94c49a445c39fae088d54da1d24 for ncardwell@google.com; Tue, 14 Sep 2021 09:51:32 CST X-Transaction-ID: 02d5a94c49a445c39fae088d54da1d24 X-Real-From: zhenggy@chinatelecom.cn X-Receive-IP: 172.18.0.218 Sender: zhenggy@chinatelecom.cn From: zhenggy To: ncardwell@google.com, netdev@vger.kernel.org Cc: edumazet@google.com, davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, ycheng@google.com, qitiepeng@chinatelecom.cn, wujianguo@chinatelecom.cn, liyonglong@chinatelecom.cn, luchang1@chinatelecom.cn, zhenggy Subject: [PATCH v4] tcp: fix tp->undo_retrans accounting in tcp_sacktag_one() Date: Tue, 14 Sep 2021 09:51:15 +0800 Message-Id: <1631584275-3075-1-git-send-email-zhenggy@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Commit 10d3be569243 ("tcp-tso: do not split TSO packets at retransmit time") may directly retrans a multiple segments TSO/GSO packet without split, Since this commit, we can no longer assume that a retransmitted packet is a single segment. This patch fixes the tp->undo_retrans accounting in tcp_sacktag_one() that use the actual segments(pcount) of the retransmitted packet. Before that commit (10d3be569243), the assumption underlying the tp->undo_retrans-- seems correct. Fixes: 10d3be569243 ("tcp-tso: do not split TSO packets at retransmit time") Signed-off-by: zhenggy Reviewed-by: Eric Dumazet Acked-by: Yuchung Cheng Acked-by: Neal Cardwell --- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 3f7bd7a..141e85e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1346,7 +1346,7 @@ static u8 tcp_sacktag_one(struct sock *sk, if (dup_sack && (sacked & TCPCB_RETRANS)) { if (tp->undo_marker && tp->undo_retrans > 0 && after(end_seq, tp->undo_marker)) - tp->undo_retrans--; + tp->undo_retrans = max_t(int, 0, tp->undo_retrans - pcount); if ((sacked & TCPCB_SACKED_ACKED) && before(start_seq, state->reord)) state->reord = start_seq;