xfrm: fix the xfrm_policy/state_walk
Subsystems (3)
PATCH 1/1 xfrm: fix the xfrm_policy/state_walk
From: Li RongQing <[email protected]>
If the walk from input is not empty, the following loop should start from the walk->next, since walk is list header, and the last policy in previours loop is connected walk tailor by list_move_tail()
--- net/xfrm/xfrm_policy.c | 2 +- net/xfrm/xfrm_state.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +1 -1
@@ -1004,7 +1004,7 @@ 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 ;
net/xfrm/xfrm_state.c +1 -1
@@ -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 ;
Signature · 1 line
2.1.0
Herbert Xu
maintainerQuoted 9 lines · On Wed, Apr 22, 2015 at 03:53:34PM +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
If the walk from input is not empty, the following loop should start from the
walk->next, since walk is list header, and the last policy in previours loop is connected walk tailor bylist_move_tail()Fixes 12a169e7d8f(ipsec: Put dumpers on the dump list)Cc Herbert Xu <[email protected]>Signed-off-by Li RongQing <[email protected]>
This is not a bug fix but an optimisation. The walker entries are all marked as dead and will be skipped by the loop.
However, I don't see anything wrong with this optimisation.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 8 lines · Herbert Xu
Quoted 1 line
Signed-off-by Li RongQing <[email protected]>This is not a bug fix but an optimisation. The walker entries are all marked as dead and will be skipped by the loop.
However, I don't see anything wrong with this optimisation.
Cheers,
thanks, you are right, I will rewrite the commit header
-Roy