aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/clnt.c59
-rw-r--r--net/sunrpc/pmap_clnt.c2
2 files changed, 59 insertions, 2 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 99515d7727a6..b36797ad8083 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -97,7 +97,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
97 * made to sleep too long. 97 * made to sleep too long.
98 */ 98 */
99struct rpc_clnt * 99struct rpc_clnt *
100rpc_create_client(struct rpc_xprt *xprt, char *servname, 100rpc_new_client(struct rpc_xprt *xprt, char *servname,
101 struct rpc_program *program, u32 vers, 101 struct rpc_program *program, u32 vers,
102 rpc_authflavor_t flavor) 102 rpc_authflavor_t flavor)
103{ 103{
@@ -182,6 +182,36 @@ out_err:
182 return ERR_PTR(err); 182 return ERR_PTR(err);
183} 183}
184 184
185/**
186 * Create an RPC client
187 * @xprt - pointer to xprt struct
188 * @servname - name of server
189 * @info - rpc_program
190 * @version - rpc_program version
191 * @authflavor - rpc_auth flavour to use
192 *
193 * Creates an RPC client structure, then pings the server in order to
194 * determine if it is up, and if it supports this program and version.
195 *
196 * This function should never be called by asynchronous tasks such as
197 * the portmapper.
198 */
199struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
200 struct rpc_program *info, u32 version, rpc_authflavor_t authflavor)
201{
202 struct rpc_clnt *clnt;
203 int err;
204
205 clnt = rpc_new_client(xprt, servname, info, version, authflavor);
206 if (IS_ERR(clnt))
207 return clnt;
208 err = rpc_ping(clnt, RPC_TASK_SOFT|RPC_TASK_NOINTR);
209 if (err == 0)
210 return clnt;
211 rpc_shutdown_client(clnt);
212 return ERR_PTR(err);
213}
214
185/* 215/*
186 * This function clones the RPC client structure. It allows us to share the 216 * This function clones the RPC client structure. It allows us to share the
187 * same transport while varying parameters such as the authentication 217 * same transport while varying parameters such as the authentication
@@ -1086,3 +1116,30 @@ out_overflow:
1086 printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__); 1116 printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__);
1087 goto out_retry; 1117 goto out_retry;
1088} 1118}
1119
1120static int rpcproc_encode_null(void *rqstp, u32 *data, void *obj)
1121{
1122 return 0;
1123}
1124
1125static int rpcproc_decode_null(void *rqstp, u32 *data, void *obj)
1126{
1127 return 0;
1128}
1129
1130static struct rpc_procinfo rpcproc_null = {
1131 .p_encode = rpcproc_encode_null,
1132 .p_decode = rpcproc_decode_null,
1133};
1134
1135int rpc_ping(struct rpc_clnt *clnt, int flags)
1136{
1137 struct rpc_message msg = {
1138 .rpc_proc = &rpcproc_null,
1139 };
1140 int err;
1141 msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
1142 err = rpc_call_sync(clnt, &msg, flags);
1143 put_rpccred(msg.rpc_cred);
1144 return err;
1145}
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
index 97c420ff1ee0..df4d84c9020d 100644
--- a/net/sunrpc/pmap_clnt.c
+++ b/net/sunrpc/pmap_clnt.c
@@ -207,7 +207,7 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto)
207 xprt->addr.sin_port = htons(RPC_PMAP_PORT); 207 xprt->addr.sin_port = htons(RPC_PMAP_PORT);
208 208
209 /* printk("pmap: create clnt\n"); */ 209 /* printk("pmap: create clnt\n"); */
210 clnt = rpc_create_client(xprt, hostname, 210 clnt = rpc_new_client(xprt, hostname,
211 &pmap_program, RPC_PMAP_VERSION, 211 &pmap_program, RPC_PMAP_VERSION,
212 RPC_AUTH_UNIX); 212 RPC_AUTH_UNIX);
213 if (!IS_ERR(clnt)) { 213 if (!IS_ERR(clnt)) {