Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[linux-2.6-microblaze.git] / net / netfilter / nf_conntrack_core.c
index f4f9b83..bdfeace 100644 (file)
@@ -749,9 +749,6 @@ begin:
                        continue;
                }
 
-               if (nf_ct_is_dying(ct))
-                       continue;
-
                if (nf_ct_key_equal(h, tuple, zone, net))
                        return h;
        }
@@ -777,20 +774,24 @@ __nf_conntrack_find_get(struct net *net, const struct nf_conntrack_zone *zone,
        struct nf_conn *ct;
 
        rcu_read_lock();
-begin:
+
        h = ____nf_conntrack_find(net, zone, tuple, hash);
        if (h) {
+               /* We have a candidate that matches the tuple we're interested
+                * in, try to obtain a reference and re-check tuple
+                */
                ct = nf_ct_tuplehash_to_ctrack(h);
-               if (unlikely(nf_ct_is_dying(ct) ||
-                            !atomic_inc_not_zero(&ct->ct_general.use)))
-                       h = NULL;
-               else {
-                       if (unlikely(!nf_ct_key_equal(h, tuple, zone, net))) {
-                               nf_ct_put(ct);
-                               goto begin;
-                       }
+               if (likely(atomic_inc_not_zero(&ct->ct_general.use))) {
+                       if (likely(nf_ct_key_equal(h, tuple, zone, net)))
+                               goto found;
+
+                       /* TYPESAFE_BY_RCU recycled the candidate */
+                       nf_ct_put(ct);
                }
+
+               h = NULL;
        }
+found:
        rcu_read_unlock();
 
        return h;