summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>2013-01-14 07:10:38 +0000
committerDavid S. Miller <davem@davemloft.net>2013-01-14 13:17:01 -0500
commit38675170e4235f859bb85564c33ffa077a1c1ef7 (patch)
tree5a2395aea57f6c500b2107d0ea1306c8ec660ba9 /include
parent2ef973320349cd536b33427aed98512e532d4cc6 (diff)
ipv6: 64bit version of ipv6_prefix_equal().
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/ipv6.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index fe95053d02c..dfc1363a97b 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -399,6 +399,31 @@ static inline bool ipv6_addr_equal(const struct in6_addr *a1,
#endif
}
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+static inline bool __ipv6_prefix_equal64_half(const __be64 *a1,
+ const __be64 *a2,
+ unsigned int len)
+{
+ if (len && ((*a1 ^ *a2) & cpu_to_be64(~0UL) << (64 - len)))
+ return false;
+ return true;
+}
+
+static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
+ const struct in6_addr *addr2,
+ unsigned int prefixlen)
+{
+ const __be64 *a1 = (const __be64 *)addr1;
+ const __be64 *a2 = (const __be64 *)addr2;
+
+ if (prefixlen >= 64) {
+ if (a1[0] ^ a2[0])
+ return false;
+ return __ipv6_prefix_equal64_half(a1 + 1, a2 + 1, prefixlen - 64);
+ }
+ return __ipv6_prefix_equal64_half(a1, a2, prefixlen);
+}
+#else
static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
const struct in6_addr *addr2,
unsigned int prefixlen)
@@ -419,6 +444,7 @@ static inline bool ipv6_prefix_equal(const struct in6_addr *addr1,
return true;
}
+#endif
struct inet_frag_queue;