mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
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: David S. Miller <davem@davemloft.net> Change-Id: I0cb9bc9e9f5689edc4ee73b6a9d838a89ea5a5de
This commit is contained in:
parent
a664edd900
commit
d91c40e298
2 changed files with 20 additions and 19 deletions
|
@ -897,15 +897,15 @@ __be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
|
||||||
return port;
|
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,
|
const struct flowi *fl,
|
||||||
unsigned short family);
|
unsigned short family);
|
||||||
|
|
||||||
#ifdef CONFIG_SECURITY_NETWORK_XFRM
|
#ifdef CONFIG_SECURITY_NETWORK_XFRM
|
||||||
/* If neither has a context --> match
|
/* If neither has a context --> match
|
||||||
* Otherwise, both must have a context and the sids, doi, alg must 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) ||
|
return ((!s1 && !s2) ||
|
||||||
(s1 && s2 &&
|
(s1 && s2 &&
|
||||||
|
@ -914,9 +914,9 @@ static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ct
|
||||||
(s1->ctx_alg == s2->ctx_alg)));
|
(s1->ctx_alg == s2->ctx_alg)));
|
||||||
}
|
}
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void xfrm_policy_queue_process(unsigned long arg);
|
||||||
static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
|
static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
|
||||||
int dir);
|
int dir);
|
||||||
|
|
||||||
static inline int
|
static inline bool
|
||||||
__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
|
__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
|
||||||
{
|
{
|
||||||
const struct flowi4 *fl4 = &fl->u.ip4;
|
const struct flowi4 *fl4 = &fl->u.ip4;
|
||||||
|
@ -73,7 +73,7 @@ __xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
|
||||||
(fl4->flowi4_oif == sel->ifindex || !sel->ifindex);
|
(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)
|
__xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
|
||||||
{
|
{
|
||||||
const struct flowi6 *fl6 = &fl->u.ip6;
|
const struct flowi6 *fl6 = &fl->u.ip6;
|
||||||
|
@ -86,8 +86,8 @@ __xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
|
||||||
(fl6->flowi6_oif == sel->ifindex || !sel->ifindex);
|
(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)
|
unsigned short family)
|
||||||
{
|
{
|
||||||
switch (family) {
|
switch (family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -95,7 +95,7 @@ int xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return __xfrm6_selector_match(sel, fl);
|
return __xfrm6_selector_match(sel, fl);
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos,
|
static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos,
|
||||||
|
@ -938,7 +938,8 @@ static int xfrm_policy_match(const struct xfrm_policy *pol,
|
||||||
u8 type, u16 family, int dir)
|
u8 type, u16 family, int dir)
|
||||||
{
|
{
|
||||||
const struct xfrm_selector *sel = &pol->selector;
|
const struct xfrm_selector *sel = &pol->selector;
|
||||||
int match, ret = -ESRCH;
|
int ret = -ESRCH;
|
||||||
|
bool match;
|
||||||
|
|
||||||
if (pol->family != family ||
|
if (pol->family != family ||
|
||||||
(fl->flowi_mark & pol->mark.m) != pol->mark.v ||
|
(fl->flowi_mark & pol->mark.m) != pol->mark.v ||
|
||||||
|
@ -1085,8 +1086,8 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir,
|
||||||
|
|
||||||
read_lock_bh(&xfrm_policy_lock);
|
read_lock_bh(&xfrm_policy_lock);
|
||||||
if ((pol = sk->sk_policy[dir]) != NULL) {
|
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);
|
sk->sk_family);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -3026,8 +3027,8 @@ EXPORT_SYMBOL_GPL(xfrm_audit_policy_delete);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_XFRM_MIGRATE
|
#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)
|
const struct xfrm_selector *sel_tgt)
|
||||||
{
|
{
|
||||||
if (sel_cmp->proto == IPSEC_ULPROTO_ANY) {
|
if (sel_cmp->proto == IPSEC_ULPROTO_ANY) {
|
||||||
if (sel_tgt->family == sel_cmp->family &&
|
if (sel_tgt->family == sel_cmp->family &&
|
||||||
|
@ -3037,14 +3038,14 @@ static int xfrm_migrate_selector_match(const struct xfrm_selector *sel_cmp,
|
||||||
sel_cmp->family) &&
|
sel_cmp->family) &&
|
||||||
sel_tgt->prefixlen_d == sel_cmp->prefixlen_d &&
|
sel_tgt->prefixlen_d == sel_cmp->prefixlen_d &&
|
||||||
sel_tgt->prefixlen_s == sel_cmp->prefixlen_s) {
|
sel_tgt->prefixlen_s == sel_cmp->prefixlen_s) {
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (memcmp(sel_tgt, sel_cmp, sizeof(*sel_tgt)) == 0) {
|
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,
|
static struct xfrm_policy * xfrm_migrate_policy_find(const struct xfrm_selector *sel,
|
||||||
|
|
Loading…
Reference in a new issue