* [PATCH] xfrm: optimise to search the inexact policy list
@ 2015-05-14 3:16 rongqing.li
2015-05-19 11:14 ` Steffen Klassert
0 siblings, 1 reply; 2+ messages in thread
From: rongqing.li @ 2015-05-14 3:16 UTC (permalink / raw)
To: netdev, steffen.klassert
From: Li RongQing <roy.qing.li@gmail.com>
The policies are organized into list by priority ascent of policy,
so it is unnecessary to continue to loop the policy if the priority
of current looped police is larger than or equal priority which is
from the policy_bydst list.
This allows to match policy with ~0U priority in inexact list too.
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
net/xfrm/xfrm_policy.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 3d264e5..18cead7 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1114,6 +1114,9 @@ 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) && ret)
+ break;
+
err = xfrm_policy_match(pol, fl, type, family, dir);
if (err) {
if (err == -ESRCH)
@@ -1122,7 +1125,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;
}
@@ -3203,9 +3206,11 @@ static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector *
}
chain = &net->xfrm.policy_inexact[dir];
hlist_for_each_entry(pol, chain, bydst) {
+ if ((pol->priority >= priority) && ret)
+ break;
+
if (xfrm_migrate_selector_match(sel, &pol->selector) &&
- pol->type == type &&
- pol->priority < priority) {
+ pol->type == type) {
ret = pol;
break;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfrm: optimise to search the inexact policy list
2015-05-14 3:16 [PATCH] xfrm: optimise to search the inexact policy list rongqing.li
@ 2015-05-19 11:14 ` Steffen Klassert
0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2015-05-19 11:14 UTC (permalink / raw)
To: rongqing.li; +Cc: netdev
On Thu, May 14, 2015 at 11:16:59AM +0800, rongqing.li@windriver.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
>
> The policies are organized into list by priority ascent of policy,
> so it is unnecessary to continue to loop the policy if the priority
> of current looped police is larger than or equal priority which is
> from the policy_bydst list.
>
> This allows to match policy with ~0U priority in inexact list too.
>
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Applied to ipsec-next, thanks a lot!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-19 11:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-14 3:16 [PATCH] xfrm: optimise to search the inexact policy list rongqing.li
2015-05-19 11:14 ` 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).