Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2758
b: refs/heads/master
c: 5ee0ed7
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jun 22, 2005
1 parent c3e06b9 commit bb4a5c7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5b616f5d596c0b056129f8aeafbc08409b3cd050
refs/heads/master: 5ee0ed7d3ab620a764740fb018f469d45f561931
4 changes: 2 additions & 2 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ nlm_bind_host(struct nlm_host *host)
goto forgetit;

xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
xprt->nocong = 1; /* No congestion control for NLM */
xprt->resvport = 1; /* NLM requires a reserved port */

/* Existing NLM servers accept AUTH_UNIX only */
clnt = rpc_create_client(xprt, host->h_name, &nlm_program,
host->h_version, RPC_AUTH_UNIX);
if (IS_ERR(clnt))
goto forgetit;
clnt->cl_autobind = 1; /* turn on pmap queries */
xprt->nocong = 1; /* No congestion control for NLM */
xprt->resvport = 1; /* NLM requires a reserved port */

host->h_rpcclnt = clnt;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ nsm_create(void)
xprt = xprt_create_proto(IPPROTO_UDP, &sin, NULL);
if (IS_ERR(xprt))
return (struct rpc_clnt *)xprt;
xprt->resvport = 1; /* NSM requires a reserved port */

clnt = rpc_create_client(xprt, "localhost",
&nsm_program, SM_VERSION,
Expand All @@ -124,7 +125,6 @@ nsm_create(void)
clnt->cl_softrtry = 1;
clnt->cl_chatty = 1;
clnt->cl_oneshot = 1;
xprt->resvport = 1; /* NSM requires a reserved port */
return clnt;

out_err:
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/linux/sunrpc/clnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ struct rpc_procinfo {
struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
struct rpc_program *info,
u32 version, rpc_authflavor_t authflavor);
struct rpc_clnt *rpc_new_client(struct rpc_xprt *xprt, char *servname,
struct rpc_program *info,
u32 version, rpc_authflavor_t authflavor);
struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
int rpc_shutdown_client(struct rpc_clnt *);
int rpc_destroy_client(struct rpc_clnt *);
Expand All @@ -129,6 +132,7 @@ void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
size_t rpc_max_payload(struct rpc_clnt *);
int rpc_ping(struct rpc_clnt *clnt, int flags);

static __inline__
int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
Expand Down
59 changes: 58 additions & 1 deletion trunk/net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
* made to sleep too long.
*/
struct rpc_clnt *
rpc_create_client(struct rpc_xprt *xprt, char *servname,
rpc_new_client(struct rpc_xprt *xprt, char *servname,
struct rpc_program *program, u32 vers,
rpc_authflavor_t flavor)
{
Expand Down Expand Up @@ -182,6 +182,36 @@ rpc_create_client(struct rpc_xprt *xprt, char *servname,
return ERR_PTR(err);
}

/**
* Create an RPC client
* @xprt - pointer to xprt struct
* @servname - name of server
* @info - rpc_program
* @version - rpc_program version
* @authflavor - rpc_auth flavour to use
*
* Creates an RPC client structure, then pings the server in order to
* determine if it is up, and if it supports this program and version.
*
* This function should never be called by asynchronous tasks such as
* the portmapper.
*/
struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
struct rpc_program *info, u32 version, rpc_authflavor_t authflavor)
{
struct rpc_clnt *clnt;
int err;

clnt = rpc_new_client(xprt, servname, info, version, authflavor);
if (IS_ERR(clnt))
return clnt;
err = rpc_ping(clnt, RPC_TASK_SOFT|RPC_TASK_NOINTR);
if (err == 0)
return clnt;
rpc_shutdown_client(clnt);
return ERR_PTR(err);
}

/*
* This function clones the RPC client structure. It allows us to share the
* same transport while varying parameters such as the authentication
Expand Down Expand Up @@ -1086,3 +1116,30 @@ call_verify(struct rpc_task *task)
printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__);
goto out_retry;
}

static int rpcproc_encode_null(void *rqstp, u32 *data, void *obj)
{
return 0;
}

static int rpcproc_decode_null(void *rqstp, u32 *data, void *obj)
{
return 0;
}

static struct rpc_procinfo rpcproc_null = {
.p_encode = rpcproc_encode_null,
.p_decode = rpcproc_decode_null,
};

int rpc_ping(struct rpc_clnt *clnt, int flags)
{
struct rpc_message msg = {
.rpc_proc = &rpcproc_null,
};
int err;
msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
err = rpc_call_sync(clnt, &msg, flags);
put_rpccred(msg.rpc_cred);
return err;
}
2 changes: 1 addition & 1 deletion trunk/net/sunrpc/pmap_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto)
xprt->addr.sin_port = htons(RPC_PMAP_PORT);

/* printk("pmap: create clnt\n"); */
clnt = rpc_create_client(xprt, hostname,
clnt = rpc_new_client(xprt, hostname,
&pmap_program, RPC_PMAP_VERSION,
RPC_AUTH_UNIX);
if (!IS_ERR(clnt)) {
Expand Down

0 comments on commit bb4a5c7

Please sign in to comment.