2010-11-01 19:58:29

by Chuck Lever III

[permalink] [raw]
Subject: [PATCH] SUNRPC: Initialize source address if passed-in srcaddr is AF_UNSPEC

Recently xs_bind() was changed so it can't tolerate an AF_UNSPEC
bind address; it needs a fully initialized ANYADDR. We recently fixed
this case in xprtsock.c, but some upper layer protocols seem to assume
that it's OK to pass in an AF_UNSPEC address for the source address.
Catch that case too.

Signed-off-by: Chuck Lever <[email protected]>
---

Untested.

net/sunrpc/xprtsock.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index dfcab5a..fd6484b 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2181,7 +2181,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,
new = container_of(xprt, struct sock_xprt, xprt);
memcpy(&xprt->addr, args->dstaddr, args->addrlen);
xprt->addrlen = args->addrlen;
- if (args->srcaddr)
+ if (args->srcaddr && args->srcaddr->sa_family != AF_UNSPEC)
memcpy(&new->srcaddr, args->srcaddr, args->addrlen);
else {
int err;


2010-11-01 20:31:38

by Nick Bowler

[permalink] [raw]
Subject: Re: [PATCH] SUNRPC: Initialize source address if passed-in srcaddr is AF_UNSPEC

On 2010-11-01 15:58 -0400, Chuck Lever wrote:
> Recently xs_bind() was changed so it can't tolerate an AF_UNSPEC
> bind address; it needs a fully initialized ANYADDR. We recently fixed
> this case in xprtsock.c, but some upper layer protocols seem to assume
> that it's OK to pass in an AF_UNSPEC address for the source address.
> Catch that case too.
>
> Signed-off-by: Chuck Lever <[email protected]>
> ---
>
> Untested.

This one seems to correct the issue.

Tested-by: Nick Bowler <[email protected]>

--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)