From 9f30654d20015a51d3a644835a88dd169551f521 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 16 Jan 2007 16:52:02 -0800 Subject: [PATCH] --- yaml --- r: 45783 b: refs/heads/master c: a6c7ab55dda3e16ab5a3cf6f39585aee5876ac3a h: refs/heads/master i: 45781: fa5ce5e6e2a212de5250fc26ac4167ad00b67327 45779: c076e386e9ae30c4fedcf549fcb3a211f020f40d 45775: e6e5f30b2bdb867facfeceddcb87bb238d95e77b v: v3 --- [refs] | 2 +- trunk/net/xfrm/xfrm_policy.c | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index 3f83eb328d6f..8699baa470d8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8f1adb5f27d352c776ac34648cc277d1f8199dba +refs/heads/master: a6c7ab55dda3e16ab5a3cf6f39585aee5876ac3a diff --git a/trunk/net/xfrm/xfrm_policy.c b/trunk/net/xfrm/xfrm_policy.c index bebd40e5a62e..b7e537fe2d75 100644 --- a/trunk/net/xfrm/xfrm_policy.c +++ b/trunk/net/xfrm/xfrm_policy.c @@ -650,19 +650,18 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) struct xfrm_policy *pol; struct xfrm_policy *delpol; struct hlist_head *chain; - struct hlist_node *entry, *newpos, *last; + struct hlist_node *entry, *newpos; struct dst_entry *gc_list; write_lock_bh(&xfrm_policy_lock); chain = policy_hash_bysel(&policy->selector, policy->family, dir); delpol = NULL; newpos = NULL; - last = NULL; hlist_for_each_entry(pol, entry, chain, bydst) { - if (!delpol && - pol->type == policy->type && + if (pol->type == policy->type && !selector_cmp(&pol->selector, &policy->selector) && - xfrm_sec_ctx_match(pol->security, policy->security)) { + xfrm_sec_ctx_match(pol->security, policy->security) && + !WARN_ON(delpol)) { if (excl) { write_unlock_bh(&xfrm_policy_lock); return -EEXIST; @@ -671,17 +670,12 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) if (policy->priority > pol->priority) continue; } else if (policy->priority >= pol->priority) { - last = &pol->bydst; + newpos = &pol->bydst; continue; } - if (!newpos) - newpos = &pol->bydst; if (delpol) break; - last = &pol->bydst; } - if (!newpos) - newpos = last; if (newpos) hlist_add_after(newpos, &policy->bydst); else