* [PATCH][net-next][v2] xfrm: optimise the use of walk list header in xfrm_policy/state_walk
@ 2015-04-22 9:09 roy.qing.li
2015-04-22 9:13 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: roy.qing.li @ 2015-04-22 9:09 UTC (permalink / raw)
To: netdev; +Cc: steffen.klassert, herbert
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>
---
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;
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][net-next][v2] xfrm: optimise the use of walk list header in xfrm_policy/state_walk
2015-04-22 9:09 [PATCH][net-next][v2] xfrm: optimise the use of walk list header in xfrm_policy/state_walk roy.qing.li
@ 2015-04-22 9:13 ` Herbert Xu
2015-04-27 10:37 ` Steffen Klassert
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2015-04-22 9:13 UTC (permalink / raw)
To: roy.qing.li; +Cc: netdev, steffen.klassert
On Wed, Apr 22, 2015 at 05:09:54PM +0800, roy.qing.li@gmail.com wrote:
> 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>
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][net-next][v2] xfrm: optimise the use of walk list header in xfrm_policy/state_walk
2015-04-22 9:13 ` Herbert Xu
@ 2015-04-27 10:37 ` Steffen Klassert
0 siblings, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2015-04-27 10:37 UTC (permalink / raw)
To: Herbert Xu; +Cc: roy.qing.li, netdev
On Wed, Apr 22, 2015 at 05:13:18PM +0800, Herbert Xu wrote:
> On Wed, Apr 22, 2015 at 05:09:54PM +0800, roy.qing.li@gmail.com wrote:
> > 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>
Applied to ipsec-next, thanks everyone!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-27 10:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22 9:09 [PATCH][net-next][v2] xfrm: optimise the use of walk list header in xfrm_policy/state_walk roy.qing.li
2015-04-22 9:13 ` Herbert Xu
2015-04-27 10: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).