xfrm: Convert xfrm_addr_cmp() to boolean xfrm_addr_equal().

All users of xfrm_addr_cmp() use its result as boolean.
Introduce xfrm_addr_equal() (which is equal to !xfrm_addr_cmp())
and convert all users.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
YOSHIFUJI Hideaki / 吉藤英明
2013-01-29 12:48:50 +00:00
committed by David S. Miller
parent ff88b30c71
commit 70e94e66ae
5 changed files with 47 additions and 48 deletions

View File

@@ -1574,20 +1574,6 @@ 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)
{
switch (family) {
default:
case AF_INET:
return (__force u32)a->a4 - (__force u32)b->a4;
case AF_INET6:
return ipv6_addr_cmp((const struct in6_addr *)a,
(const struct in6_addr *)b);
}
}
static inline bool xfrm6_addr_equal(const xfrm_address_t *a,
const xfrm_address_t *b)
{
@@ -1595,6 +1581,19 @@ static inline bool xfrm6_addr_equal(const xfrm_address_t *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) == 0;
case AF_INET6:
return xfrm6_addr_equal(a, b);
}
}
static inline int xfrm_policy_id2dir(u32 index)
{
return index & 7;