Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158552
b: refs/heads/master
c: c0c077d
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Aug 9, 2009
1 parent a6ed782 commit bfd2b20
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 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: 7ed0ff983c8ad30bf4e2b9fdbb299a3e3ec08d08
refs/heads/master: c0c077df009f2f329875051ac5283df235288689
80 changes: 77 additions & 3 deletions trunk/net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot)
struct rpc_message msg = {
.rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT],
.rpc_argp = &map,
.rpc_resp = &map.r_port,
.rpc_resp = &map,
};
struct rpc_clnt *rpcb_clnt;
int status;
Expand Down Expand Up @@ -484,7 +484,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
struct rpc_message msg = {
.rpc_proc = proc,
.rpc_argp = map,
.rpc_resp = &map->r_port,
.rpc_resp = map,
};
struct rpc_task_setup task_setup_data = {
.rpc_client = rpcb_clnt,
Expand Down Expand Up @@ -727,6 +727,31 @@ static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p,
return 0;
}

static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p,
struct rpcbind_args *rpcb)
{
struct rpc_task *task = req->rq_task;
struct xdr_stream xdr;
unsigned long port;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);

rpcb->r_port = 0;

p = xdr_inline_decode(&xdr, sizeof(__be32));
if (unlikely(p == NULL))
return -EIO;

port = ntohl(*p);
dprintk("RPC: %5u PMAP_%s result: %lu\n", task->tk_pid,
task->tk_msg.rpc_proc->p_name, port);
if (unlikely(port > USHORT_MAX))
return -EIO;

rpcb->r_port = port;
return 0;
}

static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p,
unsigned int *boolp)
{
Expand Down Expand Up @@ -871,11 +896,60 @@ static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p,
return -EIO;
}

static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p,
struct rpcbind_args *rpcb)
{
struct sockaddr_storage address;
struct sockaddr *sap = (struct sockaddr *)&address;
struct rpc_task *task = req->rq_task;
struct xdr_stream xdr;
u32 len;

rpcb->r_port = 0;

xdr_init_decode(&xdr, &req->rq_rcv_buf, p);

p = xdr_inline_decode(&xdr, sizeof(__be32));
if (unlikely(p == NULL))
goto out_fail;
len = ntohl(*p);

/*
* If the returned universal address is a null string,
* the requested RPC service was not registered.
*/
if (len == 0) {
dprintk("RPC: %5u RPCB reply: program not registered\n",
task->tk_pid);
return 0;
}

if (unlikely(len > RPCBIND_MAXUADDRLEN))
goto out_fail;

p = xdr_inline_decode(&xdr, len);
if (unlikely(p == NULL))
goto out_fail;
dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid,
task->tk_msg.rpc_proc->p_name, (char *)p);

if (rpc_uaddr2sockaddr((char *)p, len, sap, sizeof(address)) == 0)
goto out_fail;
rpcb->r_port = rpc_get_port(sap);

return 0;

out_fail:
dprintk("RPC: %5u malformed RPCB_%s reply\n",
task->tk_pid, task->tk_msg.rpc_proc->p_name);
return -EIO;
}

#define PROC(proc, argtype, restype) \
[RPCBPROC_##proc] = { \
.p_proc = RPCBPROC_##proc, \
.p_encode = (kxdrproc_t) rpcb_enc_##argtype, \
.p_decode = (kxdrproc_t) rpcb_decode_##restype, \
.p_decode = (kxdrproc_t) rpcb_dec_##restype, \
.p_arglen = RPCB_##argtype##args_sz, \
.p_replen = RPCB_##restype##res_sz, \
.p_statidx = RPCBPROC_##proc, \
Expand Down

0 comments on commit bfd2b20

Please sign in to comment.