Skip to contentSkip to conversation

xfrm: optimise the use of walk list header in xfrm_policy/state_walk

PATCH Applied [email protected] 3 participants 3 messages Apr 22, 2015 – Apr 27, 2015

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

PATCH v2 1/1 xfrm: optimise the use of walk list header in xfrm_policy/state_walk

From: Li RongQing <[email protected]>

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

---
 net/xfrm/xfrm_policy.c | 4 +++-
 net/xfrm/xfrm_state.c  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +3 -1
index d8c35ad..847053e 100644
@@ -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;
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 Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines · On Wed, Apr 22, 2015 at 05:09:54PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

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

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
maintainer Applied
#2 lore raw
Quoted 6 lines · Herbert Xu
Quoted 5 lines · On Wed, Apr 22, 2015 at 05:09:54PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

The walk from input is the list header, and marked as dead, and will be skipped in loop.

Quoted 6 lines
Quoted 4 lines

list_first_entry() can be used to return the true usable value from walk if walk is not empty

Applied to ipsec-next, thanks everyone!