]> git.neil.brown.name Git - history.git/commitdiff
[XFRM]: Fix policy update bug when increasing priority of last policy.
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 20 Oct 2004 14:49:52 +0000 (07:49 -0700)
committerDavid S. Miller <davem@nuts.davemloft.net>
Wed, 20 Oct 2004 14:49:52 +0000 (07:49 -0700)
Based upon a patch by Patrick McHardy.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_policy.c

index 63723042d813ba56d84c1f95e022bc89827afdc2..1708bf045a2bb1ee0494265897cd5582a2e1e343 100644 (file)
@@ -332,7 +332,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
        struct xfrm_policy **newpos = NULL;
 
        write_lock_bh(&xfrm_policy_lock);
-       for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) {
+       for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL;) {
                if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0) {
                        if (excl) {
                                write_unlock_bh(&xfrm_policy_lock);
@@ -342,8 +342,10 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
                        delpol = pol;
                        if (policy->priority > pol->priority)
                                continue;
-               } else if (policy->priority >= pol->priority)
+               } else if (policy->priority >= pol->priority) {
+                       p = &pol->next;
                        continue;
+               }
                if (!newpos)
                        newpos = p;
                if (delpol)