linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfs: fix bug about IPv6 address scope checking
@ 2011-10-12  7:09 Mi Jinlong
  2011-10-12 14:39 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Mi Jinlong @ 2011-10-12  7:09 UTC (permalink / raw)
  To: NFS; +Cc: Trond Myklebust, J. Bruce Fields, Chuck Lever

The result from ipv6_addr_scope() always not be a single SCOPE,
so we can't use equal to compare the result with IPV6_ADDR_SCOPE_LINKLOCAL
at nfs_sockaddr_match_ipaddr6.

This patch fixs the problem, and lets checking address before scope_id.

Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
---
 fs/nfs/client.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5833fbb..b4e41dd 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -336,11 +336,12 @@ static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
 
-	if (ipv6_addr_scope(&sin1->sin6_addr) == IPV6_ADDR_SCOPE_LINKLOCAL &&
-	    sin1->sin6_scope_id != sin2->sin6_scope_id)
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
 		return 0;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;
 
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+	return 1;
 }
 #else	/* !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) */
 static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
-- 
1.7.6




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfs: fix bug about IPv6 address scope checking
  2011-10-12  7:09 [PATCH] nfs: fix bug about IPv6 address scope checking Mi Jinlong
@ 2011-10-12 14:39 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2011-10-12 14:39 UTC (permalink / raw)
  To: Mi Jinlong; +Cc: NFS, Trond Myklebust, Chuck Lever

On Wed, Oct 12, 2011 at 03:09:34PM +0800, Mi Jinlong wrote:
> The result from ipv6_addr_scope() always not be a single SCOPE,
> so we can't use equal to compare the result with IPV6_ADDR_SCOPE_LINKLOCAL
> at nfs_sockaddr_match_ipaddr6.
> 
> This patch fixs the problem, and lets checking address before scope_id.

Looks right to me, thanks; committing unless someone else catches a
problem.

--b.

> 
> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
> ---
>  fs/nfs/client.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfs/client.c b/fs/nfs/client.c
> index 5833fbb..b4e41dd 100644
> --- a/fs/nfs/client.c
> +++ b/fs/nfs/client.c
> @@ -336,11 +336,12 @@ static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
>  	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
>  	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
>  
> -	if (ipv6_addr_scope(&sin1->sin6_addr) == IPV6_ADDR_SCOPE_LINKLOCAL &&
> -	    sin1->sin6_scope_id != sin2->sin6_scope_id)
> +	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
>  		return 0;
> +	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
> +		return sin1->sin6_scope_id == sin2->sin6_scope_id;
>  
> -	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
> +	return 1;
>  }
>  #else	/* !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) */
>  static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1,
> -- 
> 1.7.6
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-12 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12  7:09 [PATCH] nfs: fix bug about IPv6 address scope checking Mi Jinlong
2011-10-12 14:39 ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).