diff options
author | YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> | 2013-01-20 02:38:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-20 22:29:49 -0500 |
commit | d1641565f6926c2e9f5859d81bc6f72fc0e1ad76 (patch) | |
tree | fa5f134b9f5faa2413c439019918d0020742c685 /include/net | |
parent | 9d1007740041613bae8492be092932a3f0eb1ebf (diff) |
ipv6: Optimize ipv6_addr_is_ll_all_{nodes,routers}().
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/addrconf.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 9dc5efc3b0d6..6c58d507123f 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -288,16 +288,26 @@ static inline bool ipv6_addr_is_multicast(const struct in6_addr *addr) | |||
288 | 288 | ||
289 | static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) | 289 | static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) |
290 | { | 290 | { |
291 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
292 | __u64 *p = (__u64 *)addr; | ||
293 | return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) | (p[1] ^ cpu_to_be64(1))) == 0UL; | ||
294 | #else | ||
291 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 295 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
292 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 296 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
293 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0; | 297 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0; |
298 | #endif | ||
294 | } | 299 | } |
295 | 300 | ||
296 | static inline bool ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) | 301 | static inline bool ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) |
297 | { | 302 | { |
303 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
304 | __u64 *p = (__u64 *)addr; | ||
305 | return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) | (p[1] ^ cpu_to_be64(2))) == 0UL; | ||
306 | #else | ||
298 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 307 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
299 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 308 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
300 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0; | 309 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0; |
310 | #endif | ||
301 | } | 311 | } |
302 | 312 | ||
303 | static inline bool ipv6_addr_is_isatap(const struct in6_addr *addr) | 313 | static inline bool ipv6_addr_is_isatap(const struct in6_addr *addr) |