提交 9f6ad26d 编写于 作者: C Chuck Lever 提交者: Trond Myklebust

SUNRPC: Fix socket address handling in rpcb_clnt

Make sure rpcb_clnt passes the correct address length to rpc_create().
Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 510deb0d
...@@ -148,12 +148,13 @@ static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status) ...@@ -148,12 +148,13 @@ static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
} }
static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
int proto, int version, int privileged) size_t salen, int proto, int version,
int privileged)
{ {
struct rpc_create_args args = { struct rpc_create_args args = {
.protocol = proto, .protocol = proto,
.address = srvaddr, .address = srvaddr,
.addrsize = sizeof(struct sockaddr_in), .addrsize = salen,
.servername = hostname, .servername = hostname,
.program = &rpcb_program, .program = &rpcb_program,
.version = version, .version = version,
...@@ -216,7 +217,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) ...@@ -216,7 +217,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
prog, vers, prot, port); prog, vers, prot, port);
rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin, rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin,
XPRT_TRANSPORT_UDP, 2, 1); sizeof(sin), XPRT_TRANSPORT_UDP, 2, 1);
if (IS_ERR(rpcb_clnt)) if (IS_ERR(rpcb_clnt))
return PTR_ERR(rpcb_clnt); return PTR_ERR(rpcb_clnt);
...@@ -265,7 +266,8 @@ int rpcb_getport_sync(struct sockaddr_in *sin, __u32 prog, ...@@ -265,7 +266,8 @@ int rpcb_getport_sync(struct sockaddr_in *sin, __u32 prog,
__FUNCTION__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); __FUNCTION__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
sprintf(hostname, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr)); sprintf(hostname, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin, prot, 2, 0); rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin,
sizeof(sin), prot, 2, 0);
if (IS_ERR(rpcb_clnt)) if (IS_ERR(rpcb_clnt))
return PTR_ERR(rpcb_clnt); return PTR_ERR(rpcb_clnt);
...@@ -314,7 +316,9 @@ void rpcb_getport_async(struct rpc_task *task) ...@@ -314,7 +316,9 @@ void rpcb_getport_async(struct rpc_task *task)
struct rpc_clnt *rpcb_clnt; struct rpc_clnt *rpcb_clnt;
static struct rpcbind_args *map; static struct rpcbind_args *map;
struct rpc_task *child; struct rpc_task *child;
struct sockaddr addr; struct sockaddr_storage addr;
struct sockaddr *sap = (struct sockaddr *)&addr;
size_t salen;
int status; int status;
struct rpcb_info *info; struct rpcb_info *info;
...@@ -344,10 +348,10 @@ void rpcb_getport_async(struct rpc_task *task) ...@@ -344,10 +348,10 @@ void rpcb_getport_async(struct rpc_task *task)
goto bailout_nofree; goto bailout_nofree;
} }
rpc_peeraddr(clnt, (void *)&addr, sizeof(addr)); salen = rpc_peeraddr(clnt, sap, sizeof(addr));
/* Don't ever use rpcbind v2 for AF_INET6 requests */ /* Don't ever use rpcbind v2 for AF_INET6 requests */
switch (addr.sa_family) { switch (sap->sa_family) {
case AF_INET: case AF_INET:
info = rpcb_next_version; info = rpcb_next_version;
break; break;
...@@ -372,7 +376,7 @@ void rpcb_getport_async(struct rpc_task *task) ...@@ -372,7 +376,7 @@ void rpcb_getport_async(struct rpc_task *task)
dprintk("RPC: %5u %s: trying rpcbind version %u\n", dprintk("RPC: %5u %s: trying rpcbind version %u\n",
task->tk_pid, __FUNCTION__, bind_version); task->tk_pid, __FUNCTION__, bind_version);
rpcb_clnt = rpcb_create(clnt->cl_server, &addr, xprt->prot, rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot,
bind_version, 0); bind_version, 0);
if (IS_ERR(rpcb_clnt)) { if (IS_ERR(rpcb_clnt)) {
status = PTR_ERR(rpcb_clnt); status = PTR_ERR(rpcb_clnt);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册