Commit c4a5692f authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Clean-up after recent changes to sunrpc/pmap_clnt.c

Add comments for external functions, use modern function definition style,
and fix up dprintk formatting.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4a68179d
/* /*
* linux/net/sunrpc/pmap.c * linux/net/sunrpc/pmap_clnt.c
* *
* Portmapper client. * In-kernel RPC portmapper client.
*
* Portmapper supports version 2 of the rpcbind protocol (RFC 1833).
* *
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
*/ */
...@@ -76,12 +78,15 @@ static inline void pmap_wake_portmap_waiters(struct rpc_xprt *xprt) ...@@ -76,12 +78,15 @@ static inline void pmap_wake_portmap_waiters(struct rpc_xprt *xprt)
rpc_wake_up(&xprt->binding); rpc_wake_up(&xprt->binding);
} }
/* /**
* Obtain the port for a given RPC service on a given host. This one can * rpc_getport - obtain the port for a given RPC service on a given host
* be called for an ongoing RPC request. * @task: task that is waiting for portmapper request
* @clnt: controlling rpc_clnt
*
* This one can be called for an ongoing RPC request, and can be used in
* an async (rpciod) context.
*/ */
void void rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt)
rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
struct sockaddr_in *sap = &xprt->addr; struct sockaddr_in *sap = &xprt->addr;
...@@ -144,8 +149,16 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt) ...@@ -144,8 +149,16 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt)
} }
#ifdef CONFIG_ROOT_NFS #ifdef CONFIG_ROOT_NFS
int /**
rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot) * rpc_getport_external - obtain the port for a given RPC service on a given host
* @sin: address of remote peer
* @prog: RPC program number to bind
* @vers: RPC version number to bind
* @prot: transport protocol to use to make this request
*
* This one is called from outside the RPC client in a synchronous task context.
*/
int rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot)
{ {
struct portmap_args map = { struct portmap_args map = {
.pm_prog = prog, .pm_prog = prog,
...@@ -162,7 +175,7 @@ rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot) ...@@ -162,7 +175,7 @@ rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot)
char hostname[32]; char hostname[32];
int status; int status;
dprintk("RPC: rpc_getport_external(%u.%u.%u.%u, %d, %d, %d)\n", dprintk("RPC: rpc_getport_external(%u.%u.%u.%u, %u, %u, %d)\n",
NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr)); sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr));
...@@ -182,8 +195,10 @@ rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot) ...@@ -182,8 +195,10 @@ rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot)
} }
#endif #endif
static void /*
pmap_getport_done(struct rpc_task *child, void *data) * Portmapper child task invokes this callback via tk_exit.
*/
static void pmap_getport_done(struct rpc_task *child, void *data)
{ {
struct portmap_args *map = data; struct portmap_args *map = data;
struct rpc_task *task = map->pm_task; struct rpc_task *task = map->pm_task;
...@@ -211,12 +226,17 @@ pmap_getport_done(struct rpc_task *child, void *data) ...@@ -211,12 +226,17 @@ pmap_getport_done(struct rpc_task *child, void *data)
pmap_wake_portmap_waiters(xprt); pmap_wake_portmap_waiters(xprt);
} }
/* /**
* Set or unset a port registration with the local portmapper. * rpc_register - set or unset a port registration with the local portmapper
* @prog: RPC program number to bind
* @vers: RPC version number to bind
* @prot: transport protocol to use to make this request
* @port: port value to register
* @okay: result code
*
* port == 0 means unregister, port != 0 means register. * port == 0 means unregister, port != 0 means register.
*/ */
int int rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
{ {
struct sockaddr_in sin = { struct sockaddr_in sin = {
.sin_family = AF_INET, .sin_family = AF_INET,
...@@ -236,7 +256,7 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) ...@@ -236,7 +256,7 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
struct rpc_clnt *pmap_clnt; struct rpc_clnt *pmap_clnt;
int error = 0; int error = 0;
dprintk("RPC: registering (%d, %d, %d, %d) with portmapper.\n", dprintk("RPC: registering (%u, %u, %d, %u) with portmapper.\n",
prog, vers, prot, port); prog, vers, prot, port);
pmap_clnt = pmap_create("localhost", &sin, IPPROTO_UDP, 1); pmap_clnt = pmap_create("localhost", &sin, IPPROTO_UDP, 1);
...@@ -259,13 +279,11 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) ...@@ -259,13 +279,11 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
return error; return error;
} }
static struct rpc_clnt * static struct rpc_clnt *pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileged)
pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileged)
{ {
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
/* printk("pmap: create xprt\n"); */
xprt = xprt_create_proto(proto, srvaddr, NULL); xprt = xprt_create_proto(proto, srvaddr, NULL);
if (IS_ERR(xprt)) if (IS_ERR(xprt))
return (struct rpc_clnt *)xprt; return (struct rpc_clnt *)xprt;
...@@ -274,7 +292,6 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg ...@@ -274,7 +292,6 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg
if (!privileged) if (!privileged)
xprt->resvport = 0; xprt->resvport = 0;
/* printk("pmap: create clnt\n"); */
clnt = rpc_new_client(xprt, hostname, clnt = rpc_new_client(xprt, hostname,
&pmap_program, RPC_PMAP_VERSION, &pmap_program, RPC_PMAP_VERSION,
RPC_AUTH_UNIX); RPC_AUTH_UNIX);
...@@ -288,10 +305,9 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg ...@@ -288,10 +305,9 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg
/* /*
* XDR encode/decode functions for PMAP * XDR encode/decode functions for PMAP
*/ */
static int static int xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args *map)
xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args *map)
{ {
dprintk("RPC: xdr_encode_mapping(%d, %d, %d, %d)\n", dprintk("RPC: xdr_encode_mapping(%u, %u, %u, %u)\n",
map->pm_prog, map->pm_vers, map->pm_prot, map->pm_port); map->pm_prog, map->pm_vers, map->pm_prot, map->pm_port);
*p++ = htonl(map->pm_prog); *p++ = htonl(map->pm_prog);
*p++ = htonl(map->pm_vers); *p++ = htonl(map->pm_vers);
...@@ -302,15 +318,13 @@ xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args *map) ...@@ -302,15 +318,13 @@ xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args *map)
return 0; return 0;
} }
static int static int xdr_decode_port(struct rpc_rqst *req, u32 *p, unsigned short *portp)
xdr_decode_port(struct rpc_rqst *req, u32 *p, unsigned short *portp)
{ {
*portp = (unsigned short) ntohl(*p++); *portp = (unsigned short) ntohl(*p++);
return 0; return 0;
} }
static int static int xdr_decode_bool(struct rpc_rqst *req, u32 *p, unsigned int *boolp)
xdr_decode_bool(struct rpc_rqst *req, u32 *p, unsigned int *boolp)
{ {
*boolp = (unsigned int) ntohl(*p++); *boolp = (unsigned int) ntohl(*p++);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment