Skip to content

Commit fd13359

Browse files
author
Trond Myklebust
committed
SUNRPC: Ensure that the gssproxy client can start in a connected state
Ensure that the gssproxy client connects to the server from the gssproxy daemon process context so that the AF_LOCAL socket connection is done using the correct path and namespaces. Fixes: 1d65833 ("SUNRPC: Add RPC based upcall mechanism for RPCGSS auth") Cc: [email protected] Signed-off-by: Trond Myklebust <[email protected]>
1 parent 3d1b0d3 commit fd13359

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

include/linux/sunrpc/clnt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct rpc_add_xprt_test {
160160
#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
161161
#define RPC_CLNT_CREATE_SOFTERR (1UL << 10)
162162
#define RPC_CLNT_CREATE_REUSEPORT (1UL << 11)
163+
#define RPC_CLNT_CREATE_CONNECTED (1UL << 12)
163164

164165
struct rpc_clnt *rpc_create(struct rpc_create_args *args);
165166
struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,

net/sunrpc/auth_gss/gss_rpc_upcall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_clnt **_clnt)
9898
* done without the correct namespace:
9999
*/
100100
.flags = RPC_CLNT_CREATE_NOPING |
101+
RPC_CLNT_CREATE_CONNECTED |
101102
RPC_CLNT_CREATE_NO_IDLE_TIMEOUT
102103
};
103104
struct rpc_clnt *clnt;

net/sunrpc/clnt.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static int rpc_encode_header(struct rpc_task *task,
7676
static int rpc_decode_header(struct rpc_task *task,
7777
struct xdr_stream *xdr);
7878
static int rpc_ping(struct rpc_clnt *clnt);
79+
static int rpc_ping_noreply(struct rpc_clnt *clnt);
7980
static void rpc_check_timeout(struct rpc_task *task);
8081

8182
static void rpc_register_client(struct rpc_clnt *clnt)
@@ -483,6 +484,12 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
483484
rpc_shutdown_client(clnt);
484485
return ERR_PTR(err);
485486
}
487+
} else if (args->flags & RPC_CLNT_CREATE_CONNECTED) {
488+
int err = rpc_ping_noreply(clnt);
489+
if (err != 0) {
490+
rpc_shutdown_client(clnt);
491+
return ERR_PTR(err);
492+
}
486493
}
487494

488495
clnt->cl_softrtry = 1;
@@ -2709,6 +2716,10 @@ static const struct rpc_procinfo rpcproc_null = {
27092716
.p_decode = rpcproc_decode_null,
27102717
};
27112718

2719+
static const struct rpc_procinfo rpcproc_null_noreply = {
2720+
.p_encode = rpcproc_encode_null,
2721+
};
2722+
27122723
static void
27132724
rpc_null_call_prepare(struct rpc_task *task, void *data)
27142725
{
@@ -2762,6 +2773,28 @@ static int rpc_ping(struct rpc_clnt *clnt)
27622773
return status;
27632774
}
27642775

2776+
static int rpc_ping_noreply(struct rpc_clnt *clnt)
2777+
{
2778+
struct rpc_message msg = {
2779+
.rpc_proc = &rpcproc_null_noreply,
2780+
};
2781+
struct rpc_task_setup task_setup_data = {
2782+
.rpc_client = clnt,
2783+
.rpc_message = &msg,
2784+
.callback_ops = &rpc_null_ops,
2785+
.flags = RPC_TASK_SOFT | RPC_TASK_SOFTCONN | RPC_TASK_NULLCREDS,
2786+
};
2787+
struct rpc_task *task;
2788+
int status;
2789+
2790+
task = rpc_run_task(&task_setup_data);
2791+
if (IS_ERR(task))
2792+
return PTR_ERR(task);
2793+
status = task->tk_status;
2794+
rpc_put_task(task);
2795+
return status;
2796+
}
2797+
27652798
struct rpc_cb_add_xprt_calldata {
27662799
struct rpc_xprt_switch *xps;
27672800
struct rpc_xprt *xprt;

0 commit comments

Comments
 (0)