Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2785538rdh; Wed, 27 Sep 2023 12:35:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbNWO0yG33DC4BT4dIc07KLFAVX/OrGOAa5a4ma9L7uWLaP3/PdgMYymC9EYOjlZNBUCnC X-Received: by 2002:a05:6a00:3a1c:b0:690:d620:7801 with SMTP id fj28-20020a056a003a1c00b00690d6207801mr3069262pfb.11.1695843342337; Wed, 27 Sep 2023 12:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695843342; cv=none; d=google.com; s=arc-20160816; b=Oz/ZPVD8xzVOTkpbMJAzs0Fg2cWGFI2ZeWA2kIfBUP1WUvaf/z1+mz2pmv7uFHK6Qw q8hxxrnfKnUG+SCYHZLpkj/BM9cRsQnOi0dS5Jn6HBv29ez4TQk1JeQcXgN7d7OAC7CR 2U62wUSFq58dGyn4ad+p6hQ7kd2T7Iw5Dv5+TPABKAf7ME0m/LqfS30b4XQgOmb1qCva B2ARWiY3FJyEopqEWyDap90IXs7EQTkxJK68lnWF/m09CzMTzVmjvbVVAN2vEeDCmgvO pLndIcaDC3fOFi60OJJkK32byyCulYbe22drm4ZLlyCOTO6hrPGwc6wtO8a/jkPdxiez 1V0A== 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:to:from:dkim-signature; bh=Ql+h1QBgc3koaQYe9I9920/WuPRnotBAElChH3HGs3o=; fh=Mys3y4MwsHRytUQMpdfGBn3oGRYLcLloxNwkFYMYMmg=; b=rmmXyjArEXeRg7p4i6gPkHsW39Yt5yn4tVR5WxmoQ8CLy6e/zjM1ipaF26NsbXMWoc S9KXu9XFo3sjyJEmBd7JWi86vcw7rC0UQOPQSCHsKQpzaNHVlKUvF6Pvqu0+YjbkYEIU TfKmR0TiqITSym/uIDNT/dArGH+ahFdYiHWWFRqycFOus2RLlG9yEfXzOo8QmEdcr2ar ToFEU+/RUQ7hB2qkvRhc9PgAJe8fHFExUaP/8RZl9GMC6r0jMR8g3PGWbzyUnOaZOGis vr0vg5nm4AtwbekjdpeicCkqx12Nl0V103PyYzH3NaeyU9Y/D4hWFvxaHv2/AviZNpxI X5TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="NLX/djhX"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id i67-20020a639d46000000b0057c3103bf15si15737093pgd.277.2023.09.27.12.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="NLX/djhX"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 33F2781EB0EE; Wed, 27 Sep 2023 12:33:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbjI0TdA (ORCPT + 99 others); Wed, 27 Sep 2023 15:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjI0TdA (ORCPT ); Wed, 27 Sep 2023 15:33:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C11CC for ; Wed, 27 Sep 2023 12:32:59 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E75DC433C8 for ; Wed, 27 Sep 2023 19:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695843179; bh=/AzHoaphmmitQd4Rx4tvk528BJh1T1MnaCxmDYju/84=; h=From:To:Subject:Date:From; b=NLX/djhXPuTjBosmZLv43Nhj0jG/cydViM0Rs71hSerYBNf20HpT/y1O1AxZ+eQUd agS7DnM43eNAvocdwqjG9eqivHuWQbNiOSjDQooGhoBv/ckl1KjrHSmxChCLg2PK3T vmwGQcC4kXvDoHrqMxQzmQkQCLCzkKqOjylW5kfXEqd/W1+8ZE8JZzsMyVAa2kCXDp oeRKj4HXG59M3PLX/mOAGlCuQ5AJDyhwZ3/xjfwfDy6ctSnlEtJzAFhkwuAedjTVVR SUN5fYcM8QOLttPsgmbYbJ9hYUT9Ue/rn4eS2iOFzaDmnjJVPgVN5ty+e+XWQyI/vb U4EdvObxYGVzQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH] SUNRPC: Don't retry using the same source port if connection failed Date: Wed, 27 Sep 2023 15:27:12 -0400 Message-ID: <20230927192712.317799-1-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 12:33:01 -0700 (PDT) From: Trond Myklebust If the TCP connection attempt fails without ever establishing a connection, then assume the problem may be the server is rejecting us due to port reuse. Signed-off-by: Trond Myklebust --- net/sunrpc/xprtsock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 71848ab90d13..1a96777f0ed5 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -62,6 +62,7 @@ #include "sunrpc.h" static void xs_close(struct rpc_xprt *xprt); +static void xs_reset_srcport(struct sock_xprt *transport); static void xs_set_srcport(struct sock_xprt *transport, struct socket *sock); static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt, struct socket *sock); @@ -1565,8 +1566,10 @@ static void xs_tcp_state_change(struct sock *sk) break; case TCP_CLOSE: if (test_and_clear_bit(XPRT_SOCK_CONNECTING, - &transport->sock_state)) + &transport->sock_state)) { + xs_reset_srcport(transport); xprt_clear_connecting(xprt); + } clear_bit(XPRT_CLOSING, &xprt->state); /* Trigger the socket release */ xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT); @@ -1722,6 +1725,11 @@ static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) xs_update_peer_port(xprt); } +static void xs_reset_srcport(struct sock_xprt *transport) +{ + transport->srcport = 0; +} + static void xs_set_srcport(struct sock_xprt *transport, struct socket *sock) { if (transport->srcport == 0 && transport->xprt.reuseport) -- 2.41.0