Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp834123rwi; Wed, 26 Oct 2022 07:47:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM593sPR3d9EQxQbfQwSy1bpk0x5mFzNqe4z44PPNiPo9dA/F3Q26T9uIv3YjvZDLa6A64X2 X-Received: by 2002:a17:902:6bc8:b0:179:fef9:b2fa with SMTP id m8-20020a1709026bc800b00179fef9b2famr45325081plt.96.1666795672102; Wed, 26 Oct 2022 07:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666795672; cv=none; d=google.com; s=arc-20160816; b=eZ3nThQLSTYutlaX2vy+ytPt/gClMKY14bsR4iVdC4JDTRwHUulNZ4BBKY9akI3MSa 1+9e6JwDKV5dENw97NG1Wg+AG/qGlk/D+dvjW0uqSPjWa5x2nIL44oPVt7zZnyJdt3F/ uTuRjwCT84vV+4ZbIK8KfGJIaBiIl3rqLYBVDwKLGIj4Et/88xObro5+tR0tnKxnhWp7 li7YaV49KZsoUUOTESoKLb57TbQsN3qm1pS2cDcGeokOslEoBxfwcMF1KhMiF0BbgaUc 31rI6vWPwPvPiJlP6l0wiBIedmOjrhHXMfOERvR58hjydtlPuNTOYaB+Dyg+nL3g6jT1 dhzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=O8ox5Vjpqbut2HWEJqXTMWMGhh1V8cXSr+71zLXWLVk=; b=ADdoHu5l7VPG56ftFX+5KSZh/CAYGK2ymGwRC7CxxDwFs/lVv5sSx2gF+m69Z1sg+6 6+QXVX/3TQclripzePePbZ572ITpNMrBFOWEKq83rHW8Mhpb30L0h1TVRpOkttDruvqd DrIEUj81KuUvoWORE0xg+4oJ6digTA8ulbgXGikL0fqxxh2Nj+XAVm4HvNfnOEhvsu3Z 4K7l4h/LdxaDl6Ung+qvOaZBLd5coV4NPylFozS+dNjWisOgfikhN2Eqg+vmzFYeeOPn 6aFQOAdMOVm/xnaZoKdCxCk4w+dn3+gsGSq3ECoiFXUZXa/LM0LGVLi+2g5KvZcCOVk5 bJQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cS+OEkce; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902e74200b0017db9b9d54asi8581981plf.300.2022.10.26.07.47.40; Wed, 26 Oct 2022 07:47:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cS+OEkce; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbiJZOeA (ORCPT + 99 others); Wed, 26 Oct 2022 10:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233717AbiJZOd5 (ORCPT ); Wed, 26 Oct 2022 10:33:57 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB10118747 for ; Wed, 26 Oct 2022 07:33:57 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id i127so19078619ybc.11 for ; Wed, 26 Oct 2022 07:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=O8ox5Vjpqbut2HWEJqXTMWMGhh1V8cXSr+71zLXWLVk=; b=cS+OEkce0Epvs5RObk0TjuOpGoAyKkMtjZGrxaLSPfQQN/33ph2elTppkEOA2XMrdN ePIAU6G0iXWCllBDfplra+KVD0B+p2oGhC2ji2m5uS/ariiOBEWvOw1S7LlTJyHZHIXE sTj1RiZIOfhXsHK7//csSbIIpy8HyTmfhAJI3DlZotDjkFaLNROABB9iKjBY2PS1m2i8 0C1otqS5sAI2BIJ1JIvOc2arODS4CeGT68ZgrcA3oxlsQULr1JMSS8ETsPWJgBKdSXFf qd/XgVhounSzbVVFcJnooihcNcxXP9VAPATTliDGZsnZRaw+oT4xCVTc4kh7cnL+TIRb gNxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O8ox5Vjpqbut2HWEJqXTMWMGhh1V8cXSr+71zLXWLVk=; b=XG2lrWHRpJTqisu9e0ehmPlKd7oL2dV97FF/Xau9gupaKAm2Jh178SAwS7NlXnJdhA d9eEO6pK71RintVFJQEzlz0v2nyPIXn2Bv6d+RvQUnf4oVFpHLYYWqeS+ecEhMFgTU20 dKDxFetpH9mO94t3VbtSGWRczkuL7ZUUrdgpCicNFH9E5SuE5poiMvp/44sV0wYUZln0 arHzE/ylyNLigwiQ9oWHGRvM/VnXnHLSOTY5KbJukYwlHCD0Iag5LZEnvGBA7bLSNeS/ yjDCGnOba+6ptEn9+LKRDpPBg1xRWgDQeqf+CA3eUVckhA0hGJ8IZbG5uO0XWvJMOYEg lBaQ== X-Gm-Message-State: ACrzQf1y2XulrNleTR148d8Q4XUl5R7vfuzD8GFpk0iGrlhr0UnU803v 4f9u18n9M4pYz6cEWzREbSZt7MG/hanI1Zy1MxTKEw== X-Received: by 2002:a25:7a01:0:b0:6b0:820:dd44 with SMTP id v1-20020a257a01000000b006b00820dd44mr36720991ybc.387.1666794836054; Wed, 26 Oct 2022 07:33:56 -0700 (PDT) MIME-Version: 1.0 References: <20221026151558.4165020-1-luwei32@huawei.com> In-Reply-To: From: Eric Dumazet Date: Wed, 26 Oct 2022 07:33:45 -0700 Message-ID: Subject: Re: [PATCH net] tcp: reset tp->sacked_out when sack is enabled To: Lu Wei , "Denis V. Lunev" Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, xemul@parallels.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 26, 2022 at 7:30 AM Eric Dumazet wrote: > > On Wed, Oct 26, 2022 at 7:12 AM Lu Wei wrote: > > > > The meaning of tp->sacked_out depends on whether sack is enabled > > or not. If setsockopt is called to enable sack_ok via > > tcp_repair_options_est(), tp->sacked_out should be cleared, or it > > will trigger warning in tcp_verify_left_out as follows: > > > > ============================================ > > WARNING: CPU: 8 PID: 0 at net/ipv4/tcp_input.c:2132 > > tcp_timeout_mark_lost+0x154/0x160 > > tcp_enter_loss+0x2b/0x290 > > tcp_retransmit_timer+0x50b/0x640 > > tcp_write_timer_handler+0x1c8/0x340 > > tcp_write_timer+0xe5/0x140 > > call_timer_fn+0x3a/0x1b0 > > __run_timers.part.0+0x1bf/0x2d0 > > run_timer_softirq+0x43/0xb0 > > __do_softirq+0xfd/0x373 > > __irq_exit_rcu+0xf6/0x140 > > > > This warning occurs in several steps: > > Step1. If sack is not enabled, when server receives dup-ack, > > it calls tcp_add_reno_sack() to increase tp->sacked_out. > > > > Step2. Setsockopt() is called to enable sack > > > > Step3. The retransmit timer expires, it calls tcp_timeout_mark_lost() > > to increase tp->lost_out but not clear tp->sacked_out because > > sack is enabled and tcp_is_reno() is false. > > > > So tp->left_out is increased repeatly in Step1 and Step3 and it is > > greater than tp->packets_out and trigger the warning. In function > > tcp_timeout_mark_lost(), tp->sacked_out will be cleared if Step2 not > > happen and the warning will not be triggered. So this patch clears > > tp->sacked_out in tcp_repair_options_est(). > > > > Fixes: b139ba4e90dc ("tcp: Repair connection-time negotiated parameters") > > Signed-off-by: Lu Wei > > --- > > net/ipv4/tcp.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > > index ef14efa1fb70..188d5c0e440f 100644 > > --- a/net/ipv4/tcp.c > > +++ b/net/ipv4/tcp.c > > @@ -3282,6 +3282,9 @@ static int tcp_repair_options_est(struct sock *sk, sockptr_t optbuf, > > if (opt.opt_val != 0) > > return -EINVAL; > > > > + if (tcp_is_reno(tp)) > > + tp->sacked_out = 0; > > + > > tp->rx_opt.sack_ok |= TCP_SACK_SEEN; > > break; > > case TCPOPT_TIMESTAMP: > > -- > > 2.31.1 > > > > Hmm, I am not sure this is the right fix. > > Probably TCP_REPAIR_OPTIONS should not be allowed if data has already been sent. > > Pavel, what do you think ? Routing to Denis V. Lunev , because Pavel's address no longer works. Thanks !