From fed85383ac34d82e96f227ce49ce68117cec23a0 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Fri, 11 Apr 2008 20:17:55 +0900 Subject: [IPV6]: Use XOR and OR rather than mutiple ands for ipv6 address comparisons. ipv6_addr_equal(), ipv6_addr_v4mapped(), ipv6_addr_is_ll_all_{nodes,routers}(), ipv6_masked_addr_cmp() Signed-off-by: YOSHIFUJI Hideaki --- include/net/addrconf.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'include/net/addrconf.h') diff --git a/include/net/addrconf.h b/include/net/addrconf.h index bdcc863a60a..1dc9d03372d 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -240,18 +240,16 @@ static inline int ipv6_addr_is_multicast(const struct in6_addr *addr) static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) { - return (addr->s6_addr32[0] == htonl(0xff020000) && - addr->s6_addr32[1] == 0 && - addr->s6_addr32[2] == 0 && - addr->s6_addr32[3] == htonl(0x00000001)); + return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | + addr->s6_addr32[1] | addr->s6_addr32[2] | + (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0); } static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) { - return (addr->s6_addr32[0] == htonl(0xff020000) && - addr->s6_addr32[1] == 0 && - addr->s6_addr32[2] == 0 && - addr->s6_addr32[3] == htonl(0x00000002)); + return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | + addr->s6_addr32[1] | addr->s6_addr32[2] | + (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0); } static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr) -- cgit v1.2.3