From nobody Sun Jun 14 21:07:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84848C433EF for ; Wed, 11 May 2022 13:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243074AbiEKNET (ORCPT ); Wed, 11 May 2022 09:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243038AbiEKNEP (ORCPT ); Wed, 11 May 2022 09:04:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A4D235151; Wed, 11 May 2022 06:04:12 -0700 (PDT) Received: from kwepemi100016.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Kyw816KR5zhZ2W; Wed, 11 May 2022 21:03:29 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by kwepemi100016.china.huawei.com (7.221.188.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:09 +0800 Received: from huawei.com (10.175.113.133) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:08 +0800 From: Wang Hai To: , , , , , , CC: , , , Subject: [PATCH 1/3] Revert "SUNRPC: Ensure gss-proxy connects on setup" Date: Wed, 11 May 2022 21:22:30 +0800 Message-ID: <20220511132232.4030-2-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220511132232.4030-1-wanghai38@huawei.com> References: <20220511132232.4030-1-wanghai38@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit 892de36fd4a98fab3298d417c051d9099af5448d. In fact, gss-proxy can't respond to rpc_ping() at setup time. After the timeout, rpc_ping() will return -EIO instead of -EOPNOTSUPP. The reverted patch can't ensure that gssp connects to the service at setup time. Signed-off-by: Wang Hai --- include/linux/sunrpc/clnt.h | 1 - net/sunrpc/auth_gss/gss_rpc_upcall.c | 2 +- net/sunrpc/clnt.c | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index db5149567305..267b7aeaf1a6 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -160,7 +160,6 @@ struct rpc_add_xprt_test { #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) #define RPC_CLNT_CREATE_SOFTERR (1UL << 10) #define RPC_CLNT_CREATE_REUSEPORT (1UL << 11) -#define RPC_CLNT_CREATE_IGNORE_NULL_UNAVAIL (1UL << 12) =20 struct rpc_clnt *rpc_create(struct rpc_create_args *args); struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, diff --git a/net/sunrpc/auth_gss/gss_rpc_upcall.c b/net/sunrpc/auth_gss/gss= _rpc_upcall.c index 8ca1d809b78d..61c276bddaf2 100644 --- a/net/sunrpc/auth_gss/gss_rpc_upcall.c +++ b/net/sunrpc/auth_gss/gss_rpc_upcall.c @@ -97,7 +97,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_cl= nt **_clnt) * timeout, which would result in reconnections being * done without the correct namespace: */ - .flags =3D RPC_CLNT_CREATE_IGNORE_NULL_UNAVAIL | + .flags =3D RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_NO_IDLE_TIMEOUT }; struct rpc_clnt *clnt; diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 22c28cf43eba..98133aa54f19 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -479,9 +479,6 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_crea= te_args *args, =20 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { int err =3D rpc_ping(clnt); - if ((args->flags & RPC_CLNT_CREATE_IGNORE_NULL_UNAVAIL) && - err =3D=3D -EOPNOTSUPP) - err =3D 0; if (err !=3D 0) { rpc_shutdown_client(clnt); return ERR_PTR(err); --=20 2.17.1 From nobody Sun Jun 14 21:07:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98687C433EF for ; Wed, 11 May 2022 13:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243102AbiEKNEb (ORCPT ); Wed, 11 May 2022 09:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243049AbiEKNEQ (ORCPT ); Wed, 11 May 2022 09:04:16 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7AD2233A5F; Wed, 11 May 2022 06:04:12 -0700 (PDT) Received: from kwepemi100017.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Kyw3G2ZsmzCscg; Wed, 11 May 2022 20:59:22 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by kwepemi100017.china.huawei.com (7.221.188.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:09 +0800 Received: from huawei.com (10.175.113.133) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:09 +0800 From: Wang Hai To: , , , , , , CC: , , , Subject: [PATCH 2/3] Revert "Revert "SUNRPC: attempt AF_LOCAL connect on setup"" Date: Wed, 11 May 2022 21:22:31 +0800 Message-ID: <20220511132232.4030-3-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220511132232.4030-1-wanghai38@huawei.com> References: <20220511132232.4030-1-wanghai38@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit a3d0562d4dc039bca39445e1cddde7951662e17d. There is currently no better way to ensure that gss-proxy connects when setup. Therefore, it is still necessary to connect in the construction. The mechanism to safely tear xprt down needs to be implemented later. Signed-off-by: Wang Hai --- net/sunrpc/xprtsock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 650102a9c86a..25b8a8ead56b 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2875,6 +2875,9 @@ static struct rpc_xprt *xs_setup_local(struct xprt_cr= eate *args) } xprt_set_bound(xprt); xs_format_peer_addresses(xprt, "local", RPCBIND_NETID_LOCAL); + ret =3D ERR_PTR(xs_local_setup_socket(transport)); + if (ret) + goto out_err; break; default: ret =3D ERR_PTR(-EAFNOSUPPORT); --=20 2.17.1 From nobody Sun Jun 14 21:07:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8EE3C4332F for ; Wed, 11 May 2022 13:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243216AbiEKNEj (ORCPT ); Wed, 11 May 2022 09:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243058AbiEKNEQ (ORCPT ); Wed, 11 May 2022 09:04:16 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8878233A6A; Wed, 11 May 2022 06:04:13 -0700 (PDT) Received: from kwepemi100014.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Kyw3H1n2DzCsbX; Wed, 11 May 2022 20:59:23 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by kwepemi100014.china.huawei.com (7.221.188.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:10 +0800 Received: from huawei.com (10.175.113.133) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 21:04:09 +0800 From: Wang Hai To: , , , , , , CC: , , , Subject: [PATCH 3/3] SUNRPC: Fix local socket leak in xs_setup_local() Date: Wed, 11 May 2022 21:22:32 +0800 Message-ID: <20220511132232.4030-4-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220511132232.4030-1-wanghai38@huawei.com> References: <20220511132232.4030-1-wanghai38@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mechanism in xs_setup_local() to safely tear xprt down and solve the socket leak problem. Signed-off-by: Wang Hai --- net/sunrpc/xprtsock.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 25b8a8ead56b..7b9a62750571 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1264,6 +1264,18 @@ static void xs_xprt_free(struct rpc_xprt *xprt) xprt_free(xprt); } =20 +/** + * xs_destroy_xprt - close xprt socket and destroy it. + */ +static void xs_destroy_xprt(struct work_struct *work) +{ + struct rpc_xprt *xprt =3D + container_of(work, struct rpc_xprt, task_cleanup); + + xs_close(xprt); + xs_xprt_free(xprt); +} + /** * xs_destroy - prepare to shutdown a transport * @xprt: doomed transport @@ -2891,7 +2903,9 @@ static struct rpc_xprt *xs_setup_local(struct xprt_cr= eate *args) return xprt; ret =3D ERR_PTR(-EINVAL); out_err: - xs_xprt_free(xprt); + + INIT_WORK(&xprt->task_cleanup, xs_destroy_xprt); + schedule_work(&xprt->task_cleanup); return ret; } =20 --=20 2.17.1