Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec...
[pandora-kernel.git] / include / net / xfrm.h
index 30f3e5b..24c8886 100644 (file)
@@ -1039,7 +1039,7 @@ static inline int
 __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
@@ -1250,8 +1250,8 @@ 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;
@@ -1582,17 +1582,23 @@ extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe);
 extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len,
                                                   int probe);
 
-static inline int xfrm_addr_cmp(const xfrm_address_t *a,
-                               const xfrm_address_t *b,
-                               int family)
+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 bool xfrm_addr_equal(const xfrm_address_t *a,
+                                  const xfrm_address_t *b,
+                                  sa_family_t family)
 {
        switch (family) {
        default:
        case AF_INET:
-               return (__force u32)a->a4 - (__force u32)b->a4;
+               return ((__force u32)a->a4 ^ (__force u32)b->a4) == 0;
        case AF_INET6:
-               return ipv6_addr_cmp((const struct in6_addr *)a,
-                                    (const struct in6_addr *)b);
+               return xfrm6_addr_equal(a, b);
        }
 }