]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/nf_conntrack_core.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6-omap-h63xx.git] / net / netfilter / nf_conntrack_core.c
index 327e847d2702d8e647ca656b5e89db6ba2ca74fd..4eac65c74ed05ac18a504957f2dbcb721bb2014d 100644 (file)
@@ -94,7 +94,7 @@ static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple)
                                nf_conntrack_hash_rnd);
 }
 
-int
+bool
 nf_ct_get_tuple(const struct sk_buff *skb,
                unsigned int nhoff,
                unsigned int dataoff,
@@ -108,7 +108,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
 
        tuple->src.l3num = l3num;
        if (l3proto->pkt_to_tuple(skb, nhoff, tuple) == 0)
-               return 0;
+               return false;
 
        tuple->dst.protonum = protonum;
        tuple->dst.dir = IP_CT_DIR_ORIGINAL;
@@ -117,10 +117,8 @@ nf_ct_get_tuple(const struct sk_buff *skb,
 }
 EXPORT_SYMBOL_GPL(nf_ct_get_tuple);
 
-int nf_ct_get_tuplepr(const struct sk_buff *skb,
-                     unsigned int nhoff,
-                     u_int16_t l3num,
-                     struct nf_conntrack_tuple *tuple)
+bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
+                      u_int16_t l3num, struct nf_conntrack_tuple *tuple)
 {
        struct nf_conntrack_l3proto *l3proto;
        struct nf_conntrack_l4proto *l4proto;
@@ -134,7 +132,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb,
        ret = l3proto->get_l4proto(skb, nhoff, &protoff, &protonum);
        if (ret != NF_ACCEPT) {
                rcu_read_unlock();
-               return 0;
+               return false;
        }
 
        l4proto = __nf_ct_l4proto_find(l3num, protonum);
@@ -147,7 +145,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb,
 }
 EXPORT_SYMBOL_GPL(nf_ct_get_tuplepr);
 
-int
+bool
 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
                   const struct nf_conntrack_tuple *orig,
                   const struct nf_conntrack_l3proto *l3proto,
@@ -157,7 +155,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
 
        inverse->src.l3num = orig->src.l3num;
        if (l3proto->invert_tuple(inverse, orig) == 0)
-               return 0;
+               return false;
 
        inverse->dst.dir = !orig->dst.dir;
 
@@ -194,8 +192,7 @@ destroy_conntrack(struct nf_conntrack *nfct)
         * destroy_conntrack() MUST NOT be called with a write lock
         * to nf_conntrack_lock!!! -HW */
        rcu_read_lock();
-       l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num,
-                                      ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum);
+       l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
        if (l4proto && l4proto->destroy)
                l4proto->destroy(ct);
 
@@ -256,13 +253,19 @@ __nf_conntrack_find(const struct nf_conntrack_tuple *tuple)
        struct hlist_node *n;
        unsigned int hash = hash_conntrack(tuple);
 
+       /* Disable BHs the entire time since we normally need to disable them
+        * at least once for the stats anyway.
+        */
+       local_bh_disable();
        hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) {
                if (nf_ct_tuple_equal(tuple, &h->tuple)) {
                        NF_CT_STAT_INC(found);
+                       local_bh_enable();
                        return h;
                }
                NF_CT_STAT_INC(searched);
        }
+       local_bh_enable();
 
        return NULL;
 }
@@ -400,17 +403,20 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
        struct hlist_node *n;
        unsigned int hash = hash_conntrack(tuple);
 
-       rcu_read_lock();
+       /* Disable BHs the entire time since we need to disable them at
+        * least once for the stats anyway.
+        */
+       rcu_read_lock_bh();
        hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) {
                if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack &&
                    nf_ct_tuple_equal(tuple, &h->tuple)) {
                        NF_CT_STAT_INC(found);
-                       rcu_read_unlock();
+                       rcu_read_unlock_bh();
                        return 1;
                }
                NF_CT_STAT_INC(searched);
        }
-       rcu_read_unlock();
+       rcu_read_unlock_bh();
 
        return 0;
 }
@@ -730,10 +736,10 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff *skb)
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_in);
 
-int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
-                        const struct nf_conntrack_tuple *orig)
+bool nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
+                         const struct nf_conntrack_tuple *orig)
 {
-       int ret;
+       bool ret;
 
        rcu_read_lock();
        ret = nf_ct_invert_tuple(inverse, orig,
@@ -757,10 +763,10 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
        NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
 
        pr_debug("Altering reply tuple of %p to ", ct);
-       NF_CT_DUMP_TUPLE(newreply);
+       nf_ct_dump_tuple(newreply);
 
        ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
-       if (ct->master || (help && help->expecting != 0))
+       if (ct->master || (help && !hlist_empty(&help->expectations)))
                return;
 
        rcu_read_lock();