]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
xfrm: optimise the use of walk list header in xfrm_policy/state_walk
authorLi RongQing <roy.qing.li@gmail.com>
Wed, 22 Apr 2015 09:09:54 +0000 (17:09 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 23 Apr 2015 09:36:06 +0000 (11:36 +0200)
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
net/xfrm/xfrm_state.c

index d8c35ad4210daabf773d9b8ae1f52d9b2b3d5176..847053ec7d91dcd8c38b49c1b25ea17a0277379e 100644 (file)
@@ -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;
index f5e39e35d73aa96c3551b0e46f9b26ab291d23aa..df9318301e981af5dc5742e8658fb6609ecc529c 100644 (file)
@@ -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;