Skip to contentSkip to conversation

xfrm: fix the xfrm_policy/state_walk

PATCH In review [email protected] 2 participants 3 messages Apr 22, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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()

Fixes 12a169e7d8f(ipsec: Put dumpers on the dump list)
Cc Herbert Xu <[email protected]>
---
 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
index d8c35ad..7a63148 100644
@@ -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
index f5e39e3..df93183 100644
@@ -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
maintainer
#1 lore raw
Quoted 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 by list_move_tail()

Fixes 12a169e7d8f(ipsec: Put dumpers on the dump list)
Cc Herbert Xu <[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
#2 lore raw
Quoted 8 lines · Herbert Xu
Quoted 1 line

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