* pull request (net-next): ipsec-next 2015-05-28
@ 2015-05-28 6:25 Steffen Klassert
2015-05-28 6:25 ` [PATCH 1/7] xfrm: remove the xfrm_queue_purge definition Steffen Klassert
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
1) Remove xfrm_queue_purge as this is the same as skb_queue_purge.
2) Optimize policy and state walk.
3) Use a sane return code if afinfo registration fails.
4) Only check fori a acquire state if the state is not valid.
5) Remove a unnecessary NULL check before xfrm_pol_hold
as it checks the input for NULL.
6) Return directly if the xfrm hold queue is empty, avoid
to take a lock as it is nothing to do in this case.
7) Optimize the inexact policy search and allow for matching
of policies with priority ~0U.
All from Li RongQing.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit 04b7fe6a4a231871ef681bc95e08fe66992f7b1f:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide (2015-04-17 16:36:59 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master
for you to fetch changes up to 8faf491e642011f449d6405be52bedb70964aed6:
xfrm: optimise to search the inexact policy list (2015-05-18 10:31:56 +0200)
----------------------------------------------------------------
Li RongQing (7):
xfrm: remove the xfrm_queue_purge definition
xfrm: optimise the use of walk list header in xfrm_policy/state_walk
xfrm: fix the return code when xfrm_*_register_afinfo failed
xfrm: slightly optimise xfrm_input
xfrm: remove the unnecessary checking before call xfrm_pol_hold
xfrm: move the checking for old xfrm_policy hold_queue to beginning
xfrm: optimise to search the inexact policy list
net/xfrm/xfrm_input.c | 12 ++++++------
net/xfrm/xfrm_policy.c | 42 ++++++++++++++++++++----------------------
net/xfrm/xfrm_state.c | 4 ++--
3 files changed, 28 insertions(+), 30 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/7] xfrm: remove the xfrm_queue_purge definition
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 2/7] xfrm: optimise the use of walk list header in xfrm_policy/state_walk Steffen Klassert
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
The task of xfrm_queue_purge is same as skb_queue_purge, so remove it
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_policy.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 638af06..d8c35ad 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -315,14 +315,6 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
}
EXPORT_SYMBOL(xfrm_policy_destroy);
-static void xfrm_queue_purge(struct sk_buff_head *list)
-{
- struct sk_buff *skb;
-
- while ((skb = skb_dequeue(list)) != NULL)
- kfree_skb(skb);
-}
-
/* Rule must be locked. Release descentant resources, announce
* entry dead. The rule must be unlinked from lists to the moment.
*/
@@ -335,7 +327,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
if (del_timer(&policy->polq.hold_timer))
xfrm_pol_put(policy);
- xfrm_queue_purge(&policy->polq.hold_queue);
+ skb_queue_purge(&policy->polq.hold_queue);
if (del_timer(&policy->timer))
xfrm_pol_put(policy);
@@ -1955,7 +1947,7 @@ out:
purge_queue:
pq->timeout = 0;
- xfrm_queue_purge(&pq->hold_queue);
+ skb_queue_purge(&pq->hold_queue);
xfrm_pol_put(pol);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/7] xfrm: optimise the use of walk list header in xfrm_policy/state_walk
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
2015-05-28 6:25 ` [PATCH 1/7] xfrm: remove the xfrm_queue_purge definition Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 3/7] xfrm: fix the return code when xfrm_*_register_afinfo failed Steffen Klassert
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
The walk from input is the list header, and marked as dead, and will
be skipped in loop.
list_first_entry() can be used to return the true usable value from
walk if walk is not empty
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_policy.c | 4 +++-
net/xfrm/xfrm_state.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index d8c35ad..847053e 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1004,7 +1004,9 @@ int xfrm_policy_walk(struct net *net, struct xfrm_policy_walk *walk,
if (list_empty(&walk->walk.all))
x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all);
else
- x = list_entry(&walk->walk.all, struct xfrm_policy_walk_entry, all);
+ x = list_first_entry(&walk->walk.all,
+ struct xfrm_policy_walk_entry, all);
+
list_for_each_entry_from(x, &net->xfrm.policy_all, all) {
if (x->dead)
continue;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index f5e39e3..df93183 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1626,7 +1626,7 @@ int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk,
if (list_empty(&walk->all))
x = list_first_entry(&net->xfrm.state_all, struct xfrm_state_walk, all);
else
- x = list_entry(&walk->all, struct xfrm_state_walk, all);
+ x = list_first_entry(&walk->all, struct xfrm_state_walk, all);
list_for_each_entry_from(x, &net->xfrm.state_all, all) {
if (x->state == XFRM_STATE_DEAD)
continue;
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] xfrm: fix the return code when xfrm_*_register_afinfo failed
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
2015-05-28 6:25 ` [PATCH 1/7] xfrm: remove the xfrm_queue_purge definition Steffen Klassert
2015-05-28 6:25 ` [PATCH 2/7] xfrm: optimise the use of walk list header in xfrm_policy/state_walk Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 4/7] xfrm: slightly optimise xfrm_input Steffen Klassert
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
If xfrm_*_register_afinfo failed since xfrm_*_afinfo[afinfo->family] had the
value, return the -EEXIST, not -ENOBUFS
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_input.c | 2 +-
net/xfrm/xfrm_policy.c | 2 +-
net/xfrm/xfrm_state.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 526c4fe..459796a 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -29,7 +29,7 @@ int xfrm_input_register_afinfo(struct xfrm_input_afinfo *afinfo)
return -EAFNOSUPPORT;
spin_lock_bh(&xfrm_input_afinfo_lock);
if (unlikely(xfrm_input_afinfo[afinfo->family] != NULL))
- err = -ENOBUFS;
+ err = -EEXIST;
else
rcu_assign_pointer(xfrm_input_afinfo[afinfo->family], afinfo);
spin_unlock_bh(&xfrm_input_afinfo_lock);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 847053e..c4c47f3 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2808,7 +2808,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
return -EAFNOSUPPORT;
spin_lock(&xfrm_policy_afinfo_lock);
if (unlikely(xfrm_policy_afinfo[afinfo->family] != NULL))
- err = -ENOBUFS;
+ err = -EEXIST;
else {
struct dst_ops *dst_ops = afinfo->dst_ops;
if (likely(dst_ops->kmem_cachep == NULL))
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index df93183..e47e498 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1908,7 +1908,7 @@ int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo)
return -EAFNOSUPPORT;
spin_lock_bh(&xfrm_state_afinfo_lock);
if (unlikely(xfrm_state_afinfo[afinfo->family] != NULL))
- err = -ENOBUFS;
+ err = -EEXIST;
else
rcu_assign_pointer(xfrm_state_afinfo[afinfo->family], afinfo);
spin_unlock_bh(&xfrm_state_afinfo_lock);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] xfrm: slightly optimise xfrm_input
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
` (2 preceding siblings ...)
2015-05-28 6:25 ` [PATCH 3/7] xfrm: fix the return code when xfrm_*_register_afinfo failed Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 5/7] xfrm: remove the unnecessary checking before call xfrm_pol_hold Steffen Klassert
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
Check x->km.state with XFRM_STATE_ACQ only when state is not
XFRM_STAT_VALID, not everytime
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_input.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 459796a..1858a45f 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -239,13 +239,13 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
skb->sp->xvec[skb->sp->len++] = x;
spin_lock(&x->lock);
- if (unlikely(x->km.state == XFRM_STATE_ACQ)) {
- XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
- goto drop_unlock;
- }
if (unlikely(x->km.state != XFRM_STATE_VALID)) {
- XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEINVALID);
+ if (x->km.state == XFRM_STATE_ACQ)
+ XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
+ else
+ XFRM_INC_STATS(net,
+ LINUX_MIB_XFRMINSTATEINVALID);
goto drop_unlock;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] xfrm: remove the unnecessary checking before call xfrm_pol_hold
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
` (3 preceding siblings ...)
2015-05-28 6:25 ` [PATCH 4/7] xfrm: slightly optimise xfrm_input Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 6/7] xfrm: move the checking for old xfrm_policy hold_queue to beginning Steffen Klassert
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
xfrm_pol_hold will check its input with NULL
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_policy.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index c4c47f3..435bc0d 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1127,8 +1127,8 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,
break;
}
}
- if (ret)
- xfrm_pol_hold(ret);
+
+ xfrm_pol_hold(ret);
fail:
read_unlock_bh(&net->xfrm.xfrm_policy_lock);
@@ -3211,8 +3211,7 @@ static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector *
}
}
- if (ret)
- xfrm_pol_hold(ret);
+ xfrm_pol_hold(ret);
read_unlock_bh(&net->xfrm.xfrm_policy_lock);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] xfrm: move the checking for old xfrm_policy hold_queue to beginning
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
` (4 preceding siblings ...)
2015-05-28 6:25 ` [PATCH 5/7] xfrm: remove the unnecessary checking before call xfrm_pol_hold Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-28 6:25 ` [PATCH 7/7] xfrm: optimise to search the inexact policy list Steffen Klassert
2015-05-29 3:23 ` pull request (net-next): ipsec-next 2015-05-28 David Miller
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Li RongQing <roy.qing.li@gmail.com>
if hold_queue of old xfrm_policy is NULL, return directly, then not need to
run other codes, especially take the spin lock
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_policy.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 435bc0d..3d264e5 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -700,6 +700,9 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
struct xfrm_policy_queue *pq = &old->polq;
struct sk_buff_head list;
+ if (skb_queue_empty(&pq->hold_queue))
+ return;
+
__skb_queue_head_init(&list);
spin_lock_bh(&pq->hold_queue.lock);
@@ -708,9 +711,6 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
xfrm_pol_put(old);
spin_unlock_bh(&pq->hold_queue.lock);
- if (skb_queue_empty(&list))
- return;
-
pq = &new->polq;
spin_lock_bh(&pq->hold_queue.lock);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] xfrm: optimise to search the inexact policy list
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
` (5 preceding siblings ...)
2015-05-28 6:25 ` [PATCH 6/7] xfrm: move the checking for old xfrm_policy hold_queue to beginning Steffen Klassert
@ 2015-05-28 6:25 ` Steffen Klassert
2015-05-29 3:23 ` pull request (net-next): ipsec-next 2015-05-28 David Miller
7 siblings, 0 replies; 9+ messages in thread
From: Steffen Klassert @ 2015-05-28 6:25 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
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>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: pull request (net-next): ipsec-next 2015-05-28
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
` (6 preceding siblings ...)
2015-05-28 6:25 ` [PATCH 7/7] xfrm: optimise to search the inexact policy list Steffen Klassert
@ 2015-05-29 3:23 ` David Miller
7 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2015-05-29 3:23 UTC (permalink / raw)
To: steffen.klassert; +Cc: herbert, netdev
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Thu, 28 May 2015 08:25:47 +0200
> 1) Remove xfrm_queue_purge as this is the same as skb_queue_purge.
>
> 2) Optimize policy and state walk.
>
> 3) Use a sane return code if afinfo registration fails.
>
> 4) Only check fori a acquire state if the state is not valid.
>
> 5) Remove a unnecessary NULL check before xfrm_pol_hold
> as it checks the input for NULL.
>
> 6) Return directly if the xfrm hold queue is empty, avoid
> to take a lock as it is nothing to do in this case.
>
> 7) Optimize the inexact policy search and allow for matching
> of policies with priority ~0U.
>
> All from Li RongQing.
>
> Please pull or let me know if there are problems.
Pulled, thanks Steffen.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-05-29 3:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-28 6:25 pull request (net-next): ipsec-next 2015-05-28 Steffen Klassert
2015-05-28 6:25 ` [PATCH 1/7] xfrm: remove the xfrm_queue_purge definition Steffen Klassert
2015-05-28 6:25 ` [PATCH 2/7] xfrm: optimise the use of walk list header in xfrm_policy/state_walk Steffen Klassert
2015-05-28 6:25 ` [PATCH 3/7] xfrm: fix the return code when xfrm_*_register_afinfo failed Steffen Klassert
2015-05-28 6:25 ` [PATCH 4/7] xfrm: slightly optimise xfrm_input Steffen Klassert
2015-05-28 6:25 ` [PATCH 5/7] xfrm: remove the unnecessary checking before call xfrm_pol_hold Steffen Klassert
2015-05-28 6:25 ` [PATCH 6/7] xfrm: move the checking for old xfrm_policy hold_queue to beginning Steffen Klassert
2015-05-28 6:25 ` [PATCH 7/7] xfrm: optimise to search the inexact policy list Steffen Klassert
2015-05-29 3:23 ` pull request (net-next): ipsec-next 2015-05-28 David Miller
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).