__xfrm6_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x)
 {
        return  (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) &&
-                ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr));
+                !ipv6_addr_equal((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr));
 }
 
 static inline int
 __xfrm6_state_addr_check(const struct xfrm_state *x,
                         const xfrm_address_t *daddr, const xfrm_address_t *saddr)
 {
-       if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) &&
-           (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)|| 
+       if (ipv6_addr_equal((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) &&
+           (ipv6_addr_equal((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr) ||
             ipv6_addr_any((struct in6_addr *)saddr) || 
             ipv6_addr_any((struct in6_addr *)&x->props.saddr)))
                return 1;
        }
 }
 
+static inline bool xfrm6_addr_equal(const xfrm_address_t *a,
+                                   const xfrm_address_t *b)
+{
+       return ipv6_addr_equal((const struct in6_addr *)a,
+                              (const struct in6_addr *)b);
+}
+
 static inline int xfrm_policy_id2dir(u32 index)
 {
        return index & 7;
 
        hlist_for_each_entry_rcu(x6spi, pos,
                             &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
                             list_byaddr) {
-               if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0)
+               if (xfrm6_addr_equal(&x6spi->addr, saddr))
                        return x6spi;
        }
 
                                  &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
                                  list_byaddr)
        {
-               if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0) {
+               if (xfrm6_addr_equal(&x6spi->addr, saddr)) {
                        if (atomic_dec_and_test(&x6spi->refcnt)) {
                                hlist_del_rcu(&x6spi->list_byaddr);
                                hlist_del_rcu(&x6spi->list_byspi);