xfrm: Use ipv6_addr_equal() where appropriate.
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Tue, 29 Jan 2013 12:48:31 +0000 (12:48 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Jan 2013 03:58:40 +0000 (22:58 -0500)
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h
net/ipv6/xfrm6_tunnel.c

index 421f764794d59f5100ef3fe26190554a2e8a00c0..0d8a797f04413279e996a8bdc25a73cbef88cca8 100644 (file)
@@ -1032,7 +1032,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
@@ -1243,8 +1243,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;
@@ -1588,6 +1588,13 @@ static inline int xfrm_addr_cmp(const xfrm_address_t *a,
        }
 }
 
+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;
index babd1674388a962b86c63fce58a79bdd7f27b522..6cc48012b7309d2cd90db0f415f1543f3676f91b 100644 (file)
@@ -94,7 +94,7 @@ static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, const
        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;
        }
 
@@ -211,7 +211,7 @@ static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr)
                                  &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);