nfsd4: set shorter timeout
[safe/jmp/linux-2.6] / net / ipv4 / inet_fragment.c
index 724d69a..eaf3e2c 100644 (file)
@@ -86,7 +86,10 @@ EXPORT_SYMBOL(inet_frags_fini);
 void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
 {
        nf->low_thresh = 0;
+
+       local_bh_disable();
        inet_frag_evictor(nf, f);
+       local_bh_enable();
 }
 EXPORT_SYMBOL(inet_frags_exit_net);
 
@@ -104,10 +107,10 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
        if (del_timer(&fq->timer))
                atomic_dec(&fq->refcnt);
 
-       if (!(fq->last_in & COMPLETE)) {
+       if (!(fq->last_in & INET_FRAG_COMPLETE)) {
                fq_unlink(fq, f);
                atomic_dec(&fq->refcnt);
-               fq->last_in |= COMPLETE;
+               fq->last_in |= INET_FRAG_COMPLETE;
        }
 }
 
@@ -131,8 +134,8 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f,
        struct sk_buff *fp;
        struct netns_frags *nf;
 
-       BUG_TRAP(q->last_in & COMPLETE);
-       BUG_TRAP(del_timer(&q->timer) == 0);
+       WARN_ON(!(q->last_in & INET_FRAG_COMPLETE));
+       WARN_ON(del_timer(&q->timer) != 0);
 
        /* Release all fragment data. */
        fp = q->fragments;
@@ -174,7 +177,7 @@ int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f)
                read_unlock(&f->lock);
 
                spin_lock(&q->lock);
-               if (!(q->last_in & COMPLETE))
+               if (!(q->last_in & INET_FRAG_COMPLETE))
                        inet_frag_kill(q, f);
                spin_unlock(&q->lock);
 
@@ -189,14 +192,21 @@ EXPORT_SYMBOL(inet_frag_evictor);
 
 static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
                struct inet_frag_queue *qp_in, struct inet_frags *f,
-               unsigned int hash, void *arg)
+               void *arg)
 {
        struct inet_frag_queue *qp;
 #ifdef CONFIG_SMP
        struct hlist_node *n;
 #endif
+       unsigned int hash;
 
        write_lock(&f->lock);
+       /*
+        * While we stayed w/o the lock other CPU could update
+        * the rnd seed, so we need to re-calculate the hash
+        * chain. Fortunatelly the qp_in can be used to get one.
+        */
+       hash = f->hashfn(qp_in);
 #ifdef CONFIG_SMP
        /* With SMP race we have to recheck hash table, because
         * such entry could be created on other cpu, while we
@@ -206,7 +216,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
                if (qp->net == nf && f->match(qp, arg)) {
                        atomic_inc(&qp->refcnt);
                        write_unlock(&f->lock);
-                       qp_in->last_in |= COMPLETE;
+                       qp_in->last_in |= INET_FRAG_COMPLETE;
                        inet_frag_put(qp_in, f);
                        return qp;
                }
@@ -244,7 +254,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
 }
 
 static struct inet_frag_queue *inet_frag_create(struct netns_frags *nf,
-               struct inet_frags *f, void *arg, unsigned int hash)
+               struct inet_frags *f, void *arg)
 {
        struct inet_frag_queue *q;
 
@@ -252,16 +262,16 @@ static struct inet_frag_queue *inet_frag_create(struct netns_frags *nf,
        if (q == NULL)
                return NULL;
 
-       return inet_frag_intern(nf, q, f, hash, arg);
+       return inet_frag_intern(nf, q, f, arg);
 }
 
 struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
                struct inet_frags *f, void *key, unsigned int hash)
+       __releases(&f->lock)
 {
        struct inet_frag_queue *q;
        struct hlist_node *n;
 
-       read_lock(&f->lock);
        hlist_for_each_entry(q, n, &f->hash[hash], list) {
                if (q->net == nf && f->match(q, key)) {
                        atomic_inc(&q->refcnt);
@@ -271,6 +281,6 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
        }
        read_unlock(&f->lock);
 
-       return inet_frag_create(nf, f, key, hash);
+       return inet_frag_create(nf, f, key);
 }
 EXPORT_SYMBOL(inet_frag_find);