From patchwork Wed May 17 12:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 9458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1124391vqo; Wed, 17 May 2023 06:11:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BTLObQ+V8FJ4uAcikH+evbTTUoKjanDaQunlaCXtj82GCsCRtnfz+1HkndmKcGs+ONMeD X-Received: by 2002:a17:902:c249:b0:1ae:3e5b:31b1 with SMTP id 9-20020a170902c24900b001ae3e5b31b1mr5297070plg.9.1684329085335; Wed, 17 May 2023 06:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684329085; cv=none; d=google.com; s=arc-20160816; b=oVYZ/kGbVoBjPY1Kdw73G+oMXq/7fsRB30lcxIuzyCE3AqkGYMDMCD0l9MEJLYFhiR YbvpiOZ0a9NZC8K9BdFX/kaI/3O317wo2prt0I+kt29rbJi2Pxo3a900XPnKYMVjQTHK wO16DezyEQkUWSammHsO+BXI1qLC8PNlOhg81dwEMLzD48rm76EGC3sjcQXUUqnZLnLk tQ39b7rHsJ+xX8jfsMVjOp9HeNaOB6JWGlIU+CnVxu00DTMq13Tit5xLRymxeXDqwotf 9tG1pjI86FNp0FpJT/XyizaahgsWfjRgjK2HS+wlqSa5OsvfUMdc2NP0982KmrMhZQyz bkAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vdNngZhsKhcXNCAWoCajdyQW0IMTNw0nIYVCN7bYTSU=; b=WF6rcd2vROKEmBgijuVB8gbHG8jRT7YWVIc/3af6+upWlwd4e9sdPveYKmrpv1Nchf CTowQlqg7giq3UPEiL7BXD5Vzmu1N8rh43R9LLmuhKSLBJIptoebfYjz9Q7vYW4Q+fxD j1sLTuGqjIkbmO/Lm/sxmf2Cllm33w7XqzeoG/R4LDmJuFH+ZObi+i6sshyGBGzFfi+o n42IAihZsY2QUrsipsuB/DjCEzFQ6s8anqmehkdESBZANg1PT0h40vARNt65I9nYK53x kOWOlYSsXp+M6RCohzqTQnJbd+JwqNotetZfwt0Sy1za2aGrrMvQYsNzJ81zqbw/9eOo VjjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TZQUdKyn; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170902f68a00b001adb9d3bf5bsi12766032plg.372.2023.05.17.06.11.10; Wed, 17 May 2023 06:11:25 -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=@gmail.com header.s=20221208 header.b=TZQUdKyn; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbjEQMmR (ORCPT + 99 others); Wed, 17 May 2023 08:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbjEQMmM (ORCPT ); Wed, 17 May 2023 08:42:12 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FDF8211C; Wed, 17 May 2023 05:42:08 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-64384274895so497006b3a.2; Wed, 17 May 2023 05:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684327328; x=1686919328; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vdNngZhsKhcXNCAWoCajdyQW0IMTNw0nIYVCN7bYTSU=; b=TZQUdKyniQjbEM8cAFb8uyX9CbMNswaIhc51dp0m7XKiPT0Fl6Ik+avjN9tUPoadEF pKenfSIxInRPBretbCTpojzxlaup7EVmiolpppd5MZW3ttsp9X47uAWwW0AIOM6Ki/rn Q8IUtZmPrZhQqHP0G4oQOzzvsJNPs6EcjQ/Gz/YQNfk71Vpcj2vM9zALZ/Q+wK8wBpN2 qs3iAlS2fQLJc1UN+epgWSe1ZTC5e4MMyfxQi72GgOuBos2Ms30olwuQKr3W7CCma5Cq J3LifgTvfn4LvOS8E6C+UMUqR/2Vk4oDGL3YDOf/oez/PchSDzXvG3a5yF5addp15beQ Hdlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684327328; x=1686919328; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vdNngZhsKhcXNCAWoCajdyQW0IMTNw0nIYVCN7bYTSU=; b=SuvKh076tr6KJC0nv5UcN1ovzwB7ELaSSk7zYcXIbeOzBqKCaV+D1Yq46ZblGm8RaN 6BvzTArStJ1Rf/YiF1ofB845Dn2sg2Zkg0xie7w8TzM+6kbHC+rIl/SGPRNk67lNiPCf 4eX3gW27G0mNP/ZH5+E1qcjKMa/lbu4uiZOOzbRcKVp/h4/tLrg4GxUqJaNhADn4SLwC CxjcDpNFmyoi19XBuf1BnyIHUGHDFQ6JtGbHUlTb6TKwBW/im7twE4mVRfXyQ7h5cYvd BR5D04vfws72G0OC4KTKAdI3TIdZCHAJIpUViBbCP0aL4e5TD4TpmIG2v4g9LQRyUtsl Tv3w== X-Gm-Message-State: AC+VfDxZ6P1w/uy6Q9uclbgibAlFUr2ggbpeVFy0L78Kg02PTbHj96su h7VgdXEQeABdcsMtXf4qZxk= X-Received: by 2002:aa7:88d0:0:b0:646:663a:9d60 with SMTP id k16-20020aa788d0000000b00646663a9d60mr994827pff.10.1684327327983; Wed, 17 May 2023 05:42:07 -0700 (PDT) Received: from localhost.localdomain ([81.70.217.19]) by smtp.gmail.com with ESMTPSA id u23-20020aa78497000000b0064aea45b040sm9244224pfn.168.2023.05.17.05.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 05:42:07 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH net-next 0/3] net: tcp: add support of window shrink Date: Wed, 17 May 2023 20:41:58 +0800 Message-Id: <20230517124201.441634-1-imagedong@tencent.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766147054905734175?= X-GMAIL-MSGID: =?utf-8?q?1766147054905734175?= From: Menglong Dong For now, skb will be dropped when no memory, which makes client keep retrans util timeout and it's not friendly to the users. Therefore, now we force to receive one packet on current socket when the protocol memory is out of the limitation. Then, this socket will stay in 'no mem' status, util protocol memory is available. When a socket is in 'no mem' status, it's receive window will become 0, which means window shrink happens. For the sender, it need to cover this case, and we turn it into zero-window probe status. In the origin logic, 0 probe is triggered only when there is no any data in the retrans queue and the receive window can't hold the data of the 1th packet in the send queue. Now, let's change it and trigger the 0 probe in such cases: - if the retrans queue has data and the 1th packet in it is not within the receive window, which is for window shrink case, as the shrinked window may can't cover the data in retrans queue. - no data in the retrans queue and the 1th packet in the send queue is out of the end of the receive window And the sysctl 'tcp_wnd_shrink' is also introduced. In order to keep safe, we disable this feature by default. *** BLURB HERE *** Menglong Dong (3): net: tcp: add sysctl for controling tcp window shrink net: tcp: send zero-window when no memory net: tcp: handle window shrink properly include/net/sock.h | 1 + include/net/tcp.h | 22 ++++++++++++++++ net/ipv4/sysctl_net_ipv4.c | 9 +++++++ net/ipv4/tcp.c | 3 +++ net/ipv4/tcp_input.c | 53 ++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_output.c | 10 +++++-- net/ipv4/tcp_timer.c | 4 +-- 7 files changed, 97 insertions(+), 5 deletions(-)