Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp871615rdg; Fri, 11 Aug 2023 02:32:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy8x5mL+/7K7Ig2J5hzmzBA2lRqaVkgsvYqu2AbpY156BgZCkl+rGIj6aP10uQHW7H7wLv X-Received: by 2002:a17:902:e545:b0:1b7:f64b:379b with SMTP id n5-20020a170902e54500b001b7f64b379bmr1755391plf.17.1691746346116; Fri, 11 Aug 2023 02:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691746346; cv=none; d=google.com; s=arc-20160816; b=dwkDS0rVqNWBElP5HJn8Iv0BubLl3ilawv5JpJliE26uOkKt5ySHMdGVpS5pNvyp7n XlNMyN5oL+SQY7cJSO8OCCvq26O/FZ5epdpd8f9uZ91MWb3wrVSnbrak3U0cpTa65XO+ ruCPk31NQsu4xNLccB1IFyXPYOSPnyXqEEyUHY7/am/ejDNTnN4QNi+Akx3gebm/tjfQ GTQl1u6+H9Ut/XMcjdglh9dBGUYvW0rxnDCRygqRu+W36SS/wafGTw4O5eA0HWIC9Hwg PX6O9FP7UQ94Q1tKtCs1HDh2J/VzvW8YGJIo4kNIzNxlz9hc3iMjkVHwbuOhzl0zc9lq ipXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Kks36w6bHX4unasxObmVyQSJGyfFC2zILJXj+GYVj9w=; fh=umD2oWwKhwn+J20AsKzTyEqs9pal02DEVpQdqf0GbFw=; b=kPADQfTqqVq8VFhBYKQP5QNONjOXiZZbB5Qxtd8iMfOYWITxDVwydfsH7/DvIHDbg/ mQp0nJE6aZ+zNmRvkf0K3qBHAqmPTsnTEWeg010iDoiy3hcWpEuFJ0auKDKsPs8jXbrR ofGif0FGvo3pw415+a8FnDjnV4421ETWhY16PL/l2BVex00hdqSYNgy4F/leHsTgfpO9 VSXbVcS7zBD8t2/6T8XAx/TUngy27N34GC7j89G+gIklqdnYNPwugJSAlK5kocr6wsAV W4H1DeDX9Id9GtgI6NR6j+kim65QwMmKc3jtjNFtOnU2JWw0qoPyF4pT7tU/nUr2uKPo kvjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=iulkA4nq; 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 j4-20020a170902da8400b001bc079974dbsi3115195plx.355.2023.08.11.02.32.14; Fri, 11 Aug 2023 02:32:26 -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=20221208 header.b=iulkA4nq; 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 S234091AbjHKHii (ORCPT + 99 others); Fri, 11 Aug 2023 03:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234086AbjHKHig (ORCPT ); Fri, 11 Aug 2023 03:38:36 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA76B2132 for ; Fri, 11 Aug 2023 00:38:34 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-40a47e8e38dso125321cf.1 for ; Fri, 11 Aug 2023 00:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691739514; x=1692344314; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Kks36w6bHX4unasxObmVyQSJGyfFC2zILJXj+GYVj9w=; b=iulkA4nqhtM0XCPIDilNtBx6s5ey4MieRPzycAJ/osCn1Kk7YqUA8Y49+BTycPldmM RbjmJvpmh2B7A82P/WMAf8i27pj6PnejGYm9V/MBLwPciDBWVy7sBoWiuAfqEv4uUenD NexUG6VrR4Bz5RRRABD2zfgY3W5KFDyvaLR+R3oe5qHlEMNN9jbBuQVQT2cEDSPudAy7 tDx1HV0I8Nek9A/ecNkK/yQruaf79+/e5zVrR2OBc3PA8kW5lqezqwH8leo+5ojLPTQC VV0TwiJ2Le6J0bqeFksLBTzLK+mzf1RLuTNIJkRVcTQ/1uHoWpDTi8Cgq1SZCTWcs3Rk m2jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691739514; x=1692344314; h=content-transfer-encoding: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=Kks36w6bHX4unasxObmVyQSJGyfFC2zILJXj+GYVj9w=; b=LAwmSTG7/Tt4xNQV7rn4jCMTnRsIliVYbDB5uI7XxLebeLJzK1DWMKhktxN1ZYM2BF 7EHApD8LZYMQZeADUQmFnfkeupsaiMQR/yZuxDvM3IyMrHzay6EBT2DI4eP85ylSgU2M 4v52VO/2Y1Fb2OhQHROIT/k8c0dOEwhpq7GIpig7IzCCuUHYHnf88xniyO51kxpTFp59 hBKNhhZ1KdPqtUoEtEPdQFmkHWdTcAoc7N2CdCGKntecKdyMDQYxg9B2RPkNJxgdImgg A7LYAH6ltgZ5mwUdLcBvekk6PS/odawKKMFUTha3JUi2dM21/0YEaPIhjTu1lUZ8QMo6 PEqg== X-Gm-Message-State: AOJu0Yx3Qnzp2kbKU7KIYnZ7B3DJwYStbRUtRhKy3OHeNPLS3Kn0QCE9 Srla6xuK8V/GSmJshlZfRRqCTxDABQjagrCKEOf4Ow== X-Received: by 2002:a05:622a:14:b0:3fa:3c8f:3435 with SMTP id x20-20020a05622a001400b003fa3c8f3435mr109585qtw.27.1691739513628; Fri, 11 Aug 2023 00:38:33 -0700 (PDT) MIME-Version: 1.0 References: <20230811025530.3510703-1-imagedong@tencent.com> <20230811025530.3510703-4-imagedong@tencent.com> In-Reply-To: <20230811025530.3510703-4-imagedong@tencent.com> From: Eric Dumazet Date: Fri, 11 Aug 2023 09:38:22 +0200 Message-ID: Subject: Re: [PATCH net-next v4 3/4] net: tcp: fix unexcepted socket die when snd_wnd is 0 To: menglong8.dong@gmail.com Cc: ncardwell@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, flyingpeng@tencent.com, Menglong Dong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Fri, Aug 11, 2023 at 5:01=E2=80=AFAM wrote: > > From: Menglong Dong > > In tcp_retransmit_timer(), a window shrunk connection will be regarded > as timeout if 'tcp_jiffies32 - tp->rcv_tstamp > TCP_RTO_MAX'. This is not > right all the time. > > The retransmits will become zero-window probes in tcp_retransmit_timer() > if the 'snd_wnd=3D=3D0'. Therefore, the icsk->icsk_rto will come up to > TCP_RTO_MAX sooner or later. > > However, the timer can be delayed and be triggered after 122877ms, not > TCP_RTO_MAX, as I tested. > > Therefore, 'tcp_jiffies32 - tp->rcv_tstamp > TCP_RTO_MAX' is always true > once the RTO come up to TCP_RTO_MAX, and the socket will die. > > Fix this by replacing the 'tcp_jiffies32' with '(u32)icsk->icsk_timeout', > which is exact the timestamp of the timeout. > > However, "tp->rcv_tstamp" can restart from idle, then tp->rcv_tstamp > could already be a long time (minutes or hours) in the past even on the > first RTO. So we double check the timeout with the duration of the > retransmission. > > Meanwhile, making "2 * TCP_RTO_MAX" as the timeout to avoid the socket > dying too soon. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Link: https://lore.kernel.org/netdev/CADxym3YyMiO+zMD4zj03YPM3FBi-1LHi6gS= D2XT8pyAMM096pg@mail.gmail.com/ > Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet