aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index ff1e90fd81ab..dbb93bdf6cc9 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -192,6 +192,67 @@ out_no_xprt:
192 return ERR_PTR(err); 192 return ERR_PTR(err);
193} 193}
194 194
195/*
196 * rpc_create - create an RPC client and transport with one call
197 * @args: rpc_clnt create argument structure
198 *
199 * Creates and initializes an RPC transport and an RPC client.
200 *
201 * It can ping the server in order to determine if it is up, and to see if
202 * it supports this program and version. RPC_CLNT_CREATE_NOPING disables
203 * this behavior so asynchronous tasks can also use rpc_create.
204 */
205struct rpc_clnt *rpc_create(struct rpc_create_args *args)
206{
207 struct rpc_xprt *xprt;
208 struct rpc_clnt *clnt;
209
210 xprt = xprt_create_transport(args->protocol, args->address,
211 args->addrsize, args->timeout);
212 if (IS_ERR(xprt))
213 return (struct rpc_clnt *)xprt;
214
215 /*
216 * By default, kernel RPC client connects from a reserved port.
217 * CAP_NET_BIND_SERVICE will not be set for unprivileged requesters,
218 * but it is always enabled for rpciod, which handles the connect
219 * operation.
220 */
221 xprt->resvport = 1;
222 if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT)
223 xprt->resvport = 0;
224
225 dprintk("RPC: creating %s client for %s (xprt %p)\n",
226 args->program->name, args->servername, xprt);
227
228 clnt = rpc_new_client(xprt, args->servername, args->program,
229 args->version, args->authflavor);
230 if (IS_ERR(clnt))
231 return clnt;
232
233 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
234 int err = rpc_ping(clnt, RPC_TASK_SOFT|RPC_TASK_NOINTR);
235 if (err != 0) {
236 rpc_shutdown_client(clnt);
237 return ERR_PTR(err);
238 }
239 }
240
241 clnt->cl_softrtry = 1;
242 if (args->flags & RPC_CLNT_CREATE_HARDRTRY)
243 clnt->cl_softrtry = 0;
244
245 if (args->flags & RPC_CLNT_CREATE_INTR)
246 clnt->cl_intr = 1;
247 if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
248 clnt->cl_autobind = 1;
249 if (args->flags & RPC_CLNT_CREATE_ONESHOT)
250 clnt->cl_oneshot = 1;
251
252 return clnt;
253}
254EXPORT_SYMBOL(rpc_create);
255
195/** 256/**
196 * Create an RPC client 257 * Create an RPC client
197 * @xprt - pointer to xprt struct 258 * @xprt - pointer to xprt struct