Commit a5bdb72d authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[XFRM]: Fix policy update bug when increasing priority of last policy.

Based upon a patch by Patrick McHardy.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2b608e5a
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment