aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2005-06-22 13:16:20 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-06-22 16:07:04 -0400
commit5ee0ed7d3ab620a764740fb018f469d45f561931 (patch)
tree9b6a938fe521815afd3cfb42e2023b443bb05d28 /net/sunrpc/clnt.c
parent5b616f5d596c0b056129f8aeafbc08409b3cd050 (diff)
[PATCH] RPC: Make rpc_create_client() probe server for RPC program+version support
Ensure that we don't create an RPC client without checking that the server does indeed support the RPC program + version that we are trying to set up. This enables us to immediately return an error to "mount" if it turns out that the server is only supporting NFSv2, when we requested NFSv3 or NFSv4. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c59
1 files changed, 58 insertions, 1 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}