From 6c797982e0d290263172caff3585ef2671b63cb3 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 25 Aug 2006 15:46:46 -0700 Subject: [PATCH] --- yaml --- r: 34623 b: refs/heads/master c: acba48e1a3c95082af1e12c5efaaca3506103a92 h: refs/heads/master i: 34621: 811a122ce630d9f74f091abb5610430e36e487b1 34619: ed9f6e45a4ae1f3dd47bb8ae57ce6a7a983bd685 34615: cb8bf0721fef931a38597e6bd9d9f8210ea6912d 34607: acf59ce8ed65ccca906e5071ca38c2e005587fa9 34591: 4095a9bcdf00bca785b193b518180d51b4cab5f0 34559: e8c2e9dbd4e893fd0f9ec1d95def53dc22e827bc v: v3 --- [refs] | 2 +- trunk/net/xfrm/xfrm_policy.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 676e39694bcb..4f5e5177c31f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 65e3d72654d9a33cdccd5c19777a5515ae9dd37d +refs/heads/master: acba48e1a3c95082af1e12c5efaaca3506103a92 diff --git a/trunk/net/xfrm/xfrm_policy.c b/trunk/net/xfrm/xfrm_policy.c index b446ca31fecc..1cf3209cdf4b 100644 --- a/trunk/net/xfrm/xfrm_policy.c +++ b/trunk/net/xfrm/xfrm_policy.c @@ -908,6 +908,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl, xfrm_address_t *daddr, *saddr; struct hlist_node *entry; struct hlist_head *chain; + u32 priority = ~0U; daddr = xfrm_flowi_daddr(fl, family); saddr = xfrm_flowi_saddr(fl, family); @@ -919,21 +920,21 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(u8 type, struct flowi *fl, ret = NULL; hlist_for_each_entry(pol, entry, chain, bydst) { if (xfrm_policy_match(pol, fl, type, family, dir)) { - xfrm_pol_hold(pol); ret = pol; + priority = ret->priority; break; } } - if (!ret) { - chain = &xfrm_policy_inexact[dir]; - hlist_for_each_entry(pol, entry, chain, bydst) { - if (xfrm_policy_match(pol, fl, type, family, dir)) { - xfrm_pol_hold(pol); - ret = pol; - break; - } + chain = &xfrm_policy_inexact[dir]; + hlist_for_each_entry(pol, entry, chain, bydst) { + if (xfrm_policy_match(pol, fl, type, family, dir) && + pol->priority < priority) { + ret = pol; + break; } } + if (ret) + xfrm_pol_hold(ret); read_unlock_bh(&xfrm_policy_lock); return ret;