Skip to contentSkip to conversation

SUNRPC: compare scopeid for link-local addresses

PATCH In review Mi Jinlong 4 participants 6 messages Aug 30, 2011 – Sep 14, 2011

Subsystems (2)
lore
Share & tools
lore

Mi Jinlong

author
#0 lore raw

PATCH 2/2 SUNRPC: compare scopeid for link-local addresses

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

---
 include/linux/sunrpc/clnt.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +7 -1
index db7bcaf..ee1bb67 100644
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,
Signature · 1 line
1.7.6
Reviewed-by on v1 2/2
#1 lore raw
Quoted 4 lines · On Tue, 30 Aug 2011 17:22:49 +0800 Mi Jinlong <[email protected]> wrote:

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

Reviewed-by:

Quoted 13 lines
---
 include/linux/sunrpc/clnt.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +0 -1
index db7bcaf..ee1bb67 100644
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);

include/linux/sunrpc/clnt.h static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, · line 230

Quoted 10 lines
include/linux/sunrpc/clnt.h +7 -0
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,
#2 lore raw
In reply to Mi Jinlong
Quoted 13 lines · Mi Jinlong

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

---
include/linux/sunrpc/clnt.h | 8 +++++++-

1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +0 -0
index db7bcaf..ee1bb67 100644

include/linux/sunrpc/clnt.h static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, · line 225

Quoted 9 lines
include/linux/sunrpc/clnt.h +5 -1
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;

Thanks for splitting the patches.

The address comparators I've seen check that both addresses are link-local before comparing the scope IDs. I don't think we can assume the kind of source-destination address relationship we have in parts of the RPC server code.

Quoted 9 lines
include/linux/sunrpc/clnt.h +2 -0
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,
Signature · 1 line
1.7.6
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Reviewed-by
#3 lore raw
Quoted 28 lines · Chuck Lever
Quoted 13 lines · Mi Jinlong

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

---
include/linux/sunrpc/clnt.h | 8 +++++++-

1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +0 -0
index db7bcaf..ee1bb67 100644

include/linux/sunrpc/clnt.h static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, · line 225

Quoted 9 lines
include/linux/sunrpc/clnt.h +5 -1
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;

Thanks for splitting the patches.

Quoted 1 line

The address comparators I've seen check that both addresses are link-local before comparing the scope IDs. I don't think we can assume the kind of source-destination address relationship we have in parts of the RPC server code.

Jeff points out that you've already tested that the addresses are equal. So, never mind.

Quoted 22 lines
Quoted 10 lines
include/linux/sunrpc/clnt.h +2 -0
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,
Signature · 1 line
1.7.6
Signature · 10 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com




--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
author
#4 lore raw
In reply to Mi Jinlong

Hi guys:

What's the situation about those two paths?

thanks,
Mi Jinlong

Mi Jinlong:

Quoted 27 lines

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

---
 include/linux/sunrpc/clnt.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +7 -1
index db7bcaf..ee1bb67 100644
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,
#5 lore raw
Quoted 3 lines · Mi Jinlong

Hi guys:

What's the situation about those two paths?

Apologies for the delay; both look reasonable to me, thanks. Applying for 3.2. (May be a few days before I push it out to my public tree.)

--b.

Quoted 34 lines

thanks,
Mi Jinlong

Mi Jinlong:

Quoted 27 lines

For ipv6 link-local addresses, sunrpc do not compare those scope id. This patch let sunrpc compares scope id only on link-local addresses.

---
 include/linux/sunrpc/clnt.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +7 -1
index db7bcaf..ee1bb67 100644
@@ -218,7 +218,13 @@ static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
 {
 	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
 	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
-	return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
+
+	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
+		return false;
+	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+		return sin1->sin6_scope_id == sin2->sin6_scope_id;
+
+	return true;
 }
 
 static inline bool __rpc_copy_addr6(struct sockaddr *dst,