Commit bc9b35ad authored by David S. Miller's avatar David S. Miller
Browse files

xfrm: Convert several xfrm policy match functions to bool.



xfrm_selector_match
xfrm_sec_ctx_match
__xfrm4_selector_match
__xfrm6_selector_match

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e87cc472
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -886,7 +886,7 @@ __be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
	return port;
}

extern int xfrm_selector_match(const struct xfrm_selector *sel,
extern bool xfrm_selector_match(const struct xfrm_selector *sel,
				const struct flowi *fl,
				unsigned short family);

@@ -894,7 +894,7 @@ extern int xfrm_selector_match(const struct xfrm_selector *sel,
/*	If neither has a context --> match
 * 	Otherwise, both must have a context and the sids, doi, alg must match
 */
static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2)
static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2)
{
	return ((!s1 && !s2) ||
		(s1 && s2 &&
@@ -903,9 +903,9 @@ static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ct
		 (s1->ctx_alg == s2->ctx_alg)));
}
#else
static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2)
static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2)
{
	return 1;
	return true;
}
#endif

+14 −13
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *xdst);
static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
						int dir);

static inline int
static inline bool
__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
{
	const struct flowi4 *fl4 = &fl->u.ip4;
@@ -69,7 +69,7 @@ __xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
		(fl4->flowi4_oif == sel->ifindex || !sel->ifindex);
}

static inline int
static inline bool
__xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
{
	const struct flowi6 *fl6 = &fl->u.ip6;
@@ -82,7 +82,7 @@ __xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
		(fl6->flowi6_oif == sel->ifindex || !sel->ifindex);
}

int xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
bool xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
			 unsigned short family)
{
	switch (family) {
@@ -91,7 +91,7 @@ int xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
	case AF_INET6:
		return __xfrm6_selector_match(sel, fl);
	}
	return 0;
	return false;
}

static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos,
@@ -877,7 +877,8 @@ static int xfrm_policy_match(const struct xfrm_policy *pol,
			     u8 type, u16 family, int dir)
{
	const struct xfrm_selector *sel = &pol->selector;
	int match, ret = -ESRCH;
	int ret = -ESRCH;
	bool match;

	if (pol->family != family ||
	    (fl->flowi_mark & pol->mark.m) != pol->mark.v ||
@@ -1006,7 +1007,7 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir,

	read_lock_bh(&xfrm_policy_lock);
	if ((pol = sk->sk_policy[dir]) != NULL) {
		int match = xfrm_selector_match(&pol->selector, fl,
		bool match = xfrm_selector_match(&pol->selector, fl,
						 sk->sk_family);
		int err = 0;

@@ -2767,7 +2768,7 @@ EXPORT_SYMBOL_GPL(xfrm_audit_policy_delete);
#endif

#ifdef CONFIG_XFRM_MIGRATE
static int xfrm_migrate_selector_match(const struct xfrm_selector *sel_cmp,
static bool xfrm_migrate_selector_match(const struct xfrm_selector *sel_cmp,
					const struct xfrm_selector *sel_tgt)
{
	if (sel_cmp->proto == IPSEC_ULPROTO_ANY) {
@@ -2778,14 +2779,14 @@ static int xfrm_migrate_selector_match(const struct xfrm_selector *sel_cmp,
				  sel_cmp->family) == 0 &&
		    sel_tgt->prefixlen_d == sel_cmp->prefixlen_d &&
		    sel_tgt->prefixlen_s == sel_cmp->prefixlen_s) {
			return 1;
			return true;
		}
	} else {
		if (memcmp(sel_tgt, sel_cmp, sizeof(*sel_tgt)) == 0) {
			return 1;
			return true;
		}
	}
	return 0;
	return false;
}

static struct xfrm_policy * xfrm_migrate_policy_find(const struct xfrm_selector *sel,