Refix the socket leak in xs_setup_local()
Subsystems (4)
cover Refix the socket leak in xs_setup_local()
Patch1 and patch2 roll back the wrong solution to fix socket leaks.
Patch3 adds safe teardown mechanism to re-fix socket leaks.
Wang Hai (3):
Revert "SUNRPC: Ensure gss-proxy connects on setup" Revert "Revert "SUNRPC: attempt AF_LOCAL connect on setup""
SUNRPC: Fix local socket leak in xs_setup_local()
include/linux/sunrpc/clnt.h | 1 - net/sunrpc/auth_gss/gss_rpc_upcall.c | 2 +- net/sunrpc/clnt.c | 3 --- net/sunrpc/xprtsock.c | 19 ++++++++++++++++++- 4 files changed, 19 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 Revert "SUNRPC: Ensure gss-proxy connects on setup"
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.
--- 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(-)
include/linux/sunrpc/clnt.h +0 -1
@@ -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)struct rpc_clnt *rpc_create (struct rpc_create_args *args); struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
net/sunrpc/auth_gss/gss_rpc_upcall.c +1 -1
@@ -97,7 +97,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_clnt **_clnt)* timeout, which would result in reconnections being * done without the correct namespace: */ - .flags = RPC_CLNT_CREATE_IGNORE_NULL_UNAVAIL | + .flags = RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_NO_IDLE_TIMEOUT };struct rpc_clnt *clnt;
net/sunrpc/clnt.c +0 -3
@@ -479,9 +479,6 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,if (!(args->flags &RPC_CLNT_CREATE_NOPING )) {int err =rpc_ping (clnt); -if ((args->flags &RPC_CLNT_CREATE_IGNORE_NULL_UNAVAIL ) && - err == -EOPNOTSUPP ) - err =0 ;if (err !=0 ) {rpc_shutdown_client (clnt);return ERR_PTR (err);
Signature · 1 line
2.17.1
PATCH 2/3 Revert "Revert "SUNRPC: attempt AF_LOCAL connect on setup""
In reply to Wang HaiThis 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.
--- net/sunrpc/xprtsock.c | 3 +++ 1 file changed, 3 insertions(+)
net/sunrpc/xprtsock.c +3 -0
@@ -2875,6 +2875,9 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) }xprt_set_bound (xprt);xs_format_peer_addresses (xprt,"local" ,RPCBIND_NETID_LOCAL ); + ret =ERR_PTR (xs_local_setup_socket (transport)); +if (ret) + goto out_err;break ;default : ret =ERR_PTR (-EAFNOSUPPORT );
Signature · 1 line
2.17.1
PATCH 3/3 SUNRPC: Fix local socket leak in xs_setup_local()
In reply to Wang HaiAdd mechanism in xs_setup_local() to safely tear xprt down and solve the socket leak problem.
--- net/sunrpc/xprtsock.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
net/sunrpc/xprtsock.c +15 -1
@@ -1264,6 +1264,18 @@ static void xs_xprt_free(struct rpc_xprt *xprt)xprt_free (xprt); } +/** +* xs_destroy_xprt - close xprt socket and destroy it. +*/ +static void xs_destroy_xprt (struct work_struct *work) +{ +struct rpc_xprt *xprt = + 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_create *args)return xprt; ret =ERR_PTR (-EINVAL ); out_err: -xs_xprt_free (xprt); + +INIT_WORK (&xprt->task_cleanup, xs_destroy_xprt); +schedule_work (&xprt->task_cleanup);return ret; }
Signature · 1 line
2.17.1
Quoted 9 lines · Wang Hai
Patch1 and patch2 roll back the wrong solution to fix socket leaks.
Patch3 adds safe teardown mechanism to re-fix socket leaks.
Wang Hai (3):
Revert "SUNRPC: Ensure gss-proxy connects on setup" Revert "Revert "SUNRPC: attemptAF_LOCALconnect on setup""
SUNRPC: Fix local socket leak inxs_setup_local()
Quoted 6 lines
include/linux/sunrpc/clnt.h | 1 -
net/sunrpc/auth_gss/gss_rpc_upcall.c| 2 +- net/sunrpc/clnt.c | 3 --- net/sunrpc/xprtsock.c | 19 ++++++++++++++++++-4 files changed, 19 insertions(+), 6 deletions(-)
Thanks, but there is already a fix for this queued up in the linux-next branch.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 10 lines · Trond Myklebust
Quoted 9 lines · Wang Hai
Patch1 and patch2 roll back the wrong solution to fix socket leaks.
Patch3 adds safe teardown mechanism to re-fix socket leaks.
Wang Hai (3):
Revert "SUNRPC: Ensure gss-proxy connects on setup" Revert "Revert "SUNRPC: attemptAF_LOCALconnect on setup""
SUNRPC: Fix local socket leak inxs_setup_local()
Quoted 8 lines
Quoted 6 lines
include/linux/sunrpc/clnt.h | 1 - net/sunrpc/auth_gss/gss_rpc_upcall.c | 2 +- net/sunrpc/clnt.c | 3 --- net/sunrpc/xprtsock.c | 19 ++++++++++++++++++- 4 files changed, 19 insertions(+), 6 deletions(-)Thanks, but there is already a fix for this queued up in the linux-next branch.
Thanks, sorry to bother you, I found it.
I only subscribed to the [email protected] mailing list, not the [email protected] mailing list separately. So I didn't notice it was fixed.
Signature · 1 line
Wang Hai