diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2006-08-22 20:06:20 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-22 23:24:49 -0400 |
commit | c2866763b4029411d166040306691773c12d4caf (patch) | |
tree | 5b16b3a293843062234c5eaf377da2af93365266 /net/sunrpc/clnt.c | |
parent | 6ca948238724c945bd353f51d54ae7d285f3889f (diff) |
SUNRPC: use sockaddr + size when creating remote transport endpoints
Prepare for more generic transport endpoint handling needed by transports
that might use different forms of addressing, such as IPv6.
Introduce a single function call to replace the two-call
xprt_create_proto/rpc_create_client API. Define a new rpc_create_args
structure that allows callers to pass in remote endpoint addresses of
varying length.
Test-plan:
Compile kernel with CONFIG_NFS enabled.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r-- | net/sunrpc/clnt.c | 61 |
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 | */ | ||
205 | struct 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 | } | ||
254 | EXPORT_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 |