netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] xfrm: optimise xfrm_policy_lookup_bytype
@ 2015-05-09 11:17 roy.qing.li
  2015-05-11 12:06 ` Steffen Klassert
  0 siblings, 1 reply; 4+ messages in thread
From: roy.qing.li @ 2015-05-09 11:17 UTC (permalink / raw)
  To: netdev; +Cc: steffen.klassert

From: Li RongQing <roy.qing.li@gmail.com>

It is unnecessary to continue to loop the policy if the priority
of current looped police is larger than priority which is from
the policy_bydst list.

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 net/xfrm/xfrm_policy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 66450c3..4adee12 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1116,6 +1116,8 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
 	}
 	chain = &net->xfrm.policy_inexact[dir];
 	hlist_for_each_entry(pol, chain, bydst) {
+		if (pol->priority >= priority)
+			break;
 		err = xfrm_policy_match(pol, fl, type, family, dir);
 		if (err) {
 			if (err == -ESRCH)
@@ -1124,7 +1126,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
 				ret = ERR_PTR(err);
 				goto fail;
 			}
-		} else if (pol->priority < priority) {
+		} else {
 			ret = pol;
 			break;
 		}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-12 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-09 11:17 [PATCH][next] xfrm: optimise xfrm_policy_lookup_bytype roy.qing.li
2015-05-11 12:06 ` Steffen Klassert
2015-05-12  8:25   ` Li RongQing
2015-05-12 11:37     ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).