diff options
Diffstat (limited to 'net/ipv4/inet_fragment.c')
| -rw-r--r-- | net/ipv4/inet_fragment.c | 37 | 
1 files changed, 37 insertions, 0 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 484cf512858..15054eb3d4b 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -172,3 +172,40 @@ int inet_frag_evictor(struct inet_frags *f)  	return evicted;  }  EXPORT_SYMBOL(inet_frag_evictor); + +struct inet_frag_queue *inet_frag_intern(struct inet_frag_queue *qp_in, +		struct inet_frags *f, unsigned int hash) +{ +	struct inet_frag_queue *qp; +#ifdef CONFIG_SMP +	struct hlist_node *n; +#endif + +	write_lock(&f->lock); +#ifdef CONFIG_SMP +	/* With SMP race we have to recheck hash table, because +	 * such entry could be created on other cpu, while we +	 * promoted read lock to write lock. +	 */ +	hlist_for_each_entry(qp, n, &f->hash[hash], list) { +		if (f->equal(qp, qp_in)) { +			atomic_inc(&qp->refcnt); +			write_unlock(&f->lock); +			qp_in->last_in |= COMPLETE; +			inet_frag_put(qp_in, f); +			return qp; +		} +	} +#endif +	qp = qp_in; +	if (!mod_timer(&qp->timer, jiffies + f->ctl->timeout)) +		atomic_inc(&qp->refcnt); + +	atomic_inc(&qp->refcnt); +	hlist_add_head(&qp->list, &f->hash[hash]); +	list_add_tail(&qp->lru_list, &f->lru_list); +	f->nqueues++; +	write_unlock(&f->lock); +	return qp; +} +EXPORT_SYMBOL(inet_frag_intern);  |